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 X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01BE6C433E0 for ; Wed, 10 Jun 2020 11:34:21 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id 7C25F2078D for ; Wed, 10 Jun 2020 11:34:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ksvks8e2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C25F2078D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvmarm-bounces@lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id F03D24B237; Wed, 10 Jun 2020 07:34:19 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Authentication-Results: mm01.cs.columbia.edu (amavisd-new); dkim=softfail (fail, message has been altered) header.i=@kernel.org Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 7n7lZgCXU0yc; Wed, 10 Jun 2020 07:34:18 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id DD97E4B1F0; Wed, 10 Jun 2020 07:34:18 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id E817A4B17B for ; Wed, 10 Jun 2020 07:34:17 -0400 (EDT) X-Virus-Scanned: at lists.cs.columbia.edu Received: from mm01.cs.columbia.edu ([127.0.0.1]) by localhost (mm01.cs.columbia.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uAOjhsDkvxPF for ; Wed, 10 Jun 2020 07:34:16 -0400 (EDT) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by mm01.cs.columbia.edu (Postfix) with ESMTPS id C769C4B149 for ; Wed, 10 Jun 2020 07:34:16 -0400 (EDT) Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B0BCA20734; Wed, 10 Jun 2020 11:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591788855; bh=9N6nffWe0REroh98cZzvRnmfrffUIT7lJJ7yMkeQ6uI=; h=From:To:Cc:Subject:Date:From; b=Ksvks8e29KLnHD9le872+c+3SUvatPHr3scAMz190kRFvyApeml9YWHh8o+yITFcD Mj8bsnfTJ1Vtcu0R5MHp396KaIIEEQ11lRB+vXVJj0rIdF/qd77dIO2NIfDLl5PFao YoBbsMa+nMUOr7bfYEkscw/tyWNN//u47xzi+XXM= Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jiyzm-001lrp-8M; Wed, 10 Jun 2020 12:34:14 +0100 From: Marc Zyngier To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 0/4] kvm: arm64: Pointer Authentication handling fixes Date: Wed, 10 Jun 2020 12:34:02 +0100 Message-Id: <20200610113406.1493170-1-maz@kernel.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, ascull@google.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: kernel-team@android.com, Catalin Marinas , Will Deacon X-BeenThere: kvmarm@lists.cs.columbia.edu X-Mailman-Version: 2.1.14 Precedence: list List-Id: Where KVM/ARM decisions are made List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: kvmarm-bounces@lists.cs.columbia.edu Sender: kvmarm-bounces@lists.cs.columbia.edu I recently discovered that the Pointer Authentication (PtrAuth) handling code in KVM is busted, and has been for a while. The main issue is that the we save the host's keys from a preemptible context. Things will go wrong at some point. In order to address this, the first patch move the saving of the host's keys to vcpu_load(). It is done eagerly, which is a bore, but is at least safe. This is definitely stable material. The following patch is adding an optimisatioe: we handle key saving and HCR massaging as a fixup, much like the FPSIMD code. Subsequent patch cleans up our HYP per-CPU accessor and make it sparse friendly, asthe last patch makes heavy use of it by killing the per-vcpu backpointer to the physical CPU context, avoiding the first bug altogether. This has been very lightly tested on a model. Unless someone shouts, I plan to send this as part of the pending set of fixes. * From v1: - Dropped the misbehaving guest handling patch - Added the two cleanup patches to the series (previously posted separately) Marc Zyngier (4): KVM: arm64: Save the host's PtrAuth keys in non-preemptible context KVM: arm64: Handle PtrAuth traps early KVM: arm64: Stop sparse from moaning at __hyp_this_cpu_ptr KVM: arm64: Remove host_cpu_context member from vcpu structure arch/arm64/include/asm/kvm_asm.h | 13 ++++-- arch/arm64/include/asm/kvm_emulate.h | 6 --- arch/arm64/include/asm/kvm_host.h | 3 -- arch/arm64/kvm/arm.c | 6 +-- arch/arm64/kvm/handle_exit.c | 32 ++------------ arch/arm64/kvm/hyp/debug-sr.c | 4 +- arch/arm64/kvm/hyp/switch.c | 65 +++++++++++++++++++++++++++- arch/arm64/kvm/hyp/sysreg-sr.c | 6 ++- arch/arm64/kvm/pmu.c | 8 +--- arch/arm64/kvm/sys_regs.c | 13 +++--- 10 files changed, 91 insertions(+), 65 deletions(-) -- 2.26.2 _______________________________________________ kvmarm mailing list kvmarm@lists.cs.columbia.edu https://lists.cs.columbia.edu/mailman/listinfo/kvmarm 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 X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7E83FC433DF for ; Wed, 10 Jun 2020 11:34:32 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 4F80120734 for ; Wed, 10 Jun 2020 11:34:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="LD4cwpTa"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="Ksvks8e2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4F80120734 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References: List-Owner; bh=QnOyqzs0UHMzBs+iFxzwplFo4P/kyX3F7St+19MZ9I0=; b=LD4cwpTayUerMa qhqiNSZSgeeh+SDrywH0Ys+7x6hWRqjg90tqh5gQb9rb/djgh2dkJkdHhieyofcXairX3r8beiwbO GMlRtBaOmJLpOwEibCqQEazZ1rXpuNVDTyRAVOuz3qfR5qnoM2LBr+EGnEk5FjALHVZAk1fKgpUff 0AxP4nGC92kWUG5NiXzpX/+O2LEw/OsJndVXI1W5I0h5ggjhqDqEyA11f/LHJu81MDE3jddcQn8Sx pV8jZZEWW20OKxiZ5tnF1gAGpJi9pD0FNptCjurELtEBd1cIjdwUdg9WwNxZx+UjZEJxT5X4OUeJ7 WGWEPPRPY6xLoUStjO6Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jiyzr-0006kE-Gr; Wed, 10 Jun 2020 11:34:19 +0000 Received: from mail.kernel.org ([198.145.29.99]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jiyzo-0006iu-Dy for linux-arm-kernel@lists.infradead.org; Wed, 10 Jun 2020 11:34:17 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B0BCA20734; Wed, 10 Jun 2020 11:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591788855; bh=9N6nffWe0REroh98cZzvRnmfrffUIT7lJJ7yMkeQ6uI=; h=From:To:Cc:Subject:Date:From; b=Ksvks8e29KLnHD9le872+c+3SUvatPHr3scAMz190kRFvyApeml9YWHh8o+yITFcD Mj8bsnfTJ1Vtcu0R5MHp396KaIIEEQ11lRB+vXVJj0rIdF/qd77dIO2NIfDLl5PFao YoBbsMa+nMUOr7bfYEkscw/tyWNN//u47xzi+XXM= Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jiyzm-001lrp-8M; Wed, 10 Jun 2020 12:34:14 +0100 From: Marc Zyngier To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 0/4] kvm: arm64: Pointer Authentication handling fixes Date: Wed, 10 Jun 2020 12:34:02 +0100 Message-Id: <20200610113406.1493170-1-maz@kernel.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, ascull@google.com, kernel-team@android.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-20200610_043416_490492_31AE5E83 X-CRM114-Status: GOOD ( 12.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , kernel-team@android.com, Suzuki K Poulose , Catalin Marinas , James Morse , Andrew Scull , Will Deacon , Julien Thierry Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org I recently discovered that the Pointer Authentication (PtrAuth) handling code in KVM is busted, and has been for a while. The main issue is that the we save the host's keys from a preemptible context. Things will go wrong at some point. In order to address this, the first patch move the saving of the host's keys to vcpu_load(). It is done eagerly, which is a bore, but is at least safe. This is definitely stable material. The following patch is adding an optimisatioe: we handle key saving and HCR massaging as a fixup, much like the FPSIMD code. Subsequent patch cleans up our HYP per-CPU accessor and make it sparse friendly, asthe last patch makes heavy use of it by killing the per-vcpu backpointer to the physical CPU context, avoiding the first bug altogether. This has been very lightly tested on a model. Unless someone shouts, I plan to send this as part of the pending set of fixes. * From v1: - Dropped the misbehaving guest handling patch - Added the two cleanup patches to the series (previously posted separately) Marc Zyngier (4): KVM: arm64: Save the host's PtrAuth keys in non-preemptible context KVM: arm64: Handle PtrAuth traps early KVM: arm64: Stop sparse from moaning at __hyp_this_cpu_ptr KVM: arm64: Remove host_cpu_context member from vcpu structure arch/arm64/include/asm/kvm_asm.h | 13 ++++-- arch/arm64/include/asm/kvm_emulate.h | 6 --- arch/arm64/include/asm/kvm_host.h | 3 -- arch/arm64/kvm/arm.c | 6 +-- arch/arm64/kvm/handle_exit.c | 32 ++------------ arch/arm64/kvm/hyp/debug-sr.c | 4 +- arch/arm64/kvm/hyp/switch.c | 65 +++++++++++++++++++++++++++- arch/arm64/kvm/hyp/sysreg-sr.c | 6 ++- arch/arm64/kvm/pmu.c | 8 +--- arch/arm64/kvm/sys_regs.c | 13 +++--- 10 files changed, 91 insertions(+), 65 deletions(-) -- 2.26.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel 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 X-Spam-Level: X-Spam-Status: No, score=-4.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E6B06C433E0 for ; Wed, 10 Jun 2020 11:34:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C19C620820 for ; Wed, 10 Jun 2020 11:34:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591788857; bh=9N6nffWe0REroh98cZzvRnmfrffUIT7lJJ7yMkeQ6uI=; h=From:To:Cc:Subject:Date:List-ID:From; b=zD/S8qvQlPtR0/uDSL8lDgrz2XaFg8/lZPhr3NVsdagE5r3p3Hthe29MJRC4V6+Si 2/MdVN1MScOcP3XvWkyD9uaZPAM7F6qGDUhPD1WgLcXNBX9mpPwrutRb8oEql6khk7 hOMmehfmEjHvQ1TkNwrYLadIe8jb6aJDeODRHa1g= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728527AbgFJLeQ (ORCPT ); Wed, 10 Jun 2020 07:34:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:42712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728491AbgFJLeQ (ORCPT ); Wed, 10 Jun 2020 07:34:16 -0400 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B0BCA20734; Wed, 10 Jun 2020 11:34:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591788855; bh=9N6nffWe0REroh98cZzvRnmfrffUIT7lJJ7yMkeQ6uI=; h=From:To:Cc:Subject:Date:From; b=Ksvks8e29KLnHD9le872+c+3SUvatPHr3scAMz190kRFvyApeml9YWHh8o+yITFcD Mj8bsnfTJ1Vtcu0R5MHp396KaIIEEQ11lRB+vXVJj0rIdF/qd77dIO2NIfDLl5PFao YoBbsMa+nMUOr7bfYEkscw/tyWNN//u47xzi+XXM= Received: from 78.163-31-62.static.virginmediabusiness.co.uk ([62.31.163.78] helo=why.lan) by disco-boy.misterjones.org with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jiyzm-001lrp-8M; Wed, 10 Jun 2020 12:34:14 +0100 From: Marc Zyngier To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org Cc: James Morse , Julien Thierry , Suzuki K Poulose , Will Deacon , Catalin Marinas , Mark Rutland , Andrew Scull , kernel-team@android.com Subject: [PATCH v2 0/4] kvm: arm64: Pointer Authentication handling fixes Date: Wed, 10 Jun 2020 12:34:02 +0100 Message-Id: <20200610113406.1493170-1-maz@kernel.org> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 62.31.163.78 X-SA-Exim-Rcpt-To: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, james.morse@arm.com, julien.thierry.kdev@gmail.com, suzuki.poulose@arm.com, will@kernel.org, catalin.marinas@arm.com, mark.rutland@arm.com, ascull@google.com, kernel-team@android.com X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org I recently discovered that the Pointer Authentication (PtrAuth) handling code in KVM is busted, and has been for a while. The main issue is that the we save the host's keys from a preemptible context. Things will go wrong at some point. In order to address this, the first patch move the saving of the host's keys to vcpu_load(). It is done eagerly, which is a bore, but is at least safe. This is definitely stable material. The following patch is adding an optimisatioe: we handle key saving and HCR massaging as a fixup, much like the FPSIMD code. Subsequent patch cleans up our HYP per-CPU accessor and make it sparse friendly, asthe last patch makes heavy use of it by killing the per-vcpu backpointer to the physical CPU context, avoiding the first bug altogether. This has been very lightly tested on a model. Unless someone shouts, I plan to send this as part of the pending set of fixes. * From v1: - Dropped the misbehaving guest handling patch - Added the two cleanup patches to the series (previously posted separately) Marc Zyngier (4): KVM: arm64: Save the host's PtrAuth keys in non-preemptible context KVM: arm64: Handle PtrAuth traps early KVM: arm64: Stop sparse from moaning at __hyp_this_cpu_ptr KVM: arm64: Remove host_cpu_context member from vcpu structure arch/arm64/include/asm/kvm_asm.h | 13 ++++-- arch/arm64/include/asm/kvm_emulate.h | 6 --- arch/arm64/include/asm/kvm_host.h | 3 -- arch/arm64/kvm/arm.c | 6 +-- arch/arm64/kvm/handle_exit.c | 32 ++------------ arch/arm64/kvm/hyp/debug-sr.c | 4 +- arch/arm64/kvm/hyp/switch.c | 65 +++++++++++++++++++++++++++- arch/arm64/kvm/hyp/sysreg-sr.c | 6 ++- arch/arm64/kvm/pmu.c | 8 +--- arch/arm64/kvm/sys_regs.c | 13 +++--- 10 files changed, 91 insertions(+), 65 deletions(-) -- 2.26.2