From patchwork Wed Jun 26 13:38:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 13712996 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C7178C3064D for ; Wed, 26 Jun 2024 13:58:14 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.749008.1156969 (Exim 4.92) (envelope-from ) id 1sMT9x-0000dM-Od; Wed, 26 Jun 2024 13:58:05 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 749008.1156969; Wed, 26 Jun 2024 13:58:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMT9x-0000cc-LM; Wed, 26 Jun 2024 13:58:05 +0000 Received: by outflank-mailman (input) for mailman id 749008; Wed, 26 Jun 2024 13:58:04 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMT9w-0000af-B1 for xen-devel@lists.xenproject.org; Wed, 26 Jun 2024 13:58:04 +0000 Received: from mail-ot1-x32f.google.com (mail-ot1-x32f.google.com [2607:f8b0:4864:20::32f]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1a2cb9e6-33c4-11ef-b4bb-af5377834399; Wed, 26 Jun 2024 15:58:02 +0200 (CEST) Received: by mail-ot1-x32f.google.com with SMTP id 46e09a7af769-700cc97b220so859853a34.0 for ; Wed, 26 Jun 2024 06:58:02 -0700 (PDT) Received: from georged-x-u.xenrt.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79bce9318f6sm499371185a.101.2024.06.26.06.57.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 06:58:00 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1a2cb9e6-33c4-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1719410281; x=1720015081; darn=lists.xenproject.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=mXSq9cIt+cDOKNPJ1wEig1h0MbpC9b/C/ll62WYu3WA=; b=YCpEDFcFJ7d2G5KY/dtFwIhg8TPxfs3+LvPqcYHhNqtVT7zOir9QjqYWYDZTc+QAHu ArMYRa9kO++X8HFRHrOhMKIjWS4hsmZYoccqW9bv9fiJQQWYm8qSfW0WlHisiQRHN+Cq epTnWAWXa0XIb1ZVRep/P52AvPfwAczCzmPAA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719410281; x=1720015081; 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=mXSq9cIt+cDOKNPJ1wEig1h0MbpC9b/C/ll62WYu3WA=; b=GWZ40zcs3ns+/vKHS4yuVCs5nPmJRtQbtjIzs/6FtTNk4NPmvqgoIceB+f33M+fTpB X6bgGMPQiF/7DDmmzSJlztH/hvaYn3xegVJeZZq1/EScS2bh8T8F/5AqCZT0DCj59I5U rxssGs+vYYhq/cirfskf5lWA1H9dHgvpa6hIMIPdAZ4YKOlzXvVJQTKMIfGpgRUVZY+Z PTfEj1jtVo1fOKvb1d+jNIgG7NL1BgW2wRG7WWzMJ2G4jc4J9BiZ6Oa0tSQ1Z3jcEcbp jqS+44NFYpqhsz79ecMH3xU16yCabi0tJuaZkvJTftAU50gWFdYvhGQEthx0K7OrfAlv LGUQ== X-Gm-Message-State: AOJu0Yy+uafvBOeMq5M+fIP1CPNs053Pvs12+iIFgxj6v4h0uf8xDR2T 0/PT9djhK8oJpgxNUQ/N/3IdaOvITBhEGqPwd+v0rFRuhxKOVPQ3YYjJzdUw++r2EXObq7ZixYl Ef24= X-Google-Smtp-Source: AGHT+IFZ+U741Xe22L3IWdU6A/JpCNgMUNRvCO/9WayrRbFltM4UDYHFtnKiLh3aCsSZgpCCJu66BA== X-Received: by 2002:a05:6830:e8b:b0:6f9:7145:ed49 with SMTP id 46e09a7af769-700b117f908mr12160357a34.7.1719410280859; Wed, 26 Jun 2024 06:58:00 -0700 (PDT) From: George Dunlap To: xen-devel@lists.xenproject.org Cc: George Dunlap , Andrew Cooper , Jan Beulich , Roger Pau Monne Subject: [PATCH WIP 01/14] x86/cpuid-policy: Add AMD SVM CPUID leaf to featureset Date: Wed, 26 Jun 2024 14:38:40 +0100 Message-Id: <20240626133853.4150731-2-george.dunlap@cloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626133853.4150731-1-george.dunlap@cloud.com> References: <20240626133853.4150731-1-george.dunlap@cloud.com> MIME-Version: 1.0 NOTE: This patch is be partially superseded by Andrew Cooper's "x86: AMD CPUID handling improvements" series. Currently, the CPUID leaf for SVM features (extd 0xa.edx) is manually twiddled: - hvm_max_policy takes host_policy and clamps it to supported features (with some features unilaterally enabled because they're always emulated - hvm_default_policy is copied from there - When recalculate_policy() is called for a guest, if SVM is clear, then the entire leaf is zeroed out. Move to a mode where the extended features are off by default, and enabled when nested_virt is enabled. In cpufeatureset.h, define a new featureset word for the AMD SVM features, and declare all of the bits defined in x86/include/asm/hvm/svm/svm.h. Mark the ones we currently pass through to the "max policy" as HAP-only and optional. In cpu-policy.h, define FEATURESET_ead, and convert the un-named space in struct_cpu_policy into the appropriate union. FIXME: Do this in a prerequisite patch, and change all references to p->extd.raw[0xa]. Update x86_cpu_X_to_Y and Y_to_X to copy this into and out of the appropriate leaf. Populate this during boot in generic_identify(). Add the new featureset definition into libxl_cpuid.c. Update the code in calculate_hvm_max_policy() to do nothing with the "normal" CPUID bits, and use the feature bit to unconditionally enable VMCBCLEAN. FIXME Move this to a follow-up patch. In recalculate_cpuid_policy(), enable max_fs when nested_hvm() is true. Signed-off-by: George Dunlap --- CC: Andrew Cooper CC: Jan Beulich CC: Roger Pau Monne --- tools/libs/light/libxl_cpuid.c | 1 + tools/misc/xen-cpuid.c | 1 + xen/arch/x86/cpu-policy.c | 23 ++++++++++----------- xen/arch/x86/cpu/common.c | 2 ++ xen/include/public/arch-x86/cpufeatureset.h | 16 ++++++++++++++ xen/include/xen/lib/x86/cpu-policy.h | 10 ++++++++- xen/lib/x86/cpuid.c | 4 +++- 7 files changed, 43 insertions(+), 14 deletions(-) diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c index 063fe86eb7..e8000615ab 100644 --- a/tools/libs/light/libxl_cpuid.c +++ b/tools/libs/light/libxl_cpuid.c @@ -342,6 +342,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *policy, const char* str) CPUID_ENTRY(0x00000007, 1, CPUID_REG_EDX), MSR_ENTRY(0x10a, CPUID_REG_EAX), MSR_ENTRY(0x10a, CPUID_REG_EDX), + CPUID_ENTRY(0x8000000a, NA, CPUID_REG_EDX), #undef MSR_ENTRY #undef CPUID_ENTRY }; diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c index 4c4593528d..460acec46c 100644 --- a/tools/misc/xen-cpuid.c +++ b/tools/misc/xen-cpuid.c @@ -37,6 +37,7 @@ static const struct { { "CPUID 0x00000007:1.edx", "7d1" }, { "MSR_ARCH_CAPS.lo", "m10Al" }, { "MSR_ARCH_CAPS.hi", "m10Ah" }, + { "CPUID 0x8000000a.edx", "ead" }, }; #define COL_ALIGN "24" diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c index 304dc20cfa..d3ba177dac 100644 --- a/xen/arch/x86/cpu-policy.c +++ b/xen/arch/x86/cpu-policy.c @@ -751,22 +751,16 @@ static void __init calculate_hvm_max_policy(void) if ( !cpu_has_vmx ) __clear_bit(X86_FEATURE_PKS, fs); - /* + /* * Make adjustments to possible (nested) virtualization features exposed * to the guest */ if ( p->extd.svm ) { - /* Clamp to implemented features which require hardware support. */ - p->extd.raw[0xa].d &= ((1u << SVM_FEATURE_NPT) | - (1u << SVM_FEATURE_LBRV) | - (1u << SVM_FEATURE_NRIPS) | - (1u << SVM_FEATURE_PAUSEFILTER) | - (1u << SVM_FEATURE_DECODEASSISTS)); /* Enable features which are always emulated. */ - p->extd.raw[0xa].d |= (1u << SVM_FEATURE_VMCBCLEAN); + __set_bit(X86_FEATURE_VMCBCLEAN, fs); } - + guest_common_max_feature_adjustments(fs); guest_common_feature_adjustments(fs); @@ -915,6 +909,14 @@ void recalculate_cpuid_policy(struct domain *d) __clear_bit(X86_FEATURE_VMX, max_fs); __clear_bit(X86_FEATURE_SVM, max_fs); } + else + { + /* + * Enable SVM features. This will be empty on VMX + * hosts. + */ + fs[FEATURESET_ead] = max_fs[FEATURESET_ead]; + } } /* @@ -981,9 +983,6 @@ void recalculate_cpuid_policy(struct domain *d) ((vpmu_mode & XENPMU_MODE_ALL) && !is_hardware_domain(d)) ) p->basic.raw[0xa] = EMPTY_LEAF; - if ( !p->extd.svm ) - p->extd.raw[0xa] = EMPTY_LEAF; - if ( !p->extd.page1gb ) p->extd.raw[0x19] = EMPTY_LEAF; } diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c index ff4cd22897..da5ad10516 100644 --- a/xen/arch/x86/cpu/common.c +++ b/xen/arch/x86/cpu/common.c @@ -478,6 +478,8 @@ static void generic_identify(struct cpuinfo_x86 *c) c->x86_capability[FEATURESET_e7d] = cpuid_edx(0x80000007); if (c->extended_cpuid_level >= 0x80000008) c->x86_capability[FEATURESET_e8b] = cpuid_ebx(0x80000008); + if (c->extended_cpuid_level >= 0x8000000a) + c->x86_capability[FEATURESET_ead] = cpuid_edx(0x8000000a); if (c->extended_cpuid_level >= 0x80000021) c->x86_capability[FEATURESET_e21a] = cpuid_eax(0x80000021); diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h index d9eba5e9a7..88d5d0054b 100644 --- a/xen/include/public/arch-x86/cpufeatureset.h +++ b/xen/include/public/arch-x86/cpufeatureset.h @@ -365,6 +365,22 @@ XEN_CPUFEATURE(RFDS_CLEAR, 16*32+28) /*!A| Register File(s) cleared by V /* Intel-defined CPU features, MSR_ARCH_CAPS 0x10a.edx, word 17 */ +/* AMD-defined CPU features, CPUID level 0x8000000a.edx, word 18 */ +XEN_CPUFEATURE(NPT, 18*32+ 0) /*h Nested page table support */ +XEN_CPUFEATURE(LBRV, 18*32+ 1) /*h LBR virtualization support */ +XEN_CPUFEATURE(SVML, 18*32+ 2) /* SVM locking MSR support */ +XEN_CPUFEATURE(NRIPS, 18*32+ 3) /*h Next RIP save on VMEXIT support */ +XEN_CPUFEATURE(TSCRATEMSR, 18*32+ 4) /* TSC ratio MSR support */ +XEN_CPUFEATURE(VMCBCLEAN, 18*32+ 5) /*h VMCB clean bits support */ +XEN_CPUFEATURE(FLUSHBYASID, 18*32+ 6) /* TLB flush by ASID support */ +XEN_CPUFEATURE(DECODEASSISTS, 18*32+ 7) /*h Decode assists support */ +XEN_CPUFEATURE(PAUSEFILTER, 18*32+10) /*h Pause intercept filter support */ +XEN_CPUFEATURE(PAUSETHRESH, 18*32+12) /* Pause intercept filter threshold */ +XEN_CPUFEATURE(VLOADSAVE, 18*32+15) /* virtual vmload/vmsave */ +XEN_CPUFEATURE(VGIF, 18*32+16) /* Virtual GIF */ +XEN_CPUFEATURE(SSS, 18*32+19) /* NPT Supervisor Shadow Stacks */ +XEN_CPUFEATURE(SPEC_CTRL, 18*32+20) /* MSR_SPEC_CTRL virtualisation */ + #endif /* XEN_CPUFEATURE */ /* Clean up from a default include. Close the enum (for C). */ diff --git a/xen/include/xen/lib/x86/cpu-policy.h b/xen/include/xen/lib/x86/cpu-policy.h index d26012c6da..445325a5b5 100644 --- a/xen/include/xen/lib/x86/cpu-policy.h +++ b/xen/include/xen/lib/x86/cpu-policy.h @@ -22,6 +22,7 @@ #define FEATURESET_7d1 15 /* 0x00000007:1.edx */ #define FEATURESET_m10Al 16 /* 0x0000010a.eax */ #define FEATURESET_m10Ah 17 /* 0x0000010a.edx */ +#define FEATURESET_ead 18 /* 0x8000000a.edx */ struct cpuid_leaf { @@ -296,7 +297,14 @@ struct cpu_policy uint32_t /* d */:32; uint64_t :64, :64; /* Leaf 0x80000009. */ - uint64_t :64, :64; /* Leaf 0x8000000a - SVM rev and features. */ + + /* Leaf 0x8000000a - SVM rev and features. */ + uint64_t /* a, b */:64, /* c */:32; + union { + uint32_t ead; + struct { DECL_BITFIELD(ead); }; + }; + uint64_t :64, :64; /* Leaf 0x8000000b. */ uint64_t :64, :64; /* Leaf 0x8000000c. */ uint64_t :64, :64; /* Leaf 0x8000000d. */ diff --git a/xen/lib/x86/cpuid.c b/xen/lib/x86/cpuid.c index eb7698dc73..d68f442d4e 100644 --- a/xen/lib/x86/cpuid.c +++ b/xen/lib/x86/cpuid.c @@ -81,7 +81,8 @@ void x86_cpu_policy_to_featureset( fs[FEATURESET_7d1] = p->feat._7d1; fs[FEATURESET_m10Al] = p->arch_caps.lo; fs[FEATURESET_m10Ah] = p->arch_caps.hi; -} + fs[FEATURESET_ead] = p->extd.ead; + } void x86_cpu_featureset_to_policy( const uint32_t fs[FEATURESET_NR_ENTRIES], struct cpu_policy *p) @@ -104,6 +105,7 @@ void x86_cpu_featureset_to_policy( p->feat._7d1 = fs[FEATURESET_7d1]; p->arch_caps.lo = fs[FEATURESET_m10Al]; p->arch_caps.hi = fs[FEATURESET_m10Ah]; + p->extd.ead = fs[FEATURESET_ead]; } void x86_cpu_policy_recalc_synth(struct cpu_policy *p) From patchwork Wed Jun 26 13:38:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 13712999 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8F42BC3065C for ; Wed, 26 Jun 2024 13:58:15 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.749009.1156985 (Exim 4.92) (envelope-from ) id 1sMT9y-00014K-Vd; Wed, 26 Jun 2024 13:58:06 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 749009.1156985; Wed, 26 Jun 2024 13:58:06 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMT9y-000147-S7; Wed, 26 Jun 2024 13:58:06 +0000 Received: by outflank-mailman (input) for mailman id 749009; Wed, 26 Jun 2024 13:58:05 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMT9x-0000af-BC for xen-devel@lists.xenproject.org; Wed, 26 Jun 2024 13:58:05 +0000 Received: from mail-qk1-x733.google.com (mail-qk1-x733.google.com [2607:f8b0:4864:20::733]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1ab3aff0-33c4-11ef-b4bb-af5377834399; Wed, 26 Jun 2024 15:58:03 +0200 (CEST) Received: by mail-qk1-x733.google.com with SMTP id af79cd13be357-795a4fde8bfso396633185a.2 for ; Wed, 26 Jun 2024 06:58:03 -0700 (PDT) Received: from georged-x-u.xenrt.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79bce9318f6sm499371185a.101.2024.06.26.06.58.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 06:58:01 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1ab3aff0-33c4-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1719410282; x=1720015082; darn=lists.xenproject.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=DtQlCgHMpYyj0NMMsQz5bXaCF8IMRtA28KklQoqKVVg=; b=gQu7JENtQR7tLTo8nv1XDdlszKteOr5Q2PJpoTFLCBOoJ5H6KldOIYWJ60JApkUtbS ihiGsYKev5a0jQ1F5l1I5rm1kOW4OkrBB4aCW8T7xLo1R80oRZzjkc0JyZ3DyF8+FA3m SMLTqY3MozFYRQZYmCpLDjFRvlVdZurzuOLe4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719410282; x=1720015082; 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=DtQlCgHMpYyj0NMMsQz5bXaCF8IMRtA28KklQoqKVVg=; b=A6rAIet/mvMb6gLafCcTK6Abio2bQnGb8X23GOIsARwpTWIoBDAlHezwMy/BbdX1UL rxmakdOnBfkNynLX+4mZXEpvyiKkf1gC2rYmGnr+wSY/hinCZnEUIHdNCqq4llWyMxpo 1zk3LiQ2xu3vpdEcbFzv247ZLzXAdzlFZiOpKGWs3XhSFrktN8svgtjRsfjoY9KP0KYS D2TKAwk0W9Ncq+Nz0ZZTAJOF0slPfn7BPMT9r1ax5U0bJ70ExPVKgJnl9rQL8cIMnhbn FwiVzqfXVS3fziAIVnnAJG2aFMg+k45UxIk04zQM5LYCDnLfg5+YUScFYH5Oz3JPiEkl +UBA== X-Gm-Message-State: AOJu0YwcJg9fccEq+cL5hGM87BbKmWYvVsuFDetXsDhMTU7R4y75S9J9 0129pEJTpnh8bL4Bvj/sIvnyvYFSpqjm8ysCeL70aRp8B2kEjPzcLfcZe6KzfXJ8nqzbmCM8gtk hZ10= X-Google-Smtp-Source: AGHT+IF+gxCgdyj9i9WXkQO/B9fdFeKeEYEhfT9GWGoCYkvEYPhcPyStk9Q1P/c1vDx6AEp+n33aqw== X-Received: by 2002:a05:620a:2494:b0:79d:5943:15ee with SMTP id af79cd13be357-79d59431889mr16196485a.60.1719410281882; Wed, 26 Jun 2024 06:58:01 -0700 (PDT) From: George Dunlap To: xen-devel@lists.xenproject.org Cc: George Dunlap Subject: [PATCH WIP 02/14] x86/cpu-policy: HACK Disable PCID when nested virt is enabled Date: Wed, 26 Jun 2024 14:38:41 +0100 Message-Id: <20240626133853.4150731-3-george.dunlap@cloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626133853.4150731-1-george.dunlap@cloud.com> References: <20240626133853.4150731-1-george.dunlap@cloud.com> MIME-Version: 1.0 The non-nested HVM code knows how to provide PCID functionality (non-zero values in the lower 12 bits of CR3 when running in 64-bit mode), but the nested code doesn't. If the L2 decides to use the PCID functionality, the L0 will fail the next L1 VMENTRY. Long term we definitely want to enable this feature, but for now, just hide it from guests when nested HVM is enabled. Signed-off-by: George Dunlap --- xen/arch/x86/cpu-policy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c index d3ba177dac..91281b44b0 100644 --- a/xen/arch/x86/cpu-policy.c +++ b/xen/arch/x86/cpu-policy.c @@ -916,6 +916,7 @@ void recalculate_cpuid_policy(struct domain *d) * hosts. */ fs[FEATURESET_ead] = max_fs[FEATURESET_ead]; + __clear_bit(X86_FEATURE_PCID, max_fs); } } From patchwork Wed Jun 26 13:38:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 13712997 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C11D2C27C4F for ; Wed, 26 Jun 2024 13:58:14 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.749010.1156990 (Exim 4.92) (envelope-from ) id 1sMT9z-00017U-AY; Wed, 26 Jun 2024 13:58:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 749010.1156990; Wed, 26 Jun 2024 13:58:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMT9z-00015j-3u; Wed, 26 Jun 2024 13:58:07 +0000 Received: by outflank-mailman (input) for mailman id 749010; Wed, 26 Jun 2024 13:58:05 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMT9x-0000aq-C9 for xen-devel@lists.xenproject.org; Wed, 26 Jun 2024 13:58:05 +0000 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [2607:f8b0:4864:20::729]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1b496037-33c4-11ef-90a3-e314d9c70b13; Wed, 26 Jun 2024 15:58:04 +0200 (CEST) Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-79c11e92afaso71239485a.2 for ; Wed, 26 Jun 2024 06:58:04 -0700 (PDT) Received: from georged-x-u.xenrt.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79bce9318f6sm499371185a.101.2024.06.26.06.58.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 06:58:02 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1b496037-33c4-11ef-90a3-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1719410283; x=1720015083; darn=lists.xenproject.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=jvj66XLtWaLUUhs6hHRcK0ccgrRw6yMVK7cJhOUGdj4=; b=RKQrSjKSwCvg2r8kpo3ysSgxPwmWvJPnWxdIAPtON0ZWr7NhRqXB8ulJmn7dKQSYrO qUSSnqWV1Mxlr8WKyynv7/frWooV+pTXRDGaJPJwWnGUALOP9fobuk0dgDoFRIbZlLW1 dHJRSx7k7L77ItffWA4OQPs3wpnmW0wzZEGbE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719410283; x=1720015083; 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=jvj66XLtWaLUUhs6hHRcK0ccgrRw6yMVK7cJhOUGdj4=; b=N8uFceKd6mbFEGC2ag90TX7uuaRg4AOzEEa3PZWCsNJF1Ef/u2q6w8TXSH6Q3N3/Tm CW+AJa7KhoRHr85ftN4Xxj1W0/0F8BSRE0dvV6yINVSyXGBL/rWboceV1dUzOXJbNg5b 0lyVm5yna7eGFGuYczM+ecnM9YSNp5LQbxoLbQf7RMeE2G+FdiAuTjSkr5m2yWhtHaAH 99DDD/zthhLMcuUbVj05ZIhasPFz3RPDfxFN2AoEt8JnbV9SN8rdJNeVa3icIbbGjYkv IzXAla1X2xpQdLOto2rPEYSBkFB5pKaNizP1DxfKrd1reWs3i1POunKjgCezwStsGtAm D4Dw== X-Gm-Message-State: AOJu0Yyw3WjuqcDM6QnjIBtVKkVgRW58HV7YfAMvWUU/Oe3K5cvhCrYF u3trU9X1UPAP0Qfa4ak5gA+QuFq23AdcJ7o6Vyt7+fbLho3yb5bztOxdtaVQUpYPpiUxC0vQCab 3wwI= X-Google-Smtp-Source: AGHT+IHFDYppDfhSsXX23yD5NHNWcJuD1Vdf+5KwPSJ4NnOz2YoqrvF07uS8JC9JNzH8eNAHdGhIuQ== X-Received: by 2002:a05:620a:190f:b0:795:598d:b99c with SMTP id af79cd13be357-79be701b2b6mr1258395985a.64.1719410282848; Wed, 26 Jun 2024 06:58:02 -0700 (PDT) From: George Dunlap To: xen-devel@lists.xenproject.org Cc: George Dunlap Subject: [PATCH WIP 03/14] xenalyze: Basic nested virt processing Date: Wed, 26 Jun 2024 14:38:42 +0100 Message-Id: <20240626133853.4150731-4-george.dunlap@cloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626133853.4150731-1-george.dunlap@cloud.com> References: <20240626133853.4150731-1-george.dunlap@cloud.com> MIME-Version: 1.0 On SVM, VMEXIT that occur in when an L1 is in non-root mode ("nested exits") are tagged with the TRC_HVM_NESTEDFLAG flag. Expand xenalyze to do basic handling of these records: - Refactor hvm_process to filter out both TRC_HVM_NESTEDFLAG and TRC_64_FLAG when deciding how to process - Create separate "trace volume" sub-categories for them (HVM_VOL_*), tweaking layout so things continue to align - Visually distinquish nested from non-nested vmexits and vmentries in dump mode At the moment, nested VMEXITs which are passed through to the L1 hypervisor won't have any HVM handlers; note in hvm_data when a vmexit was nested, and don't warn when no handlers occur. While here: - Expand one of the error messages with a bit more information - Replace repeated `ri->event & TRC_64_FLAG` instances with `flag64` - Remove a stray whitespace at the end of a line - Add a missing newline to a warning statement Signed-off-by: George Dunlap --- tools/xentrace/xenalyze.c | 66 ++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 21 deletions(-) diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c index d95e52695f..52ee7a5f9f 100644 --- a/tools/xentrace/xenalyze.c +++ b/tools/xentrace/xenalyze.c @@ -986,7 +986,9 @@ const char * hvm_event_handler_name[HVM_EVENT_HANDLER_MAX] = { enum { HVM_VOL_VMENTRY, + HVM_VOL_VMENTRY_NESTED, HVM_VOL_VMEXIT, + HVM_VOL_VMEXIT_NESTED, HVM_VOL_HANDLER, HVM_VOL_EMUL, HVM_VOL_MAX @@ -1014,6 +1016,8 @@ const char *guest_interrupt_case_name[] = { const char *hvm_vol_name[HVM_VOL_MAX] = { [HVM_VOL_VMENTRY]="vmentry", [HVM_VOL_VMEXIT] ="vmexit", + [HVM_VOL_VMENTRY_NESTED]="vmentry(n)", + [HVM_VOL_VMEXIT_NESTED] ="vmexit(n)", [HVM_VOL_HANDLER]="handler", [HVM_VOL_EMUL]="emul", }; @@ -1380,7 +1384,7 @@ struct hvm_data { tsc_t exit_tsc, arc_cycles, entry_tsc; unsigned long long rip; unsigned exit_reason, event_handler; - unsigned int short_summary_done:1, prealloc_unpin:1, wrmap_bf:1; + bool nested_vmexit, short_summary_done, prealloc_unpin, wrmap_bf; /* Immediate processing */ void *d; @@ -1807,7 +1811,7 @@ void volume_summary(struct trace_volume *vol) case TOPLEVEL_HVM: for(k=0; khvm[k]) - printf(" +-%-7s: %10lld\n", + printf(" +-%-10s: %10lld\n", hvm_vol_name[k], vol->hvm[k]); } @@ -4633,6 +4637,9 @@ void hvm_generic_postprocess(struct hvm_data *h) /* Some exits we don't expect a handler; just return */ if(opt.svm_mode) { + /* Nested vmexits passed on to L1's have no handlers for now */ + if(h->nested_vmexit) + return; switch(h->exit_reason) { case VMEXIT_VINTR: /* Equivalent of PENDING_VIRT_INTR */ @@ -4660,8 +4667,10 @@ void hvm_generic_postprocess(struct hvm_data *h) if ( !warned[h->exit_reason] ) { /* If we aren't a known exception, warn and log results */ - fprintf(warn, "%s: Strange, exit %x(%s) missing a handler\n", - __func__, h->exit_reason, + fprintf(warn, "%s: d%dv%d Strange, exit %x(%s) missing a handler\n", + __func__, + h->v->d->did, h->v->vid, + h->exit_reason, (h->exit_reason > h->exit_reason_max) ? "[clipped]" : h->exit_reason_name[h->exit_reason]); @@ -5067,6 +5076,9 @@ static inline void runstate_update(struct vcpu_data *v, int new_runstate, void hvm_vmexit_process(struct record_info *ri, struct hvm_data *h, struct vcpu_data *v) { + bool flag64 = ri->event & TRC_64_FLAG; + bool nested = ri->event & TRC_HVM_NESTEDFLAG; + struct { union { struct { @@ -5080,7 +5092,7 @@ void hvm_vmexit_process(struct record_info *ri, struct hvm_data *h, }; } *r; - if ( ri->event & TRC_64_FLAG ) + if(flag64) { if (check_extra_words(ri, sizeof(r->x64), "vmexit")) return; @@ -5097,9 +5109,10 @@ void hvm_vmexit_process(struct record_info *ri, struct hvm_data *h, set_hvm_exit_reason_data(h, ri->event); h->vmexit_valid=1; + h->nested_vmexit=nested; bzero(&h->inflight, sizeof(h->inflight)); - if(ri->event & TRC_64_FLAG) { + if(flag64) { if(v->guest_paging_levels != 4) { if ( verbosity >= 6 ) @@ -5145,14 +5158,16 @@ void hvm_vmexit_process(struct record_info *ri, struct hvm_data *h, if(opt.dump_all) { if ( h->exit_reason < h->exit_reason_max && h->exit_reason_name[h->exit_reason] != NULL) - printf("]%s vmexit exit_reason %s eip %llx%s\n", + printf("]%s vmexit%s exit_reason %s eip %llx%s\n", ri->dump_header, + nested ? "(n)" : "", h->exit_reason_name[h->exit_reason], h->rip, find_symbol(h->rip)); else - printf("]%s vmexit exit_reason %x eip %llx%s\n", + printf("]%s vmexit%s exit_reason %x eip %llx%s\n", ri->dump_header, + nested ? "(n)" : "", h->exit_reason, h->rip, find_symbol(h->rip)); @@ -5244,11 +5259,13 @@ void hvm_close_vmexit(struct hvm_data *h, tsc_t tsc) { } void hvm_vmentry_process(struct record_info *ri, struct hvm_data *h) { + bool nested = ri->event & TRC_HVM_NESTEDFLAG; if(!h->init) { if(opt.dump_all) - printf("!%s vmentry\n", - ri->dump_header); + printf("!%s vmentry%s\n", + ri->dump_header, + nested ? "(n)" : ""); return; } @@ -5283,15 +5300,18 @@ void hvm_vmentry_process(struct record_info *ri, struct hvm_data *h) { if(!h->vmexit_valid) { if(opt.dump_all) - printf("!%s vmentry\n", - ri->dump_header); + printf("!%s vmentry%s\n", + ri->dump_header, + nested ? "(n)" : ""); return; } if(opt.dump_all) { unsigned long long arc_cycles = ri->tsc - h->exit_tsc; - printf("]%s vmentry cycles %lld %s\n", - ri->dump_header, arc_cycles, (arc_cycles>10000)?"!":""); + printf("]%s vmentry%s cycles %lld %s\n", + ri->dump_header, + nested ? "(n)" : "", + arc_cycles, (arc_cycles>10000)?"!":""); } hvm_close_vmexit(h, ri->tsc); @@ -5323,16 +5343,20 @@ void hvm_process(struct pcpu_info *p) /* FIXME: Collect analysis on this */ break; default: - switch(ri->event) { + switch(ri->event & ~(TRC_HVM_NESTEDFLAG|TRC_64_FLAG)) { case TRC_HVM_VMX_EXIT: - case TRC_HVM_VMX_EXIT64: case TRC_HVM_SVM_EXIT: - case TRC_HVM_SVM_EXIT64: - UPDATE_VOLUME(p, hvm[HVM_VOL_VMEXIT], ri->size); + if (ri->event & TRC_HVM_NESTEDFLAG) + UPDATE_VOLUME(p, hvm[HVM_VOL_VMEXIT_NESTED], ri->size); + else + UPDATE_VOLUME(p, hvm[HVM_VOL_VMEXIT], ri->size); hvm_vmexit_process(ri, h, v); break; case TRC_HVM_VMENTRY: - UPDATE_VOLUME(p, hvm[HVM_VOL_VMENTRY], ri->size); + if (ri->event & TRC_HVM_NESTEDFLAG) + UPDATE_VOLUME(p, hvm[HVM_VOL_VMENTRY_NESTED], ri->size); + else + UPDATE_VOLUME(p, hvm[HVM_VOL_VMENTRY], ri->size); hvm_vmentry_process(ri, &p->current->hvm); break; default: @@ -6977,7 +7001,7 @@ void vcpu_start(struct pcpu_info *p, struct vcpu_data *v, /* Change default domain to 'queued' */ runstate_update(p->current, RUNSTATE_QUEUED, p->first_tsc); - /* + /* * Set current to NULL, so that if another vcpu (not in INIT) * is scheduled here, we don't trip over the check in * vcpu_next_update() @@ -6997,7 +7021,7 @@ void vcpu_start(struct pcpu_info *p, struct vcpu_data *v, return; } else if ( v->delayed_init ) { - fprintf(warn, "d%dv%d RUNSTATE_RUNNING detected, leaving INIT", + fprintf(warn, "d%dv%d RUNSTATE_RUNNING detected, leaving INIT\n", v->d->did, v->vid); v->delayed_init = 0; } From patchwork Wed Jun 26 13:38:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 13713000 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CEC26C30659 for ; Wed, 26 Jun 2024 13:58:14 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.749012.1157005 (Exim 4.92) (envelope-from ) id 1sMTA0-0001N2-C4; Wed, 26 Jun 2024 13:58:08 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 749012.1157005; Wed, 26 Jun 2024 13:58:08 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMT9z-0001L2-Um; Wed, 26 Jun 2024 13:58:07 +0000 Received: by outflank-mailman (input) for mailman id 749012; Wed, 26 Jun 2024 13:58:06 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMT9y-0000af-JH for xen-devel@lists.xenproject.org; Wed, 26 Jun 2024 13:58:06 +0000 Received: from mail-qk1-x72b.google.com (mail-qk1-x72b.google.com [2607:f8b0:4864:20::72b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1bc125b2-33c4-11ef-b4bb-af5377834399; Wed, 26 Jun 2024 15:58:05 +0200 (CEST) Received: by mail-qk1-x72b.google.com with SMTP id af79cd13be357-79c06a06a8eso99842385a.0 for ; Wed, 26 Jun 2024 06:58:05 -0700 (PDT) Received: from georged-x-u.xenrt.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79bce9318f6sm499371185a.101.2024.06.26.06.58.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 06:58:03 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1bc125b2-33c4-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1719410284; x=1720015084; darn=lists.xenproject.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=4CicAy88BoQhTqLPRoVgCuGO0iyrk5R5H3mkM3cjN/E=; b=J6ZCXsgv6aZiOJCAsaTTg8qJPXOAnqYSAzGzNjwu4pN8+c/V4tTM6Gx06TrimhfXZz Z+2IMsj+VCpgXjUzu9ik6hDB3lHAnRSL2CtgzInB0i9+CJK4N5kANfbPDdyqPQbgf/hU 5M7HRJJq+zAIi9YegdDEnlRC+LGKFVc8i+O40= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719410284; x=1720015084; 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=4CicAy88BoQhTqLPRoVgCuGO0iyrk5R5H3mkM3cjN/E=; b=D0t9vUZeOFo4zOhL43Fk1vUxTKLd/Z6EVe36fNBuGfvnIQhl51NDmSCqbHxZPqNewt WMnZlOzlTuIy9Ckt+OKVkawRuD8TpTeINDR1V5twzolgo3shiDVqJvdSpOfU+tcPAuXn tPUN5C901OYxiDBCmRm0AaOLGS4zHTz8Dz98o9k5YxSpwTyblNQi6yYiPGBG0U28ft0L bd4SjLvPWffAc0mnteXlgJirIFwFXzqLStLl6sHfMGPL5uajWNDgFBsZpJHxCLmkjvYQ e1qEEAffGbx36efhVpOYJAUTqv3aT28T7Pfe5RmjLGaRiPpiy+uYZ63r/2clfqtTUbmo 0Z8w== X-Gm-Message-State: AOJu0Yx/7G9iTJd5E0FGKqxov6Lo9XhjJex/YZCX9A1SYxs9Fw0UlJSK nPjSd7fUn2zdf3Yjfx5J3+b0wdo0R6KhP/qYrb3brPqb5w0VQ+1jnbFqi66Q2xhX3n/1rHRefdr 9nFY= X-Google-Smtp-Source: AGHT+IFuaaGzYU5rWVD3+w/otwtbTWoRCXh7i4fUBEqB1FYOqspJGP6Lpr0Q080r7c8cpsLLXlmXCA== X-Received: by 2002:a05:620a:1a19:b0:797:b319:c3a2 with SMTP id af79cd13be357-79be6eae80dmr1257297985a.39.1719410283769; Wed, 26 Jun 2024 06:58:03 -0700 (PDT) From: George Dunlap To: xen-devel@lists.xenproject.org Cc: George Dunlap Subject: [PATCH WIP 04/14] xenalyze: Track generic event information when not in summary mode Date: Wed, 26 Jun 2024 14:38:43 +0100 Message-Id: <20240626133853.4150731-5-george.dunlap@cloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626133853.4150731-1-george.dunlap@cloud.com> References: <20240626133853.4150731-1-george.dunlap@cloud.com> MIME-Version: 1.0 Generally speaking, a VMEXIT/VMENTRY cycle should have at least three trace records: the VMEXIT trace (which contains the processor-specific exit code), a more generic Xen-based Xen event (an HVM_HANDLER trace record), and a VMEXIT trace; and any given VMEXIT exit reason should only have a single HVM_HANDLER trace type. Having duplicate or missing HVM_HANDLER traces is generally indicative of a problem that's crept in in the hypervisor tracing scheme. This is property is checked in hvm_generic_postprocess(), and violations are flagged with a warning. In order to do this, when an HVM trace record that doesn't have a specific post-processor happens, information about the HVM trace record is stored in hvm_data->inflight.generic. Unfortunately, while the check was being done in all "modes", the relevant information was only being copied into inflight.generic in summary mode. This resulted in spurious warnings about missing HVM_HANDLER traces when running in dump mode. Since running in dump mode is often critical to understanding how the warnings came about, just collect the information always as well. That said, the data from the trace doesn't appear to be used by anyone; so to save some time, don't bother copying it. Signed-off-by: George Dunlap --- tools/xentrace/xenalyze.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c index 52ee7a5f9f..46248e9a70 100644 --- a/tools/xentrace/xenalyze.c +++ b/tools/xentrace/xenalyze.c @@ -1367,7 +1367,6 @@ struct hvm_data { } msr; struct { unsigned int event; - uint32_t d[4]; } generic; struct { unsigned eax; @@ -4572,8 +4571,7 @@ void hvm_npf_process(struct record_info *ri, struct hvm_data *h) (unsigned long long)r->gpa, r->qualification, (unsigned long long)r->mfn, r->p2mt); - if ( opt.summary_info ) - hvm_generic_postprocess_init(ri, h); + hvm_generic_postprocess_init(ri, h); } void hvm_rdtsc_process(struct record_info *ri, struct hvm_data *h) @@ -4621,7 +4619,6 @@ void hvm_generic_postprocess_init(struct record_info *ri, struct hvm_data *h) fprintf(warn, "%s: Strange, h->postprocess set!\n", __func__); h->inflight.generic.event = ri->event; - bcopy(h->d, h->inflight.generic.d, sizeof(unsigned int) * 4); } void hvm_generic_postprocess(struct hvm_data *h) @@ -4899,8 +4896,7 @@ needs_vmexit: default: if(opt.dump_all) hvm_generic_dump(ri, "]"); - if(opt.summary_info) - hvm_generic_postprocess_init(ri, h); + hvm_generic_postprocess_init(ri, h); break; } } @@ -6166,11 +6162,10 @@ void shadow_fault_generic_process(struct record_info *ri, struct hvm_data *h) /* pf-case traces, vs others */ h->inflight.generic.event = ri->event; - bcopy(ri->d, h->inflight.generic.d, sizeof(unsigned int) * 4); if(opt.dump_all) - shadow_fault_generic_dump(h->inflight.generic.event, - h->inflight.generic.d, + shadow_fault_generic_dump(ri->event, + ri->d, "]", ri->dump_header); h->inflight.pf_xen.pf_case = sevt.minor; From patchwork Wed Jun 26 13:38:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 13712998 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 44D8EC30658 for ; Wed, 26 Jun 2024 13:58:15 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.749011.1156996 (Exim 4.92) (envelope-from ) id 1sMT9z-0001HJ-Pj; Wed, 26 Jun 2024 13:58:07 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 749011.1156996; Wed, 26 Jun 2024 13:58:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMT9z-0001F2-Lu; Wed, 26 Jun 2024 13:58:07 +0000 Received: by outflank-mailman (input) for mailman id 749011; Wed, 26 Jun 2024 13:58:06 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMT9y-0000aq-J6 for xen-devel@lists.xenproject.org; Wed, 26 Jun 2024 13:58:06 +0000 Received: from mail-ot1-x329.google.com (mail-ot1-x329.google.com [2607:f8b0:4864:20::329]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1c51c914-33c4-11ef-90a3-e314d9c70b13; Wed, 26 Jun 2024 15:58:06 +0200 (CEST) Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6fd3d9f572fso3187114a34.0 for ; Wed, 26 Jun 2024 06:58:06 -0700 (PDT) Received: from georged-x-u.xenrt.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79bce9318f6sm499371185a.101.2024.06.26.06.58.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 06:58:04 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1c51c914-33c4-11ef-90a3-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1719410285; x=1720015085; darn=lists.xenproject.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=PeXJAa32g4UEe7AmZVpxSa6rawo1LbJSKY3deaYLOBo=; b=dw91qHep2LwHa7dnqyxLp9RKZ2E6b++Rodb7rMyCIZYlLaBk33Ki6xyjoNgwx7haaQ CYX997tkLQxtQDS7tQIxY81bXE1EKhTSzHRE301b2tl7c9jYD30+AjocsKpBURTsRAxu ZqGQFeYQKY+UBnU7ZLm7IzdVW9qu26+h1X960= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719410285; x=1720015085; 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=PeXJAa32g4UEe7AmZVpxSa6rawo1LbJSKY3deaYLOBo=; b=Rky0HY7bzmsFc1H9bQ9x6N0RhuhcQguwdlHZDObUKT8E+S/rpsIu2GYR35hNYNafcl KunbWizmvJM3urbOymyDxtoJf3uF4aEWMlGEgbaVyqt5YHRx1yv0DVHoULECNiahYh3J u6B+PUSr7gAabGOP0HpDlMuLfkuNYe1nGCQ+ZY/zGKQsl6Lvslr+q1l3WSNqu4tU3k3v 8VC3fF2x0nPdZzLyUoM2b6MLEK6WfxryJW2K3j7KMCZuBY+wT7Z0F8VtfnJSt4xDhAcW Xey4gQm1Fo9Flfi2a/L4OL2vxfmyKoZIhKPGv3FMB+dcqVes7LU8UOk6zKhG3hBgWcY6 2R8A== X-Gm-Message-State: AOJu0Yziw1QC+f/wXD9XQcwaxb7t/vbr1IcF8K+01BJlz9OtJdbYELYm dwremCgFY7EpwQDRwz4N1sgpgJAnrLt8qRPmn0c86PT4/G5r7mQQtCCq5MiaVrAoS2VMv18RIdn pLXs= X-Google-Smtp-Source: AGHT+IHJesmEszuQOmOLW16x2yS6nMyF1lEaZlEgMRvbsep/0oYldxQi8lVX09o99u1oxbaAhpAY8A== X-Received: by 2002:a9d:7cc6:0:b0:6f9:aa39:fd7d with SMTP id 46e09a7af769-700af8ad056mr11300588a34.6.1719410284675; Wed, 26 Jun 2024 06:58:04 -0700 (PDT) From: George Dunlap To: xen-devel@lists.xenproject.org Cc: George Dunlap Subject: [PATCH WIP 05/14] xenalyze: Ignore vmexits where an HVM_HANDLER traces would be redundant Date: Wed, 26 Jun 2024 14:38:44 +0100 Message-Id: <20240626133853.4150731-6-george.dunlap@cloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626133853.4150731-1-george.dunlap@cloud.com> References: <20240626133853.4150731-1-george.dunlap@cloud.com> MIME-Version: 1.0 VMX combines all exceptions into a single VMEXIT exit reason, and so needs a separate HVM_HANDLER trace record (HVM_TRAP) to say which exception happened; but for a number of exceptions, no further information is put into the trace log. SVM, by contrast, has a separate VMEXIT exit reason for each exception vector, so HVM_TRAP would be redundant. NB that VMEXIT_EXCEPTION_DB doesn't have an HVM_HANDLER for SVM yet; but for VMX, there's a specific HVM_HANDLER trace record which includes more information; so SVM really should record information as well. Signed-off-by: George Dunlap --- tools/xentrace/xenalyze.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c index 46248e9a70..19b99dc66d 100644 --- a/tools/xentrace/xenalyze.c +++ b/tools/xentrace/xenalyze.c @@ -4641,6 +4641,14 @@ void hvm_generic_postprocess(struct hvm_data *h) { case VMEXIT_VINTR: /* Equivalent of PENDING_VIRT_INTR */ case VMEXIT_PAUSE: + /* + * VMX just has TRC_HVM_TRAP for these, which would be + * redundant on SVM + */ + case VMEXIT_EXCEPTION_BP: + case VMEXIT_EXCEPTION_NM: + case VMEXIT_EXCEPTION_AC: + case VMEXIT_EXCEPTION_UD: return; default: break; From patchwork Wed Jun 26 13:38:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 13713001 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AD1D1C3065B for ; Wed, 26 Jun 2024 13:58:16 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.749013.1157022 (Exim 4.92) (envelope-from ) id 1sMTA1-0001v7-MA; Wed, 26 Jun 2024 13:58:09 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 749013.1157022; Wed, 26 Jun 2024 13:58:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA1-0001si-Cj; Wed, 26 Jun 2024 13:58:09 +0000 Received: by outflank-mailman (input) for mailman id 749013; Wed, 26 Jun 2024 13:58:08 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA0-0000aq-Gt for xen-devel@lists.xenproject.org; Wed, 26 Jun 2024 13:58:08 +0000 Received: from mail-qk1-x72f.google.com (mail-qk1-x72f.google.com [2607:f8b0:4864:20::72f]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 1d600963-33c4-11ef-90a3-e314d9c70b13; Wed, 26 Jun 2024 15:58:07 +0200 (CEST) Received: by mail-qk1-x72f.google.com with SMTP id af79cd13be357-795a4fde8bfso396636985a.2 for ; Wed, 26 Jun 2024 06:58:07 -0700 (PDT) Received: from georged-x-u.xenrt.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79bce9318f6sm499371185a.101.2024.06.26.06.58.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 06:58:05 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1d600963-33c4-11ef-90a3-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1719410286; x=1720015086; darn=lists.xenproject.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=RQPpBZ6HUrKlZc92OfyG7VzBOtY27D4cEzdSY9vU/Hg=; b=h2vjbbUd/ocY5uNF/tmZ6w9P50ZQ6dAV1H9J6EM4hxaR4FGFgk6qXhPDtc6MRFPgPN GGAqx9kImj2WbhL6/YeXXpKkbtyRHUisJYLAEbP7dznu7f3bqkQZwK5POmb6xnKxr0bU 0JJcwHA2J4kOw0RLi4tKXzLeOMLVpyhGQoKXg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719410286; x=1720015086; 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=RQPpBZ6HUrKlZc92OfyG7VzBOtY27D4cEzdSY9vU/Hg=; b=m5FXvgzq0xCkHat9bJziWLFcZJfr9cCM5aaTNid4ngKkFMS/EzEI9SG5SCXoG8LJeg hngOLISnBxat8b1ldn7Ly/XfFBYPtsQ5mVXm6Y9Hpu84bY3EGNvRKqAEBCxERV8s0Oo4 CrrF1kzGirdFlevEnretDJZAiN9ZGw5Ip4auZsY54MEMVY0uY2SD00lBDd1uz1qsPuyV ls0Z3NpIZohZOTaKadw/pBQ74rRhlEzRGM0i76FSrAk/QbcvYGhYzm3RtuOfLWEqQbTV /ULj6XyT0YNWM5ih8qtXFRsMVXkNdCrN8vC0QLJsh7hYp82EYa/6yU9NuO2o//o5JM2e a6NQ== X-Gm-Message-State: AOJu0Yx/XIKVzERbyrKdkuat8shuvD+nfvgVdjHa2HCigNxOr8vGcUNq 753E/moGIUX1hiwEhRq7yzeTawDqyHapN4QZkmAgOkGzO1MNXA+NwQeSzTm2fe8aMikoeeC8duK iM1g= X-Google-Smtp-Source: AGHT+IHYOMfst4jjFAWDaoBPQd4epq0sodwQ8Lc9GhHBIHXeDf1jkpgCheuuVvuRECqN+bBlRsuDqg== X-Received: by 2002:a05:620a:414b:b0:797:de98:1420 with SMTP id af79cd13be357-79be6e9f513mr1244126985a.45.1719410285511; Wed, 26 Jun 2024 06:58:05 -0700 (PDT) From: George Dunlap To: xen-devel@lists.xenproject.org Cc: George Dunlap Subject: [PATCH WIP 06/14] xen/svm: Remove redundant HVM_HANDLER trace for EXCEPTION_AC Date: Wed, 26 Jun 2024 14:38:45 +0100 Message-Id: <20240626133853.4150731-7-george.dunlap@cloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626133853.4150731-1-george.dunlap@cloud.com> References: <20240626133853.4150731-1-george.dunlap@cloud.com> MIME-Version: 1.0 Adding an HVM_TRAP trace record is redundant for EXCEPTION_AC: it adds trace volume without adding any information, and xenalyze already knows not to expect it. Remove it. Signed-off-by: George Dunlap --- xen/arch/x86/hvm/svm/svm.c | 1 - 1 file changed, 1 deletion(-) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 988250dbc1..abe665ee43 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -2779,7 +2779,6 @@ void asmlinkage svm_vmexit_handler(void) } case VMEXIT_EXCEPTION_AC: - TRACE(TRC_HVM_TRAP, X86_EXC_AC); hvm_inject_hw_exception(X86_EXC_AC, vmcb->ei.exc.ec); break; From patchwork Wed Jun 26 13:38:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 13713005 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 12A33C30658 for ; Wed, 26 Jun 2024 13:58:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.749014.1157035 (Exim 4.92) (envelope-from ) id 1sMTA3-0002QO-Qv; Wed, 26 Jun 2024 13:58:11 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 749014.1157035; Wed, 26 Jun 2024 13:58:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA3-0002Q9-M6; Wed, 26 Jun 2024 13:58:11 +0000 Received: by outflank-mailman (input) for mailman id 749014; Wed, 26 Jun 2024 13:58:10 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA2-0000af-CT for xen-devel@lists.xenproject.org; Wed, 26 Jun 2024 13:58:10 +0000 Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [2607:f8b0:4864:20::22a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1df9d88d-33c4-11ef-b4bb-af5377834399; Wed, 26 Jun 2024 15:58:08 +0200 (CEST) Received: by mail-oi1-x22a.google.com with SMTP id 5614622812f47-3d55c0fadd2so971982b6e.3 for ; Wed, 26 Jun 2024 06:58:08 -0700 (PDT) Received: from georged-x-u.xenrt.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79bce9318f6sm499371185a.101.2024.06.26.06.58.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 06:58:07 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1df9d88d-33c4-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1719410287; x=1720015087; darn=lists.xenproject.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=ihcaurA1Zhe1+CN+gql25MhLcUH6MWHK0QwFWHqTTAY=; b=UPJzTzWFFtuIwxx5EBW9eSvJoy925ThjJod6rGpTPlQNIObyaiUgPZcuD27wTKg9NO nAjAhb4iDYkH55A1Ki6NI0CfWeVLV71nv4MgaYQ8RZkqCMibxtXrGcXhibDBCUGR+Dyv /SMJ5m8XQASaNjtbH2AkNooUAyAVgUjTZ72B8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719410287; x=1720015087; 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=ihcaurA1Zhe1+CN+gql25MhLcUH6MWHK0QwFWHqTTAY=; b=ZF7Ep4hVEglaiSGnujBXWhrYDxEkXd97cC28dBMhpk767OCErYN7QcR+eJL+VT1n7s IrnGkQh9Mk4qpd7oc6DYLg0sfcYXPnhHaPmwTNjP5bsS4mEa1K0jL0/P6+Fp/yunp9ql fWJfcqkgVCsSuwYIFOigfUAXX6Ck57MDB9DNT+yJdLyOdhdvWJ5yoRG3WijThkLMguva Y5RjBehbdP2tp3sBbdIcKxCtPwD8uQVc2AMBZNj52uDgYIHyHwA6AOgDsVhLGM25jG0U 4nHMOOLAyFA5qzxhdCROgnpPU+5TlCGVa29H3ooH+7VQrw6VdJ5MK9thtjV2cay+qJh/ Q7UQ== X-Gm-Message-State: AOJu0Yzn8CLWhWKi7NSYN4fkGDp4xT1VsvKofE2D8zx9/U9ZbZWlERJN HexhZwMULwsKzGdGUW0nxnvW3nD0VCKiBi89KxIhDyHKs60tDZ5kzP1Tg8t0glqNR3L3QgcBWRk du8I= X-Google-Smtp-Source: AGHT+IEFfaOnT5G7EPh+PZ1hPt4pC+pnq82ztk88/9m2zZJbgavZuE6gOnjPyhkdmYShkwmjac3cmQ== X-Received: by 2002:a05:6808:30a9:b0:3d2:1d51:e505 with SMTP id 5614622812f47-3d543aa87admr12513465b6e.17.1719410287385; Wed, 26 Jun 2024 06:58:07 -0700 (PDT) From: George Dunlap To: xen-devel@lists.xenproject.org Cc: George Dunlap Subject: [PATCH WIP 07/14] xen/hvm: Don't skip MSR_READ trace record Date: Wed, 26 Jun 2024 14:38:46 +0100 Message-Id: <20240626133853.4150731-8-george.dunlap@cloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626133853.4150731-1-george.dunlap@cloud.com> References: <20240626133853.4150731-1-george.dunlap@cloud.com> MIME-Version: 1.0 Commit 37f074a3383 ("x86/msr: introduce guest_rdmsr()") introduced a function to combine the MSR_READ handling between PV and HVM. Unfortunately, by returning directly, it skipped the trace generation, leading to gaps in the trace record, as well as xenalyze errors like this: hvm_generic_postprocess: d2v0 Strange, exit 7c(VMEXIT_MSR) missing a handler Replace the `return` with `goto out`. Fixes: 37f074a3383 ("x86/msr: introduce guest_rdmsr()") Signed-off-by: George Dunlap Reviewed-by: Jan Beulich --- xen/arch/x86/hvm/hvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 7f4b627b1f..0fe2b85b16 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -3557,7 +3557,7 @@ int hvm_msr_read_intercept(unsigned int msr, uint64_t *msr_content) fixed_range_base = (uint64_t *)v->arch.hvm.mtrr.fixed_ranges; if ( (ret = guest_rdmsr(v, msr, msr_content)) != X86EMUL_UNHANDLEABLE ) - return ret; + goto out; ret = X86EMUL_OKAY; From patchwork Wed Jun 26 13:38:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 13713003 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79773C3064D for ; Wed, 26 Jun 2024 13:58:20 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.749015.1157045 (Exim 4.92) (envelope-from ) id 1sMTA5-0002kO-Dp; Wed, 26 Jun 2024 13:58:13 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 749015.1157045; Wed, 26 Jun 2024 13:58:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA5-0002jz-8y; Wed, 26 Jun 2024 13:58:13 +0000 Received: by outflank-mailman (input) for mailman id 749015; Wed, 26 Jun 2024 13:58:11 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA3-0000af-Ci for xen-devel@lists.xenproject.org; Wed, 26 Jun 2024 13:58:11 +0000 Received: from mail-qk1-x72d.google.com (mail-qk1-x72d.google.com [2607:f8b0:4864:20::72d]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1ea343a8-33c4-11ef-b4bb-af5377834399; Wed, 26 Jun 2024 15:58:09 +0200 (CEST) Received: by mail-qk1-x72d.google.com with SMTP id af79cd13be357-79c2c05638cso72828185a.3 for ; Wed, 26 Jun 2024 06:58:09 -0700 (PDT) Received: from georged-x-u.xenrt.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79bce9318f6sm499371185a.101.2024.06.26.06.58.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 06:58:08 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1ea343a8-33c4-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1719410288; x=1720015088; darn=lists.xenproject.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=9e+XtFKCBF6+ISNOtkiCTkrjeCZCly6CC4Zvn3nhKU4=; b=TYbm68MLDysmVqRx672iicKjQp8G3c+5YQzWh+s0hsAVvQ1RsgslTBnR8QpExkxWFS WpdNilK/Y/NYMyBx9sY68ozVvXPMmztYShMdPB43rKtFIJfVvaR/esYhFDLcDs/q9pml ToyH91t0W4PX4edbCEsakLtWq9c6VwaGJprXY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719410288; x=1720015088; 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=9e+XtFKCBF6+ISNOtkiCTkrjeCZCly6CC4Zvn3nhKU4=; b=Zsv76ReI6uFyM41hmwcBNW8Etmo0jUlBcM+dhb9L2A02t49eubjxTF/3gT6Qiwhp/D j5b5YJJYs7ULeekEbvDgpujxSyNFhk77uNfVKk8hkVw/YMoUWm9zoeWgjRnIGsXzllYG ilh/JBAaVevcV83oEMy6sh51rln+mW66jX623uC5oeZFLG4cGQM1dBA/x7dJtWabRHCo i1JgdwQhnp+AWIuikZ4ctmfD6lhxJkpxiv0N/Rd65sWPcap7b+P377nAH52HIOtrxR90 H8FStoBp9/wzv2xtRC2xLhoPSqoFJpNxO90GlPn2l2oYL2spo6XMiMEWf7dBgmfN3Icq EY7Q== X-Gm-Message-State: AOJu0YyiKdmHY0dllCUb2mRw8qnadD3z3VyVEmsx/s2PVDh+Upr9cAn1 53ox5cQL0Otb4DvkZmu4j1jsl3CTSgR1pg3+cBID0rH9moz1liraL/B0yniwv4rQX41/RI2tWle XdlQ= X-Google-Smtp-Source: AGHT+IFibB7T4hWFxDlipIyL2aXKLogeYDFxykKHCycOIPIolO9DIPzvurs40uQc14FSUfQEpPfE/Q== X-Received: by 2002:a05:620a:1a8c:b0:795:533f:452c with SMTP id af79cd13be357-79be701cf0fmr1278984585a.73.1719410288627; Wed, 26 Jun 2024 06:58:08 -0700 (PDT) From: George Dunlap To: xen-devel@lists.xenproject.org Cc: George Dunlap , George Dunlap Subject: [PATCH WIP 08/14] svm: Do NPF trace before calling hvm_hap_nested_page_fault Date: Wed, 26 Jun 2024 14:38:47 +0100 Message-Id: <20240626133853.4150731-9-george.dunlap@cloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626133853.4150731-1-george.dunlap@cloud.com> References: <20240626133853.4150731-1-george.dunlap@cloud.com> MIME-Version: 1.0 Unfortunately I've forgotten exactly why I made this change. I suspect that there were other traces (like MMIO traces) which were being put before the NPF trace; but to understand the trace record you'd want to have the NPF information first. Signed-off-by: George Dunlap --- xen/arch/x86/hvm/svm/svm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index abe665ee43..240401dc77 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1614,8 +1614,6 @@ static void svm_do_nested_pgfault(struct vcpu *v, else if ( pfec & NPT_PFEC_in_gpt ) npfec.kind = npfec_kind_in_gpt; - ret = hvm_hap_nested_page_fault(gpa, ~0UL, npfec); - if ( tb_init_done ) { struct { @@ -1636,6 +1634,8 @@ static void svm_do_nested_pgfault(struct vcpu *v, trace(TRC_HVM_NPF, sizeof(_d), &_d); } + ret = hvm_hap_nested_page_fault(gpa, ~0UL, npfec); + switch ( ret ) { case 1: From patchwork Wed Jun 26 13:38:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 13713004 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 244A4C3065B for ; Wed, 26 Jun 2024 13:58:21 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.749016.1157051 (Exim 4.92) (envelope-from ) id 1sMTA6-0002pQ-2F; Wed, 26 Jun 2024 13:58:14 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 749016.1157051; Wed, 26 Jun 2024 13:58:14 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA5-0002nS-Mb; Wed, 26 Jun 2024 13:58:13 +0000 Received: by outflank-mailman (input) for mailman id 749016; Wed, 26 Jun 2024 13:58:12 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA4-0000af-SP for xen-devel@lists.xenproject.org; Wed, 26 Jun 2024 13:58:12 +0000 Received: from mail-ot1-x332.google.com (mail-ot1-x332.google.com [2607:f8b0:4864:20::332]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1f79cb05-33c4-11ef-b4bb-af5377834399; Wed, 26 Jun 2024 15:58:11 +0200 (CEST) Received: by mail-ot1-x332.google.com with SMTP id 46e09a7af769-6fa0d077694so3120525a34.0 for ; Wed, 26 Jun 2024 06:58:11 -0700 (PDT) Received: from georged-x-u.xenrt.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79bce9318f6sm499371185a.101.2024.06.26.06.58.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 06:58:09 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1f79cb05-33c4-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1719410290; x=1720015090; darn=lists.xenproject.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=DoUNb50e5mp4r/rfJxIl3Pgj6LDhk8b0bQb4gVKsKhE=; b=PpoQCUpAqOGNwjGr6KtIYp/S0oIJDezuV6wy9FjvADuo6SsB1tLo3xG3Qk1uqBv7zB J371uYBpYTEZ7miQSCHixN81YnO5oJnCJiPxk9sNeVQAtM1BdLfOMtsiO1mml3+S+BRw LHHt7tUtPSeSLNkzapQ3ZJECJlbzGH5CJQ3dU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719410290; x=1720015090; 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=DoUNb50e5mp4r/rfJxIl3Pgj6LDhk8b0bQb4gVKsKhE=; b=QWIFzWp6s57N/fqzLdRR615b1ZE3A+8/QBYKrHnoGL1YPm+yEyI9CY7Pyl4p7NF5uD 1FGK3Rok2veat1hLoL2IOUGpXQwuY5HIMRF4BCDwiJQVFxxmDDoGfl5NBLwu82Q+QNJf FZPJfUxXMdMyXI8sqWOUt4cQz6mzNJ9bvM0rg0dJPmKMXonc/9UPHW2pxuzZQv7JrXys ixUWRpPg8iG/4GmceHJVeMiR0XTHA84i5soit69F4NI5jln35CyunXupeX2Kls/QEFOQ Ybo11JrC/Bz0n76j95Bb92cpAe3a8SZ/4hr/JoLcrm8O8QLrzyI30KvsQOZ0QXbXH7+l 64aQ== X-Gm-Message-State: AOJu0YxnAnpLuTVSuGeGuuhF4UUvSfw6EiaDBNMUcEd7GKD+yzvd1x6J It+Pp0y0DkxbaSEpwpYK4ZeYrcFu2q5hQSIRaB5XcXrt29ID+rToFn49s1W6Ai1/ck42N5er+Ex ujX4= X-Google-Smtp-Source: AGHT+IGZ+U34IqEAjwOGmI73wgJjK4aN/mscCA7HeKeH+LcTuTCPz+Z7Ougl3kzzmNIG9S+yzLeCNg== X-Received: by 2002:a9d:3e49:0:b0:700:d3eb:c554 with SMTP id 46e09a7af769-700d3ebc59fmr1552872a34.1.1719410289917; Wed, 26 Jun 2024 06:58:09 -0700 (PDT) From: George Dunlap To: xen-devel@lists.xenproject.org Cc: George Dunlap Subject: [PATCH WIP 09/14] x86/emulate: Don't trace cr reads during emulation Date: Wed, 26 Jun 2024 14:38:48 +0100 Message-Id: <20240626133853.4150731-10-george.dunlap@cloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626133853.4150731-1-george.dunlap@cloud.com> References: <20240626133853.4150731-1-george.dunlap@cloud.com> MIME-Version: 1.0 hvmemul_read_cr ends up being called fairly freqently during emulation; these are generally not necessary for understanding a trace, and make processing more complicated (because they show up as extra trace records within a vmexit/entry "arc" that must be classified). Leave the trace in write_cr, as any hypothetical writes to CRs *will* be necessary to understand traces. Signed-off-by: George Dunlap --- xen/arch/x86/hvm/emulate.c | 1 - 1 file changed, 1 deletion(-) diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c index 02e378365b..e78f06cf3f 100644 --- a/xen/arch/x86/hvm/emulate.c +++ b/xen/arch/x86/hvm/emulate.c @@ -2180,7 +2180,6 @@ static int cf_check hvmemul_read_cr( case 3: case 4: *val = current->arch.hvm.guest_cr[reg]; - TRACE(TRC_HVM_CR_READ64, reg, *val, *val >> 32); return X86EMUL_OKAY; default: break; From patchwork Wed Jun 26 13:38:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 13713009 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0006DC3DA41 for ; Wed, 26 Jun 2024 13:58:27 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.749018.1157069 (Exim 4.92) (envelope-from ) id 1sMTA8-0003K0-DW; Wed, 26 Jun 2024 13:58:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 749018.1157069; Wed, 26 Jun 2024 13:58:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA7-0003IP-PT; Wed, 26 Jun 2024 13:58:15 +0000 Received: by outflank-mailman (input) for mailman id 749018; Wed, 26 Jun 2024 13:58:14 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA5-0000af-O4 for xen-devel@lists.xenproject.org; Wed, 26 Jun 2024 13:58:13 +0000 Received: from mail-ot1-x32c.google.com (mail-ot1-x32c.google.com [2607:f8b0:4864:20::32c]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 1ffabbd8-33c4-11ef-b4bb-af5377834399; Wed, 26 Jun 2024 15:58:12 +0200 (CEST) Received: by mail-ot1-x32c.google.com with SMTP id 46e09a7af769-6f855b2499cso3591964a34.1 for ; Wed, 26 Jun 2024 06:58:12 -0700 (PDT) Received: from georged-x-u.xenrt.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79bce9318f6sm499371185a.101.2024.06.26.06.58.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 06:58:10 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 1ffabbd8-33c4-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1719410291; x=1720015091; darn=lists.xenproject.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=aNXebvkx1B3kPnk1v4QIpuUImYj6FwSyktzAJ/iZD9E=; b=GIvlIpDGcvMZSx7J6k2ZpG3O1lpc71ItbHGp24k3C+qUDO3zo3yTOWAHySwzvcLIny fcV+M8CJK+QCEdsUAveSJKMsxYsFpeUCAdcGJbVRoEEuJnbI/KUER3peHuGImo8H5FFg Hd0FTelINn3FQKbjYpBsM9Y5suTiVRmQ+jix4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719410291; x=1720015091; 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=aNXebvkx1B3kPnk1v4QIpuUImYj6FwSyktzAJ/iZD9E=; b=r/lSUiEvrbwuRB5x3sQkF7MERwGcW4KdN4toJK19K65JLR8ZM5Oh7hqw6fIYR32JVS sgF8FPjqjvB5mrCosiaGPCj0zGdQr6oNp9bAr5holgEn0im9mfAbmwDe6wDiQgmZqF7z EgUekczEFMkdRtEUdU426WJkS3R96yMqB0kZGqvM6cLjHpV2ae1CGyouZ1kKEzKf0ttt STwMS2aAgR558mSSQuDsej00ai2n83EZFi+od08YBfLy/EWAyZ1tPSu7Nuc4qqhd49Mo /y3iSrsrzcJVGp6wUr+2UYX+8kyjsBmJM+kLPiBhAbP4p74JdFLkxMp/d4uktKSJN/wq Xm8g== X-Gm-Message-State: AOJu0YwkL6DxBzn+g8q7fkiiVD7YR745IxZuKY5jNSUT2OY518IbN/Oa gDolJouFAcxYrseU7y0B775G8vAUX7Lk8M0sa9rrL0CzosSnQaYVe5iML5Yv4Lk0dOe730Zi3CW r6lA= X-Google-Smtp-Source: AGHT+IEe5R8IsPa1WFXgoNQbI1tAaCHrwm2edK3lw3vpBp5ucsDlcV6zDqyFqTDgn390po2VCa/vVw== X-Received: by 2002:a05:6830:4108:b0:6fa:11aa:e929 with SMTP id 46e09a7af769-700b11d614emr13128067a34.11.1719410290845; Wed, 26 Jun 2024 06:58:10 -0700 (PDT) From: George Dunlap To: xen-devel@lists.xenproject.org Cc: George Dunlap Subject: [PATCH WIP 10/14] xenalyze: Quiet warnings about VMEXIT_IOIO Date: Wed, 26 Jun 2024 14:38:49 +0100 Message-Id: <20240626133853.4150731-11-george.dunlap@cloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626133853.4150731-1-george.dunlap@cloud.com> References: <20240626133853.4150731-1-george.dunlap@cloud.com> MIME-Version: 1.0 There's a general issue with both PIO and MMIO reads (as detailed in the comment); do a work-around for now. Signed-off-by: George Dunlap --- tools/xentrace/xenalyze.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c index 19b99dc66d..eb0e60e6ef 100644 --- a/tools/xentrace/xenalyze.c +++ b/tools/xentrace/xenalyze.c @@ -4650,6 +4650,24 @@ void hvm_generic_postprocess(struct hvm_data *h) case VMEXIT_EXCEPTION_AC: case VMEXIT_EXCEPTION_UD: return; + case VMEXIT_IOIO: + /* + * FIXME: Both IO and MMIO reads which have gone out + * to the emulator and back typically have the + * [mm]io_assist trace happen on resume, just before + * the subsequent VMENTRY. + * + * However, when a VM has blocked, we call + * hvm_vmexit_close() when it becomes RUNNABLE again, + * rather than when it actually runs again; meaning + * that when hvm_vmexit_close() is called, no HVM + * handler has been seen. + * + * What we really need is some sort of intermediate + * state for [mm]io reads; but for now just ignore + * VMEXIT_IOIO exits without a handler. + */ + return; default: break; } From patchwork Wed Jun 26 13:38:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 13713010 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EBA13C30658 for ; Wed, 26 Jun 2024 13:58:27 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.749017.1157061 (Exim 4.92) (envelope-from ) id 1sMTA7-0003DS-Ev; Wed, 26 Jun 2024 13:58:15 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 749017.1157061; Wed, 26 Jun 2024 13:58:15 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA7-0003BZ-AX; Wed, 26 Jun 2024 13:58:15 +0000 Received: by outflank-mailman (input) for mailman id 749017; Wed, 26 Jun 2024 13:58:13 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA5-0000aq-LD for xen-devel@lists.xenproject.org; Wed, 26 Jun 2024 13:58:13 +0000 Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [2607:f8b0:4864:20::732]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 209e8c70-33c4-11ef-90a3-e314d9c70b13; Wed, 26 Jun 2024 15:58:13 +0200 (CEST) Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-79c0bbff48aso152550085a.1 for ; Wed, 26 Jun 2024 06:58:13 -0700 (PDT) Received: from georged-x-u.xenrt.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79bce9318f6sm499371185a.101.2024.06.26.06.58.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 06:58:11 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 209e8c70-33c4-11ef-90a3-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1719410292; x=1720015092; darn=lists.xenproject.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=d3jc/D3oGiKvIBrZUXRabVXNRbnlweDK3F2GwPRZj5o=; b=S5T1oBiY7HpIqqQj5UBrBgDEhVlDzpevKmgYY03agoWjnfE1SslwTzWQzFMPT8SuGW t0vzskujDGvM1SyGKjVZ7jDGsvAPZ5JQFw/ZveCZQKD5FJaSJ9jLgDQJ8WRqtXMD5BoM O3NiGMfTiswm2H8gDsCQJTHEWlUDCC9kKQ03E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719410292; x=1720015092; 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=d3jc/D3oGiKvIBrZUXRabVXNRbnlweDK3F2GwPRZj5o=; b=Cwuq01hezb9SMfqudNFGxW42/0eglrUv/juDhjeErs+81skXHJqXXuh13Rs3I8iLYm Pusjpk0wPiDSEMapKn1/aIRqb7UQI+jKUiNg0H9h69jM7XFFe6zwJYvyCfXGj0hzngVB nWtRr1akFqKlOiRnVXmq3PuJANEgm4QHxPCIfoRhma2zTUhUaqpR4xUa7VmLgpdvBnty EQMQa1JxiJX8DvNjJ9pCHYdJ8i2g6946ywW9PbngoK1Z8cWNGSOuabCgydQyotVyWm1Z q/ei1qzXnU4CH3JwOKX4cegYgkwIyn8i/w941Syp9gxdyjKB/k+a7rdTZCq3WAsRbBNk DL2w== X-Gm-Message-State: AOJu0YzP5DI2jfcsnURcVI1KCxElXdiVrxEI1UTIFjqBQ63XiH3V4eEL YakWgf7ryzwiFvopkCH5lLUAE74Om5NHq/OQ2oc6xVgaf4q5f8Ev65X/zrnvwLCvSIiC2g8ihuz k7h4= X-Google-Smtp-Source: AGHT+IGot/l4FhRSt0d1zR1K2xibC+CVce1BvKCqj8naOo9yU4mayrW66/FlAJVn8S5u6fG4LZWhRA== X-Received: by 2002:a05:620a:3727:b0:798:db85:c999 with SMTP id af79cd13be357-79be6f13d87mr1195903485a.51.1719410291966; Wed, 26 Jun 2024 06:58:11 -0700 (PDT) From: George Dunlap To: xen-devel@lists.xenproject.org Cc: George Dunlap , Andrew Cooper , Jan Beulich , Roger Pau Monne Subject: [PATCH WIP 11/14] x86/trace: Add trace to xsetbv svm/vmx handler path Date: Wed, 26 Jun 2024 14:38:50 +0100 Message-Id: <20240626133853.4150731-12-george.dunlap@cloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626133853.4150731-1-george.dunlap@cloud.com> References: <20240626133853.4150731-1-george.dunlap@cloud.com> MIME-Version: 1.0 There are already "HVM handler" trace records for writing to XCRs in the context of an HVM guest. This trace is currently taken in hvmemul_write_xcr. However, both VMX and SVM vmexits call hvm_handle_xsetbv as a result of an XSETBV vmexit, and hvm_handle_xsetbv calls x86emul_write_xcr directly, bypassing the trace, resulting in no "HVM handler" trace record for that VMEXIT. For maximal DRY-ness, we would want hvm_handle_xsetbv to call hvmemul_write_xcr; but since the intent seems to be for hvmemul_* to be only accesible via hvm_emulate(), just duplicate the trace. Signed-off-by: George Dunlap --- CC: Andrew Cooper CC: Jan Beulich CC: Roger Pau Monne --- xen/arch/x86/hvm/hvm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 0fe2b85b16..628a131399 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -2073,6 +2073,8 @@ int hvm_handle_xsetbv(u32 index, u64 new_bv) if ( index == 0 ) hvm_monitor_crX(XCR0, new_bv, current->arch.xcr0); + TRACE(TRC_HVM_XCR_WRITE64, index, new_bv, new_bv >> 32); + rc = x86emul_write_xcr(index, new_bv, NULL); if ( rc != X86EMUL_OKAY ) hvm_inject_hw_exception(X86_EXC_GP, 0); From patchwork Wed Jun 26 13:38:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 13713008 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EB9DBC3064D for ; Wed, 26 Jun 2024 13:58:27 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.749019.1157074 (Exim 4.92) (envelope-from ) id 1sMTA9-0003RM-23; Wed, 26 Jun 2024 13:58:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 749019.1157074; Wed, 26 Jun 2024 13:58:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA8-0003NA-B9; Wed, 26 Jun 2024 13:58:16 +0000 Received: by outflank-mailman (input) for mailman id 749019; Wed, 26 Jun 2024 13:58:14 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA6-0000aq-LN for xen-devel@lists.xenproject.org; Wed, 26 Jun 2024 13:58:14 +0000 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [2607:f8b0:4864:20::729]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 2137ce87-33c4-11ef-90a3-e314d9c70b13; Wed, 26 Jun 2024 15:58:14 +0200 (CEST) Received: by mail-qk1-x729.google.com with SMTP id af79cd13be357-79c05c19261so97325085a.0 for ; Wed, 26 Jun 2024 06:58:14 -0700 (PDT) Received: from georged-x-u.xenrt.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79bce9318f6sm499371185a.101.2024.06.26.06.58.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 06:58:12 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 2137ce87-33c4-11ef-90a3-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1719410293; x=1720015093; darn=lists.xenproject.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=3TUWwDLi1R2zJHBj9N1SaI7go8LX451Wfg2VkzZDApI=; b=DHlQYGcAYHYp6zr+at4420d2vigfHVwNhCdFEC6c5EdxGmh6gYsvd341eoPod/lr1a yU/iQUIZZLz6+gJXaiN6pi5mDYTYSTjfsB3pbKIE9FxkMIiqGAqXQv8mpi14Gf1eSXqS EXDS4TOMIZ4T0EdezQz5c4EfRsTdxs22ZlRDg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719410293; x=1720015093; 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=3TUWwDLi1R2zJHBj9N1SaI7go8LX451Wfg2VkzZDApI=; b=r6T62Rxr3VZeLmhANYvB9DIrG5ta2XoTk7XihECUlqpr9PanKRhpnNb5SK/Z//IEi3 yOJ5BQVVsjIPtgLTMj1DsHAR52ly0He+ZVgtRHLH7FZ7EgEhxI6qEK1ZXB/cxsVBA/AP mfbWrrThqzfnRL8bZCQ/cZPOLQhgcSvBvHtxrsCfHtil1qtW3L01RpgwplvnCTAKzhJx 7+0IUdidti4yYMXPkf3AMBAvwoajnDdLUBWNNF6aUDH1f3gZDXAtO7GEx3L5wFjem1yv MEk6rfnnrojKFz3OQgMvwMNgv85jIZlorncJDpISi1RVlqgdg5SEKt68mDQ9zodL1aub oSMA== X-Gm-Message-State: AOJu0YwhNb60vAqK44Z0DX7cyzvFet4O9hqJ32SjRcmPrqhBP10W4XaC NP4hxujOjZCCjnh45u8QlaJkIr0NOHGNt/ixHOCUbrkNJidC2az0ajChMk8mImt1HMk3SD65S1h 7fyI= X-Google-Smtp-Source: AGHT+IGJ2lo2PMzNvloP71CWFEAIEwg6k06VIqoyJtqytdgCEBGc6bBZGCVD6c/8GEgw9Au8SXicJA== X-Received: by 2002:a05:620a:28c5:b0:79c:ec3:f121 with SMTP id af79cd13be357-79c0ec3f47bmr354079385a.31.1719410292829; Wed, 26 Jun 2024 06:58:12 -0700 (PDT) From: George Dunlap To: xen-devel@lists.xenproject.org Cc: George Dunlap Subject: [PATCH WIP 12/14] xenalyze: Basic processing for XSETBV exits and handlers Date: Wed, 26 Jun 2024 14:38:51 +0100 Message-Id: <20240626133853.4150731-13-george.dunlap@cloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626133853.4150731-1-george.dunlap@cloud.com> References: <20240626133853.4150731-1-george.dunlap@cloud.com> MIME-Version: 1.0 Basically this means adding VMEXIT strings for XSETBV exit, and adding the handlers and strings for them. Signed-off-by: George Dunlap --- tools/xentrace/xenalyze.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c index eb0e60e6ef..d0e2788727 100644 --- a/tools/xentrace/xenalyze.c +++ b/tools/xentrace/xenalyze.c @@ -694,6 +694,8 @@ enum VMEXIT_EXITCODE VMEXIT_MONITOR = 138, VMEXIT_MWAIT = 139, VMEXIT_MWAIT_CONDITIONAL= 140, + VMEXIT_XSETBV = 141, /* 0x8d */ + VMEXIT_RDPRU = 142, /* 0x8e */ VMEXIT_NPF = 1024, /* nested paging fault */ VMEXIT_INVALID = -1 }; @@ -853,6 +855,8 @@ const char * hvm_svm_exit_reason_name[HVM_SVM_EXIT_REASON_MAX] = { "VMEXIT_MWAIT", /* 140 */ "VMEXIT_MWAIT_CONDITIONAL", + "VMEXIT_XSETBV", + "VMEXIT_RDPRU", [VMEXIT_NPF] = "VMEXIT_NPF", /* nested paging fault */ }; @@ -946,6 +950,8 @@ enum { HVM_EVENT_TRAP, HVM_EVENT_TRAP_DEBUG, HVM_EVENT_VLAPIC, + HVM_EVENT_XCR_READ, + HVM_EVENT_XCR_WRITE, HVM_EVENT_HANDLER_MAX }; const char * hvm_event_handler_name[HVM_EVENT_HANDLER_MAX] = { @@ -981,7 +987,9 @@ const char * hvm_event_handler_name[HVM_EVENT_HANDLER_MAX] = { "realmode_emulate", "trap", "trap_debug", - "vlapic" + "vlapic", + "xcr_read", + "xcr_write" }; enum { From patchwork Wed Jun 26 13:38:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 13713007 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 050ADC41513 for ; Wed, 26 Jun 2024 13:58:27 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.749020.1157080 (Exim 4.92) (envelope-from ) id 1sMTA9-0003au-L1; Wed, 26 Jun 2024 13:58:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 749020.1157080; Wed, 26 Jun 2024 13:58:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA9-0003XQ-6M; Wed, 26 Jun 2024 13:58:17 +0000 Received: by outflank-mailman (input) for mailman id 749020; Wed, 26 Jun 2024 13:58:15 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA7-0000aq-LN for xen-devel@lists.xenproject.org; Wed, 26 Jun 2024 13:58:15 +0000 Received: from mail-qk1-x732.google.com (mail-qk1-x732.google.com [2607:f8b0:4864:20::732]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 21be66db-33c4-11ef-90a3-e314d9c70b13; Wed, 26 Jun 2024 15:58:15 +0200 (CEST) Received: by mail-qk1-x732.google.com with SMTP id af79cd13be357-79c04e6e1b9so145459685a.0 for ; Wed, 26 Jun 2024 06:58:15 -0700 (PDT) Received: from georged-x-u.xenrt.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79bce9318f6sm499371185a.101.2024.06.26.06.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 06:58:13 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 21be66db-33c4-11ef-90a3-e314d9c70b13 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1719410294; x=1720015094; darn=lists.xenproject.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=no+X6902JG1x7fj9iA4/toVtrkKWwuLeqtvhWCBHqWU=; b=QqqW2wI7R9S5p1b0r7zHB4rVrciwQpkHuA3wA+7NBp55AcVywLz9NcWT0qh4Rnm1Au CJxpVFOhII/Al29nhHNazKKjL40KVuSX88iE2XOym99FJZxxP7NRf22+r5CfMzNAcYO5 GMoRZ7YlPP9RzujPNHdZHLBd44DdFKvXbzzEU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719410294; x=1720015094; 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=no+X6902JG1x7fj9iA4/toVtrkKWwuLeqtvhWCBHqWU=; b=voHWOpR/XeV9lUo1LkW8u0CBIa34xmLAZAZ8HdIdfILydO6Hrat773ErcP6KbI66kQ NyAYXqeAIKEQ4PKYCoIyEopyhfXEFf23TgdbP0JeZI5SHCfiq6tTP7Af9l6zxw3+Q6o8 ozCAnQKWT07S+QvNUPQwtSvUFXYXegLm9dyeyzgqpYpXbljbxfnqex+quXoNeO9px+8u MwrIUGMD+HapxeF4PTM4rn/YrA5ScU0IeX2G/kS7aya1oV6qFhVqMNB3gdlcGuDP1jNg NZ7R7u9YnwOPh9FQUu6AcVMRQ7AvFHLPLqdfwyJcfThfT9LSHY2wYYGsc2bWsJHd4u81 +oMQ== X-Gm-Message-State: AOJu0Yx2CWAPjSmJXLUwKA9jmgfZYrvPxqnt6aXcvR3qQXTLl2wcCEYb Fes4PGMtguDhGV8OM3DEmB49Dy04pf1vIj9a4G1BZe2DO1mZLZ1hTXtagFEHY3N2QREDH4MPqYx W2WY= X-Google-Smtp-Source: AGHT+IH904eHMI1zSSqNbKZPKyIjtzLTWlNqjr6c8ygXrMuor5Jj4QVS7saH0tsJmAnDi0imhmjWGQ== X-Received: by 2002:a05:620a:424c:b0:792:952b:6310 with SMTP id af79cd13be357-79be0c6b8b3mr1288300585a.45.1719410293810; Wed, 26 Jun 2024 06:58:13 -0700 (PDT) From: George Dunlap To: xen-devel@lists.xenproject.org Cc: George Dunlap Subject: [PATCH WIP 13/14] x86/svm: Add a trace for VMEXIT_VMRUN Date: Wed, 26 Jun 2024 14:38:52 +0100 Message-Id: <20240626133853.4150731-14-george.dunlap@cloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626133853.4150731-1-george.dunlap@cloud.com> References: <20240626133853.4150731-1-george.dunlap@cloud.com> MIME-Version: 1.0 Note that this trace is SVM-specific. Most HVM handler traces are shared between VMX and SVM because the underlying instruction set is largely the equivalent; but in this case, the instructions are different enough that there's no sensible way to share HVM handler traces between them. Keeping the target VMCB address should allow future analysis of which L2 vcpu within an L1 is running. Signed-off-by: George Dunlap --- tools/xentrace/xenalyze.c | 20 +++++++++++++++++++- xen/arch/x86/hvm/svm/svm.c | 2 ++ xen/include/public/trace.h | 1 + 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/tools/xentrace/xenalyze.c b/tools/xentrace/xenalyze.c index d0e2788727..d1988b4232 100644 --- a/tools/xentrace/xenalyze.c +++ b/tools/xentrace/xenalyze.c @@ -952,6 +952,7 @@ enum { HVM_EVENT_VLAPIC, HVM_EVENT_XCR_READ, HVM_EVENT_XCR_WRITE, + HVM_EVENT_VMRUN, HVM_EVENT_HANDLER_MAX }; const char * hvm_event_handler_name[HVM_EVENT_HANDLER_MAX] = { @@ -989,7 +990,8 @@ const char * hvm_event_handler_name[HVM_EVENT_HANDLER_MAX] = { "trap_debug", "vlapic", "xcr_read", - "xcr_write" + "xcr_write", + "vmrun" }; enum { @@ -4610,6 +4612,19 @@ void hvm_rdtsc_process(struct record_info *ri, struct hvm_data *h) h->last_rdtsc = r->tsc; } + +void hvm_vmrun_process(struct record_info *ri, struct hvm_data *h) +{ + struct { + uint64_t vmcbaddr; + } *r = (typeof(r))h->d; + + if ( opt.dump_all ) + printf(" %s vmrun %llx\n", + ri->dump_header, + (unsigned long long)r->vmcbaddr); +} + void hvm_generic_summary(struct hvm_data *h, void *data) { long evt = (long)data; @@ -4910,6 +4925,9 @@ needs_vmexit: case TRC_HVM_RDTSC: hvm_rdtsc_process(ri, h); break; + case TRC_HVM_VMRUN: + hvm_vmrun_process(ri, h); + break; case TRC_HVM_DR_READ: case TRC_HVM_DR_WRITE: case TRC_HVM_CPUID: diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 240401dc77..39af0ffdd6 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -2177,6 +2177,8 @@ svm_vmexit_do_vmrun(struct cpu_user_regs *regs, return; } + TRACE(TRC_HVM_VMRUN, vmcbaddr, vmcbaddr >> 32); + vcpu_nestedhvm(v).nv_vmentry_pending = 1; return; } diff --git a/xen/include/public/trace.h b/xen/include/public/trace.h index 141efa0ea7..19a29a5929 100644 --- a/xen/include/public/trace.h +++ b/xen/include/public/trace.h @@ -222,6 +222,7 @@ #define TRC_HVM_VLAPIC (TRC_HVM_HANDLER + 0x25) #define TRC_HVM_XCR_READ64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x26) #define TRC_HVM_XCR_WRITE64 (TRC_HVM_HANDLER + TRC_64_FLAG + 0x27) +#define TRC_HVM_VMRUN (TRC_HVM_HANDLER + 0x28) #define TRC_HVM_IOPORT_WRITE (TRC_HVM_HANDLER + 0x216) #define TRC_HVM_IOMEM_WRITE (TRC_HVM_HANDLER + 0x217) From patchwork Wed Jun 26 13:38:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: George Dunlap X-Patchwork-Id: 13713006 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id F2057C27C4F for ; Wed, 26 Jun 2024 13:58:26 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.749021.1157094 (Exim 4.92) (envelope-from ) id 1sMTAC-0004CF-1p; Wed, 26 Jun 2024 13:58:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 749021.1157094; Wed, 26 Jun 2024 13:58:19 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTAB-00049P-Bs; Wed, 26 Jun 2024 13:58:19 +0000 Received: by outflank-mailman (input) for mailman id 749021; Wed, 26 Jun 2024 13:58:17 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sMTA9-0000af-HC for xen-devel@lists.xenproject.org; Wed, 26 Jun 2024 13:58:17 +0000 Received: from mail-qk1-x72e.google.com (mail-qk1-x72e.google.com [2607:f8b0:4864:20::72e]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 224d103b-33c4-11ef-b4bb-af5377834399; Wed, 26 Jun 2024 15:58:16 +0200 (CEST) Received: by mail-qk1-x72e.google.com with SMTP id af79cd13be357-79c06169e9cso118414785a.3 for ; Wed, 26 Jun 2024 06:58:15 -0700 (PDT) Received: from georged-x-u.xenrt.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id af79cd13be357-79bce9318f6sm499371185a.101.2024.06.26.06.58.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Jun 2024 06:58:14 -0700 (PDT) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 224d103b-33c4-11ef-b4bb-af5377834399 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1719410294; x=1720015094; darn=lists.xenproject.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=TTGn0K1/CfHD8ie03BFgIyvIbG3pkRzclg3QaK3twgk=; b=GOrzi10VMjCDzkCGUc9Bbhjg5PhJY2r6Bo3rq900pIuJbbpnNSZqPB58tNGW2tyARU 6d7QPtUcNFglGP9FjcfC+n9m27SrRH01IGe/0JVLjTo4DRNfYIjkkvLUJo1nd/sAlhrP 5X8Oh2YQ9R4a3IEDmPAytfjniHt4LUzB2/WyA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719410294; x=1720015094; 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=TTGn0K1/CfHD8ie03BFgIyvIbG3pkRzclg3QaK3twgk=; b=iHi0w8Ynic1QmrOUkqcgpJ4cLZ1NIFgiFHqhWd8Bn9jKbWucrYsIYJIfOVFzK/JE6Y 6aZwQ2cR9j3d2A5dZeOF6Whei0Be7ZHNy+TTSVLKhVnijP4ayKf5JHiUSFa+vSuzK6M/ AfmlOInZ5NLFOGaP4m0lviNxdJZ1sZnDycZZkCF+S+MbdZhm6XXap4pTdAE56L3dCRT4 l6xS3cm46bu0Ih5WWjpmbQuD7TF0MVhUXPTVjNrdhSVHP6mSLEVqcosyVZT2rqPet1w7 YDDHUE4v/Ax6jKIi6RZInCbrNFJsIpN3rDzNmWCa8zr8ys3XO9uSjF/MOkA7FyckPRZZ bv4Q== X-Gm-Message-State: AOJu0YziF7q4ficrPcUgkRP9CPYtzSWc5Mjko2rkB1jnXYG+KEm3lS7h UlsV4qnnFmHbekRNOmR+lZmjIbSbjtyrQGP/Z2cWjrHu/vkCNwRiJcvL+A9wH8c5eEk/+1UuC6Q YsCU= X-Google-Smtp-Source: AGHT+IEdIn4jHdr7DjURLQkv1U3KWYIzU9lQCj249iwKA5u/sbddkQCWiKMo/H6Z+aKLg9OtApUkww== X-Received: by 2002:a05:620a:4150:b0:795:52e7:a49a with SMTP id af79cd13be357-79be701fef5mr1199488085a.75.1719410294659; Wed, 26 Jun 2024 06:58:14 -0700 (PDT) From: George Dunlap To: xen-devel@lists.xenproject.org Cc: George Dunlap Subject: [PATCH WIP 14/14] x86/nestedsvm: Note some places for improvement Date: Wed, 26 Jun 2024 14:38:53 +0100 Message-Id: <20240626133853.4150731-15-george.dunlap@cloud.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240626133853.4150731-1-george.dunlap@cloud.com> References: <20240626133853.4150731-1-george.dunlap@cloud.com> MIME-Version: 1.0 Signed-off-by: George Dunlap --- xen/arch/x86/hvm/svm/nestedsvm.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c index 35a2cbfd7d..dca06f2a6c 100644 --- a/xen/arch/x86/hvm/svm/nestedsvm.c +++ b/xen/arch/x86/hvm/svm/nestedsvm.c @@ -1349,8 +1349,21 @@ nestedsvm_check_intercepts(struct vcpu *v, struct cpu_user_regs *regs, return NESTEDHVM_VMEXIT_INJECT; case VMEXIT_VMMCALL: /* Always let the guest handle VMMCALL/VMCALL */ + /* + * FIXME: This is wrong; if the L1 hasn't set the VMMCALL + * intercept and the L2 executes a VMMACALL, it should result + * in a #UD, not a VMMCALL exception. + */ return NESTEDHVM_VMEXIT_INJECT; default: + /* + * FIXME: It's not true that any VMEXIT not intercepted by L1 + * can safely be handled "safely" by L0; VMCALL above is one + * such example, but there may be more. We either need to + * combine this switch statement into the one in + * nsvm_vmcb_guest_intercepts_exitcode(), or explicitly list + * known-safe exits here. + */ break; }