Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp6268223pxb; Thu, 27 Jan 2022 09:56:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyby6tvyvZs7rmnCPRkjQd3yVORJIEW576o+/sPvZthcgjVhwddVcDEbp3K9UXqdshmTCf+ X-Received: by 2002:a17:906:5e0f:: with SMTP id n15mr3745952eju.744.1643306200277; Thu, 27 Jan 2022 09:56:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643306200; cv=none; d=google.com; s=arc-20160816; b=SOsBwYOpRPxZML55Aq9XWdhx8jsc6VhEcmoqAEhCtnxkD6IzhngACTPpqwHrjWI36R sKZaAoemcHmPqsAUJyk1xngVMvN1IpbXANQkypr6JNlpi+i6TBwlQqzxbnuzZoIqG0FT tZH/uaSyhjmEGv9VbUSCfagwY3sq+15RM2vvIn8Uz1QzAbJmqH7qEgMZJLAFgIv5jqzr x7fG2giyZlj74uWPQa+Cj/aBmmCR6MUlb6JGcon9Aq56Uzgc5jyeuqSHLC9XQK9XYP3a Is8JPoeSWBT+Qkw97spRIo7x5mbhgZKQKg3OTKNOWCJ2ZVW21yd8R1h/Y2OMLAJ1Ty4w +Nzw== 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=G9CuS+mctTq028RCsO9cUCYYLUcxXanATlrv6H403eg=; b=Z/IxELF0bJvct9dXqgpIE7fzEp+Td7svJqDmsxdhFr3ZX9XYAGKbs8TF2KBHyZfQMB zxbUgCAw/qJC1Fexhe6GzWhW7MY+91jkMhnpmTlRvkUEIqZmoxcbw+wb0m9ZPan2spSp FWfxQDsuceBS2VGWICYaFa7tQP1DCXMa/r2sr9vUaLjtzrH7rtiIKg8d7sloEhLFDXOG ZNheQtgbAfNhLwj/K0fchQEHKZwNtt1/wsgSO8xoj7i6dS/+Q9ks1icYm2JRoxgMRafO eUWLa/cDg8eNg99PBnKrZvPgJMvocP5bnzoUNgffhnAvar5uDzx0HiwfzuZrDBH3DrK+ paHQ== 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 u25si1619150edd.329.2022.01.27.09.56.14; Thu, 27 Jan 2022 09:56:40 -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 S239131AbiA0KLk (ORCPT + 99 others); Thu, 27 Jan 2022 05:11:40 -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: linux-kernel@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