From nobody Tue Apr 30 02:09:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1577119552; cv=none; d=zohomail.com; s=zohoarc; b=PFfSDC1uwG41gjoRZNInSNZeTIGDao+S5HAtzEpqOl5+YbgDqEhmxg0dwKvPIlBYbs1kx3CfBkFvFknYQsENSZC0498BnLfOaXGIY0tfJnNoSYqK0T3etBkbCe1okbWnF1G+WSoGU48TlptAvfwRwmGJV29MP/mHWmfDHWZUEP0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577119552; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=C3l7MraeJixEATd6xZFw91Xt96cuwHR7q2rEzrJPpHk=; b=NYlf/AF6FyMpVx3KR4ZA5vo18+EFtXmP6lYAs3EaTv/xHQ95IoiGLcVrm7IKbWYiC3zhpSP5phHvh0S3CRIwmRI9i5a6W4mVw+eZp2ZGi1M3gSoanrJ8b3yGJzEa5Z25MMKTmH7FmyIlOq1O/hQxSpoTFB3YVWIHGrDgBmuYYQI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1577119552081712.8166108033477; Mon, 23 Dec 2019 08:45:52 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijQoA-0006Kn-Kd; Mon, 23 Dec 2019 16:43:50 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijQo8-0006KG-V5 for xen-devel@lists.xenproject.org; Mon, 23 Dec 2019 16:43:48 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5c36a6da-25a3-11ea-96fe-12813bfff9fa; Mon, 23 Dec 2019 16:43:34 +0000 (UTC) X-Inumbo-ID: 5c36a6da-25a3-11ea-96fe-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1577119414; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=vsbhqvxTPqxq150MwF1GoyaiUXnxXCxdKv0AX0i+w4A=; b=KwLHx/uJU2tWJiLH6hKiz+Bk10NTE1NbIwHv0OjtSqwLMlKinKcHckWq /Tl0KWaPupeTJygqSvH2nWD8lmGHj3WTko3MpYXsCuToXTzYu7wnIp5jb r/PE3QBq3Ek0jAUyPhN7m3gM6y4LFnvpSR6Hhh5ZKQnFkMIthiZII2rDj s=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=george.dunlap@citrix.com; spf=Pass smtp.mailfrom=George.Dunlap@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of george.dunlap@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="george.dunlap@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of George.Dunlap@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="George.Dunlap@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 7yCzjNOIXE9cMcr2KHNYPhVUxnpjVBL9i5LUbLITtj9830IRWyE98T/XwFbO7hF793u7hLd/tS q8p+dsEsxrvEFZ/4obU8sk3o29Uhrk3svBGG2iIixBy5nMCAr8jO//ZaXHLtzSa8g2dVFLGq7Q R87ogzktdYXJ20D9IIoiBylAWOL37ekWC0TnFAk8yFGULHoyotomVSFNhHeAD29CWZPNtwO0uG TU6ES15VDEM4Yys1DFw5vWSgqjQEh0YXtvigmkZ2pOHLdCmphj80Q9y1FYVY1tqUhUgZHF2o/F FVg= X-SBRS: 2.7 X-MesageID: 10229662 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,348,1571716800"; d="scan'208";a="10229662" From: George Dunlap To: Date: Mon, 23 Dec 2019 16:43:26 +0000 Message-ID: <20191223164329.3113378-2-george.dunlap@citrix.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191223164329.3113378-1-george.dunlap@citrix.com> References: <20191223164329.3113378-1-george.dunlap@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 1/4] xen: Remove trailing whitespace from time.c X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , George Dunlap , Jan Beulich Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) No functional changes. Signed-off-by: George Dunlap Acked-by: Jan Beulich --- CC: Andrew Cooper CC: Jan Beulich --- xen/arch/x86/time.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index ea696a95e8..64e471a39b 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1,10 +1,10 @@ /*************************************************************************= ***** * arch/x86/time.c - *=20 + * * Per-CPU time calibration and management. - *=20 + * * Copyright (c) 2002-2005, K A Fraser - *=20 + * * Portions from Linux are: * Copyright (c) 1991, 1992, 1995 Linus Torvalds */ @@ -78,8 +78,8 @@ static struct timer calibration_timer; * We simulate a 32-bit platform timer from the 16-bit PIT ch2 counter. * Otherwise overflow happens too quickly (~50ms) for us to guarantee that * softirq handling will happen in time. - *=20 - * The pit_lock protects the 16- and 32-bit stamp fields as well as the=20 + * + * The pit_lock protects the 16- and 32-bit stamp fields as well as the */ static DEFINE_SPINLOCK(pit_lock); static u16 pit_stamp16; @@ -100,7 +100,7 @@ static inline u32 div_frac(u32 dividend, u32 divisor) { u32 quotient, remainder; ASSERT(dividend < divisor); - asm (=20 + asm ( "divl %4" : "=3Da" (quotient), "=3Dd" (remainder) : "0" (0), "1" (dividend), "r" (divisor) ); @@ -1011,7 +1011,7 @@ static void __get_cmos_time(struct rtc_time *rtc) rtc->day =3D CMOS_READ(RTC_DAY_OF_MONTH); rtc->mon =3D CMOS_READ(RTC_MONTH); rtc->year =3D CMOS_READ(RTC_YEAR); - =20 + if ( RTC_ALWAYS_BCD || !(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) ) { BCD_TO_BIN(rtc->sec); @@ -1511,8 +1511,8 @@ static void check_tsc_warp(unsigned long tsc_khz, uns= igned long *max_warp) spin_unlock(&sync_lock); =20 /* - * Be nice every now and then (and also check whether measurement = is=20 - * done [we also insert a 10 million loops safety exit, so we dont=20 + * Be nice every now and then (and also check whether measurement = is + * done [we also insert a 10 million loops safety exit, so we dont * lock up in case the TSC readout is totally broken]): */ if ( unlikely(!(i & 7)) ) @@ -1524,7 +1524,7 @@ static void check_tsc_warp(unsigned long tsc_khz, uns= igned long *max_warp) } =20 /* - * Outside the critical section we can now see whether we saw a=20 + * Outside the critical section we can now see whether we saw a * time-warp of the TSC going backwards: */ if ( unlikely(prev > now) ) @@ -1806,11 +1806,11 @@ void init_percpu_time(void) } =20 /* - * On certain older Intel CPUs writing the TSC MSR clears the upper 32 bit= s.=20 + * On certain older Intel CPUs writing the TSC MSR clears the upper 32 bit= s. * Obviously we must not use write_tsc() on such CPUs. * - * Additionally, AMD specifies that being able to write the TSC MSR is not= an=20 - * architectural feature (but, other than their manual says, also cannot b= e=20 + * Additionally, AMD specifies that being able to write the TSC MSR is not= an + * architectural feature (but, other than their manual says, also cannot be * determined from CPUID bits). */ static void __init tsc_check_writability(void) @@ -2010,7 +2010,7 @@ void __init early_time_init(void) =20 do_div(tmp, 1000); cpu_khz =3D (unsigned long)tmp; - printk("Detected %lu.%03lu MHz processor.\n",=20 + printk("Detected %lu.%03lu MHz processor.\n", cpu_khz / 1000, cpu_khz % 1000); =20 setup_irq(0, 0, &irq0); @@ -2025,7 +2025,7 @@ static int _disable_pit_irq(void(*hpet_broadcast_setu= p)(void)) return -1; =20 /* - * If we do not rely on PIT CH0 then we can use HPET for one-shot time= r=20 + * If we do not rely on PIT CH0 then we can use HPET for one-shot timer * emulation when entering deep C states. * XXX dom0 may rely on RTC interrupt delivery, so only enable * hpet_broadcast if FSB mode available or if force_hpet_broadcast. --=20 2.24.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 30 02:09:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1577119522; cv=none; d=zohomail.com; s=zohoarc; b=jyykieiBFLTiB4lxxZUDIPmoTaJzYCXY8FkWud/C+WjxbfzmaHZIk9P3xRFzzYrAtckjvbay8Hml7zWGVILFSNpqKz4XtYpWDaWxxicvNIVuXjSw1BvW/z/I2W2elWWqDEQpgK+GPdIOzin+4JdGTHU4Z7gUXmrFzP2VqdrmS6Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577119522; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XAHi2xyBH4SRzD0JRwZurs8pJgV4u6GcZqG10xqLV5Y=; b=UkpNpnoA1ITHcmd5MAyLo1BQtV0L3mmwaO60CPNiWQTUjjYDvUThRBFecff5cdZDdJRJFDhIJlILZvTYO01t1w7cfkmcp8Fu6jBibUDR2fRiE/Z4qPGHKyQkSXv5Tw9qScHu/RIY6As0F9XniJsvrSQex0B4D7MQmS9Mk/bAhbw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1577119522473723.6710559933351; Mon, 23 Dec 2019 08:45:22 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijQo5-0006J1-B5; Mon, 23 Dec 2019 16:43:45 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijQo3-0006Id-VA for xen-devel@lists.xenproject.org; Mon, 23 Dec 2019 16:43:43 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5bbafdb4-25a3-11ea-96fe-12813bfff9fa; Mon, 23 Dec 2019 16:43:34 +0000 (UTC) X-Inumbo-ID: 5bbafdb4-25a3-11ea-96fe-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1577119414; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4LajtYjbMp6EySa6REpYUzL+FBkEHu6GtKsC0g+RZ1c=; b=VkLNS03auYBPUxa4z5ruzmcRWIi5To29A0hBDVoa4diQttgFcehaCh7d 86wFrN6/j0wYdnpXpSepG4qq3Wra4GTssSjirMxOtoDU7lW0AJ/S1WtVX E9STo4BjQXjokrAzUzgfisnlVYBvn2a+Ou4r18vuNpotEDsw6E25CcWmj k=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=george.dunlap@citrix.com; spf=Pass smtp.mailfrom=George.Dunlap@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of george.dunlap@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="george.dunlap@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of George.Dunlap@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="George.Dunlap@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: AxsFZfHdjC5LEZb4P+WEb/mOM+GeGKy4uTMsLWWzIUTaafKoQS8ilxHcMLF+7CpZtU+6BTPe61 /vSJFaMh/xJdpaYiutyWAijRme/t+fq3S0XaE9DUs77KvFflBusgA/oDxIKtmKlh8doBfmYR31 aDkTUbyAKgUpELHrwMsAAM3/wWhWQAencHg60V6NbgkK5llQudM/9kqE11NBIWwThXrHzZnsqV 9X3TjNGIHtHmM11DJZdPd23AgG5zSsSY32GBFUbQ4KFdKLfqi+aL7gVxCm7hQXbrl1M38icCwn 36A= X-SBRS: 2.7 X-MesageID: 10229661 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,348,1571716800"; d="scan'208";a="10229661" From: George Dunlap To: Date: Mon, 23 Dec 2019 16:43:27 +0000 Message-ID: <20191223164329.3113378-3-george.dunlap@citrix.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191223164329.3113378-1-george.dunlap@citrix.com> References: <20191223164329.3113378-1-george.dunlap@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 2/4] xen: Add 'synthetic' preemption check parameter X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , George Dunlap , Jan Beulich Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) In order to better test hypervisor preemption paths, add an option to artificially increase the number of preemptions. While modifying xen-command-line.pandoc, escape some underscores, and remove some trailing whitespace. Signed-off-by: George Dunlap --- CC: Andrew Cooper CC: Jan Beulich --- docs/misc/xen-command-line.pandoc | 20 ++++++++++++++++++-- xen/arch/x86/time.c | 11 +++++++++++ xen/include/xen/sched.h | 10 +++++++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line= .pandoc index 981a5e2381..1a9fda8627 100644 --- a/docs/misc/xen-command-line.pandoc +++ b/docs/misc/xen-command-line.pandoc @@ -636,13 +636,29 @@ Available alternatives, with their meaning, are: Specify the USB controller to use, either by instance number (when going over the PCI busses sequentially) or by PCI device (must be on segment 0). =20 -### debug_stack_lines +### debug\_stack\_lines > `=3D ` =20 > Default: `20` =20 Limits the number lines printed in Xen stack traces. =20 +### debug-synthetic-preemption +> `=3D ` + +> Default: `0` + +Artificially increases rate at which `hypercall_preempt_check()` +returns `true`, for debugging purposes, to a rate of one in `N`. (The +default, `0`, disables the feature.) + +When promoting pagetables, for instance, `hypercall_preempt_check()` +is called before processing each PTE. Since there are 512 PTEs per +page, a value of `1024` should result in pagetable promotion being +interrupted every other page on average. + +Only available in DEBUG builds. + ### debugtrace > `=3D [cpu:]` =20 @@ -1690,7 +1706,7 @@ The following resources are available: CDP, one COS will corespond two CBMs other than one with CAT, due to t= he sum of CBMs is fixed, that means actual `cos_max` in use will automati= cally reduce to half when CDP is enabled. -=09 + ### pv-linear-pt (x86) > `=3D ` =20 diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index 64e471a39b..34302f81e7 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -43,6 +43,17 @@ static char __initdata opt_clocksource[10]; string_param("clocksource", opt_clocksource); =20 +#ifndef NDEBUG +int debug_synthetic_preemption =3D 0; +integer_param("debug-synthetic-preemption", debug_synthetic_preemption); + +bool synthetic_preemption_check(void) { + if ( debug_synthetic_preemption =3D=3D 0 ) + return false; + return !(rdtsc() % debug_synthetic_preemption); +} +#endif + unsigned long __read_mostly cpu_khz; /* CPU clock frequency in kHz. */ DEFINE_SPINLOCK(rtc_lock); unsigned long pit0_ticks; diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 9f7bc69293..c0071eee04 100644 --- a/xen/include/xen/sched.h +++ b/xen/include/xen/sched.h @@ -748,6 +748,13 @@ static inline void hypercall_cancel_continuation(struc= t vcpu *v) v->hcall_preempted =3D false; } =20 +#ifndef NDEBUG +bool synthetic_preemption_check(void); +#define synthetic_preemption_check synthetic_preemption_check +#else +#define synthetic_preempiton_check() false +#endif + /* * For long-running operations that must be in hypercall context, check * if there is background work to be done that should interrupt this @@ -755,7 +762,8 @@ static inline void hypercall_cancel_continuation(struct= vcpu *v) */ #define hypercall_preempt_check() (unlikely( \ softirq_pending(smp_processor_id()) | \ - local_events_need_delivery() \ + local_events_need_delivery() | \ + synthetic_preemption_check() \ )) =20 /* --=20 2.24.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 30 02:09:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1577119474; cv=none; d=zohomail.com; s=zohoarc; b=XTU4uq+mSCV4zh87t2uOFX6tN9UUJv6RVkVxq5/v587iYW0EQ/TLF+6+SChUEIQ5rYFgDdpyLD2rycVK2cS7+pQC0mbf1t0ZULChoQIM3M0Yrru9EdHibrYEJ76gadK9CHS2oAs6F5P2yuH29JUkxO6qBXXEWpvcs4zdnAhkoCQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577119474; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=uvxIBt7xhOETBNjjNd3qbAIMg3JurLbg7GByXWbQ6S4=; b=m/rXibjS1ID4c4KMQWKAx3eCENTg3pZY6XljHcfJyjxMShl8OIAaZB4umeezLtTXy/ht+4/WnVFKnjk3CYTbJHjJKUPk5srRRAmKgz1dcRoGDiV/jRrnKfNV/WA8xScFx3o7gQMQezQS20alICmnJfuHxxJis+xUuhZ8sjEx0CU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 157711947448638.13102011806916; Mon, 23 Dec 2019 08:44:34 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijQo0-0006Ht-0p; Mon, 23 Dec 2019 16:43:40 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijQny-0006Hg-VI for xen-devel@lists.xenproject.org; Mon, 23 Dec 2019 16:43:38 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5ac53912-25a3-11ea-96fe-12813bfff9fa; Mon, 23 Dec 2019 16:43:34 +0000 (UTC) X-Inumbo-ID: 5ac53912-25a3-11ea-96fe-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1577119414; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=7vWp9GkW3ug+BLCdr2aqVvMT7j7OYz0ptK5b/xJThzk=; b=JzdaddEBp2gfFrj9Sge4mRu0EsTJrDoAZZ2dmN4nP2f6w37UlcPdrr+O ni1lqLtlxuD904m9cJKYjMR9N8V9o3qRGPsMgA5G8mogU+0jPKMCmodqK b/oVARpUqyKZQhEOSJM0gRl00fIBGfsaXemsLAOrqBDEjvJP2kpO/T8+S o=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=george.dunlap@citrix.com; spf=Pass smtp.mailfrom=George.Dunlap@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of george.dunlap@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="george.dunlap@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of George.Dunlap@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="George.Dunlap@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: 1ngXjC+DlOsqHUXA2V84RYcwdaRuaVODbDhbte0npTb8cVe9u0mcKyBEcYtcUlhXtBzHoQVgDJ ILjBaO49C6Mo2jJTfxcT/D3sGnR5Hoc9RpyakuSohggTk4mMTHaucVcSzroBp3HaM10lVR1gtJ w8AeWQAZ7+c1a/C54NIew76cRZ+u98qJZMblkF28sEhspZnxVCT2n1wOe5eyeoxck7IptGAfRJ FuBrgA5dUcmZ4LNavMm/YFvSqnTelgFKTS5jyZDLVRMxIUUNF0znCXGRO7djoDUOHs1Mei98sp LOo= X-SBRS: 2.7 X-MesageID: 10229660 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,348,1571716800"; d="scan'208";a="10229660" From: George Dunlap To: Date: Mon, 23 Dec 2019 16:43:28 +0000 Message-ID: <20191223164329.3113378-4-george.dunlap@citrix.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191223164329.3113378-1-george.dunlap@citrix.com> References: <20191223164329.3113378-1-george.dunlap@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 3/4] mm: Use put_old_guest_table for relinquish_pages X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , George Dunlap , Jan Beulich Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) relinquish_pages() deals with interrupted de-validation in a fairly ad-hoc way, by either re-setting PGT_pinned (in the case of EINTR) or letting the page "fall through" to the "force invalidate" loop below. This requires an extensive comment describing what needs to happen to the type and count in each case, and why each works. Additionally, it turns out that at this point, the "force invalidate" loop is only required to handle this ad-hoc continuation. Replace this with the 'standard' way of dealing with restarting pages, old_guest_table. Call put_old_guest_table(current) at the top of the function, and set current->arch.old_guest_table* as appropriate. This code is simpler, and mirrors other old_guest_table code in mm.c. It will also allow us to remove the force-invalidate loop entirely in a subsequent patch. While here, make the refcounting logic a bit easier to follow: We always drop the general reference held by PGT_pinned, regardless of what happens to the type count. Rather than manually re-dropping the refcount if put_page_and_type_preemptible() fails, just drop the refcount unconditionally, and call put_page_type_preemptible() instead. Signed-off-by: George Dunlap Reviewed-by: Jan Beulich --- CC: Andrew Cooper CC: Jan Beulich --- xen/arch/x86/domain.c | 50 +++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index d9c63379cd..b7968463cb 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1953,6 +1953,10 @@ static int relinquish_memory( unsigned long x, y; int ret =3D 0; =20 + ret =3D put_old_guest_table(current); + if ( ret ) + return ret; + /* Use a recursive lock, as we may enter 'free_domheap_page'. */ spin_lock_recursive(&d->page_alloc_lock); =20 @@ -1967,42 +1971,32 @@ static int relinquish_memory( } =20 if ( test_and_clear_bit(_PGT_pinned, &page->u.inuse.type_info) ) - ret =3D put_page_and_type_preemptible(page); + { + /* Always drop the page ref associated with PGT_pinned */ + put_page(page); + ret =3D put_page_type_preemptible(page); + } switch ( ret ) { case 0: break; - case -ERESTART: case -EINTR: - /* - * -EINTR means PGT_validated has been re-set; re-set - * PGT_pinned again so that it gets picked up next time - * around. - * - * -ERESTART, OTOH, means PGT_partial is set instead. Put - * it back on the list, but don't set PGT_pinned; the - * section below will finish off de-validation. But we do - * need to drop the general ref associated with - * PGT_pinned, since put_page_and_type_preemptible() - * didn't do it. - * - * NB we can do an ASSERT for PGT_validated, since we - * "own" the type ref; but theoretically, the PGT_partial - * could be cleared by someone else. - */ - if ( ret =3D=3D -EINTR ) - { - ASSERT(page->u.inuse.type_info & PGT_validated); - set_bit(_PGT_pinned, &page->u.inuse.type_info); - } - else - put_page(page); + ASSERT(page->u.inuse.type_info & PGT_validated); + /* Fallthrough */ + case -ERESTART: + current->arch.old_guest_ptpg =3D NULL; + current->arch.old_guest_table =3D page; + current->arch.old_guest_table_partial =3D (ret =3D=3D -ERESTAR= T); =20 ret =3D -ERESTART; =20 - /* Put the page back on the list and drop the ref we grabbed a= bove */ - page_list_add(page, list); - put_page(page); + /* Make sure we don't lose track of the page */ + page_list_add_tail(page, &d->arch.relmem_list); + + /* + * NB that we've transferred the general ref acquired at + * the top of the loop to old_guest_table. + */ goto out; default: BUG(); --=20 2.24.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel From nobody Tue Apr 30 02:09:50 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail(p=none dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1577119534; cv=none; d=zohomail.com; s=zohoarc; b=HJ2FpFzTmBCpOSdxQaAYHHssOVw1VTrMkZF6hYmnYf9ZDbxuF1B5GTnvePG2GjEQyQcc8KIFRiKuGQQFuHbsYK9kLgF7/rHV8mutM4q/Ks8c5kV6H/Jbk8GZcuXGCQahlwa1An3diVgXkLxVnCAb1U9I8JpgsK4BS+XeGeU+jaY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1577119534; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vNdv7hnZemXBAo/JpmX1sVKbxPtV50qtwA959jPcuI8=; b=RTDiJgxdC0sJXAn6J0CmJOXKq3f6a6G0XJTCLy0bKGSUSkWyQfBqLodAFArttt7qN3q6RsK/SuN0mMNoxTYZb5wiJhuXEE0OszXnKXwNpdtUo8ZSC81HempE6P+lWSjb4NZW7hMXmB+Z8533VLT7EwGwij5OyHZcfr1a0TO7aA4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1577119534223974.0667311211888; Mon, 23 Dec 2019 08:45:34 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijQoF-0006Mf-3t; Mon, 23 Dec 2019 16:43:55 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ijQoE-0006MM-1b for xen-devel@lists.xenproject.org; Mon, 23 Dec 2019 16:43:54 +0000 Received: from esa1.hc3370-68.iphmx.com (unknown [216.71.145.142]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id 5bbafdb5-25a3-11ea-96fe-12813bfff9fa; Mon, 23 Dec 2019 16:43:34 +0000 (UTC) X-Inumbo-ID: 5bbafdb5-25a3-11ea-96fe-12813bfff9fa DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1577119415; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=AZQ3x3k2kqbsUYZ1QjMtwFE51Vo18atykQNPnlW1pg4=; b=e0cjfsJQi2erxh0m7YcP3+XtwiokzdQl6bah5eOHg+NaFGEpV6yDzwSv ZiQBiqjwi+Ha89Fm6OMP1QvDLJeWTIIGdAP2MmaxdsPe/M5J8zYql0R17 lIcpKFq1ejONpG1R1CcS6wM14PRzjeUI7fnHdgtBM8XGxGPvXvsi7cl3x g=; Authentication-Results: esa1.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none; spf=None smtp.pra=george.dunlap@citrix.com; spf=Pass smtp.mailfrom=George.Dunlap@citrix.com; spf=None smtp.helo=postmaster@mail.citrix.com Received-SPF: none (zohomail.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of george.dunlap@citrix.com) identity=pra; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="george.dunlap@citrix.com"; x-conformance=sidf_compatible Received-SPF: Pass (esa1.hc3370-68.iphmx.com: domain of George.Dunlap@citrix.com designates 162.221.158.21 as permitted sender) identity=mailfrom; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="George.Dunlap@citrix.com"; x-conformance=sidf_compatible; x-record-type="v=spf1"; x-record-text="v=spf1 ip4:209.167.231.154 ip4:178.63.86.133 ip4:195.66.111.40/30 ip4:85.115.9.32/28 ip4:199.102.83.4 ip4:192.28.146.160 ip4:192.28.146.107 ip4:216.52.6.88 ip4:216.52.6.188 ip4:162.221.158.21 ip4:162.221.156.83 ip4:168.245.78.127 ~all" Received-SPF: None (esa1.hc3370-68.iphmx.com: no sender authenticity information available from domain of postmaster@mail.citrix.com) identity=helo; client-ip=162.221.158.21; receiver=esa1.hc3370-68.iphmx.com; envelope-from="George.Dunlap@citrix.com"; x-sender="postmaster@mail.citrix.com"; x-conformance=sidf_compatible IronPort-SDR: rDAD6UMyiKDpv9n+segRvegA9NQBvFAA75lfhPztGHXaYzHGQRxmmPL4VR/PRBHyIxNn5GkHJB Ghipv7stAMoJa3nCkW78oOLQJBV6Yr1YmbHyFezg6McZpTLATf1wvq6G/Ec4YCSgD2MrzeQ1SL V9ggY8UUkOpaQJuUF+C7D+lLbUbwWfUMJ4DAhCLW/SuOaSfNeqWVBTiPeyRDW98suB8Wa43kqn VFFBJPoevBvMv1aGy5541xG0zwyeGoD8P6bpjUcwuOhZ4jq0EJQCnvDDFyQIk9qimCWSCAnibU HJA= X-SBRS: 2.7 X-MesageID: 10229663 X-Ironport-Server: esa1.hc3370-68.iphmx.com X-Remote-IP: 162.221.158.21 X-Policy: $RELAYED X-IronPort-AV: E=Sophos;i="5.69,348,1571716800"; d="scan'208";a="10229663" From: George Dunlap To: Date: Mon, 23 Dec 2019 16:43:29 +0000 Message-ID: <20191223164329.3113378-5-george.dunlap@citrix.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191223164329.3113378-1-george.dunlap@citrix.com> References: <20191223164329.3113378-1-george.dunlap@citrix.com> MIME-Version: 1.0 Subject: [Xen-devel] [PATCH 4/4] x86/mm: Remove force-invalidate loop X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , George Dunlap , Jan Beulich Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) The comment about the "force-invalidate" loop gives two reasons for its existence: 1. Breaking circular "linear pagetable" references 2. Cleaning up partially-validated pages. The first reason been invalid since XSA-240: Since then it hasn't been possible to generate circular linear pagetable references. The second reason has been invalid since long before that: Before calling relinquish_memory(), domain_relinquish_resources() calls vcpu_destroy_pagetables() on each vcpu; this will in turn call put_old_guest_table() on each vcpu. The result should be that it's not possible to have top-level partially-devalidated pagetables by the time we get to relinquish_memory(). The loop, it turns out, was effectively there only to pick up interrupted UNPIN operations of relinquish_memory() itself. Now that these are being handled by put_old_guest_table(), we can remove this loop entirely. Signed-off-by: George Dunlap --- This patch has the advantage that it doesn't hide mis-accounted partial pages anymore; but has the disadvantage that if there *is* such a mis-accounting, it will become a resource leak (and thus an XSA). It might be a good idea to add another "clean up partial pages" pass after all other pages have been cleaned up, with a suitable ASSERT(). That way we have a higher chance of catching mis-accounting during development, without risking opening up a memory / domain leak in production. CC: Andrew Cooper CC: Jan Beulich --- xen/arch/x86/domain.c | 71 ------------------------------------------- 1 file changed, 71 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index b7968463cb..847a70302c 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -1950,7 +1950,6 @@ static int relinquish_memory( struct domain *d, struct page_list_head *list, unsigned long type) { struct page_info *page; - unsigned long x, y; int ret =3D 0; =20 ret =3D put_old_guest_table(current); @@ -2004,76 +2003,6 @@ static int relinquish_memory( =20 put_page_alloc_ref(page); =20 - /* - * Forcibly invalidate top-most, still valid page tables at this p= oint - * to break circular 'linear page table' references as well as cle= an up - * partially validated pages. This is okay because MMU structures = are - * not shared across domains and this domain is now dead. Thus top= -most - * valid tables are not in use so a non-zero count means circular - * reference or partially validated. - */ - y =3D page->u.inuse.type_info; - for ( ; ; ) - { - x =3D y; - if ( likely((x & PGT_type_mask) !=3D type) || - likely(!(x & (PGT_validated|PGT_partial))) ) - break; - - y =3D cmpxchg(&page->u.inuse.type_info, x, - x & ~(PGT_validated|PGT_partial)); - if ( likely(y =3D=3D x) ) - { - /* No need for atomic update of type_info here: noone else= updates it. */ - switch ( ret =3D devalidate_page(page, x, 1) ) - { - case 0: - break; - case -EINTR: - page_list_add(page, list); - page->u.inuse.type_info |=3D PGT_validated; - if ( x & PGT_partial ) - put_page(page); - put_page(page); - ret =3D -ERESTART; - goto out; - case -ERESTART: - page_list_add(page, list); - /* - * PGT_partial holds a type ref and a general ref. - * If we came in with PGT_partial set, then we 1) - * don't need to grab an extra type count, and 2) - * do need to drop the extra page ref we grabbed - * at the top of the loop. If we didn't come in - * with PGT_partial set, we 1) do need to drab an - * extra type count, but 2) can transfer the page - * ref we grabbed above to it. - * - * Note that we must increment type_info before - * setting PGT_partial. Theoretically it should - * be safe to drop the page ref before setting - * PGT_partial, but do it afterwards just to be - * extra safe. - */ - if ( !(x & PGT_partial) ) - page->u.inuse.type_info++; - smp_wmb(); - page->u.inuse.type_info |=3D PGT_partial; - if ( x & PGT_partial ) - put_page(page); - goto out; - default: - BUG(); - } - if ( x & PGT_partial ) - { - page->u.inuse.type_info--; - put_page(page); - } - break; - } - } - /* Put the page on the list and /then/ potentially free it. */ page_list_add_tail(page, &d->arch.relmem_list); put_page(page); --=20 2.24.0 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel