From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AD2824B34; Mon, 19 Feb 2024 09:20:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708334425; cv=none; b=XuiEsbiEXrXvBqhafroa6apwNYjhJWOiYjRTz0zdqkVlQlpUbQJp91/qaY88TCZHznbSsJ7hbENQRKitBCcfhQ1V1VibaUDla6AWdSqhyLkgBSaXgmymNKeBXl9bXV4huJ/ziQZNLZ8ZPaXqrmNCPxh0FYWT5Hudm9xPA5OtiKQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708334425; c=relaxed/simple; bh=63HmN5bCw4yV1qIue0vyjz/ZbDoxT4DvgQFZU7t3gk4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LinVRoqzdfl5Pn49BufVmyiV7EEIHrEWYQRdpryBzp00OfAs8YQPvi/CH3ot3JqkVRyj/F4w259Ir9Ii+EPZHA7jCDT1RGtbDN2lM0hyJEbFR7It+wASobmYzCKJJdD/eB9KA/sMcCDj17yTkT0ebxf4nv8CHVt6WE8sx+YIeSE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Dxjk0cVz; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Dxjk0cVz" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 357C2C43390; Mon, 19 Feb 2024 09:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708334425; bh=63HmN5bCw4yV1qIue0vyjz/ZbDoxT4DvgQFZU7t3gk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dxjk0cVz0HulajUHnGT6D+sHWDAhmbx36//4etWG2bCziQ6290kACEQiJTZzpxlHk bmXzKICBXa4BqZprEGfH1Dph4I9NwAFWV6KAqwwR196J+Hj85eVQp8aXJPC5kVV7CF jaWnFBLhXcZdMW0+l8V8yRu5GmfJMqvzE5Trsu6j7fwlyjR+sQOHGHvhsmwzQk6mIf cuZem1XUawDmLrO0q5PTqm5BbJE9hrHMCFVauTL7W2zijmMSM2pX90s78uir6Uge4X 4DWI4Y5p1ZwtMpPVBsLxvL1hkVS4ns+Fj3cHpRhlwVkobQrWVWsss3dQWaNqtboTmM oc01fHe2QKIPw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rbzp1-004WBZ-B5; Mon, 19 Feb 2024 09:20:23 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Will Deacon , Catalin Marinas Subject: [PATCH 10/13] KVM: arm64: nv: Add kvm_has_pauth() helper Date: Mon, 19 Feb 2024 09:20:11 +0000 Message-Id: <20240219092014.783809-11-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219092014.783809-1-maz@kernel.org> References: <20240219092014.783809-1-maz@kernel.org> Precedence: bulk X-Mailing-List: kvmarm@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, will@kernel.org, catalin.marinas@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Pointer Authentication comes in many flavors, and a faithful emulation relies on correctly handling the flavour implemented by the HW. For this, provide a new kvm_has_pauth() that checks whether we expose to the guest a particular level of support. This checks across all 3 possible authentication algorithms (Q5, Q3 and IMPDEF). Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_host.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 75eb8e170515..a97b092b7064 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -1334,4 +1334,19 @@ bool kvm_arm_vcpu_stopped(struct kvm_vcpu *vcpu); (get_idreg_field((kvm), id, fld) >= expand_field_sign(id, fld, min) && \ get_idreg_field((kvm), id, fld) <= expand_field_sign(id, fld, max)) +/* Check for a given level of PAuth support */ +#define kvm_has_pauth(k, l) \ + ({ \ + bool pa, pi, pa3; \ + \ + pa = kvm_has_feat((k), ID_AA64ISAR1_EL1, APA, l); \ + pa &= kvm_has_feat((k), ID_AA64ISAR1_EL1, GPA, IMP); \ + pi = kvm_has_feat((k), ID_AA64ISAR1_EL1, API, l); \ + pi &= kvm_has_feat((k), ID_AA64ISAR1_EL1, GPI, IMP); \ + pa3 = kvm_has_feat((k), ID_AA64ISAR2_EL1, APA3, l); \ + pa3 &= kvm_has_feat((k), ID_AA64ISAR2_EL1, GPA3, IMP); \ + \ + (pa + pi + pa3) == 1; \ + }) + #endif /* __ARM64_KVM_HOST_H__ */ -- 2.39.2 From mboxrd@z Thu Jan 1 00:00:00 1970 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 63744C54764 for ; Mon, 19 Feb 2024 09:21:17 +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=yIxmUrHou+LZKvRpqllc3mfbZjFTKfqA24LU39bhMMI=; b=SPMcM/024NWZyR b2CGUPHKq4HFLyi8zYKJzdf5RHkE/D5V2Rc0vcmw7RqngX5ve9G8FdtS2H2dyHnWgOTECo0nKBHdP 8E+j0aakKTyH3goVMLvVKD1fOYoitNiCWClLduepk+/9mK+KkAiqHETWmJxPqSt6dOYpAUbajYk5a OC6ji6WvNhj55467Zguvc0U1p8GClTkacdPbd0LiqzHZzvNQ/2XTyvDSkoPAzlJS2VLXjlj6bZ7kB ++4XNdZLW8syHsZFUJejTZssb2sTplaqrFdE2DcwWbhqUOx+IIao7GUyR/u+jjRIbG+KR3f3z63+y krjgLjXafRNsX114Gv+Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbzpd-00000009mIn-0l76; Mon, 19 Feb 2024 09:21:01 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rbzp4-00000009lxm-3h8j for linux-arm-kernel@lists.infradead.org; Mon, 19 Feb 2024 09:20:28 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6DA5F60C75; Mon, 19 Feb 2024 09:20:25 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 357C2C43390; Mon, 19 Feb 2024 09:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708334425; bh=63HmN5bCw4yV1qIue0vyjz/ZbDoxT4DvgQFZU7t3gk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Dxjk0cVz0HulajUHnGT6D+sHWDAhmbx36//4etWG2bCziQ6290kACEQiJTZzpxlHk bmXzKICBXa4BqZprEGfH1Dph4I9NwAFWV6KAqwwR196J+Hj85eVQp8aXJPC5kVV7CF jaWnFBLhXcZdMW0+l8V8yRu5GmfJMqvzE5Trsu6j7fwlyjR+sQOHGHvhsmwzQk6mIf cuZem1XUawDmLrO0q5PTqm5BbJE9hrHMCFVauTL7W2zijmMSM2pX90s78uir6Uge4X 4DWI4Y5p1ZwtMpPVBsLxvL1hkVS4ns+Fj3cHpRhlwVkobQrWVWsss3dQWaNqtboTmM oc01fHe2QKIPw== Received: from sofa.misterjones.org ([185.219.108.64] helo=valley-girl.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rbzp1-004WBZ-B5; Mon, 19 Feb 2024 09:20:23 +0000 From: Marc Zyngier To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: James Morse , Suzuki K Poulose , Oliver Upton , Zenghui Yu , Will Deacon , Catalin Marinas Subject: [PATCH 10/13] KVM: arm64: nv: Add kvm_has_pauth() helper Date: Mon, 19 Feb 2024 09:20:11 +0000 Message-Id: <20240219092014.783809-11-maz@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219092014.783809-1-maz@kernel.org> References: <20240219092014.783809-1-maz@kernel.org> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: kvmarm@lists.linux.dev, kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, suzuki.poulose@arm.com, oliver.upton@linux.dev, yuzenghui@huawei.com, will@kernel.org, catalin.marinas@arm.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240219_012027_043184_151DD8CD X-CRM114-Status: GOOD ( 10.29 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Pointer Authentication comes in many flavors, and a faithful emulation relies on correctly handling the flavour implemented by the HW. For this, provide a new kvm_has_pauth() that checks whether we expose to the guest a particular level of support. This checks across all 3 possible authentication algorithms (Q5, Q3 and IMPDEF). Signed-off-by: Marc Zyngier --- arch/arm64/include/asm/kvm_host.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index 75eb8e170515..a97b092b7064 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -1334,4 +1334,19 @@ bool kvm_arm_vcpu_stopped(struct kvm_vcpu *vcpu); (get_idreg_field((kvm), id, fld) >= expand_field_sign(id, fld, min) && \ get_idreg_field((kvm), id, fld) <= expand_field_sign(id, fld, max)) +/* Check for a given level of PAuth support */ +#define kvm_has_pauth(k, l) \ + ({ \ + bool pa, pi, pa3; \ + \ + pa = kvm_has_feat((k), ID_AA64ISAR1_EL1, APA, l); \ + pa &= kvm_has_feat((k), ID_AA64ISAR1_EL1, GPA, IMP); \ + pi = kvm_has_feat((k), ID_AA64ISAR1_EL1, API, l); \ + pi &= kvm_has_feat((k), ID_AA64ISAR1_EL1, GPI, IMP); \ + pa3 = kvm_has_feat((k), ID_AA64ISAR2_EL1, APA3, l); \ + pa3 &= kvm_has_feat((k), ID_AA64ISAR2_EL1, GPA3, IMP); \ + \ + (pa + pi + pa3) == 1; \ + }) + #endif /* __ARM64_KVM_HOST_H__ */ -- 2.39.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel