From patchwork Wed May 1 07:10:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 13650283 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 4D9E4C4345F for ; Wed, 1 May 2024 07:48:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA8AF6B0092; Wed, 1 May 2024 03:48:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C56CB6B0093; Wed, 1 May 2024 03:48:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AACC96B0095; Wed, 1 May 2024 03:48:01 -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 8A2366B0092 for ; Wed, 1 May 2024 03:48:01 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 305F6402DF for ; Wed, 1 May 2024 07:47:59 +0000 (UTC) X-FDA: 82069048278.13.4DABDB9 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2066.outbound.protection.outlook.com [40.107.94.66]) by imf07.hostedemail.com (Postfix) with ESMTP id 3E2FE40022 for ; Wed, 1 May 2024 07:47:56 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=LTQsaA5x; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf07.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.94.66 as permitted sender) smtp.mailfrom=Michael.Roth@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=1714549676; 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=TzzAZm9oYogXqez2TlMGxs3a+KLmFqZxsyGAqlGIiK8=; b=AkzSbMOsRFJtd9LGm3EF1SC2UKaGEGpOjAuUufQtI2c8kZ7xTWFq1dj2n9c2dzw2yqDc2D qhR71lhTh1faKmiCa+aYGBWaGr+9Fcyay6e3ir3UA0P7U5/IewjmNyg9uFQ0Uk+Lj2X+U+ Jpb+Q7U03U9ybd4g585XWA5EXd1mwBg= ARC-Authentication-Results: i=2; imf07.hostedemail.com; dkim=pass header.d=amd.com header.s=selector1 header.b=LTQsaA5x; dmarc=pass (policy=quarantine) header.from=amd.com; spf=pass (imf07.hostedemail.com: domain of Michael.Roth@amd.com designates 40.107.94.66 as permitted sender) smtp.mailfrom=Michael.Roth@amd.com; arc=pass ("microsoft.com:s=arcselector9901:i=1") ARC-Seal: i=2; s=arc-20220608; d=hostedemail.com; t=1714549676; a=rsa-sha256; cv=pass; b=rzA4v5HeY1oHRs2NrbMSJLk89IwvENCuEo+q+xIAv0c0BvKSZARc2ZCM2lk/Cl+X0TbMWu OTZf5XwbCDluTPbUS3Esd7Jh2dC0BohG96VeY+SSHZAFt/lrumxqmOhHg6NFXC0S9+VEkR JgsSm/ktvb+rsgdQjirwqAdXGg2Ab/c= ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YSwNk2CR9NXOsFPx8u/Z0mj/3NNbNZp1QBhTusQ8+RJ3+Kxj7/cJgZKLPPwrf6fi/mRQTv/6GZX0ONF0NNxx/imnJeEENSijbb1ps5jMET11i55xu2kF6wQsl0Eyi6RhhXzIiXh0pdsek40y9gsAWV7ySG2YmTIxWgVV5w/S8Vx+BsgKHkJQ6+HMYEhF3Kw8enkRq+b0NQvjfeHhB6uQaZHRRVCliPcbsedR94DVRtQ66T0ti4Y5qQAZDacjFv3x+lPvlScfNtKi39PjK1StkzataCPcyREQwHHvtJWk/60CjmyzB2aoEJLZteJBUv9Hm5AvPlCFy9kekD6mAmzmzw== 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=TzzAZm9oYogXqez2TlMGxs3a+KLmFqZxsyGAqlGIiK8=; b=LS4QhWLnt8MNcM9QbitmRGtURvCZ10aeEIwy34Hcs89+3WAjX37+FwXn8HvPCZzvBAp5xdvUOUHNp+LpuEbu6c2aAHUOqzsD7UwrcCFdVMbiiEG6E1xD7uy6MhRx74wuaSHr3KVpoqsAwdRrMaWq797Som1wWgr13pePjLGca2W1hO1ZuTBbQKpWb1h0JY/6SheLmC9zxODaNZSYPEYAyayVZXnkSmZwsBqh5prxqL13NNLLBEN4He9neCW3VNKMdb2azmC8Xj20vgbmwQjxEWxIfVtNBHTlsaDHwpvbxh2+7KqkYR56Z+Hx4ET8Rc4rqWfNQSl3Sibt8fpSYum9TQ== 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 (0) 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=TzzAZm9oYogXqez2TlMGxs3a+KLmFqZxsyGAqlGIiK8=; b=LTQsaA5xvuzJo3+XLZzUZkLDWNim0Qdnp8VJlQCRbEIIAy/+H8hLWUah00zgxK84E9Bq4kjNG4w0kPEMLZssDwQwdT5/9pbvILGJOUwWgnp2xtjqjCt8COyEFUYkGF51+e/KxNk35FFSub5ZOgStvSWdtGzZ/gNRmJOz/hbV9Kw= Received: from PH7PR17CA0062.namprd17.prod.outlook.com (2603:10b6:510:325::23) by CYYPR12MB8749.namprd12.prod.outlook.com (2603:10b6:930:c6::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7519.36; Wed, 1 May 2024 07:47:51 +0000 Received: from CY4PEPF0000EE34.namprd05.prod.outlook.com (2603:10b6:510:325:cafe::79) by PH7PR17CA0062.outlook.office365.com (2603:10b6:510:325::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7544.25 via Frontend Transport; Wed, 1 May 2024 07:47:51 +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 CY4PEPF0000EE34.mail.protection.outlook.com (10.167.242.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7544.18 via Frontend Transport; Wed, 1 May 2024 07:47:51 +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.35; Wed, 1 May 2024 02:47:50 -0500 From: Michael Roth To: CC: , , , , , , , , , , , , Subject: [PATCH 3/4] KVM: SEV: Add GHCB handling for termination requests Date: Wed, 1 May 2024 02:10:47 -0500 Message-ID: <20240501071048.2208265-4-michael.roth@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240501071048.2208265-1-michael.roth@amd.com> References: <20240501071048.2208265-1-michael.roth@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE34:EE_|CYYPR12MB8749:EE_ X-MS-Office365-Filtering-Correlation-Id: 537ed26d-c693-4ee8-4a06-08dc69b300cf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230031|36860700004|82310400014|1800799015|7416005|376005; X-Microsoft-Antispam-Message-Info: hQWUVhX00nM+DYhxT02EUQ4ptNhKwPYJBp96864jywBy31emY60asPL2W5d285MxZD6nFd67+uMYRcSGLvmabno979x/n5xxlCZzQDDe7D2ISL3DAXucacjoLThWfxPrccABObaRFoHy66hUYhtqbHAN6a997XcFJeAOZN1B7l3dtA2lyny5fsNJTuc79E5bj86A6QrwQZaN3FrPkM2nIikScvAa2PLCRPMopqptkkf+ANrtEJoRSnkOp4UEuuMxF7o4dLSNbxaR4ee7htnrufyfsFLQ4ylKHFEV7kRmGfAEsRUJevtfqiJVh8dIA8pJUlHciLkx/bqlstE8OiDQy9HEiu6hAlpQPIvfeko26v3LtjYj9CwBOjXr0aiIMxfcskTFfBiaDGPaRH0zmeLi0FJ/S3uU0LljqA+JD41Lq/DowYg5RmeOT61mEnQhFxvkSpUsWEJitHtus3QicEnaYyzWktxS369o+1LMX3Wwtdys0AYc4NfOUtHUA1TyfZpMx6xj3ZjIk/bU3+VkVqGmYeFFpiY6oJWS8ffj3SWHqz20KJztQQYSG5q+AIOuQx+t0AYyd2zjYRRSSDzV1s/IluroXwHW2KM6XJFS6s26QB8ohqQm4/ZvvqqH8lFEAMPj3gxCnwxA28yvqag0GQ9dIptE8DhyDc7vqSdHSyeUWakdVg8NoEReg4iNaa6nB+7+B6cRFne7bw1Gsqc7NNlmyJefA23EtVBECfcB8uvHOfRshrH5zeooxKm/wd6/aQFWwuhyeUdB2urUn1tXx+0pobjIIDZoIMR+8y0PpfNwqYwkyn8aKNahT65DGmcM5i5AihoOOGf7QdC8brpZ1xIYBYBqT1cjJiK7L0op63ZAfrqxNNVzdHaoVHDYx9tjA5YLZIMLTMuN6t2N32GMNvmUtigE6gFtnf4jJjLblxFd2abP4N1r5IWhj1xqwUBSb2ic3vjTEO5R6HXZ4aOUcFkLsVIx1fXoRmYgv87j/pwg6k6qopJFOf39UD1RcKXavgW4W67VBLkcmeCd8VF7ju0ZfmffMCLAlZdPdx/YZ38Ugw9i3zKEFou0ux19lJXe3f+gCw6hnFWXjZ0nc1xQ+bY6IzgKj3bxSezstj8RmSzLBbp/vw/mtZcEBPbNlgof3UHWxB+h0/hPvt+GUYJlfZQlzRQD492eBlhirgPtPv5192+YXPgLCa72zboo7LoKO1oYan5LTNA5a6wVLB+j7fh+nSQ0NsqPBIgfqLtsz8Z1l9LUm/AtZjoIQ+kJZvdaYn7KNiUlrT8PPjZ32PTxht10lHAmNAysNU49y0je223sNmOrUo7EdwBk8rGeQI6K6ABy4C55LP5GO8rQHP4p6CJqMZsgDii97YmIUNKM6ES9/G0= 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)(36860700004)(82310400014)(1800799015)(7416005)(376005);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 May 2024 07:47:51.2162 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 537ed26d-c693-4ee8-4a06-08dc69b300cf 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: CY4PEPF0000EE34.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CYYPR12MB8749 X-Stat-Signature: w87bqsfpq1jd6eofcxp9iqek8174c6ik X-Rspamd-Queue-Id: 3E2FE40022 X-Rspam-User: X-Rspamd-Server: rspam12 X-HE-Tag: 1714549676-380298 X-HE-Meta: U2FsdGVkX19Vxm8zHGgYKmU+KyUvzq6Qx6XMyq97Nb5Rhxyh15GNS2MjSMt88V9u+wLd2EKefImb+f6oY/Uh6ToLxRp0Wbpy+YH2fh2baQAAlWy/Y1TZQ6NMlJYt/4JlDxgg853TMEhswyyLn+xsUb+pjsE6CVSohAX6Vf1guZHTU1nH0hRt5cfrgxbvj9OF17f6O+5MX46D9tm3e0Z2p9MmgOTFOjQhxqseV+lIQzyr71lswstd6O+y9kyz2kh3YVCIXs7RpLEg15TEsSuBP1gP6tT6K/iDgvz7/0I1/71SVCW3co5rDW/DmbzScZYNilvLdAzultIXc8zh7zodhQJE4xQx9LoqpXU3QpfK0rwK3gixveUBpNheqSW2IzWoevKXU3ebNzyqbtiiKv1iF2vXAo1ga0YcIUcP4XOyQJDw+E5DH3pfUAAKag6WPhMmwf/93ynZ81yIOUdN5wtXuz499xU3eEdpgu1NWlzYW7y3rDHhyWx6IEOkh0Qds9ikfhJbn4xEmYH338sGIbj4cEn5UTAsRUEQUszHWKggTjm0UbWb4kMSbQ2S8O0Ox3I6R27SrGRTZ14sUfpkIGK8wn5jDDsdyNsL3Lac8EvBPkLzGRwRWy/S9PQ7yfsBDRR1RF0eQyjKstzku1BC7I8IYwX8CV/NkyM4RrP7mg7FrIxCW8iOYunU0vs58qzM/8thZZzbSuMIApZCU5b4+vGfShQs8Eb5M/o6dn83rfV6+8PufAk0mczdLuXvLUQJECFRHdd9sgNGWFfcXVO9GapFZt+CgNITwC3nOLxSrAelH/pfxz+3iilp84dVLmk4/rd1+xmnpJMNGqwaqEFFNnXrC/y7XJReQjr6eroClQKywBjmEHafc/660euqXdvSon596fhbjlJTj7XdIu3VfRVCBQOe9cqh6ICQuCX0XBPcTIjlcMOGYDm4tgTW9G/pizvQySXBEt7Y1A6lumDzsze 0Sx7gadB hww4GYmCg4cguO55kWTp+3zc/RiWejv81SlTb09hOJEv20VP+66FSDoz2JMMBtKL9r/H+Em4z1S0Mh9VXnz0yFAa8Higbf3JU9mhZyz/UfC5S8nwYbGlVOabrHio/MPEwD82W1g35qaSXUmBDmyWxj7dHTx2n8mQ2LTQ+h/mwmw8cVFi99fNNvTkNIQJclfbKSPPMYwn24rqOgqKJ0Nrv/lcKudVTTw4ObCVXHCFx/Egz2yQl2Zr54WfPuWSkasQp/DhOWl76nRy/cZVQmCVtKPmRCAiZLsTF8/JeFvVc3UgiB+H4bmrx4RtprfjjN82YBIW6RueBn4ytlpA= 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: List-Subscribe: List-Unsubscribe: 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. See 'Termination Request' in the 'Invoking VMGEXIT' section of the GHCB specification for more details. Signed-off-by: Michael Roth --- 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 37d396636b71..01baa8aa7e12 100644 --- a/arch/x86/kvm/svm/sev.c +++ b/arch/x86/kvm/svm/sev.c @@ -2704,6 +2704,7 @@ static int sev_es_validate_vmgexit(struct vcpu_svm *svm) case SVM_VMGEXIT_AP_JUMP_TABLE: case SVM_VMGEXIT_UNSUPPORTED_EVENT: case SVM_VMGEXIT_HV_FEATURES: + case SVM_VMGEXIT_TERM_REQUEST: break; default: reason = GHCB_ERR_INVALID_EVENT; @@ -3099,6 +3100,14 @@ int sev_handle_vmgexit(struct kvm_vcpu *vcpu) ret = 1; break; + case SVM_VMGEXIT_TERM_REQUEST: + pr_info("SEV-ES guest requested termination: reason %#llx info %#llx\n", + control->exit_info_1, control->exit_info_2); + 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",