From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4864:20::143; helo=mail-it1-x143.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it1-x143.google.com (mail-it1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id CA8CC21A07A92 for ; Wed, 23 Jan 2019 08:17:09 -0800 (PST) Received: by mail-it1-x143.google.com with SMTP id a6so3711697itl.4 for ; Wed, 23 Jan 2019 08:17:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1l8m5uhmC3VG4PsdSVsgAMvOkfPFU2veq3Sv5EhGm30=; b=faghufPcnr3jrlUuzTCBwg6PnziW1/cqNaNtOKFkMJXGtVqD7AV5OkrENZCe1AUBg9 IQoXMXJVQAQOkSf0FuifNh+G4gnkIMVXswqwhd+AaUhNZvmHoC9V3NCZ6YC9mmZRP6qZ XD7YTaJjrd3s1t7z/k9ROmlISpHXrfy1EJFLc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1l8m5uhmC3VG4PsdSVsgAMvOkfPFU2veq3Sv5EhGm30=; b=YOg3b70LKe2WwRwSfYJRCmwQgxIDQ6f5CoI7LaXO2JLeI+lmolulAno/Rn7yhznLil g3w895beruTyIGkwueSqNAeQJZ0xG+mDsuq7lBdRlvOoqSe27xV1ETgSCUJW60MIztAP /oFTUBpeVJx6ZQhp5qhTxvt+XvuJXA2ez6bMVI/OY8s3qW11nyQD8c9trgWinLBI8J8V pUYlJxH/kebBZvfKNVtNkPoNdcFsiDLthzpJnfCH5vnKnIuAIhR+eEPJTuizrJwLPvyt 5UmUZHF98rWkLBjgnrtieR920CHzBDNV2Ua/7vPWIbhOV8cxQAtJBIRdsB4PLBuQGEkl oMFA== X-Gm-Message-State: AHQUAubeyEay9aokAq7FB2l+D7d6sQiH9GJ+B5is3y6Nyum4OlsEg4X/ 8yS2wrr4eTJPWnsxmPLhEqZHm2qu/CExWlGsHMmGwA== X-Google-Smtp-Source: AHgI3IbV6gBQgUguDCvAmoOUerzjqkoytEHwQAaskBjdMXmcKqCKRp75Fnc7e/6KddIc8ccsYLL0mXP9bX4zUg/LWu4= X-Received: by 2002:a24:edc4:: with SMTP id r187mr2189733ith.158.1548260229083; Wed, 23 Jan 2019 08:17:09 -0800 (PST) MIME-Version: 1.0 References: <20190107071504.2431-1-ard.biesheuvel@linaro.org> <20190107071504.2431-3-ard.biesheuvel@linaro.org> <20190123154622.pibw6mi5gh6ywb26@bivouac.eciton.net> <20190123161257.nydm3s5c27oibn6e@bivouac.eciton.net> In-Reply-To: <20190123161257.nydm3s5c27oibn6e@bivouac.eciton.net> From: Ard Biesheuvel Date: Wed, 23 Jan 2019 17:16:57 +0100 Message-ID: To: Leif Lindholm Cc: "edk2-devel@lists.01.org" Subject: Re: [PATCH 2/5] ArmPkg/ArmMmuLib AARCH64: get rid of needless TLB invalidation X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 Jan 2019 16:17:10 -0000 Content-Type: text/plain; charset="UTF-8" On Wed, 23 Jan 2019 at 17:13, Leif Lindholm wrote: > > On Wed, Jan 23, 2019 at 04:55:28PM +0100, Ard Biesheuvel wrote: > > On Wed, 23 Jan 2019 at 16:46, Leif Lindholm wrote: > > > > > > On Mon, Jan 07, 2019 at 08:15:01AM +0100, Ard Biesheuvel wrote: > > > > Currently, we always invalidate the TLBs entirely after making > > > > any modification to the page tables. Now that we have introduced > > > > strict memory permissions in quite a number of places, such > > > > modifications occur much more often, and it is better for performance > > > > to flush only those TLB entries that are actually affected by > > > > the changes. > > > > > > > > Contributed-under: TianoCore Contribution Agreement 1.1 > > > > Signed-off-by: Ard Biesheuvel > > > > --- > > > > ArmPkg/Include/Library/ArmMmuLib.h | 3 ++- > > > > ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S | 6 +++--- > > > > ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 16 +++++++--------- > > > > ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibReplaceEntry.S | 14 ++++++++------ > > > > 4 files changed, 20 insertions(+), 19 deletions(-) > > > > > > > > diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c > > > > index d66df3e17a02..e1fabfcbea14 100644 > > > > --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c > > > > +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c > > > > @@ -129,13 +129,14 @@ STATIC > > > > VOID > > > > ReplaceLiveEntry ( > > > > IN UINT64 *Entry, > > > > - IN UINT64 Value > > > > + IN UINT64 Value, > > > > + IN UINT64 Address > > > > ) > > > > { > > > > if (!ArmMmuEnabled ()) { > > > > *Entry = Value; > > > > } else { > > > > - ArmReplaceLiveTranslationEntry (Entry, Value); > > > > + ArmReplaceLiveTranslationEntry (Entry, Value, Address); > > > > } > > > > } > > > > > > > > @@ -296,7 +297,8 @@ GetBlockEntryListFromAddress ( > > > > > > > > // Fill the BlockEntry with the new TranslationTable > > > > ReplaceLiveEntry (BlockEntry, > > > > - ((UINTN)TranslationTable & TT_ADDRESS_MASK_DESCRIPTION_TABLE) | TableAttributes | TT_TYPE_TABLE_ENTRY); > > > > + (UINTN)TranslationTable | TableAttributes | TT_TYPE_TABLE_ENTRY, > > > > + RegionStart); > > > > > > > /me pages in the data ... > > > > > OK, this whole patch took a few times around the loop before I think I > > > caught on what was happening. > > > > > > I think I'm down to the only things confusing me being: > > > - The name "Address" to refer to something that is always the start > > > address of a 4KB-aligned translation region. > > > Is this because the function will be usable in other contexts in > > > later patches? > > > > I could change it to VirtualAddress if you prefer. > > It is only passed > > for TLB maintenance which is only needed at page granularity, and the > > low bits are shifted out anyway. > > Yeah, exactly. It would just be nice if the name reflected that. Not > sure VirtualAddress does. VirtualBase? PageBase? > Well, the argument passed in is called RegionStart, so let's just stick with that. > > > - Why drop the & TT_ADDRESS_MASK_DESCRIPTION_TABLE bit here? > > > Was it just always pointless and you decided to drop it while you > > > were at it? > > > > IIRC yes. It is a newly allocated page, so the masking does not do anything. > > Yeah, that's fair enough. > Just made me wonder if anything unobvious was going on :) > > / > Leif