[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 1/3] xen/pv: allow pmu msr accesses to cause GP
- To: Juergen Gross <jgross@xxxxxxxx>, linux-kernel@xxxxxxxxxxxxxxx, x86@xxxxxxxxxx
- From: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>
- Date: Tue, 4 Oct 2022 15:46:36 -0400
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oracle.com; dmarc=pass action=none header.from=oracle.com; dkim=pass header.d=oracle.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=wHBTo+ambuPpT2lbGLdnXGa6zDb6J6Fzm8H0eKJTR/M=; b=DsBXvW1AYhUzSCARo6WRaDn1wIpHJj1KhKARrU7bRwFUXSOKPSXd2FPt0gq/AOsJaMCs/y/da6kCFK9AzSfLzNKUu8l4gIIRGpdIUasavnzPh1VNUhmjmHxuD/zst5nZDlpzxjmM3FlqhPcqH3hxPhukClH0HZz8FqW0IJWV+5r11XRCaDkM178okB0F1pyhG++aEezoEpDxFAnwTQ2fHIo+JRSUWRcqEJGB4ka2KLlOZFJzJjoOnoW53wx9D3N3wzOipEZQGOuZaI/IfGm4nx8bTGHSUKlIyY/WdhPfjmaPqyQ7zBflcmVoTPvHqFHcNyCqeAJUZJ2LXJTiTdQZrA==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PQrVdZAZSAri+Losi/0Pvw3GlqF/bI28fd4J1V3lg2eiGqWPba8h8L+Fdtecu4Lbrc+Q9yblmDdBuLyHM/bhyjO2J7SyeZiKmBerx4i/TtwFy5Ga0mdNGBZGiywaeHa2sX1B8Pom3i0QoAw3FxnQkTunzMI+THEMit6oG9Wug5SPBXngsyHJTrWX3hfLccoOWS+TAs+ZXTsmhO7ce0W8kyoMWeFm+jwr6Q97hw/e2ce9wl5UY6aiQ77/yeFyHN0Rrwi/w55pW46mbhO/0QXqMmeHHbu5vqHV9IhdUP1Cpc+nEmOxKK4NRFYTrkldVK0m6IGrAGrpMEit08VrpsT+og==
- Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, "H. Peter Anvin" <hpa@xxxxxxxxx>, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Tue, 04 Oct 2022 19:47:21 +0000
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On 10/4/22 4:43 AM, Juergen Gross wrote:
bool pmu_msr_read(unsigned int msr, uint64_t *val, int *err)
{
- if (boot_cpu_data.x86_vendor != X86_VENDOR_INTEL) {
- if (is_amd_pmu_msr(msr)) {
- if (!xen_amd_pmu_emulate(msr, val, 1))
- *val = native_read_msr_safe(msr, err);
- return true;
- }
- } else {
- int type, index;
+ int type, index;
+ bool emulated;
- if (is_intel_pmu_msr(msr, &type, &index)) {
- if (!xen_intel_pmu_emulate(msr, val, type, index, 1))
- *val = native_read_msr_safe(msr, err);
- return true;
- }
+ if (is_amd_pmu_msr(msr))
+ emulated = xen_amd_pmu_emulate(msr, val, 1);
+ else if (is_intel_pmu_msr(msr, &type, &index))
+ emulated = xen_intel_pmu_emulate(msr, val, type, index, 1);
+ else
+ return false;
+
+ if (!emulated) {
You can factor this out even further I think by moving if/elseif/esle into a
separate routine and then have 'if (!xen_emulate_pmu_msr(msr, val, 1))' (and
pass zero from pmu_msr_write())
-boris
|