From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38E0DC433F5 for ; Thu, 27 Jan 2022 10:11:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239042AbiA0KLa (ORCPT ); Thu, 27 Jan 2022 05:11:30 -0500 Received: from 8bytes.org ([81.169.241.247]:47998 "EHLO theia.8bytes.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238960AbiA0KLZ (ORCPT ); Thu, 27 Jan 2022 05:11:25 -0500 Received: from cap.home.8bytes.org (p549ad610.dip0.t-ipconnect.de [84.154.214.16]) (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 07031D35; Thu, 27 Jan 2022 11:11:24 +0100 (CET) From: Joerg Roedel To: x86@kernel.org Cc: Joerg Roedel , Joerg Roedel , Eric Biederman , kexec@lists.infradead.org, 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-coco@lists.linux.dev, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org Subject: [PATCH v3 09/10] x86/sev: Handle CLFLUSH MMIO events Date: Thu, 27 Jan 2022 11:10:43 +0100 Message-Id: <20220127101044.13803-10-joro@8bytes.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220127101044.13803-1-joro@8bytes.org> References: <20220127101044.13803-1-joro@8bytes.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org From: Joerg Roedel Handle CLFLUSH instruction to MMIO memory in the #VC handler. The instruction is ignored by the handler, as the Hypervisor is responsible for cache management of emulated MMIO memory. Signed-off-by: Joerg Roedel --- arch/x86/include/asm/insn-eval.h | 1 + arch/x86/kernel/sev-shared.c | 3 +++ arch/x86/lib/insn-eval-shared.c | 7 +++++++ 3 files changed, 11 insertions(+) diff --git a/arch/x86/include/asm/insn-eval.h b/arch/x86/include/asm/insn-eval.h index f07faa61c7f3..c3eb753a912b 100644 --- a/arch/x86/include/asm/insn-eval.h +++ b/arch/x86/include/asm/insn-eval.h @@ -40,6 +40,7 @@ enum mmio_type { MMIO_READ_ZERO_EXTEND, MMIO_READ_SIGN_EXTEND, MMIO_MOVS, + MMIO_IGNORE, }; enum mmio_type insn_decode_mmio(struct insn *insn, int *bytes); diff --git a/arch/x86/kernel/sev-shared.c b/arch/x86/kernel/sev-shared.c index b12fb063a30e..1aa33509c7b5 100644 --- a/arch/x86/kernel/sev-shared.c +++ b/arch/x86/kernel/sev-shared.c @@ -698,6 +698,9 @@ static enum es_result vc_handle_mmio(struct ghcb *ghcb, struct es_em_ctxt *ctxt) if (mmio == MMIO_DECODE_FAILED) return ES_DECODE_FAILED; + if (mmio == MMIO_IGNORE) + return ES_OK; + if (mmio != MMIO_WRITE_IMM && mmio != MMIO_MOVS) { reg_data = insn_get_modrm_reg_ptr(insn, ctxt->regs); if (!reg_data) diff --git a/arch/x86/lib/insn-eval-shared.c b/arch/x86/lib/insn-eval-shared.c index ec310b5e6cd5..ddec72fccdd2 100644 --- a/arch/x86/lib/insn-eval-shared.c +++ b/arch/x86/lib/insn-eval-shared.c @@ -898,6 +898,13 @@ enum mmio_type insn_decode_mmio(struct insn *insn, int *bytes) *bytes = 2; type = MMIO_READ_SIGN_EXTEND; break; + case 0xae: /* CLFLUSH */ + /* + * Ignore CLFLUSHes - those go to emulated MMIO anyway and the + * hypervisor is responsible for cache management. + */ + type = MMIO_IGNORE; + break; } break; } -- 2.34.1