Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp746849rdb; Fri, 26 Jan 2024 09:22:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IGj57KRIBC6xLi7YRm76PRdV0pkb1X0k9HH7+mcvkMNB3SmgIvTWldrwNT0uqUNRN/tvUJl X-Received: by 2002:a05:6a20:d906:b0:19c:9737:cc1 with SMTP id jd6-20020a056a20d90600b0019c97370cc1mr16099pzb.93.1706289721576; Fri, 26 Jan 2024 09:22:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706289721; cv=pass; d=google.com; s=arc-20160816; b=f2IpljcbXdUzPhGuOYoMwcBkQFnDWj9TIkClcw0UCOZXnaVSHbac6mN9fL81roiNCe BulmIzvkczWtxOr6fYJdyxeywcY0+AYS3t4LugXn1A081cbCWYmyNqKJVe0Oy5sJ0j4Z k/8QhAp/xdRoutvenUmDQV+w+g3PpcGHIhIl3EUP4pTG4nlEHFmTZf2O0RF12tzRJ6iN uyew1rySAftwPjM3orxB0nnAWZKvcY891ejUfjKE+c2kc5o+cPXQAmC15dCG8xM4S49G Lt2Jb7xqDQRYTVcC1xRd9Dw5QwpJxSN7raaz9TAV9CA22Gwc/cJuk2n/skpaTRiujGvD 6Ksw== 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=O7VC2CaOLxs8bdWKsg/9lQnPVBkE5i3xDyL04oTNrnk=; fh=ILHfJ0uLc1EruXziwgJ5p79BI7cXVVRZxn5LqOC7zKA=; b=EVbfaHl4q8cnD0xfAW7MK10phFadQQc5T9IH2Y2KwewT6VOvOiVs+zjEJFm7CWA0/W KWVyKviWRHND/G85mfaTvWoTwmbmm9V/EBb3wg8R9fyzbPZd34BSGY26Qe9lv5UfmhfQ qsY5PDy3Ff97RK71P84zP1CpmBJ8d9PqDoyRN78eyqezg4kD3Ow04YLwyQAzJJVa9z52 POUtcQW/nC4nVIlJga663Yvb/XWvmmSkeVjeqUJ4VoWXIWJhGmOHJK3lOJluZS1LnwoN 4/V127S/6siSY9gji4cHoVbzzOKlWgJlS2T/9aCxmgl9RHIeH9w/FA36z6wkYf+DimCh VPIw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=SSgn7Ve2; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-39816-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39816-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 x23-20020a63b217000000b005ce4d72996fsi1359839pge.353.2024.01.26.09.22.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 09:22:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-39816-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=@intel.com header.s=Intel header.b=SSgn7Ve2; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-39816-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-39816-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.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 55ECC28AF9B for ; Fri, 26 Jan 2024 09:32:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BF6321B275; Fri, 26 Jan 2024 08:56:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="SSgn7Ve2" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.12]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AC2E613A258; Fri, 26 Jan 2024 08:56:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.12 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706259378; cv=none; b=cmKWR83tpa+TO3QRl7XvAMSrp5/CB9nOckTH7Kr0rpWIoUUIyYYdmeJvnY2i+qZYaJpCzHCdS5epsjjaZDqwiBhJSPM/jw9Yt4v7pp3u/tfPf6MfepPxzQRKDL1eLFZJNAkjCrwxknzn43dP5fKb0rjlgH2fpM7WWlLJW1RJaAE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706259378; c=relaxed/simple; bh=sk50AeICiuzbmUFMWt0doHegxV+qoCoxmVRzVH3ArVs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dbMJnU+4P9zwN72mqDX0CSTU4tMbPppFzabhO4OhAfnXEyuP8mM9xoUcbFIPvXYJGJcVcFIJRfcLY47u7Qu1YiYw6RyoQeXU5OFsqKj4zOb1+QMb3W6D2eQ3j6rDFE2qsbXrI2Jgcnea795YjDmF4FeVbYVwYiKMyz03jB/4J7Q= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=SSgn7Ve2; arc=none smtp.client-ip=198.175.65.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1706259377; x=1737795377; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sk50AeICiuzbmUFMWt0doHegxV+qoCoxmVRzVH3ArVs=; b=SSgn7Ve2GsgeIrbD2OlWH2YSxTGCCG6JAKsBU9f9WIxsNWU3zJfpZ2z7 E0FS3RS2xAxmOAzgKpyt5o6xGGzMEy7AmAFyMuuCTAfQdS4kjmSMIeDzq R2OHtd/bOskFFNFq2ZWXOjuVtGRbDn7ImVWpdKzrlSKMgp1UEhYaIo6iX CRjd4sa6a5yXes0lnAXqM0MyliqlTZtZm73yEXo+/dZ59Fz2ZbIVP1/UO fqFb0GViCeo4bOnpyb/ZUeGQ7g8E2/iIXPb6Mz++vqEk4vtCPWgnGjaqG enproLrLDEVIfe0bvLTU0fdyxdVLLT6UMDUK4QTILGeMfdtyrXkxBxqZm A==; X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="9792137" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="9792137" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2024 00:56:16 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10964"; a="930309950" X-IronPort-AV: E=Sophos;i="6.05,216,1701158400"; d="scan'208";a="930309950" Received: from yanli3-mobl.ccr.corp.intel.com (HELO xiongzha-desk1.ccr.corp.intel.com) ([10.254.213.178]) by fmsmga001-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 Jan 2024 00:56:11 -0800 From: Xiong Zhang To: seanjc@google.com, pbonzini@redhat.com, peterz@infradead.org, mizhang@google.com, kan.liang@intel.com, zhenyuw@linux.intel.com, dapeng1.mi@linux.intel.com, jmattson@google.com Cc: kvm@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org, zhiyuan.lv@intel.com, eranian@google.com, irogers@google.com, samantha.alt@intel.com, like.xu.linux@gmail.com, chao.gao@intel.com, xiong.y.zhang@linux.intel.com, Xiong Zhang Subject: [RFC PATCH 08/41] KVM: x86/pmu: Add get virtual LVTPC_MASK bit function Date: Fri, 26 Jan 2024 16:54:11 +0800 Message-Id: <20240126085444.324918-9-xiong.y.zhang@linux.intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240126085444.324918-1-xiong.y.zhang@linux.intel.com> References: <20240126085444.324918-1-xiong.y.zhang@linux.intel.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: Xiong Zhang On PMU passthrough mode, guest virtual LVTPC_MASK bit must be reflected onto HW, especially when guest clear it, the HW bit should be cleared also. Otherwise processor can't generate PMI until the HW mask bit is cleared. This commit add a function to get virtual LVTPC_MASK bit, so that it can be set onto HW later. Signed-off-by: Xiong Zhang --- arch/x86/kvm/lapic.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kvm/lapic.h b/arch/x86/kvm/lapic.h index e30641d5ac90..dafae44325d1 100644 --- a/arch/x86/kvm/lapic.h +++ b/arch/x86/kvm/lapic.h @@ -277,4 +277,10 @@ static inline u8 kvm_xapic_id(struct kvm_lapic *apic) { return kvm_lapic_get_reg(apic, APIC_ID) >> 24; } + +static inline bool kvm_lapic_get_lvtpc_mask(struct kvm_vcpu *vcpu) +{ + return lapic_in_kernel(vcpu) && + (kvm_lapic_get_reg(vcpu->arch.apic, APIC_LVTPC) & APIC_LVT_MASKED); +} #endif -- 2.34.1