Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3598602rdb; Wed, 13 Sep 2023 18:01:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFzd+TJZLo3VKdEsoFdnHlssJ64Tqv6Zhq5LLav1cyd/nFrUurzJUTCTPm9a4MABbISbk/t X-Received: by 2002:a05:6e02:20ea:b0:34b:191:8444 with SMTP id q10-20020a056e0220ea00b0034b01918444mr5596512ilv.15.1694653283884; Wed, 13 Sep 2023 18:01:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694653283; cv=none; d=google.com; s=arc-20160816; b=iBeOxYNlcNwplw/eiRaGA7zKBtNiSnCKwtQsMHk7H4OukkSXiRiA8jB4rC8zTYIfCS OuDkH5Ncn7u60R/CN8apXkd/N6ZqBTRsBDxwd9ZG7I4zE7fpih6C5wpi0MHWnERB12y8 9sjrT7r8zbXrALYfTzI4Jid1uBcISksx5NGkfWg4ixfA8Ni3FhBt3dDjaASRycw/mVVv N4WdM1UvxBDpxvjRflwgKlPH+dkoPN7zf1OSLMteAqhxKYPc/ALjrfn3UL34fNYUrVDs yk4TR1Ejk2Uoz8IvzrujGysAWvqKOTALGSwZ6PdGjTQlZwqcsrgrYt80mmt2Ar4RrsSl I8zA== 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 :dkim-signature; bh=ijDnegEW3Ezm8/nW3/M6RCa0KvqaX2n5Bd8JWMLx718=; fh=XU07i6VjSHyq3GxtsXSBrQ3+Dy8rztqr00WST2j1mn0=; b=LqQkRPuHNvtvLK5SUv60/SzP56vGKTdgq3EmhiDVO8PhSulBE2NQCFXDvc02gQK0aN 3u6sSdZcCYXGkCfhBqKvmsB4G1sBX5vhCdczR7GWbigCDPzrsp5vQyKUkOCHObSqTiCX DHB5aToccBFaNlF74qZTSJdd6YVTwAx3RD6UDijCbmhp1J4h8cDqfBjk1U6m1Skuly57 6USq9RhROLI/x7c7kataL015G2Wu5QYtNNRitug7/X3FFnH05FlymUllXIt5AbEULL4o XbyZQz/lhFw5Vad5SvqwtMJk8QiYCe5CQ5W4fUdLZCECh2rTU1/Q8zevrGVDw8PwfmDS 8TuA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WiEoHAyq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id bw16-20020a056a00409000b0068fcae723easi413037pfb.368.2023.09.13.18.01.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Sep 2023 18:01:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=WiEoHAyq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id ADB9985140EE; Wed, 13 Sep 2023 08:40:07 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229805AbjIMPkD (ORCPT + 99 others); Wed, 13 Sep 2023 11:40:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229885AbjIMPkA (ORCPT ); Wed, 13 Sep 2023 11:40:00 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.93]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCE7A1BDA; Wed, 13 Sep 2023 08:39:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1694619592; x=1726155592; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AEWudJDZ+NDRaTIFe/yzf4ZaPBnztbnXXDvtdbIDNGE=; b=WiEoHAyqSsBkDGyse4vvga40pj543fcyySqjTkum63wxwW8bPxBt42yP GPJq0guDfTJ8d7d5qj03uQhHR2HxLnmlqEp58WHzevENSJtx50JU+ZaRG nkV9pNFvgCSAHEVtJts8rx1KVjEGi7gZMfcU5C0Nd4mypkls1fEp1WNR1 MI3w3bLxQsNBs+IyED7RKUUks6vNi+8FjRQvjkzsqFZ7ZrL0GeZgkaegS +HpGj7rqdX3rhLY7JyG55HOOLdgf0W7j2dd5+8bjoM6RlVVkWvX2Ukdna Q3yCKkJOxh5W9WaStD62svm2+o6F6Vz3cj2BDm27SnGYBsbqB63CscRoN g==; X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="376030160" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="376030160" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 08:39:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10832"; a="867852081" X-IronPort-AV: E=Sophos;i="6.02,143,1688454000"; d="scan'208";a="867852081" Received: from binbinwu-mobl.ccr.corp.intel.com (HELO binbinwu-mobl.sh.intel.com) ([10.93.2.44]) by orsmga004-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Sep 2023 08:39:49 -0700 From: Binbin Wu To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: seanjc@google.com, pbonzini@redhat.com, chao.gao@intel.com, kai.huang@intel.com, David.Laight@ACULAB.COM, robert.hu@linux.intel.com, guang.zeng@intel.com, binbin.wu@linux.intel.com Subject: [PATCH v11 04/16] KVM: x86: Add X86EMUL_F_INVLPG and pass it in em_invlpg() Date: Wed, 13 Sep 2023 20:42:15 +0800 Message-Id: <20230913124227.12574-5-binbin.wu@linux.intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230913124227.12574-1-binbin.wu@linux.intel.com> References: <20230913124227.12574-1-binbin.wu@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 13 Sep 2023 08:40:08 -0700 (PDT) Add an emulation flag X86EMUL_F_INVLPG, which is used to identify an instruction that does TLB invalidation without true memory access. Only invlpg & invlpga implemented in emulator belong to this kind. invlpga doesn't need additional information for emulation. Just pass the flag to em_invlpg(). Linear Address Masking (LAM) and Linear Address Space Separation (LASS) don't apply to addresses that are inputs to TLB invalidation. The flag will be consumed to support LAM/LASS virtualization. Signed-off-by: Binbin Wu Tested-by: Xuelian Guo --- arch/x86/kvm/emulate.c | 4 +++- arch/x86/kvm/kvm_emulate.h | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/x86/kvm/emulate.c b/arch/x86/kvm/emulate.c index 274d6e7aa0c1..f54e1a2cafa9 100644 --- a/arch/x86/kvm/emulate.c +++ b/arch/x86/kvm/emulate.c @@ -3441,8 +3441,10 @@ static int em_invlpg(struct x86_emulate_ctxt *ctxt) { int rc; ulong linear; + unsigned int max_size; - rc = linearize(ctxt, ctxt->src.addr.mem, 1, false, &linear); + rc = __linearize(ctxt, ctxt->src.addr.mem, &max_size, 1, ctxt->mode, + &linear, X86EMUL_F_INVLPG); if (rc == X86EMUL_CONTINUE) ctxt->ops->invlpg(ctxt, linear); /* Disable writeback. */ diff --git a/arch/x86/kvm/kvm_emulate.h b/arch/x86/kvm/kvm_emulate.h index 5f9869018332..70f329a685fe 100644 --- a/arch/x86/kvm/kvm_emulate.h +++ b/arch/x86/kvm/kvm_emulate.h @@ -93,6 +93,7 @@ struct x86_instruction_info { #define X86EMUL_F_FETCH BIT(1) #define X86EMUL_F_BRANCH BIT(2) #define X86EMUL_F_IMPLICIT BIT(3) +#define X86EMUL_F_INVLPG BIT(4) struct x86_emulate_ops { void (*vm_bugged)(struct x86_emulate_ctxt *ctxt); -- 2.25.1