From patchwork Wed Jan 11 00:02:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver Upton X-Patchwork-Id: 13095777 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B702DC46467 for ; Wed, 11 Jan 2023 00:04:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Zlq1M9V+RRWcNqzaIPdc0GXTrOg6faQAQegmeFK8ip8=; b=plya9h+GlFDs/d c+s/Zvv3jeXfO+yM+xDmuarnnT7wrVDJ+tJMEn0+TSgOooMkGiBvMDHAbMo4HLvjK5ikOPzJwVVWK n18cKGg8zjNyFjI2wlTAmOhp5JgUaN8ETyh1gc7YRKa0Y9AhOwY3tJ4XI7jxraijfJpB3nYvlSu67 x9fghzQScYVGOC7AuMfi9e80Wvqde6qT2erBBjs84JT4mKJxQrQuCstAyNJ1hoVIowG3QOq6Xlb5D DaBSUKdKq2vZJEXfjpAZDZB+alUydbjFRwFR2OBVJsCQVSzQVgl4IuTU0C2FSLyGpB/TgRpDmWsM0 PDTFo/4TQWl42GHAJZCg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFOaq-008yAu-VR; Wed, 11 Jan 2023 00:03:49 +0000 Received: from out-246.mta0.migadu.com ([91.218.175.246]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pFOag-008y7T-VI for linux-arm-kernel@lists.infradead.org; Wed, 11 Jan 2023 00:03:40 +0000 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1673395415; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dAXX/LNlPU0/7x/WB4sHfAEpk6aprKisr31vwb0y/J8=; b=rVdEIqr8nA4DZ0XZnB6dpg6NqL8ss9zcS6ljQu0ScAqDn7Ex0/tR+GZUXTBrnHfQDj3JkE ZftP2b2B3vJtXev9rt83En5kutZG7+iIa7S9lyOAGHvua4rNBcnxXq1THmnR63aVDn2wnE Cx5chH2cJisrpGtaLO37mctfcSrepu4= From: Oliver Upton To: Marc Zyngier , James Morse Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.linux.dev, Quentin Perret , Will Deacon , Reiji Watanabe , Oliver Upton Subject: [PATCH 2/5] KVM: arm64: Add a mask for all leaf PTE attributes Date: Wed, 11 Jan 2023 00:02:57 +0000 Message-Id: <20230111000300.2034799-3-oliver.upton@linux.dev> In-Reply-To: <20230111000300.2034799-1-oliver.upton@linux.dev> References: <20230111000300.2034799-1-oliver.upton@linux.dev> MIME-Version: 1.0 X-Migadu-Flow: FLOW_OUT X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230110_160339_172102_8B47CCA2 X-CRM114-Status: UNSURE ( 9.65 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org No functional change intended. Signed-off-by: Oliver Upton --- arch/arm64/include/asm/kvm_pgtable.h | 3 +++ arch/arm64/kvm/hyp/pgtable.c | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/kvm_pgtable.h b/arch/arm64/include/asm/kvm_pgtable.h index 8071698cc680..f8f6b4d2735a 100644 --- a/arch/arm64/include/asm/kvm_pgtable.h +++ b/arch/arm64/include/asm/kvm_pgtable.h @@ -73,6 +73,9 @@ typedef u64 kvm_pte_t; KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W | \ KVM_PTE_LEAF_ATTR_HI_S2_XN) +#define KVM_PTE_LEAF_ATTRS (KVM_PTE_LEAF_ATTR_LO | \ + KVM_PTE_LEAF_ATTR_HI) + #define KVM_PTE_ADDR_MASK GENMASK(47, PAGE_SHIFT) #define KVM_PTE_ADDR_51_48 GENMASK(15, 12) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 3efe3aca3cb9..26f61462527d 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -111,7 +111,7 @@ static kvm_pte_t kvm_init_valid_leaf_pte(u64 pa, kvm_pte_t attr, u32 level) u64 type = (level == KVM_PGTABLE_MAX_LEVELS - 1) ? KVM_PTE_TYPE_PAGE : KVM_PTE_TYPE_BLOCK; - pte |= attr & (KVM_PTE_LEAF_ATTR_LO | KVM_PTE_LEAF_ATTR_HI); + pte |= attr & KVM_PTE_LEAF_ATTRS; pte |= FIELD_PREP(KVM_PTE_TYPE, type); pte |= KVM_PTE_VALID; @@ -1027,10 +1027,9 @@ static int stage2_update_leaf_attrs(struct kvm_pgtable *pgt, u64 addr, u32 *level, enum kvm_pgtable_walk_flags flags) { int ret; - kvm_pte_t attr_mask = KVM_PTE_LEAF_ATTR_LO | KVM_PTE_LEAF_ATTR_HI; struct stage2_attr_data data = { - .attr_set = attr_set & attr_mask, - .attr_clr = attr_clr & attr_mask, + .attr_set = attr_set & KVM_PTE_LEAF_ATTRS, + .attr_clr = attr_clr & KVM_PTE_LEAF_ATTRS, }; struct kvm_pgtable_walker walker = { .cb = stage2_attr_walker,