Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp487140pxu; Fri, 11 Dec 2020 07:05:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyrOQcJCmjr9xzN8TcAKSAYTobsBjvF2EskHQlOsIscvJyzS9HjaJK1V9hADs87U28nyQDr X-Received: by 2002:a50:f61b:: with SMTP id c27mr12121865edn.61.1607699156735; Fri, 11 Dec 2020 07:05:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1607699156; cv=pass; d=google.com; s=arc-20160816; b=0iqki91tUPNMHMC+HEYt8xmdhniscVe0XJbyB4Ny3jAtX92rFAmWdIDlDvkv0z3Crg LcI8o3qQBWxJA7rRS5zESVtQbulc0LtZxX2XR+UbDIkILYT9cLZfwnZgbGdLS45Wx8mI tx7tQb965NYCX4u+tFQKiShQBWIKIaWyVZL5F103zLblvxEbHmL49zm/R56lH1zzjd3V LB4OXZdjNKdrmVUj4itwFxfH5fZtRnhdrsmGRGxiEYfWrpBWlKpYqC/fKpMfsijVxM/0 gbvWQlnAcyhhQ+IkAGRzB+sUEEdNsUI0WoteR24ERc10QP0RTfwHnsLgRwZFRqWIrjuH 3N8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HP/5Th62f8/BaTNryP9EmMDjhB5bsdKIYw1YeOXgs90=; b=BrBukcJrp8aCmsVm3miAcMXsofnVtm/A6VMUwB8KwtO7flYUMPs0tEvA4OUewboXop cUZhe94dTsaFO/GQVmE1jdFWwPoZmSSU1iwhfRbrKqCjvYfOo/qAk4187jf++fegMrIE lao4JVsg0SKCRrWNg76lCNJbXCNsL8OunsL8XOTPgJQ2Q+Q42lXgiHksStlS9d/5ZP4s XzUxgSjI1uYrGVFDwr0+/lf0PMT3dURZzjcg7nmbsvoJ10MoMl2pRtk6PaU5tWb7ZFUg hT4mxVadhIHIfo7BQa1hCac/M9FQmdqSg34p1VH6l+GMG1XDXv5Kxst5TGR9M/t9F43F 4VcQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=itf0s1V2; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=amd.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bs4si4844713edb.555.2020.12.11.07.05.32; Fri, 11 Dec 2020 07:05:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amdcloud.onmicrosoft.com header.s=selector2-amdcloud-onmicrosoft-com header.b=itf0s1V2; arc=pass (i=1 spf=pass spfdomain=amd.com dkim=pass dkdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392538AbgLJRNz (ORCPT + 99 others); Thu, 10 Dec 2020 12:13:55 -0500 Received: from mail-bn8nam11on2055.outbound.protection.outlook.com ([40.107.236.55]:12128 "EHLO NAM11-BN8-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2392117AbgLJRNW (ORCPT ); Thu, 10 Dec 2020 12:13:22 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fw6hfw6lgpIbfnmHMLYHT2G/6/+1fI7baWiFUFAEXTUepPOn2Ro+kCgCm6r9iLzxN0ArGVsGqsw/WWYXaucQ6hgu3WbkhZFJ/Ha5QsECJt4CN1/0u4u9XAM/fdNJRYakW8WQL5men8ak40sZ84zBLvV4dL9CXJvxdkBi8Jd5jEwAoRJQfHQthn5blE7ceJOmb3/SJEc9GuDACyFs6AK7Uw88Ce3viIwL2OjaTSyPqhhm0J1sUA6elZB5h2ZwvA/RIab/lZ6nusDWZJVKJCO3F0F6Dk7e9xPdMQT6yIhLEqxOgqqYHmABjZY3p5XQAy+SJHSrEYMmbTYC9eDBB142ig== 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-SenderADCheck; bh=HP/5Th62f8/BaTNryP9EmMDjhB5bsdKIYw1YeOXgs90=; b=E34gG3JqZpmlllUpJ7h8gvYnthlhkxLcz0QKyI22xm2uuY6AYLSMzCvypFloZ4ObdJ1uE7wh0L+IejDiGxsq0W18K5IOvA6u7eCNQsPbZCdCXkjWTxf/zSKchWZRz1sIT8pLMj1BWiARumZEpeDECFALQCt6wtbmDgY9AQ6KmJ3hSi7duxGsrhRrLqh/IkTcL7WxmEwyRvHuee1E0VMGmM7//Mtl8aQxX7Tx7wwZf1gCZWU88NuLZatnM84YdoqoEzB4RZF6mSwYkQ3op4CD2+Z0wBTQezNCd5dazxARXwU38mLYTOGVQg2EhekwijgvCuzWDgrwKRmMu6nBNu/3Jg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amdcloud.onmicrosoft.com; s=selector2-amdcloud-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HP/5Th62f8/BaTNryP9EmMDjhB5bsdKIYw1YeOXgs90=; b=itf0s1V2oyiEMsKrLD9adn6Zu8avhxzvhBpY/qhqcodXIgzB7XAwGRpEbVy81d70BNwjB5XC8jfxpTr4dQrkzC6g7ea261zqB8QHpIfy6sFeJgrn822Dc8sdPxE/7V+4SXZpfe6BiMG5no/8HWujXEE1Jf+u+HjavnrDqmlhgy8= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) by CY4PR1201MB0149.namprd12.prod.outlook.com (2603:10b6:910:1c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12; Thu, 10 Dec 2020 17:11:46 +0000 Received: from CY4PR12MB1352.namprd12.prod.outlook.com ([fe80::a10a:295e:908d:550d]) by CY4PR12MB1352.namprd12.prod.outlook.com ([fe80::a10a:295e:908d:550d%8]) with mapi id 15.20.3632.021; Thu, 10 Dec 2020 17:11:46 +0000 From: Tom Lendacky To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org Cc: Paolo Bonzini , Jim Mattson , Joerg Roedel , Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Borislav Petkov , Ingo Molnar , Thomas Gleixner , Brijesh Singh Subject: [PATCH v5 10/34] KVM: SVM: Cannot re-initialize the VMCB after shutdown with SEV-ES Date: Thu, 10 Dec 2020 11:09:45 -0600 Message-Id: X-Mailer: git-send-email 2.28.0 In-Reply-To: References: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Originating-IP: [165.204.77.1] X-ClientProxiedBy: CH2PR14CA0012.namprd14.prod.outlook.com (2603:10b6:610:60::22) To CY4PR12MB1352.namprd12.prod.outlook.com (2603:10b6:903:3a::13) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from tlendack-t1.amd.com (165.204.77.1) by CH2PR14CA0012.namprd14.prod.outlook.com (2603:10b6:610:60::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3654.12 via Frontend Transport; Thu, 10 Dec 2020 17:11:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: 20998994-1242-4bde-6c23-08d89d2eacf2 X-MS-TrafficTypeDiagnostic: CY4PR1201MB0149: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4502; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G3kSDLlmZ5T2zqY8AtivJpUzRHYsIFey0Mq5JUO6rD4m3BlkhrZzYmi4PjPqXbXPTihmwZ66pFER50FfNqatwzqYo1/4O7WastWnhyrAuZImc18LV7i/XeIBU5zNzXk2fClLBfrJigLYtZ1I6WOuOokQMkqRt+7vqep3Qu0o3GvDeYz//CcBR8q/QduRGSA5gMzQqum7ZPf1Ic6qusAVDB++nRDiqX2HKzRl8LSWaKAkewvYlI75lnSpOCNcxoD/CP4WkVTlwgVXygDxs6RK9OeZI0P4perz+5vfNIkhGdMza5CCyc63oURiX0okYmmJ9aw5ZngpRNSCaEJhQerJ8RAZoXdtGHBroTvsVgt+0vfitBrqQPhmi2FU/yvP8anN X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CY4PR12MB1352.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(346002)(376002)(366004)(2906002)(5660300002)(26005)(52116002)(186003)(16526019)(54906003)(6486002)(956004)(2616005)(8936002)(7696005)(4744005)(508600001)(66946007)(66476007)(36756003)(8676002)(86362001)(34490700003)(4326008)(7416002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-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GQWuRImVGMHoQIcL5aKqZzcieDfcVi1WZOnAGA+o?= =?us-ascii?Q?LtAATdWtugJ50e9NyQox86CrwjjzcaZ8oq8Vo0dlKb7DFYYypn33LEK2bg2c?= =?us-ascii?Q?/9+6YdwMMQaKzVGGfSH0epQA5+wPJfZnPXG/fRYG65/CRiyavl70YeuD31CD?= =?us-ascii?Q?5aCG?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-AuthSource: CY4PR12MB1352.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Dec 2020 17:11:46.7330 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-Network-Message-Id: 20998994-1242-4bde-6c23-08d89d2eacf2 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: QInn8f+M0exGxK8DnxOzfKAv7AqtLizHnI5D8EokoF2iPRV3BTV0CYe9+zPWP9Tp87hbi8GdXmaZhIWK0JeafA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY4PR1201MB0149 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tom Lendacky When a SHUTDOWN VMEXIT is encountered, normally the VMCB is re-initialized so that the guest can be re-launched. But when a guest is running as an SEV-ES guest, the VMSA cannot be re-initialized because it has been encrypted. For now, just return -EINVAL to prevent a possible attempt at a guest reset. Signed-off-by: Tom Lendacky --- arch/x86/kvm/svm/svm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/kvm/svm/svm.c b/arch/x86/kvm/svm/svm.c index 81572899b7ea..3b02620ba9a9 100644 --- a/arch/x86/kvm/svm/svm.c +++ b/arch/x86/kvm/svm/svm.c @@ -2030,6 +2030,13 @@ static int shutdown_interception(struct vcpu_svm *svm) { struct kvm_run *kvm_run = svm->vcpu.run; + /* + * The VM save area has already been encrypted so it + * cannot be reinitialized - just terminate. + */ + if (sev_es_guest(svm->vcpu.kvm)) + return -EINVAL; + /* * VMCB is undefined after a SHUTDOWN intercept * so reinitialize it. -- 2.28.0