Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp1161034img; Tue, 19 Mar 2019 01:32:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqz6OhMjBkpiSaQ9lvKOUElnVM68M8pB81oQkVUHlWLgTzW6lYAb3x45ax1kmDs13UJuEYDx X-Received: by 2002:a62:69c3:: with SMTP id e186mr738845pfc.169.1552984369441; Tue, 19 Mar 2019 01:32:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552984369; cv=none; d=google.com; s=arc-20160816; b=Q1Q7J2tBpn4Eh8dN3brNJ1OOcSpRDqZTZygF3ikVEGe3xknmyxWC1rMGeHfptwdDiU nEyCTCyWeQU/m8yKYA3vInQzQ4z7l3zgF1cC9IW2BV0PBY9JNyNB/U4UWh2Wq8O2H8u2 LGSMu2nXhcZUE+Z8YxAZT9nlrvQdgqgndWzJBBnmq81StC0gH9MWERurgYw+mJGoXpQM 7WYYwwqOBm5otJtSebULNdH20KBSM1VeXpAhkSVzyJYVnEj4jkqEzZCKaDfW/9RwXBKQ S2RKzJmwulWIKi4V1a8/KjcXIyLz5jU/b3fdvhdGItcM1jsRN+w7SbfEQhXMcAUwkeqB Llzw== 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=0S6B96om8JzECB1sL7WtA+nVv7ZMf0IcST5sAmxKXLU=; b=q9I9+C/jfrFRziKcR4GWnGhbYMj3hmXRRvqJyPFnyLNeQPer+maJPLMF0pIC+LuwOW KHZyoSni0Ef6WWlCER06IDGKkIN8HshDFC9q4HU5f65cVviPG4OV0elh5xOi45nGnmSZ 53K8eciHNK1b92+l49nVnA3/gb9CwhsxYI/06fxLNT+kaqhMBcDmNLFLsYI1uI0sKk6T ud12tmLDz5ZBoBS8TPGVWscSYY8UqqEZ6snOMDkrO/Wz11XQEYyU3ipCzqCqkj6AtrQK N0gp1jsNclND9xoOIQhgw4bFswjS6N/P2YUNG9jLzDwAJOQp9Yx6Jj1OAVuRZrk7jUAm FxDA== 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 o2si10820638pgh.565.2019.03.19.01.32.34; Tue, 19 Mar 2019 01:32:49 -0700 (PDT) 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 S1727656AbfCSIbj (ORCPT + 99 others); Tue, 19 Mar 2019 04:31:39 -0400 Received: from foss.arm.com ([217.140.101.70]:47034 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725934AbfCSIbi (ORCPT ); Tue, 19 Mar 2019 04:31:38 -0400 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 5DF3A19BF; Tue, 19 Mar 2019 01:31:38 -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 256E73F59C; Tue, 19 Mar 2019 01:31:33 -0700 (PDT) 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 v7 6/10] KVM: arm64: Add vcpu feature flags to control ptrauth accessibility Date: Tue, 19 Mar 2019 14:00:39 +0530 Message-Id: <1552984243-7689-7-git-send-email-amit.kachhap@arm.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1552984243-7689-1-git-send-email-amit.kachhap@arm.com> References: <1552984243-7689-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 Since Pointer authentication will be enabled or disabled on a per-vcpu basis, vcpu feature flags are added in order to know which vcpus have it enabled from userspace. This features will allow the KVM guest to allow the handling of pointer authentication instructions or to treat them as undefined if not set. The helper macro added checks the feature flag along with other conditions such as VHE mode present and system supports pointer address/generic authentication. Signed-off-by: Amit Daniel Kachhap Cc: Mark Rutland Cc: Marc Zyngier Cc: Christoffer Dall Cc: kvmarm@lists.cs.columbia.edu --- arch/arm64/include/asm/kvm_host.h | 8 +++++++- arch/arm64/include/uapi/asm/kvm.h | 2 ++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h index e3ccd7b..9dd2918 100644 --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -45,7 +45,7 @@ #define KVM_MAX_VCPUS VGIC_V3_MAX_CPUS -#define KVM_VCPU_MAX_FEATURES 4 +#define KVM_VCPU_MAX_FEATURES 6 #define KVM_REQ_SLEEP \ KVM_ARCH_REQ_FLAGS(0, KVM_REQUEST_WAIT | KVM_REQUEST_NO_WAKEUP) @@ -491,6 +491,12 @@ static inline bool kvm_arch_requires_vhe(void) return false; } +#define vcpu_has_ptrauth(vcpu) (has_vhe() && \ + system_supports_address_auth() && \ + system_supports_generic_auth() && \ + test_bit(KVM_ARM_VCPU_PTRAUTH_ADDRESS, vcpu->arch.features) && \ + test_bit(KVM_ARM_VCPU_PTRAUTH_GENERIC, vcpu->arch.features)) + static inline void kvm_arch_hardware_unsetup(void) {} static inline void kvm_arch_sync_events(struct kvm *kvm) {} static inline void kvm_arch_vcpu_uninit(struct kvm_vcpu *vcpu) {} diff --git a/arch/arm64/include/uapi/asm/kvm.h b/arch/arm64/include/uapi/asm/kvm.h index 97c3478..8806f71 100644 --- a/arch/arm64/include/uapi/asm/kvm.h +++ b/arch/arm64/include/uapi/asm/kvm.h @@ -102,6 +102,8 @@ struct kvm_regs { #define KVM_ARM_VCPU_EL1_32BIT 1 /* CPU running a 32bit VM */ #define KVM_ARM_VCPU_PSCI_0_2 2 /* CPU uses PSCI v0.2 */ #define KVM_ARM_VCPU_PMU_V3 3 /* Support guest PMUv3 */ +#define KVM_ARM_VCPU_PTRAUTH_ADDRESS 4 /* VCPU uses address authentication */ +#define KVM_ARM_VCPU_PTRAUTH_GENERIC 5 /* VCPU uses generic authentication */ struct kvm_vcpu_init { __u32 target; -- 2.7.4