Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp931057pxk; Thu, 10 Sep 2020 02:25:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwE4MXKrWfxzbTFum1aHdj69MS/ubp7VnBA91LNPkfs/kPNaY88e3n74SnqQ6x/Wayx67pd X-Received: by 2002:a17:906:30c5:: with SMTP id b5mr7973016ejb.98.1599729932075; Thu, 10 Sep 2020 02:25:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599729932; cv=none; d=google.com; s=arc-20160816; b=iA5OkfetXNjCAuiaCdkTrxvbXyuLK8rbwDL36UIA/3I9TVtcLv2aUqhwaZn5zULpPO QiLIeBHnK5ZpTiB9pXH7BSbF54861mauA1TVqOCG+mO1TgbpfQeXSRuM55QRhbH94iMe QIRIuyK80mUfkBPHUUxFEY52g3Rco5rz8i10OlqEbweTwwbGdhF+vb4/4OcNUiIJViyH RJEnWY5nlSPBDtcTzI0jm5I2/tEZ7Idnohv8G7X14+jcgmEP5UYUe3++MCA/pjW/sUjN 7dWJ83OMosJ4cEVCMZ9lapz0SFNEwmE0msZl7yFWsowWqFBLt7P/RYVsmsXXgVF/vvDF TNEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :robot-unsubscribe:robot-id:message-id:mime-version:references :in-reply-to:cc:subject:to:reply-to:from:dkim-signature :dkim-signature:date; bh=VTdy7/EBirJXydnNikKRqtOCcrlDzKtIRzM3jUW6CRc=; b=bGWdtR0frZ2/PRNkMe3GJvflGJHAZf+Z7FfB/7i6B6vYAoUrPTVu3wya4UeOZzE9Wi BnqXMMcTTRHI24Jyfbks0s0cYb0lQ2Z5Bzg38P4Y5bJ0Ws9IEUZrMo/sOLYAhCxsMt6e LglYrTm5IhZQscrVWYvUFe/NItuh2Dp2NFTT7o2/PmkbrLFPJ9oiGFMuNbZ9BiZ6ZvSa qlG4nDRfEGGPFUGgdpEjxV66YsH/7OOcEzNIQL6EvrZztMEVOvDp6ZVOQwpAt5pnhoXc 0v42lnjz7hXL6GJd9UA2ZBI6pPmotGJzQNV5iTmvPP2Ph1aA0DlVs3skDzfcoGGtoHlo L7ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b=SEApkfvh; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t7si3279601edt.107.2020.09.10.02.25.09; Thu, 10 Sep 2020 02:25:32 -0700 (PDT) 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=fail header.i=@linutronix.de header.s=2020 header.b=SEApkfvh; dkim=neutral (no key) header.i=@vger.kernel.org header.s=2020e; 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=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730466AbgIJJXb (ORCPT + 99 others); Thu, 10 Sep 2020 05:23:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730293AbgIJJWS (ORCPT ); Thu, 10 Sep 2020 05:22:18 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E0E43C061786; Thu, 10 Sep 2020 02:22:14 -0700 (PDT) Date: Thu, 10 Sep 2020 09:22:05 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1599729726; h=from:from:sender:sender:reply-to: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; bh=VTdy7/EBirJXydnNikKRqtOCcrlDzKtIRzM3jUW6CRc=; b=SEApkfvhDwcszC1xpl/XIuEfUKCzRuEOTg/w85qMQSlDLw1KCdMvhr7Rli+92M/9TZR9hY edeABXSqkneLmnInznUSrBps2cyR26k7x1wBb1BlZgTABlZQwY8NrfGm6sa5b6OlZcFJ00 Q2wqLxWDIf6Sc6FYjqnuWUC+Sqq5NGl/3IRPQcnpSo7nSm9A8aZBMpnhfBcY6Kei08b3ZR cmvdmk4Z/ureCSBxFcxxIrQKXiabHIXjv2tRpSvDm8N6zlk0Q3CBGt6Egm75OHOHhd25gl Urtkvszb31OIdAAVmSYV1aG12hZR98+98fa6aj18K9uC+bwld7iDnE9jzZKH9A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1599729726; h=from:from:sender:sender:reply-to: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; bh=VTdy7/EBirJXydnNikKRqtOCcrlDzKtIRzM3jUW6CRc=; b=W62LrPRT9IImw3snr+EAhL6afa2sxbAoervRio0q9KMtLBd1Rd6R+TYA3hZJatAYN9yl08 rKVa+3YEvhCTnCDg== From: "tip-bot2 for Doug Covelli" Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/seves] x86/vmware: Add VMware-specific handling for VMMCALL under SEV-ES Cc: Doug Covelli , Tom Lendacky , Joerg Roedel , Borislav Petkov , x86 , LKML In-Reply-To: <20200907131613.12703-65-joro@8bytes.org> References: <20200907131613.12703-65-joro@8bytes.org> MIME-Version: 1.0 Message-ID: <159972972557.20229.773744278485296601.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/seves branch of tip: Commit-ID: 1a222de8dcfb903d039810b0823570ee0be4e6c6 Gitweb: https://git.kernel.org/tip/1a222de8dcfb903d039810b0823570ee0be4e6c6 Author: Doug Covelli AuthorDate: Mon, 07 Sep 2020 15:16:05 +02:00 Committer: Borislav Petkov CommitterDate: Wed, 09 Sep 2020 11:33:20 +02:00 x86/vmware: Add VMware-specific handling for VMMCALL under SEV-ES Add VMware-specific handling for #VC faults caused by VMMCALL instructions. Signed-off-by: Doug Covelli Signed-off-by: Tom Lendacky [ jroedel@suse.de: - Adapt to different paravirt interface ] Co-developed-by: Joerg Roedel Signed-off-by: Joerg Roedel Signed-off-by: Borislav Petkov Link: https://lkml.kernel.org/r/20200907131613.12703-65-joro@8bytes.org --- arch/x86/kernel/cpu/vmware.c | 50 +++++++++++++++++++++++++++++++---- 1 file changed, 45 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c index 9b6fafa..924571f 100644 --- a/arch/x86/kernel/cpu/vmware.c +++ b/arch/x86/kernel/cpu/vmware.c @@ -33,6 +33,7 @@ #include #include #include +#include #undef pr_fmt #define pr_fmt(fmt) "vmware: " fmt @@ -476,10 +477,49 @@ static bool __init vmware_legacy_x2apic_available(void) (eax & (1 << VMWARE_CMD_LEGACY_X2APIC)) != 0; } +#ifdef CONFIG_AMD_MEM_ENCRYPT +static void vmware_sev_es_hcall_prepare(struct ghcb *ghcb, + struct pt_regs *regs) +{ + /* Copy VMWARE specific Hypercall parameters to the GHCB */ + ghcb_set_rip(ghcb, regs->ip); + ghcb_set_rbx(ghcb, regs->bx); + ghcb_set_rcx(ghcb, regs->cx); + ghcb_set_rdx(ghcb, regs->dx); + ghcb_set_rsi(ghcb, regs->si); + ghcb_set_rdi(ghcb, regs->di); + ghcb_set_rbp(ghcb, regs->bp); +} + +static bool vmware_sev_es_hcall_finish(struct ghcb *ghcb, struct pt_regs *regs) +{ + if (!(ghcb_rbx_is_valid(ghcb) && + ghcb_rcx_is_valid(ghcb) && + ghcb_rdx_is_valid(ghcb) && + ghcb_rsi_is_valid(ghcb) && + ghcb_rdi_is_valid(ghcb) && + ghcb_rbp_is_valid(ghcb))) + return false; + + regs->bx = ghcb->save.rbx; + regs->cx = ghcb->save.rcx; + regs->dx = ghcb->save.rdx; + regs->si = ghcb->save.rsi; + regs->di = ghcb->save.rdi; + regs->bp = ghcb->save.rbp; + + return true; +} +#endif + const __initconst struct hypervisor_x86 x86_hyper_vmware = { - .name = "VMware", - .detect = vmware_platform, - .type = X86_HYPER_VMWARE, - .init.init_platform = vmware_platform_setup, - .init.x2apic_available = vmware_legacy_x2apic_available, + .name = "VMware", + .detect = vmware_platform, + .type = X86_HYPER_VMWARE, + .init.init_platform = vmware_platform_setup, + .init.x2apic_available = vmware_legacy_x2apic_available, +#ifdef CONFIG_AMD_MEM_ENCRYPT + .runtime.sev_es_hcall_prepare = vmware_sev_es_hcall_prepare, + .runtime.sev_es_hcall_finish = vmware_sev_es_hcall_finish, +#endif };