From patchwork Mon Oct 16 13:28:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13423347 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2A1BCDB465 for ; Mon, 16 Oct 2023 13:42:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 652AE8D008F; Mon, 16 Oct 2023 09:42:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 603BE8D0001; Mon, 16 Oct 2023 09:42:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4A4AF8D008F; Mon, 16 Oct 2023 09:42:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 38CE58D0001 for ; Mon, 16 Oct 2023 09:42:39 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 09ED11A0935 for ; Mon, 16 Oct 2023 13:42:39 +0000 (UTC) X-FDA: 81351439638.16.B3BA1E4 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2080.outbound.protection.outlook.com [40.107.93.80]) by imf20.hostedemail.com (Postfix) with ESMTP id 13D041C000D for ; Mon, 16 Oct 2023 13:42:35 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=IE9R83fQ; spf=pass (imf20.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.93.80 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1697463756; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=taEAnXAx4AHIhFKtNmiIBrEk5Qj5RWdX2hupeZhmCl4=; b=CzJS6FJWBtBZEMRdaZMRnzcBhOm3j/bYd7Hta2Sjx2aie5mgJqthdRHOTU+h3dbz2s+DNc sm3F2FjjnJgLVpn7g/74mygwr087B+88iNp/E0G2F5jXzeo7Mq3ebZHVgjExvi5Wd8irqK MMgwhjfN4o0Q1J+Wa4K/3lRGvs3Rj2o= ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1697463756; a=rsa-sha256; cv=pass; b=vvnldhGdEAqEJmsk4GMsMr3GtG4uEQgncOkfGBARMO/vvhKemM0oa5dIVS4j6weGUGdQ7+ 3v/wvD9l29sUHfxi3n2P/h8Z4D7hgE8ni3+gltTq35fnbSnQuLuXVssaT4puoXltyqSMWs /STBWUijfXsZh8yDYa0DQym/RauF7yg= ARC-Authentication-Results: i=2; imf20.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=IE9R83fQ; spf=pass (imf20.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.93.80 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; dmarc=pass (policy=quarantine) header.from=amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FD08Z9Qhnwr7ob4n5Pk4O+vtyCtR3uzH2bRfVRinX06TarBsX+A89ifaSCnqE6S5chepdEu4lrbWBbLNWBvd6JMj2TbdX/VuzTNPl0lx1exlyBdDI57/tgvNo5zFirEZI9lar9CdDsJ/SowqadEXCo4hQKPAO5H9iGPpnf7lW2f5u71s9nMfYPzOQNLnBOozQ9vM9cYWi+Jx7mjP78KtBdUKCcgHCFgfMzAk7Ftdu00+SO7HL4Fh2mGoH7mHwWKHjg8QpzMNPoBf2xnZqMTMeNyelOTnzD79Qm3sTD76jV6/eHElx1j7Ss3AzZ2bJLMZHP7tuGYcK3rHjXSIhMAdXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=taEAnXAx4AHIhFKtNmiIBrEk5Qj5RWdX2hupeZhmCl4=; b=dB+Kqbm2PjTh/gbwagKMmSUwl0JdPeW7RtRTyhuUQEWXLZyMIvpuL+ZRDhhaZFB9c5zJVGJ5+gHv7Q9bdbX49jlB5XEWqgk5CkB0aFarz+Z9W8dYu6ybWHkaQfsaaaagBYo5rQ8VZPcucnZP0TmzhnuQhdQZ4MJxxRL2LauAZXouBIaSksTFGjJEPEOruI7G5FDWnRTTANZcP53emQsAAI6AncmrOCCiUVgNs6CJz3kDuCE49eB1BWYCBu01HZB2qqTSYOO/3xhObu7qLoSDRgqvnhYQj1ErJpDgSiKcf3WPGzWoyCAaADx3K30vSqqLOU7Nh5lhcio7zn3+7Ypv8w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=taEAnXAx4AHIhFKtNmiIBrEk5Qj5RWdX2hupeZhmCl4=; b=IE9R83fQKzE/o+7mWjqLdx5SoZKOk0l+g0ZRnbyVPu7TAfURe33uz8bckEVjkXb9FeV9ukzAe6TbTeL7O0w7bcn+f9ievDxMvYHslr2cXhg6ltqw6EboWoA3OuVkk58T8jSogmegmpi6IuyOmpjhQPOt/Gd7+8mDZe7yrRQIU8I= Received: from PH7PR17CA0066.namprd17.prod.outlook.com (2603:10b6:510:325::15) by SJ2PR12MB8111.namprd12.prod.outlook.com (2603:10b6:a03:4fe::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.36; Mon, 16 Oct 2023 13:42:33 +0000 Received: from SN1PEPF000252A1.namprd05.prod.outlook.com (2603:10b6:510:325:cafe::87) by PH7PR17CA0066.outlook.office365.com (2603:10b6:510:325::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6886.35 via Frontend Transport; Mon, 16 Oct 2023 13:42:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF000252A1.mail.protection.outlook.com (10.167.242.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6838.22 via Frontend Transport; Mon, 16 Oct 2023 13:42:33 +0000 Received: from localhost (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Mon, 16 Oct 2023 08:42:32 -0500 From: Michael Roth To: CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v10 38/50] KVM: SEV: Add support for GHCB-based termination requests Date: Mon, 16 Oct 2023 08:28:07 -0500 Message-ID: <20231016132819.1002933-39-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231016132819.1002933-1-michael.roth@amd.com> References: <20231016132819.1002933-1-michael.roth@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF000252A1:EE_|SJ2PR12MB8111:EE_ X-MS-Office365-Filtering-Correlation-Id: b8f739cc-04f1-4473-7819-08dbce4dc00f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Cu3L7Sif8VPbMyA+ubp1eBadBHxnIsJXI1PmXa+d6RwjhsjkPA2lrugmGNGZ7lLwBnmRZDMaLEosHMqpwWlSPQ2e1C/PhlcQeNMAbN9dVKRL7TosdEkU6GT0Tm+SN5TKdzYrJSy2K/4dY/qs7XfQ+mVRtahbGQtLM3ojQ3W9X/jMxRY9xtGsv1AImNS/XOev7obx6g1llrJgwngOoMQDHYwSUP2e60x7r/yh29UYc354XJq0MjehM0kRCVFkriubp/rtbRupcb+fpbFQVbgaIvlkvCLvm+Ld7LHdvI65vJaCk2wOd7eoLX6fVTxW7zJj1qHNFPW/t3r92d2NigtLoYceW6NfVaZpJ9fYw1nUuyX+pq+zaIofycXDpRHIKch6UHFOEHugDMW22UZquyRGrzs6+kcQaWgGyxa5nB0tIWvnO66GRE/C1oBju9DNqIwtQNx4ueTw7Za+bL+Jp9KIRVTCAHnwdtG5uMxfso43o1poT/Nc/ZV5L37pAbecU6WTLCxEQ6InzB1lWo7sCiMW4yaTWypFHpM9pp+YNtoe2LY58A/rjj0+qGrFAM9rQbJEWa8haYTdGzLmdQzdilTwShyCUH844P4wDJsTPsyXS46nSHW7YrQlym6ToWysnB27atVUcUTK5EivaXE5vfqM0vjxA+NSxg/43iXf0ASBvXbbLJTYUcVaO9Irg9MvJQViAx+HEw1lmR1nChj12AMM+ZEe0TFprnaVe+nZEnxhDK7EXnunR3VPIZexeUDUMLk4/SviQKkQrNnp+5Zev/RTfA== X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(346002)(136003)(376002)(39860400002)(396003)(230922051799003)(451199024)(64100799003)(1800799009)(186009)(82310400011)(46966006)(36840700001)(40470700004)(40460700003)(40480700001)(36860700001)(82740400003)(356005)(47076005)(83380400001)(81166007)(6666004)(16526019)(26005)(36756003)(70586007)(70206006)(54906003)(316002)(6916009)(478600001)(1076003)(426003)(336012)(2616005)(41300700001)(44832011)(7416002)(7406005)(86362001)(2906002)(5660300002)(8936002)(8676002)(4326008)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Oct 2023 13:42:33.2318 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b8f739cc-04f1-4473-7819-08dbce4dc00f X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: SN1PEPF000252A1.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR12MB8111 X-Rspamd-Queue-Id: 13D041C000D X-Rspam-User: X-Rspamd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9qkBV0NpVzlOz1ChR+CexNtK80kOGjQGm50/PJz/FpJBewBVC2NoVoeGY//E4NKNWkY9yhULBwfx2JTGMM4yIBPanl8sSLLSfvPAR5FfKLFoFGnrs34uQJNFu58cTFlMBFOH7uq1cF9FvWmGCUVWDVDXKfApFGcx9UcCwDV74GZp31A6NRhuFgw0LkA4oEN8tM2L6DUx2b8NeD5U+CSs1ZafMwvNjr+aDFNig7WlgJC+ZnKzeStcS21cv6cE5wuW7qRvXzL1mK5/UudLUenIcYkusr7ZYBLnS2jvzPJchR3+dpw43Pp5kYEMecHdsPnhjg6fs3p07zp+30= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: GHCB version 2 adds support for a GHCB-based termination request that a guest can issue when it reaches an error state and wishes to inform the hypervisor that it should be terminated. Implement support for that similarly to GHCB MSR-based termination requests that are already available to SEV-ES guests via earlier versions of the GHCB protocol. Signed-off-by: Michael Roth Reviewed-by: Liam Merwick --- arch/x86/kvm/svm/sev.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index e547adddacfa..9c38fe796e00 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -3094,6 +3094,7 @@ static int sev_es_validate_vmgexit(struct vcpu_svm *svm) case SVM_VMGEXIT_UNSUPPORTED_EVENT: case SVM_VMGEXIT_HV_FEATURES: case SVM_VMGEXIT_PSC: + case SVM_VMGEXIT_TERM_REQUEST: break; default: reason = GHCB_ERR_INVALID_EVENT; @@ -3762,6 +3763,14 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu) ret = 1; break; + case SVM_VMGEXIT_TERM_REQUEST: + pr_info("SEV-ES guess requested termination: reason %#llx info %#llx\n", + control->exit_info_1, control->exit_info_1); + vcpu->run->exit_reason = KVM_EXIT_SYSTEM_EVENT; + vcpu->run->system_event.type = KVM_SYSTEM_EVENT_SEV_TERM; + vcpu->run->system_event.ndata = 1; + vcpu->run->system_event.data[0] = control->ghcb_gpa; + break; case SVM_VMGEXIT_UNSUPPORTED_EVENT: vcpu_unimpl(vcpu, "vmgexit: unsupported event - exit_info_1=%#llx, exit_info_2=%#llx\n",