Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1199263pxb; Wed, 10 Feb 2021 02:36:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJyBLH5w+dtXuvmuKkueV8BZIdCQ27Uj5Do7uXQXgH+HBYV005KYhgKrrW3NzlxvHd6f52Ck X-Received: by 2002:a50:d6c1:: with SMTP id l1mr2557998edj.336.1612953370297; Wed, 10 Feb 2021 02:36:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612953370; cv=none; d=google.com; s=arc-20160816; b=hs7SMyXJVAAZfvQLQviMZWsGcR86pibKXHkTpE5w+y3WxCJ7lt+GxQpUGP/VbON8Ke 86PHYHumwUtpPc3NOGLC81Bwl/HVsfrq+C3DsMyOmaSzAzJkhA2945CWIVfunzMjjy6m wSu5v53nJM3d5j7FxK5FBKCogFPSdCEuB3+2jQdwoNOosesV0/6XfT9l46uWiNf6LzlM yLUk3CeXwkwsLitE3uHM7SWATOkZtCEXqMEz+iF21PQrc904Ta6Pna8O2sNGFqmii1mP mnwRG2wuOTcgM79bQjvZWSG85ip4p61al0iavAJ76druaWn7I3OXhn8NMyhA9Pb4ZKkO 1O+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=OJvPStj1bSD6Eu8J8Y0P513P5X9ZMjlXWtR3JQ99SKs=; b=P2m0UYttDtc+rpkiCniJ1A6yfJpK18bThQaY/FlvXR66oHLZLTlss0VgtzcDwFomWW WxsBzQqoCC5AIw839P9kwCsmsaC1OSU0DJRyESra9lBs8SVbXXiaf1NanV8UspHZdC9F 5V71B3d4JkxY9kb4RiCEeciE2yypY2gEzHq9vSkXXoHyf/Z6Sae16GMA+UqK14DuOaRI 59wi97d2MJmnQFW7BJhPAlmEEf6mxiyjaxI1BniyMVWTrLA09YQcTAmYLeiQvTHtXThd w5kluvEMeYo/GP7UxTxQYaZXXdmoHn2URz5/X1WX5eJnLG4upT6iXwI8Op8iOdFTjY46 L+3A== ARC-Authentication-Results: i=1; mx.google.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=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id jl7si1027400ejc.746.2021.02.10.02.35.47; Wed, 10 Feb 2021 02:36:10 -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; 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=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231326AbhBJKdB (ORCPT + 99 others); Wed, 10 Feb 2021 05:33:01 -0500 Received: from 8bytes.org ([81.169.241.247]:55276 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230508AbhBJKWm (ORCPT ); Wed, 10 Feb 2021 05:22:42 -0500 Received: from cap.home.8bytes.org (p549adcf6.dip0.t-ipconnect.de [84.154.220.246]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by theia.8bytes.org (Postfix) with ESMTPSA id B66804B5; Wed, 10 Feb 2021 11:21:58 +0100 (CET) From: Joerg Roedel To: x86@kernel.org Cc: Joerg Roedel , Joerg Roedel , hpa@zytor.com, Andy Lutomirski , Dave Hansen , Peter Zijlstra , Jiri Slaby , Dan Williams , Tom Lendacky , Juergen Gross , Kees Cook , David Rientjes , Cfir Cohen , Erdem Aktas , Masami Hiramatsu , Mike Stunes , Sean Christopherson , Martin Radev , Arvind Sankar , linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH 7/7] x86/sev-es: Replace open-coded hlt-loops with sev_es_terminate() Date: Wed, 10 Feb 2021 11:21:35 +0100 Message-Id: <20210210102135.30667-8-joro@8bytes.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210210102135.30667-1-joro@8bytes.org> References: <20210210102135.30667-1-joro@8bytes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel There are a few places left in the SEV-ES C code where hlt loops and/or terminate requests are implemented. Replace them all with calls to sev_es_terminate(). Signed-off-by: Joerg Roedel --- arch/x86/boot/compressed/sev-es.c | 12 +++--------- arch/x86/kernel/sev-es-shared.c | 10 +++------- 2 files changed, 6 insertions(+), 16 deletions(-) diff --git a/arch/x86/boot/compressed/sev-es.c b/arch/x86/boot/compressed/sev-es.c index 27826c265aab..d904bd56b3e3 100644 --- a/arch/x86/boot/compressed/sev-es.c +++ b/arch/x86/boot/compressed/sev-es.c @@ -200,14 +200,8 @@ void do_boot_stage2_vc(struct pt_regs *regs, unsigned long exit_code) } finish: - if (result == ES_OK) { + if (result == ES_OK) vc_finish_insn(&ctxt); - } else if (result != ES_RETRY) { - /* - * For now, just halt the machine. That makes debugging easier, - * later we just call sev_es_terminate() here. - */ - while (true) - asm volatile("hlt\n"); - } + else if (result != ES_RETRY) + sev_es_terminate(GHCB_SEV_ES_REASON_GENERAL_REQUEST); } diff --git a/arch/x86/kernel/sev-es-shared.c b/arch/x86/kernel/sev-es-shared.c index cdc04d091242..7c34be61258e 100644 --- a/arch/x86/kernel/sev-es-shared.c +++ b/arch/x86/kernel/sev-es-shared.c @@ -24,7 +24,7 @@ static bool __init sev_es_check_cpu_features(void) return true; } -static void sev_es_terminate(unsigned int reason) +static void __noreturn sev_es_terminate(unsigned int reason) { u64 val = GHCB_SEV_TERMINATE; @@ -210,12 +210,8 @@ void __init do_vc_no_ghcb(struct pt_regs *regs, unsigned long exit_code) return; fail: - sev_es_wr_ghcb_msr(GHCB_SEV_TERMINATE); - VMGEXIT(); - - /* Shouldn't get here - if we do halt the machine */ - while (true) - asm volatile("hlt\n"); + /* Terminate the guest */ + sev_es_terminate(GHCB_SEV_ES_REASON_GENERAL_REQUEST); } static enum es_result vc_insn_string_read(struct es_em_ctxt *ctxt, -- 2.30.0