Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1183166lqe; Mon, 8 Apr 2024 00:43:59 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXkL5ptZ6Zmo5pLpnxdKMPBblHRKMptffq3MLjXj8PJGYTSXWp8U//ZwiSqfQMv9fCg1+XbGnXY5VHNGsOESQQIB85yCzTkhFBqKP8Rbw== X-Google-Smtp-Source: AGHT+IESDjM6/yk+chQXTqc0rzcDUnWg/N1ULJmD3ToXdD6Q57mFKFurXhg60XWper0VKKtoQdQw X-Received: by 2002:a05:6358:7d96:b0:183:6427:10b8 with SMTP id z22-20020a0563587d9600b00183642710b8mr7689468rwf.23.1712562238868; Mon, 08 Apr 2024 00:43:58 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712562238; cv=pass; d=google.com; s=arc-20160816; b=QWCFahvHh9YANs2O2VG6/CtqHApPk2/QoLsrBWYCG5uNcD0j2hEm+FS/h1/GvVkRh3 PXIcPZBW2ieZxI7a/iJxXvpczCkBfMDd51zTME4gI1ZjqMvKypbtrg3Fq8dgBHJBig0u JwnrT2wwObJyZoqUny75vH3AxqqcJS4+6U08UIi3Z10vJHq8xygzS2TOENFWndC0dPzp 0GuhNOR0FLH0p7ALZcLEJxt+lZfJxlfPsX+UjvbKWi34T/H4irjoeeNYd9HH2y7CBuTo TN1tugLoA/KN092wHh+vy5/tLCE5elZeqsRX4P9dlQ7qm24T8Upkx3+cOF9RgPJNygKV QvuA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=AJPEklCzoS2DFb7f9ZXxyBC3nyK2AChPfFAIeZ8KZAI=; fh=48moRK8ij2tMdLsVh3vWNKPN9IvXeO524A2+/a9yn50=; b=cWwqjANze26k8zk3aWuhyVLMqn8252W57wLlNaK4WjveAGpF21UDFVzN7EHMQgHUEb uWWjxdj3ZmjQqyrSNoBBBhKPAeioClNSpk7Roov3bzK9RGKN/05N8va6vK+jSIalRaum 7qHYuoYTPAhonSbXR//+pEZvZ5/97SuU+ToBayUi23HGn7U0baibbNz29ND6O5qHqnAB V7gNHqTlQTv0KPRTYnJLHQJ349y5o9yj0xtFAuvoNMSh+WXArNmUomlbNWYYucDaVx1Z pQ7tdSFFhFOPRiEEdWq5l6GClm5U9Qx3OtNph4f6si6YTYIVgXdfaWCDP+AT9nor4ulZ 9bRA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="f9/BqaWp"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-134921-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134921-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id e184-20020a6369c1000000b005dc8a59e303si5527569pgc.111.2024.04.08.00.43.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 00:43:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-134921-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="f9/BqaWp"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-134921-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-134921-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 60953283B1F for ; Mon, 8 Apr 2024 07:43:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 42174482E9; Mon, 8 Apr 2024 07:41:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="f9/BqaWp" Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AA919482DB; Mon, 8 Apr 2024 07:41:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712562081; cv=none; b=BLwNC4b5y4KZrwwRv6UmzS4oAHO2uL+26svHq7vGu/+HnCHGNgPlzJRNQZb5Rdge4c5Yl05rGcNaz4WgRuM9oV2038cVQW31GeViSINurn5Fe5/Ce6C28rOl2bhujMGagaP8gP/76mz/5WhVHubUbhGkaU9GyXefLUWPart30go= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712562081; c=relaxed/simple; bh=HH1sJn4b3V30rPMVBuHlYzoyuDIoo8e0e1oZipDtD1M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=O63kiKKuAa9nLQ9TCfthOhokR0MfW9H5i8F12ttJ7ySRvZRzf0qXaPr6tkmFXjWhINy4NqMZ5cvgOxjes2Za3kKocn9oBrZtjtAWn5gumcUu6YHEG0/5zHJ6FVKP8RFgE6/25BIG8b8iG56EpDdaZ8gLJN7PJ0sc6Fmmonm4JUQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=f9/BqaWp; arc=none smtp.client-ip=209.85.167.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f47.google.com with SMTP id 2adb3069b0e04-516d4d80d00so3050278e87.0; Mon, 08 Apr 2024 00:41:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712562078; x=1713166878; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AJPEklCzoS2DFb7f9ZXxyBC3nyK2AChPfFAIeZ8KZAI=; b=f9/BqaWpnL9FZAK2QZzdNA6mMlpfZkQ5i7yk7OpIl16ca+yfdPJy9zrT8ezz8GE00+ c15kBVYY5ZZA6YDB+0h+2ySAAgoKp8DiGN3zkUvfzEEGoAE5LWKeO4E6sP7ZwmQ1tgHh Wwxva+rpFrQBKb9RlhO/KJytYF/0u93+heFK3x80+5nUwr72rgJ/zlcwoS07GYMgt9wh HeWMzIBebR7MpHjCc8oUXWcV41Z0aYPsbWEkfYWxKUdUZF8r8MG4kEzBInr3mnu3VsQV IO76EDFq3ghbzrDv8ltt8WG0SACEwKCV2rBO/XqQ3eoR9SWUCOH0V+MqIHvEzWiSfmkg 54Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712562078; x=1713166878; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AJPEklCzoS2DFb7f9ZXxyBC3nyK2AChPfFAIeZ8KZAI=; b=MmD9Ss9e+KMliucR5xLGiR7CUOcRD1vXirfW5/YHukzNO75aPiBXMe+j+I6IzK4BTk PvZzpE3FFHPju+DCUPh18C2825NopoVjvZV6a0/6boTRt7z8yLkOGtpqY5Qzm9Cy1tcZ WHdc1FywAAjTYCUmIPsZvffQzJUVAGBObmwrZtxovKIyZLUjQkAeBTNLqUcQyW4MNeCl IVqhnRdUz0sBYyNUgZgKE0Nt0Co29VsNrQswQK8StFz6AkOyFhq0+N+guI3oH+8H2o29 u3323nql8Gf7TleXCSXR4YMYwmlF/TKdSBoJv/IjP5Z5N9Kv+hqUOU/cC92ylVftYExe YvCw== X-Forwarded-Encrypted: i=1; AJvYcCXN62ss7ymvZtuXkUYmLhUQO5GiON7gKASpEF5iO0/y9nesu7wVntFOFXTmeHQXyXFmv09tG9s1d36AWzUNy36anzKALhNzF7VkqFQ3I8PUiaDQzELGfDYM4LuH7FnD8mWYU6PRSJDKwpaTKgQzOa4dvrF6RNOY149i X-Gm-Message-State: AOJu0YzzpUhhyR6FNs5aIGtxexYYKfBiXKTquXAImyK/wlIjUMO0JWbz lGujMEiak3Z08lmy9I8o1tW2LHzwcByvOf4959ZhqWr0OFvlTfrQ X-Received: by 2002:a05:6512:3618:b0:513:d5ea:1d21 with SMTP id f24-20020a056512361800b00513d5ea1d21mr5855791lfs.69.1712562077693; Mon, 08 Apr 2024 00:41:17 -0700 (PDT) Received: from vasant-suse.suse.cz ([2001:9e8:ab70:9c00:7f0b:c18e:56a6:4f2]) by smtp.gmail.com with ESMTPSA id j3-20020adfff83000000b00341e2146b53sm8271413wrr.106.2024.04.08.00.41.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 00:41:16 -0700 (PDT) From: vsntk18@gmail.com To: x86@kernel.org Cc: cfir@google.com, dan.j.williams@intel.com, dave.hansen@linux.intel.com, ebiederm@xmission.com, erdemaktas@google.com, hpa@zytor.com, jgross@suse.com, jroedel@suse.de, jslaby@suse.cz, keescook@chromium.org, kexec@lists.infradead.org, kvm@vger.kernel.org, linux-coco@lists.linux.dev, linux-kernel@vger.kernel.org, luto@kernel.org, martin.b.radev@gmail.com, mhiramat@kernel.org, mstunes@vmware.com, nivedita@alum.mit.edu, peterz@infradead.org, rientjes@google.com, seanjc@google.com, stable@vger.kernel.org, thomas.lendacky@amd.com, virtualization@lists.linux-foundation.org, vkarasulli@suse.de, ashish.kalra@amd.com, michael.roth@amd.com, Borislav.Petkov@amd.com, Dhaval.Giani@amd.com Subject: [PATCH v5 08/10] x86/sev: Handle CLFLUSH MMIO events Date: Mon, 8 Apr 2024 09:40:47 +0200 Message-Id: <20240408074049.7049-9-vsntk18@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240408074049.7049-1-vsntk18@gmail.com> References: <20240408074049.7049-1-vsntk18@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Vasant Karasulli --- 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 54368a43abf6..3bcea641913a 100644 --- a/arch/x86/include/asm/insn-eval.h +++ b/arch/x86/include/asm/insn-eval.h @@ -40,6 +40,7 @@ enum insn_mmio_type { INSN_MMIO_READ_ZERO_EXTEND, INSN_MMIO_READ_SIGN_EXTEND, INSN_MMIO_MOVS, + INSN_MMIO_IGNORE, }; enum insn_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 d769f80d0264..1bffc2205480 100644 --- a/arch/x86/kernel/sev-shared.c +++ b/arch/x86/kernel/sev-shared.c @@ -1171,6 +1171,9 @@ static enum es_result vc_handle_mmio(struct ghcb *ghcb, struct es_em_ctxt *ctxt) if (mmio == INSN_MMIO_DECODE_FAILED) return ES_DECODE_FAILED; + if (mmio == INSN_MMIO_IGNORE) + return ES_OK; + if (mmio != INSN_MMIO_WRITE_IMM && mmio != INSN_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 02acdc2921ff..27fd347d84ae 100644 --- a/arch/x86/lib/insn-eval-shared.c +++ b/arch/x86/lib/insn-eval-shared.c @@ -906,6 +906,13 @@ enum insn_mmio_type insn_decode_mmio(struct insn *insn, int *bytes) *bytes = 2; type = INSN_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 = INSN_MMIO_IGNORE; + break; } break; } -- 2.34.1