From patchwork Fri Mar 17 09:57:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 9630151 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 62ED460249 for ; Fri, 17 Mar 2017 09:59:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38F30286A1 for ; Fri, 17 Mar 2017 09:59:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DAC3286A3; Fri, 17 Mar 2017 09:59:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D21A0286A1 for ; Fri, 17 Mar 2017 09:59:52 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1coodM-0000Ub-6X; Fri, 17 Mar 2017 09:57:20 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1coodL-0000TG-5J for xen-devel@lists.xenproject.org; Fri, 17 Mar 2017 09:57:19 +0000 Received: from [85.158.137.68] by server-3.bemta-3.messagelabs.com id E2/2F-14551-DF2BBC85; Fri, 17 Mar 2017 09:57:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprNIsWRWlGSWpSXmKPExsXitHSDve7fTac jDE79lrH4vmUykwOjx+EPV1gCGKNYM/OS8isSWDMWfNvNVvBMrGJ75yqWBsatQl2MnBwSAv4S f0+fZQex2QR0JKY+vcTaxcjBISKgInF7rwGIySxQLtExoRakQlggTOLw9ttsIDaLgKrE889zW EFsXgF3iZ+NB1ggJspJnD/+kxnE5hTwkLh4qYkRxBYCqlnQ/JUNwlaRWD91FhtEr6DEyZlPwH qZBSQkDr54wTyBkXcWktQsJKkFjEyrGDWKU4vKUot0jUz1kooy0zNKchMzc3QNDYz1clOLixP TU3MSk4r1kvNzNzECA6eegYFxB2PrCb9DjJIcTEqivC9WnI4Q4kvKT6nMSCzOiC8qzUktPsQo w8GhJMEbvREoJ1iUmp5akZaZAwxhmLQEB4+SCO+RDUBp3uKCxNzizHSI1ClGS445s3e/YeK41 bAHSM57ceANkxBLXn5eqpQ4bzDIPAGQhozSPLhxsDi7xCgrJczLyMDAIMRTkFqUm1mCKv+KUZ yDUUmYtx9kCk9mXgnc1ldABzEBHfT2wwmQg0oSEVJSDYw8Z9x3bPwnHiQ96ZDTqYiFl90CVaN 2Gc4+nHbz+PG5KieTNr9+UVK8R6not/+BjqlzAhWXBc+bt65zfmNOcZzhNMn9j9/smvO2+Ipo jKFsvT/rhxcmu6InHOs3ar7W79Pfqn5ryv6mM135ThLbDnmXLVguK15aFs4feJ3nmWKO/olfE wK6UncrsRRnJBpqMRcVJwIAGFN7Wq4CAAA= X-Env-Sender: prvs=242126e8b=Paul.Durrant@citrix.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1489744635!64401385!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64110 invoked from network); 17 Mar 2017 09:57:17 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-6.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 17 Mar 2017 09:57:17 -0000 X-IronPort-AV: E=Sophos;i="5.36,176,1486425600"; d="scan'208";a="423198445" From: Paul Durrant To: Date: Fri, 17 Mar 2017 09:57:12 +0000 Message-ID: <1489744633-28760-7-git-send-email-paul.durrant@citrix.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1489744633-28760-1-git-send-email-paul.durrant@citrix.com> References: <1489744633-28760-1-git-send-email-paul.durrant@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Paul Durrant , Jan Beulich Subject: [Xen-devel] [PATCH 6/7] x86/viridian: make the threshold for HvNotifyLongSpinWait tunable X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP The current threshold before the guest issues the hypercall is, and always has been, hard-coded to 2047. It is not clear where this number came from so, to at least allow for ease of experimentation, this patch makes the threshold tunable via the Xen command line. Signed-off-by: Paul Durrant --- Cc: Jan Beulich Cc: Andrew Cooper --- docs/misc/xen-command-line.markdown | 8 ++++++++ xen/arch/x86/hvm/viridian.c | 24 +++++++++++++++++++++++- 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/docs/misc/xen-command-line.markdown b/docs/misc/xen-command-line.markdown index 4daf5b5..7f7e0d9 100644 --- a/docs/misc/xen-command-line.markdown +++ b/docs/misc/xen-command-line.markdown @@ -1623,6 +1623,14 @@ The optional `keep` parameter causes Xen to continue using the vga console even after dom0 has been started. The default behaviour is to relinquish control to dom0. +### viridian\_spinlock\_retry\_count +> `= ` + +> Default: `2047` + +Specify the maximum number of retries before an enlightened Windows +guest will notify Xen that it has failed to acquire a spinlock. + ### vpid (Intel) > `= ` diff --git a/xen/arch/x86/hvm/viridian.c b/xen/arch/x86/hvm/viridian.c index deb57f9..e7cc4e4 100644 --- a/xen/arch/x86/hvm/viridian.c +++ b/xen/arch/x86/hvm/viridian.c @@ -22,6 +22,12 @@ #include #include +#define VIRIDIAN_SPINLOCK_RETRY_COUNT_DEFAULT 2047 + +static int __read_mostly viridian_spinlock_retry_count; +integer_param("viridian_spinlock_retry_count", + viridian_spinlock_retry_count); + /* Viridian MSR numbers. */ #define HV_X64_MSR_GUEST_OS_ID 0x40000000 #define HV_X64_MSR_HYPERCALL 0x40000001 @@ -241,7 +247,13 @@ void cpuid_viridian_leaves(const struct vcpu *v, uint32_t leaf, res->a |= CPUID4A_HCALL_REMOTE_TLB_FLUSH; if ( !cpu_has_vmx_apic_reg_virt ) res->a |= CPUID4A_MSR_BASED_APIC; - res->b = 2047; /* long spin count */ + + /* + * This value is the recommended number of attempts to try to + * acquire a spinlock before notifying the hypervisor via the + * HvNotifyLongSpinWait hypercall. + */ + res->b = viridian_spinlock_retry_count; break; case 6: @@ -991,6 +1003,16 @@ static int viridian_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t *h) HVM_REGISTER_SAVE_RESTORE(VIRIDIAN_VCPU, viridian_save_vcpu_ctxt, viridian_load_vcpu_ctxt, 1, HVMSR_PER_VCPU); +static int __init viridian_init(void) +{ + if ( !viridian_spinlock_retry_count ) + viridian_spinlock_retry_count = + VIRIDIAN_SPINLOCK_RETRY_COUNT_DEFAULT; + + return 0; +} +__initcall(viridian_init); + /* * Local variables: * mode: C