Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp3333817imj; Tue, 19 Feb 2019 01:26:44 -0800 (PST) X-Google-Smtp-Source: AHgI3IaAiTCFAF2ghlYMWfQAqnKIVhkoqCnqqdclf3nihwXyxX1P5O+y9rVI1LUEuS9HVLXOdRtw X-Received: by 2002:a62:bd17:: with SMTP id a23mr28154996pff.233.1550568404086; Tue, 19 Feb 2019 01:26:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550568404; cv=none; d=google.com; s=arc-20160816; b=g8KATzZTQoJkLZnvoTxDHegyLmr1RaxIXG98YZln76FijiO1IsUVUZAWiE9XHXxSA9 sLyhWUfTxDXsKnTZ91GiqpPliAc2rEvPWs+2CDi/dSuqRuljRucw9XGfjf/JuSTqJRJs rp3/2JaroIt/xwXaIOVG+NukWKAyrav5t2veS1fFSDF15tZPUO+YhEJYiDOYHtW8kNmm hl9DqwwHQ8PBxbU/OpqB/93CXyzW//qpIlaq2Byeu9LyufLDeTE5lByCcf6LztpEBqam Ydc2+SHJJDEt+B9hREuSWyyoI+wsZk9kCG3XTWFqCoJszo1MidNe9iVT9vTfixFTHFRC KsEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=rVdzrpe1UwV1mAzVlFiPMFEV7FmsIjCijwqrDKCr9nA=; b=F+D9OxiSLqwzdgYK+3a9L5xozFbwvAK/9nXHRmmFpb7FPlFMQolak2c4mx2tQNvY5c ODaOwgjUoI+EUdc5nF40Q9M4dj3rCbDeg7fiYKiYy7vSEBMtN7UzOC5skKa/pF+Wy9TI szPOU+SddP8bjSpXvw7L69b17JHzHwM9UM2N7Y/kxP9xTgwb6FasHy8SlIV5e6Ko+bLz glm4awyvB885e0yPt6I2qU9ikKSKxdJ4Kg+m70tG5COQEKiw/32SZznawqSDyI7iphcD ZVRc7Wxuz18YFJDi8PTg86qynC1lQL9RcE4neNxLpwCQyUeKiokhbxR2eMux0RCMFw43 6JKw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k64si14816166pgc.303.2019.02.19.01.26.28; Tue, 19 Feb 2019 01:26:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726814AbfBSJZb (ORCPT + 99 others); Tue, 19 Feb 2019 04:25:31 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:42640 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728189AbfBSJZ3 (ORCPT ); Tue, 19 Feb 2019 04:25:29 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 2F4EE1596; Tue, 19 Feb 2019 01:25:25 -0800 (PST) Received: from a075553-lin.blr.arm.com (a075553-lin.blr.arm.com [10.162.0.144]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id E45713F675; Tue, 19 Feb 2019 01:25:15 -0800 (PST) From: Amit Daniel Kachhap To: linux-arm-kernel@lists.infradead.org Cc: Christoffer Dall , Marc Zyngier , Catalin Marinas , Will Deacon , Andrew Jones , Dave Martin , Ramana Radhakrishnan , kvmarm@lists.cs.columbia.edu, Kristina Martsenko , linux-kernel@vger.kernel.org, Amit Daniel Kachhap , Mark Rutland , James Morse , Julien Thierry Subject: [PATCH v6 5/6] arm64/kvm: control accessibility of ptrauth key registers Date: Tue, 19 Feb 2019 14:54:30 +0530 Message-Id: <1550568271-5319-6-git-send-email-amit.kachhap@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1550568271-5319-1-git-send-email-amit.kachhap@arm.com> References: <1550568271-5319-1-git-send-email-amit.kachhap@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org According to userspace settings, ptrauth key registers are conditionally present in guest system register list based on user specified flag KVM_ARM_VCPU_PTRAUTH. Reset routines still sets these registers to default values but they are left like that as they are conditionally accessible (set/get). Signed-off-by: Amit Daniel Kachhap Cc: Mark Rutland Cc: Marc Zyngier Cc: Christoffer Dall Cc: kvmarm@lists.cs.columbia.edu --- This patch needs patch [1] by Dave Martin and adds feature to manage accessibility in a scalable way. [1]: https://lore.kernel.org/linux-arm-kernel/1547757219-19439-13-git-send-email-Dave.Martin@arm.com/ Documentation/arm64/pointer-authentication.txt | 4 ++++ arch/arm64/kvm/sys_regs.c | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Documentation/arm64/pointer-authentication.txt b/Documentation/arm64/pointer-authentication.txt index 0529a7d..996e435 100644 --- a/Documentation/arm64/pointer-authentication.txt +++ b/Documentation/arm64/pointer-authentication.txt @@ -87,3 +87,7 @@ created by passing a flag (KVM_ARM_VCPU_PTRAUTH) requesting this feature to be enabled. Without this flag, pointer authentication is not enabled in KVM guests and attempted use of the feature will result in an UNDEFINED exception being injected into the guest. + +Additionally, when KVM_ARM_VCPU_PTRAUTH is not set then KVM will filter +out the Pointer Authentication system key registers from KVM_GET/SET_REG_* +ioctls. diff --git a/arch/arm64/kvm/sys_regs.c b/arch/arm64/kvm/sys_regs.c index f7bcc60..c2f4974 100644 --- a/arch/arm64/kvm/sys_regs.c +++ b/arch/arm64/kvm/sys_regs.c @@ -1005,8 +1005,13 @@ static bool trap_ptrauth(struct kvm_vcpu *vcpu, return false; } +static bool check_ptrauth(const struct kvm_vcpu *vcpu, const struct sys_reg_desc *rd) +{ + return kvm_arm_vcpu_ptrauth_allowed(vcpu); +} + #define __PTRAUTH_KEY(k) \ - { SYS_DESC(SYS_## k), trap_ptrauth, reset_unknown, k } + { SYS_DESC(SYS_## k), trap_ptrauth, reset_unknown, k , .check_present = check_ptrauth} #define PTRAUTH_KEY(k) \ __PTRAUTH_KEY(k ## KEYLO_EL1), \ -- 2.7.4