Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3561671imu; Mon, 17 Dec 2018 23:58:23 -0800 (PST) X-Google-Smtp-Source: AFSGD/UXe/kEVfN9qmFJqaA4kkBiiW8YZh21zNP8cEgZLYMGZSrxDA6XfxDpF3tsSIJnf7rGoAHV X-Received: by 2002:a62:61c3:: with SMTP id v186mr15889371pfb.55.1545119903850; Mon, 17 Dec 2018 23:58:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545119903; cv=none; d=google.com; s=arc-20160816; b=XIUbn/gK+PCONXVtYfaSL3ZBR85hYvCCEyhScWq8KgP5Zk8L8KuZAY2zioxxwqV6kp +k6agCanydksyQILryl6ZSfvR9sqlH3I8KfaL15CkiUPPC0qTJpWZhxU2FiYAPTAcORK qboPgRU/d7/gXXPd9P2HZMiMofYkdKip9n5ACNKz+wIXQmSCs0hjAyLqcgOkcPtoW5MS +lUK1L31PYB3VqHxgHJtXQBZOUbGhDhDY+6off9rrfPyKX9ltt3gMiWlfOyWRKDL1skq esgzj82bEH+DjmCd+3ScKBsLgMvUoXRsajNb6PVoMC6S2EF8/VXWAZ1mRzazVspk6rKe RQTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=KY2y3kOVYcReAIJ/BWqxWw9qdRKDAU/bHfYBXq5J2p8=; b=MqbInBOFWOQal+LAQ9YqL8mACqEzEG7Ahdi77jyA2xia0miVtuofH2nqaJb6PIwpZ7 pU5FkK9Wo6wmpBnLQGYe5Tj5XSQQP3ADasikXDifQB63mVTXNNOH3pwH0IHIwjxoV5x1 VA0FABvZndDkXEtxtQYRY5devh7lbq7zN8RG7k0wJkfKbcAVWkE4Y9bA8L9VV0HfT7Tv 5y7cM3JU8VLivrtKpTsWZ8TT9d78/LiUlNCqm+DXxGDcMG9JcZyAniZ0vMHJJks+rZ3U OtTWTrDh22q2gODDvZCO8Pw3QtnsVTKFzwG3GdWJie4mvWM5bYw9hwpa+2e0KxxKQyu6 FRqA== 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 82si11800643pfa.115.2018.12.17.23.58.08; Mon, 17 Dec 2018 23:58:23 -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 S1726583AbeLRH5L (ORCPT + 99 others); Tue, 18 Dec 2018 02:57:11 -0500 Received: from foss.arm.com ([217.140.101.70]:39714 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726402AbeLRH5J (ORCPT ); Tue, 18 Dec 2018 02:57:09 -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 367D480D; Mon, 17 Dec 2018 23:57:09 -0800 (PST) Received: from a75553-lin.blr.arm.com (a75553-lin.blr.arm.com [10.162.0.175]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9E47D3F575; Mon, 17 Dec 2018 23:57:05 -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 Subject: [PATCH v4 0/6] Add ARMv8.3 pointer authentication for kvm guest Date: Tue, 18 Dec 2018 13:26:44 +0530 Message-Id: <1545119810-12182-1-git-send-email-amit.kachhap@arm.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, This patch series adds pointer authentication support for KVM guest and is based on top of Linux 4.20-rc5 and generic pointer authentication patch series[1]. The first two patch in this series was originally posted by Mark Rutland earlier[2,3] and contains some history of this work. Extension Overview: ============================================= The ARMv8.3 pointer authentication extension adds functionality to detect modification of pointer values, mitigating certain classes of attack such as stack smashing, and making return oriented programming attacks harder. The extension introduces the concept of a pointer authentication code (PAC), which is stored in some upper bits of pointers. Each PAC is derived from the original pointer, another 64-bit value (e.g. the stack pointer), and a secret 128-bit key. New instructions are added which can be used to: * Insert a PAC into a pointer * Strip a PAC from a pointer * Authenticate and strip a PAC from a pointer The detailed description of ARMv8.3 pointer authentication support in userspace/kernel can be found in Kristina's generic pointer authentication patch series[1]. KVM guest work: ============================================== If pointer authentication is enabled for KVM guests then the new PAC intructions will not trap to EL2. If not then they may be ignored if in HINT region or trapped in EL2 as illegal instruction. Since KVM guest vcpu runs as a thread so they have a key initialised which will be used by PAC. When world switch happens between host and guest then this key is exchanged. There were some review comments by Christoffer Dall in the original series[2,3,4] and this patch series tries to implement them. The original series enabled pointer authentication for both userspace and kvm userspace. However it is now bifurcated and this series contains only KVM guest support. Changes since v3 [4]: * Use pointer authentication only when VHE is present as ARM8.3 implies ARM8.1 features to be present. * Added lazy context handling of ptrauth instructions from V2 version again. * Added more details in Documentation. * Rebased to new version of generic ptrauth patches [1]. Changes since v2 [2,3]: * Allow host and guest to have different HCR_EL2 settings and not just constant value HCR_HOST_VHE_FLAGS or HCR_HOST_NVHE_FLAGS. * Optimise the reading of HCR_EL2 in host/guest switch by fetching it once during KVM initialisation state and using it later. * Context switch pointer authentication keys when switching between guest and host. Pointer authentication was enabled in a lazy context earlier[2] and is removed now to make it simple. However it can be revisited later if there is significant performance issue. * Added a userspace option to choose pointer authentication. * Based on the userspace option, ptrauth cpufeature will be visible. * Based on the userspace option, ptrauth key registers will be accessible. * A small document is added on how to enable pointer authentication from userspace KVM API. Looking for feedback and comments. Thanks, Amit [1]: https://lkml.org/lkml/2018/12/7/666 [2]: https://lore.kernel.org/lkml/20171127163806.31435-11-mark.rutland@arm.com/ [3]: https://lore.kernel.org/lkml/20171127163806.31435-10-mark.rutland@arm.com/ [4]: https://lkml.org/lkml/2018/10/17/594 Linux (4.20-rc5 based): Amit Daniel Kachhap (5): arm64/kvm: preserve host HCR_EL2 value arm64/kvm: context-switch ptrauth registers arm64/kvm: add a userspace option to enable pointer authentication arm64/kvm: enable pointer authentication cpufeature conditionally arm64/kvm: control accessibility of ptrauth key registers Documentation/arm64/pointer-authentication.txt | 13 ++-- Documentation/virtual/kvm/api.txt | 4 ++ arch/arm/include/asm/kvm_host.h | 7 ++ arch/arm64/include/asm/cpufeature.h | 6 ++ arch/arm64/include/asm/kvm_asm.h | 2 + arch/arm64/include/asm/kvm_host.h | 41 +++++++++++- arch/arm64/include/asm/kvm_hyp.h | 7 ++ arch/arm64/include/uapi/asm/kvm.h | 1 + arch/arm64/kernel/traps.c | 1 + arch/arm64/kvm/handle_exit.c | 24 ++++--- arch/arm64/kvm/hyp/Makefile | 1 + arch/arm64/kvm/hyp/ptrauth-sr.c | 89 +++++++++++++++++++++++++ arch/arm64/kvm/hyp/switch.c | 19 ++++-- arch/arm64/kvm/hyp/sysreg-sr.c | 11 ++++ arch/arm64/kvm/hyp/tlb.c | 6 +- arch/arm64/kvm/reset.c | 3 + arch/arm64/kvm/sys_regs.c | 91 ++++++++++++++++++++------ include/uapi/linux/kvm.h | 1 + virt/kvm/arm/arm.c | 4 ++ 19 files changed, 289 insertions(+), 42 deletions(-) create mode 100644 arch/arm64/kvm/hyp/ptrauth-sr.c kvmtool: Repo: git.kernel.org/pub/scm/linux/kernel/git/will/kvmtool.git Amit Daniel Kachhap (1): arm/kvm: arm64: Add a vcpu feature for pointer authentication arm/aarch32/include/kvm/kvm-cpu-arch.h | 2 ++ arm/aarch64/include/asm/kvm.h | 3 +++ arm/aarch64/include/kvm/kvm-arch.h | 1 + arm/aarch64/include/kvm/kvm-config-arch.h | 4 +++- arm/aarch64/include/kvm/kvm-cpu-arch.h | 2 ++ arm/aarch64/kvm-cpu.c | 5 +++++ arm/include/arm-common/kvm-config-arch.h | 1 + arm/kvm-cpu.c | 7 +++++++ include/linux/kvm.h | 1 + 9 files changed, 25 insertions(+), 1 deletion(-) -- 2.7.4