From patchwork Mon Jul 26 09:28:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quentin Perret X-Patchwork-Id: 12398935 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8E13C4338F for ; Mon, 26 Jul 2021 09:33:19 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B0F8C60F02 for ; Mon, 26 Jul 2021 09:33:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B0F8C60F02 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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:Cc:To:From:Subject:References: Mime-Version:Message-Id:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=gYdvdGh+FCZER1mSLpEvMG9aRAbpUyWByGtgLf/caRE=; b=qIWMbhf1Bqsb6QoCf3A6rDnC2b u90B1i6CccQGc2ebhQ+srp8yGb92uA/1g2u0rmKygu4y8MYdo2TsIyp8ENdMWBTSNb7zf0TKwmKFa KDIt6P2VARMAeK+ukDsf6X0rELNLRb6bSol4a1hTQNBdxg5vqyLyHVjVSyXIC8hQryFopGh3fXVL0 QYaMP7OWoSh/MudAk6JGHroxhk6Qy64nh1K35PcrCgB8Blx+olgenu/Bh834IZ+imuQ4bPhvzcfD0 rPoLr6bQT7KY0bY6Xbe7Q7azrW+RfPyvID1hQziKdDdS9SKFj/GWqhyDzbPtrJC4m/uDAtDE7J4F7 yf8s+KPg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m7wxJ-00ASHM-K7; Mon, 26 Jul 2021 09:31:26 +0000 Received: from mail-qv1-xf49.google.com ([2607:f8b0:4864:20::f49]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m7wvO-00ARXw-NG for linux-arm-kernel@lists.infradead.org; Mon, 26 Jul 2021 09:29:28 +0000 Received: by mail-qv1-xf49.google.com with SMTP id t4-20020a0cef040000b02902e2f9404330so7876020qvr.9 for ; Mon, 26 Jul 2021 02:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=xhqFHmC/x7AnH8ZRcl4l1dWbyNuPeqmFIi1qz6ztr7w=; b=ky9L1rdM2E3/pnvC1byWpnnDrketwgcUM2bCx8+9oPsj/Yt617M9WBkhR3Ympi/l4L VTeD1nruEtGe4LWOp3GLcU+7LstB63zkiS4nWY8QanDvEdLTpsDsMTSnXOla07D8Y4LE CKd5U8AUGdUjttxk0FKMZofS9v9BiNVjLm3R2YTEuFvxA2hECbp42flWzlsfaVnzYCaW ff1fKfwwzoN8osSFvI3OV/+2ArYR9Z0WC5vtT3Q8fMLNmb0YI3GsjsikhLyr2K4YGhdV OtFyNK5p9iKQ8eOXfzV9kQ58g82+/f5r/bb15bcMbUTlfDrVHghBIyXO41eZuDmkB84i dKbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=xhqFHmC/x7AnH8ZRcl4l1dWbyNuPeqmFIi1qz6ztr7w=; b=mh8b+Hs/KvNtFxuv4OGXQ39BvEe6Mxojeb2dkKzM02EHbBlmw9q3XRQeH/3UiU/v1C 7LopjHvWdy1oajnOLsf7Dsgob/tDBx6leLNAsGYIETIoblEcNiqr1/ebtQYLto1v7Yf5 B0aRj6t2VZvLOtIocsPZ9LT/JtKevOLrHHgYh+/N/s5VgD1OlahXCH4/FPcahQDixftT sLdQX5l40ZcSHgCzqTxJfeX/bqu8TiLn5jrv8YaqkWHi/Pv1hUK/UCC7ITvmgUD4vTne xV8folcc8FjB6HLbNxdrcLj69KQmM3Sq0Nu951UG1EDT8GN2GYfOVVukG7Et0gdZuk4B p29w== X-Gm-Message-State: AOAM532QFaTjQA/IbmsIM3SC48sQ09wIM5Q9Nal6Y1Z5/SmDSut/yUKu t1KmnI84ksJdZtBzJ8a68vHo0n+s804M X-Google-Smtp-Source: ABdhPJw4miv6yKMoP660KkuAQKoQs6QJrbWUOze6sSCFx/jyqDsnRSbtfSCLwuMOdKieMRJBqFuxCCiKdHzU X-Received: from luke.lon.corp.google.com ([2a00:79e0:d:210:23a0:2f14:433:e6cb]) (user=qperret job=sendgmr) by 2002:a0c:fbd1:: with SMTP id n17mr17016888qvp.19.1627291764500; Mon, 26 Jul 2021 02:29:24 -0700 (PDT) Date: Mon, 26 Jul 2021 10:28:55 +0100 In-Reply-To: <20210726092905.2198501-1-qperret@google.com> Message-Id: <20210726092905.2198501-7-qperret@google.com> Mime-Version: 1.0 References: <20210726092905.2198501-1-qperret@google.com> X-Mailer: git-send-email 2.32.0.432.gabb21c7263-goog Subject: [PATCH v2 06/16] KVM: arm64: Don't overwrite software bits with owner id From: Quentin Perret To: maz@kernel.org, james.morse@arm.com, alexandru.elisei@arm.com, suzuki.poulose@arm.com, catalin.marinas@arm.com, will@kernel.org Cc: linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, linux-kernel@vger.kernel.org, ardb@kernel.org, qwandor@google.com, tabba@google.com, dbrazdil@google.com, kernel-team@android.com, Quentin Perret X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210726_022926_816139_869DE9F8 X-CRM114-Status: GOOD ( 14.06 ) 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 We will soon start annotating page-tables with new flags to track shared pages and such, and we will do so in valid mappings using software bits in the PTEs, as provided by the architecture. However, it is possible that we will need to use those flags to annotate invalid mappings as well in the future, similar to what we do to track page ownership in the host stage-2. In order to facilitate the annotation of invalid mappings with such flags, it would be preferable to re-use the same bits as for valid mappings (bits [58-55]), but these are currently used for ownership encoding. Since we have plenty of bits left to use in invalid mappings, move the ownership bits further down the PTE to avoid the conflict. Signed-off-by: Quentin Perret --- arch/arm64/kvm/hyp/pgtable.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kvm/hyp/pgtable.c b/arch/arm64/kvm/hyp/pgtable.c index 516c1b8ce6b8..b5ca21b44b6a 100644 --- a/arch/arm64/kvm/hyp/pgtable.c +++ b/arch/arm64/kvm/hyp/pgtable.c @@ -49,7 +49,7 @@ KVM_PTE_LEAF_ATTR_LO_S2_S2AP_W | \ KVM_PTE_LEAF_ATTR_HI_S2_XN) -#define KVM_INVALID_PTE_OWNER_MASK GENMASK(63, 56) +#define KVM_INVALID_PTE_OWNER_MASK GENMASK(9, 2) #define KVM_MAX_OWNER_ID 1 struct kvm_pgtable_walk_data {