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=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 6E0A9C433F5 for ; Thu, 23 Sep 2021 11:45:17 +0000 (UTC) Received: from mm01.cs.columbia.edu (mm01.cs.columbia.edu [128.59.11.253]) by mail.kernel.org (Postfix) with ESMTP id DB9C161241 for ; Thu, 23 Sep 2021 11:45:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DB9C161241 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.cs.columbia.edu Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 5D3C84B104; Thu, 23 Sep 2021 07:45:16 -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 6r5Rol7k3EKc; Thu, 23 Sep 2021 07:45:13 -0400 (EDT) Received: from mm01.cs.columbia.edu (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id A6E694B10A; Thu, 23 Sep 2021 07:45:13 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mm01.cs.columbia.edu (Postfix) with ESMTP id 2A0464B101 for ; Thu, 23 Sep 2021 07:45:13 -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 uuDEDRmuOznZ for ; Thu, 23 Sep 2021 07:45:11 -0400 (EDT) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mm01.cs.columbia.edu (Postfix) with ESMTP id B3044406E0 for ; Thu, 23 Sep 2021 07:45:11 -0400 (EDT) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4B973106F; Thu, 23 Sep 2021 04:45:11 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.17.13]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E915E3F59C; Thu, 23 Sep 2021 04:45:09 -0700 (PDT) Date: Thu, 23 Sep 2021 12:45:06 +0100 From: Mark Rutland To: Will Deacon Subject: Re: [PATCH 1/5] arm64: Prevent kexec and hibernation if is_protected_kvm_enabled() Message-ID: <20210923114506.GB14893@C02TD0UTHF1T.local> References: <20210923112256.15767-1-will@kernel.org> <20210923112256.15767-2-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210923112256.15767-2-will@kernel.org> Cc: Marc Zyngier , kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, Catalin Marinas 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 On Thu, Sep 23, 2021 at 12:22:52PM +0100, Will Deacon wrote: > When pKVM is enabled, the hypervisor code at EL2 and its data structures > are inaccessible to the host kernel and cannot be torn down or replaced > as this would defeat the integrity properies which pKVM aims to provide. > Furthermore, the ABI between the host and EL2 is flexible and private to > whatever the current implementation of KVM requires and so booting a new > kernel with an old EL2 component is very likely to end in disaster. > > In preparation for uninstalling the hyp stub calls which are relied upon > to reset EL2, disable kexec and hibernation in the host when protected > KVM is enabled. > > Cc: Marc Zyngier > Cc: Quentin Perret > Signed-off-by: Will Deacon > --- > arch/arm64/kernel/smp.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 6f6ff072acbd..44369b99a57e 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -1128,5 +1128,6 @@ bool cpus_are_stuck_in_kernel(void) > { > bool smp_spin_tables = (num_possible_cpus() > 1 && !have_cpu_die()); > > - return !!cpus_stuck_in_kernel || smp_spin_tables; > + return !!cpus_stuck_in_kernel || smp_spin_tables || > + is_protected_kvm_enabled(); > } IIUC you'll also need to do something to prevent kdump, since even with CPUs stuck in the kernel that will try to do a kexec on the crashed CPU and __cpu_soft_restart() won't be able to return to EL2. You could fiddle with the BUG_ON() in machine_kexec() to die in this case too. Thanks, Mark. > -- > 2.33.0.464.g1972c5931b-goog > > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm _______________________________________________ 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=-15.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 32FC3C433EF for ; Thu, 23 Sep 2021 11:47:33 +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 EA6F560F44 for ; Thu, 23 Sep 2021 11:47:32 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org EA6F560F44 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=gtt3ke0guSUBJvLElFSZKA+FK5RZ9ZwtpYjMvVobMRk=; b=U0lmp8LCUUkGEE 91Ft13P+9PaQoHmh9B9mOXZ1aHb0cJPmrWmlBQnUDcPmWbZQwrTYpqvolat9kiXUj4oOiJK0LiPXb MIKu1bqjVDdHnMjDxgHmyXNYtncGXWs6iRCphBucT9YMq+Lz2z0RAgz2pTeiMxycBx35iNVQy9nBz AopbGyKeiF8GRnyu0Xi+Qybpc4fEJtgFyn1P3V+a2TzKZLAx3Bj5C2fV+rxPBIMgmU04dgqYcx1LV iTxErPewo2XaxnAX9HkKlPEAIYn3U1pkBIiHnM1Bt1qEC2PtduSA0qNNDz6JUzemdVsVyCHYGj1bw is2bpZAgGI6Oad+7YvQA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTNAF-00B8ax-G4; Thu, 23 Sep 2021 11:45:19 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mTNA9-00B8aS-MI for linux-arm-kernel@lists.infradead.org; Thu, 23 Sep 2021 11:45:15 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4B973106F; Thu, 23 Sep 2021 04:45:11 -0700 (PDT) Received: from C02TD0UTHF1T.local (unknown [10.57.17.13]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E915E3F59C; Thu, 23 Sep 2021 04:45:09 -0700 (PDT) Date: Thu, 23 Sep 2021 12:45:06 +0100 From: Mark Rutland To: Will Deacon Cc: linux-arm-kernel@lists.infradead.org, Marc Zyngier , Catalin Marinas , kvmarm@lists.cs.columbia.edu Subject: Re: [PATCH 1/5] arm64: Prevent kexec and hibernation if is_protected_kvm_enabled() Message-ID: <20210923114506.GB14893@C02TD0UTHF1T.local> References: <20210923112256.15767-1-will@kernel.org> <20210923112256.15767-2-will@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210923112256.15767-2-will@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210923_044513_818204_C2565E00 X-CRM114-Status: GOOD ( 24.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Sep 23, 2021 at 12:22:52PM +0100, Will Deacon wrote: > When pKVM is enabled, the hypervisor code at EL2 and its data structures > are inaccessible to the host kernel and cannot be torn down or replaced > as this would defeat the integrity properies which pKVM aims to provide. > Furthermore, the ABI between the host and EL2 is flexible and private to > whatever the current implementation of KVM requires and so booting a new > kernel with an old EL2 component is very likely to end in disaster. > > In preparation for uninstalling the hyp stub calls which are relied upon > to reset EL2, disable kexec and hibernation in the host when protected > KVM is enabled. > > Cc: Marc Zyngier > Cc: Quentin Perret > Signed-off-by: Will Deacon > --- > arch/arm64/kernel/smp.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 6f6ff072acbd..44369b99a57e 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -1128,5 +1128,6 @@ bool cpus_are_stuck_in_kernel(void) > { > bool smp_spin_tables = (num_possible_cpus() > 1 && !have_cpu_die()); > > - return !!cpus_stuck_in_kernel || smp_spin_tables; > + return !!cpus_stuck_in_kernel || smp_spin_tables || > + is_protected_kvm_enabled(); > } IIUC you'll also need to do something to prevent kdump, since even with CPUs stuck in the kernel that will try to do a kexec on the crashed CPU and __cpu_soft_restart() won't be able to return to EL2. You could fiddle with the BUG_ON() in machine_kexec() to die in this case too. Thanks, Mark. > -- > 2.33.0.464.g1972c5931b-goog > > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel