From patchwork Tue Apr 2 02:27:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Daniel Kachhap X-Patchwork-Id: 10880947 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 21FF11390 for ; Tue, 2 Apr 2019 02:36:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 04925287E0 for ; Tue, 2 Apr 2019 02:36:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC9172887B; Tue, 2 Apr 2019 02:36:52 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 8A90D287E0 for ; Tue, 2 Apr 2019 02:36:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=JB6kDDC0UlLQewo8F58JWc2Utaih6i+HKLKmfzWRzQQ=; b=rTSgTUAk8lPGvGcj24Px8wU7M0 dyFAdDz9TGZJTyayaTM2Zfbl+pYry093O7Y/biP0qSeM20OjuUQCCIz2LUqUYPm249ZW4cUlnIYkZ RgoSuDAdkoK5vwe/f2bgsr4zsTikZlqLzcYwVRGImy3lER+SHE/B4Kg+lSZRYsFGs6Zdsc7XChQFp c+9Q7a3U6FKSJswXTuryReCbtpD/TAw2bIUEIXs1RXD2XwqugVUuVVAPpD3cqnoiIYUdl2ou/U+3s fg5vBNtNkfSw+IhAY4Jb9jO8fTDZpMD/UY1zDQPswIIYn5q9b7ibiXxpAiersV7TOpFeS0+hPBNuu 5y8kQW1w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hB9IA-0002OR-Nh; Tue, 02 Apr 2019 02:36:50 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hB9I8-0002KX-0U for linux-arm-kernel@bombadil.infradead.org; Tue, 02 Apr 2019 02:36:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=/pjOfyGeK78h/RxJoXbFWHE7VeJ8u+6EVywN+W+mNAw=; b=hLRRkIbDeqdUaGvqoEI07asVP uKPIu/G+i6IuTXDQEZUSTx9tnjzzZaPD5cNQ9+ns1KvJsz6Yp1MW490r3p5H1gYhv0t17mrZzawch wiLY4gT9lLyuibqhbNAIWPs92EoPvceDQcvDSza3IMaTZ2vNxuU+hSunzqWjucoUTKaP+5YTQZ5UY sLC9zg8qXdOSp9zqZpp83cDhS8/TO0hn+fzOOBYoZOmk30TtMQeIGac3ouxekEG9xs/bpwgmjEsmz BTEEawRTRzNwBjJqu3w9q0jJTHOihyT2aoMDwLosc76dRIWWS1pUsmhbce+fDAo3i3fuq90FwQxPF gdjrt6UmQ==; Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hB99u-0007fe-5X for linux-arm-kernel@lists.infradead.org; Tue, 02 Apr 2019 02:28:20 +0000 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 9B261EBD; Mon, 1 Apr 2019 19:28:16 -0700 (PDT) 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 DEDD13F59C; Mon, 1 Apr 2019 19:28:11 -0700 (PDT) From: Amit Daniel Kachhap To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v8 8/9] KVM: arm64: Add capability to advertise ptrauth for guest Date: Tue, 2 Apr 2019 07:57:16 +0530 Message-Id: <1554172037-4516-9-git-send-email-amit.kachhap@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1554172037-4516-1-git-send-email-amit.kachhap@arm.com> References: <1554172037-4516-1-git-send-email-amit.kachhap@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190402_032818_554590_ED73EEE9 X-CRM114-Status: GOOD ( 10.38 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , Andrew Jones , Julien Thierry , Marc Zyngier , Catalin Marinas , Will Deacon , Christoffer Dall , Kristina Martsenko , kvmarm@lists.cs.columbia.edu, James Morse , Ramana Radhakrishnan , Amit Daniel Kachhap , Dave Martin , linux-kernel@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP This patch advertises the capability of two cpu feature called address pointer authentication and generic pointer authentication. These capabilities depend upon system support for pointer authentication and VHE mode. The current arm64 KVM partially implements pointer authentication and support of address/generic authentication are tied together. However, separate ABI requirements for both of them is added so that the future isolated implementation will not require any ABI changes. Signed-off-by: Amit Daniel Kachhap Cc: Mark Rutland Cc: Marc Zyngier Cc: Christoffer Dall Cc: kvmarm@lists.cs.columbia.edu --- Changes since v7: * Created 2 capabilities KVM_CAP_ARM_PTRAUTH_ADDRESS and KVM_CAP_ARM_PTRAUTH_GENERIC instead of one KVM_CAP_ARM_PTRAUTH [Kristina Martsenko]. * Added documentation here itself instead of in a new patch. Documentation/virtual/kvm/api.txt | 3 +++ arch/arm64/kvm/reset.c | 6 ++++++ include/uapi/linux/kvm.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/Documentation/virtual/kvm/api.txt b/Documentation/virtual/kvm/api.txt index aaa048d..9b56892 100644 --- a/Documentation/virtual/kvm/api.txt +++ b/Documentation/virtual/kvm/api.txt @@ -2661,8 +2661,11 @@ Possible features: Depends on KVM_CAP_ARM_PMU_V3. - KVM_ARM_VCPU_PTRAUTH_ADDRESS: Enables Address Pointer authentication for the CPU and supported only on arm64 architecture. + Depends on KVM_CAP_ARM_PTRAUTH_ADDRESS. - KVM_ARM_VCPU_PTRAUTH_GENERIC: Enables Generic Pointer authentication for the CPU and supported only on arm64 architecture. + Depends on KVM_CAP_ARM_PTRAUTH_GENERIC. + More details on Documentation/arm64/pointer-authentication.txt. 4.83 KVM_ARM_PREFERRED_TARGET diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c index 717afed..8aa8982 100644 --- a/arch/arm64/kvm/reset.c +++ b/arch/arm64/kvm/reset.c @@ -92,6 +92,12 @@ int kvm_arch_vm_ioctl_check_extension(struct kvm *kvm, long ext) case KVM_CAP_ARM_VM_IPA_SIZE: r = kvm_ipa_limit; break; + case KVM_CAP_ARM_PTRAUTH_ADDRESS: + r = has_vhe() && system_supports_address_auth(); + break; + case KVM_CAP_ARM_PTRAUTH_GENERIC: + r = has_vhe() && system_supports_generic_auth(); + break; default: r = 0; } diff --git a/include/uapi/linux/kvm.h b/include/uapi/linux/kvm.h index 6d4ea4b..500ac2b 100644 --- a/include/uapi/linux/kvm.h +++ b/include/uapi/linux/kvm.h @@ -988,6 +988,8 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_ARM_VM_IPA_SIZE 165 #define KVM_CAP_MANUAL_DIRTY_LOG_PROTECT 166 #define KVM_CAP_HYPERV_CPUID 167 +#define KVM_CAP_ARM_PTRAUTH_ADDRESS 168 +#define KVM_CAP_ARM_PTRAUTH_GENERIC 169 #ifdef KVM_CAP_IRQ_ROUTING