From xen-changelog-bounces@lists.xenproject.org Thu Feb 01 03:33:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 01 Feb 2024 03:33:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.674213.1049007 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVNp1-0004q8-EL; Thu, 01 Feb 2024 03:33:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 674213.1049007; Thu, 01 Feb 2024 03:33:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVNp1-0004q0-BP; Thu, 01 Feb 2024 03:33:03 +0000
Received: by outflank-mailman (input) for mailman id 674213;
 Thu, 01 Feb 2024 03:33:01 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVNoz-0004ps-JA
 for xen-changelog@lists.xenproject.org; Thu, 01 Feb 2024 03:33:01 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVNoz-0005fp-HD
 for xen-changelog@lists.xenproject.org; Thu, 01 Feb 2024 03:33:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVNoz-0001XW-G6
 for xen-changelog@lists.xenproject.org; Thu, 01 Feb 2024 03:33:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=88ViMEY5wZU1JZM4XUhcWfFspPEkt8xyV0+gi0JweaQ=; b=rgB2Tpx7pVeXknIAv5wyCs7k33
	vg0hivacX2jniw1fJIfyEvUAirXh+xb+wOt1XwowsRN35OZcBjSqnvjLiH6R3RpA1XlquluSaqHf/
	/MhZhPwY1RoWYQIXKXL7S5ufK7KIRh4XrViN75LNVjn32Zi8UlwAXS4+0sfKcMWz6Ots=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] pci: fail device assignment if phantom functions cannot be assigned
Message-Id: <E1rVNoz-0001XW-G6@xenbits.xenproject.org>
Date: Thu, 01 Feb 2024 03:33:01 +0000

commit cb4ecb3cc17b02c2814bc817efd05f3f3ba33d1e
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Jan 30 14:28:01 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Jan 30 14:28:01 2024 +0100

    pci: fail device assignment if phantom functions cannot be assigned
    
    The current behavior is that no error is reported if (some) phantom functions
    fail to be assigned during device add or assignment, so the operation succeeds
    even if some phantom functions are not correctly setup.
    
    This can lead to devices possibly being successfully assigned to a domU while
    some of the device phantom functions are still assigned to dom0.  Even when the
    device is assigned domIO before being assigned to a domU phantom functions
    might fail to be assigned to domIO, and also fail to be assigned to the domU,
    leaving them assigned to dom0.
    
    Since the device can generate requests using the IDs of those phantom
    functions, given the scenario above a device in such state would be in control
    of a domU, but still capable of generating transactions that use a context ID
    targeting dom0 owned memory.
    
    Modify device assign in order to attempt to deassign the device if phantom
    functions failed to be assigned.
    
    Note that device addition is not modified in the same way, as in that case the
    device is assigned to a trusted domain, and hence partial assign can lead to
    device malfunction but not a security issue.
    
    This is XSA-449 / CVE-2023-46839
    
    Fixes: 4e9950dc1bd2 ('IOMMU: add phantom function support')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/drivers/passthrough/pci.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 1439d1ef2b..47c0eee7bd 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -1488,11 +1488,10 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)
 
     pdev->fault.count = 0;
 
-    if ( (rc = iommu_call(hd->platform_ops, assign_device, d, devfn,
-                          pci_to_dev(pdev), flag)) )
-        goto done;
+    rc = iommu_call(hd->platform_ops, assign_device, d, devfn, pci_to_dev(pdev),
+                    flag);
 
-    for ( ; pdev->phantom_stride; rc = 0 )
+    while ( pdev->phantom_stride && !rc )
     {
         devfn += pdev->phantom_stride;
         if ( PCI_SLOT(devfn) != PCI_SLOT(pdev->devfn) )
@@ -1503,8 +1502,24 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)
 
  done:
     if ( rc )
-        printk(XENLOG_G_WARNING "%pd: assign (%pp) failed (%d)\n",
-               d, &PCI_SBDF(seg, bus, devfn), rc);
+    {
+        printk(XENLOG_G_WARNING "%pd: assign %s(%pp) failed (%d)\n",
+               d, devfn != pdev->devfn ? "phantom function " : "",
+               &PCI_SBDF(seg, bus, devfn), rc);
+
+        if ( devfn != pdev->devfn && deassign_device(d, seg, bus, pdev->devfn) )
+        {
+            /*
+             * Device with phantom functions that failed to both assign and
+             * rollback.  Mark the device as broken and crash the target domain,
+             * as the state of the functions at this point is unknown and Xen
+             * has no way to assert consistent context assignment among them.
+             */
+            pdev->broken = true;
+            if ( !is_hardware_domain(d) && d != dom_io )
+                domain_crash(d);
+        }
+    }
     /* The device is assigned to dom_io so mark it as quarantined */
     else if ( d == dom_io )
         pdev->quarantine = true;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 01 03:33:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 01 Feb 2024 03:33:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.674214.1049011 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVNpB-0004s5-FN; Thu, 01 Feb 2024 03:33:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 674214.1049011; Thu, 01 Feb 2024 03:33:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVNpB-0004ry-Ct; Thu, 01 Feb 2024 03:33:13 +0000
Received: by outflank-mailman (input) for mailman id 674214;
 Thu, 01 Feb 2024 03:33:11 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVNp9-0004ro-N6
 for xen-changelog@lists.xenproject.org; Thu, 01 Feb 2024 03:33:11 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVNp9-0005gC-MH
 for xen-changelog@lists.xenproject.org; Thu, 01 Feb 2024 03:33:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVNp9-0001Xv-JY
 for xen-changelog@lists.xenproject.org; Thu, 01 Feb 2024 03:33:11 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=pGx9MZ4x4PkJZzvR88vAKG/8A4QTGvqZY9Xpjymtqsw=; b=Fes8DPQ+X+o28dpjQkCoUYrGnb
	TEORqTrlxDZLVRxUXqR128vUf7kK7O9GFLTEfNX9qbuOUwl0cTA29S0Sk1X06rjbE9uY9ZVkN6vjT
	kDtEMyEYjcTS5uYKXiuFbQrR1xVIBPbhKqXpMQ4tC8qynVR6CzuqmBvYWiOSQyOQweoo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] VT-d: Fix "else" vs "#endif" misplacement
Message-Id: <E1rVNp9-0001Xv-JY@xenbits.xenproject.org>
Date: Thu, 01 Feb 2024 03:33:11 +0000

commit cc6ba68edf6dcd18c3865e7d7c0f1ed822796426
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Jan 30 14:29:15 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Jan 30 14:29:15 2024 +0100

    VT-d: Fix "else" vs "#endif" misplacement
    
    In domain_pgd_maddr() the "#endif" is misplaced with respect to "else".  This
    generates incorrect logic when CONFIG_HVM is compiled out, as the "else" body
    is executed unconditionally.
    
    Rework the logic to use IS_ENABLED() instead of explicit #ifdef-ary, as it's
    clearer to follow.  This in turn involves adjusting p2m_get_pagetable() to
    compile when CONFIG_HVM is disabled.
    
    This is XSA-450 / CVE-2023-46840.
    
    Fixes: 033ff90aa9c1 ("x86/P2M: p2m_{alloc,free}_ptp() and p2m_alloc_table() are HVM-only")
    Reported-by: Teddy Astie <teddy.astie@vates.tech>
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/include/asm/p2m.h      | 9 ++++++++-
 xen/drivers/passthrough/vtd/iommu.c | 4 +---
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h
index 32f3f394b0..6ada585eaa 100644
--- a/xen/arch/x86/include/asm/p2m.h
+++ b/xen/arch/x86/include/asm/p2m.h
@@ -435,7 +435,14 @@ static inline bool p2m_is_altp2m(const struct p2m_domain *p2m)
     return p2m->p2m_class == p2m_alternate;
 }
 
-#define p2m_get_pagetable(p2m)  ((p2m)->phys_table)
+#ifdef CONFIG_HVM
+static inline pagetable_t p2m_get_pagetable(const struct p2m_domain *p2m)
+{
+    return p2m->phys_table;
+}
+#else
+pagetable_t p2m_get_pagetable(const struct p2m_domain *p2m);
+#endif
 
 /*
  * Ensure any deferred p2m TLB flush has been completed on all VCPUs.
diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index 99b642f12e..4244855032 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -438,15 +438,13 @@ static paddr_t domain_pgd_maddr(struct domain *d, paddr_t pgd_maddr,
 
     if ( pgd_maddr )
         /* nothing */;
-#ifdef CONFIG_HVM
-    else if ( iommu_use_hap_pt(d) )
+    else if ( IS_ENABLED(CONFIG_HVM) && iommu_use_hap_pt(d) )
     {
         pagetable_t pgt = p2m_get_pagetable(p2m_get_hostp2m(d));
 
         pgd_maddr = pagetable_get_paddr(pgt);
     }
     else
-#endif
     {
         if ( !hd->arch.vtd.pgd_maddr )
         {
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 02 09:22:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 02 Feb 2024 09:22:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.674897.1050053 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVpkI-0003kW-Ve; Fri, 02 Feb 2024 09:22:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 674897.1050053; Fri, 02 Feb 2024 09:22:02 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVpkI-0003kP-TC; Fri, 02 Feb 2024 09:22:02 +0000
Received: by outflank-mailman (input) for mailman id 674897;
 Fri, 02 Feb 2024 09:22:01 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpkH-0003kJ-JI
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:01 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpkH-0004el-IP
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpkH-0007CV-HR
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=/O8DrlwY8UrmToLBV1e+NaLscmhZ2JDVXXf6LMIuF28=; b=kZEsPB5w7ubC7dr53OeWUMXJYb
	/DhrP4YbnemQ4OXSmcgO9qa7QzbTERo+3TzFUnSO3vQGBQfS0ev8NIIjIp8azTCj1xZDmSwMA6kY5
	Wze2QNVa7hSZOzCx/PlmSSiEa/LIAElaidvzza4pl9fdUR/GSqBmHkix1VXHxgG2Zbms=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] x86/amd: Extend CPU erratum #1474 fix to more affected models
Message-Id: <E1rVpkH-0007CV-HR@xenbits.xenproject.org>
Date: Fri, 02 Feb 2024 09:22:01 +0000

commit 62b3d7f8e45a7ec1597f0ed61a99d1f423b22315
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Thu Feb 1 17:58:17 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 1 17:58:17 2024 +0100

    x86/amd: Extend CPU erratum #1474 fix to more affected models
    
    Erratum #1474 has now been extended to cover models from family 17h ranges
    00-2Fh, so the errata now covers all the models released under Family
    17h (Zen, Zen+ and Zen2).
    
    Additionally extend the workaround to Family 18h (Hygon), since it's based on
    the Zen architecture and very likely affected.
    
    Rename all the zen2 related symbols to fam17, since the errata doesn't
    exclusively affect Zen2 anymore.
    
    Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: 23db507a01a4ec5259ec0ab43d296a41b1c326ba
    master date: 2023-12-21 12:19:40 +0000
---
 xen/arch/x86/cpu/amd.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index 0f305312ff..d43288ae97 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -54,7 +54,7 @@ bool __read_mostly amd_acpi_c1e_quirk;
 bool __ro_after_init amd_legacy_ssbd;
 bool __initdata amd_virt_spec_ctrl;
 
-static bool __read_mostly zen2_c6_disabled;
+static bool __read_mostly fam17_c6_disabled;
 
 static inline int rdmsr_amd_safe(unsigned int msr, unsigned int *lo,
 				 unsigned int *hi)
@@ -978,24 +978,24 @@ void amd_check_zenbleed(void)
 		       val & chickenbit ? "chickenbit" : "microcode");
 }
 
-static void cf_check zen2_disable_c6(void *arg)
+static void cf_check fam17_disable_c6(void *arg)
 {
 	/* Disable C6 by clearing the CCR{0,1,2}_CC6EN bits. */
 	const uint64_t mask = ~((1ul << 6) | (1ul << 14) | (1ul << 22));
 	uint64_t val;
 
-	if (!zen2_c6_disabled) {
+	if (!fam17_c6_disabled) {
 		printk(XENLOG_WARNING
     "Disabling C6 after 1000 days apparent uptime due to AMD errata 1474\n");
-		zen2_c6_disabled = true;
+		fam17_c6_disabled = true;
 		/*
 		 * Prevent CPU hotplug so that started CPUs will either see
-		 * zen2_c6_disabled set, or will be handled by
+		 * zen_c6_disabled set, or will be handled by
 		 * smp_call_function().
 		 */
 		while (!get_cpu_maps())
 			process_pending_softirqs();
-		smp_call_function(zen2_disable_c6, NULL, 0);
+		smp_call_function(fam17_disable_c6, NULL, 0);
 		put_cpu_maps();
 	}
 
@@ -1294,8 +1294,8 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)
 	amd_check_zenbleed();
 	amd_check_erratum_1485();
 
-	if (zen2_c6_disabled)
-		zen2_disable_c6(NULL);
+	if (fam17_c6_disabled)
+		fam17_disable_c6(NULL);
 
 	check_syscfg_dram_mod_en();
 
@@ -1307,7 +1307,7 @@ const struct cpu_dev amd_cpu_dev = {
 	.c_init		= init_amd,
 };
 
-static int __init cf_check zen2_c6_errata_check(void)
+static int __init cf_check amd_check_erratum_1474(void)
 {
 	/*
 	 * Errata #1474: A Core May Hang After About 1044 Days
@@ -1315,7 +1315,8 @@ static int __init cf_check zen2_c6_errata_check(void)
 	 */
 	s_time_t delta;
 
-	if (cpu_has_hypervisor || boot_cpu_data.x86 != 0x17 || !is_zen2_uarch())
+	if (cpu_has_hypervisor ||
+	    (boot_cpu_data.x86 != 0x17 && boot_cpu_data.x86 != 0x18))
 		return 0;
 
 	/*
@@ -1330,10 +1331,10 @@ static int __init cf_check zen2_c6_errata_check(void)
 	if (delta > 0) {
 		static struct timer errata_c6;
 
-		init_timer(&errata_c6, zen2_disable_c6, NULL, 0);
+		init_timer(&errata_c6, fam17_disable_c6, NULL, 0);
 		set_timer(&errata_c6, NOW() + delta);
 	} else
-		zen2_disable_c6(NULL);
+		fam17_disable_c6(NULL);
 
 	return 0;
 }
@@ -1341,4 +1342,4 @@ static int __init cf_check zen2_c6_errata_check(void)
  * Must be executed after early_time_init() for tsc_ticks2ns() to have been
  * calibrated.  That prevents us doing the check in init_amd().
  */
-presmp_initcall(zen2_c6_errata_check);
+presmp_initcall(amd_check_erratum_1474);
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Fri Feb 02 09:22:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 02 Feb 2024 09:22:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.674898.1050058 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVpkT-0003mm-0u; Fri, 02 Feb 2024 09:22:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 674898.1050058; Fri, 02 Feb 2024 09:22:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVpkS-0003me-Uf; Fri, 02 Feb 2024 09:22:12 +0000
Received: by outflank-mailman (input) for mailman id 674898;
 Fri, 02 Feb 2024 09:22:11 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpkR-0003mU-PD
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:11 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpkR-0004er-NQ
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpkR-0007DP-Kc
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:11 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=yo0k9htEiPILV9g0ZPii7r+F4bSjrp/HqX2wsugp2sM=; b=Vo1VAhgdl77vLZxIWLSU8SsuOG
	dEd4e/pcQJPwzE0nRDJ4nxLCE5+ThI3Xq/IQdMlfmcmcnEIDNgp+aZghA4w9tJOb4SxN7iphcjLau
	vVpw3nse3sx8Q0YiwDJ+pORdxCIJJQcqszMQO22f4a5Xdlbr8+7mzTcI3fUpg108EMD0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] CirrusCI: drop FreeBSD 12
Message-Id: <E1rVpkR-0007DP-Kc@xenbits.xenproject.org>
Date: Fri, 02 Feb 2024 09:22:11 +0000

commit b26c30a408255454f8ceb4e49e3c4385aa32fbc3
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Thu Feb 1 17:58:59 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 1 17:58:59 2024 +0100

    CirrusCI: drop FreeBSD 12
    
    Went EOL by the end of December 2023, and the pkg repos have been shut down.
    
    Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: c2ce3466472e9c9eda79f5dc98eb701bc6fdba20
    master date: 2024-01-15 12:20:11 +0100
---
 .cirrus.yml | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index 7e0beb200d..63f3afb104 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -14,12 +14,6 @@ freebsd_template: &FREEBSD_TEMPLATE
     - ./configure --with-system-seabios=/usr/local/share/seabios/bios.bin
     - gmake -j`sysctl -n hw.ncpu` clang=y
 
-task:
-  name: 'FreeBSD 12'
-  freebsd_instance:
-    image_family: freebsd-12-4
-  << : *FREEBSD_TEMPLATE
-
 task:
   name: 'FreeBSD 13'
   freebsd_instance:
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Fri Feb 02 09:22:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 02 Feb 2024 09:22:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.674899.1050061 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVpkd-0003pQ-2N; Fri, 02 Feb 2024 09:22:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 674899.1050061; Fri, 02 Feb 2024 09:22:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVpkc-0003pJ-W6; Fri, 02 Feb 2024 09:22:22 +0000
Received: by outflank-mailman (input) for mailman id 674899;
 Fri, 02 Feb 2024 09:22:21 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpkb-0003p9-RC
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:21 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpkb-0004f5-QS
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:21 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpkb-0007Dx-PW
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:21 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=yacq7mErTv2QJfnxkEdstP4c58PeTPYRwhSUSd/gDDQ=; b=QsZ30qEkSrqUusRloJv3/8v55D
	1vIE0ZbsHITuKxyY6jT2ly43YrGuQlxBCsVN4sK4gEu3gq+iATDUlzBQ7JzTg94loiv9rDY1gWFI8
	B9fsl+mJLsw3bM2GDldeaWQQn0epNXJa9zQKEeG28r0OYGVm6+yVjsqvWSflue/O7QT0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] x86/intel: ensure Global Performance Counter Control is setup correctly
Message-Id: <E1rVpkb-0007Dx-PW@xenbits.xenproject.org>
Date: Fri, 02 Feb 2024 09:22:21 +0000

commit 6ccf064b0ce1d06449565129ab944b4fd9531b3a
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Thu Feb 1 17:59:25 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 1 17:59:25 2024 +0100

    x86/intel: ensure Global Performance Counter Control is setup correctly
    
    When Architectural Performance Monitoring is available, the PERF_GLOBAL_CTRL
    MSR contains per-counter enable bits that is ANDed with the enable bit in the
    counter EVNTSEL MSR in order for a PMC counter to be enabled.
    
    So far the watchdog code seems to have relied on the PERF_GLOBAL_CTRL enable
    bits being set by default, but at least on some Intel Sapphire and Emerald
    Rapids this is no longer the case, and Xen reports:
    
    Testing NMI watchdog on all CPUs: 0 40 stuck
    
    The first CPU on each package is started with PERF_GLOBAL_CTRL zeroed, so PMC0
    doesn't start counting when the enable bit in EVNTSEL0 is set, due to the
    relevant enable bit in PERF_GLOBAL_CTRL not being set.
    
    Check and adjust PERF_GLOBAL_CTRL during CPU initialization so that all the
    general-purpose PMCs are enabled.  Doing so brings the state of the package-BSP
    PERF_GLOBAL_CTRL in line with the rest of the CPUs on the system.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    master commit: 6bdb965178bbb3fc50cd4418d4770a7789956e2c
    master date: 2024-01-17 10:40:52 +0100
---
 xen/arch/x86/cpu/intel.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/cpu/intel.c b/xen/arch/x86/cpu/intel.c
index a8ba3191e6..aef8e4506c 100644
--- a/xen/arch/x86/cpu/intel.c
+++ b/xen/arch/x86/cpu/intel.c
@@ -533,9 +533,30 @@ static void cf_check init_intel(struct cpuinfo_x86 *c)
 	init_intel_cacheinfo(c);
 	if (c->cpuid_level > 9) {
 		unsigned eax = cpuid_eax(10);
+		unsigned int cnt = (eax >> 8) & 0xff;
+
 		/* Check for version and the number of counters */
-		if ((eax & 0xff) && (((eax>>8) & 0xff) > 1))
+		if ((eax & 0xff) && (cnt > 1) && (cnt <= 32)) {
+			uint64_t global_ctrl;
+			unsigned int cnt_mask = (1UL << cnt) - 1;
+
+			/*
+			 * On (some?) Sapphire/Emerald Rapids platforms each
+			 * package-BSP starts with all the enable bits for the
+			 * general-purpose PMCs cleared.  Adjust so counters
+			 * can be enabled from EVNTSEL.
+			 */
+			rdmsrl(MSR_CORE_PERF_GLOBAL_CTRL, global_ctrl);
+			if ((global_ctrl & cnt_mask) != cnt_mask) {
+				printk("CPU%u: invalid PERF_GLOBAL_CTRL: %#"
+				       PRIx64 " adjusting to %#" PRIx64 "\n",
+				       smp_processor_id(), global_ctrl,
+				       global_ctrl | cnt_mask);
+				wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL,
+				       global_ctrl | cnt_mask);
+			}
 			__set_bit(X86_FEATURE_ARCH_PERFMON, c->x86_capability);
+		}
 	}
 
 	if ( !cpu_has(c, X86_FEATURE_XTOPOLOGY) )
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Fri Feb 02 09:22:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 02 Feb 2024 09:22:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.674900.1050066 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVpkn-0003sB-3u; Fri, 02 Feb 2024 09:22:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 674900.1050066; Fri, 02 Feb 2024 09:22:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVpkn-0003s3-1J; Fri, 02 Feb 2024 09:22:33 +0000
Received: by outflank-mailman (input) for mailman id 674900;
 Fri, 02 Feb 2024 09:22:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpkm-0003rt-1t
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpkl-0004fG-TZ
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:31 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpkl-0007EQ-So
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:31 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=cA7Zj+rvUYHVydKR0OJQQMff5qG/tunff3D1Hx6gUQQ=; b=4qfISGQ8KnXRVsNN44cuNCfVa5
	3GG1iZy0vs5AP1H9r3skhHm9ceBTo9JMVTqbPJYL09g6tDQRdJHS96eHT3vVxS5DZUMvHk1lzqVOu
	VpRjdUIeuQ4lia+0Uie0AIOM3s5HvRlYXA1yFtnn3Y6GXPgSVO/OLYDraZ7P/TzCQY90=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] x86/vmx: Fix IRQ handling for EXIT_REASON_INIT
Message-Id: <E1rVpkl-0007EQ-So@xenbits.xenproject.org>
Date: Fri, 02 Feb 2024 09:22:31 +0000

commit 4cc0f88c42f374c7a8e2d05e38777fa18619482e
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Thu Feb 1 17:59:57 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 1 17:59:57 2024 +0100

    x86/vmx: Fix IRQ handling for EXIT_REASON_INIT
    
    When receiving an INIT, a prior bugfix tried to ignore the INIT and continue
    onwards.
    
    Unfortunately it's not safe to return at that point in vmx_vmexit_handler().
    Just out of context in the first hunk is a local_irqs_enabled() which is
    depended-upon by the return-to-guest path, causing the following checklock
    failure in debug builds:
    
      (XEN) Error: INIT received - ignoring
      (XEN) CHECKLOCK FAILURE: prev irqsafe: 0, curr irqsafe 1
      (XEN) Xen BUG at common/spinlock.c:132
      (XEN) ----[ Xen-4.19-unstable  x86_64  debug=y  Tainted:     H  ]----
      ...
      (XEN) Xen call trace:
      (XEN)    [<ffff82d040238e10>] R check_lock+0xcd/0xe1
      (XEN)    [<ffff82d040238fe3>] F _spin_lock+0x1b/0x60
      (XEN)    [<ffff82d0402ed6a8>] F pt_update_irq+0x32/0x3bb
      (XEN)    [<ffff82d0402b9632>] F vmx_intr_assist+0x3b/0x51d
      (XEN)    [<ffff82d040206447>] F vmx_asm_vmexit_handler+0xf7/0x210
    
    Luckily, this is benign in release builds.  Accidentally having IRQs disabled
    when trying to take an IRQs-on lock isn't a deadlock-vulnerable pattern.
    
    Drop the problematic early return.  In hindsight, it's wrong to skip other
    normal VMExit steps.
    
    Fixes: b1f11273d5a7 ("x86/vmx: Don't spuriously crash the domain when INIT is received")
    Reported-by: Reima ISHII <ishiir@g.ecc.u-tokyo.ac.jp>
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: d1f8883aebe00f6a9632d77ab0cd5c6d02c9cbe4
    master date: 2024-01-18 20:59:06 +0000
---
 xen/arch/x86/hvm/vmx/vmx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 1edc7f1e91..964891934b 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -4100,7 +4100,7 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
 
     case EXIT_REASON_INIT:
         printk(XENLOG_ERR "Error: INIT received - ignoring\n");
-        return; /* Renter the guest without further processing */
+        break;
     }
 
     /* Now enable interrupts so it's safe to take locks. */
@@ -4385,6 +4385,7 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
         break;
     }
     case EXIT_REASON_EXTERNAL_INTERRUPT:
+    case EXIT_REASON_INIT:
         /* Already handled above. */
         break;
     case EXIT_REASON_TRIPLE_FAULT:
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Fri Feb 02 09:22:43 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 02 Feb 2024 09:22:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.674901.1050070 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVpkx-0003ut-5k; Fri, 02 Feb 2024 09:22:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 674901.1050070; Fri, 02 Feb 2024 09:22:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVpkx-0003ul-2n; Fri, 02 Feb 2024 09:22:43 +0000
Received: by outflank-mailman (input) for mailman id 674901;
 Fri, 02 Feb 2024 09:22:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpkw-0003uS-1R
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpkw-0004fN-0e
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpkv-0007Et-Vy
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:41 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=RG9Dl26s3Z3kcbOsPB/ApS4xurnKeGqJEZUBkkQCeME=; b=Mzr3JLjjSehrN4Rnk3IQxKmTzA
	V6s9SPwsHnClyHvcWYfHGg4l4F82XYlYhQhCNe0z9yZjkCVXdClR8ZEOQmUUumiReP3LNQAzV/874
	s/09x+gIcKDO4+eiCipZ14+EurAJ/vJlc28SYzDXnP43tsMxnd2UlYShhHuvCehNe40s=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] x86/vmx: Disallow the use of inactivity states
Message-Id: <E1rVpkv-0007Et-Vy@xenbits.xenproject.org>
Date: Fri, 02 Feb 2024 09:22:41 +0000

commit 00550e808c10c67710ebb8867200eda1fbee332c
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Thu Feb 1 18:00:32 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 1 18:00:32 2024 +0100

    x86/vmx: Disallow the use of inactivity states
    
    Right now, vvmx will blindly copy L12's ACTIVITY_STATE into the L02 VMCS and
    enter the vCPU.  Luckily for us, nested-virt is explicitly unsupported for
    security bugs.
    
    The inactivity states are HLT, SHUTDOWN and WAIT-FOR-SIPI, and as noted by the
    SDM in Vol3 27.7 "Special Features of VM Entry":
    
      If VM entry ends with the logical processor in an inactive activity state,
      the VM entry generates any special bus cycle that is normally generated when
      that activity state is entered from the active state.
    
    Also,
    
      Some activity states unconditionally block certain events.
    
    I.e. A VMEntry with ACTIVITY=SHUTDOWN will initiate a platform reset, while a
    VMEntry with ACTIVITY=WAIT-FOR-SIPI will really block everything other than
    SIPIs.
    
    Both of these activity states are for the TXT ACM to use, not for regular
    hypervisors, and Xen doesn't support dropping the HLT intercept either.
    
    There are two paths in Xen which operate on ACTIVITY_STATE.
    
    1) The vmx_{get,set}_nonreg_state() helpers for VM-Fork.
    
       As regular VMs can't use any inactivity states, this is just duplicating
       the 0 from construct_vmcs().  Retain the ability to query activity_state,
       but crash the domain on any attempt to set an inactivity state.
    
    2) Nested virt, because of ACTIVITY_STATE in vmcs_gstate_field[].
    
       Explicitly hide the inactivity states in the guest's view of MSR_VMX_MISC,
       and remove ACTIVITY_STATE from vmcs_gstate_field[].
    
       In virtual_vmentry(), we should trigger a VMEntry failure for the use of
       any inactivity states, but there's no support for that in the code at all
       so leave a TODO for when we finally start working on nested-virt in
       earnest.
    
    Reported-by: Reima Ishii <ishiir@g.ecc.u-tokyo.ac.jp>
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Tamas K Lengyel <tamas@tklengyel.com>
    master commit: 3643bb53a05b7c8fbac072c63bef1538f2a6d0d2
    master date: 2024-01-18 20:59:06 +0000
---
 xen/arch/x86/hvm/vmx/vmx.c              | 5 ++++-
 xen/arch/x86/hvm/vmx/vvmx.c             | 9 +++++++--
 xen/arch/x86/include/asm/hvm/vmx/vmcs.h | 1 +
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 964891934b..28dece7c6b 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -1558,7 +1558,10 @@ static void cf_check vmx_set_nonreg_state(struct vcpu *v,
 {
     vmx_vmcs_enter(v);
 
-    __vmwrite(GUEST_ACTIVITY_STATE, nrs->vmx.activity_state);
+    if ( nrs->vmx.activity_state )
+        domain_crash(v->domain, "Attempt to set %pv activity_state %#lx\n",
+                     v, nrs->vmx.activity_state);
+
     __vmwrite(GUEST_INTERRUPTIBILITY_INFO, nrs->vmx.interruptibility_info);
     __vmwrite(GUEST_PENDING_DBG_EXCEPTIONS, nrs->vmx.pending_dbg);
 
diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
index 16b0ef82b6..fd0ae39166 100644
--- a/xen/arch/x86/hvm/vmx/vvmx.c
+++ b/xen/arch/x86/hvm/vmx/vvmx.c
@@ -899,7 +899,10 @@ static const u16 vmcs_gstate_field[] = {
     GUEST_LDTR_AR_BYTES,
     GUEST_TR_AR_BYTES,
     GUEST_INTERRUPTIBILITY_INFO,
+    /*
+     * ACTIVITY_STATE is handled specially.
     GUEST_ACTIVITY_STATE,
+     */
     GUEST_SYSENTER_CS,
     GUEST_PREEMPTION_TIMER,
     /* natural */
@@ -1200,6 +1203,8 @@ static void virtual_vmentry(struct cpu_user_regs *regs)
     nvcpu->nv_vmentry_pending = 0;
     nvcpu->nv_vmswitch_in_progress = 1;
 
+    /* TODO: Fail VMentry for GUEST_ACTIVITY_STATE != 0 */
+
     /*
      * EFER handling:
      * hvm_set_efer won't work if CR0.PG = 1, so we change the value
@@ -2316,8 +2321,8 @@ int nvmx_msr_read_intercept(unsigned int msr, u64 *msr_content)
         data = hvm_cr4_guest_valid_bits(d);
         break;
     case MSR_IA32_VMX_MISC:
-        /* Do not support CR3-target feature now */
-        data = host_data & ~VMX_MISC_CR3_TARGET;
+        /* Do not support CR3-targets or activity states. */
+        data = host_data & ~(VMX_MISC_CR3_TARGET | VMX_MISC_ACTIVITY_MASK);
         break;
     case MSR_IA32_VMX_EPT_VPID_CAP:
         data = nept_get_ept_vpid_cap();
diff --git a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h
index d07fcb2bc9..8de9977eb3 100644
--- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h
+++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h
@@ -277,6 +277,7 @@ extern u32 vmx_secondary_exec_control;
 #define VMX_VPID_INVVPID_SINGLE_CONTEXT_RETAINING_GLOBAL 0x80000000000ULL
 extern u64 vmx_ept_vpid_cap;
 
+#define VMX_MISC_ACTIVITY_MASK                  0x000001c0
 #define VMX_MISC_PROC_TRACE                     0x00004000
 #define VMX_MISC_CR3_TARGET                     0x01ff0000
 #define VMX_MISC_VMWRITE_ALL                    0x20000000
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Fri Feb 02 09:22:53 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 02 Feb 2024 09:22:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.674902.1050073 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVpl7-0003xY-7D; Fri, 02 Feb 2024 09:22:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 674902.1050073; Fri, 02 Feb 2024 09:22:53 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVpl7-0003xR-4N; Fri, 02 Feb 2024 09:22:53 +0000
Received: by outflank-mailman (input) for mailman id 674902;
 Fri, 02 Feb 2024 09:22:52 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpl6-0003xB-4I
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:52 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpl6-0004fU-3X
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVpl6-0007FM-2f
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:22:52 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=NW1R0UJIkIGJEuC2rgp2K5Z3nt7XRdt7b1zTm3m+IyQ=; b=U9gE2l4/hfhO4X7JqSW1XV6lSu
	Sbwt23RaXVgQRQS08KpJMA4uFUq7rPbcrPcRBzpKLDKxRe73dr137jtyeqBDEne10qfhvYjJvjOC9
	UuPgnl3Md8nboupRwxiD6rCRioPvGnfp8hITkrNIwGj9HAbW+KNu9pJkiFoxg9zJGXyc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] lib{fdt,elf}: move lib{fdt,elf}-temp.o and their deps to $(targets)
Message-Id: <E1rVpl6-0007FM-2f@xenbits.xenproject.org>
Date: Fri, 02 Feb 2024 09:22:52 +0000

commit 579a622eb41cf4e1ae4d94100985a81eebda23b9
Author:     Michal Orzel <michal.orzel@amd.com>
AuthorDate: Thu Feb 1 18:01:27 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 1 18:01:27 2024 +0100

    lib{fdt,elf}: move lib{fdt,elf}-temp.o and their deps to $(targets)
    
    At the moment, trying to run xencov read/reset (calling SYSCTL_coverage_op
    under the hood) results in a crash. This is due to a profiler trying to
    access data in the .init.* sections (libfdt for Arm and libelf for x86)
    that are stripped after boot. Normally, the build system compiles any
    *.init.o file without COV_FLAGS. However, these two libraries are
    handled differently as sections will be renamed to init after linking.
    
    To override COV_FLAGS to empty for these libraries, lib{fdt,elf}.o were
    added to nocov-y. This worked until e321576f4047 ("xen/build: start using
    if_changed") that added lib{fdt,elf}-temp.o and their deps to extra-y.
    This way, even though these objects appear as prerequisites of
    lib{fdt,elf}.o and the settings should propagate to them, make can also
    build them as a prerequisite of __build, in which case COV_FLAGS would
    still have the unwanted flags. Fix it by switching to $(targets) instead.
    
    Also, for libfdt, append libfdt.o to nocov-y only if CONFIG_OVERLAY_DTB
    is not set. Otherwise, there is no section renaming and we should be able
    to run the coverage.
    
    Fixes: e321576f4047 ("xen/build: start using if_changed")
    Signed-off-by: Michal Orzel <michal.orzel@amd.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    master commit: 79519fcfa0605bbf19d8c02b979af3a2c8afed68
    master date: 2024-01-23 12:02:44 +0100
---
 xen/common/libelf/Makefile | 2 +-
 xen/common/libfdt/Makefile | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/common/libelf/Makefile b/xen/common/libelf/Makefile
index 8a4522e4e1..917d12b006 100644
--- a/xen/common/libelf/Makefile
+++ b/xen/common/libelf/Makefile
@@ -13,4 +13,4 @@ $(obj)/libelf.o: $(obj)/libelf-temp.o FORCE
 $(obj)/libelf-temp.o: $(addprefix $(obj)/,$(libelf-objs)) FORCE
 	$(call if_changed,ld)
 
-extra-y += libelf-temp.o $(libelf-objs)
+targets += libelf-temp.o $(libelf-objs)
diff --git a/xen/common/libfdt/Makefile b/xen/common/libfdt/Makefile
index d50487aa6e..6ce679f98f 100644
--- a/xen/common/libfdt/Makefile
+++ b/xen/common/libfdt/Makefile
@@ -5,10 +5,10 @@ SECTIONS := text data $(SPECIAL_DATA_SECTIONS)
 # For CONFIG_OVERLAY_DTB, libfdt functionalities will be needed during runtime.
 ifneq ($(CONFIG_OVERLAY_DTB),y)
 OBJCOPYFLAGS := $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s))
+nocov-y += libfdt.o
 endif
 
 obj-y += libfdt.o
-nocov-y += libfdt.o
 
 CFLAGS-y += -I$(srctree)/include/xen/libfdt/
 
@@ -18,4 +18,4 @@ $(obj)/libfdt.o: $(obj)/libfdt-temp.o FORCE
 $(obj)/libfdt-temp.o: $(addprefix $(obj)/,$(LIBFDT_OBJS)) FORCE
 	$(call if_changed,ld)
 
-extra-y += libfdt-temp.o $(LIBFDT_OBJS)
+targets += libfdt-temp.o $(LIBFDT_OBJS)
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Fri Feb 02 09:23:03 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 02 Feb 2024 09:23:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.674903.1050077 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVplH-000419-A5; Fri, 02 Feb 2024 09:23:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 674903.1050077; Fri, 02 Feb 2024 09:23:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVplH-000412-7a; Fri, 02 Feb 2024 09:23:03 +0000
Received: by outflank-mailman (input) for mailman id 674903;
 Fri, 02 Feb 2024 09:23:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVplG-00040n-7L
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:23:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVplG-0004i0-6g
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:23:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVplG-0007Fz-5k
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:23:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ol3KubXqqYuEKsLqgGA1FKRKV4EMdIx3+hbGzkunLr8=; b=w8pwNq6oR3GQZS1wdXAAApUlun
	UikTf5cnLWLZS4abB3rCGx42g8NOzb5/LSIfwedOqMF5rTBiaFQy6UFy6ZiCodDMROq2aQ600WDqm
	XIGPEHpRw5dPM/dPcZ+sMINxIYiD2a+etoJYGxjUbCuns5jQibOhHjlwEChNFoKK9W6Q=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] x86/p2m-pt: fix off by one in entry check assert
Message-Id: <E1rVplG-0007Fz-5k@xenbits.xenproject.org>
Date: Fri, 02 Feb 2024 09:23:02 +0000

commit 295ab8060d95ed8c365077946c7faf8793099ef8
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Thu Feb 1 18:01:52 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 1 18:01:52 2024 +0100

    x86/p2m-pt: fix off by one in entry check assert
    
    The MMIO RO rangeset overlap check is bogus: the rangeset is inclusive so the
    passed end mfn should be the last mfn to be mapped (not last + 1).
    
    Fixes: 6fa1755644d0 ('amd/npt/shadow: replace assert that prevents creating 2M/1G MMIO entries')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: George Dunlap <george.dunlap@cloud.com>
    master commit: 610775d0dd61c1bd2f4720c755986098e6a5bafd
    master date: 2024-01-25 16:09:04 +0100
---
 xen/arch/x86/mm/p2m-pt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c
index b2b14746c1..88d3733891 100644
--- a/xen/arch/x86/mm/p2m-pt.c
+++ b/xen/arch/x86/mm/p2m-pt.c
@@ -552,7 +552,7 @@ static void check_entry(mfn_t mfn, p2m_type_t new, p2m_type_t old,
     if ( new == p2m_mmio_direct )
         ASSERT(!mfn_eq(mfn, INVALID_MFN) &&
                !rangeset_overlaps_range(mmio_ro_ranges, mfn_x(mfn),
-                                        mfn_x(mfn) + (1UL << order)));
+                                        mfn_x(mfn) + (1UL << order) - 1));
     else if ( p2m_allows_invalid_mfn(new) || new == p2m_invalid ||
               new == p2m_mmio_dm )
         ASSERT(mfn_valid(mfn) || mfn_eq(mfn, INVALID_MFN));
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Fri Feb 02 09:23:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 02 Feb 2024 09:23:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.674904.1050082 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVplR-000440-Bc; Fri, 02 Feb 2024 09:23:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 674904.1050082; Fri, 02 Feb 2024 09:23:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVplR-00043s-91; Fri, 02 Feb 2024 09:23:13 +0000
Received: by outflank-mailman (input) for mailman id 674904;
 Fri, 02 Feb 2024 09:23:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVplQ-00043e-AV
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:23:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVplQ-0004iL-9q
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:23:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVplQ-0007GX-8v
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 09:23:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=XDG4hly10qeDtBQbJBOKOq06KYGQFquLRSkMnHZ4+Sk=; b=z+zS+AwhOiaaJyFXbKB7wJesv5
	9RWsJabfqC6bs8EMjzddo9u5H9aqbTmMV6eXYgP4XCsXHd/eH3LyCQevUTmfS6CwEUNPmRbfNkmJT
	asIVZ5M3b0rEPtpOaOxjzUwwWMJMyWzrRobxCC0qVTVk9ugVZJwUen0kWvMRdb4kUmMM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] x86/ucode: Fix stability of the raw CPU Policy rescan
Message-Id: <E1rVplQ-0007GX-8v@xenbits.xenproject.org>
Date: Fri, 02 Feb 2024 09:23:12 +0000

commit b1fdd7d0e47e0831ac7a99d0417385fc10d3068c
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Thu Feb 1 18:02:24 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 1 18:02:24 2024 +0100

    x86/ucode: Fix stability of the raw CPU Policy rescan
    
    Always run microcode_update_helper() on the BSP, so the the updated Raw CPU
    policy doesn't get non-BSP topology details included.
    
    Have calculate_raw_cpu_policy() clear the instantanious XSTATE sizes.  The
    value XCR0 | MSR_XSS had when we scanned the policy isn't terribly interesting
    to report.
    
    When CPUID Masking is active, it affects CPUID instructions issued by Xen
    too.  Transiently disable masking to get a clean scan.
    
    Fixes: 694d79ed5aac ("x86/ucode: Refresh raw CPU policy after microcode load")
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: cf7fe8b72deaa94157ddf97d4bb391480205e9c2
    master date: 2024-01-25 17:46:57 +0000
---
 xen/arch/x86/cpu-policy.c         |  7 +++++++
 xen/arch/x86/cpu/microcode/core.c | 20 +++++++++++++++++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
index 81e574390f..bcb17b7ce3 100644
--- a/xen/arch/x86/cpu-policy.c
+++ b/xen/arch/x86/cpu-policy.c
@@ -353,6 +353,13 @@ void calculate_raw_cpu_policy(void)
     /* Nothing good will come from Xen and libx86 disagreeing on vendor. */
     ASSERT(p->x86_vendor == boot_cpu_data.x86_vendor);
 
+    /*
+     * Clear the truly dynamic fields.  These vary with the in-context XCR0
+     * and MSR_XSS, and aren't interesting fields in the raw policy.
+     */
+    p->xstate.raw[0].b = 0;
+    p->xstate.raw[1].b = 0;
+
     /* 0x000000ce  MSR_INTEL_PLATFORM_INFO */
     /* Was already added by probe_cpuid_faulting() */
 }
diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c
index 65ebeb50de..4e011cdc41 100644
--- a/xen/arch/x86/cpu/microcode/core.c
+++ b/xen/arch/x86/cpu/microcode/core.c
@@ -680,8 +680,18 @@ static long cf_check microcode_update_helper(void *data)
         microcode_update_cache(patch);
         spin_unlock(&microcode_mutex);
 
-        /* Refresh the raw CPU policy, in case the features have changed. */
+        /*
+         * Refresh the raw CPU policy, in case the features have changed.
+         * Disable CPUID masking if in use, to avoid having current's
+         * cpu_policy affect the rescan.
+         */
+	if ( ctxt_switch_masking )
+            alternative_vcall(ctxt_switch_masking, NULL);
+
         calculate_raw_cpu_policy();
+
+	if ( ctxt_switch_masking )
+            alternative_vcall(ctxt_switch_masking, current);
     }
     else
         microcode_free_patch(patch);
@@ -721,8 +731,12 @@ int microcode_update(XEN_GUEST_HANDLE(const_void) buf, unsigned long len)
     }
     buffer->len = len;
 
-    return continue_hypercall_on_cpu(smp_processor_id(),
-                                     microcode_update_helper, buffer);
+    /*
+     * Always queue microcode_update_helper() on CPU0.  Most of the logic
+     * won't care, but the update of the Raw CPU policy wants to (re)run on
+     * the BSP.
+     */
+    return continue_hypercall_on_cpu(0, microcode_update_helper, buffer);
 }
 
 static int __init cf_check microcode_init(void)
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Fri Feb 02 19:22:09 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 02 Feb 2024 19:22:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675180.1050420 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVz6x-0000us-8g; Fri, 02 Feb 2024 19:22:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675180.1050420; Fri, 02 Feb 2024 19:22:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVz6x-0000uk-62; Fri, 02 Feb 2024 19:22:03 +0000
Received: by outflank-mailman (input) for mailman id 675180;
 Fri, 02 Feb 2024 19:22:01 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVz6v-0000uS-Pc
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 19:22:01 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVz6v-0007VQ-Og
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 19:22:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVz6v-0000LI-LT
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 19:22:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=wBgKWnNowRbZRG8hm38ZyifO9RyLJe2B46TNgkzEXek=; b=A2+sqskxRWBe0iBevTxVexqijt
	Xm5RURWGY57P7W590vPzneFnullQDIiUifw6s5XjrbpK87kHzmpSmEpRJEZXA+l+AJWi99auM2zCM
	TdLVNANPoAD/Wb2gb1zT+mU5O0Ar6Rv+hXSpQ5IWr+yL8e8ijI3cy4zvKsjCcnyqW44g=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/PoD: simplify / improve p2m_pod_cache_add()
Message-Id: <E1rVz6v-0000LI-LT@xenbits.xenproject.org>
Date: Fri, 02 Feb 2024 19:22:01 +0000

commit d3df0f180fe4e6545f7fa4817683bcdb7861741e
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 1 16:18:28 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 1 16:18:28 2024 +0100

    x86/PoD: simplify / improve p2m_pod_cache_add()
    
    Avoid recurring MFN -> page or page -> MFN translations. Drop the pretty
    pointless local variable "p". Make sure the MFN logged in a debugging
    error message is actually the offending one. Return negative errno
    values rather than -1 (presently no caller really cares, but imo this
    should change). Adjust style.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: George Dunlap <george.dunlap@cloud.com>
---
 xen/arch/x86/mm/p2m-pod.c | 31 ++++++++++---------------------
 1 file changed, 10 insertions(+), 21 deletions(-)

diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index 9e5ad68df2..bc78c61062 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -48,34 +48,27 @@ p2m_pod_cache_add(struct p2m_domain *p2m,
                   unsigned int order)
 {
     unsigned long i;
-    struct page_info *p;
     struct domain *d = p2m->domain;
+    mfn_t mfn = page_to_mfn(page);
 
 #ifndef NDEBUG
-    mfn_t mfn;
-
-    mfn = page_to_mfn(page);
-
     /* Check to make sure this is a contiguous region */
     if ( mfn_x(mfn) & ((1UL << order) - 1) )
     {
         printk("%s: mfn %lx not aligned order %u! (mask %lx)\n",
                __func__, mfn_x(mfn), order, ((1UL << order) - 1));
-        return -1;
+        return -EINVAL;
     }
 
-    for ( i = 0; i < 1UL << order ; i++)
+    for ( i = 0; i < (1UL << order); i++)
     {
-        struct domain * od;
+        const struct domain *od = page_get_owner(page + i);
 
-        p = mfn_to_page(mfn_add(mfn, i));
-        od = page_get_owner(p);
         if ( od != d )
         {
-            printk("%s: mfn %lx expected owner d%d, got owner d%d!\n",
-                   __func__, mfn_x(mfn), d->domain_id,
-                   od ? od->domain_id : -1);
-            return -1;
+            printk("%s: mfn %lx owner: expected %pd, got %pd\n",
+                   __func__, mfn_x(mfn) + i, d, od);
+            return -EACCES;
         }
     }
 #endif
@@ -88,16 +81,12 @@ p2m_pod_cache_add(struct p2m_domain *p2m,
      * promise to provide zero pages. So we scrub pages before using.
      */
     for ( i = 0; i < (1UL << order); i++ )
-        clear_domain_page(mfn_add(page_to_mfn(page), i));
+        clear_domain_page(mfn_add(mfn, i));
 
     /* First, take all pages off the domain list */
     lock_page_alloc(p2m);
-    for ( i = 0; i < 1UL << order ; i++ )
-    {
-        p = page + i;
-        page_list_del(p, &d->page_list);
-    }
-
+    for ( i = 0; i < (1UL << order); i++ )
+        page_list_del(page + i, &d->page_list);
     unlock_page_alloc(p2m);
 
     /* Then add to the appropriate populate-on-demand list. */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 02 19:22:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 02 Feb 2024 19:22:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675181.1050423 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVz77-00010I-9z; Fri, 02 Feb 2024 19:22:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675181.1050423; Fri, 02 Feb 2024 19:22:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVz77-00010B-7Q; Fri, 02 Feb 2024 19:22:13 +0000
Received: by outflank-mailman (input) for mailman id 675181;
 Fri, 02 Feb 2024 19:22:11 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVz75-0000zW-TC
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 19:22:11 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVz75-0007Vo-SM
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 19:22:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVz75-0000Mr-Qo
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 19:22:11 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=tgLn51Nldp47iIgajj+9QQDOmWjVj70TXN1NzQMZ3Ns=; b=SRMRkn2ancIvxU8IbytlYc9vRK
	xc0qa6x3HP13oRUTEf8s2DKTtd45mxHs4G7JSOpoULrnU1LnhEaQ1IrRz83L9upn27PUqyA78adCg
	h9ouuaduJB0xrWpUL7YAeOdphallqW0G9UCh07b8/I/FqkweEglJG5NBdr+rW9ah1cn0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xenpm: Print message for disabled commands
Message-Id: <E1rVz75-0000Mr-Qo@xenbits.xenproject.org>
Date: Fri, 02 Feb 2024 19:22:11 +0000

commit 18cd98490545de0cfc1b326abeddd9b1188c0bd2
Author:     Jason Andryuk <jandryuk@gmail.com>
AuthorDate: Thu Feb 1 16:19:36 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 1 16:19:36 2024 +0100

    xenpm: Print message for disabled commands
    
    xenpm get-cpufreq-states currently just prints no output when cpufreq is
    disabled or HWP is running.  Have it print an appropriate message.  The
    cpufreq disabled one mirrors the cpuidle disabled one.
    
    cpufreq disabled:
    $ xenpm get-cpufreq-states
    Either Xen cpufreq is disabled or no valid information is registered!
    
    Under HWP:
    $ xenpm get-cpufreq-states
    P-State information not supported.  Try 'get-cpufreq-average' or 'start'.
    
    Also allow xenpm to handle EOPNOTSUPP from the pmstat hypercalls.
    EOPNOTSUPP is returned when HWP is active in some cases and allows the
    differentiation from cpufreq being disabled.
    
    Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 tools/misc/xenpm.c | 19 ++++++++++++++++---
 1 file changed, 16 insertions(+), 3 deletions(-)

diff --git a/tools/misc/xenpm.c b/tools/misc/xenpm.c
index d982482a3f..336d246346 100644
--- a/tools/misc/xenpm.c
+++ b/tools/misc/xenpm.c
@@ -362,7 +362,15 @@ static int show_pxstat_by_cpuid(xc_interface *xc_handle, int cpuid)
 
     ret = get_pxstat_by_cpuid(xc_handle, cpuid, &pxstatinfo);
     if ( ret )
+    {
+        if ( ret == -ENODEV )
+            fprintf(stderr,
+                    "Either Xen cpufreq is disabled or no valid information is registered!\n");
+        else if ( ret == -EOPNOTSUPP )
+            fprintf(stderr,
+                    "P-State information not supported.  Try 'get-cpufreq-average' or 'start'.\n");
         return ret;
+    }
 
     print_pxstat(cpuid, &pxstatinfo);
 
@@ -383,8 +391,12 @@ void pxstat_func(int argc, char *argv[])
         /* show pxstates on all cpus */
         int i;
         for ( i = 0; i < max_cpu_nr; i++ )
-            if ( show_pxstat_by_cpuid(xc_handle, i) == -ENODEV )
+        {
+            int ret = show_pxstat_by_cpuid(xc_handle, i);
+
+            if ( ret == -ENODEV || ret == -EOPNOTSUPP )
                 break;
+        }
     }
     else
         show_pxstat_by_cpuid(xc_handle, cpuid);
@@ -432,7 +444,7 @@ static uint64_t *sum, *sum_cx, *sum_px;
 
 static void signal_int_handler(int signo)
 {
-    int i, j, k;
+    int i, j, k, ret;
     struct timeval tv;
     int cx_cap = 0, px_cap = 0;
     xc_cputopo_t *cputopo = NULL;
@@ -473,7 +485,8 @@ static void signal_int_handler(int signo)
                 }
     }
 
-    if ( get_pxstat_by_cpuid(xc_handle, 0, NULL) != -ENODEV )
+    ret = get_pxstat_by_cpuid(xc_handle, 0, NULL);
+    if ( ret != -ENODEV && ret != -EOPNOTSUPP )
     {
         px_cap = 1;
         for ( i = 0; i < max_cpu_nr; i++ )
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 02 19:22:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 02 Feb 2024 19:22:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675182.1050428 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVz7H-00017a-Bm; Fri, 02 Feb 2024 19:22:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675182.1050428; Fri, 02 Feb 2024 19:22:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVz7H-00017S-8x; Fri, 02 Feb 2024 19:22:23 +0000
Received: by outflank-mailman (input) for mailman id 675182;
 Fri, 02 Feb 2024 19:22:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVz7G-000170-12
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 19:22:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVz7G-0007Vy-0A
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 19:22:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVz7F-0000Na-Uf
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 19:22:21 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=NqrywMWsz/MlrNC1T2HhmlQI7V4KGEcjIR+GGi7cPQo=; b=phsX/IaQJlbIBwHiKiodWVINAj
	n6A/1dOBphUwCj3SZBpiExcd4YVAGMLHKSM6cgenlUXka2aIOc4aMg9iX5AZ4ftjA+0zOe1putAVT
	Ei7gl6TMjBdqoNPRAtOLxYlFqRo3qELOzUVv0xHKNUHOQ8erabEQh4vwblfDAe1zy7nE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/page_alloc: introduce init_free_page_fields() helper
Message-Id: <E1rVz7F-0000Na-Uf@xenbits.xenproject.org>
Date: Fri, 02 Feb 2024 19:22:21 +0000

commit 1aee91fe9824d0b33fddbf548add5df1e63a94ad
Author:     Carlo Nonato <carlo.nonato@minervasys.tech>
AuthorDate: Thu Feb 1 16:19:51 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 1 16:19:51 2024 +0100

    xen/page_alloc: introduce init_free_page_fields() helper
    
    Introduce a new helper to initialize fields that have different uses for
    free pages.
    
    Signed-off-by: Carlo Nonato <carlo.nonato@minervasys.tech>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/common/page_alloc.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index 2f4f2859c4..2ec17df9b4 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -925,6 +925,13 @@ static struct page_info *get_free_buddy(unsigned int zone_lo,
     }
 }
 
+/* Initialise fields which have other uses for free pages. */
+static void init_free_page_fields(struct page_info *pg)
+{
+    pg->u.inuse.type_info = PGT_TYPE_INFO_INITIALIZER;
+    page_set_owner(pg, NULL);
+}
+
 /* Allocate 2^@order contiguous pages. */
 static struct page_info *alloc_heap_pages(
     unsigned int zone_lo, unsigned int zone_hi,
@@ -1033,10 +1040,7 @@ static struct page_info *alloc_heap_pages(
             accumulate_tlbflush(&need_tlbflush, &pg[i],
                                 &tlbflush_timestamp);
 
-        /* Initialise fields which have other uses for free pages. */
-        pg[i].u.inuse.type_info = PGT_TYPE_INFO_INITIALIZER;
-        page_set_owner(&pg[i], NULL);
-
+        init_free_page_fields(&pg[i]);
     }
 
     spin_unlock(&heap_lock);
@@ -2799,9 +2803,7 @@ static bool prepare_staticmem_pages(struct page_info *pg, unsigned long nr_mfns,
          * to PGC_state_inuse.
          */
         pg[i].count_info = PGC_static | PGC_state_inuse;
-        /* Initialise fields which have other uses for free pages. */
-        pg[i].u.inuse.type_info = PGT_TYPE_INFO_INITIALIZER;
-        page_set_owner(&pg[i], NULL);
+        init_free_page_fields(&pg[i]);
     }
 
     spin_unlock(&heap_lock);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 02 19:22:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 02 Feb 2024 19:22:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675184.1050432 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVz7R-0001Fu-E2; Fri, 02 Feb 2024 19:22:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675184.1050432; Fri, 02 Feb 2024 19:22:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVz7R-0001Fh-AP; Fri, 02 Feb 2024 19:22:33 +0000
Received: by outflank-mailman (input) for mailman id 675184;
 Fri, 02 Feb 2024 19:22:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVz7Q-0001FN-4U
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 19:22:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVz7Q-0007W6-3n
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 19:22:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVz7Q-0000Nz-2U
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 19:22:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=0U0BV/u6Jw86grbD3KvF1sL+gZiz6JbOqPlybX0qb0M=; b=PTtCGatY6tC29LpkY979oCGGq1
	F/wpUny1tj1jGiHczvjuBJnMG8+SibvM5BN4OQQpaJ4uptFHu8146wC2FKz3kVAXSdATtha57PA2v
	jmlvkImH/y2UU0R7FRk6ZRBQV0GXYe9VZqxpItzBhEOSHNp7r7LAlIkre65Bf5CkrnPQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] IOMMU: iommu_use_hap_pt() implies CONFIG_HVM
Message-Id: <E1rVz7Q-0000Nz-2U@xenbits.xenproject.org>
Date: Fri, 02 Feb 2024 19:22:32 +0000

commit 9916fdff4b3e2955ed31113473699b111d78f385
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 1 16:21:04 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 1 16:21:04 2024 +0100

    IOMMU: iommu_use_hap_pt() implies CONFIG_HVM
    
    Allow the compiler a little more room on DCE by moving the compile-time-
    constant condition into the predicate (from the one place where it was
    added in an open-coded fashion for XSA-450).
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/drivers/passthrough/vtd/iommu.c | 2 +-
 xen/include/xen/iommu.h             | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index 4244855032..54c4c0f9b9 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -438,7 +438,7 @@ static paddr_t domain_pgd_maddr(struct domain *d, paddr_t pgd_maddr,
 
     if ( pgd_maddr )
         /* nothing */;
-    else if ( IS_ENABLED(CONFIG_HVM) && iommu_use_hap_pt(d) )
+    else if ( iommu_use_hap_pt(d) )
     {
         pagetable_t pgt = p2m_get_pagetable(p2m_get_hostp2m(d));
 
diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
index f53d045e2c..a21f25df9f 100644
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -381,7 +381,8 @@ struct domain_iommu {
 #define iommu_clear_feature(d, f) clear_bit(f, dom_iommu(d)->features)
 
 /* Are we using the domain P2M table as its IOMMU pagetable? */
-#define iommu_use_hap_pt(d)       (dom_iommu(d)->hap_pt_share)
+#define iommu_use_hap_pt(d)       (IS_ENABLED(CONFIG_HVM) && \
+                                   dom_iommu(d)->hap_pt_share)
 
 /* Does the IOMMU pagetable need to be kept synchronized with the P2M */
 #ifdef CONFIG_HAS_PASSTHROUGH
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 02 19:22:43 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 02 Feb 2024 19:22:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675187.1050436 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVz7b-0001JO-Ed; Fri, 02 Feb 2024 19:22:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675187.1050436; Fri, 02 Feb 2024 19:22:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVz7b-0001JC-Bo; Fri, 02 Feb 2024 19:22:43 +0000
Received: by outflank-mailman (input) for mailman id 675187;
 Fri, 02 Feb 2024 19:22:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVz7a-0001J2-AZ
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 19:22:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVz7a-0007WD-80
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 19:22:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVz7a-0000OQ-5n
 for xen-changelog@lists.xenproject.org; Fri, 02 Feb 2024 19:22:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Q3Bxjw4/mNaH0tDUotQLIHhuLjCsCKBCLJTKFtzUWvU=; b=sxRUXMEDMM1yD8oAiRui07dyZ+
	AsVAb9my7TlQqrYMIyn2yZTAy1cprsSq7gnNMrSdvtXhkK7wiakaxLG9MEpcAF4kxc0lA9ZPsQJzL
	eC1TXHQEkarWH3OGAz/B7+TZxuZN2p6JzRh/pp2ZPKckcWYeydtjd0Y55nbUbx2mK/vc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] shim: avoid building of vendor IOMMU code
Message-Id: <E1rVz7a-0000OQ-5n@xenbits.xenproject.org>
Date: Fri, 02 Feb 2024 19:22:42 +0000

commit bc45f20c01f1711bc56a4bb0955c49c182a5a03a
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 1 16:21:51 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 1 16:21:51 2024 +0100

    shim: avoid building of vendor IOMMU code
    
    There's no use for IOMMU code in the shim. Disable at least the vendor-
    specific code, until eventually IOMMU code can be disabled altogether.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/configs/pvshim_defconfig | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/arch/x86/configs/pvshim_defconfig b/xen/arch/x86/configs/pvshim_defconfig
index a8ab1d4337..2ad27f898e 100644
--- a/xen/arch/x86/configs/pvshim_defconfig
+++ b/xen/arch/x86/configs/pvshim_defconfig
@@ -22,5 +22,7 @@ CONFIG_EXPERT=y
 # CONFIG_LIVEPATCH is not set
 # CONFIG_SUPPRESS_DUPLICATE_SYMBOL_WARNINGS is not set
 # CONFIG_TRACEBUFFER is not set
+# CONFIG_AMD_IOMMU is not set
+# CONFIG_INTEL_IOMMU is not set
 # CONFIG_DEBUG is not set
 # CONFIG_GDBSX is not set
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 05:55:09 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 05:55:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675310.1050658 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rW8zY-0008L9-8x; Sat, 03 Feb 2024 05:55:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675310.1050658; Sat, 03 Feb 2024 05:55:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rW8zY-0008L1-6M; Sat, 03 Feb 2024 05:55:04 +0000
Received: by outflank-mailman (input) for mailman id 675310;
 Sat, 03 Feb 2024 05:55:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW8zW-0008Kf-6N
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW8zW-0007oD-5X
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW8zW-0003qw-4Q
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=FpdkHno074v3qvqSbOqJMrftqSgXNPMBloe5uCjLTgg=; b=lGgLbxuJKOtIUUhSuewy/imcgu
	VRXkk41ltn4Vrb/cHbvxxcJ0hSwIpc7AlmxZ35tOFraQdGWfXMz10pFZ5zRBfxHnCWd2EYICJ3gEx
	5mKrpCJT/u3gqjWyC8i2N1r7um4lrTW6YpnIEaNZvBX2gCtCWXbXh++ufQjCRMplbef0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] x86/amd: Extend CPU erratum #1474 fix to more affected models
Message-Id: <E1rW8zW-0003qw-4Q@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 05:55:02 +0000

commit abcc32f0634627fe21117a48bd10e792bfbdd6dc
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Fri Feb 2 08:01:09 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri Feb 2 08:01:09 2024 +0100

    x86/amd: Extend CPU erratum #1474 fix to more affected models
    
    Erratum #1474 has now been extended to cover models from family 17h ranges
    00-2Fh, so the errata now covers all the models released under Family
    17h (Zen, Zen+ and Zen2).
    
    Additionally extend the workaround to Family 18h (Hygon), since it's based on
    the Zen architecture and very likely affected.
    
    Rename all the zen2 related symbols to fam17, since the errata doesn't
    exclusively affect Zen2 anymore.
    
    Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: 23db507a01a4ec5259ec0ab43d296a41b1c326ba
    master date: 2023-12-21 12:19:40 +0000
---
 xen/arch/x86/cpu/amd.c | 27 ++++++++++++++-------------
 1 file changed, 14 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index 29ae97e7c0..3d85e9797d 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -54,7 +54,7 @@ bool __read_mostly amd_acpi_c1e_quirk;
 bool __ro_after_init amd_legacy_ssbd;
 bool __initdata amd_virt_spec_ctrl;
 
-static bool __read_mostly zen2_c6_disabled;
+static bool __read_mostly fam17_c6_disabled;
 
 static inline int rdmsr_amd_safe(unsigned int msr, unsigned int *lo,
 				 unsigned int *hi)
@@ -951,24 +951,24 @@ void amd_check_zenbleed(void)
 		       val & chickenbit ? "chickenbit" : "microcode");
 }
 
-static void cf_check zen2_disable_c6(void *arg)
+static void cf_check fam17_disable_c6(void *arg)
 {
 	/* Disable C6 by clearing the CCR{0,1,2}_CC6EN bits. */
 	const uint64_t mask = ~((1ul << 6) | (1ul << 14) | (1ul << 22));
 	uint64_t val;
 
-	if (!zen2_c6_disabled) {
+	if (!fam17_c6_disabled) {
 		printk(XENLOG_WARNING
     "Disabling C6 after 1000 days apparent uptime due to AMD errata 1474\n");
-		zen2_c6_disabled = true;
+		fam17_c6_disabled = true;
 		/*
 		 * Prevent CPU hotplug so that started CPUs will either see
-		 * zen2_c6_disabled set, or will be handled by
+		 * zen_c6_disabled set, or will be handled by
 		 * smp_call_function().
 		 */
 		while (!get_cpu_maps())
 			process_pending_softirqs();
-		smp_call_function(zen2_disable_c6, NULL, 0);
+		smp_call_function(fam17_disable_c6, NULL, 0);
 		put_cpu_maps();
 	}
 
@@ -1273,8 +1273,8 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)
 	amd_check_zenbleed();
 	amd_check_erratum_1485();
 
-	if (zen2_c6_disabled)
-		zen2_disable_c6(NULL);
+	if (fam17_c6_disabled)
+		fam17_disable_c6(NULL);
 
 	check_syscfg_dram_mod_en();
 
@@ -1286,7 +1286,7 @@ const struct cpu_dev amd_cpu_dev = {
 	.c_init		= init_amd,
 };
 
-static int __init cf_check zen2_c6_errata_check(void)
+static int __init cf_check amd_check_erratum_1474(void)
 {
 	/*
 	 * Errata #1474: A Core May Hang After About 1044 Days
@@ -1294,7 +1294,8 @@ static int __init cf_check zen2_c6_errata_check(void)
 	 */
 	s_time_t delta;
 
-	if (cpu_has_hypervisor || boot_cpu_data.x86 != 0x17 || !is_zen2_uarch())
+	if (cpu_has_hypervisor ||
+	    (boot_cpu_data.x86 != 0x17 && boot_cpu_data.x86 != 0x18))
 		return 0;
 
 	/*
@@ -1309,10 +1310,10 @@ static int __init cf_check zen2_c6_errata_check(void)
 	if (delta > 0) {
 		static struct timer errata_c6;
 
-		init_timer(&errata_c6, zen2_disable_c6, NULL, 0);
+		init_timer(&errata_c6, fam17_disable_c6, NULL, 0);
 		set_timer(&errata_c6, NOW() + delta);
 	} else
-		zen2_disable_c6(NULL);
+		fam17_disable_c6(NULL);
 
 	return 0;
 }
@@ -1320,4 +1321,4 @@ static int __init cf_check zen2_c6_errata_check(void)
  * Must be executed after early_time_init() for tsc_ticks2ns() to have been
  * calibrated.  That prevents us doing the check in init_amd().
  */
-presmp_initcall(zen2_c6_errata_check);
+presmp_initcall(amd_check_erratum_1474);
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 05:55:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 05:55:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675311.1050663 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rW8zi-0008N6-Ay; Sat, 03 Feb 2024 05:55:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675311.1050663; Sat, 03 Feb 2024 05:55:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rW8zi-0008My-7q; Sat, 03 Feb 2024 05:55:14 +0000
Received: by outflank-mailman (input) for mailman id 675311;
 Sat, 03 Feb 2024 05:55:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW8zg-0008Mh-AT
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW8zg-0007oH-9X
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW8zg-0003rM-7b
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=eHJ1fXWE4Z5N3FOrYsUbibGaULRjsn00QqNxjuLDHqU=; b=RX/Y12jViPE/UVGsZ6TpENRGYW
	dZCVao52/7mbOl70snxYuWlHG2HWC6bb2Tv+ylQ29XMgpCv3+JC/i4XSHO0FvOCn7NSR3xtQf3JYA
	zR1xasFwVaX2nKACx2dEy9IOH4crlR/N/4jW0zBZMJhcpB7A378xrfGPIcUXqKqG3nkQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] CirrusCI: drop FreeBSD 12
Message-Id: <E1rW8zg-0003rM-7b@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 05:55:12 +0000

commit 0ef1fb43ddd61b3c4c953e833e012ac21ad5ca0f
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Fri Feb 2 08:01:50 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri Feb 2 08:01:50 2024 +0100

    CirrusCI: drop FreeBSD 12
    
    Went EOL by the end of December 2023, and the pkg repos have been shut down.
    
    Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: c2ce3466472e9c9eda79f5dc98eb701bc6fdba20
    master date: 2024-01-15 12:20:11 +0100
---
 .cirrus.yml | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
index 7e0beb200d..63f3afb104 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -14,12 +14,6 @@ freebsd_template: &FREEBSD_TEMPLATE
     - ./configure --with-system-seabios=/usr/local/share/seabios/bios.bin
     - gmake -j`sysctl -n hw.ncpu` clang=y
 
-task:
-  name: 'FreeBSD 12'
-  freebsd_instance:
-    image_family: freebsd-12-4
-  << : *FREEBSD_TEMPLATE
-
 task:
   name: 'FreeBSD 13'
   freebsd_instance:
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 05:55:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 05:55:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675312.1050667 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rW8zr-0008QQ-E4; Sat, 03 Feb 2024 05:55:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675312.1050667; Sat, 03 Feb 2024 05:55:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rW8zr-0008QI-BA; Sat, 03 Feb 2024 05:55:23 +0000
Received: by outflank-mailman (input) for mailman id 675312;
 Sat, 03 Feb 2024 05:55:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW8zq-0008Q6-FA
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW8zq-0007om-Ch
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW8zq-0003rs-Bl
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=DC0bHZcCGG+WI/Se+rdh7W1AtAFZ6Ygs8CmtacuG3gw=; b=DFm+I7/jArl4fZCSSiC7ltAluD
	1WoxatHBwkikr6pKCFZLEPuoL9HCduy798c4BJWQkPjURXnNUdbwCclAMBTOdL0tzCUW6PAZuLTot
	VrfjEMwnDMo/ABa8A/V5N4MJgS1t1+T/NUxGXSQ7+ym7VY3i54Z/Qefso+OCACjjVwgk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] x86/intel: ensure Global Performance Counter Control is setup correctly
Message-Id: <E1rW8zq-0003rs-Bl@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 05:55:22 +0000

commit d0ad2cc5eac1b5d3cfd14204d377ce2384f52607
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Fri Feb 2 08:02:20 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri Feb 2 08:02:20 2024 +0100

    x86/intel: ensure Global Performance Counter Control is setup correctly
    
    When Architectural Performance Monitoring is available, the PERF_GLOBAL_CTRL
    MSR contains per-counter enable bits that is ANDed with the enable bit in the
    counter EVNTSEL MSR in order for a PMC counter to be enabled.
    
    So far the watchdog code seems to have relied on the PERF_GLOBAL_CTRL enable
    bits being set by default, but at least on some Intel Sapphire and Emerald
    Rapids this is no longer the case, and Xen reports:
    
    Testing NMI watchdog on all CPUs: 0 40 stuck
    
    The first CPU on each package is started with PERF_GLOBAL_CTRL zeroed, so PMC0
    doesn't start counting when the enable bit in EVNTSEL0 is set, due to the
    relevant enable bit in PERF_GLOBAL_CTRL not being set.
    
    Check and adjust PERF_GLOBAL_CTRL during CPU initialization so that all the
    general-purpose PMCs are enabled.  Doing so brings the state of the package-BSP
    PERF_GLOBAL_CTRL in line with the rest of the CPUs on the system.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    master commit: 6bdb965178bbb3fc50cd4418d4770a7789956e2c
    master date: 2024-01-17 10:40:52 +0100
---
 xen/arch/x86/cpu/intel.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/cpu/intel.c b/xen/arch/x86/cpu/intel.c
index b40ac696e6..96723b5d44 100644
--- a/xen/arch/x86/cpu/intel.c
+++ b/xen/arch/x86/cpu/intel.c
@@ -528,9 +528,30 @@ static void cf_check init_intel(struct cpuinfo_x86 *c)
 	init_intel_cacheinfo(c);
 	if (c->cpuid_level > 9) {
 		unsigned eax = cpuid_eax(10);
+		unsigned int cnt = (eax >> 8) & 0xff;
+
 		/* Check for version and the number of counters */
-		if ((eax & 0xff) && (((eax>>8) & 0xff) > 1))
+		if ((eax & 0xff) && (cnt > 1) && (cnt <= 32)) {
+			uint64_t global_ctrl;
+			unsigned int cnt_mask = (1UL << cnt) - 1;
+
+			/*
+			 * On (some?) Sapphire/Emerald Rapids platforms each
+			 * package-BSP starts with all the enable bits for the
+			 * general-purpose PMCs cleared.  Adjust so counters
+			 * can be enabled from EVNTSEL.
+			 */
+			rdmsrl(MSR_CORE_PERF_GLOBAL_CTRL, global_ctrl);
+			if ((global_ctrl & cnt_mask) != cnt_mask) {
+				printk("CPU%u: invalid PERF_GLOBAL_CTRL: %#"
+				       PRIx64 " adjusting to %#" PRIx64 "\n",
+				       smp_processor_id(), global_ctrl,
+				       global_ctrl | cnt_mask);
+				wrmsrl(MSR_CORE_PERF_GLOBAL_CTRL,
+				       global_ctrl | cnt_mask);
+			}
 			__set_bit(X86_FEATURE_ARCH_PERFMON, c->x86_capability);
+		}
 	}
 
 	if ( !cpu_has(c, X86_FEATURE_XTOPOLOGY) )
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 05:55:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 05:55:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675313.1050671 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rW901-0008TB-FG; Sat, 03 Feb 2024 05:55:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675313.1050671; Sat, 03 Feb 2024 05:55:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rW901-0008T4-Cj; Sat, 03 Feb 2024 05:55:33 +0000
Received: by outflank-mailman (input) for mailman id 675313;
 Sat, 03 Feb 2024 05:55:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW900-0008Sm-IX
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW900-0007ot-Hp
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW900-0003sH-F6
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=stzOP+rnTyzcSzT64xGuJT6q+t7xlWGalsq78Gcf5PE=; b=EHfQQ5AA1FLzlAKo1My8Kn/K2l
	JlSSA38UzsumN454yFfycPHjF7avutrthl5XlSqgYq6hf4Cgk52bvBpPtnPWJdbo6Khb4tLqzsTCQ
	dDak8EjVh2bnizJc/LgwsPyqsNDCsLAaGMzQk+0s0NMa5ZRsBSy8tqynafZ7ldSp9wj4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] x86/vmx: Fix IRQ handling for EXIT_REASON_INIT
Message-Id: <E1rW900-0003sH-F6@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 05:55:32 +0000

commit eca5416f9b0e179de9553900de8de660ab09199d
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Feb 2 08:02:51 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri Feb 2 08:02:51 2024 +0100

    x86/vmx: Fix IRQ handling for EXIT_REASON_INIT
    
    When receiving an INIT, a prior bugfix tried to ignore the INIT and continue
    onwards.
    
    Unfortunately it's not safe to return at that point in vmx_vmexit_handler().
    Just out of context in the first hunk is a local_irqs_enabled() which is
    depended-upon by the return-to-guest path, causing the following checklock
    failure in debug builds:
    
      (XEN) Error: INIT received - ignoring
      (XEN) CHECKLOCK FAILURE: prev irqsafe: 0, curr irqsafe 1
      (XEN) Xen BUG at common/spinlock.c:132
      (XEN) ----[ Xen-4.19-unstable  x86_64  debug=y  Tainted:     H  ]----
      ...
      (XEN) Xen call trace:
      (XEN)    [<ffff82d040238e10>] R check_lock+0xcd/0xe1
      (XEN)    [<ffff82d040238fe3>] F _spin_lock+0x1b/0x60
      (XEN)    [<ffff82d0402ed6a8>] F pt_update_irq+0x32/0x3bb
      (XEN)    [<ffff82d0402b9632>] F vmx_intr_assist+0x3b/0x51d
      (XEN)    [<ffff82d040206447>] F vmx_asm_vmexit_handler+0xf7/0x210
    
    Luckily, this is benign in release builds.  Accidentally having IRQs disabled
    when trying to take an IRQs-on lock isn't a deadlock-vulnerable pattern.
    
    Drop the problematic early return.  In hindsight, it's wrong to skip other
    normal VMExit steps.
    
    Fixes: b1f11273d5a7 ("x86/vmx: Don't spuriously crash the domain when INIT is received")
    Reported-by: Reima ISHII <ishiir@g.ecc.u-tokyo.ac.jp>
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: d1f8883aebe00f6a9632d77ab0cd5c6d02c9cbe4
    master date: 2024-01-18 20:59:06 +0000
---
 xen/arch/x86/hvm/vmx/vmx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 072288a5ef..31f4a861c6 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -4037,7 +4037,7 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
 
     case EXIT_REASON_INIT:
         printk(XENLOG_ERR "Error: INIT received - ignoring\n");
-        return; /* Renter the guest without further processing */
+        break;
     }
 
     /* Now enable interrupts so it's safe to take locks. */
@@ -4323,6 +4323,7 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
         break;
     }
     case EXIT_REASON_EXTERNAL_INTERRUPT:
+    case EXIT_REASON_INIT:
         /* Already handled above. */
         break;
     case EXIT_REASON_TRIPLE_FAULT:
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 05:55:43 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 05:55:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675314.1050675 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rW90B-00004u-HX; Sat, 03 Feb 2024 05:55:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675314.1050675; Sat, 03 Feb 2024 05:55:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rW90B-0008WS-EJ; Sat, 03 Feb 2024 05:55:43 +0000
Received: by outflank-mailman (input) for mailman id 675314;
 Sat, 03 Feb 2024 05:55:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW90A-0008WM-Nt
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW90A-0007p0-N4
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW90A-0003su-KL
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=vLFwBAxX1iQ4uDRasPkn+1b9MR2i5oHGCZxEdZKqHE0=; b=BKpK4R3ZNgOLUolxdEUmIeyJs+
	8MZosC4OlJDJkDCTZsVWmfRfxNDy+26U+/UakoLuXK7w7aZYbW3upuXjqzZFHY3FGR6c2GWO+94dZ
	YXlx5s7HgAGUj7HJX3CSZlNg0aULMQCA5f9Cjp57OWvJ+S9iUVr8CHyi94HS5xZgB7M0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] x86/vmx: Disallow the use of inactivity states
Message-Id: <E1rW90A-0003su-KL@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 05:55:42 +0000

commit 7bd612727df792671e44152a8205f0cf821ad984
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Feb 2 08:03:26 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri Feb 2 08:03:26 2024 +0100

    x86/vmx: Disallow the use of inactivity states
    
    Right now, vvmx will blindly copy L12's ACTIVITY_STATE into the L02 VMCS and
    enter the vCPU.  Luckily for us, nested-virt is explicitly unsupported for
    security bugs.
    
    The inactivity states are HLT, SHUTDOWN and WAIT-FOR-SIPI, and as noted by the
    SDM in Vol3 27.7 "Special Features of VM Entry":
    
      If VM entry ends with the logical processor in an inactive activity state,
      the VM entry generates any special bus cycle that is normally generated when
      that activity state is entered from the active state.
    
    Also,
    
      Some activity states unconditionally block certain events.
    
    I.e. A VMEntry with ACTIVITY=SHUTDOWN will initiate a platform reset, while a
    VMEntry with ACTIVITY=WAIT-FOR-SIPI will really block everything other than
    SIPIs.
    
    Both of these activity states are for the TXT ACM to use, not for regular
    hypervisors, and Xen doesn't support dropping the HLT intercept either.
    
    There are two paths in Xen which operate on ACTIVITY_STATE.
    
    1) The vmx_{get,set}_nonreg_state() helpers for VM-Fork.
    
       As regular VMs can't use any inactivity states, this is just duplicating
       the 0 from construct_vmcs().  Retain the ability to query activity_state,
       but crash the domain on any attempt to set an inactivity state.
    
    2) Nested virt, because of ACTIVITY_STATE in vmcs_gstate_field[].
    
       Explicitly hide the inactivity states in the guest's view of MSR_VMX_MISC,
       and remove ACTIVITY_STATE from vmcs_gstate_field[].
    
       In virtual_vmentry(), we should trigger a VMEntry failure for the use of
       any inactivity states, but there's no support for that in the code at all
       so leave a TODO for when we finally start working on nested-virt in
       earnest.
    
    Reported-by: Reima Ishii <ishiir@g.ecc.u-tokyo.ac.jp>
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Tamas K Lengyel <tamas@tklengyel.com>
    master commit: 3643bb53a05b7c8fbac072c63bef1538f2a6d0d2
    master date: 2024-01-18 20:59:06 +0000
---
 xen/arch/x86/hvm/vmx/vmx.c              | 8 +++++++-
 xen/arch/x86/hvm/vmx/vvmx.c             | 9 +++++++--
 xen/arch/x86/include/asm/hvm/vmx/vmcs.h | 1 +
 3 files changed, 15 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 31f4a861c6..35d391d8e5 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -1499,7 +1499,13 @@ static void cf_check vmx_set_nonreg_state(struct vcpu *v,
 {
     vmx_vmcs_enter(v);
 
-    __vmwrite(GUEST_ACTIVITY_STATE, nrs->vmx.activity_state);
+    if ( nrs->vmx.activity_state )
+    {
+        printk("Attempt to set %pv activity_state %#lx\n",
+               v, nrs->vmx.activity_state);
+        domain_crash(v->domain);
+    }
+
     __vmwrite(GUEST_INTERRUPTIBILITY_INFO, nrs->vmx.interruptibility_info);
     __vmwrite(GUEST_PENDING_DBG_EXCEPTIONS, nrs->vmx.pending_dbg);
 
diff --git a/xen/arch/x86/hvm/vmx/vvmx.c b/xen/arch/x86/hvm/vmx/vvmx.c
index f8fe8d0c14..515cb5ae77 100644
--- a/xen/arch/x86/hvm/vmx/vvmx.c
+++ b/xen/arch/x86/hvm/vmx/vvmx.c
@@ -910,7 +910,10 @@ static const u16 vmcs_gstate_field[] = {
     GUEST_LDTR_AR_BYTES,
     GUEST_TR_AR_BYTES,
     GUEST_INTERRUPTIBILITY_INFO,
+    /*
+     * ACTIVITY_STATE is handled specially.
     GUEST_ACTIVITY_STATE,
+     */
     GUEST_SYSENTER_CS,
     GUEST_PREEMPTION_TIMER,
     /* natural */
@@ -1211,6 +1214,8 @@ static void virtual_vmentry(struct cpu_user_regs *regs)
     nvcpu->nv_vmentry_pending = 0;
     nvcpu->nv_vmswitch_in_progress = 1;
 
+    /* TODO: Fail VMentry for GUEST_ACTIVITY_STATE != 0 */
+
     /*
      * EFER handling:
      * hvm_set_efer won't work if CR0.PG = 1, so we change the value
@@ -2327,8 +2332,8 @@ int nvmx_msr_read_intercept(unsigned int msr, u64 *msr_content)
         data = hvm_cr4_guest_valid_bits(d);
         break;
     case MSR_IA32_VMX_MISC:
-        /* Do not support CR3-target feature now */
-        data = host_data & ~VMX_MISC_CR3_TARGET;
+        /* Do not support CR3-targets or activity states. */
+        data = host_data & ~(VMX_MISC_CR3_TARGET | VMX_MISC_ACTIVITY_MASK);
         break;
     case MSR_IA32_VMX_EPT_VPID_CAP:
         data = nept_get_ept_vpid_cap();
diff --git a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h
index 78404e42b3..0af021d5f5 100644
--- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h
+++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h
@@ -288,6 +288,7 @@ extern u32 vmx_secondary_exec_control;
 #define VMX_VPID_INVVPID_SINGLE_CONTEXT_RETAINING_GLOBAL 0x80000000000ULL
 extern u64 vmx_ept_vpid_cap;
 
+#define VMX_MISC_ACTIVITY_MASK                  0x000001c0
 #define VMX_MISC_PROC_TRACE                     0x00004000
 #define VMX_MISC_CR3_TARGET                     0x01ff0000
 #define VMX_MISC_VMWRITE_ALL                    0x20000000
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 05:55:53 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 05:55:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675315.1050679 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rW90L-00008I-Ia; Sat, 03 Feb 2024 05:55:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675315.1050679; Sat, 03 Feb 2024 05:55:53 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rW90L-000087-G2; Sat, 03 Feb 2024 05:55:53 +0000
Received: by outflank-mailman (input) for mailman id 675315;
 Sat, 03 Feb 2024 05:55:52 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW90K-00007w-Qr
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:52 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW90K-0007p7-QC
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW90K-0003tJ-PB
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:55:52 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Jjld+oAVbN3Cf0eCKKOu0A07/ATOl8qRjG7ERYlbNOE=; b=aAgO28WxRVLgwFnQj8fB8q7wGV
	GG8r31FsNoUUMLSBDdayjD2eTaTsY7dnThCmIR0W25W53niMBo/4zrYJpBZBJ5h9TuRIDSwEzyT4a
	oriNtRumVaipFLIujajgLESFGzK5yFSoJwTXGrwpWzPoIflhzzA2ZZ17E3AHTi+1a9dk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] lib{fdt,elf}: move lib{fdt,elf}-temp.o and their deps to $(targets)
Message-Id: <E1rW90K-0003tJ-PB@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 05:55:52 +0000

commit afb85cf1e8f165abf88de9d8a6df625692a753b1
Author:     Michal Orzel <michal.orzel@amd.com>
AuthorDate: Fri Feb 2 08:04:07 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri Feb 2 08:04:07 2024 +0100

    lib{fdt,elf}: move lib{fdt,elf}-temp.o and their deps to $(targets)
    
    At the moment, trying to run xencov read/reset (calling SYSCTL_coverage_op
    under the hood) results in a crash. This is due to a profiler trying to
    access data in the .init.* sections (libfdt for Arm and libelf for x86)
    that are stripped after boot. Normally, the build system compiles any
    *.init.o file without COV_FLAGS. However, these two libraries are
    handled differently as sections will be renamed to init after linking.
    
    To override COV_FLAGS to empty for these libraries, lib{fdt,elf}.o were
    added to nocov-y. This worked until e321576f4047 ("xen/build: start using
    if_changed") that added lib{fdt,elf}-temp.o and their deps to extra-y.
    This way, even though these objects appear as prerequisites of
    lib{fdt,elf}.o and the settings should propagate to them, make can also
    build them as a prerequisite of __build, in which case COV_FLAGS would
    still have the unwanted flags. Fix it by switching to $(targets) instead.
    
    Also, for libfdt, append libfdt.o to nocov-y only if CONFIG_OVERLAY_DTB
    is not set. Otherwise, there is no section renaming and we should be able
    to run the coverage.
    
    Fixes: e321576f4047 ("xen/build: start using if_changed")
    Signed-off-by: Michal Orzel <michal.orzel@amd.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    master commit: 79519fcfa0605bbf19d8c02b979af3a2c8afed68
    master date: 2024-01-23 12:02:44 +0100
---
 xen/common/libelf/Makefile | 2 +-
 xen/common/libfdt/Makefile | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/common/libelf/Makefile b/xen/common/libelf/Makefile
index 8a4522e4e1..917d12b006 100644
--- a/xen/common/libelf/Makefile
+++ b/xen/common/libelf/Makefile
@@ -13,4 +13,4 @@ $(obj)/libelf.o: $(obj)/libelf-temp.o FORCE
 $(obj)/libelf-temp.o: $(addprefix $(obj)/,$(libelf-objs)) FORCE
 	$(call if_changed,ld)
 
-extra-y += libelf-temp.o $(libelf-objs)
+targets += libelf-temp.o $(libelf-objs)
diff --git a/xen/common/libfdt/Makefile b/xen/common/libfdt/Makefile
index 75aaefa2e3..4d14fd61ba 100644
--- a/xen/common/libfdt/Makefile
+++ b/xen/common/libfdt/Makefile
@@ -2,9 +2,9 @@ include $(src)/Makefile.libfdt
 
 SECTIONS := text data $(SPECIAL_DATA_SECTIONS)
 OBJCOPYFLAGS := $(foreach s,$(SECTIONS),--rename-section .$(s)=.init.$(s))
+nocov-y += libfdt.o
 
 obj-y += libfdt.o
-nocov-y += libfdt.o
 
 CFLAGS-y += -I$(srctree)/include/xen/libfdt/
 
@@ -14,4 +14,4 @@ $(obj)/libfdt.o: $(obj)/libfdt-temp.o FORCE
 $(obj)/libfdt-temp.o: $(addprefix $(obj)/,$(LIBFDT_OBJS)) FORCE
 	$(call if_changed,ld)
 
-extra-y += libfdt-temp.o $(LIBFDT_OBJS)
+targets += libfdt-temp.o $(LIBFDT_OBJS)
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 05:56:03 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 05:56:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675316.1050683 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rW90V-0000Bq-KN; Sat, 03 Feb 2024 05:56:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675316.1050683; Sat, 03 Feb 2024 05:56:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rW90V-0000Bi-HZ; Sat, 03 Feb 2024 05:56:03 +0000
Received: by outflank-mailman (input) for mailman id 675316;
 Sat, 03 Feb 2024 05:56:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW90U-0000BV-Ty
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:56:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW90U-0007pb-TH
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:56:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rW90U-0003uO-SL
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 05:56:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=td5/i7QtxEe9hlWwUvMobWwcxjTUFmjPTmhEo0J8/bs=; b=GtLTZSkPErR6iBuIYJkSeZAS3D
	zKZgn/vSMXH1jSMLsUdOKc3Y8EddKmntD0KdnRtS1kxGH76rW9DEeOswqbmjTigKiDj9Y0E4hDUot
	FvPYjZx34BzaqF2wdernHsOMpt1yKFmYxTEbqfjEwtp56M9v+ChJtPKozIw4cVKSiCq0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] x86/p2m-pt: fix off by one in entry check assert
Message-Id: <E1rW90U-0003uO-SL@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 05:56:02 +0000

commit 091466ba55d1e2e75738f751818ace2e3ed08ccf
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Fri Feb 2 08:04:33 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri Feb 2 08:04:33 2024 +0100

    x86/p2m-pt: fix off by one in entry check assert
    
    The MMIO RO rangeset overlap check is bogus: the rangeset is inclusive so the
    passed end mfn should be the last mfn to be mapped (not last + 1).
    
    Fixes: 6fa1755644d0 ('amd/npt/shadow: replace assert that prevents creating 2M/1G MMIO entries')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: George Dunlap <george.dunlap@cloud.com>
    master commit: 610775d0dd61c1bd2f4720c755986098e6a5bafd
    master date: 2024-01-25 16:09:04 +0100
---
 xen/arch/x86/mm/p2m-pt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/mm/p2m-pt.c b/xen/arch/x86/mm/p2m-pt.c
index eaba2b0fb4..f02ebae372 100644
--- a/xen/arch/x86/mm/p2m-pt.c
+++ b/xen/arch/x86/mm/p2m-pt.c
@@ -564,7 +564,7 @@ static void check_entry(mfn_t mfn, p2m_type_t new, p2m_type_t old,
     if ( new == p2m_mmio_direct )
         ASSERT(!mfn_eq(mfn, INVALID_MFN) &&
                !rangeset_overlaps_range(mmio_ro_ranges, mfn_x(mfn),
-                                        mfn_x(mfn) + (1ul << order)));
+                                        mfn_x(mfn) + (1UL << order) - 1));
     else if ( p2m_allows_invalid_mfn(new) || new == p2m_invalid ||
               new == p2m_mmio_dm )
         ASSERT(mfn_valid(mfn) || mfn_eq(mfn, INVALID_MFN));
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 16:11:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 16:11:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675406.1050770 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIbg-0005vJ-2g; Sat, 03 Feb 2024 16:11:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675406.1050770; Sat, 03 Feb 2024 16:11:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIbg-0005vB-05; Sat, 03 Feb 2024 16:11:04 +0000
Received: by outflank-mailman (input) for mailman id 675406;
 Sat, 03 Feb 2024 16:11:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIbe-0005v5-Ck
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIbe-0002tR-8m
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIbe-0002Bl-4D
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=rP2P9aAzk2E8Cib4Yaz3aR48/W8LxjX6XuySNel6Bao=; b=YVSlIKQXJcLCcBupkAywNAKpLY
	IuCKNJNAP+sbvzbgk/CLV5TOstlluUycf+GPJOdJsmowl8UFRCQna/MDTtVltzuCm/xcD+QD6kvpp
	slNzy+j5sFsEi/K8LJ8WypJ5X3mfBPLaBoMUoso2EhI4q01rMt3GJZS4YwUAVXqWYAGU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: Properly clean update to init_ttbr and smp_up_cpu
Message-Id: <E1rWIbe-0002Bl-4D@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 16:11:02 +0000

commit 4c2d50d586717533f6bee4c6340be0432d0a76d0
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Thu Feb 1 17:35:22 2024 +0000
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu Feb 1 17:35:45 2024 +0000

    xen/arm: Properly clean update to init_ttbr and smp_up_cpu
    
    Recent rework to the secondary boot code modified how init_ttbr and
    smp_up_cpu are accessed. Rather than directly accessing them, we
    are using a pointer to them.
    
    The helper clean_dcache() is expected to take the variable in parameter
    and then clean its content. As we now pass a pointer to the variable,
    we will clean the area storing the address rather than the content itself.
    
    Switch to use clean_dcache_va_range() to avoid casting the pointer.
    
    Fixes: a5ed59e62c6f ("arm/mmu: Move init_ttbr to a new section .data.idmap")
    Fixes: 9a5114074b04 ("arm/smpboot: Move smp_up_cpu to a new section .data.idmap)
    
    Reported-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Tested-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
---
 xen/arch/arm/mmu/smpboot.c | 2 +-
 xen/arch/arm/smpboot.c     | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/mmu/smpboot.c b/xen/arch/arm/mmu/smpboot.c
index bc91fdfe33..4ffc8254a4 100644
--- a/xen/arch/arm/mmu/smpboot.c
+++ b/xen/arch/arm/mmu/smpboot.c
@@ -88,7 +88,7 @@ static void set_init_ttbr(lpae_t *root)
      * init_ttbr will be accessed with the MMU off, so ensure the update
      * is visible by cleaning the cache.
      */
-    clean_dcache(ptr);
+    clean_dcache_va_range(ptr, sizeof(uint64_t));
 
     unmap_domain_page(ptr);
 }
diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index 119bfa3160..a84e706d77 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -449,7 +449,7 @@ static void set_smp_up_cpu(unsigned long mpidr)
      * smp_up_cpu will be accessed with the MMU off, so ensure the update
      * is visible by cleaning the cache.
      */
-    clean_dcache(ptr);
+    clean_dcache_va_range(ptr, sizeof(unsigned long));
 
     unmap_domain_page(ptr);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 16:11:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 16:11:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675407.1050774 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIbq-0005x9-4C; Sat, 03 Feb 2024 16:11:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675407.1050774; Sat, 03 Feb 2024 16:11:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIbq-0005x2-1W; Sat, 03 Feb 2024 16:11:14 +0000
Received: by outflank-mailman (input) for mailman id 675407;
 Sat, 03 Feb 2024 16:11:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIbo-0005wi-Cr
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIbo-0002tZ-C1
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIbo-0002CU-B3
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=5IBIXwHi3GnXwb1fWWjalI+XRuXPlrOPYHBBVkz4Lw4=; b=XmHCmjlTG3BNBRCksQc8dgvxLe
	voVCqms/LMTXcSqa2+554Whi3+Xs+wrYinJNgEWroV9khgh+6Pf05imlkB1i8nP/Ui45Dqxdg9Y+X
	lI+k4p8/c6PuylYpC8fpItUJiEbnf9+HdNAQ2sIu1PWZHyHgcp87gyGUOapwo6CVKECc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen: Drop superfluous semi-colons
Message-Id: <E1rWIbo-0002CU-B3@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 16:11:12 +0000

commit 8e36c668ca107be8225bd31bf93520fc68d44fb8
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Jan 30 22:13:17 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 1 19:52:44 2024 +0000

    xen: Drop superfluous semi-colons
    
    All these cases happen to be benign, but drop them anyway.  This is one step
    towards making -Wextra-semi work.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/common/sched/private.h   | 2 +-
 xen/drivers/acpi/apei/hest.c | 2 +-
 xen/include/xen/livepatch.h  | 2 +-
 xen/include/xen/serial.h     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/common/sched/private.h b/xen/common/sched/private.h
index 79e3f56c5a..26a196f428 100644
--- a/xen/common/sched/private.h
+++ b/xen/common/sched/private.h
@@ -518,7 +518,7 @@ static inline void sched_unit_unpause(const struct sched_unit *unit)
 }
 
 #define REGISTER_SCHEDULER(x) static const struct scheduler *x##_entry \
-  __used_section(".data.schedulers") = &x;
+  __used_section(".data.schedulers") = &x
 
 struct cpupool
 {
diff --git a/xen/drivers/acpi/apei/hest.c b/xen/drivers/acpi/apei/hest.c
index 4ec28c3c11..34b376bc2d 100644
--- a/xen/drivers/acpi/apei/hest.c
+++ b/xen/drivers/acpi/apei/hest.c
@@ -86,7 +86,7 @@ static int hest_esrc_len(const struct acpi_hest_header *hest_hdr)
 	BUG_ON(len == -1);
 
 	return len;
-};
+}
 
 int apei_hest_parse(apei_hest_func_t func, void *data)
 {
diff --git a/xen/include/xen/livepatch.h b/xen/include/xen/livepatch.h
index df339a134e..45df4bba4f 100644
--- a/xen/include/xen/livepatch.h
+++ b/xen/include/xen/livepatch.h
@@ -182,7 +182,7 @@ static inline int livepatch_op(struct xen_sysctl_livepatch_op *op)
     return -ENOSYS;
 }
 
-static inline void check_for_livepatch_work(void) { };
+static inline void check_for_livepatch_work(void) {}
 static inline bool is_patch(const void *addr)
 {
     return 0;
diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
index 870ca2f6eb..12ef24351d 100644
--- a/xen/include/xen/serial.h
+++ b/xen/include/xen/serial.h
@@ -175,7 +175,7 @@ void ehci_dbgp_init(void);
 #ifdef CONFIG_XHCI
 void xhci_dbc_uart_init(void);
 #else
-static void inline xhci_dbc_uart_init(void) {};
+static void inline xhci_dbc_uart_init(void) {}
 #endif
 
 void arm_uart_init(void);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 16:11:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 16:11:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675408.1050777 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIc0-0005zP-5g; Sat, 03 Feb 2024 16:11:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675408.1050777; Sat, 03 Feb 2024 16:11:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIc0-0005zG-2t; Sat, 03 Feb 2024 16:11:24 +0000
Received: by outflank-mailman (input) for mailman id 675408;
 Sat, 03 Feb 2024 16:11:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIby-0005z6-GP
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIby-0002u6-FZ
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIby-0002DG-EM
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=tsasbaqU23ZM0fr3Fl7NDlo4FQRwTuczKyLDahrL1SQ=; b=U60vH6FkIVw7hjhbykWHajKBoG
	NUwjW6QiEUejCLL5gjEGTa3027Hvaa/Am2+X1BgYDqH9SsPN2YHxuT88lgWRZdaH6PlM54jXUXCFh
	GYJPgZRSlFYP35sLw5d1ek37YdE5avmbNdhIWbnxGD2qKfgClhc7Wb1J897bK4CsSzmM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/hvm: Fix UBSAN failure in do_hvm_op() printk
Message-Id: <E1rWIby-0002DG-EM@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 16:11:22 +0000

commit 9d701bc9abaf1e9ab458545a8f320d36dc54d686
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Jan 30 18:13:14 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 1 19:52:44 2024 +0000

    x86/hvm: Fix UBSAN failure in do_hvm_op() printk
    
    Tamas reported this UBSAN failure from fuzzing:
    
      (XEN) ================================================================================
      (XEN) UBSAN: Undefined behaviour in common/vsprintf.c:64:19
      (XEN) negation of -9223372036854775808 cannot be represented in type 'long long int':
      (XEN) ----[ Xen-4.19-unstable  x86_64  debug=y ubsan=y  Not tainted ]----
      ...
      (XEN) Xen call trace:
      (XEN)    [<ffff82d040307c1c>] R ubsan.c#ubsan_epilogue+0xa/0xd9
      (XEN)    [<ffff82d04030805d>] F __ubsan_handle_negate_overflow+0x99/0xce
      (XEN)    [<ffff82d04028868f>] F vsprintf.c#number+0x10a/0x93e
      (XEN)    [<ffff82d04028ac74>] F vsnprintf+0x19e2/0x1c56
      (XEN)    [<ffff82d04030a47a>] F console.c#vprintk_common+0x76/0x34d
      (XEN)    [<ffff82d04030a79e>] F printk+0x4d/0x4f
      (XEN)    [<ffff82d04040c42b>] F do_hvm_op+0x288e/0x28f5
      (XEN)    [<ffff82d04040d385>] F hvm_hypercall+0xad2/0x149a
      (XEN)    [<ffff82d0403cd072>] F vmx_vmexit_handler+0x1596/0x279c
      (XEN)    [<ffff82d0403d909b>] F vmx_asm_vmexit_handler+0xdb/0x200
    
    The problem is an unsigned -> signed converstion because of a bad
    formatter (%ld trying to format an unsigned long).
    
    We could fix it by swapping to %lu, but this is a useless printk() even in
    debug builds, so just drop it completely.
    
    Reported-by: Tamas K Lengyel <tamas@tklengyel.com>
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/hvm/hvm.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index e3bd9157d7..e8deeb0222 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -5147,12 +5147,9 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
         break;
 
     default:
-    {
-        gdprintk(XENLOG_DEBUG, "Bad HVM op %ld.\n", op);
         rc = -ENOSYS;
         break;
     }
-    }
 
     if ( rc == -ERESTART )
         rc = hypercall_create_continuation(__HYPERVISOR_hvm_op, "lh",
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 16:11:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 16:11:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675412.1050792 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIcA-0006Ie-FS; Sat, 03 Feb 2024 16:11:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675412.1050792; Sat, 03 Feb 2024 16:11:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIcA-0006IW-Cm; Sat, 03 Feb 2024 16:11:34 +0000
Received: by outflank-mailman (input) for mailman id 675412;
 Sat, 03 Feb 2024 16:11:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIc8-0006Hm-Mz
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIc8-0002uN-KT
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIc8-0002Dq-Hq
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=y7VdItx8syB32g+iWJJ4DQ/otvRVKZqLZu0c9mjnaVE=; b=I2i8115576M+DZMpjeZYIdcRnu
	DuH4XhJt8mRQLUerctbNbKbWbsnWGPalQLLV7JMn76yTSR2aa6d62EmV5zoUffHgULdpbYFIdv6sy
	3OgWWbCuIfGWa52lktphQGDpyUz9bByskVtlihcBM1UR6dmv5Q7+MkoljxQnqFl1WkDY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/sched: Fix UB shift in compat_set_timer_op()
Message-Id: <E1rWIc8-0002Dq-Hq@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 16:11:32 +0000

commit ae6d4fd876765e6d623eec67d14f5d0464be09cb
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Jan 30 20:44:34 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 1 19:52:44 2024 +0000

    xen/sched: Fix UB shift in compat_set_timer_op()
    
    Tamas reported this UBSAN failure from fuzzing:
    
      (XEN) ================================================================================
      (XEN) UBSAN: Undefined behaviour in common/sched/compat.c:48:37
      (XEN) left shift of negative value -2147425536
      (XEN) ----[ Xen-4.19-unstable  x86_64  debug=y ubsan=y  Not tainted ]----
      ...
      (XEN) Xen call trace:
      (XEN)    [<ffff82d040307c1c>] R ubsan.c#ubsan_epilogue+0xa/0xd9
      (XEN)    [<ffff82d040308afb>] F __ubsan_handle_shift_out_of_bounds+0x11a/0x1c5
      (XEN)    [<ffff82d040307758>] F compat_set_timer_op+0x41/0x43
      (XEN)    [<ffff82d04040e4cc>] F hvm_do_multicall_call+0x77f/0xa75
      (XEN)    [<ffff82d040519462>] F arch_do_multicall_call+0xec/0xf1
      (XEN)    [<ffff82d040261567>] F do_multicall+0x1dc/0xde3
      (XEN)    [<ffff82d04040d2b3>] F hvm_hypercall+0xa00/0x149a
      (XEN)    [<ffff82d0403cd072>] F vmx_vmexit_handler+0x1596/0x279c
      (XEN)    [<ffff82d0403d909b>] F vmx_asm_vmexit_handler+0xdb/0x200
    
    Left-shifting any negative value is strictly undefined behaviour in C, and
    the two parameters here come straight from the guest.
    
    The fuzzer happened to choose lo 0xf, hi 0x8000e300.
    
    Switch everything to be unsigned values, making the shift well defined.
    
    As GCC documents:
    
      As an extension to the C language, GCC does not use the latitude given in
      C99 and C11 only to treat certain aspects of signed '<<' as undefined.
      However, -fsanitize=shift (and -fsanitize=undefined) will diagnose such
      cases.
    
    this was deemed not to need an XSA.
    
    Note: The unsigned -> signed conversion for do_set_timer_op()'s s_time_t
    parameter is also well defined.  C makes it implementation defined, and GCC
    defines it as reduction modulo 2^N to be within range of the new type.
    
    Fixes: 2942f45e09fb ("Enable compatibility mode operation for HYPERVISOR_sched_op and HYPERVISOR_set_timer_op.")
    Reported-by: Tamas K Lengyel <tamas@tklengyel.com>
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/common/sched/compat.c    | 4 ++--
 xen/include/hypercall-defs.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/common/sched/compat.c b/xen/common/sched/compat.c
index d718e450d4..dd97593630 100644
--- a/xen/common/sched/compat.c
+++ b/xen/common/sched/compat.c
@@ -43,9 +43,9 @@ static int compat_poll(struct compat_sched_poll *compat)
 
 #include "core.c"
 
-int compat_set_timer_op(uint32_t lo, int32_t hi)
+int compat_set_timer_op(uint32_t lo, uint32_t hi)
 {
-    return do_set_timer_op(((s64)hi << 32) | lo);
+    return do_set_timer_op(((uint64_t)hi << 32) | lo);
 }
 
 #endif /* __COMMON_SCHED_COMPAT_C__ */
diff --git a/xen/include/hypercall-defs.c b/xen/include/hypercall-defs.c
index 6d361ddfce..47c093acc8 100644
--- a/xen/include/hypercall-defs.c
+++ b/xen/include/hypercall-defs.c
@@ -134,7 +134,7 @@ xenoprof_op(int op, void *arg)
 
 #ifdef CONFIG_COMPAT
 prefix: compat
-set_timer_op(uint32_t lo, int32_t hi)
+set_timer_op(uint32_t lo, uint32_t hi)
 multicall(multicall_entry_compat_t *call_list, uint32_t nr_calls)
 memory_op(unsigned int cmd, void *arg)
 #ifdef CONFIG_IOREQ_SERVER
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 16:11:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 16:11:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675413.1050797 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIcK-0006Qp-HX; Sat, 03 Feb 2024 16:11:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675413.1050797; Sat, 03 Feb 2024 16:11:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIcK-0006Qf-EB; Sat, 03 Feb 2024 16:11:44 +0000
Received: by outflank-mailman (input) for mailman id 675413;
 Sat, 03 Feb 2024 16:11:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIcI-0006Nb-OF
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIcI-0002uX-NX
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIcI-0002EP-Mf
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=pozZ4NSH82MMYqPO4fNFW3ztpIvzxm/cDozymrYHQxg=; b=cadplSWbshmGUjwrLIYEpICj2y
	u4OJKSiuGbKjePJ8+nPXbZcok2qXzwlHplmldfJh76b/4ioi/fqFqwFaloqCn/MLIYWr3ygSihj9w
	xbktHEoyv7R6XDRDlJxH/6Ciyl7duYjrB/RhWto5SLoq3i5k25sgVROiWiLHovrQqiMY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/boot: Add braces in reloc.c
Message-Id: <E1rWIcI-0002EP-Mf@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 16:11:42 +0000

commit fb22c33d17633ab16b16955ba691296f1ff230fc
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Jan 30 13:59:07 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 1 19:52:44 2024 +0000

    x86/boot: Add braces in reloc.c
    
    107 lines is an unreasonably large switch statement to live inside a
    brace-less for loop.  Drop the comment that's clumsily trying to cover the
    fact that this logic has wrong-looking indentation.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/boot/reloc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/boot/reloc.c b/xen/arch/x86/boot/reloc.c
index 77fdb2be05..4033557481 100644
--- a/xen/arch/x86/boot/reloc.c
+++ b/xen/arch/x86/boot/reloc.c
@@ -230,6 +230,7 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, uint32_t video_out)
     /* Put all needed data into mbi_out. */
     for ( tag = _p(ptr); (u32)tag - mbi_in < mbi_fix->total_size;
           tag = _p(ALIGN_UP((u32)tag + tag->size, MULTIBOOT2_TAG_ALIGN)) )
+    {
         switch ( tag->type )
         {
         case MULTIBOOT2_TAG_TYPE_BOOT_LOADER_NAME:
@@ -332,11 +333,12 @@ static multiboot_info_t *mbi2_reloc(uint32_t mbi_in, uint32_t video_out)
 #endif /* CONFIG_VIDEO */
 
         case MULTIBOOT2_TAG_TYPE_END:
-            goto end; /* Cannot "break;" here. */
+            goto end;
 
         default:
             break;
         }
+    }
 
  end:
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 16:11:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 16:11:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675414.1050800 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIcU-0006YU-IS; Sat, 03 Feb 2024 16:11:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675414.1050800; Sat, 03 Feb 2024 16:11:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIcU-0006YM-Fg; Sat, 03 Feb 2024 16:11:54 +0000
Received: by outflank-mailman (input) for mailman id 675414;
 Sat, 03 Feb 2024 16:11:52 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIcS-0006Y1-RH
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:52 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIcS-0002ug-QX
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIcS-0002Eo-Pi
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:11:52 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=bMmF4xgNEoJVY5L7e7F1g3moS/EwBjclf+9b6M8XPgc=; b=DK59mkYKeZYGJvYjhSfn5NnXy5
	fUWhkDHN31gMWSm4i522w5fsMLuY32MYKQHsbLEbg7F2EgJopl94cVhhSgPmfKKUU8xNzfgcMLYhD
	IRG1TjU8nvfh7T35Ub4ABPm2NnbnnZm6XTQa9enpK2Fk3Kt3oapxPUs3sQS11I3Vp5ws=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/traps: Annotate {l,c}star_enter() as nocall
Message-Id: <E1rWIcS-0002Eo-Pi@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 16:11:52 +0000

commit 4f0b0ffff379818f39f34d5682e7350f618db691
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Jan 30 15:06:32 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 1 19:52:44 2024 +0000

    x86/traps: Annotate {l,c}star_enter() as nocall
    
    ... as with other declarations which aren't legal to call from C.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/x86_64/traps.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/x86_64/traps.c b/xen/arch/x86/x86_64/traps.c
index 668605e5bc..02fdb3637d 100644
--- a/xen/arch/x86/x86_64/traps.c
+++ b/xen/arch/x86/x86_64/traps.c
@@ -333,8 +333,8 @@ static unsigned int write_stub_trampoline(
 
 DEFINE_PER_CPU(struct stubs, stubs);
 
-void lstar_enter(void);
-void cstar_enter(void);
+void nocall lstar_enter(void);
+void nocall cstar_enter(void);
 
 void subarch_percpu_traps_init(void)
 {
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 16:12:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 16:12:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675416.1050804 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIce-0006c4-KI; Sat, 03 Feb 2024 16:12:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675416.1050804; Sat, 03 Feb 2024 16:12:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIce-0006bw-H9; Sat, 03 Feb 2024 16:12:04 +0000
Received: by outflank-mailman (input) for mailman id 675416;
 Sat, 03 Feb 2024 16:12:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIcc-0006bW-US
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIcc-0002v6-TY
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIcc-0002Fm-Sd
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=qFe/712owj8f9LFnWtjyhcsNyqYdQu1E1peHhcIj4R8=; b=sgGgpH3JoTRoopoJ8cRyHhiiX9
	JFGKG4vmmqHY6R6wL4Q4CcDn0Eq6fSr63pPJkQPAeRrFmWAzvsrWFGROnHsLXjlwmdZdQ1LkWs01e
	NDDQbaGPCUM7ybJJlWbc7oioBNPQFBo05y+yRqI7LRgO0nT0yzgV587D66ITt3qgSvgE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/bitmap: Consistently use unsigned bits values
Message-Id: <E1rWIcc-0002Fm-Sd@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 16:12:02 +0000

commit 558e84b7ffec77cc8b1b4cf3256b5febc84f17f9
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Jan 31 17:05:47 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 1 19:52:44 2024 +0000

    xen/bitmap: Consistently use unsigned bits values
    
    Right now, most of the static inline helpers take an unsigned nbits quantity,
    and most of the library functions take a signed quanity.  Because
    BITMAP_LAST_WORD_MASK() is expressed as a divide, the compiler is forced to
    emit two different paths to get the correct semantics for signed division.
    
    Swap all signed bit-counts to being unsigned bit-counts for the simple cases.
    This includes the return value of bitmap_weight().
    
    Bloat-o-meter for a random x86 build reports:
      add/remove: 0/0 grow/shrink: 8/19 up/down: 167/-413 (-246)
    
    which all comes from compiler not emitting "dead" logic paths for negative bit
    counts.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/common/bitmap.c      | 24 ++++++++++++------------
 xen/include/xen/bitmap.h | 43 ++++++++++++++++++++++---------------------
 2 files changed, 34 insertions(+), 33 deletions(-)

diff --git a/xen/common/bitmap.c b/xen/common/bitmap.c
index 7d4551f782..c57b35f004 100644
--- a/xen/common/bitmap.c
+++ b/xen/common/bitmap.c
@@ -55,7 +55,7 @@ static void clamp_last_byte(uint8_t *bp, unsigned int nbits)
 		bp[nbits/8] &= (1U << remainder) - 1;
 }
 
-int __bitmap_empty(const unsigned long *bitmap, int bits)
+int __bitmap_empty(const unsigned long *bitmap, unsigned int bits)
 {
 	int k, lim = bits/BITS_PER_LONG;
 	for (k = 0; k < lim; ++k)
@@ -70,7 +70,7 @@ int __bitmap_empty(const unsigned long *bitmap, int bits)
 }
 EXPORT_SYMBOL(__bitmap_empty);
 
-int __bitmap_full(const unsigned long *bitmap, int bits)
+int __bitmap_full(const unsigned long *bitmap, unsigned int bits)
 {
 	int k, lim = bits/BITS_PER_LONG;
 	for (k = 0; k < lim; ++k)
@@ -86,7 +86,7 @@ int __bitmap_full(const unsigned long *bitmap, int bits)
 EXPORT_SYMBOL(__bitmap_full);
 
 int __bitmap_equal(const unsigned long *bitmap1,
-		const unsigned long *bitmap2, int bits)
+                   const unsigned long *bitmap2, unsigned int bits)
 {
 	int k, lim = bits/BITS_PER_LONG;
 	for (k = 0; k < lim; ++k)
@@ -101,7 +101,7 @@ int __bitmap_equal(const unsigned long *bitmap1,
 }
 EXPORT_SYMBOL(__bitmap_equal);
 
-void __bitmap_complement(unsigned long *dst, const unsigned long *src, int bits)
+void __bitmap_complement(unsigned long *dst, const unsigned long *src, unsigned int bits)
 {
 	int k, lim = bits/BITS_PER_LONG;
 	for (k = 0; k < lim; ++k)
@@ -113,7 +113,7 @@ void __bitmap_complement(unsigned long *dst, const unsigned long *src, int bits)
 EXPORT_SYMBOL(__bitmap_complement);
 
 void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
-				const unsigned long *bitmap2, int bits)
+                  const unsigned long *bitmap2, unsigned int bits)
 {
 	int k;
 	int nr = BITS_TO_LONGS(bits);
@@ -124,7 +124,7 @@ void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
 EXPORT_SYMBOL(__bitmap_and);
 
 void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
-				const unsigned long *bitmap2, int bits)
+                 const unsigned long *bitmap2, unsigned int bits)
 {
 	int k;
 	int nr = BITS_TO_LONGS(bits);
@@ -135,7 +135,7 @@ void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
 EXPORT_SYMBOL(__bitmap_or);
 
 void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
-				const unsigned long *bitmap2, int bits)
+                  const unsigned long *bitmap2, unsigned int bits)
 {
 	int k;
 	int nr = BITS_TO_LONGS(bits);
@@ -146,7 +146,7 @@ void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
 EXPORT_SYMBOL(__bitmap_xor);
 
 void __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
-				const unsigned long *bitmap2, int bits)
+                     const unsigned long *bitmap2, unsigned int bits)
 {
 	int k;
 	int nr = BITS_TO_LONGS(bits);
@@ -157,7 +157,7 @@ void __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
 EXPORT_SYMBOL(__bitmap_andnot);
 
 int __bitmap_intersects(const unsigned long *bitmap1,
-				const unsigned long *bitmap2, int bits)
+                        const unsigned long *bitmap2, unsigned int bits)
 {
 	int k, lim = bits/BITS_PER_LONG;
 	for (k = 0; k < lim; ++k)
@@ -172,7 +172,7 @@ int __bitmap_intersects(const unsigned long *bitmap1,
 EXPORT_SYMBOL(__bitmap_intersects);
 
 int __bitmap_subset(const unsigned long *bitmap1,
-				const unsigned long *bitmap2, int bits)
+                    const unsigned long *bitmap2, unsigned int bits)
 {
 	int k, lim = bits/BITS_PER_LONG;
 	for (k = 0; k < lim; ++k)
@@ -187,7 +187,7 @@ int __bitmap_subset(const unsigned long *bitmap1,
 EXPORT_SYMBOL(__bitmap_subset);
 
 #if BITS_PER_LONG == 32
-int __bitmap_weight(const unsigned long *bitmap, int bits)
+unsigned int __bitmap_weight(const unsigned long *bitmap, unsigned int bits)
 {
 	int k, w = 0, lim = bits/BITS_PER_LONG;
 
@@ -200,7 +200,7 @@ int __bitmap_weight(const unsigned long *bitmap, int bits)
 	return w;
 }
 #else
-int __bitmap_weight(const unsigned long *bitmap, int bits)
+unsigned int __bitmap_weight(const unsigned long *bitmap, unsigned int bits)
 {
 	int k, w = 0, lim = bits/BITS_PER_LONG;
 
diff --git a/xen/include/xen/bitmap.h b/xen/include/xen/bitmap.h
index 657390e32e..b9f980e919 100644
--- a/xen/include/xen/bitmap.h
+++ b/xen/include/xen/bitmap.h
@@ -66,25 +66,25 @@
  * lib/bitmap.c provides these functions:
  */
 
-extern int __bitmap_empty(const unsigned long *bitmap, int bits);
-extern int __bitmap_full(const unsigned long *bitmap, int bits);
-extern int __bitmap_equal(const unsigned long *bitmap1,
-                	const unsigned long *bitmap2, int bits);
-extern void __bitmap_complement(unsigned long *dst, const unsigned long *src,
-			int bits);
-extern void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
-			const unsigned long *bitmap2, int bits);
-extern void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
-			const unsigned long *bitmap2, int bits);
-extern void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
-			const unsigned long *bitmap2, int bits);
-extern void __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
-			const unsigned long *bitmap2, int bits);
-extern int __bitmap_intersects(const unsigned long *bitmap1,
-			const unsigned long *bitmap2, int bits);
-extern int __bitmap_subset(const unsigned long *bitmap1,
-			const unsigned long *bitmap2, int bits);
-extern int __bitmap_weight(const unsigned long *bitmap, int bits);
+int __bitmap_empty(const unsigned long *bitmap, unsigned int bits);
+int __bitmap_full(const unsigned long *bitmap, unsigned int bits);
+int __bitmap_equal(const unsigned long *bitmap1,
+                   const unsigned long *bitmap2, unsigned int bits);
+void __bitmap_complement(unsigned long *dst, const unsigned long *src,
+                         unsigned int bits);
+void __bitmap_and(unsigned long *dst, const unsigned long *bitmap1,
+                  const unsigned long *bitmap2, unsigned int bits);
+void __bitmap_or(unsigned long *dst, const unsigned long *bitmap1,
+                 const unsigned long *bitmap2, unsigned int bits);
+void __bitmap_xor(unsigned long *dst, const unsigned long *bitmap1,
+                  const unsigned long *bitmap2, unsigned int bits);
+void __bitmap_andnot(unsigned long *dst, const unsigned long *bitmap1,
+                     const unsigned long *bitmap2, unsigned int bits);
+int __bitmap_intersects(const unsigned long *bitmap1,
+                        const unsigned long *bitmap2, unsigned int bits);
+int __bitmap_subset(const unsigned long *bitmap1,
+                    const unsigned long *bitmap2, unsigned int bits);
+unsigned int __bitmap_weight(const unsigned long *bitmap, unsigned int bits);
 extern void __bitmap_set(unsigned long *map, unsigned int start, int len);
 extern void __bitmap_clear(unsigned long *map, unsigned int start, int len);
 
@@ -117,7 +117,7 @@ static inline void bitmap_zero(unsigned long *dst, unsigned int nbits)
 		memset(dst, 0, bitmap_bytes(nbits)));
 }
 
-static inline void bitmap_fill(unsigned long *dst, int nbits)
+static inline void bitmap_fill(unsigned long *dst, unsigned int nbits)
 {
 	size_t nlongs = BITS_TO_LONGS(nbits);
 
@@ -224,7 +224,8 @@ static inline int bitmap_full(const unsigned long *src, unsigned int nbits)
 		return __bitmap_full(src, nbits));
 }
 
-static inline int bitmap_weight(const unsigned long *src, int nbits)
+static inline unsigned int bitmap_weight(const unsigned long *src,
+                                         unsigned int nbits)
 {
 	return __bitmap_weight(src, nbits);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 16:12:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 16:12:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675417.1050808 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIco-0006g4-Mw; Sat, 03 Feb 2024 16:12:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675417.1050808; Sat, 03 Feb 2024 16:12:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIco-0006fw-K9; Sat, 03 Feb 2024 16:12:14 +0000
Received: by outflank-mailman (input) for mailman id 675417;
 Sat, 03 Feb 2024 16:12:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIcn-0006fZ-1i
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIcn-0002vG-0z
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIcm-0002GY-WF
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=AOODkOp2Wx+3eb3uEFv8+nLENAGmF2ZUrPd1TG5muok=; b=vXj+y3oGd+DByaROOZ2WjRn7/G
	n1V/8MtCANmpn0TjIptDPZYuvvNdH9rna5gAP6eKmRaBkTlgVqWV88bfIxR+icIJkP2pKVaJUC5il
	gYpI5xD+hSC7nxIu2P3SEUrJ/TvkKDnUnrk1WA8pW1I3YEK94WjUILyVoryavDwbQMqQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/ocaml: Bump minimum version to OCaml 4.05
Message-Id: <E1rWIcm-0002GY-WF@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 16:12:12 +0000

commit c852ca5c05f32d23928ce756b6f1114dd4aeb0cf
Author:     Edwin Török <edwin.torok@cloud.com>
AuthorDate: Wed Jan 31 10:42:48 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 1 19:52:44 2024 +0000

    tools/ocaml: Bump minimum version to OCaml 4.05
    
    Char.lowercase got removed in OCaml 5.0 (it has been deprecated since 2014),
    and doesn't build any more.
    
    Char.lowercase_ascii has existed since OCaml 4.03, so that is the new
    minimum version for oxenstored.
    
    However, OCaml 4.05 is the oldest new-enough version found in common distros,
    so pick this as a baseline.
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    Acked-by: Christian Lindig <christian.lindig@cloud.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    [Update CHANGELOG.md]
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 CHANGELOG.md                  | 1 +
 tools/configure               | 2 +-
 tools/configure.ac            | 2 +-
 tools/ocaml/xenstored/disk.ml | 2 +-
 4 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1f55c9c72d..bfe3b2b6f5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
 ### Changed
  - Changed flexible array definitions in public I/O interface headers to not
    use "1" as the number of array elements.
+ - The minimum supported OCaml toolchain version is now 4.05
  - On x86:
    - HVM PIRQs are disabled by default.
    - Reduce IOMMU setup time for hardware domain.
diff --git a/tools/configure b/tools/configure
index 0135a0059a..3d557234b3 100755
--- a/tools/configure
+++ b/tools/configure
@@ -6836,7 +6836,7 @@ else
                      -e 's/[^0-9]//g'`
 
 
-  ax_compare_version_B=`echo "4.02.0" | sed -e 's/\([0-9]*\)/Z\1Z/g' \
+  ax_compare_version_B=`echo "4.05.0" | sed -e 's/\([0-9]*\)/Z\1Z/g' \
                      -e 's/Z\([0-9]\)Z/Z0\1Z/g' \
                      -e 's/Z\([0-9][0-9]\)Z/Z0\1Z/g' \
                      -e 's/Z\([0-9][0-9][0-9]\)Z/Z0\1Z/g' \
diff --git a/tools/configure.ac b/tools/configure.ac
index 618ef8c63f..851887080c 100644
--- a/tools/configure.ac
+++ b/tools/configure.ac
@@ -336,7 +336,7 @@ AS_IF([test "x$ocamltools" = "xy"], [
             AC_MSG_ERROR([Ocaml tools enabled, but missing ocamlopt or ocamlfind])])
         ocamltools="n"
     ], [
-        AX_COMPARE_VERSION([$OCAMLVERSION], [lt], [4.02.0], [
+        AX_COMPARE_VERSION([$OCAMLVERSION], [lt], [4.05.0], [
             AS_IF([test "x$enable_ocamltools" = "xyes"], [
                 AC_MSG_ERROR([Your version of OCaml: $OCAMLVERSION is not supported])])
             ocamltools="n"
diff --git a/tools/ocaml/xenstored/disk.ml b/tools/ocaml/xenstored/disk.ml
index 91f945f2bd..ccaa048faf 100644
--- a/tools/ocaml/xenstored/disk.ml
+++ b/tools/ocaml/xenstored/disk.ml
@@ -30,7 +30,7 @@ let undec c =
   | _          -> raise (Failure "undecify")
 
 let unhex c =
-  let c = Char.lowercase c in
+  let c = Char.lowercase_ascii c in
   match c with
   | '0' .. '9' -> (Char.code c) - (Char.code '0')
   | 'a' .. 'f' -> (Char.code c) - (Char.code 'a') + 10
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 16:12:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 16:12:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675418.1050812 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIcy-0006ir-OZ; Sat, 03 Feb 2024 16:12:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675418.1050812; Sat, 03 Feb 2024 16:12:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIcy-0006ii-Lc; Sat, 03 Feb 2024 16:12:24 +0000
Received: by outflank-mailman (input) for mailman id 675418;
 Sat, 03 Feb 2024 16:12:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIcx-0006iP-6n
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIcx-0002vh-4F
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIcx-0002HB-3D
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=xZGe6a9wJNarZdYMBrBUZvlqNTRAQQp7D7wP66QvZ5k=; b=sRl3tngh61tAcsD6s83LsDIUU6
	nXa7NW6Tygu0UF3rM36qKCzKdCkjux6GGt9XXOz7qXuxnJNezZlIUjkvVzb9B76uMBSKrQTnfhToF
	VowVUDVYaghn3k4R2dkxy/E7SzPklPcmm51E/cLLI3p76oh2MYmL3CDkXQ2MTrMrXpTA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/spec-ctrl: Expose IPRED_CTRL to guests
Message-Id: <E1rWIcx-0002HB-3D@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 16:12:23 +0000

commit 4dd6760706848de30f7c8b5f83462b9bcb070c91
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Jan 30 10:13:58 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 1 19:52:44 2024 +0000

    x86/spec-ctrl: Expose IPRED_CTRL to guests
    
    The CPUID feature bit signals the presence of the IPRED_DIS_{U,S} controls in
    SPEC_CTRL MSR, first available in Intel AlderLake and Sapphire Rapids CPUs.
    
    Xen already knows how to context switch MSR_SPEC_CTRL properly between guest
    and hypervisor context.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/msr.c                          | 6 ++++--
 xen/include/public/arch-x86/cpufeatureset.h | 2 +-
 xen/tools/gen-cpuid.py                      | 3 ++-
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index c33dc78cd8..54d3752e93 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -309,8 +309,8 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val)
 
 /*
  * Caller to confirm that MSR_SPEC_CTRL is available.  Intel and AMD have
- * separate CPUID features for this functionality, but only set will be
- * active.
+ * separate CPUID features for some of this functionality, but only one
+ * vendors-worth will be active on a single host.
  */
 uint64_t msr_spec_ctrl_valid_bits(const struct cpu_policy *cp)
 {
@@ -324,6 +324,8 @@ uint64_t msr_spec_ctrl_valid_bits(const struct cpu_policy *cp)
     return (SPEC_CTRL_IBRS | SPEC_CTRL_STIBP |
             (ssbd       ? SPEC_CTRL_SSBD       : 0) |
             (psfd       ? SPEC_CTRL_PSFD       : 0) |
+            (cp->feat.ipred_ctrl
+             ? (SPEC_CTRL_IPRED_DIS_U | SPEC_CTRL_IPRED_DIS_S) : 0) |
             0);
 }
 
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index c897c20401..e586e141c3 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -302,7 +302,7 @@ XEN_CPUFEATURE(INTEL_PPIN,         12*32+ 0) /*   Protected Processor Inventory
 
 /* Intel-defined CPU features, CPUID level 0x00000007:2.edx, word 13 */
 XEN_CPUFEATURE(INTEL_PSFD,         13*32+ 0) /*A  MSR_SPEC_CTRL.PSFD */
-XEN_CPUFEATURE(IPRED_CTRL,         13*32+ 1) /*   MSR_SPEC_CTRL.IPRED_DIS_* */
+XEN_CPUFEATURE(IPRED_CTRL,         13*32+ 1) /*A  MSR_SPEC_CTRL.IPRED_DIS_* */
 XEN_CPUFEATURE(RRSBA_CTRL,         13*32+ 2) /*   MSR_SPEC_CTRL.RRSBA_DIS_* */
 XEN_CPUFEATURE(DDP_CTRL,           13*32+ 3) /*   MSR_SPEC_CTRL.DDP_DIS_U */
 XEN_CPUFEATURE(BHI_CTRL,           13*32+ 4) /*   MSR_SPEC_CTRL.BHI_DIS_S */
diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py
index df5222a3cd..45fab5e75d 100755
--- a/xen/tools/gen-cpuid.py
+++ b/xen/tools/gen-cpuid.py
@@ -319,7 +319,8 @@ def crunch_numbers(state):
         # IBRSB/IBRS, and we pass this MSR directly to guests.  Treating them
         # as dependent features simplifies Xen's logic, and prevents the guest
         # from seeing implausible configurations.
-        IBRSB: [STIBP, SSBD, INTEL_PSFD, EIBRS],
+        IBRSB: [STIBP, SSBD, INTEL_PSFD, EIBRS,
+                IPRED_CTRL],
         IBRS: [AMD_STIBP, AMD_SSBD, PSFD, AUTO_IBRS,
                IBRS_ALWAYS, IBRS_FAST, IBRS_SAME_MODE],
         IBPB: [IBPB_RET, SBPB, IBPB_BRTYPE],
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 16:12:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 16:12:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675419.1050815 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWId8-0006mq-PW; Sat, 03 Feb 2024 16:12:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675419.1050815; Sat, 03 Feb 2024 16:12:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWId8-0006mi-N2; Sat, 03 Feb 2024 16:12:34 +0000
Received: by outflank-mailman (input) for mailman id 675419;
 Sat, 03 Feb 2024 16:12:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWId7-0006lL-86
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWId7-0002vt-7J
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWId7-0002He-6V
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=o2KgbCXdJflO3xLCm7ljjK6mNZvQg3UAkDVhgdsY+qM=; b=WlbS/4HDMLXU2sido3fhnsls2M
	IHe7kFBEbJYui7Djfw3RIOgzR4L9g9eftG81BWlct2uDsG7VaG90degOZbZ3dkifCY06jmUmZ44Yt
	ScUrNHx87J4gpoy+8L7CTWCXvwS/Y73z9kATRaDiiRn0Z4CucCWYMx6nbUmT5C57/TrQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/spec-ctrl: Expose RRSBA_CTRL to guests
Message-Id: <E1rWId7-0002He-6V@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 16:12:33 +0000

commit 478e4787fa64b621061177a7843c452e9a19916d
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Jan 30 10:13:59 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 1 19:52:44 2024 +0000

    x86/spec-ctrl: Expose RRSBA_CTRL to guests
    
    The CPUID feature bit signals the presence of the RRSBA_DIS_{U,S} controls in
    SPEC_CTRL MSR, first available in Intel AlderLake and Sapphire Rapids CPUs.
    
    Xen already knows how to context switch MSR_SPEC_CTRL properly between guest
    and hypervisor context.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/msr.c                          | 2 ++
 xen/include/public/arch-x86/cpufeatureset.h | 2 +-
 xen/tools/gen-cpuid.py                      | 2 +-
 3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index 54d3752e93..d42f5bd6ef 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -326,6 +326,8 @@ uint64_t msr_spec_ctrl_valid_bits(const struct cpu_policy *cp)
             (psfd       ? SPEC_CTRL_PSFD       : 0) |
             (cp->feat.ipred_ctrl
              ? (SPEC_CTRL_IPRED_DIS_U | SPEC_CTRL_IPRED_DIS_S) : 0) |
+            (cp->feat.rrsba_ctrl
+             ? (SPEC_CTRL_RRSBA_DIS_U | SPEC_CTRL_RRSBA_DIS_S) : 0) |
             0);
 }
 
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index e586e141c3..bade4edab3 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -303,7 +303,7 @@ XEN_CPUFEATURE(INTEL_PPIN,         12*32+ 0) /*   Protected Processor Inventory
 /* Intel-defined CPU features, CPUID level 0x00000007:2.edx, word 13 */
 XEN_CPUFEATURE(INTEL_PSFD,         13*32+ 0) /*A  MSR_SPEC_CTRL.PSFD */
 XEN_CPUFEATURE(IPRED_CTRL,         13*32+ 1) /*A  MSR_SPEC_CTRL.IPRED_DIS_* */
-XEN_CPUFEATURE(RRSBA_CTRL,         13*32+ 2) /*   MSR_SPEC_CTRL.RRSBA_DIS_* */
+XEN_CPUFEATURE(RRSBA_CTRL,         13*32+ 2) /*A  MSR_SPEC_CTRL.RRSBA_DIS_* */
 XEN_CPUFEATURE(DDP_CTRL,           13*32+ 3) /*   MSR_SPEC_CTRL.DDP_DIS_U */
 XEN_CPUFEATURE(BHI_CTRL,           13*32+ 4) /*   MSR_SPEC_CTRL.BHI_DIS_S */
 XEN_CPUFEATURE(MCDT_NO,            13*32+ 5) /*A  MCDT_NO */
diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py
index 45fab5e75d..1c6d762441 100755
--- a/xen/tools/gen-cpuid.py
+++ b/xen/tools/gen-cpuid.py
@@ -320,7 +320,7 @@ def crunch_numbers(state):
         # as dependent features simplifies Xen's logic, and prevents the guest
         # from seeing implausible configurations.
         IBRSB: [STIBP, SSBD, INTEL_PSFD, EIBRS,
-                IPRED_CTRL],
+                IPRED_CTRL, RRSBA_CTRL],
         IBRS: [AMD_STIBP, AMD_SSBD, PSFD, AUTO_IBRS,
                IBRS_ALWAYS, IBRS_FAST, IBRS_SAME_MODE],
         IBPB: [IBPB_RET, SBPB, IBPB_BRTYPE],
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 16:12:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 16:12:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675420.1050820 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIdI-0006pX-RO; Sat, 03 Feb 2024 16:12:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675420.1050820; Sat, 03 Feb 2024 16:12:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIdI-0006pP-OT; Sat, 03 Feb 2024 16:12:44 +0000
Received: by outflank-mailman (input) for mailman id 675420;
 Sat, 03 Feb 2024 16:12:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIdH-0006pE-BH
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:43 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIdH-0002w0-Ad
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIdH-0002I5-9f
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=y7gCwczxXBfI2nfI/2fa/FsaLqhJRzaU1AzDUfzzIbk=; b=nVfnODSxG/m9KVPcoMLzJewbHp
	wjr0NKc6P0PpuhwlhYHUjUBdZafSUkx/0UuDL7auLXWuuzTlwyfVsvBwrz7UeD0/4TPieTpJmWbKQ
	jZ4+M15KG/72RK5IZodJvErV/DaVLm+PjHCQD81AupjLfmm1qod3I7HHOB1qoOXPTz/4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/spec-ctrl: Expose BHI_CTRL to guests
Message-Id: <E1rWIdH-0002I5-9f@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 16:12:43 +0000

commit 583f1d0950529f3517b1741c2b21a028a82ba831
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Jan 30 10:14:00 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 1 19:52:44 2024 +0000

    x86/spec-ctrl: Expose BHI_CTRL to guests
    
    The CPUID feature bit signals the presence of the BHI_DIS_S control in
    SPEC_CTRL MSR, first available in Intel AlderLake and Sapphire Rapids CPUs
    
    Xen already knows how to context switch MSR_SPEC_CTRL properly between guest
    and hypervisor context.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/msr.c                          | 1 +
 xen/include/public/arch-x86/cpufeatureset.h | 2 +-
 xen/tools/gen-cpuid.py                      | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index d42f5bd6ef..9babd441f9 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -328,6 +328,7 @@ uint64_t msr_spec_ctrl_valid_bits(const struct cpu_policy *cp)
              ? (SPEC_CTRL_IPRED_DIS_U | SPEC_CTRL_IPRED_DIS_S) : 0) |
             (cp->feat.rrsba_ctrl
              ? (SPEC_CTRL_RRSBA_DIS_U | SPEC_CTRL_RRSBA_DIS_S) : 0) |
+            (cp->feat.bhi_ctrl   ? SPEC_CTRL_BHI_DIS_S : 0) |
             0);
 }
 
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index bade4edab3..be5c1b748e 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -305,7 +305,7 @@ XEN_CPUFEATURE(INTEL_PSFD,         13*32+ 0) /*A  MSR_SPEC_CTRL.PSFD */
 XEN_CPUFEATURE(IPRED_CTRL,         13*32+ 1) /*A  MSR_SPEC_CTRL.IPRED_DIS_* */
 XEN_CPUFEATURE(RRSBA_CTRL,         13*32+ 2) /*A  MSR_SPEC_CTRL.RRSBA_DIS_* */
 XEN_CPUFEATURE(DDP_CTRL,           13*32+ 3) /*   MSR_SPEC_CTRL.DDP_DIS_U */
-XEN_CPUFEATURE(BHI_CTRL,           13*32+ 4) /*   MSR_SPEC_CTRL.BHI_DIS_S */
+XEN_CPUFEATURE(BHI_CTRL,           13*32+ 4) /*A  MSR_SPEC_CTRL.BHI_DIS_S */
 XEN_CPUFEATURE(MCDT_NO,            13*32+ 5) /*A  MCDT_NO */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:1.ecx, word 14 */
diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py
index 1c6d762441..25d329ce48 100755
--- a/xen/tools/gen-cpuid.py
+++ b/xen/tools/gen-cpuid.py
@@ -320,7 +320,7 @@ def crunch_numbers(state):
         # as dependent features simplifies Xen's logic, and prevents the guest
         # from seeing implausible configurations.
         IBRSB: [STIBP, SSBD, INTEL_PSFD, EIBRS,
-                IPRED_CTRL, RRSBA_CTRL],
+                IPRED_CTRL, RRSBA_CTRL, BHI_CTRL],
         IBRS: [AMD_STIBP, AMD_SSBD, PSFD, AUTO_IBRS,
                IBRS_ALWAYS, IBRS_FAST, IBRS_SAME_MODE],
         IBPB: [IBPB_RET, SBPB, IBPB_BRTYPE],
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 16:12:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 16:12:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675421.1050824 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIdS-0006t2-T3; Sat, 03 Feb 2024 16:12:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675421.1050824; Sat, 03 Feb 2024 16:12:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIdS-0006sv-Pz; Sat, 03 Feb 2024 16:12:54 +0000
Received: by outflank-mailman (input) for mailman id 675421;
 Sat, 03 Feb 2024 16:12:53 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIdR-0006si-Eq
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:53 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIdR-0002wG-E1
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:53 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIdR-0002IU-D1
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:12:53 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=LiIslhOXGJ9IXguyzho6NecXIyyDq5X7jKWvUpNhZ2Q=; b=BlFh6qqlIb+CR2whE9ESbUwcap
	OIBR0mWSkhJPwLTLSLqmsP2rAtgKSqKamuqovG9ywYcO3voNOFICugwHVfj3srxo/rHU5P8FNjpwH
	2xGANosyDTdwDQakErmO2YMhuqqb7olk5Fxj3j79fc4Iuz0Z/L/jZYbKYgm+aFz4XGe0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86: Remove gdbstub
Message-Id: <E1rWIdR-0002IU-D1@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 16:12:53 +0000

commit d182f9feae6d8085121fbf5f8978e9a43b90da41
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Jan 26 19:57:01 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 1 19:52:44 2024 +0000

    x86: Remove gdbstub
    
    In 13y of working on Xen, I've never seen seen it used.  The implementation
    was introduced (commit b69f92f3012e, Jul 28 2004) with known issues such as:
    
      /* Resuming after we've stopped used to work, but more through luck
         than any actual intention.  It doesn't at the moment. */
    
    which appear to have gone unfixed for the 20 years since.
    
    Nowadays there are more robust ways of inspecting crashed state, such as a
    kexec crash kernel, or running Xen in a VM.
    
    This will allow us to clean up some hooks around the codebase which are
    proving awkward for other tasks.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 CHANGELOG.md                      |   1 +
 docs/misc/xen-command-line.pandoc |   7 -
 xen/Kconfig.debug                 |   7 -
 xen/arch/x86/Makefile             |   1 -
 xen/arch/x86/gdbstub.c            |  91 -----
 xen/arch/x86/x86_64/Makefile      |   2 -
 xen/arch/x86/x86_64/gdbstub.c     | 150 --------
 xen/common/Makefile               |   1 -
 xen/common/gdbstub.c              | 748 --------------------------------------
 xen/include/xen/gdbstub.h         | 103 ------
 10 files changed, 1 insertion(+), 1110 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index bfe3b2b6f5..f9874f9bb0 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -25,6 +25,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
 - /usr/bin/pygrub symlink.  This was deprecated in Xen 4.2 (2012) but left for
   compatibility reasons.  VMs configured with bootloader="/usr/bin/pygrub"
   should be updated to just bootloader="pygrub".
+- The Xen gdbstub on x86.
 
 ## [4.18.0](https://xenbits.xenproject.org/gitweb/?p=xen.git;a=shortlog;h=RELEASE-4.18.0) - 2023-11-16
 
diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
index 8e65f8bd18..be76be8d53 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -1242,13 +1242,6 @@ requirement can be relaxed.  This option is particularly useful for nested
 virtualization, to allow the L1 hypervisor to use EPT even if the L0 hypervisor
 does not provide `VM_ENTRY_LOAD_GUEST_PAT`.
 
-### gdb
-> `= com1[H,L] | com2[H,L] | dbgp`
-
-> Default: ``
-
-Specify which console gdbstub should use. See **console**.
-
 ### gnttab
 > `= List of [ max-ver:<integer>, transitive=<bool>, transfer=<bool> ]`
 
diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug
index e19e9d4881..fa81853e93 100644
--- a/xen/Kconfig.debug
+++ b/xen/Kconfig.debug
@@ -13,13 +13,6 @@ config DEBUG
 
 if DEBUG || EXPERT
 
-config CRASH_DEBUG
-	bool "Crash Debugging Support"
-	depends on X86
-	---help---
-	  If you want to attach gdb to Xen to debug Xen if it crashes
-	  then say Y.
-
 config GDBSX
 	bool "Guest debugging with gdbsx"
 	depends on X86
diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index 9f326b9e32..26d8740529 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -35,7 +35,6 @@ obj-y += e820.o
 obj-y += emul-i8254.o
 obj-y += extable.o
 obj-y += flushtlb.o
-obj-$(CONFIG_CRASH_DEBUG) += gdbstub.o
 obj-$(CONFIG_GDBSX) += gdbsx.o
 obj-y += hypercall.o
 obj-y += i387.o
diff --git a/xen/arch/x86/gdbstub.c b/xen/arch/x86/gdbstub.c
deleted file mode 100644
index 961cae0be7..0000000000
--- a/xen/arch/x86/gdbstub.c
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * x86-specific gdb stub routines
- * based on x86 cdb(xen/arch/x86/cdb.c), but Extensively modified.
- * 
- * Copyright (C) 2006 Isaku Yamahata <yamahata at valinux co jp>
- *                    VA Linux Systems Japan. K.K.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; If not, see <http://www.gnu.org/licenses/>.
- */
-#include <asm/uaccess.h>
-#include <asm/x86-defns.h>
-
-#include <xen/gdbstub.h>
-
-u16
-gdb_arch_signal_num(struct cpu_user_regs *regs, unsigned long cookie)
-{
-    return 5;   /* TRAP signal.  see include/gdb/signals.h */
-}
-
-/*
- * Use __copy_*_user to make us page-fault safe, but not otherwise restrict
- * our access to the full virtual address space.
- */
-unsigned int
-gdb_arch_copy_from_user(void *dest, const void *src, unsigned len)
-{
-    return copy_from_unsafe(dest, src, len);
-}
-
-unsigned int 
-gdb_arch_copy_to_user(void *dest, const void *src, unsigned len)
-{
-    return copy_to_unsafe(dest, src, len);
-}
-
-void
-gdb_arch_print_state(struct cpu_user_regs *regs)
-{
-    /* XXX */
-}
-
-void
-gdb_arch_enter(struct cpu_user_regs *regs)
-{
-    /* nothing */
-}
-
-void
-gdb_arch_exit(struct cpu_user_regs *regs)
-{
-    /* nothing */
-}
-
-void 
-gdb_arch_resume(struct cpu_user_regs *regs,
-                unsigned long addr, unsigned long type,
-                struct gdb_context *ctx)
-{
-    if ( addr != -1UL )
-        regs->rip = addr;
-
-    regs->eflags &= ~X86_EFLAGS_TF;
-
-    /* Set eflags.RF to ensure we do not re-enter. */
-    regs->eflags |= X86_EFLAGS_RF;
-
-    /* Set the trap flag if we are single stepping. */
-    if ( type == GDB_STEP )
-        regs->eflags |= X86_EFLAGS_TF;
-}
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/xen/arch/x86/x86_64/Makefile b/xen/arch/x86/x86_64/Makefile
index 213b789c42..472b2bab52 100644
--- a/xen/arch/x86/x86_64/Makefile
+++ b/xen/arch/x86/x86_64/Makefile
@@ -12,5 +12,3 @@ obj-$(CONFIG_COMPAT) += domain.o
 obj-$(CONFIG_COMPAT) += cpu_idle.o
 obj-$(CONFIG_COMPAT) += cpufreq.o
 obj-bin-$(CONFIG_KEXEC) += kexec_reloc.o
-
-obj-$(CONFIG_CRASH_DEBUG)   += gdbstub.o
diff --git a/xen/arch/x86/x86_64/gdbstub.c b/xen/arch/x86/x86_64/gdbstub.c
deleted file mode 100644
index 8287124dfb..0000000000
--- a/xen/arch/x86/x86_64/gdbstub.c
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * x86_64 -specific gdb stub routines
- * 
- * Copyright (C) 2007 Dan Doucette   ddoucette@teradici.com
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include <xen/gdbstub.h>
-
-#define GDB_REG64(r) gdb_write_to_packet_hex(r, sizeof(u64), ctx)
-#define GDB_REG32(r)  gdb_write_to_packet_hex(r, sizeof(u32), ctx)
-
-void 
-gdb_arch_read_reg_array(struct cpu_user_regs *regs, struct gdb_context *ctx)
-{
-    GDB_REG64(regs->rax);
-    GDB_REG64(regs->rbx);
-    GDB_REG64(regs->rcx);
-    GDB_REG64(regs->rdx);
-    GDB_REG64(regs->rsi);
-    GDB_REG64(regs->rdi);
-    GDB_REG64(regs->rbp);
-    GDB_REG64(regs->rsp);
-
-    GDB_REG64(regs->r8);
-    GDB_REG64(regs->r9);
-    GDB_REG64(regs->r10);
-    GDB_REG64(regs->r11);
-    GDB_REG64(regs->r12);
-    GDB_REG64(regs->r13);
-    GDB_REG64(regs->r14);
-    GDB_REG64(regs->r15);
-
-    GDB_REG64(regs->rip);
-    GDB_REG32(regs->eflags);
-
-    GDB_REG32(regs->cs);
-    GDB_REG32(regs->ss);
-    GDB_REG32(regs->ds);
-    GDB_REG32(regs->es);
-    GDB_REG32(regs->fs);
-    GDB_REG32(regs->gs);
-
-    gdb_send_packet(ctx);
-}
-
-void 
-gdb_arch_write_reg_array(struct cpu_user_regs *regs, const char* buf,
-                         struct gdb_context *ctx)
-{
-    gdb_send_reply("", ctx);
-}
-
-void 
-gdb_arch_read_reg(unsigned long regnum, struct cpu_user_regs *regs,
-                  struct gdb_context *ctx)
-{
-    switch (regnum)
-    {
-        case 0: GDB_REG64(regs->rax); break;
-        case 1: GDB_REG64(regs->rbx); break;
-        case 2: GDB_REG64(regs->rcx); break;
-        case 3: GDB_REG64(regs->rdx); break;
-        case 4: GDB_REG64(regs->rsi); break;
-        case 5: GDB_REG64(regs->rdi); break;
-        case 6: GDB_REG64(regs->rbp); break;
-        case 7: GDB_REG64(regs->rsp); break;
-
-        case 8: GDB_REG64(regs->r8); break;
-        case 9: GDB_REG64(regs->r9); break;
-        case 10: GDB_REG64(regs->r10); break;
-        case 11: GDB_REG64(regs->r11); break;
-        case 12: GDB_REG64(regs->r12); break;
-        case 13: GDB_REG64(regs->r13); break;
-        case 14: GDB_REG64(regs->r14); break;
-        case 15: GDB_REG64(regs->r15); break;
-
-        case 16: GDB_REG64(regs->rip); break;
-        case 17: GDB_REG32(regs->rflags); break;
-        case 18: GDB_REG32(regs->cs); break;
-        case 19: GDB_REG32(regs->ss); break;
-        case 20: GDB_REG32(regs->ds); break;
-        case 21: GDB_REG32(regs->es); break;
-        case 22: GDB_REG32(regs->fs); break;
-        case 23: GDB_REG32(regs->gs); break;
-        default:
-            GDB_REG64(0xbaadf00ddeadbeef);
-            break;
-    }
-    gdb_send_packet(ctx);
-}
-
-void 
-gdb_arch_write_reg(unsigned long regnum, unsigned long val, 
-                    struct cpu_user_regs *regs, struct gdb_context *ctx)
-{
-    switch (regnum)
-    {
-        case 0: regs->rax = val; break;
-        case 1: regs->rbx = val; break;
-        case 2: regs->rcx = val; break;
-        case 3: regs->rdx = val; break;
-        case 4: regs->rsi = val; break;
-        case 5: regs->rdi = val; break;
-        case 6: regs->rbp = val; break;
-        case 7: regs->rsp = val; break;
-
-        case 8: regs->r8 = val; break;
-        case 9: regs->r9 = val; break;
-        case 10: regs->r10 = val; break;
-        case 11: regs->r11 = val; break;
-        case 12: regs->r12 = val; break;
-        case 13: regs->r13 = val; break;
-        case 14: regs->r14 = val; break;
-        case 15: regs->r15 = val; break;
-
-        case 16: regs->rip = val; break;
-        case 17: regs->rflags = (u32)val; break;
-        case 18: regs->cs = (u16)val; break;
-        case 19: regs->ss = (u16)val; break;
-        case 20: regs->ds = (u16)val; break;
-        case 21: regs->es = (u16)val; break;
-        case 22: regs->fs = (u16)val; break;
-        case 23: regs->gs = (u16)val; break;
-        default:
-            break;
-    }
-    gdb_send_reply("OK", ctx);
-}
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/xen/common/Makefile b/xen/common/Makefile
index 69d6aa626c..e5eee19a85 100644
--- a/xen/common/Makefile
+++ b/xen/common/Makefile
@@ -12,7 +12,6 @@ obj-$(CONFIG_OVERLAY_DTB) += dt-overlay.o
 obj-y += event_2l.o
 obj-y += event_channel.o
 obj-y += event_fifo.o
-obj-$(CONFIG_CRASH_DEBUG) += gdbstub.o
 obj-$(CONFIG_GRANT_TABLE) += grant_table.o
 obj-y += guestcopy.o
 obj-bin-y += gunzip.init.o
diff --git a/xen/common/gdbstub.c b/xen/common/gdbstub.c
deleted file mode 100644
index df8d122bce..0000000000
--- a/xen/common/gdbstub.c
+++ /dev/null
@@ -1,748 +0,0 @@
-/*
- * Copyright (C) 2005 Jimi Xenidis <jimix@watson.ibm.com>, IBM Corporation
- * Copyright (C) 2006 Isaku Yamahata <yamahata at valinux co jp>
- *                    VA Linux Systems Japan. K.K.
- * 
- * gdbstub arch neutral part
- * Based on x86 cdb (xen/arch/x86/cdb.c) and ppc gdbstub(xen/common/gdbstub.c)
- * But extensively modified.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; If not, see <http://www.gnu.org/licenses/>.
- */
-
-/*
- * gdbstub: implements the architecture independant parts of the
- * gdb remote protocol.
- */
-
-/* We try to avoid assuming much about what the rest of the system is
-   doing.  In particular, dynamic memory allocation is out of the
-   question. */
-
-/* Resuming after we've stopped used to work, but more through luck
-   than any actual intention.  It doesn't at the moment. */
-
-#include <xen/lib.h>
-#include <xen/spinlock.h>
-#include <xen/serial.h>
-#include <xen/irq.h>
-#include <xen/watchdog.h>
-#include <xen/init.h>
-#include <xen/param.h>
-#include <xen/smp.h>
-#include <xen/console.h>
-#include <xen/errno.h>
-#include <xen/delay.h>
-#include <xen/gdbstub.h>
-
-#include <asm/byteorder.h>
-
-/* Printk isn't particularly safe just after we've trapped to the
-   debugger. so avoid it. */
-#define dbg_printk(...)
-/*#define dbg_printk(...)   printk(__VA_ARGS__)*/
-
-#define GDB_RETRY_MAX   10
-
-struct gdb_cpu_info
-{
-    atomic_t paused;
-    atomic_t ack;
-};
-
-static struct gdb_cpu_info gdb_cpu[NR_CPUS];
-static atomic_t gdb_smp_paused_count;
-
-static void gdb_smp_pause(void);
-static void gdb_smp_resume(void);
-
-static char __initdata opt_gdb[30];
-string_param("gdb", opt_gdb);
-
-static void cf_check gdbstub_console_puts(const char *str, size_t nr);
-
-/* value <-> char (de)serialzers */
-static char
-hex2char(unsigned long x)
-{
-    const char array[] = "0123456789abcdef";
-    return array[x & 15];
-}
-
-static unsigned int
-char2hex(unsigned char c)
-{
-    if ( (c >= '0') && (c <= '9') )
-        return c - '0';
-    else if ( (c >= 'a') && (c <= 'f') )
-        return c - 'a' + 10;
-    else if ( (c >= 'A') && (c <= 'F') )
-        return c - 'A' + 10;
-    else
-        BUG();
-    return -1;
-}
-
-static unsigned char
-str2hex(const char *str)
-{
-    return (char2hex(str[0]) << 4) | char2hex(str[1]);
-}
-
-static unsigned long
-str2ulong(const char *str, unsigned long bytes)
-{
-    unsigned long x = 0;
-    unsigned long i = 0;
-
-    while ( *str && (i < (bytes * 2)) )
-    {
-        x <<= 4;
-        x += char2hex(*str);
-        ++str;
-        ++i;
-    }
-
-    return x;
-}
-
-static unsigned long
-str_to_native_ulong(const char *str)
-{
-    unsigned long x = 0, i = 0;
-
-    while ( *str && (i < BYTES_PER_LONG) )
-    {
-#ifdef __BIG_ENDIAN
-        x <<= 8;
-        x += str2hex(str);
-#elif defined(__LITTLE_ENDIAN)
-        x += (unsigned long)str2hex(str) << (i*8);
-#else
-# error unknown endian
-#endif
-        str += 2;
-        i++;
-    }
-
-    return x;
-}
-
-/* gdb io wrappers */
-static signed long
-gdb_io_write(const char *buf, unsigned long len, struct gdb_context *ctx)
-{
-    int i;
-    for ( i = 0; i < len; i++ )
-        serial_putc(ctx->serhnd, buf[i]);
-    return i;
-}
-
-static int
-gdb_io_write_char(u8 data, struct gdb_context *ctx)
-{
-    return gdb_io_write((char*)&data, 1, ctx);
-}
-
-static unsigned char
-gdb_io_read(struct gdb_context *ctx)
-{
-    return serial_getc(ctx->serhnd);
-}
-
-/* Receive a command.  Returns -1 on csum error, 0 otherwise. */
-/* Does not acknowledge. */
-static int 
-attempt_receive_packet(struct gdb_context *ctx)
-{
-    u8 csum;
-    u8 received_csum;
-    u8 ch;
-
-    /* Skip over everything up to the first '$' */
-    while ( (ch = gdb_io_read(ctx)) != '$' )
-        continue;
-
-    csum = 0;
-    for ( ctx->in_bytes = 0;
-          ctx->in_bytes < sizeof(ctx->in_buf);
-          ctx->in_bytes++ )
-    {
-        ch = gdb_io_read(ctx);
-        if ( ch == '#' )
-            break;
-        ctx->in_buf[ctx->in_bytes] = ch;
-        csum += ch;
-    }
-
-    if ( ctx->in_bytes == sizeof(ctx->in_buf) )
-    {
-        dbg_printk("WARNING: GDB sent a stupidly big packet.\n");
-        return -1;
-    }
-
-    ctx->in_buf[ctx->in_bytes] = '\0';
-    received_csum = char2hex(gdb_io_read(ctx)) * 16 +
-        char2hex(gdb_io_read(ctx));
-
-    return (received_csum == csum) ? 0 : -1;
-}
-
-/* Receive a command, discarding up to ten packets with csum
- * errors.  Acknowledges all received packets. */
-static int 
-receive_command(struct gdb_context *ctx)
-{
-    int r, count = 0;
-
-    count = 0;
-    do {
-        r = attempt_receive_packet(ctx);
-        gdb_io_write_char((r < 0) ? '-' : '+', ctx);
-        count++;
-    } while ( (r < 0) && (count < GDB_RETRY_MAX) );
-
-    return r;
-}
-
-/* routines to send reply packets */
-
-static void 
-gdb_start_packet(struct gdb_context *ctx)
-{
-    ctx->out_buf[0] = '$';
-    ctx->out_offset = 1;
-    ctx->out_csum = 0;
-}
-
-static void 
-gdb_write_to_packet_char(u8 data, struct gdb_context *ctx)
-{
-    ctx->out_csum += data;
-    ctx->out_buf[ctx->out_offset] = data;
-    ctx->out_offset++;
-}
-
-void 
-gdb_write_to_packet(const char *buf, int count, struct gdb_context *ctx)
-{
-    int x;
-    for ( x = 0; x < count; x++ )
-        gdb_write_to_packet_char(buf[x], ctx);
-}
-
-void 
-gdb_write_to_packet_str(const char *buf, struct gdb_context *ctx)
-{
-    gdb_write_to_packet(buf, strlen(buf), ctx);
-}
-
-void
-gdb_write_to_packet_hex(unsigned long x, int int_size, struct gdb_context *ctx)
-{
-    char buf[sizeof(unsigned long) * 2 + 1];
-    int i, width = int_size * 2;
-
-    buf[sizeof(unsigned long) * 2] = 0;
-
-    switch ( int_size )
-    {
-    case sizeof(u8):
-    case sizeof(u16):
-    case sizeof(u32):
-    case sizeof(u64):
-        break;
-    default:
-        dbg_printk("WARNING: %s x: %#lx int_size: %d\n",
-                   __func__, x, int_size);
-        break;
-    }
-
-#ifdef __BIG_ENDIAN
-    i = sizeof(unsigned long) * 2
-    do {
-        buf[--i] = hex2char(x & 15);
-        x >>= 4;
-    } while ( x );
-
-    while ( (i + width) > (sizeof(unsigned long) * 2) )
-        buf[--i] = '0';
-
-    gdb_write_to_packet(&buf[i], width, ctx);
-#elif defined(__LITTLE_ENDIAN)
-    i = 0;
-    while ( i < width )
-    {
-        buf[i++] = hex2char(x>>4);
-        buf[i++] = hex2char(x);
-        x >>= 8;
-    }
-    gdb_write_to_packet(buf, width, ctx);
-#else
-# error unknown endian
-#endif
-}
-
-static int
-gdb_check_ack(struct gdb_context *ctx)
-{
-    u8 c = gdb_io_read(ctx);
-
-    switch ( c )
-    {
-    case '+':
-        return 1;
-    case '-':
-        return 0;
-    default:
-        printk("Bad ack: %c\n", c);
-        return 0;
-    }
-}
-
-/* Return 0 if the reply was successfully received, !0 otherwise. */
-void 
-gdb_send_packet(struct gdb_context *ctx)
-{
-    char buf[3];
-    int count;
-
-    snprintf(buf, sizeof(buf), "%.02x\n", ctx->out_csum);
-
-    gdb_write_to_packet_char('#', ctx);
-    gdb_write_to_packet(buf, 2, ctx);
-
-    count = 0;
-    do {
-        gdb_io_write(ctx->out_buf, ctx->out_offset, ctx);
-    } while ( !gdb_check_ack(ctx) && (count++ < GDB_RETRY_MAX) );
-
-    if ( count == GDB_RETRY_MAX )
-        dbg_printk("WARNING: %s reached max retry %d\n",
-                   __func__, GDB_RETRY_MAX);
-}
-
-void 
-gdb_send_reply(const char *buf, struct gdb_context *ctx)
-{
-    gdb_start_packet(ctx);
-    gdb_write_to_packet_str(buf, ctx);
-    gdb_send_packet(ctx);
-}
-
-/* arch neutral command handlers */
-
-static void 
-gdb_cmd_signum(struct gdb_context *ctx)
-{
-    gdb_write_to_packet_char('S', ctx);
-    gdb_write_to_packet_hex(ctx->signum, sizeof(ctx->signum), ctx);
-    gdb_send_packet(ctx);
-}
-
-static void 
-gdb_cmd_read_mem(unsigned long addr, unsigned long length,
-                 struct gdb_context *ctx)
-{
-    int x, r;
-    unsigned char val;
-
-    dbg_printk("Memory read starting at %lx, length %lx.\n", addr,
-               length);
-
-    for ( x = 0; x < length; x++ )
-    {
-        r = gdb_arch_copy_from_user(&val, (void *)(addr + x), 1);
-        if ( r != 0 )
-        {
-            dbg_printk("Error reading from %lx.\n", addr + x);
-            break;
-        }
-        gdb_write_to_packet_hex(val, sizeof(val), ctx);
-    }
-
-    if ( x == 0 )
-        gdb_write_to_packet_str("E05", ctx);
-
-    dbg_printk("Read done.\n");
-
-    gdb_send_packet(ctx);
-}
-
-static void 
-gdb_cmd_write_mem(unsigned long addr, unsigned long length,
-                  const char *buf, struct gdb_context *ctx)
-{
-    int x, r;
-    unsigned char val;
-
-    dbg_printk("Memory write starting at %lx, length %lx.\n", addr, length);
-
-    for ( x = 0; x < length; x++, addr++, buf += 2 )
-    {
-        val = str2ulong(buf, sizeof(val));
-        r = gdb_arch_copy_to_user((void*)addr, (void*)&val, 1);
-        if ( r != 0 )
-        {
-            dbg_printk("Error writing to %lx.\n", addr);
-            break;
-        }
-    }
-
-    if (x == length)
-        gdb_write_to_packet_str("OK", ctx);
-    else
-        gdb_write_to_packet_str("E11", ctx);
-
-    dbg_printk("Write done.\n");
-
-    gdb_send_packet(ctx);
-}
-
-static void
-gdbstub_attach(struct gdb_context *ctx)
-{
-    if ( ctx->currently_attached )
-        return;    
-    ctx->currently_attached = 1;
-    ctx->console_steal_id = console_steal(ctx->serhnd, gdbstub_console_puts);
-}
-
-static void
-gdbstub_detach(struct gdb_context *ctx)
-{
-    if ( !ctx->currently_attached )
-        return;
-    ctx->currently_attached = 0;
-    console_giveback(ctx->console_steal_id);
-}
-
-/* command dispatcher */
-static int 
-process_command(struct cpu_user_regs *regs, struct gdb_context *ctx)
-{
-    const char *ptr;
-    unsigned long addr, length, val;
-    int resume = 0;
-    unsigned long type = GDB_CONTINUE;
-
-    /* XXX check ctx->in_bytes >= 2 or similar. */
-
-    gdb_start_packet(ctx);
-    switch ( ctx->in_buf[0] )
-    {
-    case '?':    /* query signal number */
-        gdb_cmd_signum(ctx);
-        break;
-    case 'H':    /* thread operations */
-        gdb_send_reply("OK", ctx);
-        break;
-    case 'g': /* Read registers */
-        gdb_arch_read_reg_array(regs, ctx);
-        break;
-    case 'G': /* Write registers */
-        gdb_arch_write_reg_array(regs, ctx->in_buf + 1, ctx);
-        break;
-    case 'm': /* Read memory */
-        addr = simple_strtoul(ctx->in_buf + 1, &ptr, 16);
-        if ( (ptr == (ctx->in_buf + 1)) || (ptr[0] != ',') )
-        {
-            gdb_send_reply("E03", ctx);
-            return 0;
-        }
-        length = simple_strtoul(ptr + 1, &ptr, 16);
-        if ( ptr[0] != 0 )
-        {
-            gdb_send_reply("E04", ctx);
-            return 0;
-        }
-        gdb_cmd_read_mem(addr, length, ctx);
-        break;
-    case 'M': /* Write memory */
-        addr = simple_strtoul(ctx->in_buf + 1, &ptr, 16);
-        if ( (ptr == (ctx->in_buf + 1)) || (ptr[0] != ',') )
-        {
-            gdb_send_reply("E03", ctx);
-            return 0;
-        }
-        length = simple_strtoul(ptr + 1, &ptr, 16);
-        if ( ptr[0] != ':')
-        {
-            gdb_send_reply("E04", ctx);
-            return 0;
-        }
-        gdb_cmd_write_mem(addr, length, ptr + 1, ctx);
-        break;
-    case 'p': /* read register */
-        addr = simple_strtoul(ctx->in_buf + 1, &ptr, 16);
-        if ( ptr == (ctx->in_buf + 1) )
-        {
-            gdb_send_reply("E03", ctx);
-            return 0;
-        }
-        if ( ptr[0] != 0 )
-        {
-            gdb_send_reply("E04", ctx);
-            return 0;
-        }
-        gdb_arch_read_reg(addr, regs, ctx);
-        break;
-    case 'P': /* write register */
-        addr = simple_strtoul(ctx->in_buf + 1, &ptr, 16);
-        if ( ptr == (ctx->in_buf + 1) )
-        {
-            gdb_send_reply("E03", ctx);
-            return 0;
-        }
-        if ( ptr[0] != '=' )
-        {
-            gdb_send_reply("E04", ctx);
-            return 0;
-        }
-        ptr++;
-        val = str_to_native_ulong(ptr);
-        gdb_arch_write_reg(addr, val, regs, ctx);
-        break;
-    case 'D':
-    case 'k':
-        gdbstub_detach(ctx);
-        gdb_send_reply("OK", ctx);
-        ctx->connected = 0;
-        resume = 1;
-        break;
-    case 's': /* Single step */
-        type = GDB_STEP;
-    case 'c': /* Resume at current address */
-        addr = ~((unsigned long)0);
-
-        if ( ctx->in_buf[1] )
-            addr = str2ulong(&ctx->in_buf[1], sizeof(unsigned long));
-        gdbstub_attach(ctx);
-        resume = 1;
-        gdb_arch_resume(regs, addr, type, ctx);
-        break;
-    default:
-        gdb_send_reply("", ctx);
-        break;
-    }
-    return resume;
-}
-
-static struct gdb_context
-__gdb_ctx = {
-    .serhnd  = -1,
-    .running = ATOMIC_INIT(1),
-    .signum  = 1
-};
-static struct gdb_context *gdb_ctx = &__gdb_ctx;
-
-static void cf_check gdbstub_console_puts(const char *str, size_t nr)
-{
-    const char *p;
-
-    gdb_start_packet(gdb_ctx);
-    gdb_write_to_packet_char('O', gdb_ctx);
-
-    for ( p = str; nr > 0; p++, nr-- )
-    {
-        gdb_write_to_packet_char(hex2char((*p>>4) & 0x0f), gdb_ctx );
-        gdb_write_to_packet_char(hex2char((*p) & 0x0f), gdb_ctx );
-    }
-
-    gdb_send_packet(gdb_ctx);
-}
-
-/* trap handler: main entry point */
-int 
-__trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie)
-{
-    int rc = 0;
-    unsigned long flags;
-
-    if ( gdb_ctx->serhnd < 0 )
-    {
-        printk("Debugging connection not set up.\n");
-        return -EBUSY;
-    }
-
-    /* We rely on our caller to ensure we're only on one processor
-     * at a time... We should probably panic here, but given that
-     * we're a debugger we should probably be a little tolerant of
-     * things going wrong. */
-    /* We don't want to use a spin lock here, because we're doing
-       two distinct things:
-
-       1 -- we don't want to run on more than one processor at a time,
-            and
-       2 -- we want to do something sensible if we re-enter ourselves.
-
-       Spin locks are good for 1, but useless for 2. */
-    if ( !atomic_dec_and_test(&gdb_ctx->running) )
-    {
-        printk("WARNING WARNING WARNING: Avoiding recursive gdb.\n");
-        atomic_inc(&gdb_ctx->running);
-        return -EBUSY;
-    }
-
-    if ( !gdb_ctx->connected )
-    {
-        printk("GDB connection activated.\n");
-        gdb_arch_print_state(regs);
-        gdb_ctx->connected = 1;
-    }
-
-    gdb_smp_pause();
-
-    local_irq_save(flags);
-
-    watchdog_disable();
-    console_start_sync();
-
-    gdb_arch_enter(regs);
-    gdb_ctx->signum = gdb_arch_signal_num(regs, cookie);
-
-    /* If gdb is already attached, tell it we've stopped again. */
-    if ( gdb_ctx->currently_attached )
-    {
-        gdb_start_packet(gdb_ctx);
-        gdb_cmd_signum(gdb_ctx);
-    }
-
-    do {
-        if ( receive_command(gdb_ctx) < 0 )
-        {
-            dbg_printk("Error in GDB session...\n");
-            rc = -EIO;
-            break;
-        }
-    } while ( process_command(regs, gdb_ctx) == 0 );
-
-    gdb_smp_resume();
-
-    gdb_arch_exit(regs);
-    console_end_sync();
-    watchdog_enable();
-    atomic_inc(&gdb_ctx->running);
-
-    local_irq_restore(flags);
-
-    return rc;
-}
-
-static int __init cf_check initialise_gdb(void)
-{
-    if ( *opt_gdb == '\0' )
-        return 0;
-
-    gdb_ctx->serhnd = serial_parse_handle(opt_gdb);
-    if ( gdb_ctx->serhnd == -1 )
-    {
-        printk("Bad gdb= option '%s'\n", opt_gdb);
-        return 0;
-    }
-
-    serial_start_sync(gdb_ctx->serhnd);
-
-    printk("GDB stub initialised.\n");
-
-    return 0;
-}
-presmp_initcall(initialise_gdb);
-
-static void cf_check gdb_pause_this_cpu(void *unused)
-{
-    unsigned long flags;
-
-    local_irq_save(flags);
-
-    atomic_set(&gdb_cpu[smp_processor_id()].ack, 1);
-    atomic_inc(&gdb_smp_paused_count);
-
-    while ( atomic_read(&gdb_cpu[smp_processor_id()].paused) )
-        mdelay(1);
-
-    atomic_dec(&gdb_smp_paused_count);
-    atomic_set(&gdb_cpu[smp_processor_id()].ack, 0);
-
-    /* Restore interrupts */
-    local_irq_restore(flags);
-}
-
-static void gdb_smp_pause(void)
-{
-    int timeout = 100;
-    int cpu;
-
-    for_each_online_cpu(cpu)
-    {
-        atomic_set(&gdb_cpu[cpu].ack, 0);
-        atomic_set(&gdb_cpu[cpu].paused, 1);
-    }
-
-    atomic_set(&gdb_smp_paused_count, 0);
-
-    smp_call_function(gdb_pause_this_cpu, NULL, /* dont wait! */0);
-
-    /* Wait 100ms for all other CPUs to enter pause loop */
-    while ( (atomic_read(&gdb_smp_paused_count) < (num_online_cpus() - 1)) 
-            && (timeout-- > 0) )
-        mdelay(1);
-
-    if ( atomic_read(&gdb_smp_paused_count) < (num_online_cpus() - 1) )
-    {
-        printk("GDB: Not all CPUs have paused, missing CPUs ");
-        for_each_online_cpu(cpu)
-        {
-            if ( (cpu != smp_processor_id()) &&
-                 !atomic_read(&gdb_cpu[cpu].ack) )
-                printk("%d ", cpu);
-        }
-        printk("\n");
-    }
-}
-
-static void gdb_smp_resume(void)
-{
-    int cpu;
-    int timeout = 100;
-
-    for_each_online_cpu(cpu)
-        atomic_set(&gdb_cpu[cpu].paused, 0);
-
-    /* Make sure all CPUs resume */
-    while ( (atomic_read(&gdb_smp_paused_count) > 0)
-            && (timeout-- > 0) )
-        mdelay(1);
-
-    if ( atomic_read(&gdb_smp_paused_count) > 0 )
-    {
-        printk("GDB: Not all CPUs have resumed execution, missing CPUs ");
-        for_each_online_cpu(cpu)
-        {
-            if ( (cpu != smp_processor_id()) &&
-                 atomic_read(&gdb_cpu[cpu].ack) )
-                printk("%d ", cpu);
-        }
-        printk("\n");
-    }
-}
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
diff --git a/xen/include/xen/gdbstub.h b/xen/include/xen/gdbstub.h
deleted file mode 100644
index d2efeb0e3a..0000000000
--- a/xen/include/xen/gdbstub.h
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2005 Hollis Blanchard <hollisb@us.ibm.com>, IBM Corporation
- * Copyright (C) 2006 Isaku Yamahata <yamahata at valinux co jp>
- *                    VA Linux Systems Japan. K.K.
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- * 
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- * 
- * You should have received a copy of the GNU General Public License
- * along with this program; If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef __XEN_GDBSTUB_H__
-#define __XEN_GDBSTUB_H__
-
-#include <xen/page-size.h>
-#include <asm/atomic.h>
-
-#ifdef CONFIG_CRASH_DEBUG
-
-struct cpu_user_regs;
-
-struct gdb_context {
-    int                 serhnd;           /* handle on our serial line */
-    int                 console_steal_id; /* handle on stolen console */
-    bool                currently_attached;
-    atomic_t            running;
-    unsigned long       connected;
-    u8                  signum;
-
-    char                in_buf[PAGE_SIZE];
-    unsigned long       in_bytes;
-
-    char                out_buf[PAGE_SIZE];
-    unsigned long       out_offset;
-    u8                  out_csum;
-};
-
-/* interface to arch specific routines */
-void gdb_write_to_packet(
-    const char *buf, int count, struct gdb_context *ctx);
-void gdb_write_to_packet_hex(
-    unsigned long x, int int_size, struct gdb_context *ctx);
-    /* ... writes in target native byte order as required by gdb spec. */
-void gdb_send_packet(struct gdb_context *ctx);
-void gdb_send_reply(const char *buf, struct gdb_context *ctx);
-
-/* gdb stub trap handler: entry point */
-int __trap_to_gdb(struct cpu_user_regs *regs, unsigned long cookie);
-
-/* arch specific routines */
-u16 gdb_arch_signal_num(
-    struct cpu_user_regs *regs, unsigned long cookie);
-void gdb_arch_read_reg_array(
-    struct cpu_user_regs *regs, struct gdb_context *ctx);
-void gdb_arch_write_reg_array(
-    struct cpu_user_regs *regs, const char* buf, struct gdb_context *ctx);
-void gdb_arch_read_reg(
-    unsigned long regnum, struct cpu_user_regs *regs, struct gdb_context *ctx);
-void gdb_arch_write_reg(
-    unsigned long regnum, unsigned long val, struct cpu_user_regs *regs, 
-    struct gdb_context *ctx);
-unsigned int gdb_arch_copy_from_user(
-    void *dest, const void *src, unsigned len);
-unsigned int gdb_arch_copy_to_user(
-    void *dest, const void *src, unsigned len);
-void gdb_arch_resume(
-    struct cpu_user_regs *regs, unsigned long addr,
-    unsigned long type, struct gdb_context *ctx);
-void gdb_arch_print_state(struct cpu_user_regs *regs);
-void gdb_arch_enter(struct cpu_user_regs *regs);
-void gdb_arch_exit(struct cpu_user_regs *regs);
-
-#define GDB_CONTINUE     0
-#define GDB_STEP         1
-
-#define SIGILL           4
-#define SIGTRAP          5
-#define SIGBUS           7
-#define SIGFPE           8
-#define SIGSEGV         11
-#define SIGALRM         14
-#define SIGTERM         15
-
-#endif
-
-#endif /* __XEN_GDBSTUB_H__ */
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * End:
- */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 03 16:13:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 03 Feb 2024 16:13:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.675423.1050828 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIdb-0006wL-WF; Sat, 03 Feb 2024 16:13:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 675423.1050828; Sat, 03 Feb 2024 16:13:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rWIdb-0006wD-TZ; Sat, 03 Feb 2024 16:13:03 +0000
Received: by outflank-mailman (input) for mailman id 675423;
 Sat, 03 Feb 2024 16:13:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIdb-0006w7-IE
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:13:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIdb-0002y7-HM
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:13:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rWIdb-0002J2-GV
 for xen-changelog@lists.xenproject.org; Sat, 03 Feb 2024 16:13:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=JiU7KtfOPvCQ9R4pY9MMD62SfwrJP4TuzQkjVvP/p+M=; b=Zar14GqdREHX+CKsc3zkoOHG8N
	WRIYNi1J1qk7wA3TiSWpx/84ht3K6B4Q2c8MqnWFVMFfh/yCdub5qPxwSBLqs8PD7pJFfybJXeqDY
	xjd5FTKLnB57nyI5tqbx3rpXeChtmbDhjGcLu8+k6EY5puiIkploaw0nd2tVAoeweU2I=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen: Remove debugger.h
Message-Id: <E1rWIdb-0002J2-GV@xenbits.xenproject.org>
Date: Sat, 03 Feb 2024 16:13:03 +0000

commit 3f819af8a796c0e2f798dd301ec8c3f8cccbc9fc
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Jan 26 19:55:18 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 1 19:52:44 2024 +0000

    xen: Remove debugger.h
    
    With x86 having dropped gdbstub, Xen's only debugger has gone.
    
    Drop xen/debugger.h and remove the hooks spread around the codebase.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/include/asm/bug.h      |  2 --
 xen/arch/x86/include/asm/debugger.h | 30 -------------------------
 xen/arch/x86/traps.c                | 30 ++++---------------------
 xen/common/bug.c                    | 27 -----------------------
 xen/common/keyhandler.c             | 22 +------------------
 xen/common/shutdown.c               |  2 --
 xen/drivers/char/console.c          |  3 ---
 xen/include/xen/bug.h               |  4 ----
 xen/include/xen/debugger.h          | 44 -------------------------------------
 9 files changed, 5 insertions(+), 159 deletions(-)

diff --git a/xen/arch/x86/include/asm/bug.h b/xen/arch/x86/include/asm/bug.h
index 7fe879a8cc..e748b6c2f2 100644
--- a/xen/arch/x86/include/asm/bug.h
+++ b/xen/arch/x86/include/asm/bug.h
@@ -21,8 +21,6 @@
 
 #ifndef __ASSEMBLY__
 
-#define BUG_DEBUGGER_TRAP_FATAL(regs) debugger_trap_fatal(X86_EXC_GP,regs)
-
 #define BUG_INSTR       "ud2"
 #define BUG_ASM_CONST   "c"
 
diff --git a/xen/arch/x86/include/asm/debugger.h b/xen/arch/x86/include/asm/debugger.h
deleted file mode 100644
index a5c299c6c3..0000000000
--- a/xen/arch/x86/include/asm/debugger.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/******************************************************************************
- * xen/arch/x86/include/asm/debugger.h
- *
- * x86-specific debugger hooks.
- */
-#ifndef __X86_DEBUGGER_H__
-#define __X86_DEBUGGER_H__
-
-#include <xen/gdbstub.h>
-#include <xen/stdbool.h>
-
-#include <asm/x86-defns.h>
-
-/* Returns true if GDB handled the trap, or it is surviveable. */
-static inline bool debugger_trap_fatal(
-    unsigned int vector, struct cpu_user_regs *regs)
-{
-    int rc = __trap_to_gdb(regs, vector);
-
-    if ( rc == 0 )
-        return true;
-
-    return vector == X86_EXC_BP;
-}
-
-/* Int3 is a trivial way to gather cpu_user_regs context. */
-#define debugger_trap_immediate() __asm__ __volatile__ ( "int3" )
-
-#endif /* __X86_DEBUGGER_H__ */
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 7724306116..5f4bcc0537 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -25,7 +25,6 @@
 #include <xen/shutdown.h>
 #include <xen/guest_access.h>
 #include <asm/regs.h>
-#include <xen/debugger.h>
 #include <xen/delay.h>
 #include <xen/event.h>
 #include <xen/spinlock.h>
@@ -835,11 +834,6 @@ void fatal_trap(const struct cpu_user_regs *regs, bool show_remote)
 
 void asmlinkage do_unhandled_trap(struct cpu_user_regs *regs)
 {
-    unsigned int trapnr = regs->entry_vector;
-
-    if ( debugger_trap_fatal(trapnr, regs) )
-        return;
-
     fatal_trap(regs, false);
 }
 
@@ -941,9 +935,6 @@ void asmlinkage do_trap(struct cpu_user_regs *regs)
         return;
 
  hardware_trap:
-    if ( debugger_trap_fatal(trapnr, regs) )
-        return;
-
     fatal_trap(regs, false);
 }
 
@@ -1190,9 +1181,6 @@ void asmlinkage do_invalid_op(struct cpu_user_regs *regs)
     if ( likely(extable_fixup(regs, true)) )
         return;
 
-    if ( debugger_trap_fatal(X86_EXC_UD, regs) )
-        return;
-
     show_execution_state(regs);
     panic("FATAL TRAP: vector = %d (invalid opcode)\n", X86_EXC_UD);
 }
@@ -1206,9 +1194,8 @@ void asmlinkage do_int3(struct cpu_user_regs *regs)
         if ( likely(extable_fixup(regs, true)) )
             return;
 
-        if ( !debugger_trap_fatal(X86_EXC_BP, regs) )
-            printk(XENLOG_DEBUG "Hit embedded breakpoint at %p [%ps]\n",
-                   _p(regs->rip), _p(regs->rip));
+        printk(XENLOG_DEBUG "Hit embedded breakpoint at %p [%ps]\n",
+               _p(regs->rip), _p(regs->rip));
 
         return;
     }
@@ -1294,9 +1281,6 @@ void do_general_protection(struct cpu_user_regs *regs)
         return;
 
  hardware_gp:
-    if ( debugger_trap_fatal(X86_EXC_GP, regs) )
-        return;
-
     show_execution_state(regs);
     panic("GENERAL PROTECTION FAULT\n[error_code=%04x]\n", regs->error_code);
 }
@@ -1620,9 +1604,6 @@ void asmlinkage do_page_fault(struct cpu_user_regs *regs)
         }
 
     fatal:
-        if ( debugger_trap_fatal(X86_EXC_PF, regs) )
-            return;
-
         show_execution_state(regs);
         show_page_walk(addr);
         panic("FATAL PAGE FAULT\n"
@@ -1933,11 +1914,8 @@ void asmlinkage do_debug(struct cpu_user_regs *regs)
                 return;
             }
 #endif
-            if ( !debugger_trap_fatal(X86_EXC_DB, regs) )
-            {
-                WARN();
-                regs->eflags &= ~X86_EFLAGS_TF;
-            }
+            WARN();
+            regs->eflags &= ~X86_EFLAGS_TF;
         }
 
         /*
diff --git a/xen/common/bug.c b/xen/common/bug.c
index ca166e102b..5fbe703a81 100644
--- a/xen/common/bug.c
+++ b/xen/common/bug.c
@@ -1,23 +1,4 @@
 #include <xen/bug.h>
-/*
- * Ideally <xen/debugger.h> should be included in <asm/bug.h>
- * but an issue with compilation can occur as <xen/debugger.h> uses
- * BUG/ASSERT/etc macros inside but they will be defined later in
- * <xen/bug.h> after return from inclusion of <asm/bug.h>:
- * 
- * <xen/bug.h>:
- *  ...
- *   <asm/bug.h>:
- *     ...
- *     <xen/debugger.h> -> some of included header in it uses BUG/ASSERT/etc
- *     ...
- *  ...
- *  #define BUG() ...
- *  ...
- *  #define ASSERT() ...
- *  ...
- */
-#include <xen/debugger.h>
 #include <xen/errno.h>
 #include <xen/kernel.h>
 #include <xen/livepatch.h>
@@ -96,10 +77,6 @@ int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc)
 
     case BUGFRAME_bug:
         printk("Xen BUG at %s%s:%d\n", prefix, filename, lineno);
-
-        if ( BUG_DEBUGGER_TRAP_FATAL(regs) )
-            break;
-
         show_execution_state(regs);
         panic("Xen BUG at %s%s:%d\n", prefix, filename, lineno);
 
@@ -111,10 +88,6 @@ int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc)
 
         printk("Assertion '%s' failed at %s%s:%d\n",
                predicate, prefix, filename, lineno);
-
-        if ( BUG_DEBUGGER_TRAP_FATAL(regs) )
-            break;
-
         show_execution_state(regs);
         panic("Assertion '%s' failed at %s%s:%d\n",
               predicate, prefix, filename, lineno);
diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c
index 99a2d72a02..f131034d33 100644
--- a/xen/common/keyhandler.c
+++ b/xen/common/keyhandler.c
@@ -3,7 +3,6 @@
  */
 
 #include <asm/regs.h>
-#include <xen/debugger.h>
 #include <xen/delay.h>
 #include <xen/keyhandler.h>
 #include <xen/param.h>
@@ -29,8 +28,7 @@ static bool alt_key_handling;
 static keyhandler_fn_t cf_check show_handlers, cf_check dump_hwdom_registers,
     cf_check dump_domains, cf_check read_clocks;
 static irq_keyhandler_fn_t cf_check do_toggle_alt_key, cf_check dump_registers,
-    cf_check reboot_machine, cf_check run_all_keyhandlers,
-    cf_check do_debug_key;
+    cf_check reboot_machine, cf_check run_all_keyhandlers;
 
 static struct keyhandler {
     union {
@@ -57,7 +55,6 @@ static struct keyhandler {
     IRQ_KEYHANDLER('R', reboot_machine, "reboot machine", 0),
         KEYHANDLER('t', read_clocks, "display multi-cpu clock info", 1),
         KEYHANDLER('0', dump_hwdom_registers, "dump Dom0 registers", 1),
-    IRQ_KEYHANDLER('%', do_debug_key, "trap to xendbg", 0),
     IRQ_KEYHANDLER('*', run_all_keyhandlers, "print all diagnostics", 0),
 
 #ifdef CONFIG_PERF_COUNTERS
@@ -503,23 +500,6 @@ static void cf_check run_all_keyhandlers(
     tasklet_schedule(&run_all_keyhandlers_tasklet);
 }
 
-static void cf_check do_debugger_trap_fatal(struct cpu_user_regs *regs)
-{
-    (void)debugger_trap_fatal(0xf001, regs);
-
-    /* Prevent tail call optimisation, which confuses xendbg. */
-    barrier();
-}
-
-static void cf_check do_debug_key(unsigned char key, struct cpu_user_regs *regs)
-{
-    printk("'%c' pressed -> trapping into debugger\n", key);
-    if ( regs )
-        do_debugger_trap_fatal(regs);
-    else
-        run_in_exception_handler(do_debugger_trap_fatal);
-}
-
 static void cf_check do_toggle_alt_key(
     unsigned char key, struct cpu_user_regs *regs)
 {
diff --git a/xen/common/shutdown.c b/xen/common/shutdown.c
index dfd5e41097..5f8141edc6 100644
--- a/xen/common/shutdown.c
+++ b/xen/common/shutdown.c
@@ -2,7 +2,6 @@
 #include <xen/lib.h>
 #include <xen/param.h>
 #include <xen/sched.h>
-#include <xen/debugger.h>
 #include <xen/domain.h>
 #include <xen/delay.h>
 #include <xen/watchdog.h>
@@ -40,7 +39,6 @@ void hwdom_shutdown(u8 reason)
         machine_halt();
 
     case SHUTDOWN_crash:
-        debugger_trap_immediate();
         printk("Hardware Dom%u crashed: ", hardware_domain->domain_id);
         kexec_crash(CRASHREASON_HWDOM);
         reboot_or_halt();
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 0666564ec9..dce0226e87 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -15,7 +15,6 @@
 #include <xen/init.h>
 #include <xen/event.h>
 #include <xen/console.h>
-#include <xen/debugger.h>
 #include <xen/param.h>
 #include <xen/serial.h>
 #include <xen/softirq.h>
@@ -1297,8 +1296,6 @@ void panic(const char *fmt, ...)
 
     spin_unlock_irqrestore(&lock, flags);
 
-    debugger_trap_immediate();
-
     kexec_crash(CRASHREASON_PANIC);
 
     if ( opt_noreboot )
diff --git a/xen/include/xen/bug.h b/xen/include/xen/bug.h
index 8cca4486a4..4bd0be5088 100644
--- a/xen/include/xen/bug.h
+++ b/xen/include/xen/bug.h
@@ -16,10 +16,6 @@
 
 #ifndef __ASSEMBLY__
 
-#ifndef BUG_DEBUGGER_TRAP_FATAL
-#define BUG_DEBUGGER_TRAP_FATAL(regs) 0
-#endif
-
 #include <xen/macros.h>
 #include <xen/types.h>
 
diff --git a/xen/include/xen/debugger.h b/xen/include/xen/debugger.h
deleted file mode 100644
index 72684268af..0000000000
--- a/xen/include/xen/debugger.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/******************************************************************************
- * Arch specific debuggers should implement:
- *
- * debugger_trap_fatal():
- *  Called when Xen is about to give up and crash. Typically you will use this
- *  hook to drop into a debug session. It can also be used to hook off
- *  deliberately caused traps (which you then handle and return non-zero).
- *
- * debugger_trap_immediate():
- *  Called if we want to drop into a debugger now.  This is essentially the
- *  same as debugger_trap_fatal, except that we use the current register state
- *  rather than the state which was in effect when we took the trap.
- *  For example: if we're dying because of an unhandled exception, we call
- *  debugger_trap_fatal; if we're dying because of a panic() we call
- *  debugger_trap_immediate().
- */
-
-#ifndef __XEN_DEBUGGER_H__
-#define __XEN_DEBUGGER_H__
-
-#ifdef CONFIG_CRASH_DEBUG
-
-#include <asm/debugger.h>
-
-#else
-
-#include <xen/stdbool.h>
-
-struct cpu_user_regs;
-
-static inline bool debugger_trap_fatal(
-    unsigned int vector, const struct cpu_user_regs *regs)
-{
-    return false;
-}
-
-static inline void debugger_trap_immediate(void)
-{
-}
-
-#endif /* CONFIG_CRASH_DEBUG */
-
-#endif /* __XEN_DEBUGGER_H__ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Mon Feb 05 21:55:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 05 Feb 2024 21:55:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.676523.1052682 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rX6vo-0004AQ-Vs; Mon, 05 Feb 2024 21:55:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 676523.1052682; Mon, 05 Feb 2024 21:55:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rX6vo-0004AJ-TO; Mon, 05 Feb 2024 21:55:12 +0000
Received: by outflank-mailman (input) for mailman id 676523;
 Mon, 05 Feb 2024 21:55:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rX6vn-0004AB-WD
 for xen-changelog@lists.xenproject.org; Mon, 05 Feb 2024 21:55:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rX6vn-0007yt-VQ
 for xen-changelog@lists.xenproject.org; Mon, 05 Feb 2024 21:55:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rX6vn-0001YA-UC
 for xen-changelog@lists.xenproject.org; Mon, 05 Feb 2024 21:55:11 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=zio71YzXWJKYEhc5CnqzjKPG7/R0ZEkagWfpmU4XDzg=; b=rNxqLABs8Bq9pOdeiLTHbSeKHp
	Bxy+qpgDfUoLhZI7Sy0rPSISXpWTgsmwhHsh2uRtAut8zHA5KCbQtOHZb53EEebBymfE+9ITRVdc9
	H4NJWb5dehebdQnKOLAtZmzw70UWtFuPhh2GDj9U/1TcGlNs9jqbyGXO8y07Vr9oNtdc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/guest: finish conversion to altcall
Message-Id: <E1rX6vn-0001YA-UC@xenbits.xenproject.org>
Date: Mon, 05 Feb 2024 21:55:11 +0000

commit e931edccc53c9dd6e9a505ad0ff3a03d985669bc
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Feb 5 10:45:31 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 5 10:45:31 2024 +0100

    x86/guest: finish conversion to altcall
    
    While .setup() and .e820_fixup() don't need fiddling with for being run
    only very early, both .ap_setup() and .resume() want converting too:
    This way both pre-filled struct hypervisor_ops instances can become
    __initconst_cf_clobber, thus allowing to eliminate up to 5 more ENDBR
    (configuration dependent) during the 2nd phase of alternatives patching.
    
    While fiddling with section annotations here, also move "ops" itself to
    .data.ro_after_init.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Paul Durrant <paul@xen.org>
---
 xen/arch/x86/guest/hyperv/hyperv.c | 2 +-
 xen/arch/x86/guest/hypervisor.c    | 6 +++---
 xen/arch/x86/guest/xen/xen.c       | 2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/guest/hyperv/hyperv.c b/xen/arch/x86/guest/hyperv/hyperv.c
index 912099564e..6989af38f1 100644
--- a/xen/arch/x86/guest/hyperv/hyperv.c
+++ b/xen/arch/x86/guest/hyperv/hyperv.c
@@ -207,7 +207,7 @@ static int cf_check flush_tlb(
     return hyperv_flush_tlb(mask, va, flags);
 }
 
-static const struct hypervisor_ops __initconstrel ops = {
+static const struct hypervisor_ops __initconst_cf_clobber ops = {
     .name = "Hyper-V",
     .setup = setup,
     .ap_setup = ap_setup,
diff --git a/xen/arch/x86/guest/hypervisor.c b/xen/arch/x86/guest/hypervisor.c
index e0b046cc6c..ac80e83245 100644
--- a/xen/arch/x86/guest/hypervisor.c
+++ b/xen/arch/x86/guest/hypervisor.c
@@ -13,7 +13,7 @@
 #include <asm/cache.h>
 #include <asm/guest.h>
 
-static struct hypervisor_ops __read_mostly ops;
+static struct hypervisor_ops __ro_after_init ops;
 
 const char *__init hypervisor_probe(void)
 {
@@ -49,7 +49,7 @@ void __init hypervisor_setup(void)
 int hypervisor_ap_setup(void)
 {
     if ( ops.ap_setup )
-        return ops.ap_setup();
+        return alternative_call(ops.ap_setup);
 
     return 0;
 }
@@ -57,7 +57,7 @@ int hypervisor_ap_setup(void)
 void hypervisor_resume(void)
 {
     if ( ops.resume )
-        ops.resume();
+        alternative_vcall(ops.resume);
 }
 
 void __init hypervisor_e820_fixup(void)
diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c
index 2eed32fe46..44a689d439 100644
--- a/xen/arch/x86/guest/xen/xen.c
+++ b/xen/arch/x86/guest/xen/xen.c
@@ -318,7 +318,7 @@ static int cf_check flush_tlb(
     return xen_hypercall_hvm_op(HVMOP_flush_tlbs, NULL);
 }
 
-static const struct hypervisor_ops __initconstrel ops = {
+static const struct hypervisor_ops __initconst_cf_clobber ops = {
     .name = "Xen",
     .setup = setup,
     .ap_setup = ap_setup,
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Mon Feb 05 21:55:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 05 Feb 2024 21:55:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.676522.1052678 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rX6ve-00048s-UZ; Mon, 05 Feb 2024 21:55:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 676522.1052678; Mon, 05 Feb 2024 21:55:02 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rX6ve-00048l-Ro; Mon, 05 Feb 2024 21:55:02 +0000
Received: by outflank-mailman (input) for mailman id 676522;
 Mon, 05 Feb 2024 21:55:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rX6vd-00048f-U5
 for xen-changelog@lists.xenproject.org; Mon, 05 Feb 2024 21:55:01 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rX6vd-0007yp-Rs
 for xen-changelog@lists.xenproject.org; Mon, 05 Feb 2024 21:55:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rX6vd-0001Wr-QN
 for xen-changelog@lists.xenproject.org; Mon, 05 Feb 2024 21:55:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=7+wOiW1FFhQUk/iAtuh4+zk6errUFw8s593h0aoF8Hc=; b=TD22+T+Y9eG13eWFyCG5mFgR+I
	J0l8Gt480yYfF/cSlpnrPAKMcK776nW6FBJEt8nFRtAZlx73Z+1DHB5QqK3+gFienmYqhOiwpQ4g0
	9ivrH5pnrV74oL7zmr5YP2ZRKxj/Vf7jhgsIQ43jI0jqIJ4XgVidfZ3kQnE/x+8NcugI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86: arrange for ENDBR zapping from <vendor>_ctxt_switch_masking()
Message-Id: <E1rX6vd-0001Wr-QN@xenbits.xenproject.org>
Date: Mon, 05 Feb 2024 21:55:01 +0000

commit 044168fa3a65b6542bda5c21e373742de1bd5980
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Feb 5 10:44:46 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 5 10:44:46 2024 +0100

    x86: arrange for ENDBR zapping from <vendor>_ctxt_switch_masking()
    
    While altcall is already used for them, the functions want announcing in
    .init.rodata.cf_clobber, even if the resulting static variables aren't
    otherwise used.
    
    While doing this also move ctxt_switch_masking to .data.ro_after_init.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/cpu/amd.c    | 5 +++++
 xen/arch/x86/cpu/common.c | 2 +-
 xen/arch/x86/cpu/intel.c  | 5 +++++
 3 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index d43288ae97..808cda46bc 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -258,6 +258,11 @@ static void cf_check amd_ctxt_switch_masking(const struct vcpu *next)
 #undef LAZY
 }
 
+#ifdef CONFIG_XEN_IBT /* Announce the function to ENDBR clobbering logic. */
+static const typeof(ctxt_switch_masking) __initconst_cf_clobber __used csm =
+    amd_ctxt_switch_masking;
+#endif
+
 /*
  * Mask the features and extended features returned by CPUID.  Parameters are
  * set from the boot line via two methods:
diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index 51509fece0..61e5e52151 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -119,7 +119,7 @@ static const struct cpu_dev default_cpu = {
 static const struct cpu_dev *this_cpu = &default_cpu;
 
 static DEFINE_PER_CPU(uint64_t, msr_misc_features);
-void (* __read_mostly ctxt_switch_masking)(const struct vcpu *next);
+void (* __ro_after_init ctxt_switch_masking)(const struct vcpu *next);
 
 bool __init probe_cpuid_faulting(void)
 {
diff --git a/xen/arch/x86/cpu/intel.c b/xen/arch/x86/cpu/intel.c
index b5490eb06e..cd9f101b8c 100644
--- a/xen/arch/x86/cpu/intel.c
+++ b/xen/arch/x86/cpu/intel.c
@@ -220,6 +220,11 @@ static void cf_check intel_ctxt_switch_masking(const struct vcpu *next)
 #undef LAZY
 }
 
+#ifdef CONFIG_XEN_IBT /* Announce the function to ENDBR clobbering logic. */
+static const typeof(ctxt_switch_masking) __initconst_cf_clobber __used csm =
+    intel_ctxt_switch_masking;
+#endif
+
 /*
  * opt_cpuid_mask_ecx/edx: cpuid.1[ecx, edx] feature mask.
  * For example, E8400[Intel Core 2 Duo Processor series] ecx = 0x0008E3FD,
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Mon Feb 05 21:55:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 05 Feb 2024 21:55:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.676524.1052687 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rX6vz-0004Cv-1D; Mon, 05 Feb 2024 21:55:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 676524.1052687; Mon, 05 Feb 2024 21:55:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rX6vy-0004Cn-Uo; Mon, 05 Feb 2024 21:55:22 +0000
Received: by outflank-mailman (input) for mailman id 676524;
 Mon, 05 Feb 2024 21:55:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rX6vy-0004Cb-3o
 for xen-changelog@lists.xenproject.org; Mon, 05 Feb 2024 21:55:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rX6vy-0007z4-2Z
 for xen-changelog@lists.xenproject.org; Mon, 05 Feb 2024 21:55:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rX6vy-0001Z8-1W
 for xen-changelog@lists.xenproject.org; Mon, 05 Feb 2024 21:55:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=xsYCcViJw9JoCJOTOdck+XXYKHt2UAOcTe0DGSFnT4I=; b=ck2SPEW3fuzTEdbUK9zaC1Nfrz
	lLd8hPsQQVXZzz4jlZQ/Tuta4aJEk5ZvurfIN8WJbQRTnUx6cycZYhC9jH/Q2blztuRJMhHP8BAwU
	haABTNGrOTAeZ50tgXvZRdCnWkeIy86HGLLTGE6ygliOv5Vl0Oc15w3h0yyx8mAnRz50=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/CPU: convert vendor hook invocations to altcall
Message-Id: <E1rX6vy-0001Z8-1W@xenbits.xenproject.org>
Date: Mon, 05 Feb 2024 21:55:22 +0000

commit 660f8a75013c947fbe5358a640032a1f9f1eece5
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Feb 5 10:48:11 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 5 10:48:11 2024 +0100

    x86/CPU: convert vendor hook invocations to altcall
    
    While not performance critical, these hook invocations still want
    converting: This way all pre-filled struct cpu_dev instances can become
    __initconst_cf_clobber, thus allowing to eliminate further 8 ENDBR
    during the 2nd phase of alternatives patching (besides moving previously
    resident data to .init.*).
    
    Since all use sites need touching anyway, take the opportunity and also
    address a Misra C:2012 Rule 5.5 violation: Rename the this_cpu static
    variable.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/cpu/amd.c      |  2 +-
 xen/arch/x86/cpu/centaur.c  |  2 +-
 xen/arch/x86/cpu/common.c   | 24 ++++++++++++------------
 xen/arch/x86/cpu/hygon.c    |  2 +-
 xen/arch/x86/cpu/intel.c    |  2 +-
 xen/arch/x86/cpu/shanghai.c |  2 +-
 6 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index 808cda46bc..ab92333673 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -1307,7 +1307,7 @@ static void cf_check init_amd(struct cpuinfo_x86 *c)
 	amd_log_freq(c);
 }
 
-const struct cpu_dev amd_cpu_dev = {
+const struct cpu_dev __initconst_cf_clobber amd_cpu_dev = {
 	.c_early_init	= early_init_amd,
 	.c_init		= init_amd,
 };
diff --git a/xen/arch/x86/cpu/centaur.c b/xen/arch/x86/cpu/centaur.c
index eac49d78db..750168d1e8 100644
--- a/xen/arch/x86/cpu/centaur.c
+++ b/xen/arch/x86/cpu/centaur.c
@@ -54,6 +54,6 @@ static void cf_check init_centaur(struct cpuinfo_x86 *c)
 		init_c3(c);
 }
 
-const struct cpu_dev centaur_cpu_dev = {
+const struct cpu_dev __initconst_cf_clobber centaur_cpu_dev = {
 	.c_init		= init_centaur,
 };
diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index 61e5e52151..26eed2ade1 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -113,10 +113,10 @@ static void cf_check default_init(struct cpuinfo_x86 * c)
 	__clear_bit(X86_FEATURE_SEP, c->x86_capability);
 }
 
-static const struct cpu_dev default_cpu = {
+static const struct cpu_dev __initconst_cf_clobber __used default_cpu = {
 	.c_init	= default_init,
 };
-static const struct cpu_dev *this_cpu = &default_cpu;
+static struct cpu_dev __ro_after_init actual_cpu;
 
 static DEFINE_PER_CPU(uint64_t, msr_misc_features);
 void (* __ro_after_init ctxt_switch_masking)(const struct vcpu *next);
@@ -336,12 +336,13 @@ void __init early_cpu_init(bool verbose)
 
 	c->x86_vendor = x86_cpuid_lookup_vendor(ebx, ecx, edx);
 	switch (c->x86_vendor) {
-	case X86_VENDOR_INTEL:	  this_cpu = &intel_cpu_dev;    break;
-	case X86_VENDOR_AMD:	  this_cpu = &amd_cpu_dev;      break;
-	case X86_VENDOR_CENTAUR:  this_cpu = &centaur_cpu_dev;  break;
-	case X86_VENDOR_SHANGHAI: this_cpu = &shanghai_cpu_dev; break;
-	case X86_VENDOR_HYGON:    this_cpu = &hygon_cpu_dev;    break;
+	case X86_VENDOR_INTEL:	  actual_cpu = intel_cpu_dev;    break;
+	case X86_VENDOR_AMD:	  actual_cpu = amd_cpu_dev;      break;
+	case X86_VENDOR_CENTAUR:  actual_cpu = centaur_cpu_dev;  break;
+	case X86_VENDOR_SHANGHAI: actual_cpu = shanghai_cpu_dev; break;
+	case X86_VENDOR_HYGON:    actual_cpu = hygon_cpu_dev;    break;
 	default:
+		actual_cpu = default_cpu;
 		if (!verbose)
 			break;
 		printk(XENLOG_ERR
@@ -448,8 +449,8 @@ static void generic_identify(struct cpuinfo_x86 *c)
 	if (c->extended_cpuid_level >= 0x80000021)
 		c->x86_capability[FEATURESET_e21a] = cpuid_eax(0x80000021);
 
-	if (this_cpu->c_early_init)
-		this_cpu->c_early_init(c);
+	if (actual_cpu.c_early_init)
+		alternative_vcall(actual_cpu.c_early_init, c);
 
 	/* c_early_init() may have adjusted cpuid levels/features.  Reread. */
 	c->cpuid_level = cpuid_eax(0);
@@ -546,9 +547,8 @@ void identify_cpu(struct cpuinfo_x86 *c)
 	 * At the end of this section, c->x86_capability better
 	 * indicate the features this CPU genuinely supports!
 	 */
-	if (this_cpu->c_init)
-		this_cpu->c_init(c);
-
+	if (actual_cpu.c_init)
+		alternative_vcall(actual_cpu.c_init, c);
 
 	/*
 	 * The vendor-specific functions might have changed features.  Now
diff --git a/xen/arch/x86/cpu/hygon.c b/xen/arch/x86/cpu/hygon.c
index 42029f2145..f7508cc8fc 100644
--- a/xen/arch/x86/cpu/hygon.c
+++ b/xen/arch/x86/cpu/hygon.c
@@ -87,7 +87,7 @@ static void cf_check init_hygon(struct cpuinfo_x86 *c)
 	amd_log_freq(c);
 }
 
-const struct cpu_dev hygon_cpu_dev = {
+const struct cpu_dev __initconst_cf_clobber hygon_cpu_dev = {
 	.c_early_init	= early_init_amd,
 	.c_init		= init_hygon,
 };
diff --git a/xen/arch/x86/cpu/intel.c b/xen/arch/x86/cpu/intel.c
index cd9f101b8c..ce7a77a867 100644
--- a/xen/arch/x86/cpu/intel.c
+++ b/xen/arch/x86/cpu/intel.c
@@ -603,7 +603,7 @@ static void cf_check init_intel(struct cpuinfo_x86 *c)
 		setup_clear_cpu_cap(X86_FEATURE_CLWB);
 }
 
-const struct cpu_dev intel_cpu_dev = {
+const struct cpu_dev __initconst_cf_clobber intel_cpu_dev = {
 	.c_early_init	= early_init_intel,
 	.c_init		= init_intel,
 };
diff --git a/xen/arch/x86/cpu/shanghai.c b/xen/arch/x86/cpu/shanghai.c
index 95ae544f8c..910f2c32f3 100644
--- a/xen/arch/x86/cpu/shanghai.c
+++ b/xen/arch/x86/cpu/shanghai.c
@@ -15,6 +15,6 @@ static void cf_check init_shanghai(struct cpuinfo_x86 *c)
     init_intel_cacheinfo(c);
 }
 
-const struct cpu_dev shanghai_cpu_dev = {
+const struct cpu_dev __initconst_cf_clobber shanghai_cpu_dev = {
     .c_init     = init_shanghai,
 };
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 06 10:00:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 06 Feb 2024 10:00:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.676731.1052972 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXIFI-0002TU-9U; Tue, 06 Feb 2024 10:00:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 676731.1052972; Tue, 06 Feb 2024 10:00:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXIFI-0002T8-6l; Tue, 06 Feb 2024 10:00:04 +0000
Received: by outflank-mailman (input) for mailman id 676731;
 Tue, 06 Feb 2024 10:00:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXIFG-0002Bd-JO
 for xen-changelog@lists.xenproject.org; Tue, 06 Feb 2024 10:00:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXIFG-00081G-Go
 for xen-changelog@lists.xenproject.org; Tue, 06 Feb 2024 10:00:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXIFG-0004PE-Dt
 for xen-changelog@lists.xenproject.org; Tue, 06 Feb 2024 10:00:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=5hH84+f+OL/KyzFeRCZ1sK/DLjxArPseebqTWAuhgP8=; b=A88kDri4YatYLD7D11FsYTpD42
	c9QWFkkBHS2fm6okU3I14jFDiJ26dAIXH+Dy4s6WjsUhkdyB4ZAMkZxyBMvBd+sVb6nI1Yhi22TMJ
	3FE27hlPlBD3exhJc0DjHEsdsH566/kAQMB5yZzg+lOV/MwoV+ln7aHQZYiejXBoCD94=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/ucode: Remove accidentally introduced tabs
Message-Id: <E1rXIFG-0004PE-Dt@xenbits.xenproject.org>
Date: Tue, 06 Feb 2024 10:00:02 +0000

commit 930605f155cc8283afa153481cfba5056479fc42
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Feb 2 17:57:37 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Feb 5 10:36:47 2024 +0000

    x86/ucode: Remove accidentally introduced tabs
    
    Fixes: cf7fe8b72dea ("x86/ucode: Fix stability of the raw CPU Policy rescan")
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/cpu/microcode/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c
index 6f95f7bbe2..1c9f66ea8a 100644
--- a/xen/arch/x86/cpu/microcode/core.c
+++ b/xen/arch/x86/cpu/microcode/core.c
@@ -685,12 +685,12 @@ static long cf_check microcode_update_helper(void *data)
          * Disable CPUID masking if in use, to avoid having current's
          * cpu_policy affect the rescan.
          */
-	if ( ctxt_switch_masking )
+        if ( ctxt_switch_masking )
             alternative_vcall(ctxt_switch_masking, NULL);
 
         calculate_raw_cpu_policy();
 
-	if ( ctxt_switch_masking )
+        if ( ctxt_switch_masking )
             alternative_vcall(ctxt_switch_masking, current);
     }
     else
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 06 10:00:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 06 Feb 2024 10:00:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.676732.1052976 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXIFS-0002tN-Am; Tue, 06 Feb 2024 10:00:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 676732.1052976; Tue, 06 Feb 2024 10:00:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXIFS-0002tF-8G; Tue, 06 Feb 2024 10:00:14 +0000
Received: by outflank-mailman (input) for mailman id 676732;
 Tue, 06 Feb 2024 10:00:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXIFQ-0002t8-L9
 for xen-changelog@lists.xenproject.org; Tue, 06 Feb 2024 10:00:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXIFQ-00081d-KG
 for xen-changelog@lists.xenproject.org; Tue, 06 Feb 2024 10:00:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXIFQ-0004Rf-J5
 for xen-changelog@lists.xenproject.org; Tue, 06 Feb 2024 10:00:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=xZ7aCvpW1dTZODYq5xXS76gbldL1HtYcNmYFNEs0X08=; b=4H6LJDE6R4VeYm7AcuqS13cH+C
	mAyaArY2RJ1381XHJS6HvZ4CsueWD75776S/Xs1OoiNQrK5aIc5H8hwkhi1UEYzcrL8GCD8r5D9yV
	WqR8QLY+hL/F7Mzgdx7Vmq4hJhXwtg9MCSB98z6/Vekr65juzxZIs5lUCI/muIKxrdiA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/bitmap: Deduplicate __bitmap_weight() implementations
Message-Id: <E1rXIFQ-0004Rf-J5@xenbits.xenproject.org>
Date: Tue, 06 Feb 2024 10:00:12 +0000

commit 9eee78988ca081eeed0a69fc9773e2e4268d1ed7
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Feb 2 15:03:15 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Feb 5 10:36:47 2024 +0000

    xen/bitmap: Deduplicate __bitmap_weight() implementations
    
    We have two copies of __bitmap_weight() that differ by whether they make
    hweight32() or hweight64() calls, yet we already have hweight_long() which is
    the form that __bitmap_weight() wants.
    
    Fix hweight_long() to return unsigned int like all the other hweight helpers,
    and fix __bitmap_weight() to used unsigned integers.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/common/bitmap.c      | 21 +++------------------
 xen/include/xen/bitops.h |  2 +-
 2 files changed, 4 insertions(+), 19 deletions(-)

diff --git a/xen/common/bitmap.c b/xen/common/bitmap.c
index c57b35f004..9d9ff09f3d 100644
--- a/xen/common/bitmap.c
+++ b/xen/common/bitmap.c
@@ -186,33 +186,18 @@ int __bitmap_subset(const unsigned long *bitmap1,
 }
 EXPORT_SYMBOL(__bitmap_subset);
 
-#if BITS_PER_LONG == 32
 unsigned int __bitmap_weight(const unsigned long *bitmap, unsigned int bits)
 {
-	int k, w = 0, lim = bits/BITS_PER_LONG;
+	unsigned int k, w = 0, lim = bits / BITS_PER_LONG;
 
 	for (k = 0; k < lim; k++)
-		w += hweight32(bitmap[k]);
+		w += hweight_long(bitmap[k]);
 
 	if (bits % BITS_PER_LONG)
-		w += hweight32(bitmap[k] & BITMAP_LAST_WORD_MASK(bits));
+		w += hweight_long(bitmap[k] & BITMAP_LAST_WORD_MASK(bits));
 
 	return w;
 }
-#else
-unsigned int __bitmap_weight(const unsigned long *bitmap, unsigned int bits)
-{
-	int k, w = 0, lim = bits/BITS_PER_LONG;
-
-	for (k = 0; k < lim; k++)
-		w += hweight64(bitmap[k]);
-
-	if (bits % BITS_PER_LONG)
-		w += hweight64(bitmap[k] & BITMAP_LAST_WORD_MASK(bits));
-
-	return w;
-}
-#endif
 EXPORT_SYMBOL(__bitmap_weight);
 
 void __bitmap_set(unsigned long *map, unsigned int start, int len)
diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h
index a88d45475c..2cb7892bcc 100644
--- a/xen/include/xen/bitops.h
+++ b/xen/include/xen/bitops.h
@@ -199,7 +199,7 @@ static inline unsigned int generic_hweight64(uint64_t w)
     return (w + (w >> 32)) & 0xFF;
 }
 
-static inline unsigned long hweight_long(unsigned long w)
+static inline unsigned int hweight_long(unsigned long w)
 {
     return sizeof(w) == 4 ? generic_hweight32(w) : generic_hweight64(w);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 06 10:00:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 06 Feb 2024 10:00:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.676733.1052980 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXIFc-0002v9-CH; Tue, 06 Feb 2024 10:00:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 676733.1052980; Tue, 06 Feb 2024 10:00:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXIFc-0002v2-9l; Tue, 06 Feb 2024 10:00:24 +0000
Received: by outflank-mailman (input) for mailman id 676733;
 Tue, 06 Feb 2024 10:00:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXIFa-0002uw-Of
 for xen-changelog@lists.xenproject.org; Tue, 06 Feb 2024 10:00:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXIFa-00081r-Nn
 for xen-changelog@lists.xenproject.org; Tue, 06 Feb 2024 10:00:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXIFa-0004SZ-MM
 for xen-changelog@lists.xenproject.org; Tue, 06 Feb 2024 10:00:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=YRdDOFaELa5Hyo2l1hfShtFs0rKv0exaCUmaxCD2b7E=; b=1SwX1VMQg/cUFaJKCKy4EW+KSN
	VB6dfVdyHl9DLAzK7B7fuhe3OmnifOwlKSVtKYn4mfbq1NnBEDkqvuKLgrr8Xa8gHu3iXTUYYO81k
	SQzbnW8x4LRWqYaB2G+PDdCq/FmCYLw9AuhNEBEqQy0gN+dUHfl3hGuAin1uR7Uquidc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/cpu: Fix mixed tabs/spaces
Message-Id: <E1rXIFa-0004SZ-MM@xenbits.xenproject.org>
Date: Tue, 06 Feb 2024 10:00:22 +0000

commit 10e0fb655d811031553ad0fa319a7b58fe39f047
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon Feb 5 14:13:02 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Feb 5 17:58:23 2024 +0000

    x86/cpu: Fix mixed tabs/spaces
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/cpu/common.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index 26eed2ade1..28d7f34c4d 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -336,8 +336,8 @@ void __init early_cpu_init(bool verbose)
 
 	c->x86_vendor = x86_cpuid_lookup_vendor(ebx, ecx, edx);
 	switch (c->x86_vendor) {
-	case X86_VENDOR_INTEL:	  actual_cpu = intel_cpu_dev;    break;
-	case X86_VENDOR_AMD:	  actual_cpu = amd_cpu_dev;      break;
+	case X86_VENDOR_INTEL:    actual_cpu = intel_cpu_dev;    break;
+	case X86_VENDOR_AMD:      actual_cpu = amd_cpu_dev;      break;
 	case X86_VENDOR_CENTAUR:  actual_cpu = centaur_cpu_dev;  break;
 	case X86_VENDOR_SHANGHAI: actual_cpu = shanghai_cpu_dev; break;
 	case X86_VENDOR_HYGON:    actual_cpu = hygon_cpu_dev;    break;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 06 10:00:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 06 Feb 2024 10:00:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.676734.1052985 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXIFm-0002xI-F6; Tue, 06 Feb 2024 10:00:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 676734.1052985; Tue, 06 Feb 2024 10:00:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXIFm-0002xC-BG; Tue, 06 Feb 2024 10:00:34 +0000
Received: by outflank-mailman (input) for mailman id 676734;
 Tue, 06 Feb 2024 10:00:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXIFk-0002x3-Th
 for xen-changelog@lists.xenproject.org; Tue, 06 Feb 2024 10:00:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXIFk-00081y-Sw
 for xen-changelog@lists.xenproject.org; Tue, 06 Feb 2024 10:00:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXIFk-0004Ti-Pq
 for xen-changelog@lists.xenproject.org; Tue, 06 Feb 2024 10:00:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=MCWDXBfCsnStxx5RX8pPgCT990KiKQui212pzcChO3g=; b=JeOqE9OzrHPxl7+DJ0OjTiLkjW
	RAeJPpUdMDvzFN/IOBcNMZ1SeyHiwh8yd50GkTsNnTspsAru/BxBE6ghV9UipB4W85UdqLNwLD4Gq
	lOZ6U+JN/AuGWPPSq7QRwVpVYAn2tIK7BYs5QrJtsQ79rYTkhOLZNsa7sp9u7num5Vj4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xentop: fix sorting bug for some columns
Message-Id: <E1rXIFk-0004Ti-Pq@xenbits.xenproject.org>
Date: Tue, 06 Feb 2024 10:00:32 +0000

commit 29f17d837421f13c0e0010802de1b2d51d2ded4a
Author:     Cyril Rébert <slack@rabbit.lu>
AuthorDate: Sun Feb 4 11:19:40 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Feb 5 17:58:23 2024 +0000

    tools/xentop: fix sorting bug for some columns
    
    Sort doesn't work on columns VBD_OO, VBD_RD, VBD_WR and VBD_RSECT.
    Fix by adjusting variables names in compare functions.
    Bug fix only. No functional change.
    
    Fixes: 91c3e3dc91d6 ("tools/xentop: Display '-' when stats are not available.")
    Signed-off-by: Cyril Rébert (zithro) <slack@rabbit.lu>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/xentop/xentop.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/xentop/xentop.c b/tools/xentop/xentop.c
index 950e8935c4..545bd5e96d 100644
--- a/tools/xentop/xentop.c
+++ b/tools/xentop/xentop.c
@@ -684,7 +684,7 @@ static int compare_vbd_oo(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_oo = 0, dom2_vbd_oo = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_OO, &dom1_vbd_oo);
-	tot_vbd_reqs(domain1, FIELD_VBD_OO, &dom2_vbd_oo);
+	tot_vbd_reqs(domain2, FIELD_VBD_OO, &dom2_vbd_oo);
 
 	return -compare(dom1_vbd_oo, dom2_vbd_oo);
 }
@@ -711,9 +711,9 @@ static int compare_vbd_rd(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_rd = 0, dom2_vbd_rd = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_RD, &dom1_vbd_rd);
-	tot_vbd_reqs(domain1, FIELD_VBD_RD, &dom2_vbd_rd);
+	tot_vbd_reqs(domain2, FIELD_VBD_RD, &dom2_vbd_rd);
 
-	return -compare(dom1_vbd_rd, dom1_vbd_rd);
+	return -compare(dom1_vbd_rd, dom2_vbd_rd);
 }
 
 /* Prints number of total VBD READ requests statistic */
@@ -738,7 +738,7 @@ static int compare_vbd_wr(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_wr = 0, dom2_vbd_wr = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_WR, &dom1_vbd_wr);
-	tot_vbd_reqs(domain1, FIELD_VBD_WR, &dom2_vbd_wr);
+	tot_vbd_reqs(domain2, FIELD_VBD_WR, &dom2_vbd_wr);
 
 	return -compare(dom1_vbd_wr, dom2_vbd_wr);
 }
@@ -765,7 +765,7 @@ static int compare_vbd_rsect(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_rsect = 0, dom2_vbd_rsect = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_RSECT, &dom1_vbd_rsect);
-	tot_vbd_reqs(domain1, FIELD_VBD_RSECT, &dom2_vbd_rsect);
+	tot_vbd_reqs(domain2, FIELD_VBD_RSECT, &dom2_vbd_rsect);
 
 	return -compare(dom1_vbd_rsect, dom2_vbd_rsect);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 00:44:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 00:44:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677185.1053595 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW2m-0007Px-3f; Wed, 07 Feb 2024 00:44:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677185.1053595; Wed, 07 Feb 2024 00:44:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW2m-0007Pp-1A; Wed, 07 Feb 2024 00:44:04 +0000
Received: by outflank-mailman (input) for mailman id 677185;
 Wed, 07 Feb 2024 00:44:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW2k-0007PT-6k
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW2k-0001Jm-5W
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW2k-0003oi-4R
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=rfpMwVkAdo10DkRe1RzTpGW8fP8eqPXkZMpi+omoCTc=; b=PKyETVq3qzGd9+/GGIWGJvHUX3
	5djeLo0NwHfVbq8+evLDHxIq7JYaP4eXNFc3zCv7Qz7Rca4vYsMaiH84PEyr00S9E7mNvZ5qcXTnv
	RhF7OqL3DF9udWR2/Aox69V+/7BIvJSnDv1GQrMVlbTzb1WUJcohih6FjAIZobGhaCM0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/helpers: allocate xenstore event channel for xenstore stubdom
Message-Id: <E1rXW2k-0003oi-4R@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 00:44:02 +0000

commit 9c076988fe5f9d55a0ecb846549bdbdfddcf3841
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Mon Feb 5 11:49:46 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon Feb 5 19:26:32 2024 +0000

    tools/helpers: allocate xenstore event channel for xenstore stubdom
    
    In order to prepare support of PV frontends in xenstore-stubdom, add
    allocation of a Xenstore event channel to init-xenstore-domain.c.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/helpers/init-xenstore-domain.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c
index b2d5df8ba5..140ed610ae 100644
--- a/tools/helpers/init-xenstore-domain.c
+++ b/tools/helpers/init-xenstore-domain.c
@@ -248,6 +248,13 @@ static int build(xc_interface *xch)
     dom->cmdline = xc_dom_strdup(dom, cmdline);
     dom->xenstore_domid = domid;
     dom->console_evtchn = console_evtchn;
+    rv = xc_evtchn_alloc_unbound(xch, domid, domid);
+    if ( rv < 0 )
+    {
+        fprintf(stderr, "xc_evtchn_alloc_unbound failed\n");
+        goto err;
+    }
+    dom->xenstore_evtchn = rv;
 
     rv = xc_dom_mem_init(dom, memory);
     if ( rv )
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 00:44:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 00:44:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677186.1053599 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW2w-0007S0-5M; Wed, 07 Feb 2024 00:44:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677186.1053599; Wed, 07 Feb 2024 00:44:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW2w-0007Rt-2c; Wed, 07 Feb 2024 00:44:14 +0000
Received: by outflank-mailman (input) for mailman id 677186;
 Wed, 07 Feb 2024 00:44:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW2u-0007Rh-AC
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW2u-0001Jw-9L
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW2u-0003pG-7r
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=U8OD2iX0BY8cyPVSZXRNh7fUC8Jskc8vBXm5vwHk0Eo=; b=v01qBgfOQKpJdMakDoNKctCvI8
	jjiUwA8lYAyugkLvEhfFqW/e5u8UdkS6bwFmsuYDU4Bosw4gvMdP9SW6j1NM2SqL/CWo9akM6VPlc
	NDxRGX1GXl4J9+WKU+qrlS6wJmYrC6GmaqLYocoDn15+AAR7qX36p7zfOF1H/aYtlK64=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xenstored: rename xenbus_evtchn()
Message-Id: <E1rXW2u-0003pG-7r@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 00:44:12 +0000

commit 1c2c7f790147ca003270b32da41550c04c7d15d2
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Mon Feb 5 11:49:47 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon Feb 5 19:26:32 2024 +0000

    tools/xenstored: rename xenbus_evtchn()
    
    Rename the xenbus_evtchn() function to get_xenbus_evtchn() in order to
    avoid two externally visible symbols with the same name when Xenstore-
    stubdom is being built with a Mini-OS with CONFIG_XENBUS set.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/xenstored/core.h   | 2 +-
 tools/xenstored/domain.c | 2 +-
 tools/xenstored/minios.c | 2 +-
 tools/xenstored/posix.c  | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index ad87199042..480b0f5f7b 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -383,7 +383,7 @@ static inline bool domain_is_unprivileged(const struct connection *conn)
 }
 
 /* Return the event channel used by xenbus. */
-evtchn_port_t xenbus_evtchn(void);
+evtchn_port_t get_xenbus_evtchn(void);
 
 /* Write out the pidfile */
 void write_pidfile(const char *pidfile);
diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index 409b53acf9..6ef136e01f 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -1208,7 +1208,7 @@ void dom0_init(void)
 	evtchn_port_t port;
 	struct domain *dom0;
 
-	port = xenbus_evtchn();
+	port = get_xenbus_evtchn();
 	if (port == -1)
 		barf_perror("Failed to initialize dom0 port");
 
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index b5c3a205e6..0779efbf91 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -38,7 +38,7 @@ void init_pipe(int reopen_log_pipe[2])
 	reopen_log_pipe[1] = -1;
 }
 
-evtchn_port_t xenbus_evtchn(void)
+evtchn_port_t get_xenbus_evtchn(void)
 {
 	return dom0_event;
 }
diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c
index 6ac45fdb45..7e03dd982d 100644
--- a/tools/xenstored/posix.c
+++ b/tools/xenstored/posix.c
@@ -111,7 +111,7 @@ void unmap_xenbus(void *interface)
 	munmap(interface, getpagesize());
 }
 
-evtchn_port_t xenbus_evtchn(void)
+evtchn_port_t get_xenbus_evtchn(void)
 {
 	int fd;
 	int rc;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 00:44:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 00:44:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677187.1053602 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW35-0007Ui-6o; Wed, 07 Feb 2024 00:44:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677187.1053602; Wed, 07 Feb 2024 00:44:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW35-0007Ub-4H; Wed, 07 Feb 2024 00:44:23 +0000
Received: by outflank-mailman (input) for mailman id 677187;
 Wed, 07 Feb 2024 00:44:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW34-0007UR-DN
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW34-0001KV-CZ
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW34-0003pi-Bb
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=uwGhsPk9gH3enH+uGKs3LwZTFPnHiuQ1I9mSZeVztG4=; b=QP6DIWV3Wvo38O4ZKulLTn1gLO
	pmdZaE5iOpYN1GwFQll54yNrUvt853hRTipMLdUmVjqxhzQnFoAWT2RICvcKVFjCT34AnS4unRIGB
	kWBxZBHyFuemxdr9bw5uIVGMzja7fQZ+kSz5wNvz+iDq87K2OMy5WTsuOOeKnoULQ4/A=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xenstored: add early_init() function
Message-Id: <E1rXW34-0003pi-Bb@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 00:44:22 +0000

commit e767a98f040d8274b0f1dc991b9eefbc13b39e2d
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Mon Feb 5 11:49:50 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon Feb 5 19:26:32 2024 +0000

    tools/xenstored: add early_init() function
    
    Some xenstored initialization needs to be done in the daemon case only,
    so split it out into a new early_init() function being a stub in the
    stubdom case.
    
    Remove the call of talloc_enable_leak_report_full(), as it serves no
    real purpose: the daemon only ever exits due to a crash, in which case
    a log of talloc()ed memory hardly has any value.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstored/core.c   | 30 +++---------------------------
 tools/xenstored/core.h   |  7 +++----
 tools/xenstored/minios.c | 11 +++--------
 tools/xenstored/posix.c  | 31 +++++++++++++++++++++++++++++--
 4 files changed, 38 insertions(+), 41 deletions(-)

diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index d4c76d71dc..eba7744fde 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -79,7 +79,7 @@ char **orig_argv;
 LIST_HEAD(connections);
 int tracefd = -1;
 bool keep_orphans = false;
-static int reopen_log_pipe[2];
+int reopen_log_pipe[2];
 static int reopen_log_pipe0_pollfd_idx = -1;
 char *tracefile = NULL;
 static struct hashtable *nodes;
@@ -2612,7 +2612,7 @@ static void destroy_fds(void)
 		close(sock);
 }
 
-static void init_sockets(void)
+void init_sockets(void)
 {
 	struct sockaddr_un addr;
 	const char *soc_str = xenstore_daemon_path();
@@ -2903,34 +2903,10 @@ int main(int argc, char *argv[])
 	if (optind != argc)
 		barf("%s: No arguments desired", argv[0]);
 
-	reopen_log();
-
-	/* Make sure xenstored directory exists. */
-	/* Errors ignored here, will be reported when we open files */
-	mkdir(xenstore_daemon_rundir(), 0755);
-
-	if (dofork) {
-		openlog("xenstored", 0, LOG_DAEMON);
-		if (!live_update)
-			daemonize();
-	}
-	if (pidfile)
-		write_pidfile(pidfile);
-
-	/* Talloc leak reports go to stderr, which is closed if we fork. */
-	if (!dofork)
-		talloc_enable_leak_report_full();
-
-	/* Don't kill us with SIGPIPE. */
-	signal(SIGPIPE, SIG_IGN);
+	early_init(live_update, dofork, pidfile);
 
 	talloc_enable_null_tracking();
 
-#ifndef NO_SOCKETS
-	if (!live_update)
-		init_sockets();
-#endif
-
 	init_pipe(reopen_log_pipe);
 
 	/* Listen to hypervisor. */
diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index 480b0f5f7b..72173f1684 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -384,12 +384,11 @@ static inline bool domain_is_unprivileged(const struct connection *conn)
 
 /* Return the event channel used by xenbus. */
 evtchn_port_t get_xenbus_evtchn(void);
+void early_init(bool live_update, bool dofork, const char *pidfile);
 
-/* Write out the pidfile */
-void write_pidfile(const char *pidfile);
+void init_sockets(void);
+extern int reopen_log_pipe[2];
 
-/* Fork but do not close terminal FDs */
-void daemonize(void);
 /* Close stdin/stdout/stderr to complete daemonize */
 void finish_daemonize(void);
 
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index 0779efbf91..4f48f63083 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -20,14 +20,6 @@
 #include "core.h"
 #include <xen/grant_table.h>
 
-void write_pidfile(const char *pidfile)
-{
-}
-
-void daemonize(void)
-{
-}
-
 void finish_daemonize(void)
 {
 }
@@ -54,3 +46,6 @@ void unmap_xenbus(void *interface)
 	xengnttab_unmap(*xgt_handle, interface, 1);
 }
 
+void early_init(bool live_update, bool dofork, const char *pidfile)
+{
+}
diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c
index 7e03dd982d..9463ef5c8d 100644
--- a/tools/xenstored/posix.c
+++ b/tools/xenstored/posix.c
@@ -20,14 +20,17 @@
 #include <sys/stat.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <signal.h>
 #include <stdlib.h>
+#include <syslog.h>
 #include <sys/mman.h>
+#include <xen-tools/xenstore-common.h>
 
 #include "utils.h"
 #include "core.h"
 #include "osdep.h"
 
-void write_pidfile(const char *pidfile)
+static void write_pidfile(const char *pidfile)
 {
 	char buf[100];
 	int len;
@@ -49,7 +52,7 @@ void write_pidfile(const char *pidfile)
 }
 
 /* Stevens. */
-void daemonize(void)
+static void daemonize(void)
 {
 	pid_t pid;
 
@@ -157,3 +160,27 @@ void *xenbus_map(void)
 
 	return addr;
 }
+
+void early_init(bool live_update, bool dofork, const char *pidfile)
+{
+	reopen_log();
+
+	/* Make sure xenstored directory exists. */
+	/* Errors ignored here, will be reported when we open files */
+	mkdir(xenstore_daemon_rundir(), 0755);
+
+	if (dofork) {
+		openlog("xenstored", 0, LOG_DAEMON);
+		if (!live_update)
+			daemonize();
+	}
+
+	if (pidfile)
+		write_pidfile(pidfile);
+
+	/* Don't kill us with SIGPIPE. */
+	signal(SIGPIPE, SIG_IGN);
+
+	if (!live_update)
+		init_sockets();
+}
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 00:44:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 00:44:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677188.1053607 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW3F-0007Xk-97; Wed, 07 Feb 2024 00:44:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677188.1053607; Wed, 07 Feb 2024 00:44:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW3F-0007Xc-5m; Wed, 07 Feb 2024 00:44:33 +0000
Received: by outflank-mailman (input) for mailman id 677188;
 Wed, 07 Feb 2024 00:44:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW3E-0007XW-H7
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW3E-0001Kk-Fq
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW3E-0003q7-Eo
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=J+RUBM8wBtIm50Joe6NeBzSl2ilj+CJN2Ii1SPPSaOA=; b=QK10yPeG7ARiTogbwB3x9Qsrkq
	I5H3rY5QlzHEvG0z7IhVF0E53yQgLYlkONMaCQ15JLgre6pcwgnDLUiycYiEJowS2bqp//p95rcGu
	WYkqOPRi00UIiNuYGNIaRqvdrPqQvrozryNHdgxlhfPKXHibwbgaCgR0SGln/7fIONx4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xenstored: move systemd handling to posix.c
Message-Id: <E1rXW3E-0003q7-Eo@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 00:44:32 +0000

commit 511cc30cf8bbf083f2788cf4eee91edec0b85ac0
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Mon Feb 5 11:49:51 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon Feb 5 19:26:32 2024 +0000

    tools/xenstored: move systemd handling to posix.c
    
    Move systemd handling to a new late_init() function in posix.c.
    
    This prepares a future removal of the NO_SOCKETS macro.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstored/core.c   | 17 +----------------
 tools/xenstored/core.h   |  1 +
 tools/xenstored/minios.c |  4 ++++
 tools/xenstored/posix.c  | 13 +++++++++++++
 4 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index eba7744fde..7b5e1d0c0f 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -54,16 +54,6 @@
 #include "control.h"
 #include "lu.h"
 
-#ifndef NO_SOCKETS
-#if defined(HAVE_SYSTEMD)
-#define XEN_SYSTEMD_ENABLED 1
-#endif
-#endif
-
-#if defined(XEN_SYSTEMD_ENABLED)
-#include <systemd/sd-daemon.h>
-#endif
-
 extern xenevtchn_handle *xce_handle; /* in domain.c */
 static int xce_pollfd_idx = -1;
 static struct pollfd *fds;
@@ -2938,12 +2928,7 @@ int main(int argc, char *argv[])
 	/* Get ready to listen to the tools. */
 	initialize_fds(&sock_pollfd_idx, &timeout);
 
-#if defined(XEN_SYSTEMD_ENABLED)
-	if (!live_update) {
-		sd_notify(1, "READY=1");
-		fprintf(stderr, SD_NOTICE "xenstored is ready\n");
-	}
-#endif
+	late_init(live_update);
 
 	/* Main loop. */
 	for (;;) {
diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index 72173f1684..0de2d8a26e 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -385,6 +385,7 @@ static inline bool domain_is_unprivileged(const struct connection *conn)
 /* Return the event channel used by xenbus. */
 evtchn_port_t get_xenbus_evtchn(void);
 void early_init(bool live_update, bool dofork, const char *pidfile);
+void late_init(bool live_update);
 
 void init_sockets(void);
 extern int reopen_log_pipe[2];
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index 4f48f63083..45bb0440be 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -49,3 +49,7 @@ void unmap_xenbus(void *interface)
 void early_init(bool live_update, bool dofork, const char *pidfile)
 {
 }
+
+void late_init(bool live_update)
+{
+}
diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c
index 9463ef5c8d..97c8dcaba3 100644
--- a/tools/xenstored/posix.c
+++ b/tools/xenstored/posix.c
@@ -24,6 +24,9 @@
 #include <stdlib.h>
 #include <syslog.h>
 #include <sys/mman.h>
+#if defined(HAVE_SYSTEMD)
+#include <systemd/sd-daemon.h>
+#endif
 #include <xen-tools/xenstore-common.h>
 
 #include "utils.h"
@@ -184,3 +187,13 @@ void early_init(bool live_update, bool dofork, const char *pidfile)
 	if (!live_update)
 		init_sockets();
 }
+
+void late_init(bool live_update)
+{
+#if defined(HAVE_SYSTEMD)
+	if (!live_update) {
+		sd_notify(1, "READY=1");
+		fprintf(stderr, SD_NOTICE "xenstored is ready\n");
+	}
+#endif
+}
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 00:44:43 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 00:44:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677189.1053611 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW3P-0007a9-A4; Wed, 07 Feb 2024 00:44:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677189.1053611; Wed, 07 Feb 2024 00:44:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW3P-0007a1-7N; Wed, 07 Feb 2024 00:44:43 +0000
Received: by outflank-mailman (input) for mailman id 677189;
 Wed, 07 Feb 2024 00:44:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW3O-0007Zv-KW
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW3O-0001L0-JK
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW3O-0003qW-IB
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=PkRLzh9ncXuvIJy95u1Lnb8ZzMHzOnbuIJ5B5EOuPbI=; b=rkFSNk4q6AVc5VJpzLTbkOO1Xs
	I0BWTmBjAjCMUjf7T0YhXS1KsfQuOhJI/6/oqsOYtx3QJSC6uOtfwyeyGccxECDM6tUypnYdfOwo9
	mq8W1uP2UEqpT3YMjN84xZFgmuyuMy8Dp0wkLTiRYs5Kwd7KFKqUazYd5Y0Ytak8VXgI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xenstored: move all log-pipe handling into posix.c
Message-Id: <E1rXW3O-0003qW-IB@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 00:44:42 +0000

commit aae54458a1b5e947dbc4fb44beca7ec94fe80001
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Mon Feb 5 11:49:52 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon Feb 5 19:26:32 2024 +0000

    tools/xenstored: move all log-pipe handling into posix.c
    
    All of the log-pipe handling is needed only when running as daemon.
    
    Move it into posix.c. This requires to have a service function in the
    main event loop for handling the related requests and one for setting
    the fds[] array, which is renamed to poll_fds to have a more specific
    name. Use a generic name for those functions, as socket handling can
    be added to them later, too.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstored/core.c   | 69 +++++++++++++-----------------------------------
 tools/xenstored/core.h   | 11 +++++---
 tools/xenstored/minios.c | 14 +++++-----
 tools/xenstored/posix.c  | 47 ++++++++++++++++++++++++++++++++-
 4 files changed, 79 insertions(+), 62 deletions(-)

diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index 7b5e1d0c0f..86ab330eaf 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -56,7 +56,7 @@
 
 extern xenevtchn_handle *xce_handle; /* in domain.c */
 static int xce_pollfd_idx = -1;
-static struct pollfd *fds;
+struct pollfd *poll_fds;
 static unsigned int current_array_size;
 static unsigned int nr_fds;
 static unsigned int delayed_requests;
@@ -69,8 +69,6 @@ char **orig_argv;
 LIST_HEAD(connections);
 int tracefd = -1;
 bool keep_orphans = false;
-int reopen_log_pipe[2];
-static int reopen_log_pipe0_pollfd_idx = -1;
 char *tracefile = NULL;
 static struct hashtable *nodes;
 unsigned int trace_flags = TRACE_OBJ | TRACE_IO;
@@ -145,18 +143,6 @@ void trace_destroy(const void *data, const char *type)
 		trace("obj: DESTROY %s %p\n", type, data);
 }
 
-/**
- * Signal handler for SIGHUP, which requests that the trace log is reopened
- * (in the main loop).  A single byte is written to reopen_log_pipe, to awaken
- * the poll() in the main loop.
- */
-static void trigger_reopen_log(int signal __attribute__((unused)))
-{
-	char c = 'A';
-	int dummy;
-	dummy = write(reopen_log_pipe[1], &c, 1);
-}
-
 void close_log(void)
 {
 	if (tracefd >= 0)
@@ -467,7 +453,7 @@ static bool conn_can_write(struct connection *conn)
 }
 
 /* This function returns index inside the array if succeed, -1 if fail */
-static int set_fd(int fd, short events)
+int set_fd(int fd, short events)
 {
 	int ret;
 	if (current_array_size < nr_fds + 1) {
@@ -479,18 +465,18 @@ static int set_fd(int fd, short events)
 		 */
 		newsize = ROUNDUP(nr_fds + 1, 8);
 
-		new_fds = realloc(fds, sizeof(struct pollfd)*newsize);
+		new_fds = realloc(poll_fds, sizeof(struct pollfd)*newsize);
 		if (!new_fds)
 			goto fail;
-		fds = new_fds;
+		poll_fds = new_fds;
 
-		memset(&fds[0] + current_array_size, 0,
+		memset(&poll_fds[0] + current_array_size, 0,
 		       sizeof(struct pollfd ) * (newsize-current_array_size));
 		current_array_size = newsize;
 	}
 
-	fds[nr_fds].fd = fd;
-	fds[nr_fds].events = events;
+	poll_fds[nr_fds].fd = fd;
+	poll_fds[nr_fds].events = events;
 	ret = nr_fds;
 	nr_fds++;
 
@@ -505,18 +491,16 @@ static void initialize_fds(int *p_sock_pollfd_idx, int *ptimeout)
 	struct connection *conn;
 	uint64_t msecs;
 
-	if (fds)
-		memset(fds, 0, sizeof(struct pollfd) * current_array_size);
+	if (poll_fds)
+		memset(poll_fds, 0, sizeof(struct pollfd) * current_array_size);
 	nr_fds = 0;
 
 	/* In case of delayed requests pause for max 1 second. */
 	*ptimeout = delayed_requests ? 1000 : -1;
 
+	set_special_fds();
 	if (sock != -1)
 		*p_sock_pollfd_idx = set_fd(sock, POLLIN|POLLPRI);
-	if (reopen_log_pipe[0] != -1)
-		reopen_log_pipe0_pollfd_idx =
-			set_fd(reopen_log_pipe[0], POLLIN|POLLPRI);
 
 	if (xce_handle != NULL)
 		xce_pollfd_idx = set_fd(xenevtchn_fd(xce_handle),
@@ -2324,12 +2308,12 @@ static bool socket_can_process(struct connection *conn, int mask)
 	if (conn->pollfd_idx == -1)
 		return false;
 
-	if (fds[conn->pollfd_idx].revents & ~(POLLIN | POLLOUT)) {
+	if (poll_fds[conn->pollfd_idx].revents & ~(POLLIN | POLLOUT)) {
 		talloc_free(conn);
 		return false;
 	}
 
-	return (fds[conn->pollfd_idx].revents & mask);
+	return (poll_fds[conn->pollfd_idx].revents & mask);
 }
 
 static bool socket_can_write(struct connection *conn)
@@ -2897,8 +2881,6 @@ int main(int argc, char *argv[])
 
 	talloc_enable_null_tracking();
 
-	init_pipe(reopen_log_pipe);
-
 	/* Listen to hypervisor. */
 	if (!live_update) {
 		domain_init(-1);
@@ -2913,7 +2895,6 @@ int main(int argc, char *argv[])
 		xprintf = trace;
 #endif
 
-	signal(SIGHUP, trigger_reopen_log);
 	if (tracefile)
 		tracefile = talloc_strdup(NULL, tracefile);
 
@@ -2934,43 +2915,29 @@ int main(int argc, char *argv[])
 	for (;;) {
 		struct connection *conn, *next;
 
-		if (poll(fds, nr_fds, timeout) < 0) {
+		if (poll(poll_fds, nr_fds, timeout) < 0) {
 			if (errno == EINTR)
 				continue;
 			barf_perror("Poll failed");
 		}
 
-		if (reopen_log_pipe0_pollfd_idx != -1) {
-			if (fds[reopen_log_pipe0_pollfd_idx].revents
-			    & ~POLLIN) {
-				close(reopen_log_pipe[0]);
-				close(reopen_log_pipe[1]);
-				init_pipe(reopen_log_pipe);
-			} else if (fds[reopen_log_pipe0_pollfd_idx].revents
-				   & POLLIN) {
-				char c;
-				if (read(reopen_log_pipe[0], &c, 1) != 1)
-					barf_perror("read failed");
-				reopen_log();
-			}
-			reopen_log_pipe0_pollfd_idx = -1;
-		}
+		handle_special_fds();
 
 		if (sock_pollfd_idx != -1) {
-			if (fds[sock_pollfd_idx].revents & ~POLLIN) {
+			if (poll_fds[sock_pollfd_idx].revents & ~POLLIN) {
 				barf_perror("sock poll failed");
 				break;
-			} else if (fds[sock_pollfd_idx].revents & POLLIN) {
+			} else if (poll_fds[sock_pollfd_idx].revents & POLLIN) {
 				accept_connection(sock);
 				sock_pollfd_idx = -1;
 			}
 		}
 
 		if (xce_pollfd_idx != -1) {
-			if (fds[xce_pollfd_idx].revents & ~POLLIN) {
+			if (poll_fds[xce_pollfd_idx].revents & ~POLLIN) {
 				barf_perror("xce_handle poll failed");
 				break;
-			} else if (fds[xce_pollfd_idx].revents & POLLIN) {
+			} else if (poll_fds[xce_pollfd_idx].revents & POLLIN) {
 				handle_event();
 				xce_pollfd_idx = -1;
 			}
diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index 0de2d8a26e..44c4d0f8b8 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -25,6 +25,7 @@
 #include <sys/types.h>
 #include <dirent.h>
 #include <fcntl.h>
+#include <poll.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <time.h>
@@ -361,6 +362,8 @@ extern int dom0_event;
 extern int priv_domid;
 extern bool keep_orphans;
 
+extern struct pollfd *poll_fds;
+
 extern unsigned int timeout_watch_event_msec;
 
 /* Get internal time in milliseconds. */
@@ -387,15 +390,15 @@ evtchn_port_t get_xenbus_evtchn(void);
 void early_init(bool live_update, bool dofork, const char *pidfile);
 void late_init(bool live_update);
 
+int set_fd(int fd, short events);
+void set_special_fds(void);
+void handle_special_fds(void);
+
 void init_sockets(void);
-extern int reopen_log_pipe[2];
 
 /* Close stdin/stdout/stderr to complete daemonize */
 void finish_daemonize(void);
 
-/* Open a pipe for signal handling */
-void init_pipe(int reopen_log_pipe[2]);
-
 #ifndef NO_SOCKETS
 extern const struct interface_funcs socket_funcs;
 #endif
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index 45bb0440be..3208169187 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -24,12 +24,6 @@ void finish_daemonize(void)
 {
 }
 
-void init_pipe(int reopen_log_pipe[2])
-{
-	reopen_log_pipe[0] = -1;
-	reopen_log_pipe[1] = -1;
-}
-
 evtchn_port_t get_xenbus_evtchn(void)
 {
 	return dom0_event;
@@ -53,3 +47,11 @@ void early_init(bool live_update, bool dofork, const char *pidfile)
 void late_init(bool live_update)
 {
 }
+
+void set_special_fds(void)
+{
+}
+
+void handle_special_fds(void)
+{
+}
diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c
index 97c8dcaba3..1ea8475293 100644
--- a/tools/xenstored/posix.c
+++ b/tools/xenstored/posix.c
@@ -33,6 +33,9 @@
 #include "core.h"
 #include "osdep.h"
 
+static int reopen_log_pipe0_pollfd_idx = -1;
+static int reopen_log_pipe[2];
+
 static void write_pidfile(const char *pidfile)
 {
 	char buf[100];
@@ -82,6 +85,19 @@ static void daemonize(void)
 	umask(0);
 }
 
+/*
+ * Signal handler for SIGHUP, which requests that the trace log is reopened
+ * (in the main loop).  A single byte is written to reopen_log_pipe, to awaken
+ * the poll() in the main loop.
+ */
+static void trigger_reopen_log(int signal __attribute__((unused)))
+{
+	char c = 'A';
+	int dummy;
+
+	dummy = write(reopen_log_pipe[1], &c, 1);
+}
+
 void finish_daemonize(void)
 {
 	int devnull = open("/dev/null", O_RDWR);
@@ -93,7 +109,7 @@ void finish_daemonize(void)
 	close(devnull);
 }
 
-void init_pipe(int reopen_log_pipe[2])
+static void init_pipe(void)
 {
 	int flags;
 	unsigned int i;
@@ -183,9 +199,38 @@ void early_init(bool live_update, bool dofork, const char *pidfile)
 
 	/* Don't kill us with SIGPIPE. */
 	signal(SIGPIPE, SIG_IGN);
+	signal(SIGHUP, trigger_reopen_log);
 
 	if (!live_update)
 		init_sockets();
+
+	init_pipe();
+}
+
+void set_special_fds(void)
+{
+	if (reopen_log_pipe[0] != -1)
+		reopen_log_pipe0_pollfd_idx =
+			set_fd(reopen_log_pipe[0], POLLIN|POLLPRI);
+}
+
+void handle_special_fds(void)
+{
+	if (reopen_log_pipe0_pollfd_idx != -1) {
+		if (poll_fds[reopen_log_pipe0_pollfd_idx].revents & ~POLLIN) {
+			close(reopen_log_pipe[0]);
+			close(reopen_log_pipe[1]);
+			init_pipe();
+		} else if (poll_fds[reopen_log_pipe0_pollfd_idx].revents &
+			   POLLIN) {
+			char c;
+
+			if (read(reopen_log_pipe[0], &c, 1) != 1)
+				barf_perror("read failed");
+			reopen_log();
+		}
+		reopen_log_pipe0_pollfd_idx = -1;
+	}
 }
 
 void late_init(bool live_update)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 00:44:53 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 00:44:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677190.1053615 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW3Z-0007dV-Cp; Wed, 07 Feb 2024 00:44:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677190.1053615; Wed, 07 Feb 2024 00:44:53 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW3Z-0007dO-AF; Wed, 07 Feb 2024 00:44:53 +0000
Received: by outflank-mailman (input) for mailman id 677190;
 Wed, 07 Feb 2024 00:44:52 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW3Y-0007dB-NP
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:52 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW3Y-0001LJ-Mf
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW3Y-0004A3-Li
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:44:52 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=nzup7i14qJhIASXA8Ig4ojbgzjr6w4EOyqPDln0NBm4=; b=4+CLemXnrm5VplkLj/liYZLpz7
	b8VflkJxXMv89hZRv7omB8rZxAqY+yEMBvQ7fl1hGXnjVmJXtyexzVAUnZIoQKOeOM9CQjP5bO7QU
	yrPKl14NPkiisMCQu1JkmlXV+2gI1Uo2fGlqGU0UKAQI5PujxfKYzTf8hb+xdynUkexY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xenstored: move all socket handling into posix.c
Message-Id: <E1rXW3Y-0004A3-Li@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 00:44:52 +0000

commit e199a3068097708a9e712bf5d86f9fb51e6615e8
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Mon Feb 5 11:49:53 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon Feb 5 19:26:32 2024 +0000

    tools/xenstored: move all socket handling into posix.c
    
    All of the socket handling is needed only when running as daemon.
    
    Move it into posix.c, allowing to remove the NO_SOCKETS macro.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstored/Makefile.common |   4 -
 tools/xenstored/core.c          | 160 ++-------------------------------------
 tools/xenstored/core.h          |   7 +-
 tools/xenstored/domain.c        |   9 +--
 tools/xenstored/minios.c        |  15 ++++
 tools/xenstored/posix.c         | 164 ++++++++++++++++++++++++++++++++++++++++
 6 files changed, 188 insertions(+), 171 deletions(-)

diff --git a/tools/xenstored/Makefile.common b/tools/xenstored/Makefile.common
index 189ab81b8d..ef63ef650c 100644
--- a/tools/xenstored/Makefile.common
+++ b/tools/xenstored/Makefile.common
@@ -16,10 +16,6 @@ CFLAGS += $(CFLAGS_libxenctrl)
 CFLAGS += $(CFLAGS_libxenguest)
 CFLAGS += $(CFLAGS_libxentoolcore)
 
-ifdef CONFIG_STUBDOM
-CFLAGS += -DNO_SOCKETS=1
-endif
-
 $(XENSTORED_OBJS-y): CFLAGS += $(CFLAGS_libxengnttab)
 
 xenstored.a: $(XENSTORED_OBJS-y)
diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index 86ab330eaf..c045a6e5db 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -20,10 +20,6 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <poll.h>
-#ifndef NO_SOCKETS
-#include <sys/socket.h>
-#include <sys/un.h>
-#endif
 #include <sys/time.h>
 #include <time.h>
 #include <unistd.h>
@@ -61,8 +57,6 @@ static unsigned int current_array_size;
 static unsigned int nr_fds;
 static unsigned int delayed_requests;
 
-static int sock = -1;
-
 int orig_argc;
 char **orig_argv;
 
@@ -486,7 +480,7 @@ fail:
 	return -1;
 }
 
-static void initialize_fds(int *p_sock_pollfd_idx, int *ptimeout)
+static void initialize_fds(int *ptimeout)
 {
 	struct connection *conn;
 	uint64_t msecs;
@@ -499,8 +493,6 @@ static void initialize_fds(int *p_sock_pollfd_idx, int *ptimeout)
 	*ptimeout = delayed_requests ? 1000 : -1;
 
 	set_special_fds();
-	if (sock != -1)
-		*p_sock_pollfd_idx = set_fd(sock, POLLIN|POLLPRI);
 
 	if (xce_handle != NULL)
 		xce_pollfd_idx = set_fd(xenevtchn_fd(xce_handle),
@@ -2260,97 +2252,6 @@ struct connection *get_connection_by_id(unsigned int conn_id)
 	return NULL;
 }
 
-#ifdef NO_SOCKETS
-static void accept_connection(int sock)
-{
-}
-#else
-static int writefd(struct connection *conn, const void *data, unsigned int len)
-{
-	int rc;
-
-	while ((rc = write(conn->fd, data, len)) < 0) {
-		if (errno == EAGAIN) {
-			rc = 0;
-			break;
-		}
-		if (errno != EINTR)
-			break;
-	}
-
-	return rc;
-}
-
-static int readfd(struct connection *conn, void *data, unsigned int len)
-{
-	int rc;
-
-	while ((rc = read(conn->fd, data, len)) < 0) {
-		if (errno == EAGAIN) {
-			rc = 0;
-			break;
-		}
-		if (errno != EINTR)
-			break;
-	}
-
-	/* Reading zero length means we're done with this connection. */
-	if ((rc == 0) && (len != 0)) {
-		errno = EBADF;
-		rc = -1;
-	}
-
-	return rc;
-}
-
-static bool socket_can_process(struct connection *conn, int mask)
-{
-	if (conn->pollfd_idx == -1)
-		return false;
-
-	if (poll_fds[conn->pollfd_idx].revents & ~(POLLIN | POLLOUT)) {
-		talloc_free(conn);
-		return false;
-	}
-
-	return (poll_fds[conn->pollfd_idx].revents & mask);
-}
-
-static bool socket_can_write(struct connection *conn)
-{
-	return socket_can_process(conn, POLLOUT);
-}
-
-static bool socket_can_read(struct connection *conn)
-{
-	return socket_can_process(conn, POLLIN);
-}
-
-const struct interface_funcs socket_funcs = {
-	.write = writefd,
-	.read = readfd,
-	.can_write = socket_can_write,
-	.can_read = socket_can_read,
-};
-
-static void accept_connection(int sock)
-{
-	int fd;
-	struct connection *conn;
-
-	fd = accept(sock, NULL, NULL);
-	if (fd < 0)
-		return;
-
-	conn = new_connection(&socket_funcs);
-	if (conn) {
-		conn->fd = fd;
-		conn->id = dom0_domid;
-	} else
-		close(fd);
-}
-#endif
-
 /* We create initial nodes manually. */
 static void manual_node(const char *name, const char *child)
 {
@@ -2579,46 +2480,6 @@ void corrupt(struct connection *conn, const char *fmt, ...)
 	errno = saved_errno;
 }
 
-#ifndef NO_SOCKETS
-static void destroy_fds(void)
-{
-	if (sock >= 0)
-		close(sock);
-}
-
-void init_sockets(void)
-{
-	struct sockaddr_un addr;
-	const char *soc_str = xenstore_daemon_path();
-
-	if (!soc_str)
-		barf_perror("Failed to obtain xs domain socket");
-
-	/* Create sockets for them to listen to. */
-	atexit(destroy_fds);
-	sock = socket(PF_UNIX, SOCK_STREAM, 0);
-	if (sock < 0)
-		barf_perror("Could not create socket");
-
-	/* FIXME: Be more sophisticated, don't mug running daemon. */
-	unlink(soc_str);
-
-	addr.sun_family = AF_UNIX;
-
-	if(strlen(soc_str) >= sizeof(addr.sun_path))
-		barf_perror("socket string '%s' too long", soc_str);
-	strcpy(addr.sun_path, soc_str);
-	if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) != 0)
-		barf_perror("Could not bind socket to %s", soc_str);
-
-	if (chmod(soc_str, 0600) != 0)
-		barf_perror("Could not chmod sockets");
-
-	if (listen(sock, 1) != 0)
-		barf_perror("Could not listen on sockets");
-}
-#endif
-
 static void usage(void)
 {
 	fprintf(stderr,
@@ -2796,7 +2657,6 @@ int set_trace_switch(const char *arg)
 int main(int argc, char *argv[])
 {
 	int opt;
-	int sock_pollfd_idx = -1;
 	bool dofork = true;
 	bool live_update = false;
 	const char *pidfile = NULL;
@@ -2907,7 +2767,7 @@ int main(int argc, char *argv[])
 	check_store();
 
 	/* Get ready to listen to the tools. */
-	initialize_fds(&sock_pollfd_idx, &timeout);
+	initialize_fds(&timeout);
 
 	late_init(live_update);
 
@@ -2923,16 +2783,6 @@ int main(int argc, char *argv[])
 
 		handle_special_fds();
 
-		if (sock_pollfd_idx != -1) {
-			if (poll_fds[sock_pollfd_idx].revents & ~POLLIN) {
-				barf_perror("sock poll failed");
-				break;
-			} else if (poll_fds[sock_pollfd_idx].revents & POLLIN) {
-				accept_connection(sock);
-				sock_pollfd_idx = -1;
-			}
-		}
-
 		if (xce_pollfd_idx != -1) {
 			if (poll_fds[xce_pollfd_idx].revents & ~POLLIN) {
 				barf_perror("xce_handle poll failed");
@@ -2986,7 +2836,7 @@ int main(int argc, char *argv[])
 			}
 		}
 
-		initialize_fds(&sock_pollfd_idx, &timeout);
+		initialize_fds(&timeout);
 	}
 }
 
@@ -2999,7 +2849,7 @@ const char *dump_state_global(FILE *fp)
 	head.length = sizeof(glb);
 	if (fwrite(&head, sizeof(head), 1, fp) != 1)
 		return "Dump global state error";
-	glb.socket_fd = sock;
+	glb.socket_fd = get_socket_fd();
 	glb.evtchn_fd = xenevtchn_fd(xce_handle);
 	if (fwrite(&glb, sizeof(glb), 1, fp) != 1)
 		return "Dump global state error";
@@ -3235,7 +3085,7 @@ void read_state_global(const void *ctx, const void *state)
 {
 	const struct xs_state_global *glb = state;
 
-	sock = glb->socket_fd;
+	set_socket_fd(glb->socket_fd);
 
 	domain_init(glb->evtchn_fd);
 }
diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index 44c4d0f8b8..6180ec8b5c 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -301,6 +301,7 @@ int rm_node(struct connection *conn, const void *ctx, const char *name);
 
 void setup_structure(bool live_update);
 struct connection *new_connection(const struct interface_funcs *funcs);
+struct connection *add_socket_connection(int fd);
 struct connection *get_connection_by_id(unsigned int conn_id);
 void check_store(void);
 void corrupt(struct connection *conn, const char *fmt, ...);
@@ -394,14 +395,12 @@ int set_fd(int fd, short events);
 void set_special_fds(void);
 void handle_special_fds(void);
 
-void init_sockets(void);
+int get_socket_fd(void);
+void set_socket_fd(int fd);
 
 /* Close stdin/stdout/stderr to complete daemonize */
 void finish_daemonize(void);
 
-#ifndef NO_SOCKETS
-extern const struct interface_funcs socket_funcs;
-#endif
 extern xengnttab_handle **xgt_handle;
 
 int remember_string(struct hashtable *hash, const char *str);
diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index 6ef136e01f..040df98b8c 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -1739,14 +1739,7 @@ void read_state_connection(const void *ctx, const void *state)
 	struct domain *domain, *tdomain;
 
 	if (sc->conn_type == XS_STATE_CONN_TYPE_SOCKET) {
-#ifdef NO_SOCKETS
-		barf("socket based connection without sockets");
-#else
-		conn = new_connection(&socket_funcs);
-		if (!conn)
-			barf("error restoring connection");
-		conn->fd = sc->spec.socket_fd;
-#endif
+		conn = add_socket_connection(sc->spec.socket_fd);
 	} else {
 		domain = introduce_domain(ctx, sc->spec.ring.domid,
 					  sc->spec.ring.evtchn, true);
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index 3208169187..6d0c11423c 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -18,12 +18,18 @@
 #include <sys/types.h>
 #include <sys/mman.h>
 #include "core.h"
+#include "utils.h"
 #include <xen/grant_table.h>
 
 void finish_daemonize(void)
 {
 }
 
+struct connection *add_socket_connection(int fd)
+{
+	barf("socket based connection without sockets");
+}
+
 evtchn_port_t get_xenbus_evtchn(void)
 {
 	return dom0_event;
@@ -55,3 +61,12 @@ void set_special_fds(void)
 void handle_special_fds(void)
 {
 }
+
+int get_socket_fd(void)
+{
+	return -1;
+}
+
+void set_socket_fd(int fd)
+{
+}
diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c
index 1ea8475293..496329dfd1 100644
--- a/tools/xenstored/posix.c
+++ b/tools/xenstored/posix.c
@@ -24,6 +24,8 @@
 #include <stdlib.h>
 #include <syslog.h>
 #include <sys/mman.h>
+#include <sys/socket.h>
+#include <sys/un.h>
 #if defined(HAVE_SYSTEMD)
 #include <systemd/sd-daemon.h>
 #endif
@@ -32,10 +34,14 @@
 #include "utils.h"
 #include "core.h"
 #include "osdep.h"
+#include "talloc.h"
 
 static int reopen_log_pipe0_pollfd_idx = -1;
 static int reopen_log_pipe[2];
 
+static int sock_pollfd_idx = -1;
+static int sock = -1;
+
 static void write_pidfile(const char *pidfile)
 {
 	char buf[100];
@@ -180,6 +186,142 @@ void *xenbus_map(void)
 	return addr;
 }
 
+static int writefd(struct connection *conn, const void *data, unsigned int len)
+{
+	int rc;
+
+	while ((rc = write(conn->fd, data, len)) < 0) {
+		if (errno == EAGAIN) {
+			rc = 0;
+			break;
+		}
+		if (errno != EINTR)
+			break;
+	}
+
+	return rc;
+}
+
+static int readfd(struct connection *conn, void *data, unsigned int len)
+{
+	int rc;
+
+	while ((rc = read(conn->fd, data, len)) < 0) {
+		if (errno == EAGAIN) {
+			rc = 0;
+			break;
+		}
+		if (errno != EINTR)
+			break;
+	}
+
+	/* Reading zero length means we're done with this connection. */
+	if ((rc == 0) && (len != 0)) {
+		errno = EBADF;
+		rc = -1;
+	}
+
+	return rc;
+}
+
+static bool socket_can_process(struct connection *conn, int mask)
+{
+	if (conn->pollfd_idx == -1)
+		return false;
+
+	if (poll_fds[conn->pollfd_idx].revents & ~(POLLIN | POLLOUT)) {
+		talloc_free(conn);
+		return false;
+	}
+
+	return (poll_fds[conn->pollfd_idx].revents & mask);
+}
+
+static bool socket_can_write(struct connection *conn)
+{
+	return socket_can_process(conn, POLLOUT);
+}
+
+static bool socket_can_read(struct connection *conn)
+{
+	return socket_can_process(conn, POLLIN);
+}
+
+static const struct interface_funcs socket_funcs = {
+	.write = writefd,
+	.read = readfd,
+	.can_write = socket_can_write,
+	.can_read = socket_can_read,
+};
+
+static void accept_connection(int sock)
+{
+	int fd;
+	struct connection *conn;
+
+	fd = accept(sock, NULL, NULL);
+	if (fd < 0)
+		return;
+
+	conn = new_connection(&socket_funcs);
+	if (conn) {
+		conn->fd = fd;
+		conn->id = dom0_domid;
+	} else
+		close(fd);
+}
+
+static void destroy_fds(void)
+{
+	if (sock >= 0)
+		close(sock);
+}
+
+static void init_sockets(void)
+{
+	struct sockaddr_un addr;
+	const char *soc_str = xenstore_daemon_path();
+
+	if (!soc_str)
+		barf_perror("Failed to obtain xs domain socket");
+
+	/* Create sockets for them to listen to. */
+	atexit(destroy_fds);
+	sock = socket(PF_UNIX, SOCK_STREAM, 0);
+	if (sock < 0)
+		barf_perror("Could not create socket");
+
+	/* FIXME: Be more sophisticated, don't mug running daemon. */
+	unlink(soc_str);
+
+	addr.sun_family = AF_UNIX;
+
+	if (strlen(soc_str) >= sizeof(addr.sun_path))
+		barf_perror("socket string '%s' too long", soc_str);
+	strcpy(addr.sun_path, soc_str);
+	if (bind(sock, (struct sockaddr *)&addr, sizeof(addr)) != 0)
+		barf_perror("Could not bind socket to %s", soc_str);
+
+	if (chmod(soc_str, 0600) != 0)
+		barf_perror("Could not chmod sockets");
+
+	if (listen(sock, 1) != 0)
+		barf_perror("Could not listen on sockets");
+}
+
+
+struct connection *add_socket_connection(int fd)
+{
+	struct connection *conn;
+
+	conn = new_connection(&socket_funcs);
+	if (!conn)
+		barf("error restoring connection");
+	conn->fd = fd;
+
+	return conn;
+}
+
 void early_init(bool live_update, bool dofork, const char *pidfile)
 {
 	reopen_log();
@@ -212,6 +354,9 @@ void set_special_fds(void)
 	if (reopen_log_pipe[0] != -1)
 		reopen_log_pipe0_pollfd_idx =
 			set_fd(reopen_log_pipe[0], POLLIN|POLLPRI);
+
+	if (sock != -1)
+		sock_pollfd_idx = set_fd(sock, POLLIN|POLLPRI);
 }
 
 void handle_special_fds(void)
@@ -231,6 +376,15 @@ void handle_special_fds(void)
 		}
 		reopen_log_pipe0_pollfd_idx = -1;
 	}
+
+	if (sock_pollfd_idx != -1) {
+		if (poll_fds[sock_pollfd_idx].revents & ~POLLIN) {
+			barf_perror("sock poll failed");
+		} else if (poll_fds[sock_pollfd_idx].revents & POLLIN) {
+			accept_connection(sock);
+			sock_pollfd_idx = -1;
+		}
+	}
 }
 
 void late_init(bool live_update)
@@ -242,3 +396,13 @@ void late_init(bool live_update)
 	}
 #endif
 }
+
+int get_socket_fd(void)
+{
+	return sock;
+}
+
+void set_socket_fd(int fd)
+{
+	sock = fd;
+}
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 00:45:03 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 00:45:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677191.1053619 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW3j-0007gq-EZ; Wed, 07 Feb 2024 00:45:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677191.1053619; Wed, 07 Feb 2024 00:45:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW3j-0007gi-Bn; Wed, 07 Feb 2024 00:45:03 +0000
Received: by outflank-mailman (input) for mailman id 677191;
 Wed, 07 Feb 2024 00:45:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW3i-0007ga-Qd
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:45:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW3i-0001Ly-Pt
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:45:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW3i-0004DL-Ow
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:45:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=m8P1ycsKXYjCcUFPjooPDYVtF/9M9jS1G/vX33Zhns8=; b=GPMy/NhYfBrzXhwZkaCh/e8ZZr
	q5fPM+PMQZFaxnhMXYHaamyS5R2Wo+5xaRBcE4m+z2P45UIOPbHW3lWEbOVpOzDGXIENj28Xto4hu
	iF5STUnVxX8Oiw5OFhWwMa9JPX69LibC3dThL/960WadyZorW1cSq8K8QK7kzWPErLZA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xenstored: get own domid in stubdom case
Message-Id: <E1rXW3i-0004DL-Ow@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 00:45:02 +0000

commit a3e37f7024b0fb25c648315b2edf3583aa140b32
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Mon Feb 5 11:49:54 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon Feb 5 19:26:32 2024 +0000

    tools/xenstored: get own domid in stubdom case
    
    Obtain own domid when running as stubdom.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstored/core.c   | 1 +
 tools/xenstored/core.h   | 1 +
 tools/xenstored/minios.c | 4 ++++
 3 files changed, 6 insertions(+)

diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index c045a6e5db..9eb3cdf446 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -2557,6 +2557,7 @@ static struct option options[] = {
 int dom0_domid = 0;
 int dom0_event = 0;
 int priv_domid = 0;
+domid_t stub_domid = DOMID_INVALID;
 
 static unsigned int get_optval_uint(const char *arg)
 {
diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index 6180ec8b5c..f6af086f01 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -361,6 +361,7 @@ do {						\
 extern int dom0_domid;
 extern int dom0_event;
 extern int priv_domid;
+extern domid_t stub_domid;
 extern bool keep_orphans;
 
 extern struct pollfd *poll_fds;
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index 6d0c11423c..22ac8defbd 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -20,6 +20,7 @@
 #include "core.h"
 #include "utils.h"
 #include <xen/grant_table.h>
+#include <mini-os/lib.h>
 
 void finish_daemonize(void)
 {
@@ -48,6 +49,9 @@ void unmap_xenbus(void *interface)
 
 void early_init(bool live_update, bool dofork, const char *pidfile)
 {
+	stub_domid = get_domid();
+	if (stub_domid == DOMID_INVALID)
+		barf("could not get own domid");
 }
 
 void late_init(bool live_update)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 00:45:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 00:45:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677192.1053623 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW3t-0007jX-Fx; Wed, 07 Feb 2024 00:45:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677192.1053623; Wed, 07 Feb 2024 00:45:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW3t-0007jP-DH; Wed, 07 Feb 2024 00:45:13 +0000
Received: by outflank-mailman (input) for mailman id 677192;
 Wed, 07 Feb 2024 00:45:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW3s-0007jI-Tg
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:45:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW3s-0001M5-Sw
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:45:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW3s-0004Fs-S9
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:45:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=09QkLgbIV21PYBoN/4SX2KWAK7gsDPLOCbxInZZ7Fgg=; b=eGvJNvvcNpPQCr3FSzMy3h+1Ua
	2N7GuQCC6YAGb5GKh+Y2WESs26P+Sh45ydwkrCfGOOVR7et9ojyo4aBAsiviIl472IgxGxHf92jm6
	XovhObh/DjncKtvgpBHYvTRbNtH93/mIssSbKU6C3+zu3DWsx9OuYZseh81ZRl+abCwY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xenstored: rework ring page (un)map functions
Message-Id: <E1rXW3s-0004Fs-S9@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 00:45:12 +0000

commit 5edc819ed50d4d0bc0de422eed72301b69309862
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Mon Feb 5 11:49:55 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon Feb 5 19:26:32 2024 +0000

    tools/xenstored: rework ring page (un)map functions
    
    When [un]mapping the ring page of a Xenstore client, different actions
    are required for "normal" guests and dom0. Today this distinction is
    made at call site.
    
    Move this distinction into [un]map_interface() instead, avoiding code
    duplication and preparing special handling for [un]mapping the stub
    domain's ring page.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstored/domain.c | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index 040df98b8c..af80a8221d 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -497,14 +497,20 @@ static const struct interface_funcs domain_funcs = {
 
 static void *map_interface(domid_t domid)
 {
+	if (domid == xenbus_master_domid())
+		return xenbus_map();
+
 	return xengnttab_map_grant_ref(*xgt_handle, domid,
 				       GNTTAB_RESERVED_XENSTORE,
 				       PROT_READ|PROT_WRITE);
 }
 
-static void unmap_interface(void *interface)
+static void unmap_interface(domid_t domid, void *interface)
 {
-	xengnttab_unmap(*xgt_handle, interface, 1);
+	if (domid == xenbus_master_domid())
+		unmap_xenbus(interface);
+	else
+		xengnttab_unmap(*xgt_handle, interface, 1);
 }
 
 static int domain_tree_remove_sub(const void *ctx, struct connection *conn,
@@ -594,14 +600,8 @@ static int destroy_domain(void *_domain)
 			eprintf("> Unbinding port %i failed!\n", domain->port);
 	}
 
-	if (domain->interface) {
-		/* Domain 0 was mapped by dom0_init, so it must be unmapped
-		   using munmap() and not the grant unmap call. */
-		if (domain->domid == dom0_domid)
-			unmap_xenbus(domain->interface);
-		else
-			unmap_interface(domain->interface);
-	}
+	if (domain->interface)
+		unmap_interface(domain->domid, domain->interface);
 
 	fire_special_watches("@releaseDomain");
 
@@ -966,18 +966,13 @@ static struct domain *introduce_domain(const void *ctx,
 		return NULL;
 
 	if (!domain->introduced) {
-		interface = is_master_domain ? xenbus_map()
-					     : map_interface(domid);
+		interface = map_interface(domid);
 		if (!interface && !restore)
 			return NULL;
 		if (new_domain(domain, port, restore)) {
 			rc = errno;
-			if (interface) {
-				if (is_master_domain)
-					unmap_xenbus(interface);
-				else
-					unmap_interface(interface);
-			}
+			if (interface)
+				unmap_interface(domid, interface);
 			errno = rc;
 			return NULL;
 		}
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 00:45:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 00:45:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677193.1053626 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW43-0007m8-HN; Wed, 07 Feb 2024 00:45:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677193.1053626; Wed, 07 Feb 2024 00:45:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW43-0007m0-En; Wed, 07 Feb 2024 00:45:23 +0000
Received: by outflank-mailman (input) for mailman id 677193;
 Wed, 07 Feb 2024 00:45:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW43-0007lo-0j
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:45:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW43-0001MW-04
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:45:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW42-0004Gz-VP
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:45:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=HmUu7MLWLAZ7MIhva4ah5AOvRTQYkYKKEo+3z8QO1Q4=; b=v8HndZ1u93DyVCgA86tTmHxvbx
	x0YAWvjiHWdAl6UuiV9xZDY/bcw46gTFnfob+c+tr/0tHP75Ki8JSvuRG8/hVZ80Mez6EgaTvYxKR
	zOfkIPXPZS9EaermyjzCvq7tEcFVubRLGUMDWglQhJTKJUquMXobxJJKVpbYE5dWiJMs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xenstored: split domain_init()
Message-Id: <E1rXW42-0004Gz-VP@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 00:45:22 +0000

commit 097388d520eb104ebd93b486d126f319536a54e4
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Mon Feb 5 11:49:56 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon Feb 5 19:26:32 2024 +0000

    tools/xenstored: split domain_init()
    
    Today domain_init() is called either just before calling dom0_init()
    in case no live update is being performed, or it is called after
    reading the global state from read_state_global(), as the event
    channel fd is needed.
    
    Split up domain_init() into a preparation part which can be called
    unconditionally, and in a part setting up the event channel handle.
    
    Note that there is no chance that chk_domain_generation() can be
    called now before xc_handle has been setup, so there is no need for
    the related special case anymore.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstored/core.c   |  2 ++
 tools/xenstored/domain.c | 12 ++++++------
 tools/xenstored/domain.h |  1 +
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index 9eb3cdf446..3bf2ec7734 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -2742,6 +2742,8 @@ int main(int argc, char *argv[])
 
 	talloc_enable_null_tracking();
 
+	domain_early_init();
+
 	/* Listen to hypervisor. */
 	if (!live_update) {
 		domain_init(-1);
diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index af80a8221d..621b415088 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -1224,10 +1224,8 @@ static int domeq_fn(const void *key1, const void *key2)
 	return *(const unsigned int *)key1 == *(const unsigned int *)key2;
 }
 
-void domain_init(int evtfd)
+void domain_early_init(void)
 {
-	int rc;
-
 	/* Start with a random rather low domain count for the hashtable. */
 	domhash = create_hashtable(NULL, "domains", domhash_fn, domeq_fn, 0);
 	if (!domhash)
@@ -1258,6 +1256,11 @@ void domain_init(int evtfd)
 	xengnttab_set_max_grants(*xgt_handle, DOMID_FIRST_RESERVED);
 
 	talloc_set_destructor(xgt_handle, close_xgt_handle);
+}
+
+void domain_init(int evtfd)
+{
+	int rc;
 
 	if (evtfd < 0)
 		xce_handle = xenevtchn_open(NULL, XENEVTCHN_NO_CLOEXEC);
@@ -1291,9 +1294,6 @@ static bool chk_domain_generation(unsigned int domid, uint64_t gen)
 {
 	struct domain *d;
 
-	if (!xc_handle && domid == dom0_domid)
-		return true;
-
 	d = find_domain_struct(domid);
 
 	return d && d->generation <= gen;
diff --git a/tools/xenstored/domain.h b/tools/xenstored/domain.h
index 7625dca8cd..224c4c23e2 100644
--- a/tools/xenstored/domain.h
+++ b/tools/xenstored/domain.h
@@ -82,6 +82,7 @@ int do_get_domain_path(const void *ctx, struct connection *conn,
 int do_reset_watches(const void *ctx, struct connection *conn,
 		     struct buffered_data *in);
 
+void domain_early_init(void);
 void domain_init(int evtfd);
 void dom0_init(void);
 void domain_deinit(void);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 00:45:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 00:45:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677194.1053630 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW4E-0007p9-Ig; Wed, 07 Feb 2024 00:45:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677194.1053630; Wed, 07 Feb 2024 00:45:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW4E-0007p2-GE; Wed, 07 Feb 2024 00:45:34 +0000
Received: by outflank-mailman (input) for mailman id 677194;
 Wed, 07 Feb 2024 00:45:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW4D-0007or-40
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:45:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW4D-0001Mh-3J
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:45:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW4D-0004Hu-2P
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:45:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=XfANxJBCZmPoP2GXE7AhNuhf/C0zOjyykwITQc+slKw=; b=AZhv9AqXhoeiylWhEEpN6P1B5R
	M7oW3rqokj/ewc+oYiMk9WA2Z7JhgKotyfSKGZ4aHOEdjm0GpwTcqwymUFAO6c14QPba2bt0mfWWT
	r6Ztwgshqbthvb/4JeTAve6m2mhoDl2W6KP6pJQPm2Ug6OCnmeC9umAybr2kt/c0gDII=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xenstored: map stubdom interface
Message-Id: <E1rXW4D-0004Hu-2P@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 00:45:33 +0000

commit 3ce2e1f606cef3aa16b856396b31068c447b1262
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Mon Feb 5 11:49:57 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon Feb 5 19:26:32 2024 +0000

    tools/xenstored: map stubdom interface
    
    When running as stubdom, map the stubdom's Xenstore ring page in order
    to support using the 9pfs frontend.
    
    Use the same pattern as in dom0_init() when running as daemon in dom0
    (introduce the own domain, then send an event to the client side to
    signal Xenstore is ready to communicate).
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstored/core.c   |  2 ++
 tools/xenstored/domain.c | 27 ++++++++++++++++++++++++++-
 tools/xenstored/domain.h |  1 +
 3 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index 3bf2ec7734..48fc787ac1 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -2767,6 +2767,8 @@ int main(int argc, char *argv[])
 		lu_read_state();
 #endif
 
+	stubdom_init();
+
 	check_store();
 
 	/* Get ready to listen to the tools. */
diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index 621b415088..1a7d5e9756 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -37,6 +37,10 @@
 #include <xenctrl.h>
 #include <xen/grant_table.h>
 
+#ifdef __MINIOS__
+#include <mini-os/xenbus.h>
+#endif
+
 static xc_interface **xc_handle;
 xengnttab_handle **xgt_handle;
 static evtchn_port_t virq_port;
@@ -500,6 +504,11 @@ static void *map_interface(domid_t domid)
 	if (domid == xenbus_master_domid())
 		return xenbus_map();
 
+#ifdef __MINIOS__
+	if (domid == stub_domid)
+		return xenstore_buf;
+#endif
+
 	return xengnttab_map_grant_ref(*xgt_handle, domid,
 				       GNTTAB_RESERVED_XENSTORE,
 				       PROT_READ|PROT_WRITE);
@@ -509,7 +518,7 @@ static void unmap_interface(domid_t domid, void *interface)
 {
 	if (domid == xenbus_master_domid())
 		unmap_xenbus(interface);
-	else
+	else if (domid != stub_domid)
 		xengnttab_unmap(*xgt_handle, interface, 1);
 }
 
@@ -1214,6 +1223,22 @@ void dom0_init(void)
 	xenevtchn_notify(xce_handle, dom0->port);
 }
 
+void stubdom_init(void)
+{
+#ifdef __MINIOS__
+	struct domain *stubdom;
+
+	if (stub_domid < 0)
+		return;
+
+	stubdom = introduce_domain(NULL, stub_domid, xenbus_evtchn, false);
+	if (!stubdom)
+		barf_perror("Failed to initialize stubdom");
+
+	xenevtchn_notify(xce_handle, stubdom->port);
+#endif
+}
+
 static unsigned int domhash_fn(const void *k)
 {
 	return *(const unsigned int *)k;
diff --git a/tools/xenstored/domain.h b/tools/xenstored/domain.h
index 224c4c23e2..844ac11510 100644
--- a/tools/xenstored/domain.h
+++ b/tools/xenstored/domain.h
@@ -85,6 +85,7 @@ int do_reset_watches(const void *ctx, struct connection *conn,
 void domain_early_init(void);
 void domain_init(int evtfd);
 void dom0_init(void);
+void stubdom_init(void);
 void domain_deinit(void);
 void ignore_connection(struct connection *conn, unsigned int err);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 00:45:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 00:45:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677195.1053636 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW4O-0007st-Mz; Wed, 07 Feb 2024 00:45:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677195.1053636; Wed, 07 Feb 2024 00:45:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXW4O-0007sh-J9; Wed, 07 Feb 2024 00:45:44 +0000
Received: by outflank-mailman (input) for mailman id 677195;
 Wed, 07 Feb 2024 00:45:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW4N-0007sY-72
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:45:43 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW4N-0001Mr-6F
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:45:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXW4N-0004Im-5T
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 00:45:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Y1PhEQ+UDb2V+ibRRMyM2T30SLKNGGk+4cbur+22HW8=; b=FV+OuB1bQLmdh1tyQ2d67TbXl1
	ZH3h4XrJSXxp1Nr21/dE0DiUzpIRFRRrfATE8QZQKG6puAroCLSbwl5LAjfdLZlmEpgcGLqkJgv7K
	EgpCt1pJJt0GZ8lOnUuZkrU86G7x9nOQur8LnSecJ6ZKvUcpO90+olc/mRAG03P3blG8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/evtchn: Remove useless assignment in evtchn_alloc_unbound()
Message-Id: <E1rXW4N-0004Im-5T@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 00:45:43 +0000

commit 1cb7949b37b3d8892d8a3cea3ad1e2448352a34d
Author:     Frediano Ziglio <frediano.ziglio@cloud.com>
AuthorDate: Mon Feb 5 10:46:37 2024 +0000
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon Feb 5 21:17:44 2024 +0000

    xen/evtchn: Remove useless assignment in evtchn_alloc_unbound()
    
    The variable 'rc' is assigned later, that value is never used.
    
    Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
 xen/common/event_channel.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
index a7a004a084..15aec5dcbb 100644
--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -324,8 +324,6 @@ int evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc, evtchn_port_t port)
         goto out;
     }
 
-    rc = 0;
-
     chn = evtchn_from_port(d, port);
 
     rc = xsm_evtchn_unbound(XSM_TARGET, d, chn, alloc->remote_dom);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 12:55:09 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 12:55:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677527.1054144 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhSB-0000Nu-Mb; Wed, 07 Feb 2024 12:55:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677527.1054144; Wed, 07 Feb 2024 12:55:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhSB-0000Nm-K8; Wed, 07 Feb 2024 12:55:03 +0000
Received: by outflank-mailman (input) for mailman id 677527;
 Wed, 07 Feb 2024 12:55:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSA-0000Ng-Mz
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSA-0001Vo-EH
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSA-0004cq-BO
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=JAEV5gPkKz+1TTaWHbc5c+Xc8eRi/JU6YsqoDdYYAt8=; b=Eu21ttmXy+1KPmC6/82KPa0cUN
	Ic+g8bASA87mFaebwwU5neFDg2hv++uKjq4PvOATYaRFw4SDP99qHa7B9jGWFuxEtwMUEbyj10RcB
	0Riisomv4ifaGsB7Etp9eWvG27YPid05G5SBnhYxRDFWZSHglCov6TsqZfsjbSAT4ik0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] setup: Move vm_init() before acpi calls
Message-Id: <E1rXhSA-0004cq-BO@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 12:55:02 +0000

commit 2213b5a293f7a93001917e1e97f5096a017c2a80
Author:     Wei Liu <wei.liu2@citrix.com>
AuthorDate: Tue Feb 6 11:53:04 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 6 11:53:04 2024 +0100

    setup: Move vm_init() before acpi calls
    
    After the direct map removal, pages from the boot allocator are not
    going to be mapped in the direct map. Although we have map_domain_page,
    they are ephemeral and are less helpful for mappings that are more than a
    page, so we want a mechanism to globally map a range of pages, which is
    what vmap is for. Therefore, we bring vm_init into early boot stage.
    
    To allow vmap to be initialised and used in early boot, we need to
    modify vmap to receive pages from the boot allocator during early boot
    stage.
    
    Signed-off-by: Wei Liu <wei.liu2@citrix.com>
    Signed-off-by: David Woodhouse <dwmw2@amazon.com>
    Signed-off-by: Hongyan Xia <hongyxia@amazon.com>
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Signed-off-by: Elias El Yandouzi <eliasely@amazon.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 xen/arch/arm/setup.c |  4 ++--
 xen/arch/x86/setup.c | 31 ++++++++++++++++++++-----------
 xen/common/vmap.c    | 35 +++++++++++++++++++++++++++--------
 3 files changed, 49 insertions(+), 21 deletions(-)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 59dd9bb25a..7e28f62d09 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -748,6 +748,8 @@ void asmlinkage __init start_xen(unsigned long boot_phys_offset,
 
     setup_mm();
 
+    vm_init();
+
     /* Parse the ACPI tables for possible boot-time configuration */
     acpi_boot_table_init();
 
@@ -759,8 +761,6 @@ void asmlinkage __init start_xen(unsigned long boot_phys_offset,
      */
     system_state = SYS_STATE_boot;
 
-    vm_init();
-
     if ( acpi_disabled )
     {
         printk("Booting using Device Tree\n");
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index ee682dd136..a0d99f8324 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -989,6 +989,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p)
     int i, j, e820_warn = 0, bytes = 0;
     unsigned long eb_start, eb_end;
     bool acpi_boot_table_init_done = false, relocated = false;
+    bool vm_init_done = false;
     int ret;
     struct ns16550_defaults ns16550 = {
         .data_bits = 8,
@@ -1531,12 +1532,23 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p)
             continue;
 
         if ( !acpi_boot_table_init_done &&
-             s >= (1ULL << 32) &&
-             !acpi_boot_table_init() )
+             s >= (1ULL << 32) )
         {
-            acpi_boot_table_init_done = true;
-            srat_parse_regions(s);
-            setup_max_pdx(raw_max_page);
+            /*
+             * We only initialise vmap and acpi after going through the bottom
+             * 4GiB, so that we have enough pages in the boot allocator.
+             */
+            if ( !vm_init_done )
+            {
+                vm_init();
+                vm_init_done = true;
+            }
+            if ( !acpi_boot_table_init() )
+            {
+                acpi_boot_table_init_done = true;
+                srat_parse_regions(s);
+                setup_max_pdx(raw_max_page);
+            }
         }
 
         if ( pfn_to_pdx((e - 1) >> PAGE_SHIFT) >= max_pdx )
@@ -1722,6 +1734,9 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p)
 
     init_frametable();
 
+    if ( !vm_init_done )
+        vm_init();
+
     if ( !acpi_boot_table_init_done )
         acpi_boot_table_init();
 
@@ -1761,12 +1776,6 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p)
         end_boot_allocator();
 
     system_state = SYS_STATE_boot;
-    /*
-     * No calls involving ACPI code should go between the setting of
-     * SYS_STATE_boot and vm_init() (or else acpi_os_{,un}map_memory()
-     * will break).
-     */
-    vm_init();
 
     bsp_stack = cpu_alloc_stack(0);
     if ( !bsp_stack )
diff --git a/xen/common/vmap.c b/xen/common/vmap.c
index 830f64c5ef..fc5c70da4d 100644
--- a/xen/common/vmap.c
+++ b/xen/common/vmap.c
@@ -34,10 +34,19 @@ void __init vm_init_type(enum vmap_region type, void *start, void *end)
 
     for ( i = 0, va = (unsigned long)vm_bitmap(type); i < nr; ++i, va += PAGE_SIZE )
     {
-        struct page_info *pg = alloc_domheap_page(NULL, 0);
+        mfn_t mfn;
         int rc;
 
-        rc = map_pages_to_xen(va, page_to_mfn(pg), 1, PAGE_HYPERVISOR);
+        if ( system_state == SYS_STATE_early_boot )
+            mfn = alloc_boot_pages(1, 1);
+        else
+        {
+            struct page_info *pg = alloc_domheap_page(NULL, 0);
+
+            BUG_ON(!pg);
+            mfn = page_to_mfn(pg);
+        }
+        rc = map_pages_to_xen(va, mfn, 1, PAGE_HYPERVISOR);
         BUG_ON(rc);
 
         clear_page((void *)va);
@@ -65,7 +74,7 @@ static void *vm_alloc(unsigned int nr, unsigned int align,
     spin_lock(&vm_lock);
     for ( ; ; )
     {
-        struct page_info *pg;
+        mfn_t mfn;
 
         ASSERT(vm_low[t] == vm_top[t] || !test_bit(vm_low[t], vm_bitmap(t)));
         for ( start = vm_low[t]; start < vm_top[t]; )
@@ -100,9 +109,16 @@ static void *vm_alloc(unsigned int nr, unsigned int align,
         if ( vm_top[t] >= vm_end[t] )
             return NULL;
 
-        pg = alloc_domheap_page(NULL, 0);
-        if ( !pg )
-            return NULL;
+        if ( system_state == SYS_STATE_early_boot )
+            mfn = alloc_boot_pages(1, 1);
+        else
+        {
+            struct page_info *pg = alloc_domheap_page(NULL, 0);
+
+            if ( !pg )
+                return NULL;
+            mfn = page_to_mfn(pg);
+        }
 
         spin_lock(&vm_lock);
 
@@ -110,7 +126,7 @@ static void *vm_alloc(unsigned int nr, unsigned int align,
         {
             unsigned long va = (unsigned long)vm_bitmap(t) + vm_top[t] / 8;
 
-            if ( !map_pages_to_xen(va, page_to_mfn(pg), 1, PAGE_HYPERVISOR) )
+            if ( !map_pages_to_xen(va, mfn, 1, PAGE_HYPERVISOR) )
             {
                 clear_page((void *)va);
                 vm_top[t] += PAGE_SIZE * 8;
@@ -120,7 +136,10 @@ static void *vm_alloc(unsigned int nr, unsigned int align,
             }
         }
 
-        free_domheap_page(pg);
+        if ( system_state == SYS_STATE_early_boot )
+            init_boot_pages(mfn_to_maddr(mfn), mfn_to_maddr(mfn) + PAGE_SIZE);
+        else
+            free_domheap_page(mfn_to_page(mfn));
 
         if ( start >= vm_top[t] )
         {
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 12:55:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 12:55:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677528.1054149 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhSL-0000Q7-OO; Wed, 07 Feb 2024 12:55:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677528.1054149; Wed, 07 Feb 2024 12:55:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhSL-0000Pz-Le; Wed, 07 Feb 2024 12:55:13 +0000
Received: by outflank-mailman (input) for mailman id 677528;
 Wed, 07 Feb 2024 12:55:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSK-0000Pp-J9
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSK-0001Vz-I6
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSK-0004dX-GN
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=D3/gxrdsogjlGfdOrWyNf+3P6Of0qaOT+lwcriB2GyM=; b=PGlTlZA7UbkPutPntKWAVnx61X
	S0a48442677e4+wDuy0pkMkcnn2bvQQ2uui9B51SemW0PSW9zW8oZk7aTAdchiKc3c58p2YA5Xt9t
	vfxCedvlROO6Ge/tQXYmQuLo/MVshvRx1fiwmusoMLsTuuQDy3TEiZf0bseiHYFUwwQ0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/vmap: Introduce vmap_size() and use it
Message-Id: <E1rXhSK-0004dX-GN@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 12:55:12 +0000

commit ef0873946ce3850d6dc16ece512e706dda3bc51c
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Tue Feb 6 11:54:17 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 6 11:54:17 2024 +0100

    xen/vmap: Introduce vmap_size() and use it
    
    vunmap() and vfree() currently duplicate the (small) logic to find the
    size of an vmap area. In a follow-up patch, we will want to introduce
    another one (this time externally).
    
    So introduce a new helper vmap_size() that will return the number of
    pages in the area starting at the given address. Take the opportunity
    to replace the open-coded version.
    
    Note that vfree() was storing the type of the area in a local variable.
    But this seems to have never been used (even when it was introduced).
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Signed-off-by: Elias El Yandouzi <eliasely@amazon.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/common/vmap.c      | 19 ++++++++++---------
 xen/include/xen/vmap.h |  3 +++
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/xen/common/vmap.c b/xen/common/vmap.c
index fc5c70da4d..171271fae3 100644
--- a/xen/common/vmap.c
+++ b/xen/common/vmap.c
@@ -245,14 +245,21 @@ void *vmap(const mfn_t *mfn, unsigned int nr)
     return __vmap(mfn, 1, nr, 1, PAGE_HYPERVISOR, VMAP_DEFAULT);
 }
 
-void vunmap(const void *va)
+unsigned int vmap_size(const void *va)
 {
-    unsigned long addr = (unsigned long)va;
     unsigned int pages = vm_size(va, VMAP_DEFAULT);
 
     if ( !pages )
         pages = vm_size(va, VMAP_XEN);
 
+    return pages;
+}
+
+void vunmap(const void *va)
+{
+    unsigned long addr = (unsigned long)va;
+    unsigned pages = vmap_size(va);
+
 #ifndef _PAGE_NONE
     destroy_xen_mappings(addr, addr + PAGE_SIZE * pages);
 #else /* Avoid tearing down intermediate page tables. */
@@ -328,17 +335,11 @@ void vfree(void *va)
     unsigned int i, pages;
     struct page_info *pg;
     PAGE_LIST_HEAD(pg_list);
-    enum vmap_region type = VMAP_DEFAULT;
 
     if ( !va )
         return;
 
-    pages = vm_size(va, type);
-    if ( !pages )
-    {
-        type = VMAP_XEN;
-        pages = vm_size(va, type);
-    }
+    pages = vmap_size(va);
     ASSERT(pages);
 
     for ( i = 0; i < pages; i++ )
diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h
index 2b7369e062..24c85de490 100644
--- a/xen/include/xen/vmap.h
+++ b/xen/include/xen/vmap.h
@@ -25,6 +25,9 @@ void vfree(void *va);
 
 void __iomem *ioremap(paddr_t pa, size_t len);
 
+/* Return the number of pages in the mapping starting at address 'va' */
+unsigned int vmap_size(const void *va);
+
 static inline void iounmap(void __iomem *va)
 {
     unsigned long addr = (unsigned long)(void __force *)va;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 12:55:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 12:55:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677529.1054153 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhSV-0000Sb-Pk; Wed, 07 Feb 2024 12:55:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677529.1054153; Wed, 07 Feb 2024 12:55:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhSV-0000ST-N8; Wed, 07 Feb 2024 12:55:23 +0000
Received: by outflank-mailman (input) for mailman id 677529;
 Wed, 07 Feb 2024 12:55:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSU-0000SL-Lz
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSU-0001W8-LH
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSU-0004dz-KF
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=HS5i00K4bTmjK2NbcaqVA4tILNsWXRCiXj8XQzFcSUg=; b=2zaxbT654jtbJqF/9B6gEn4ykx
	gQLhngxqTACYWq1HWjO8WVw70Ilv2vEWHCDNNjikz7HzvxJawmfv4rLdo3wfSHmgoTWcGNxFQqtKX
	rfpwMiSmUwf1zi4uJmZ3eyRu7MnmGcM7yCpC4Hsn+Fvk6f5IcR1fH0n7x4oSDdp6PvWs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] acpi: vmap pages in acpi_os_alloc_memory
Message-Id: <E1rXhSU-0004dz-KF@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 12:55:22 +0000

commit f940facaa37059a95769ea9eb638efb062b85b52
Author:     Hongyan Xia <hongyxia@amazon.com>
AuthorDate: Tue Feb 6 11:54:50 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 6 11:54:50 2024 +0100

    acpi: vmap pages in acpi_os_alloc_memory
    
    Also, introduce a wrapper around vmap that maps a contiguous range for
    boot allocations. Unfortunately, the new helper cannot be a static inline
    because the dependencies are a mess. We would need to re-include
    asm/page.h (was removed in aa4b9d1ee653 "include: don't use asm/page.h
    from common headers") and it doesn't look to be enough anymore
    because bits from asm/cpufeature.h is used in the definition of PAGE_NX.
    
    Lastly, with the move to vmap(), it is now easier to find the size
    of the mapping. So pass the whole area to init_boot_pages() rather than
    just the first page.
    
    Signed-off-by: Hongyan Xia <hongyxia@amazon.com>
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Signed-off-by: Elias El Yandouzi <eliasely@amazon.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/common/vmap.c      |  5 +++++
 xen/drivers/acpi/osl.c | 14 ++++++++++++--
 xen/include/xen/vmap.h |  1 +
 3 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/xen/common/vmap.c b/xen/common/vmap.c
index 171271fae3..966a7e763f 100644
--- a/xen/common/vmap.c
+++ b/xen/common/vmap.c
@@ -245,6 +245,11 @@ void *vmap(const mfn_t *mfn, unsigned int nr)
     return __vmap(mfn, 1, nr, 1, PAGE_HYPERVISOR, VMAP_DEFAULT);
 }
 
+void *vmap_contig(mfn_t mfn, unsigned int nr)
+{
+    return __vmap(&mfn, nr, 1, 1, PAGE_HYPERVISOR, VMAP_DEFAULT);
+}
+
 unsigned int vmap_size(const void *va)
 {
     unsigned int pages = vm_size(va, VMAP_DEFAULT);
diff --git a/xen/drivers/acpi/osl.c b/xen/drivers/acpi/osl.c
index 389505f786..ab80d6b2a9 100644
--- a/xen/drivers/acpi/osl.c
+++ b/xen/drivers/acpi/osl.c
@@ -221,7 +221,11 @@ void *__init acpi_os_alloc_memory(size_t sz)
 	void *ptr;
 
 	if (system_state == SYS_STATE_early_boot)
-		return mfn_to_virt(mfn_x(alloc_boot_pages(PFN_UP(sz), 1)));
+	{
+		mfn_t mfn = alloc_boot_pages(PFN_UP(sz), 1);
+
+		return vmap_contig(mfn, PFN_UP(sz));
+	}
 
 	ptr = xmalloc_bytes(sz);
 	ASSERT(!ptr || is_xmalloc_memory(ptr));
@@ -246,5 +250,11 @@ void __init acpi_os_free_memory(void *ptr)
 	if (is_xmalloc_memory(ptr))
 		xfree(ptr);
 	else if (ptr && system_state == SYS_STATE_early_boot)
-		init_boot_pages(__pa(ptr), __pa(ptr) + PAGE_SIZE);
+	{
+		paddr_t addr = mfn_to_maddr(vmap_to_mfn(ptr));
+		unsigned int nr = vmap_size(ptr);
+
+		vunmap(ptr);
+		init_boot_pages(addr, addr + nr * PAGE_SIZE);
+	}
 }
diff --git a/xen/include/xen/vmap.h b/xen/include/xen/vmap.h
index 24c85de490..0c16baa85f 100644
--- a/xen/include/xen/vmap.h
+++ b/xen/include/xen/vmap.h
@@ -15,6 +15,7 @@ void vm_init_type(enum vmap_region type, void *start, void *end);
 void *__vmap(const mfn_t *mfn, unsigned int granularity, unsigned int nr,
              unsigned int align, unsigned int flags, enum vmap_region type);
 void *vmap(const mfn_t *mfn, unsigned int nr);
+void *vmap_contig(mfn_t mfn, unsigned int nr);
 void vunmap(const void *va);
 
 void *vmalloc(size_t size);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 12:55:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 12:55:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677530.1054157 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhSf-0000Uw-RZ; Wed, 07 Feb 2024 12:55:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677530.1054157; Wed, 07 Feb 2024 12:55:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhSf-0000Up-Oc; Wed, 07 Feb 2024 12:55:33 +0000
Received: by outflank-mailman (input) for mailman id 677530;
 Wed, 07 Feb 2024 12:55:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSe-0000Ui-R5
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSe-0001WV-OZ
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSe-0004eS-NR
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ioNhQQ/LJbdgWGJ+e6+bx+YPCRFLTKX93qpCHGzPIg4=; b=jigNLZzs1TzScLaz+tQy+GTDvd
	HPeLJnZgwnKPBXNAHwggwuhLLIvE9XRdZ0LJ2q6UBwnlkcsMrJGtRGzK/N6yOFei+16wM+UbP5zP0
	a6QtvGFHnFikDVQGsClNBZlWlrXiaeniJ4ZY3lo0xTxShjuKxvMnMegrjqxPNV/P+7b0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/numa: vmap the pages for memnodemap
Message-Id: <E1rXhSe-0004eS-NR@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 12:55:32 +0000

commit 861d9877266e48a0007cb6ede59b134697b73025
Author:     Hongyan Xia <hongyxia@amazon.com>
AuthorDate: Tue Feb 6 11:55:24 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 6 11:55:24 2024 +0100

    xen/numa: vmap the pages for memnodemap
    
    This avoids the assumption that there is a direct map and boot pages
    fall inside the direct map.
    
    Clean up the variables so that mfn actually stores a type-safe mfn.
    
    Signed-off-by: Hongyan Xia <hongyxia@amazon.com>
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Signed-off-by: Elias El Yandouzi <eliasely@amazon.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/common/numa.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/xen/common/numa.c b/xen/common/numa.c
index f454c4d894..6374ba1721 100644
--- a/xen/common/numa.c
+++ b/xen/common/numa.c
@@ -424,13 +424,14 @@ static int __init populate_memnodemap(const struct node *nodes,
 static int __init allocate_cachealigned_memnodemap(void)
 {
     unsigned long size = PFN_UP(memnodemapsize * sizeof(*memnodemap));
-    unsigned long mfn = mfn_x(alloc_boot_pages(size, 1));
+    mfn_t mfn = alloc_boot_pages(size, 1);
 
-    memnodemap = mfn_to_virt(mfn);
-    mfn <<= PAGE_SHIFT;
+    memnodemap = vmap_contig(mfn, size);
+    if ( !memnodemap )
+        panic("Unable to map the NUMA node map. Retry with numa=off");
     size <<= PAGE_SHIFT;
     printk(KERN_DEBUG "NUMA: Allocated memnodemap from %lx - %lx\n",
-           mfn, mfn + size);
+           mfn_to_maddr(mfn), mfn_to_maddr(mfn) + size);
     memnodemapsize = size / sizeof(*memnodemap);
 
     return 0;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 12:55:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 12:55:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677531.1054160 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhSp-0000Xt-Sk; Wed, 07 Feb 2024 12:55:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677531.1054160; Wed, 07 Feb 2024 12:55:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhSp-0000Xl-QF; Wed, 07 Feb 2024 12:55:43 +0000
Received: by outflank-mailman (input) for mailman id 677531;
 Wed, 07 Feb 2024 12:55:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSo-0000Xc-Ur
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSo-0001Wg-SD
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSo-0004f7-R2
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=MAAkPr21Ul0o+dd2n2FPedlafPV4Ld+sgZiZ32U5cVw=; b=4u8CX813zmL+UUTJpffo7UqnFo
	vX2i+ynCcqoETAh6lBaF4L8+SWhRWLfSJEf0Xyjdex0sH/g0k8RKsGec1jdyqyVjbrHIX0N8iC443
	3b1grkc1w1K0A2nBwg42g5tsItfXwIfNJYlKH+rdOP8NS+SmI4bCevcC+8LdAUI/1qiI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/srat: vmap the pages for acpi_slit
Message-Id: <E1rXhSo-0004f7-R2@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 12:55:42 +0000

commit 8ac8999d7011c4339a14ce01f2a9d1e6801eefb1
Author:     Hongyan Xia <hongyxia@amazon.com>
AuthorDate: Tue Feb 6 11:55:49 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 6 11:55:49 2024 +0100

    x86/srat: vmap the pages for acpi_slit
    
    This avoids the assumption that boot pages are in the direct map.
    
    Signed-off-by: Hongyan Xia <hongyxia@amazon.com>
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Signed-off-by: Elias El Yandouzi <eliasely@amazon.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/srat.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/srat.c b/xen/arch/x86/srat.c
index 3f70338e6e..688f410287 100644
--- a/xen/arch/x86/srat.c
+++ b/xen/arch/x86/srat.c
@@ -135,7 +135,9 @@ void __init acpi_numa_slit_init(struct acpi_table_slit *slit)
 		return;
 	}
 	mfn = alloc_boot_pages(PFN_UP(slit->header.length), 1);
-	acpi_slit = mfn_to_virt(mfn_x(mfn));
+	acpi_slit = vmap_contig(mfn, PFN_UP(slit->header.length));
+	if ( !acpi_slit )
+		panic("Unable to map the ACPI SLIT. Retry with numa=off");
 	memcpy(acpi_slit, slit, slit->header.length);
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 12:55:53 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 12:55:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677532.1054165 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhSz-0000aw-UA; Wed, 07 Feb 2024 12:55:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677532.1054165; Wed, 07 Feb 2024 12:55:53 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhSz-0000ap-Ri; Wed, 07 Feb 2024 12:55:53 +0000
Received: by outflank-mailman (input) for mailman id 677532;
 Wed, 07 Feb 2024 12:55:53 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSy-0000af-WA
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:52 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSy-0001Wq-VR
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhSy-0004fY-UR
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:55:52 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=YEnBvZJJjkPRYLlg3zrWp8Sr+twzmw8CJ6U/O66Sy2E=; b=KhXa81e5djU5osfjwgHkMP5VGD
	kGwvMQvKW5t2GE8rDh/VzsylFOqTHRG6a9O2c6azKflJ6Gd3ZFjkOVqAsqLqYfVb8FDqn3zdfczaV
	I3TlfZWJ2ENqPMn9V1bqUpi/6BHKucccH56Kqosp4KUvOZ0j60eiFEQvENH4pq6R2LH0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] amd-vi: fix IVMD memory type checks
Message-Id: <E1rXhSy-0004fY-UR@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 12:55:52 +0000

commit 83afa313583019d9f159c122cecf867735d27ec5
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 6 11:56:13 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 6 11:56:13 2024 +0100

    amd-vi: fix IVMD memory type checks
    
    The current code that parses the IVMD blocks is relaxed with regard to the
    restriction that such unity regions should always fall into memory ranges
    marked as reserved in the memory map.
    
    However the type checks for the IVMD addresses are inverted, and as a result
    IVMD ranges falling into RAM areas are accepted.  Note that having such ranges
    in the first place is a firmware bug, as IVMD should always fall into reserved
    ranges.
    
    Fixes: ed6c77ebf0c1 ('AMD/IOMMU: check / convert IVMD ranges for being / to be reserved')
    Reported-by: Ox <oxjo@proton.me>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Tested-by: oxjo <oxjo@proton.me>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/drivers/passthrough/amd/iommu_acpi.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_acpi.c b/xen/drivers/passthrough/amd/iommu_acpi.c
index 2e3b83014b..ca70f4f3ae 100644
--- a/xen/drivers/passthrough/amd/iommu_acpi.c
+++ b/xen/drivers/passthrough/amd/iommu_acpi.c
@@ -426,9 +426,14 @@ static int __init parse_ivmd_block(const struct acpi_ivrs_memory *ivmd_block)
                 return -EIO;
             }
 
-            /* Types which won't be handed out are considered good enough. */
-            if ( !(type & (RAM_TYPE_RESERVED | RAM_TYPE_ACPI |
-                           RAM_TYPE_UNUSABLE)) )
+            /*
+             * Types which aren't RAM are considered good enough.
+             * Note that a page being partially RESERVED, ACPI or UNUSABLE will
+             * force Xen into assuming the whole page as having that type in
+             * practice.
+             */
+            if ( type & (RAM_TYPE_RESERVED | RAM_TYPE_ACPI |
+                         RAM_TYPE_UNUSABLE) )
                 continue;
 
             AMD_IOMMU_ERROR("IVMD: page at %lx can't be converted\n", addr);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 12:56:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 12:56:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677533.1054169 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhTA-0000eP-0t; Wed, 07 Feb 2024 12:56:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677533.1054169; Wed, 07 Feb 2024 12:56:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhT9-0000eH-US; Wed, 07 Feb 2024 12:56:03 +0000
Received: by outflank-mailman (input) for mailman id 677533;
 Wed, 07 Feb 2024 12:56:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhT9-0000e5-2q
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:56:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhT9-0001XA-2A
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:56:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhT9-0004gk-1A
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:56:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=12ftxhGI844TywNttoKWAiebXeO78WoN40Yz5LAvvv0=; b=04nc0zy78RASdRpY0i6l7hNjWR
	tKZhPdTRh7zehwBSaTEiyDyv1lIm4rBtCHMnGnX+79bBigK4tJ8aP9tRaCtpqP/RuM2MmjcBOoxjg
	3XT41PdHKSlyQdbzH+vXMISlhtT/qPX6bEZUnmTTj6LzbRdkdDZXrZ6Ml1zwv5kp+2VY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/paging: Use more specific constant
Message-Id: <E1rXhT9-0004gk-1A@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 12:56:03 +0000

commit 80b01e20d0f45a8a3fb6758bfac6dd4d2eef3387
Author:     Frediano Ziglio <frediano.ziglio@cloud.com>
AuthorDate: Tue Feb 6 11:56:38 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 6 11:56:38 2024 +0100

    x86/paging: Use more specific constant
    
    __HYPERVISOR_arch_1 and __HYPERVISOR_paging_domctl_cont for x86
    have the same value but this function is handling
    "paging_domctl_cont" hypercall so using the latter mnemonic in
    the code is more clear.
    
    Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/mm/paging.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c
index 541c2ea9b2..2961ca734d 100644
--- a/xen/arch/x86/mm/paging.c
+++ b/xen/arch/x86/mm/paging.c
@@ -783,7 +783,7 @@ long do_paging_domctl_cont(
     rcu_unlock_domain(d);
 
     if ( ret == -ERESTART )
-        ret = hypercall_create_continuation(__HYPERVISOR_arch_1,
+        ret = hypercall_create_continuation(__HYPERVISOR_paging_domctl_cont,
                                             "h", u_domctl);
     else if ( __copy_field_to_guest(u_domctl, &op, u.shadow_op) )
         ret = -EFAULT;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 12:56:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 12:56:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677534.1054173 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhTK-0000hY-2M; Wed, 07 Feb 2024 12:56:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677534.1054173; Wed, 07 Feb 2024 12:56:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhTJ-0000hQ-Vu; Wed, 07 Feb 2024 12:56:13 +0000
Received: by outflank-mailman (input) for mailman id 677534;
 Wed, 07 Feb 2024 12:56:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhTJ-0000hK-5x
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:56:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhTJ-0001XP-56
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:56:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhTJ-0004hB-4C
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:56:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=sSKxJPQ3Vik42714RsoRpgdFlyn5Sl+ytPgmSs6VHqg=; b=ZWCvObGXNJ0bRMDCPwgp/tXURC
	roueupiGjZEfnZT+W0eV+n6NJq0JVBNXimJr/zjmX+kBipipXqiylgsLkUJBN6AaJJE0pG4gQ3k3F
	jYCHbeyXQbrfw2nYjCVRqJXNPPsN7TKPuzIeXMxtsBjV70of5qAm9PDsuMbW1jerOYCM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/entry: Reduce assembly instruction size
Message-Id: <E1rXhTJ-0004hB-4C@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 12:56:13 +0000

commit 02c6ad45154b6dc47f588c98099b9084ee94c894
Author:     Frediano Ziglio <frediano.ziglio@cloud.com>
AuthorDate: Tue Feb 6 11:57:05 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 6 11:57:05 2024 +0100

    x86/entry: Reduce assembly instruction size
    
    Use 32 bit versions in all cases, not only for registers till 8th.
    This reduces the encoding from (example with r14):
    
         49 c7 c6 ff 7f 00 00    mov    $0x7fff,%r14
    
    to
    
         41 be ff 7f 00 00       mov    $0x7fff,%r14d
    
    Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/include/asm/asm_defns.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/include/asm/asm_defns.h b/xen/arch/x86/include/asm/asm_defns.h
index 51bf1cf1e6..a9a6c21c76 100644
--- a/xen/arch/x86/include/asm/asm_defns.h
+++ b/xen/arch/x86/include/asm/asm_defns.h
@@ -136,7 +136,7 @@ register unsigned long current_stack_pointer asm("rsp");
 #define STACK_CPUINFO_FIELD(field) (1 - CPUINFO_sizeof + CPUINFO_##field)
 #define GET_STACK_END(reg)                        \
         .if .Lr##reg >= 8;                        \
-        movq $STACK_SIZE-1, %r##reg;              \
+        movl $STACK_SIZE-1, %r##reg##d;           \
         .else;                                    \
         movl $STACK_SIZE-1, %e##reg;              \
         .endif;                                   \
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 12:56:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 12:56:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677535.1054177 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhTU-0000jq-3k; Wed, 07 Feb 2024 12:56:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677535.1054177; Wed, 07 Feb 2024 12:56:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhTU-0000jh-13; Wed, 07 Feb 2024 12:56:24 +0000
Received: by outflank-mailman (input) for mailman id 677535;
 Wed, 07 Feb 2024 12:56:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhTT-0000ja-90
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:56:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhTT-0001XZ-8G
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:56:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhTT-0004hh-7M
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:56:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Z9NKZO7Tz42uTsIslYuiPWhgRanla6Kqc7QVbCbNQmM=; b=uNxC1a8dLj5W0j9/e2KIxwtLl1
	Czk6Abb1d9xxhMcP3wEM1PJOP3BG+YneLwmws1BIsbZEEkHSVLpOcTCc170sQ9UNCj3r3aknVb/k/
	BBNMwdXKqho2TYfkwmiQS84y75hyp3FrJX8zAUQQrn4Ec81rw38cOJyDT9zykAsVfQRM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] golang: Regen binding
Message-Id: <E1rXhTT-0004hh-7M@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 12:56:23 +0000

commit 57a923bfd920307c5bfa533c95dba16a13ea0225
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Tue Feb 6 11:57:40 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 6 11:57:40 2024 +0100

    golang: Regen binding
    
    Fixes: 024e7131be5c ("tools: don't expose XENFEAT_hvm_pirqs by default")
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Acked-by: George Dunlap <george.dunlap@cloud.com>
---
 tools/golang/xenlight/helpers.gen.go | 6 ++++++
 tools/golang/xenlight/types.gen.go   | 1 +
 2 files changed, 7 insertions(+)

diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/helpers.gen.go
index 35e209ff1b..0f8e23773c 100644
--- a/tools/golang/xenlight/helpers.gen.go
+++ b/tools/golang/xenlight/helpers.gen.go
@@ -1280,6 +1280,9 @@ return fmt.Errorf("converting field Rdm: %v", err)
 }
 x.RdmMemBoundaryMemkb = uint64(tmp.rdm_mem_boundary_memkb)
 x.McaCaps = uint64(tmp.mca_caps)
+if err := x.Pirq.fromC(&tmp.pirq);err != nil {
+return fmt.Errorf("converting field Pirq: %v", err)
+}
 return nil
 }
 
@@ -1613,6 +1616,9 @@ return fmt.Errorf("converting field Rdm: %v", err)
 }
 hvm.rdm_mem_boundary_memkb = C.uint64_t(tmp.RdmMemBoundaryMemkb)
 hvm.mca_caps = C.uint64_t(tmp.McaCaps)
+if err := tmp.Pirq.toC(&hvm.pirq); err != nil {
+return fmt.Errorf("converting field Pirq: %v", err)
+}
 hvmBytes := C.GoBytes(unsafe.Pointer(&hvm),C.sizeof_libxl_domain_build_info_type_union_hvm)
 copy(xc.u[:],hvmBytes)
 case DomainTypePv:
diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/types.gen.go
index 7907aa8999..9c8b7b81f6 100644
--- a/tools/golang/xenlight/types.gen.go
+++ b/tools/golang/xenlight/types.gen.go
@@ -651,6 +651,7 @@ SerialList StringList
 Rdm RdmReserve
 RdmMemBoundaryMemkb uint64
 McaCaps uint64
+Pirq Defbool
 }
 
 func (x DomainBuildInfoTypeUnionHvm) isDomainBuildInfoTypeUnion(){}
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 07 12:56:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 07 Feb 2024 12:56:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677536.1054181 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhTf-0000mH-5P; Wed, 07 Feb 2024 12:56:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677536.1054181; Wed, 07 Feb 2024 12:56:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXhTf-0000m9-2Y; Wed, 07 Feb 2024 12:56:35 +0000
Received: by outflank-mailman (input) for mailman id 677536;
 Wed, 07 Feb 2024 12:56:34 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhTe-0000ly-0s
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:56:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhTe-0001Xz-0C
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:56:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXhTd-0004p6-VR
 for xen-changelog@lists.xenproject.org; Wed, 07 Feb 2024 12:56:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=v2QabKeR8S+F32kwwLEh6zJ8+SEixm7XHVP14gNCExQ=; b=av4UjReSvwzmfq2cTCcsq3OVFq
	xyMedZ7tZaOnX1BcdIy0X/XSaNkQMwhR7bVWtAODbcINvrmAOASObHX7QiFvjf3joBxR3AwOa5Bml
	UEwmqnQE1NpPDiQfb/7PGc7IIfrDIS7LmmPc4yLFJuOZCE5VulOmHV+c+6ztVTNVKp9Y=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [mini-os master] Mini-OS: fix 9pfs frontend error path
Message-Id: <E1rXhTd-0004p6-VR@xenbits.xenproject.org>
Date: Wed, 07 Feb 2024 12:56:33 +0000

commit b119f0178fd86876d0678007dfcf435ab8bb7568
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Wed Feb 7 13:52:13 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Feb 7 13:52:13 2024 +0100

    Mini-OS: fix 9pfs frontend error path
    
    The early error exit in p9_stat() returns without zeroing the p9_stat
    buffer, resulting in free() being called with an uninitialized pointer.
    
    Fix that by calling free_stat() in p9_stat() in case of returning an
    error and potentially having allocated strings.
    
    Reported-by: Julien Grall <julien@xen.org>
    Fixes: 2d1dfccd3aa3 ("Mini-OS: add read and write support to 9pfsfront")
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 9pfront.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/9pfront.c b/9pfront.c
index 315089b..042879a 100644
--- a/9pfront.c
+++ b/9pfront.c
@@ -728,6 +728,8 @@ static int p9_stat(struct dev_9pfs *dev, uint32_t fid, struct p9_stat *stat)
            &stat->extension, &stat->n_uid, &stat->n_gid, &stat->n_muid);
 
     ret = req->result;
+    if ( ret )
+        free_stat(&stat);
 
     put_free_req(dev, req);
 
@@ -932,13 +934,13 @@ static int write_9pfs(struct file *file, const void *buf, size_t nbytes)
     if ( f9pfs->append )
     {
         ret = p9_stat(f9pfs->dev, f9pfs->fid, &stat);
-        free_stat(&stat);
         if ( ret )
         {
             errno = EIO;
             return -1;
         }
         file->offset = stat.length;
+        free_stat(&stat);
     }
 
     ret = p9_write(f9pfs->dev, f9pfs->fid, file->offset, buf, nbytes);
--
generated by git-patchbot for /home/xen/git/mini-os.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 08 01:11:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 08 Feb 2024 01:11:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.677954.1054907 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXswQ-00084J-B6; Thu, 08 Feb 2024 01:11:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 677954.1054907; Thu, 08 Feb 2024 01:11:02 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rXswQ-00084B-7s; Thu, 08 Feb 2024 01:11:02 +0000
Received: by outflank-mailman (input) for mailman id 677954;
 Thu, 08 Feb 2024 01:11:01 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXswP-00083r-B3
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 01:11:01 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXswP-0000sC-AB
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 01:11:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rXswP-0005Gd-8k
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 01:11:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=VpqhjYc9nALx+91Xj4+e75qHouZVIVZYvmG/Yt3zuVU=; b=LNp8sGosTzX5SUYIeNW5u0VmbG
	Ox/w+IR4KZ6otRfYOUsO8+n9vXflrIbzwsIz75LeEFvLlMPTFP6uRp/ATHbh8NGHs9oBUwChtqbp2
	+u3OYC1cCg1FKejyLM87uE5LXG28xgGtvbwITz9i5ansAiW+OE5qivmZOPiMHCnKUTBE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] automation: Switch yocto-qemux86-64 job to run on x86
Message-Id: <E1rXswP-0005Gd-8k@xenbits.xenproject.org>
Date: Thu, 08 Feb 2024 01:11:01 +0000

commit 59a69674b533a2d0c0ad5cd7fbcd655295574509
Author:     Michal Orzel <michal.orzel@amd.com>
AuthorDate: Tue Feb 6 16:20:12 2024 +0100
Commit:     Stefano Stabellini <stefano.stabellini@amd.com>
CommitDate: Tue Feb 6 16:47:04 2024 -0800

    automation: Switch yocto-qemux86-64 job to run on x86
    
    At the moment, all Yocto jobs run on Arm64 runners. To address CI
    capacity issues, move yocto-qemux86-64 job to x86. Reflect the change in
    the makefile generating Yocto docker files and fix CONTAINER name
    definition that incorrectly expects YOCTO_HOST variable to be set for x86
    container as well, which does not have a platform name appended.
    
    Signed-off-by: Michal Orzel <michal.orzel@amd.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
 automation/build/yocto/yocto.inc |  6 ++++--
 automation/gitlab-ci/build.yaml  | 10 +++-------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/automation/build/yocto/yocto.inc b/automation/build/yocto/yocto.inc
index e4328ec7f3..2f3b1a5b2a 100644
--- a/automation/build/yocto/yocto.inc
+++ b/automation/build/yocto/yocto.inc
@@ -18,11 +18,13 @@ YOCTO_TARGETS = qemuarm64 qemuarm qemux86-64
 YOCTO_ARCHS = amd64 arm64v8
 
 # Architecture we want to use in gitlab CI (depends on runners arch).
-CI_ARCH = arm64v8
+CI_ARCH-qemuarm64 = arm64v8
+CI_ARCH-qemuarm = arm64v8
+CI_ARCH-qemux86-64 = amd64
 
 define GEN_DOCKER
 # Make all is generating architecture we use in the CI.
-ifeq ($(CI_ARCH),$(3))
+ifeq ($(CI_ARCH-$(2)),$(3))
 CONTAINERS += yocto/$(1)-$(2)$(4)
 else
 CONTAINERS_EXTRA += yocto/$(1)-$(2)$(4)
diff --git a/automation/gitlab-ci/build.yaml b/automation/gitlab-ci/build.yaml
index 32af30cced..6d2cb18b88 100644
--- a/automation/gitlab-ci/build.yaml
+++ b/automation/gitlab-ci/build.yaml
@@ -213,7 +213,7 @@
     - ./automation/build/yocto/build-yocto.sh -v --log-dir=./logs --xen-dir=`pwd` ${YOCTO_BOARD} ${YOCTO_OUTPUT}
   variables:
     YOCTO_VERSION: kirkstone
-    CONTAINER: yocto:${YOCTO_VERSION}-${YOCTO_BOARD}-${YOCTO_HOST}
+    CONTAINER: yocto:${YOCTO_VERSION}-${YOCTO_BOARD}${YOCTO_HOST}
   artifacts:
     paths:
       - 'logs/*'
@@ -224,16 +224,12 @@
 .yocto-test-arm64:
   extends: .yocto-test
   variables:
-    YOCTO_HOST: arm64v8
+    YOCTO_HOST: -arm64v8
   tags:
     - arm64
 
-# This is not used by any test job as we only run Yocto on arm based machines.
-# Keep it here so that someone having x86 hardware can easily add jobs.
 .yocto-test-x86-64:
   extends: .yocto-test
-  variables:
-    YOCTO_HOST: amd64
   tags:
     - x86_64
 
@@ -576,7 +572,7 @@ yocto-qemuarm:
     YOCTO_OUTPUT: --copy-output
 
 yocto-qemux86-64:
-  extends: .yocto-test-arm64
+  extends: .yocto-test-x86-64
   variables:
     YOCTO_BOARD: qemux86-64
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 08 11:33:11 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 08 Feb 2024 11:33:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.678139.1055197 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rY2eN-0007ge-1y; Thu, 08 Feb 2024 11:33:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 678139.1055197; Thu, 08 Feb 2024 11:33:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rY2eM-0007gW-VN; Thu, 08 Feb 2024 11:33:02 +0000
Received: by outflank-mailman (input) for mailman id 678139;
 Thu, 08 Feb 2024 11:33:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rY2eM-0007gP-1H
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 11:33:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rY2eM-000574-0W
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 11:33:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rY2eL-0003Xv-Uz
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 11:33:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Yi0Hk7DXi12kLXivuhleHoQ5eebo8qe7VFEMFZM2xbI=; b=dJ+vNBodXkM7WigeFJSoBI+6hF
	qcTHzXq+KV5JNEyorvVOhPu+V9vX7J6j8IqE2MKdusgz8g0kU/iTtLM6lQPL2opdKBhAdsOdFksnl
	A0il9ge32ax/CCK+FkGo8AYS5aZf0x9s81QTNMfgxiV2UBOtj6YvB1NjXJvNZxB6Ereo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] VMX: tertiary execution control infrastructure
Message-Id: <E1rY2eL-0003Xv-Uz@xenbits.xenproject.org>
Date: Thu, 08 Feb 2024 11:33:01 +0000

commit 878159bf259bfbd7a40312829f1ea0ce1f6645e2
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Wed Feb 7 13:46:11 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Feb 7 13:46:11 2024 +0100

    VMX: tertiary execution control infrastructure
    
    This is a prereq to enabling e.g. the MSRLIST feature.
    
    Note that the PROCBASED_CTLS3 MSR is different from other VMX feature
    reporting MSRs, in that all 64 bits report allowed 1-settings.
    
    vVMX code is left alone, though, for the time being.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/hvm/vmx/vmcs.c             | 58 +++++++++++++++++++++++++++++----
 xen/arch/x86/hvm/vmx/vmx.c              |  6 ++++
 xen/arch/x86/include/asm/hvm/vmx/vmcs.h | 13 ++++++++
 xen/arch/x86/include/asm/hvm/vmx/vmx.h  |  1 +
 xen/arch/x86/include/asm/msr-index.h    |  1 +
 5 files changed, 73 insertions(+), 6 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
index 4fe1213855..9e016634ab 100644
--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -164,6 +164,7 @@ static int cf_check parse_ept_param_runtime(const char *s)
 u32 vmx_pin_based_exec_control __read_mostly;
 u32 vmx_cpu_based_exec_control __read_mostly;
 u32 vmx_secondary_exec_control __read_mostly;
+uint64_t vmx_tertiary_exec_control __read_mostly;
 u32 vmx_vmexit_control __read_mostly;
 u32 vmx_vmentry_control __read_mostly;
 u64 vmx_ept_vpid_cap __read_mostly;
@@ -228,10 +229,32 @@ static u32 adjust_vmx_controls(
     return ctl;
 }
 
-static bool cap_check(const char *name, u32 expected, u32 saw)
+static uint64_t adjust_vmx_controls2(
+    const char *name, uint64_t ctl_min, uint64_t ctl_opt, unsigned int msr,
+    bool *mismatch)
+{
+    uint64_t vmx_msr, ctl = ctl_min | ctl_opt;
+
+    rdmsrl(msr, vmx_msr);
+
+    ctl &= vmx_msr; /* bit == 0 ==> must be zero */
+
+    /* Ensure minimum (required) set of control bits are supported. */
+    if ( ctl_min & ~ctl )
+    {
+        *mismatch = true;
+        printk("VMX: CPU%u has insufficient %s (%#lx; requires %#lx)\n",
+               smp_processor_id(), name, ctl, ctl_min);
+    }
+
+    return ctl;
+}
+
+static bool cap_check(
+    const char *name, unsigned long expected, unsigned long saw)
 {
     if ( saw != expected )
-        printk("VMX %s: saw %#x expected %#x\n", name, saw, expected);
+        printk("VMX %s: saw %#lx expected %#lx\n", name, saw, expected);
     return saw != expected;
 }
 
@@ -241,6 +264,7 @@ static int vmx_init_vmcs_config(bool bsp)
     u32 _vmx_pin_based_exec_control;
     u32 _vmx_cpu_based_exec_control;
     u32 _vmx_secondary_exec_control = 0;
+    uint64_t _vmx_tertiary_exec_control = 0;
     u64 _vmx_ept_vpid_cap = 0;
     u64 _vmx_misc_cap = 0;
     u32 _vmx_vmexit_control;
@@ -274,7 +298,8 @@ static int vmx_init_vmcs_config(bool bsp)
     opt = (CPU_BASED_ACTIVATE_MSR_BITMAP |
            CPU_BASED_TPR_SHADOW |
            CPU_BASED_MONITOR_TRAP_FLAG |
-           CPU_BASED_ACTIVATE_SECONDARY_CONTROLS);
+           CPU_BASED_ACTIVATE_SECONDARY_CONTROLS |
+           CPU_BASED_ACTIVATE_TERTIARY_CONTROLS);
     _vmx_cpu_based_exec_control = adjust_vmx_controls(
         "CPU-Based Exec Control", min, opt,
         MSR_IA32_VMX_PROCBASED_CTLS, &mismatch);
@@ -338,6 +363,15 @@ static int vmx_init_vmcs_config(bool bsp)
             MSR_IA32_VMX_PROCBASED_CTLS2, &mismatch);
     }
 
+    if ( _vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_TERTIARY_CONTROLS )
+    {
+        uint64_t opt = 0;
+
+        _vmx_tertiary_exec_control = adjust_vmx_controls2(
+            "Tertiary Exec Control", 0, opt,
+            MSR_IA32_VMX_PROCBASED_CTLS3, &mismatch);
+    }
+
     /* The IA32_VMX_EPT_VPID_CAP MSR exists only when EPT or VPID available */
     if ( _vmx_secondary_exec_control & (SECONDARY_EXEC_ENABLE_EPT |
                                         SECONDARY_EXEC_ENABLE_VPID) )
@@ -468,6 +502,7 @@ static int vmx_init_vmcs_config(bool bsp)
         vmx_pin_based_exec_control = _vmx_pin_based_exec_control;
         vmx_cpu_based_exec_control = _vmx_cpu_based_exec_control;
         vmx_secondary_exec_control = _vmx_secondary_exec_control;
+        vmx_tertiary_exec_control  = _vmx_tertiary_exec_control;
         vmx_ept_vpid_cap           = _vmx_ept_vpid_cap;
         vmx_vmexit_control         = _vmx_vmexit_control;
         vmx_vmentry_control        = _vmx_vmentry_control;
@@ -502,6 +537,9 @@ static int vmx_init_vmcs_config(bool bsp)
         mismatch |= cap_check(
             "Secondary Exec Control",
             vmx_secondary_exec_control, _vmx_secondary_exec_control);
+        mismatch |= cap_check(
+            "Tertiary Exec Control",
+            vmx_tertiary_exec_control, _vmx_tertiary_exec_control);
         mismatch |= cap_check(
             "VMExit Control",
             vmx_vmexit_control, _vmx_vmexit_control);
@@ -1080,6 +1118,7 @@ static int construct_vmcs(struct vcpu *v)
         v->arch.hvm.vmx.exec_control |= CPU_BASED_RDTSC_EXITING;
 
     v->arch.hvm.vmx.secondary_exec_control = vmx_secondary_exec_control;
+    v->arch.hvm.vmx.tertiary_exec_control  = vmx_tertiary_exec_control;
 
     /*
      * Disable features which we don't want active by default:
@@ -1134,6 +1173,10 @@ static int construct_vmcs(struct vcpu *v)
         __vmwrite(SECONDARY_VM_EXEC_CONTROL,
                   v->arch.hvm.vmx.secondary_exec_control);
 
+    if ( cpu_has_vmx_tertiary_exec_control )
+        __vmwrite(TERTIARY_VM_EXEC_CONTROL,
+                  v->arch.hvm.vmx.tertiary_exec_control);
+
     /* MSR access bitmap. */
     if ( cpu_has_vmx_msr_bitmap )
     {
@@ -2068,10 +2111,12 @@ void vmcs_dump_vcpu(struct vcpu *v)
                vmr(HOST_PERF_GLOBAL_CTRL));
 
     printk("*** Control State ***\n");
-    printk("PinBased=%08x CPUBased=%08x SecondaryExec=%08x\n",
+    printk("PinBased=%08x CPUBased=%08x\n",
            vmr32(PIN_BASED_VM_EXEC_CONTROL),
-           vmr32(CPU_BASED_VM_EXEC_CONTROL),
-           vmr32(SECONDARY_VM_EXEC_CONTROL));
+           vmr32(CPU_BASED_VM_EXEC_CONTROL));
+    printk("SecondaryExec=%08x TertiaryExec=%016lx\n",
+           vmr32(SECONDARY_VM_EXEC_CONTROL),
+           vmr(TERTIARY_VM_EXEC_CONTROL));
     printk("EntryControls=%08x ExitControls=%08x\n", vmentry_ctl, vmexit_ctl);
     printk("ExceptionBitmap=%08x PFECmask=%08x PFECmatch=%08x\n",
            vmr32(EXCEPTION_BITMAP),
@@ -2174,6 +2219,7 @@ int __init vmx_vmcs_init(void)
         vmx_pin_based_exec_control = 0;
         vmx_cpu_based_exec_control = 0;
         vmx_secondary_exec_control = 0;
+        vmx_tertiary_exec_control  = 0;
         vmx_vmexit_control         = 0;
         vmx_vmentry_control        = 0;
         vmx_ept_vpid_cap           = 0;
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 1500dca603..48376cc327 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -760,6 +760,12 @@ void vmx_update_secondary_exec_control(struct vcpu *v)
                   v->arch.hvm.vmx.secondary_exec_control);
 }
 
+void vmx_update_tertiary_exec_control(const struct vcpu *v)
+{
+    __vmwrite(TERTIARY_VM_EXEC_CONTROL,
+              v->arch.hvm.vmx.tertiary_exec_control);
+}
+
 void vmx_update_exception_bitmap(struct vcpu *v)
 {
     u32 bitmap = unlikely(v->arch.hvm.vmx.vmx_realmode)
diff --git a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h
index 5ec474c79c..a7dd2eeffc 100644
--- a/xen/arch/x86/include/asm/hvm/vmx/vmcs.h
+++ b/xen/arch/x86/include/asm/hvm/vmx/vmcs.h
@@ -114,6 +114,7 @@ struct vmx_vcpu {
     /* Cache of cpu execution control. */
     u32                  exec_control;
     u32                  secondary_exec_control;
+    uint64_t             tertiary_exec_control;
     u32                  exception_bitmap;
 
     uint64_t             shadow_gs;
@@ -196,6 +197,7 @@ void vmx_vmcs_reload(struct vcpu *v);
 #define CPU_BASED_RDTSC_EXITING               0x00001000U
 #define CPU_BASED_CR3_LOAD_EXITING            0x00008000U
 #define CPU_BASED_CR3_STORE_EXITING           0x00010000U
+#define CPU_BASED_ACTIVATE_TERTIARY_CONTROLS  0x00020000U
 #define CPU_BASED_CR8_LOAD_EXITING            0x00080000U
 #define CPU_BASED_CR8_STORE_EXITING           0x00100000U
 #define CPU_BASED_TPR_SHADOW                  0x00200000U
@@ -260,6 +262,14 @@ extern u32 vmx_vmentry_control;
 #define SECONDARY_EXEC_NOTIFY_VM_EXITING        0x80000000U
 extern u32 vmx_secondary_exec_control;
 
+#define TERTIARY_EXEC_LOADIWKEY_EXITING         BIT(0, UL)
+#define TERTIARY_EXEC_ENABLE_HLAT               BIT(1, UL)
+#define TERTIARY_EXEC_EPT_PAGING_WRITE          BIT(2, UL)
+#define TERTIARY_EXEC_GUEST_PAGING_VERIFY       BIT(3, UL)
+#define TERTIARY_EXEC_IPI_VIRT                  BIT(4, UL)
+#define TERTIARY_EXEC_VIRT_SPEC_CTRL            BIT(7, UL)
+extern uint64_t vmx_tertiary_exec_control;
+
 #define VMX_EPT_EXEC_ONLY_SUPPORTED                         0x00000001
 #define VMX_EPT_WALK_LENGTH_4_SUPPORTED                     0x00000040
 #define VMX_EPT_MEMORY_TYPE_UC                              0x00000100
@@ -296,6 +306,8 @@ extern u64 vmx_ept_vpid_cap;
     (vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_MSR_BITMAP)
 #define cpu_has_vmx_secondary_exec_control \
     (vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_SECONDARY_CONTROLS)
+#define cpu_has_vmx_tertiary_exec_control \
+    (vmx_cpu_based_exec_control & CPU_BASED_ACTIVATE_TERTIARY_CONTROLS)
 #define cpu_has_vmx_ept \
     (vmx_secondary_exec_control & SECONDARY_EXEC_ENABLE_EPT)
 #define cpu_has_vmx_dt_exiting \
@@ -423,6 +435,7 @@ enum vmcs_field {
     VIRT_EXCEPTION_INFO             = 0x0000202a,
     XSS_EXIT_BITMAP                 = 0x0000202c,
     TSC_MULTIPLIER                  = 0x00002032,
+    TERTIARY_VM_EXEC_CONTROL        = 0x00002034,
     GUEST_PHYSICAL_ADDRESS          = 0x00002400,
     VMCS_LINK_POINTER               = 0x00002800,
     GUEST_IA32_DEBUGCTL             = 0x00002802,
diff --git a/xen/arch/x86/include/asm/hvm/vmx/vmx.h b/xen/arch/x86/include/asm/hvm/vmx/vmx.h
index 31643ed481..8ffab7d94c 100644
--- a/xen/arch/x86/include/asm/hvm/vmx/vmx.h
+++ b/xen/arch/x86/include/asm/hvm/vmx/vmx.h
@@ -81,6 +81,7 @@ void vmx_realmode(struct cpu_user_regs *regs);
 void vmx_update_exception_bitmap(struct vcpu *v);
 void vmx_update_cpu_exec_control(struct vcpu *v);
 void vmx_update_secondary_exec_control(struct vcpu *v);
+void vmx_update_tertiary_exec_control(const struct vcpu *v);
 
 #define POSTED_INTR_ON  0
 #define POSTED_INTR_SN  1
diff --git a/xen/arch/x86/include/asm/msr-index.h b/xen/arch/x86/include/asm/msr-index.h
index 492699c1b4..fc82afc246 100644
--- a/xen/arch/x86/include/asm/msr-index.h
+++ b/xen/arch/x86/include/asm/msr-index.h
@@ -347,6 +347,7 @@
 #define MSR_IA32_VMX_TRUE_EXIT_CTLS             0x48f
 #define MSR_IA32_VMX_TRUE_ENTRY_CTLS            0x490
 #define MSR_IA32_VMX_VMFUNC                     0x491
+#define MSR_IA32_VMX_PROCBASED_CTLS3            0x492
 
 /* K7/K8 MSRs. Not complete. See the architecture manual for a more
    complete list. */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 08 11:33:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 08 Feb 2024 11:33:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.678140.1055201 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rY2eY-0007jU-5N; Thu, 08 Feb 2024 11:33:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 678140.1055201; Thu, 08 Feb 2024 11:33:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rY2eY-0007jM-2f; Thu, 08 Feb 2024 11:33:14 +0000
Received: by outflank-mailman (input) for mailman id 678140;
 Thu, 08 Feb 2024 11:33:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rY2eW-0007j6-6g
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 11:33:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rY2eW-00057I-5x
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 11:33:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rY2eW-0003YV-2g
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 11:33:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=BTtC2LW/o5HIeorEF2BReS7iQrSk7JppusmU9J9FskI=; b=dfZufzr57R/Nkv8CcfHOH34yQM
	XTc+Q3DyLDghMxxnUtRBjKiOwSuHmAsPvT/yMMf1+94meNtE6IbzWp6GMH+r9k1n8nzF4/EDicr55
	U673+kof5ZNOSQ1I9hAg5LQuqTItk0H/XIdLy7Km4JuQt7P9We8ttIW7WGfmoCyMm/SY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] block-common: Fix same_vm for no targets
Message-Id: <E1rY2eW-0003YV-2g@xenbits.xenproject.org>
Date: Thu, 08 Feb 2024 11:33:12 +0000

commit e8f1bb803fdf44db708991593568a9e3e6b3d130
Author:     Jason Andryuk <jandryuk@gmail.com>
AuthorDate: Wed Feb 7 13:46:52 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Feb 7 13:46:52 2024 +0100

    block-common: Fix same_vm for no targets
    
    same_vm is broken when the two main domains do not have targets.  otvm
    and targetvm are both missing, which means they get set to -1 and then
    converted to empty strings:
    
    ++10697+ local targetvm=-1
    ++10697+ local otvm=-1
    ++10697+ otvm=
    ++10697+ othervm=/vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4
    ++10697+ targetvm=
    ++10697+ local frontend_uuid=/vm/844dea4e-44f8-4e3e-8145-325132a31ca5
    
    The final comparison returns true since the two empty strings match:
    
    ++10697+ '[' /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = /vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o '' = /vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = '' -o '' = '' ']'
    
    Replace -1 with distinct strings indicating the lack of a value and
    remove the collescing to empty stings.  The strings themselves will no
    longer match, and that is correct.
    
    ++12364+ '[' /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = /vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o 'No target' = /vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = 'No other target' -o 'No target' = 'No other target' ']'
    
    Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/hotplug/Linux/block-common.sh | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tools/hotplug/Linux/block-common.sh b/tools/hotplug/Linux/block-common.sh
index f86a88c4eb..5c80237d99 100644
--- a/tools/hotplug/Linux/block-common.sh
+++ b/tools/hotplug/Linux/block-common.sh
@@ -112,14 +112,12 @@ same_vm()
                   "$FRONTEND_UUID")
   local target=$(xenstore_read_default  "/local/domain/$FRONTEND_ID/target"   \
                  "-1")
-  local targetvm=$(xenstore_read_default "/local/domain/$target/vm" "-1")
+  local targetvm=$(xenstore_read_default "/local/domain/$target/vm" "No Target")
   local otarget=$(xenstore_read_default  "/local/domain/$otherdom/target"   \
                  "-1")
   local otvm=$(xenstore_read_default  "/local/domain/$otarget/vm"   \
-                 "-1")
-  otvm=${otvm%-1}
-  othervm=${othervm%-1}
-  targetvm=${targetvm%-1}
+                 "No Other Target")
+
   local frontend_uuid=${FRONTEND_UUID%-1}
   
   [ "$frontend_uuid" = "$othervm" -o "$targetvm" = "$othervm" -o \
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 08 11:33:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 08 Feb 2024 11:33:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.678141.1055205 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rY2ei-0007no-76; Thu, 08 Feb 2024 11:33:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 678141.1055205; Thu, 08 Feb 2024 11:33:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rY2ei-0007ng-4D; Thu, 08 Feb 2024 11:33:24 +0000
Received: by outflank-mailman (input) for mailman id 678141;
 Thu, 08 Feb 2024 11:33:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rY2eg-0007nI-AJ
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 11:33:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rY2eg-00057d-9Y
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 11:33:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rY2eg-0003Z2-85
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 11:33:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=SFKCQM9iyThnp0PRwBTUIpnm7pS1RWWqX7CO7CFaiU0=; b=ewRpx5puLEgqOjdg2oVdwgpiR3
	F8BIF9dH5RFGLxfymxU9dmI4/xWDHngdzePXyuXOlxwArow5L3YIGysQGyNOCJ8QfV+7OjXJI+un8
	ZH3fKG/wvX8aGNakN118wospo81oBgiyzoJUY+k63sNDkleYryIWhACJSl1VzS+/CipA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/ns16550: address violations of MISRA C:2012 Rule 13.1
Message-Id: <E1rY2eg-0003Z2-85@xenbits.xenproject.org>
Date: Thu, 08 Feb 2024 11:33:22 +0000

commit 38ae4739d87c1025ad5d3b9282048b5311b8ef38
Author:     Simone Ballarin <simone.ballarin@bugseng.com>
AuthorDate: Wed Feb 7 13:47:32 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Feb 7 13:47:32 2024 +0100

    xen/ns16550: address violations of MISRA C:2012 Rule 13.1
    
    Rule 13.1: Initializer lists shall not contain persistent side effects
    
    The assignment operation in:
    
    .irq = rc = uart->irq,
    
    is a persistent side effect in a struct initializer list.
    
    This patch assigns rc separately outside the structure.
    
    No functional change.
    
    Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
    Signed-off-by: Maria Celeste Cesario <maria.celeste.cesario@bugseng.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/drivers/char/ns16550.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index afe3d514b9..97bf098534 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -441,10 +441,12 @@ static void __init cf_check ns16550_init_postirq(struct serial_port *port)
             struct msi_info msi = {
                 .sbdf = PCI_SBDF(0, uart->ps_bdf[0], uart->ps_bdf[1],
                                  uart->ps_bdf[2]),
-                .irq = rc = uart->irq,
+                .irq = uart->irq,
                 .entry_nr = 1
             };
 
+            rc = uart->irq;
+
             if ( rc > 0 )
             {
                 struct msi_desc *msi_desc = NULL;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 08 11:33:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 08 Feb 2024 11:33:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.678142.1055209 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rY2es-0007vN-94; Thu, 08 Feb 2024 11:33:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 678142.1055209; Thu, 08 Feb 2024 11:33:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rY2es-0007vG-5k; Thu, 08 Feb 2024 11:33:34 +0000
Received: by outflank-mailman (input) for mailman id 678142;
 Thu, 08 Feb 2024 11:33:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rY2eq-0007uw-DO
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 11:33:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rY2eq-00057n-Ca
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 11:33:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rY2eq-0003ZR-Bl
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 11:33:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=R/R6jjmV92ShtKrGsPI4koexeXw1WgsZdl44IPoioy0=; b=YBEn+3LNq40sjtSMEvRYb4T4b7
	jZQeLPBSY0VBL3ckvi0SK+o2GWOOCe5hmjAZKhw+hbjBoGPWISjBMpJQVwkw2pBuQAA21OR0RJa20
	aKMItV3/hBgfQA6lf3kMi54eSqsNX74nyybRHVymilt0vMO+x+XcfdwG7NHyEga1xof4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] eclair: move function and macro properties outside ECLAIR
Message-Id: <E1rY2eq-0003ZR-Bl@xenbits.xenproject.org>
Date: Thu, 08 Feb 2024 11:33:32 +0000

commit f4519ee87ebfb74fe0451130d82c99453b75e2e1
Author:     Maria Celeste Cesario <maria.celeste.cesario@bugseng.com>
AuthorDate: Wed Feb 7 13:49:12 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Feb 7 13:49:12 2024 +0100

    eclair: move function and macro properties outside ECLAIR
    
    Function and macro properties contained in ECLAIR/call_properties.ecl are of
    general interest: this patch moves these annotations in a generaric JSON file
    in docs. In this way, they can be exploited for other purposes (i.e. documentation,
    other tools).
    
    Add rst file containing explanation on how to update function_macro_properties.json.
    Add script to convert the JSON file in ECL configurations.
    Remove ECLAIR/call_properties.ecl: the file is now automatically generated from
    the JSON file.
    
    Signed-off-by: Maria Celeste Cesario  <maria.celeste.cesario@bugseng.com>
    Signed-off-by: Simone Ballarin  <simone.ballarin@bugseng.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 automation/eclair_analysis/ECLAIR/analysis.ecl     |   1 +
 .../eclair_analysis/ECLAIR/call_properties.ecl     | 128 ----
 automation/eclair_analysis/prepare.sh              |   2 +
 automation/eclair_analysis/propertyparser.py       |  37 +
 docs/function_macro_properties.json                | 841 +++++++++++++++++++++
 docs/function_macro_properties.rst                 |  58 ++
 6 files changed, 939 insertions(+), 128 deletions(-)

diff --git a/automation/eclair_analysis/ECLAIR/analysis.ecl b/automation/eclair_analysis/ECLAIR/analysis.ecl
index a604582da3..684c5b0b39 100644
--- a/automation/eclair_analysis/ECLAIR/analysis.ecl
+++ b/automation/eclair_analysis/ECLAIR/analysis.ecl
@@ -30,6 +30,7 @@ if(not(scheduled_analysis),
 -eval_file=deviations.ecl
 -eval_file=call_properties.ecl
 -eval_file=tagging.ecl
+-eval_file=properties.ecl
 -eval_file=concat(set,".ecl")
 
 -doc="Hide reports in external code."
diff --git a/automation/eclair_analysis/ECLAIR/call_properties.ecl b/automation/eclair_analysis/ECLAIR/call_properties.ecl
deleted file mode 100644
index c2b2a6182e..0000000000
--- a/automation/eclair_analysis/ECLAIR/call_properties.ecl
+++ /dev/null
@@ -1,128 +0,0 @@
-
--call_properties+={"name(printk)", {"pointee_write(1..=never)", "taken()"}}
--call_properties+={"name(debugtrace_printk)", {"pointee_write(1..=never)", "taken()"}}
--call_properties+={"name(panic)", {"pointee_write(1..=never)", "taken()"}}
--call_properties+={"macro(^domain_crash$)", {"pointee_write(2..=never)", "taken()"}}
--call_properties+={"macro(^(g?d|mm_)?printk$)", {"pointee_write(2..=never)", "taken()"}}
--call_properties+={"macro(^guest_bug_on_failed$)", {"pointee_write(1=never)", "taken()"}}
--call_properties+={"macro(^spin_lock_init_prof$)", {"pointee_write(2=never)", "taken()"}}
--call_properties+={"macro(^sched_test_func$)", {"pointee_write(1..=never)", "taken()"}}
--call_properties+={"macro(^dev_(info|warn)$)", {"pointee_write(1..=never)", "taken()"}}
--call_properties+={"macro(^PAGING_DEBUG$)", {"pointee_write(1..=never)", "taken()"}}
--call_properties+={"macro(^ACPI_(WARNING|ERROR|INFO)$)", {"pointee_write(1..=never)", "taken()"}}
--call_properties+={"name(fdt_get_property_by_offset_)", {"pointee_write(3=always)", "pointee_read(3=never)", "taken()"}}
--call_properties+={"name(read_atomic_size)", {"pointee_write(2=always)", "pointee_read(2=never)", "taken()"}}
--call_properties+={"name(device_tree_get_reg)", {"pointee_write(4..=always)", "pointee_read(4..=never)", "taken()"}}
--call_properties+={"name(dt_get_range)", {"pointee_write(3..=always)", "pointee_read(3..=never)", "taken()"}}
--call_properties+={"name(parse_static_mem_prop)", {"pointee_write(2..=always)", "pointee_read(2..=never)", "taken()"}}
--call_properties+={"name(get_ttbr_and_gran_64bit)", {"pointee_write(1..2=always)", "pointee_read(1..2=never)", "taken()"}}
--call_properties+={"name(hvm_emulate_init_once)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--call_properties+={"name(__vmread)", {"pointee_write(2=always)", "pointee_read(2=never)", "taken()"}}
--call_properties+={"name(hvm_pci_decode_addr)", {"pointee_write(3=always)", "pointee_read(3=never)", "taken()"}}
--call_properties+={"name(vpci_mmcfg_decode_addr)", {"pointee_write(3=always)", "pointee_read(3=never)", "taken()"}}
--call_properties+={"name(x86emul_decode)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--call_properties+={"name(unmap_grant_ref)", {"pointee_write(2=always)", "pointee_read(2=never)", "taken()"}}
--call_properties+={"name(arm_smmu_cmdq_build_cmd)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--call_properties+={"name(pci_size_mem_bar)", {"pointee_write(4=always)", "pointee_read(4=never)", "taken()"}}
--call_properties+={"name(_hvm_read_entry)", {"pointee_write(2=always)", "pointee_read(2=never)", "taken()"}}
--call_properties+={"name(hvm_map_guest_frame_rw)", {"pointee_write(3=always)", "pointee_read(3=never)", "taken()"}}
--call_properties+={"name(guest_cpuid)", {"pointee_write(4=always)", "pointee_read(4=never)", "taken()"}}
--call_properties+={"name(epte_get_entry_emt)", {"pointee_write(5=always)", "pointee_read(5=never)", "taken()"}}
--call_properties+={"name(mcheck_mca_logout)", {"pointee_write(3=always)", "pointee_read(3=never)", "taken()"}}
--call_properties+={"name(set_field_in_reg_u32)", {"pointee_write(5=always)", "pointee_read(5=never)", "taken()"}}
--call_properties+={"name(alloc_affinity_masks)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--call_properties+={"name(xasprintf)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--call_properties+={"name(find_non_smt)", {"pointee_write(2=always)", "pointee_read(2=never)", "taken()"}}
--call_properties+={"name(call_rcu)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--call_properties+={"name(getdomaininfo)", {"pointee_write(2=always)", "pointee_read(2=never)", "taken()"}}
--call_properties+={"^MAPPING_(INSERT|SEARCH)\\(.*$", {"pointee_write(2..=always)", "pointee_read(2..=never)", "taken()"}}
--call_properties+={"name(FormatDec)", {"pointee_write(2=always)", "pointee_read(2=never)", "taken()"}}
--call_properties+={"name(FormatHex)", {"pointee_write(3=always)", "pointee_read(3=never)", "taken()"}}
--call_properties+={"name(p2m_get_ioreq_server)", {"pointee_write(2=always)", "pointee_read(2=never)", "taken()"}}
--call_properties+={"name(elf_memset_unchecked)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--call_properties+={"name(set_iommu_pte_present)", {"pointee_write(7=always)", "pointee_read(7=never)", "taken()"}}
--call_properties+={"name(clear_iommu_pte_present)", {"pointee_write(4=always)", "pointee_read(4=never)", "taken()"}}
--call_properties+={"name(vcpu_runstate_get)", {"pointee_write(2=always)", "pointee_read(2=never)", "taken()"}}
--call_properties+={"name(va_start)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--call_properties+={"name(sgi_target_init)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--call_properties+={"name(get_hw_residencies)", {"pointee_write(2=always)", "pointee_read(2=never)", "taken()"}}
--call_properties+={"name(x86_cpu_policy_to_featureset)", {"pointee_write(2=always)", "pointee_read(2=never)", "taken()"}}
--call_properties+={"^simple_strtou?ll?\\(.*$", {"pointee_write(2=always)", "pointee_read(2=never)", "taken()"}}
--call_properties+={"name(msi_compose_msg)", {"pointee_write(3=always)", "pointee_read(3=never)", "taken()"}}
--call_properties+={"name(print_tainted)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--call_properties+={"name(get_hvm_registers)", {"pointee_write(3=always)", "pointee_read(3=never)", "taken()"}}
--call_properties+={"name(x86_insn_modrm)", {"pointee_write(2..3=always)", "pointee_read(2..3=never)", "taken()"}}
--call_properties+={"name(cpuid_count_leaf)", {"pointee_write(3=always)", "pointee_read(3=never)", "taken()"}}
--call_properties+={"name(rcu_lock_remote_domain_by_id)", {"pointee_write(2=always)", "pointee_read(2=never)", "taken()"}}
--call_properties+={"name(cpuid_count)", {"pointee_write(3..=always)", "pointee_read(3..=never)", "taken()"}}
--call_properties+={"name(efi_boot_mem_unused)", {"pointee_write(1..=always)", "pointee_read(1..=never)", "taken()"}}
--call_properties+={"name(collect_time_info)", {"pointee_write(2=always)", "pointee_read(2=never)", "taken()"}}
--call_properties+={"name(setup_xstate_comp)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--call_properties+={"name(map_domain_gfn)", {"pointee_read(5=never)", "taken()"}}
--call_properties+={"name(fdt_getprop)", {"pointee_read(4=never)", "taken()"}}
--call_properties+={"name(fdt_get_name)", {"pointee_read(3=never)", "taken()"}}
--call_properties+={"name(fdt_get_property)", {"pointee_read(4=never)", "taken()"}}
--call_properties+={"name(pci_get_host_bridge_segment)", {"pointee_read(2=never)", "taken()"}}
--call_properties+={"name(dt_get_property)", {"pointee_read(3=never)", "taken()"}}
--call_properties+={"name(dt_property_read_u32)", {"pointee_read(3=never)", "taken()"}}
--call_properties+={"name(dt_device_get_paddr)", {"pointee_read(3..4=never)", "taken()"}}
--call_properties+={"name(get_evtchn_dt_property)", {"pointee_write(2..3=maybe)", "pointee_read(2..3=never)", "taken()"}}
--call_properties+={"name(setup_chosen_node)", {"pointee_write(2..3=maybe)", "pointee_read(2..3=never)", "taken()"}}
--call_properties+={"name(queue_remove_raw)", {"pointee_read(2=never)", "taken()"}}
--call_properties+={"macro(^memset$)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--call_properties+={"macro(^va_start$)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--call_properties+={"macro(^memcmp$)", {"pointee_write(1..2=never)", "taken()"}}
--call_properties+={"macro(^memcpy$)", {"pointee_write(1=always&&2..=never)", "pointee_read(1=never&&2..=always)", "taken()"}}
--call_properties+={"name(get_cpu_info)",{pure}}
--call_properties+={"name(pdx_to_pfn)",{pure}}
--call_properties+={"name(is_pci_passthrough_enabled)",{const}}
--call_properties+={"name(get_cycles)", {"noeffect"}}
--call_properties+={"name(msi_gflags)",{const}}
--call_properties+={"name(hvm_save_size)",{pure}}
--call_properties+={"name(cpu_has)",{pure}}
--call_properties+={"name(boot_cpu_has)",{pure}}
--call_properties+={"name(get_cpu_info)",{pure}}
--call_properties+={"name(put_pte_flags)",{const}}
--call_properties+={"name(is_pv_vcpu)",{pure}}
-
--doc_begin="Property inferred as a consequence of the semantics of device_tree_get_reg"
--call_properties+={"name(acquire_static_memory_bank)", {"pointee_write(4..=always)", "pointee_read(4..=never)", "taken()"}}
--doc_end
-
--doc_begin="Property inferred as a consequence of the semantics of dt_set_cell"
--call_properties+={"name(set_interrupt)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--doc_end
-
--doc_begin="Property inferred as a consequence of the semantics of __p2m_get_mem_access"
--call_properties+={"name(p2m_get_mem_access)", {"pointee_write(3=always)", "pointee_read(3=never)", "taken()"}}
--doc_end
-
--doc_begin="This function has alternative definitions with props {write=always,read=never} and {write=never,read=never}"
--call_properties+={"name(alloc_cpumask_var)", {"pointee_write(1=maybe)", "pointee_read(1=never)", "taken()"}}
--doc_end
-
--doc_begin="Property inferred as a consequence of the semantics of alloc_cpumask_var"
--call_properties+={"name(xenctl_bitmap_to_cpumask)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--doc_end
-
--doc_begin="The call to bitmap_and causes the pointee of dstp to be always written"
--call_properties+={"^cpumask_(and|andnot|clear|copy|complement).*$", {"pointee_write(1=always)", "pointee_read(1=never)" "taken()"}}
--call_properties+={"^bitmap_(andnot|complement|fill).*$", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--doc_end
-
--doc_begin="The .*copy_(to|from).* helpers all have a memcpy-like expectation that the destination is a copy of the source.
-Furthermore, their uses do initialize the involved variables as needed by futher uses in the caller."
--call_properties+={"macro(^(__)?(raw_)?copy_from_(paddr|guest|compat)(_offset)?$)", {"pointee_write(1=always)", "pointee_read(1=never)", "taken()"}}
--call_properties+={"macro(^(__)?copy_to_(guest|compat)(_offset)?$)", {"pointee_write(2=always)", "pointee_read(2=never)", "taken()"}}
--doc_end
-
--doc_begin="Functions generated by build_atomic_read cannot be considered pure
-since the input pointer is volatile, but they do not produce any persistent side
-effect."
--call_properties+={"^read_u(8|16|32|64|int)_atomic.*$", {noeffect}}
--doc_end
-
--doc_begin="Functions generated by TYPE_SAFE are const."
--call_properties+={"^(mfn|gfn|pfn)_x\\(.*$",{const}}
--call_properties+={"^_(mfn|gfn|pfn)\\(.*$",{const}}
--doc_end
diff --git a/automation/eclair_analysis/prepare.sh b/automation/eclair_analysis/prepare.sh
index fe9d16e48e..47b2a2f32a 100755
--- a/automation/eclair_analysis/prepare.sh
+++ b/automation/eclair_analysis/prepare.sh
@@ -43,4 +43,6 @@ fi
     make -f "${script_dir}/Makefile.prepare" prepare
     # Translate the /* SAF-n-safe */ comments into ECLAIR CBTs
     scripts/xen-analysis.py --run-eclair --no-build --no-clean
+    # Translate function-properties.json into ECLAIR properties
+    python3 ${script_dir}/propertyparser.py
 )
diff --git a/automation/eclair_analysis/propertyparser.py b/automation/eclair_analysis/propertyparser.py
new file mode 100644
index 0000000000..0d02f505a6
--- /dev/null
+++ b/automation/eclair_analysis/propertyparser.py
@@ -0,0 +1,37 @@
+import json
+import os
+
+script_dir = os.path.dirname(__file__)
+properties_path = os.path.join(script_dir, "../../docs/function_macro_properties.json")
+output_path   = os.path.join(script_dir, "ECLAIR/call_properties.ecl")
+
+with open(properties_path) as fp:
+    properties = json.load(fp)['content']
+
+ecl = open(output_path, 'w')
+
+for record in properties:
+
+    string = "-call_properties+={\""
+    if record['type'] == "function":
+        string += f"{record['value']}\", {{".replace("\\", "\\\\")
+    else:
+        string += f"{record['type']}({record['value']})\", {{".replace("\\", "\\\\")
+
+    i=0
+    for prop in record['properties'].items():
+        if prop[0] == 'attribute':
+            string += prop[1]
+            i+=1
+        else:
+            string += f"\"{prop[0]}({prop[1]})\""
+            i+=1
+
+        if i<len(record['properties']):
+            string += ", "
+        else:
+            string +="}}\n"
+
+    ecl.write(string)
+
+ecl.close()
diff --git a/docs/function_macro_properties.json b/docs/function_macro_properties.json
new file mode 100644
index 0000000000..74058297b5
--- /dev/null
+++ b/docs/function_macro_properties.json
@@ -0,0 +1,841 @@
+{
+   "version": "1.0",
+   "content": [
+      {
+         "type": "function",
+         "value": "^printk.*$",
+         "properties":{
+            "pointee_write": "1..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^debugtrace_printk.*$",
+         "properties":{
+            "pointee_write": "1..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^panic.*$",
+         "properties":{
+            "pointee_write": "1..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^domain_crash$",
+         "properties":{
+            "pointee_write": "2..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^(g?d|mm_)?printk$",
+         "properties":{
+            "pointee_write": "2..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^guest_bug_on_failed$",
+         "properties":{
+            "pointee_write": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^spin_lock_init_prof$",
+         "properties":{
+            "pointee_write": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^sched_test_func$",
+         "properties":{
+            "pointee_write": "1..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^dev_(info|warn)$",
+         "properties":{
+            "pointee_write": "1..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^PAGING_DEBUG$",
+         "properties":{
+            "pointee_write": "1..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^ACPI_(WARNING|ERROR|INFO)$",
+         "properties":{
+            "pointee_write": "1..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^fdt_get_property_by_offset_.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^read_atomic_size.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^device_tree_get_reg.*$",
+         "properties":{
+            "pointee_write": "4..=always",
+            "pointee_read": "4..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^dt_get_range.*$",
+         "properties":{
+            "pointee_write": "3..=always",
+            "pointee_read": "3..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^parse_static_mem_prop.*$",
+         "properties":{
+            "pointee_write": "2..=always",
+            "pointee_read": "2..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^get_ttbr_and_gran_64bit.*$",
+         "properties":{
+            "pointee_write": "1..2=always",
+            "pointee_read": "1..2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^hvm_emulate_init_once.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^__vmread.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^hvm_pci_decode_addr.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^vpci_mmcfg_decode_addr.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^x86emul_decode.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^unmap_grant_ref.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^arm_smmu_cmdq_build_cmd.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^pci_size_mem_bar.*$",
+         "properties":{
+            "pointee_write": "4=always",
+            "pointee_read": "4=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^_hvm_read_entry.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^hvm_map_guest_frame_rw.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^guest_cpuid.*$",
+         "properties":{
+            "pointee_write": "4=always",
+            "pointee_read": "4=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^epte_get_entry_emt.*$",
+         "properties":{
+            "pointee_write": "5=always",
+            "pointee_read": "5=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^mcheck_mca_logout.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^set_field_in_reg_u32.*$",
+         "properties":{
+            "pointee_write": "5=always",
+            "pointee_read": "5=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^alloc_affinity_masks.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^xasprintf.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^find_non_smt.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^call_rcu.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^getdomaininfo.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^MAPPING_(INSERT|SEARCH)\\(.*$",
+         "properties":{
+            "pointee_write": "2..=always",
+            "pointee_read": "2..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^FormatDec.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^FormatHex.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^p2m_get_ioreq_server.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^elf_memset_unchecked.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^set_iommu_pte_present.*$",
+         "properties":{
+            "pointee_write": "7=always",
+            "pointee_read": "7=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^clear_iommu_pte_present.*$",
+         "properties":{
+            "pointee_write": "4=always",
+            "pointee_read": "4=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^vcpu_runstate_get.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^va_start.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^sgi_target_init.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^get_hw_residencies.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^x86_cpu_policy_to_featureset.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^simple_strtou?ll?\\(.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^msi_compose_msg.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^print_tainted.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^get_hvm_registers.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^x86_insn_modrm.*$",
+         "properties":{
+            "pointee_write": "2..3=always",
+            "pointee_read": "2..3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^cpuid_count_leaf.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^rcu_lock_remote_domain_by_id.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^cpuid_count.*$",
+         "properties":{
+            "pointee_write": "3..=always",
+            "pointee_read": "3..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^.*efi_boot_mem_unused.*$",
+         "properties":{
+            "pointee_write": "1..=always",
+            "pointee_read": "1..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^collect_time_info.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^setup_xstate_comp.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^map_domain_gfn.*$",
+         "properties":{
+            "pointee_read": "5=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^fdt_getprop.*$",
+         "properties":{
+            "pointee_read": "4=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^fdt_get_name.*$",
+         "properties":{
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^fdt_get_property.*$",
+         "properties":{
+            "pointee_read": "4=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^pci_get_host_bridge_segment.*$",
+         "properties":{
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^dt_get_property.*$",
+         "properties":{
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^dt_property_read_u32.*$",
+         "properties":{
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^dt_device_get_paddr.*$",
+         "properties":{
+            "pointee_read": "3..4=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^get_evtchn_dt_property.*$",
+         "properties":{
+            "pointee_write": "2..3=maybe",
+            "pointee_read": "2..3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^setup_chosen_node.*$",
+         "properties":{
+            "pointee_write": "2..3=maybe",
+            "pointee_read": "2..3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^queue_remove_raw.*$",
+         "properties":{
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^memset$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^va_start$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^memcmp$",
+         "properties":{
+            "pointee_write": "1..2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^memcpy$",
+         "properties":{
+            "pointee_write": "1=always&&2..=never",
+            "pointee_read": "1=never&&2..=always",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^get_cpu_info.*$",
+         "properties":{
+            "attribute": "pure"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^pdx_to_pfn.*$",
+         "properties":{
+            "attribute": "pure"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^is_pci_passthrough_enabled.*$",
+         "properties":{
+            "attribute": "const"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^get_cycles.*$",
+         "properties":{
+            "attribute": "noeffect"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^msi_gflags.*$",
+         "properties":{
+            "attribute": "const"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^hvm_save_size.*$",
+         "properties":{
+            "attribute": "pure"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^cpu_has.*$",
+         "properties":{
+            "attribute": "pure"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^boot_cpu_has.*$",
+         "properties":{
+            "attribute": "pure"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^get_cpu_info.*$",
+         "properties":{
+            "attribute": "pure"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^put_pte_flags.*$",
+         "properties":{
+            "attribute": "const"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^is_pv_cpu.*$",
+         "properties":{
+            "attribute": "pure"
+         }
+      },
+      {
+         "description": "Property inferred as a consequence of the semantics of device_tree_get_reg",
+         "type": "function",
+         "value": "^acquire_static_memory_bank.*$",
+         "properties":{
+            "pointee_write": "4..=always",
+            "pointee_read": "4..=never",
+            "taken": ""
+         }
+      },
+      {
+         "description": "Property inferred as a consequence of the semantics of dt_set_cell",
+         "type": "function",
+         "value": "^set_interrupt.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "description":"Property inferred as a consequence of the semantics of __p2m_get_mem_access",
+         "type": "function",
+         "value": "^p2m_get_mem_access.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "description": "This function has alternative definitions with props {write=always,read=never} and {write=never,read=never}",
+         "type": "function",
+         "value": "^alloc_cpumask_var.*$",
+         "properties":{
+            "pointee_write": "1=maybe",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "description": "Property inferred as a consequence of the semantics of alloc_cpumask_var",
+         "type": "function",
+         "value": "^xenctl_bitmap_to_cpumask.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "description": "The call to bitmap_and causes the pointee of dstp to be always written",
+         "type": "function",
+         "value": "^cpumask_(and|andnot|clear|copy|complement).*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "description": "The call to bitmap_and causes the pointee of dstp to be always written",
+         "type": "function",
+         "value": "^bitmap_(andnot|complement|fill).*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "description": "The .*copy_(to|from).* helpers all have a memcpy-like expectation that the destination is a copy of the source. Furthermore, their uses do initialize the involved variables as needed by futher uses in the caller.",
+         "type": "macro",
+         "value": "^(__)?(raw_)?copy_from_(paddr|guest|compat)(_offset)?$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "description":"The .*copy_(to|from).* helpers all have a memcpy-like expectation that the destination is a copy of the source. Furthermore, their uses do initialize the involved variables as needed by futher uses in the caller.",
+         "type": "macro",
+         "value": "^(__)?copy_to_(guest|compat)(_offset)?$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "description": "Functions generated by build_atomic_read cannot be considered pure since the input pointer is volatile, but they do not produce any persistent side effect.",
+         "type": "function",
+         "value": "^read_u(8|16|32|64|int)_atomic.*$",
+         "properties":{
+            "attribute": "noeffect"
+         }
+      },
+      {
+         "description": "Functions generated by TYPE_SAFE are const.",
+         "type": "function",
+         "value": "^(mfn|gfn|pfn)_x\\(.*$",
+         "properties":{
+            "attribute": "const"
+         }
+      },
+      {
+         "description": "Functions generated by TYPE_SAFE are const.",
+         "type": "function",
+         "value": "^_(mfn|gfn|pfn)\\(.*$",
+         "properties":{
+            "attribute": "const"
+         }
+      }
+   ]
+}
diff --git a/docs/function_macro_properties.rst b/docs/function_macro_properties.rst
new file mode 100644
index 0000000000..ea6fb5cf1f
--- /dev/null
+++ b/docs/function_macro_properties.rst
@@ -0,0 +1,58 @@
+.. SPDX-License-Identifier: CC-BY-4.0
+
+Properties list for Xen
+=======================
+
+Some functions and macros are found to have properties relevant to
+the Xen codebase. For this reason, the file docs/properties.json
+contains all the needed properties.
+
+Here is an example of the properties.json file::
+
+  {
+     "version": "1.0",
+     "content": [
+        {
+           "description": ""
+           "type": "function",       // required
+           "value:": "^printk*.$",   // required
+           "properties":{
+              "pointee_write": "1..2=never",
+              "pointee_read": "",
+              "taken": ""
+              "attribute": ""
+           }
+        }
+     ]
+  }
+
+Here is an explanation of the fields inside an object of the "content" array:
+
+ - description: a brief description of why the properties apply
+ - type: this is the kind of the element called: it may be either ``macro`` or ``function``
+ - value: must be a regex, starting with ^ and ending with $ and matching function fully
+   qualified name or macro name.
+ - properties: a list of properties applied to said function.
+   Possible values are:
+
+    - pointee_write: indicate the write use for call arguments that correspond to
+      parameters whose pointee types are non-const
+    - pointee_read: indicate the read use for call arguments that correspond to
+      parameters whose pointee types are non-const
+    - taken: indicates that the specified address arguments may be stored in objects
+      that persist after the function has ceased to exist (excluding the returned value);
+      address arguments not listed are never taken
+    - attribute: attributes a function may have. Possible values are pure, const and noeffect.
+
+   pointee_read and pointee_write use a specific kind of argument, structured as pointee_arg=rw:
+
+    - pointee_arg: argument index for callee. Index 0 refers to the return value,
+      the indices of the arguments start from 1. It can be either a single value or a range.
+    - rw: a value that's either always, maybe or never
+
+       - always: for pointee_read: argument pointee is expected to be fully read in the function body,
+         for pointee_write: argument pointee is fully initialized at function exit
+       - maybe: for pointee_read: argument pointee may be expected to be read in the function body,
+         for pointee_write: argument pointee may be written by function body
+       - never: for pointee_read: argument pointee is not expected to be read in the function body,
+         for pointee_write: argument pointee is never written by function body
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 08 13:44:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 08 Feb 2024 13:44:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.678201.1055282 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rY4hA-0004m2-BD; Thu, 08 Feb 2024 13:44:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 678201.1055282; Thu, 08 Feb 2024 13:44:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rY4hA-0004lv-8i; Thu, 08 Feb 2024 13:44:04 +0000
Received: by outflank-mailman (input) for mailman id 678201;
 Thu, 08 Feb 2024 13:44:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rY4h8-0004ln-Es
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 13:44:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rY4h8-0007NG-61
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 13:44:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rY4h8-0001ER-1T
 for xen-changelog@lists.xenproject.org; Thu, 08 Feb 2024 13:44:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=xku8ODXNSFndZfERRpkI4bBJdAqNi/9Cn4cbjEFkGQc=; b=xN6plv/Bd//fz25nz0SlXNinOY
	FnP8AOGxrnUgCxyvoIhnqAwg0nHr0jsBj+Q3OLm9vXpQk9L+38PrzdTa8TaVka8vYgVQvnaM4M3mM
	H2O8NvaiKa8PMuMUHrFEzRzCkOmIn4ckGD6jvwQ/foQJbGS81yzhQTRGrOXafyeOnBac=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [mini-os master] Mini-OS: fix 9pfront fix
Message-Id: <E1rY4h8-0001ER-1T@xenbits.xenproject.org>
Date: Thu, 08 Feb 2024 13:44:02 +0000

commit 2bc8dbb9b6111113d27455cbca318ea337309c04
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 8 14:43:13 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 8 14:43:13 2024 +0100

    Mini-OS: fix 9pfront fix
    
    There was a typo in the recent 9pfront fix.
    
    Fixes: b119f0178fd8 ("Mini-OS: fix 9pfs frontend error path")
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 9pfront.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/9pfront.c b/9pfront.c
index 042879a..1741d60 100644
--- a/9pfront.c
+++ b/9pfront.c
@@ -729,7 +729,7 @@ static int p9_stat(struct dev_9pfs *dev, uint32_t fid, struct p9_stat *stat)
 
     ret = req->result;
     if ( ret )
-        free_stat(&stat);
+        free_stat(stat);
 
     put_free_req(dev, req);
 
--
generated by git-patchbot for /home/xen/git/mini-os.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 09 11:55:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 09 Feb 2024 11:55:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.678664.1056140 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rYPTD-0005cS-9R; Fri, 09 Feb 2024 11:55:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 678664.1056140; Fri, 09 Feb 2024 11:55:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rYPTD-0005cL-6u; Fri, 09 Feb 2024 11:55:03 +0000
Received: by outflank-mailman (input) for mailman id 678664;
 Fri, 09 Feb 2024 11:55:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYPTC-0005ao-2S
 for xen-changelog@lists.xenproject.org; Fri, 09 Feb 2024 11:55:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYPTB-00023o-Sc
 for xen-changelog@lists.xenproject.org; Fri, 09 Feb 2024 11:55:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYPTB-0006vl-Ra
 for xen-changelog@lists.xenproject.org; Fri, 09 Feb 2024 11:55:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=FC/ZvR4jzf4uj+AO9MLO1L6g9wXJ9In10Mgw9iF4mrc=; b=28MqX9oa1GQ3IPQ+Yurl5B+5WT
	gJGb11URVDGBJ4PLg+4iylmoTYuIHq986NcWNESKrsPwUBrkOK/R3sz8WrHICIesLXzqqhl2jRdWM
	FcSiRGPQZjMySRrE7DbMDI7j8luXuzm2UGRrFEEufOKghO7ypOXiRv0OS52gPtR9WUmk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: Fix UBSAN failure in start_xen()
Message-Id: <E1rYPTB-0006vl-Ra@xenbits.xenproject.org>
Date: Fri, 09 Feb 2024 11:55:01 +0000

commit e11f5766503c0ff074b4e0f888bbfc931518a169
Author:     Michal Orzel <michal.orzel@amd.com>
AuthorDate: Thu Feb 8 11:43:39 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu Feb 8 16:09:51 2024 +0000

    xen/arm: Fix UBSAN failure in start_xen()
    
    When running Xen on arm32, in scenario where Xen is loaded at an address
    such as boot_phys_offset >= 2GB, UBSAN reports the following:
    
    (XEN) UBSAN: Undefined behaviour in arch/arm/setup.c:739:58
    (XEN) pointer operation underflowed 00200000 to 86800000
    (XEN) Xen WARN at common/ubsan/ubsan.c:172
    (XEN) ----[ Xen-4.19-unstable  arm32  debug=y ubsan=y  Not tainted ]----
    ...
    (XEN) Xen call trace:
    (XEN)    [<0031b4c0>] ubsan.c#ubsan_epilogue+0x18/0xf0 (PC)
    (XEN)    [<0031d134>] __ubsan_handle_pointer_overflow+0xb8/0xd4 (LR)
    (XEN)    [<0031d134>] __ubsan_handle_pointer_overflow+0xb8/0xd4
    (XEN)    [<004d15a8>] start_xen+0xe0/0xbe0
    (XEN)    [<0020007c>] head.o#primary_switched+0x4/0x30
    
    The failure is reported for the following line:
    (paddr_t)(uintptr_t)(_start + boot_phys_offset)
    
    This occurs because the compiler treats (ptr + size) with size bigger than
    PTRDIFF_MAX as undefined behavior. To address this, switch to macro
    virt_to_maddr(), given the future plans to eliminate boot_phys_offset.
    
    Signed-off-by: Michal Orzel <michal.orzel@amd.com>
    Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
    Tested-by: Luca Fancellu <luca.fancellu@arm.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 7e28f62d09..424744ad5e 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -736,7 +736,7 @@ void asmlinkage __init start_xen(unsigned long boot_phys_offset,
 
     /* Register Xen's load address as a boot module. */
     xen_bootmodule = add_boot_module(BOOTMOD_XEN,
-                             (paddr_t)(uintptr_t)(_start + boot_phys_offset),
+                             virt_to_maddr(_start),
                              (paddr_t)(uintptr_t)(_end - _start), false);
     BUG_ON(!xen_bootmodule);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 10 02:44:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 10 Feb 2024 02:44:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.678897.1056478 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rYdLh-0003Yr-IP; Sat, 10 Feb 2024 02:44:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 678897.1056478; Sat, 10 Feb 2024 02:44:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rYdLh-0003Yj-FT; Sat, 10 Feb 2024 02:44:13 +0000
Received: by outflank-mailman (input) for mailman id 678897;
 Sat, 10 Feb 2024 02:44:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYdLg-0003YZ-A2
 for xen-changelog@lists.xenproject.org; Sat, 10 Feb 2024 02:44:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYdLg-0004Fr-99
 for xen-changelog@lists.xenproject.org; Sat, 10 Feb 2024 02:44:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYdLg-0005AM-7p
 for xen-changelog@lists.xenproject.org; Sat, 10 Feb 2024 02:44:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=0egh08QC66Sc4+s9x5NRXd6h1TbCcm+o02OKSetrLSI=; b=QDaxbB5LUpsm79MyJCui7FCPpw
	zacGUPvTr6eEfwN41XcsVMHzUBvJg0uFaJdLWGQM0QAugKw83J445padE3+E5sWX7CCl3Me46KfVE
	psjyMtKbEjS3CvZkFobCZu+vxUyuIGR87ZYfPFtEDGpZoDwVUev/pSl3UJrlYAw/ULrI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86: convert misc assembly function annotations
Message-Id: <E1rYdLg-0005AM-7p@xenbits.xenproject.org>
Date: Sat, 10 Feb 2024 02:44:12 +0000

commit 837e5144ac5ee0f93a19e086f73d065833ad70ea
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri Feb 9 08:16:50 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri Feb 9 08:16:50 2024 +0100

    x86: convert misc assembly function annotations
    
    Use the generic framework from xen/linkage.h.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/clear_page.S               |  7 +++----
 xen/arch/x86/copy_page.S                |  7 +++----
 xen/arch/x86/guest/xen/hypercall_page.S |  6 ++----
 xen/arch/x86/indirect-thunk.S           |  6 ++----
 xen/arch/x86/pv/gpr_switch.S            | 13 ++++---------
 5 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/xen/arch/x86/clear_page.S b/xen/arch/x86/clear_page.S
index 5b5622cc52..d6c076f1d8 100644
--- a/xen/arch/x86/clear_page.S
+++ b/xen/arch/x86/clear_page.S
@@ -1,8 +1,9 @@
         .file __FILE__
 
+#include <xen/linkage.h>
 #include <asm/page.h>
 
-ENTRY(clear_page_sse2)
+FUNC(clear_page_sse2)
         mov     $PAGE_SIZE/32, %ecx
         xor     %eax,%eax
 
@@ -16,6 +17,4 @@ ENTRY(clear_page_sse2)
 
         sfence
         ret
-
-        .type clear_page_sse2, @function
-        .size clear_page_sse2, . - clear_page_sse2
+END(clear_page_sse2)
diff --git a/xen/arch/x86/copy_page.S b/xen/arch/x86/copy_page.S
index ddb6e0ebbb..c3c436545b 100644
--- a/xen/arch/x86/copy_page.S
+++ b/xen/arch/x86/copy_page.S
@@ -1,5 +1,6 @@
         .file __FILE__
 
+#include <xen/linkage.h>
 #include <asm/page.h>
 
 #define src_reg %rsi
@@ -10,7 +11,7 @@
 #define tmp3_reg %r10
 #define tmp4_reg %r11
 
-ENTRY(copy_page_sse2)
+FUNC(copy_page_sse2)
         mov     $PAGE_SIZE/(4*WORD_SIZE)-3, %ecx
 
         prefetchnta 2*4*WORD_SIZE(src_reg)
@@ -41,6 +42,4 @@ ENTRY(copy_page_sse2)
 
         sfence
         ret
-
-        .type copy_page_sse2, @function
-        .size copy_page_sse2, . - copy_page_sse2
+END(copy_page_sse2)
diff --git a/xen/arch/x86/guest/xen/hypercall_page.S b/xen/arch/x86/guest/xen/hypercall_page.S
index 9958d02cfd..7ab55fc1f6 100644
--- a/xen/arch/x86/guest/xen/hypercall_page.S
+++ b/xen/arch/x86/guest/xen/hypercall_page.S
@@ -3,13 +3,11 @@
 #include <public/xen.h>
 
         .section ".text.page_aligned", "ax", @progbits
-        .p2align PAGE_SHIFT
 
-GLOBAL(hypercall_page)
+DATA(hypercall_page, PAGE_SIZE)
          /* Poisoned with `ret` for safety before hypercalls are set up. */
         .fill PAGE_SIZE, 1, 0xc3
-        .type hypercall_page, STT_OBJECT
-        .size hypercall_page, PAGE_SIZE
+END(hypercall_page)
 
 /*
  * Identify a specific hypercall in the hypercall page
diff --git a/xen/arch/x86/indirect-thunk.S b/xen/arch/x86/indirect-thunk.S
index de6aef6068..fd5493c22b 100644
--- a/xen/arch/x86/indirect-thunk.S
+++ b/xen/arch/x86/indirect-thunk.S
@@ -35,15 +35,13 @@
 .macro GEN_INDIRECT_THUNK reg:req
         .section .text.__x86_indirect_thunk_\reg, "ax", @progbits
 
-ENTRY(__x86_indirect_thunk_\reg)
+FUNC(__x86_indirect_thunk_\reg)
         ALTERNATIVE_2 __stringify(IND_THUNK_RETPOLINE \reg),              \
         __stringify(IND_THUNK_LFENCE \reg), X86_FEATURE_IND_THUNK_LFENCE, \
         __stringify(IND_THUNK_JMP \reg),    X86_FEATURE_IND_THUNK_JMP
 
         int3 /* Halt straight-line speculation */
-
-        .size __x86_indirect_thunk_\reg, . - __x86_indirect_thunk_\reg
-        .type __x86_indirect_thunk_\reg, @function
+END(__x86_indirect_thunk_\reg)
 .endm
 
 /* Instantiate GEN_INDIRECT_THUNK for each register except %rsp. */
diff --git a/xen/arch/x86/pv/gpr_switch.S b/xen/arch/x86/pv/gpr_switch.S
index e7f5bfcd2d..5409ad3b14 100644
--- a/xen/arch/x86/pv/gpr_switch.S
+++ b/xen/arch/x86/pv/gpr_switch.S
@@ -10,7 +10,7 @@
 #include <asm/asm_defns.h>
 
 /* Load guest GPRs.  Parameter in %rdi, clobbers all registers. */
-ENTRY(load_guest_gprs)
+FUNC(load_guest_gprs)
         movq  UREGS_rdx(%rdi), %rdx
         movq  UREGS_rax(%rdi), %rax
         movq  UREGS_rbx(%rdi), %rbx
@@ -27,13 +27,10 @@ ENTRY(load_guest_gprs)
         movq  UREGS_rcx(%rdi), %rcx
         movq  UREGS_rdi(%rdi), %rdi
         ret
-
-        .size load_guest_gprs, . - load_guest_gprs
-        .type load_guest_gprs, STT_FUNC
-
+END(load_guest_gprs)
 
 /* Save guest GPRs.  Parameter on the stack above the return address. */
-ENTRY(save_guest_gprs)
+FUNC(save_guest_gprs)
         pushq %rdi
         movq  2*8(%rsp), %rdi
         movq  %rax, UREGS_rax(%rdi)
@@ -52,6 +49,4 @@ ENTRY(save_guest_gprs)
         movq  %rdx, UREGS_rdx(%rdi)
         movq  %rcx, UREGS_rcx(%rdi)
         ret
-
-        .size save_guest_gprs, . - save_guest_gprs
-        .type save_guest_gprs, STT_FUNC
+END(save_guest_gprs)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 10 02:44:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 10 Feb 2024 02:44:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.678896.1056474 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rYdLY-0003XR-Gq; Sat, 10 Feb 2024 02:44:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 678896.1056474; Sat, 10 Feb 2024 02:44:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rYdLY-0003XJ-Dw; Sat, 10 Feb 2024 02:44:04 +0000
Received: by outflank-mailman (input) for mailman id 678896;
 Sat, 10 Feb 2024 02:44:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYdLW-0003XD-CK
 for xen-changelog@lists.xenproject.org; Sat, 10 Feb 2024 02:44:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYdLW-0004FV-5k
 for xen-changelog@lists.xenproject.org; Sat, 10 Feb 2024 02:44:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYdLW-00059i-4E
 for xen-changelog@lists.xenproject.org; Sat, 10 Feb 2024 02:44:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=lCf2wfD0pQIOZ/FzOsWfZEtgJkeFvYeQ8x1z16Hy/14=; b=H4I/IIWlUr26wHMGsb6TVfWFps
	fVYDv6s7Vst+CCdv6l0bjyT8zUgYmtxyWu2E0QF+5n//5m0GvtRWRg9HjLWbALEDRHqZrc8c6Ksxn
	fD13QBiqHQ9gW6WdL6ZPytUh5HFMMWN9hPCHXoiDWgkSTjP5TbABAYs5JdqmnMEr6Tmg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] SVM: convert entry point annotations
Message-Id: <E1rYdLW-00059i-4E@xenbits.xenproject.org>
Date: Sat, 10 Feb 2024 02:44:02 +0000

commit 00ae55ad76d30c7159eee4e1be974a32f2dbea08
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri Feb 9 08:16:09 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri Feb 9 08:16:09 2024 +0100

    SVM: convert entry point annotations
    
    Use the generic framework from xen/linkage.h.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/hvm/svm/entry.S | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/hvm/svm/entry.S b/xen/arch/x86/hvm/svm/entry.S
index c52528fed4..60b0b00ed0 100644
--- a/xen/arch/x86/hvm/svm/entry.S
+++ b/xen/arch/x86/hvm/svm/entry.S
@@ -24,7 +24,7 @@
 #include <asm/asm_defns.h>
 #include <asm/page.h>
 
-ENTRY(svm_asm_do_resume)
+FUNC(svm_asm_do_resume)
         GET_CURRENT(bx)
 .Lsvm_do_resume:
         call svm_intr_assist
@@ -132,7 +132,7 @@ __UNLIKELY_END(nsvm_hap)
          * to safely resolve any Spectre-v1 concerns in the above logic.
          */
         stgi
-GLOBAL(svm_stgi_label)
+LABEL(svm_stgi_label, 0)
         call svm_vmexit_handler
         jmp  .Lsvm_do_resume
 
@@ -140,6 +140,4 @@ GLOBAL(svm_stgi_label)
         sti
         call do_softirq
         jmp  .Lsvm_do_resume
-
-        .type svm_asm_do_resume, @function
-        .size svm_asm_do_resume, . - svm_asm_do_resume
+END(svm_asm_do_resume)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 10 02:44:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 10 Feb 2024 02:44:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.678898.1056482 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rYdLr-0003bL-Jb; Sat, 10 Feb 2024 02:44:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 678898.1056482; Sat, 10 Feb 2024 02:44:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rYdLr-0003bD-Gy; Sat, 10 Feb 2024 02:44:23 +0000
Received: by outflank-mailman (input) for mailman id 678898;
 Sat, 10 Feb 2024 02:44:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYdLq-0003b3-DP
 for xen-changelog@lists.xenproject.org; Sat, 10 Feb 2024 02:44:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYdLq-0004G4-CH
 for xen-changelog@lists.xenproject.org; Sat, 10 Feb 2024 02:44:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYdLq-0005B7-BH
 for xen-changelog@lists.xenproject.org; Sat, 10 Feb 2024 02:44:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=V9ZbhKJiV7W82j4/VSiWXf6Dz7px46CRxxwVrY8hXoI=; b=m7/dkFOpccbCC4lFEiabhciwp3
	z/p6XZU0P9gqgfOV6vWI6jQvAScwle6Kw4KUOEZbUTbAm7KJioLNYg6FX7u/nsELoVIdu90jFCwGS
	r59v+U4BxiaJhAg0Wnc6dy0JgEbruHCh25oWYy4OwfCKpzU+nxpXW8sZX/9D/RvkCg8g=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/ocaml: Add missing vmtrace_buf_kb field
Message-Id: <E1rYdLq-0005B7-BH@xenbits.xenproject.org>
Date: Sat, 10 Feb 2024 02:44:22 +0000

commit e36c106b0b0e66c43855cdfdb6d41356c57ec577
Author:     Petr Beneš <w1benny@gmail.com>
AuthorDate: Fri Feb 9 08:17:24 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri Feb 9 08:17:24 2024 +0100

    tools/ocaml: Add missing vmtrace_buf_kb field
    
    Add the missing `vmtrace_buf_kb` field to the OCaml bindings to match the
    vm.cfg configuration, correcting an oversight from its initial introduction.
    
    Signed-off-by: Petr Beneš <w1benny@gmail.com>
    Acked-by: Christian Lindig <christian.lindig@cloud.com>
---
 tools/ocaml/libs/xc/xenctrl.ml      |  1 +
 tools/ocaml/libs/xc/xenctrl.mli     |  1 +
 tools/ocaml/libs/xc/xenctrl_stubs.c | 13 +++++++++++--
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml
index d6c6eb73db..55923857ec 100644
--- a/tools/ocaml/libs/xc/xenctrl.ml
+++ b/tools/ocaml/libs/xc/xenctrl.ml
@@ -85,6 +85,7 @@ type domctl_create_config =
     max_grant_frames: int;
     max_maptrack_frames: int;
     max_grant_version: int;
+    vmtrace_buf_kb: int32;
     cpupool_id: int32;
     arch: arch_domainconfig;
   }
diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli
index 3bfc16edba..9b4b45db3a 100644
--- a/tools/ocaml/libs/xc/xenctrl.mli
+++ b/tools/ocaml/libs/xc/xenctrl.mli
@@ -77,6 +77,7 @@ type domctl_create_config = {
   max_grant_frames: int;
   max_maptrack_frames: int;
   max_grant_version: int;
+  vmtrace_buf_kb: int32;
   cpupool_id: int32;
   arch: arch_domainconfig;
 }
diff --git a/tools/ocaml/libs/xc/xenctrl_stubs.c b/tools/ocaml/libs/xc/xenctrl_stubs.c
index 3703f48c74..2b6d3c09df 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -210,10 +210,17 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co
 #define VAL_MAX_GRANT_FRAMES    Field(config, 6)
 #define VAL_MAX_MAPTRACK_FRAMES Field(config, 7)
 #define VAL_MAX_GRANT_VERSION   Field(config, 8)
-#define VAL_CPUPOOL_ID          Field(config, 9)
-#define VAL_ARCH                Field(config, 10)
+#define VAL_VMTRACE_BUF_KB      Field(config, 9)
+#define VAL_CPUPOOL_ID          Field(config, 10)
+#define VAL_ARCH                Field(config, 11)
 
 	uint32_t domid = Int_val(wanted_domid);
+	uint64_t vmtrace_size = Int32_val(VAL_VMTRACE_BUF_KB);
+
+	vmtrace_size = ROUNDUP(vmtrace_size << 10, XC_PAGE_SHIFT);
+	if ( vmtrace_size != (uint32_t)vmtrace_size )
+		caml_invalid_argument("vmtrace_buf_kb");
+
 	int result;
 	struct xen_domctl_createdomain cfg = {
 		.ssidref = Int32_val(VAL_SSIDREF),
@@ -223,6 +230,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co
 		.max_maptrack_frames = Int_val(VAL_MAX_MAPTRACK_FRAMES),
 		.grant_opts =
 		    XEN_DOMCTL_GRANT_version(Int_val(VAL_MAX_GRANT_VERSION)),
+		.vmtrace_size = vmtrace_size,
 		.cpupool_id = Int32_val(VAL_CPUPOOL_ID),
 	};
 
@@ -279,6 +287,7 @@ CAMLprim value stub_xc_domain_create(value xch_val, value wanted_domid, value co
 
 #undef VAL_ARCH
 #undef VAL_CPUPOOL_ID
+#undef VAL_VMTRACE_BUF_KB
 #undef VAL_MAX_GRANT_VERSION
 #undef VAL_MAX_MAPTRACK_FRAMES
 #undef VAL_MAX_GRANT_FRAMES
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 10 02:44:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 10 Feb 2024 02:44:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.678899.1056485 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rYdM1-0003e2-Ko; Sat, 10 Feb 2024 02:44:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 678899.1056485; Sat, 10 Feb 2024 02:44:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rYdM1-0003dv-IQ; Sat, 10 Feb 2024 02:44:33 +0000
Received: by outflank-mailman (input) for mailman id 678899;
 Sat, 10 Feb 2024 02:44:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYdM0-0003dl-GX
 for xen-changelog@lists.xenproject.org; Sat, 10 Feb 2024 02:44:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYdM0-0004GI-Ff
 for xen-changelog@lists.xenproject.org; Sat, 10 Feb 2024 02:44:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYdM0-0005Bo-EM
 for xen-changelog@lists.xenproject.org; Sat, 10 Feb 2024 02:44:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=I1gCtAw9o/EXUWNNzH98YLUmzwebmYG35pRwGDaUEHA=; b=nrRcFS8BKx3e3MD987xM4aO7JJ
	NtGYEQ2K1XbDAJfO4zb89F726x/dFr6ZdcdTEeJ46yDerq17qVF4XMmHwA8x9PRDQSiyWQfau0bp/
	P3s15evJsCJKJPyFQhQoirBkgjNvOFhSLaOT7qHHOTmulheSN4a3R9az2jnk/tja0uM4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/serial: Drop serial_{put,get}c
Message-Id: <E1rYdM0-0005Bo-EM@xenbits.xenproject.org>
Date: Sat, 10 Feb 2024 02:44:32 +0000

commit 06024b26191eb6aed9cce77e7134f4159335b1ff
Author:     Michal Orzel <michal.orzel@amd.com>
AuthorDate: Fri Feb 9 08:17:39 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri Feb 9 08:17:39 2024 +0100

    xen/serial: Drop serial_{put,get}c
    
    After removal of gdbstub by commit d182f9feae6d ("x86: Remove gdbstub"),
    we no longer have users of serial_{put,get}c functions, so remove them.
    
    Signed-off-by: Michal Orzel <michal.orzel@amd.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
 xen/drivers/char/serial.c | 72 -----------------------------------------------
 xen/include/xen/serial.h  | 10 -------
 2 files changed, 82 deletions(-)

diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
index 324024c29a..93e217d348 100644
--- a/xen/drivers/char/serial.c
+++ b/xen/drivers/char/serial.c
@@ -196,36 +196,6 @@ static void __serial_putc(struct serial_port *port, char c)
     }
 }
 
-void serial_putc(int handle, char c)
-{
-    struct serial_port *port;
-    unsigned long flags;
-
-    if ( handle == -1 )
-        return;
-
-    port = &com[handle & SERHND_IDX];
-    if ( !port->driver || !port->driver->putc )
-        return;
-
-    spin_lock_irqsave(&port->tx_lock, flags);
-
-    if ( (c == '\n') && (handle & SERHND_COOKED) )
-        __serial_putc(port, '\r' | ((handle & SERHND_HI) ? 0x80 : 0x00));
-
-    if ( handle & SERHND_HI )
-        c |= 0x80;
-    else if ( handle & SERHND_LO )
-        c &= 0x7f;
-
-    __serial_putc(port, c);
-
-    if ( port->driver->flush )
-        port->driver->flush(port);
-
-    spin_unlock_irqrestore(&port->tx_lock, flags);
-}
-
 void serial_puts(int handle, const char *s, size_t nr)
 {
     struct serial_port *port;
@@ -261,48 +231,6 @@ void serial_puts(int handle, const char *s, size_t nr)
     spin_unlock_irqrestore(&port->tx_lock, flags);
 }
 
-char serial_getc(int handle)
-{
-    struct serial_port *port;
-    char c;
-    unsigned long flags;
-
-    if ( handle == -1 )
-        return '\0';
-
-    port = &com[handle & SERHND_IDX];
-    if ( !port->driver || !port->driver->getc )
-        return '\0';
-
-    do {
-        for ( ; ; )
-        {
-            spin_lock_irqsave(&port->rx_lock, flags);
-            
-            if ( port->rxbufp != port->rxbufc )
-            {
-                c = port->rxbuf[mask_serial_rxbuf_idx(port->rxbufc++)];
-                spin_unlock_irqrestore(&port->rx_lock, flags);
-                break;
-            }
-            
-            if ( port->driver->getc(port, &c) )
-            {
-                spin_unlock_irqrestore(&port->rx_lock, flags);
-                break;
-            }
-
-            spin_unlock_irqrestore(&port->rx_lock, flags);
-
-            cpu_relax();
-            udelay(100);
-        }
-    } while ( ((handle & SERHND_LO) &&  (c & 0x80)) ||
-              ((handle & SERHND_HI) && !(c & 0x80)) );
-    
-    return c & 0x7f;
-}
-
 int __init serial_parse_handle(const char *conf)
 {
     int handle, flags = 0;
diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
index 12ef24351d..7548bb7324 100644
--- a/xen/include/xen/serial.h
+++ b/xen/include/xen/serial.h
@@ -112,19 +112,9 @@ void serial_endboot(void);
 /* Takes a config string and creates a numeric handle on the COM port. */
 int serial_parse_handle(const char *conf);
 
-/* Transmit a single character via the specified COM port. */
-void serial_putc(int handle, char c);
-
 /* Transmit a string via the specified COM port. */
 void serial_puts(int handle, const char *s, size_t nr);
 
-/*
- * An alternative to registering a character-receive hook. This function
- * will not return until a character is available. It can safely be
- * called with interrupts disabled.
- */
-char serial_getc(int handle);
-
 /* Forcibly prevent serial lockup when the system is in a bad way. */
 /* (NB. This also forces an implicit serial_start_sync()). */
 void serial_force_unlock(int handle);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 10 02:44:43 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 10 Feb 2024 02:44:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.678900.1056489 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rYdMB-0003gW-MO; Sat, 10 Feb 2024 02:44:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 678900.1056489; Sat, 10 Feb 2024 02:44:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rYdMB-0003gP-Jt; Sat, 10 Feb 2024 02:44:43 +0000
Received: by outflank-mailman (input) for mailman id 678900;
 Sat, 10 Feb 2024 02:44:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYdMA-0003gH-K2
 for xen-changelog@lists.xenproject.org; Sat, 10 Feb 2024 02:44:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYdMA-0004GP-It
 for xen-changelog@lists.xenproject.org; Sat, 10 Feb 2024 02:44:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rYdMA-0005CQ-Hq
 for xen-changelog@lists.xenproject.org; Sat, 10 Feb 2024 02:44:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=qblI67rXqlOe8dcsaJzKcAZlHThsf+zNEMFtKtb8G0I=; b=1cl1dy9DoC5pF8TcfZuA3Ei9nv
	LzqR78oBP1aFlv5kAxQ8q6AFV2teb4hIRnC8+mTjRuKz1OOiyU+6IxK+zTA8hDbUBPl283UyX9HZ9
	Ca6M4mZgLBmvxEqWzO44QeqPF52xBtzgA83A0PJjT2TXLRXXcL7iK4ZUKzWKYzmysrio=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] config: update Mini-OS commit
Message-Id: <E1rYdMA-0005CQ-Hq@xenbits.xenproject.org>
Date: Sat, 10 Feb 2024 02:44:42 +0000

commit 4e5bd87d24ac2b08f33c6a9c0d530daef99ed369
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 9 08:18:04 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri Feb 9 08:18:04 2024 +0100

    config: update Mini-OS commit
    
    Update the Mini-OS upstream revision.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 Config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Config.mk b/Config.mk
index f7d6d84847..6f6e0425ba 100644
--- a/Config.mk
+++ b/Config.mk
@@ -224,7 +224,7 @@ QEMU_UPSTREAM_URL ?= https://xenbits.xen.org/git-http/qemu-xen.git
 QEMU_UPSTREAM_REVISION ?= master
 
 MINIOS_UPSTREAM_URL ?= https://xenbits.xen.org/git-http/mini-os.git
-MINIOS_UPSTREAM_REVISION ?= 090eeeb1631f00a9a41ebf66d9b4aacb97eb51e7
+MINIOS_UPSTREAM_REVISION ?= 2bc8dbb9b6111113d27455cbca318ea337309c04
 
 SEABIOS_UPSTREAM_URL ?= https://xenbits.xen.org/git-http/seabios.git
 SEABIOS_UPSTREAM_REVISION ?= rel-1.16.3
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 13 06:11:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 13 Feb 2024 06:11:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.679746.1057393 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rZm0W-0005g4-EE; Tue, 13 Feb 2024 06:11:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 679746.1057393; Tue, 13 Feb 2024 06:11:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rZm0W-0005fx-Bb; Tue, 13 Feb 2024 06:11:04 +0000
Received: by outflank-mailman (input) for mailman id 679746;
 Tue, 13 Feb 2024 06:11:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rZm0U-0005fp-BM
 for xen-changelog@lists.xenproject.org; Tue, 13 Feb 2024 06:11:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rZm0U-0007Rj-9E
 for xen-changelog@lists.xenproject.org; Tue, 13 Feb 2024 06:11:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rZm0U-0007Fy-88
 for xen-changelog@lists.xenproject.org; Tue, 13 Feb 2024 06:11:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=NOHys9yXdoW1DsNwfru8YHc+Z+p8PkzrtChwPNOngk8=; b=VfQ+XMIcDGTF0Q6V9hzazpEl+9
	7TJkb+BoXEtA+j/51jppOc7MD1xlYxIftseBb33SMGOh88t4aBcQS2aMEnCRV9VP2l3P0MmLMNVJl
	6LD9BakW8HvsZM8HcmSh5/0IycNjvVug3gvKUPgcMsN5aalqsTO6T5bVMhSlxD8WNu84=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/PV32: restore PAE-extended-CR3 logic
Message-Id: <E1rZm0U-0007Fy-88@xenbits.xenproject.org>
Date: Tue, 13 Feb 2024 06:11:02 +0000

commit a773adedbd913966e812bddcd6b223c2e4ce3061
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Feb 12 09:37:18 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 12 09:37:18 2024 +0100

    x86/PV32: restore PAE-extended-CR3 logic
    
    While the PAE-extended-CR3 VM assist is a 32-bit only concept, it still
    applies to guests also when run on a 64-bit hypervisor: The "extended
    CR3" format has to be used there as well, to fit the address in the only
    32-bit wide register there. As a result it was a mistake that the check
    was never enabled for that case, and was then mistakenly deleted in the
    course of removal of 32-bit-Xen code (218adf199e68 ["x86: We can assume
    CONFIG_PAGING_LEVELS==4"]).
    
    Similarly during Dom0 construction kernel awareness needs to be taken
    into account, and respective code was again mistakenly never enabled for
    32-bit Dom0 when running on 64-bit Xen (and thus wrongly deleted by
    5d1181a5ea5e ["xen: Remove x86_32 build target"]).
    
    At the same time restrict enabling of the assist for Dom0 to just the
    32-bit case. Furthermore there's no need for an atomic update there.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/mm.c            | 17 +++++++++++++++++
 xen/arch/x86/pv/dom0_build.c | 11 +++++++----
 2 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index b56e0d8065..4d6d7bfe4f 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -1504,6 +1504,23 @@ static int promote_l3_table(struct page_info *page)
     unsigned int   partial_flags = page->partial_flags;
     l3_pgentry_t   l3e = l3e_empty();
 
+    /*
+     * PAE pgdirs above 4GB are unacceptable if a 32-bit guest does not
+     * understand the weird 'extended cr3' format for dealing with high-order
+     * address bits. We cut some slack for control tools (before vcpu0 is
+     * initialised).
+     */
+    if ( is_pv_32bit_domain(d) &&
+         unlikely(!VM_ASSIST(d, pae_extended_cr3)) &&
+         mfn_x(l3mfn) >= PFN_DOWN(GB(4)) &&
+         d->vcpu[0] && d->vcpu[0]->is_initialised )
+    {
+        gdprintk(XENLOG_WARNING,
+                 "PAE pgd must be below 4GB (%#lx >= 0x100000)",
+                 mfn_x(l3mfn));
+        return -ERANGE;
+    }
+
     pl3e = map_domain_page(l3mfn);
 
     /*
diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c
index 5bbed3a36a..16d08c6796 100644
--- a/xen/arch/x86/pv/dom0_build.c
+++ b/xen/arch/x86/pv/dom0_build.c
@@ -495,12 +495,12 @@ int __init dom0_construct_pv(struct domain *d,
 
     nr_pages = dom0_compute_nr_pages(d, &parms, initrd_len);
 
-    if ( parms.pae == XEN_PAE_EXTCR3 )
-            set_bit(VMASST_TYPE_pae_extended_cr3, &d->vm_assist);
-
 #ifdef CONFIG_PV32
     if ( elf_32bit(&elf) )
     {
+        if ( parms.pae == XEN_PAE_EXTCR3 )
+            __set_bit(VMASST_TYPE_pae_extended_cr3, &d->vm_assist);
+
         if ( !pv_shim && (parms.virt_hv_start_low != UNSET_ADDR) )
         {
             unsigned long value = ROUNDUP(parms.virt_hv_start_low,
@@ -599,7 +599,10 @@ int __init dom0_construct_pv(struct domain *d,
         vphysmap_start = parms.p2m_base;
         vphysmap_end   = vphysmap_start + nr_pages * sizeof(unsigned long);
     }
-    page = alloc_domheap_pages(d, order, MEMF_no_scrub);
+    page = alloc_domheap_pages(d, order,
+                               MEMF_no_scrub |
+                               (VM_ASSIST(d, pae_extended_cr3) ||
+                                !compat ? 0 : MEMF_bits(32)));
     if ( page == NULL )
         panic("Not enough RAM for domain 0 allocation\n");
     alloc_spfn = mfn_x(page_to_mfn(page));
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 13 06:11:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 13 Feb 2024 06:11:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.679747.1057398 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rZm0g-0005hd-Fz; Tue, 13 Feb 2024 06:11:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 679747.1057398; Tue, 13 Feb 2024 06:11:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rZm0g-0005hV-DD; Tue, 13 Feb 2024 06:11:14 +0000
Received: by outflank-mailman (input) for mailman id 679747;
 Tue, 13 Feb 2024 06:11:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rZm0e-0005hB-FB
 for xen-changelog@lists.xenproject.org; Tue, 13 Feb 2024 06:11:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rZm0e-0007Rs-Ce
 for xen-changelog@lists.xenproject.org; Tue, 13 Feb 2024 06:11:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rZm0e-0007HE-Bi
 for xen-changelog@lists.xenproject.org; Tue, 13 Feb 2024 06:11:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=zQUYMy3jRFamlzNN/OYuGV9r5vFfu9+0yjigxbeDqBA=; b=R0Ac2YYtCp/sc4bzSi5sto+T0b
	hvRAoqvf82i7RH/cVv/weKKqtDTaTSpSHLwsMAWdRboW/d05lNulLSDP+gM/v4h4FQwB0eHGmXTNT
	Z8yj8hzclwibuq3GZ6Yah4TjCRHJ3Z2/NwrM56/FqE8KtgnrehFyaMBi+nc0TLSSQU+A=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/hvm: Fix fast singlestep state persistence
Message-Id: <E1rZm0e-0007HE-Bi@xenbits.xenproject.org>
Date: Tue, 13 Feb 2024 06:11:12 +0000

commit 897def94b56175ce569673a05909d2f223e1e749
Author:     Petr Beneš <w1benny@gmail.com>
AuthorDate: Mon Feb 12 09:37:58 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 12 09:37:58 2024 +0100

    x86/hvm: Fix fast singlestep state persistence
    
    This patch addresses an issue where the fast singlestep setting would persist
    despite xc_domain_debug_control being called with XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF.
    Specifically, if fast singlestep was enabled in a VMI session and that session
    stopped before the MTF trap occurred, the fast singlestep setting remained
    active even though MTF itself was disabled.  This led to a situation where, upon
    starting a new VMI session, the first event to trigger an EPT violation would
    cause the corresponding EPT event callback to be skipped due to the lingering
    fast singlestep setting.
    
    The fix ensures that the fast singlestep setting is properly reset when
    disabling single step debugging operations.
    
    Signed-off-by: Petr Beneš <w1benny@gmail.com>
    Reviewed-by: Tamas K Lengyel <tamas@tklengyel.com>
---
 xen/arch/x86/hvm/hvm.c | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index e8deeb0222..0cb822a41c 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -5160,26 +5160,40 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
 
 int hvm_debug_op(struct vcpu *v, int32_t op)
 {
-    int rc;
+    int rc = 0;
 
     switch ( op )
     {
         case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON:
         case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF:
-            rc = -EOPNOTSUPP;
             if ( !cpu_has_monitor_trap_flag )
-                break;
-            rc = 0;
-            vcpu_pause(v);
-            v->arch.hvm.single_step =
-                (op == XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON);
-            vcpu_unpause(v); /* guest will latch new state */
+                return -EOPNOTSUPP;
             break;
         default:
-            rc = -ENOSYS;
-            break;
+            return -ENOSYS;
+    }
+
+    vcpu_pause(v);
+
+    switch ( op )
+    {
+    case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON:
+        v->arch.hvm.single_step = true;
+        break;
+
+    case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF:
+        v->arch.hvm.single_step = false;
+        v->arch.hvm.fast_single_step.enabled = false;
+        v->arch.hvm.fast_single_step.p2midx = 0;
+        break;
+
+    default: /* Excluded above */
+        ASSERT_UNREACHABLE();
+        return -ENOSYS;
     }
 
+    vcpu_unpause(v); /* guest will latch new state */
+
     return rc;
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 13 06:11:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 13 Feb 2024 06:11:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.679748.1057402 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rZm0q-0005k6-HL; Tue, 13 Feb 2024 06:11:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 679748.1057402; Tue, 13 Feb 2024 06:11:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rZm0q-0005jy-El; Tue, 13 Feb 2024 06:11:24 +0000
Received: by outflank-mailman (input) for mailman id 679748;
 Tue, 13 Feb 2024 06:11:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rZm0o-0005jk-H2
 for xen-changelog@lists.xenproject.org; Tue, 13 Feb 2024 06:11:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rZm0o-0007SG-GC
 for xen-changelog@lists.xenproject.org; Tue, 13 Feb 2024 06:11:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rZm0o-0007IR-En
 for xen-changelog@lists.xenproject.org; Tue, 13 Feb 2024 06:11:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=svNnoNTwkbEPF6/RCvX1q7q/w9xgUHTK5mdcyAqvkzw=; b=yc3yUWdQghpU2D3ox/HnBNcMwp
	qUvEgJ2ECArcCo6Bn40Px1Z19Sw0F/FyCWa5nlfVU08+jFtIo137CS/tcBWxXzZVtyZYGkhpLPudU
	YfD5cFhn/RYa2IU+MOSirtqgsW3U+t82l8EA0gM8qpsuT8E9qvMvXGUHKwOjn5CyMNJE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] eclair: remove wrongly added -eval_file
Message-Id: <E1rZm0o-0007IR-En@xenbits.xenproject.org>
Date: Tue, 13 Feb 2024 06:11:22 +0000

commit 772380f7547bac7e4c10c9ceff87af3f54151ae5
Author:     Simone Ballarin <simone.ballarin@bugseng.com>
AuthorDate: Mon Feb 12 09:38:22 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 12 09:38:22 2024 +0100

    eclair: remove wrongly added -eval_file
    
    properties.ecl does not exist and it is not
    even generated by propertyparser.py. Loading
    this file causes empty ECLAIR analysis.
    
    Fixes: f4519ee8 ("eclair: move function and macro properties outside ECLAIR")
    Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
 automation/eclair_analysis/ECLAIR/analysis.ecl | 1 -
 1 file changed, 1 deletion(-)

diff --git a/automation/eclair_analysis/ECLAIR/analysis.ecl b/automation/eclair_analysis/ECLAIR/analysis.ecl
index 684c5b0b39..a604582da3 100644
--- a/automation/eclair_analysis/ECLAIR/analysis.ecl
+++ b/automation/eclair_analysis/ECLAIR/analysis.ecl
@@ -30,7 +30,6 @@ if(not(scheduled_analysis),
 -eval_file=deviations.ecl
 -eval_file=call_properties.ecl
 -eval_file=tagging.ecl
--eval_file=properties.ecl
 -eval_file=concat(set,".ecl")
 
 -doc="Hide reports in external code."
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:22:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:22:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680235.1058187 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAWp-0007TV-RB; Wed, 14 Feb 2024 08:22:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680235.1058187; Wed, 14 Feb 2024 08:22:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAWp-0007TN-Oa; Wed, 14 Feb 2024 08:22:03 +0000
Received: by outflank-mailman (input) for mailman id 680235;
 Wed, 14 Feb 2024 08:22:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAWo-0007TG-Il
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAWo-0005vg-HX
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAWo-0003I3-Eh
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=7FxMDzzoUaxMqqXixiFNaSiNZ3iJT18TpEWYmpQ8Gvo=; b=iNdrwUuO6SqxYbQaZpL7BapVK6
	qtdCs+dUpirfORwK7Uyp7nM6rCvyrT3YsUOI86x9HxhL6jmfkpEfl5XyO4BPbCMGTK3GIAIlW2eZq
	CvutP7WS2pGAUONunzpfUxLOuHYYl0eGlFaDEhNJPno8g5uOybDIR8iDfa2cA0k06cZY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/p2m: make p2m_get_page_from_gfn() handle grant case correctly
Message-Id: <E1raAWo-0003I3-Eh@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:22:02 +0000

commit cbbca7be4aaadbe0a65cd6a7d6a1f7c412d339f4
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 13 09:27:47 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:27:47 2024 +0100

    x86/p2m: make p2m_get_page_from_gfn() handle grant case correctly
    
    The 'fast' path of p2m_get_page_from_gfn handles three cases: normal ram,
    foreign p2m entries, and grant map entries.  For normal ram and grant table
    entries, get_page() is called, but for foreign entries,
    page_get_owner_and_reference() is called, since the current domain is
    expected not to be the owner.
    
    Unfortunately, grant maps are *also* generally expected to be owned by
    foreign domains; so this function will fail for any p2m entry containing a
    grant map that doesn't happen to be local.
    
    Have grant maps take the same path as foreign entries.  Since grants may
    actually be either foreign or local, adjust the assertion to allow for this.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: George Dunlap <george.dunlap@cloud.com>
    Reviewed-by: George Dunlap <george.dunlap@cloud.com>
---
 xen/arch/x86/mm/p2m.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 6eb446e437..d118d27ab9 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -346,11 +346,11 @@ struct page_info *p2m_get_page_from_gfn(
              && !((q & P2M_UNSHARE) && p2m_is_shared(*t)) )
         {
             page = mfn_to_page(mfn);
-            if ( unlikely(p2m_is_foreign(*t)) )
+            if ( unlikely(p2m_is_foreign(*t)) || unlikely(p2m_is_grant(*t)) )
             {
                 struct domain *fdom = page_get_owner_and_reference(page);
 
-                ASSERT(fdom != p2m->domain);
+                ASSERT(!p2m_is_foreign(*t) || fdom != p2m->domain);
                 if ( fdom == NULL )
                     page = NULL;
             }
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:22:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:22:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680236.1058191 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAWz-0007VQ-SV; Wed, 14 Feb 2024 08:22:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680236.1058191; Wed, 14 Feb 2024 08:22:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAWz-0007VI-Q1; Wed, 14 Feb 2024 08:22:13 +0000
Received: by outflank-mailman (input) for mailman id 680236;
 Wed, 14 Feb 2024 08:22:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAWy-0007V6-NH
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAWy-0005vm-MR
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAWy-0003JO-K7
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=d7BJ1GLMJZaW1QghtwqtY5rEccZRVSgSkQdJHj9bMwU=; b=t+EWsunRPFOavL3ib7ychrSB2V
	H2qNYaeiDP4S59oZpKhrYHljlWBxcfWFeCgqYJJ7+Jq/pOCSxMPOvKNcTrB8txBu50GIEOs0UkBnh
	D3fG++lyGYmCSMpqinhLsriYyP2IhujRLyJdRDd5aseLRmjoZ2YNhRqS5wKaohe9KEgM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] libxl: Add support for blktap vbd3
Message-Id: <E1raAWy-0003JO-K7@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:22:12 +0000

commit 6d7d8d2b3e3791c2005589bad0d608c9025a4bc4
Author:     Jason Andryuk <jandryuk@gmail.com>
AuthorDate: Tue Feb 13 09:28:58 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:28:58 2024 +0100

    libxl: Add support for blktap vbd3
    
    This patch re-introduces blktap support to libxl.  Unlike earlier
    versions, it does not link against any blktap library.  libxl changes
    are needed to write to the vbd3 backend XenStore nodes.
    
    blktap has three components.  tapdisk is a daemon implementing the disk
    IO, NBD (Network Block Device), and Xen PV interfaces.  tap-ctl is a
    tool to control tapdisks - creating, starting, stopping and freeing.
    tapback manages the XenStore operations and instructs tapdisk to
    connect.
    
    It is notable that tapdisk performs the grant and event channel ops, but
    doesn't interact with XenStore.  tapback performs XenStore operations
    and notifies tapdisks of values and changes.
    
    The flow is: libxl writes to the "vbd3" XenStore nodes and runs the
    block-tap script.  The block-tap script runs tap-ctl to create a tapdisk
    instance as the physical device.  tapback then sees the tapdisk and
    instructs the tapdisk to connect up the PV blkif interface.
    
    This is expected to work without the kernel blktap driver, so the
    block-tap script is modified accordingly to write the UNIX NBD path.
    
    backendtype=tap was not fully removed previously, but it would never
    succeed since it would hit the hardcoded error in disk_try_backend().
    It is reused now.
    
    An example command to attach a vhd:
    xl block-attach vm 'vdev=xvdf,backendtype=tap,format=vhd,target=/srv/target.vhd'
    
    Format raw also works to run an "aio:" tapdisk.
    
    Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 docs/man/xl-disk-configuration.5.pod.in   |  4 +++-
 tools/libs/light/libxl_device.c           | 14 ++++++++++----
 tools/libs/light/libxl_disk.c             | 20 +++++++++++++++-----
 tools/libs/light/libxl_linux.c            |  1 +
 tools/libs/light/libxl_types_internal.idl |  1 +
 tools/libs/light/libxl_utils.c            |  2 ++
 6 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/docs/man/xl-disk-configuration.5.pod.in b/docs/man/xl-disk-configuration.5.pod.in
index bc945cc517..cb442bd5b4 100644
--- a/docs/man/xl-disk-configuration.5.pod.in
+++ b/docs/man/xl-disk-configuration.5.pod.in
@@ -232,7 +232,7 @@ Specifies the backend implementation to use
 
 =item Supported values
 
-phy, qdisk, standalone
+phy, qdisk, standalone, tap
 
 =item Mandatory
 
@@ -254,6 +254,8 @@ and "standalone" does not support specifications other than "virtio".
 Normally this option should not be specified, in which case libxl will
 automatically determine the most suitable backend.
 
+"tap" needs blktap's tapback to be running.
+
 
 =item B<script>=I<SCRIPT>
 
diff --git a/tools/libs/light/libxl_device.c b/tools/libs/light/libxl_device.c
index 13da6e0573..ae2b71b0bf 100644
--- a/tools/libs/light/libxl_device.c
+++ b/tools/libs/light/libxl_device.c
@@ -328,9 +328,15 @@ static int disk_try_backend(disk_try_backend_args *a,
         return 0;
 
     case LIBXL_DISK_BACKEND_TAP:
-        LOG(DEBUG, "Disk vdev=%s, backend tap unsuitable because blktap "
-                   "not available", a->disk->vdev);
-        return 0;
+        if (a->disk->format != LIBXL_DISK_FORMAT_RAW &&
+            a->disk->format != LIBXL_DISK_FORMAT_VHD)
+            goto bad_format;
+
+        if (libxl_defbool_val(a->disk->colo_enable))
+            goto bad_colo;
+
+        LOG(DEBUG, "Disk vdev=%s, returning blktap", a->disk->vdev);
+        return backend;
 
     case LIBXL_DISK_BACKEND_QDISK:
         if (a->disk->script) goto bad_script;
@@ -478,7 +484,7 @@ char *libxl__device_disk_string_of_backend(libxl_disk_backend backend)
 {
     switch (backend) {
         case LIBXL_DISK_BACKEND_QDISK: return "qdisk";
-        case LIBXL_DISK_BACKEND_TAP: return "phy";
+        case LIBXL_DISK_BACKEND_TAP: return "vbd3";
         case LIBXL_DISK_BACKEND_PHY: return "phy";
         case LIBXL_DISK_BACKEND_STANDALONE: return "standalone";
         default: return NULL;
diff --git a/tools/libs/light/libxl_disk.c b/tools/libs/light/libxl_disk.c
index ea3623dd6f..59ff996837 100644
--- a/tools/libs/light/libxl_disk.c
+++ b/tools/libs/light/libxl_disk.c
@@ -56,7 +56,9 @@ static void disk_eject_xswatch_callback(libxl__egc *egc, libxl__ev_xswatch *w,
             "/local/domain/%d/backend/%" TOSTRING(BACKEND_STRING_SIZE)
            "[a-z]/%*d/%*d",
            &disk->backend_domid, backend_type);
-    if (!strcmp(backend_type, "tap") || !strcmp(backend_type, "vbd")) {
+    if (!strcmp(backend_type, "tap") ||
+        !strcmp(backend_type, "vbd") ||
+        !strcmp(backend_type, "vbd3")) {
         disk->backend = LIBXL_DISK_BACKEND_TAP;
     } else if (!strcmp(backend_type, "qdisk")) {
         disk->backend = LIBXL_DISK_BACKEND_QDISK;
@@ -224,7 +226,7 @@ static int libxl__device_from_disk(libxl__gc *gc, uint32_t domid,
             device->backend_kind = LIBXL__DEVICE_KIND_VBD;
             break;
         case LIBXL_DISK_BACKEND_TAP:
-            device->backend_kind = LIBXL__DEVICE_KIND_VBD;
+            device->backend_kind = LIBXL__DEVICE_KIND_VBD3;
             break;
         case LIBXL_DISK_BACKEND_QDISK:
             device->backend_kind = LIBXL__DEVICE_KIND_QDISK;
@@ -368,9 +370,17 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,
                 assert(device->backend_kind == LIBXL__DEVICE_KIND_VIRTIO_DISK);
                 break;
             case LIBXL_DISK_BACKEND_TAP:
-                LOG(ERROR, "blktap is not supported");
-                rc = ERROR_FAIL;
-                goto out;
+                flexarray_append(back, "params");
+                flexarray_append(back, GCSPRINTF("%s:%s",
+                              libxl__device_disk_string_of_format(disk->format),
+                              disk->pdev_path ? : ""));
+
+                script = libxl__abs_path(gc, disk->script?: "block-tap",
+                                         libxl__xen_script_dir_path());
+                flexarray_append_pair(back, "script", script);
+
+                assert(device->backend_kind == LIBXL__DEVICE_KIND_VBD3);
+                break;
             case LIBXL_DISK_BACKEND_QDISK:
                 flexarray_append(back, "params");
                 flexarray_append(back, GCSPRINTF("%s:%s",
diff --git a/tools/libs/light/libxl_linux.c b/tools/libs/light/libxl_linux.c
index f7c92ba562..0b4c8bd045 100644
--- a/tools/libs/light/libxl_linux.c
+++ b/tools/libs/light/libxl_linux.c
@@ -207,6 +207,7 @@ int libxl__get_hotplug_script_info(libxl__gc *gc, libxl__device *dev,
 
     switch (dev->backend_kind) {
     case LIBXL__DEVICE_KIND_VBD:
+    case LIBXL__DEVICE_KIND_VBD3:
         if (num_exec != 0) {
             LOGD(DEBUG, dev->domid,
                  "num_exec %d, not running hotplug scripts", num_exec);
diff --git a/tools/libs/light/libxl_types_internal.idl b/tools/libs/light/libxl_types_internal.idl
index e24288f1a5..56dccac153 100644
--- a/tools/libs/light/libxl_types_internal.idl
+++ b/tools/libs/light/libxl_types_internal.idl
@@ -34,6 +34,7 @@ libxl__device_kind = Enumeration("device_kind", [
     (16, "VINPUT"),
     (17, "VIRTIO_DISK"),
     (18, "VIRTIO"),
+    (19, "VBD3"),
     ])
 
 libxl__console_backend = Enumeration("console_backend", [
diff --git a/tools/libs/light/libxl_utils.c b/tools/libs/light/libxl_utils.c
index e403bd9bcf..10398a6c86 100644
--- a/tools/libs/light/libxl_utils.c
+++ b/tools/libs/light/libxl_utils.c
@@ -295,6 +295,8 @@ int libxl_string_to_backend(libxl_ctx *ctx, char *s, libxl_disk_backend *backend
         *backend = LIBXL_DISK_BACKEND_PHY;
     } else if (!strcmp(s, "file")) {
         *backend = LIBXL_DISK_BACKEND_TAP;
+    } else if (!strcmp(s, "vbd3")) {
+        *backend = LIBXL_DISK_BACKEND_TAP;
     } else if (!strcmp(s, "qdisk")) {
         *backend = LIBXL_DISK_BACKEND_QDISK;
     } else if (!strcmp(s, "standalone")) {
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:22:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:22:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680237.1058196 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAX9-0007YI-U0; Wed, 14 Feb 2024 08:22:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680237.1058196; Wed, 14 Feb 2024 08:22:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAX9-0007YB-RV; Wed, 14 Feb 2024 08:22:23 +0000
Received: by outflank-mailman (input) for mailman id 680237;
 Wed, 14 Feb 2024 08:22:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAX8-0007Xq-RG
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAX8-0005w0-QU
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAX8-0003Kd-OZ
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=oU+wCKEzJDoLYUkLodn333swWmyRK1hyi16t4iikNNg=; b=T77LM1xE0IaRBAjAmHoNRUozpp
	+hNpXQaOOaYx8E+b6rJbYm5aUM2p+xoVS8/lB7NOUfGYdigHEFo8ytAIRX8Cp5yaBUnJAmnotrzpT
	6Swf9OKnK1NMLatDDZjp6dF8ClLE0APO22wLwJsADavV4ATqDcFBClY0EDFF0FluLx54=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen: add support in public/hvm/save.h for PPC and RISC-V
Message-Id: <E1raAX8-0003Kd-OZ@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:22:22 +0000

commit 4c13f9c3fc8b501141653ecd1fa3d1ff02e9fe1a
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Mon Feb 5 16:32:10 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:29:31 2024 +0100

    xen: add support in public/hvm/save.h for PPC and RISC-V
    
    No specific header is needed to include in public/hvm/save.h for
    PPC and RISC-V for now.
    
    Code related to PPC was changed based on the comment:
    https://lore.kernel.org/xen-devel/c2f3280e-2208-496b-a0b5-fda1a2076b3a@raptorengineering.com/
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/include/public/hvm/save.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/include/public/hvm/save.h b/xen/include/public/hvm/save.h
index ff0048e5f8..31b5cd163b 100644
--- a/xen/include/public/hvm/save.h
+++ b/xen/include/public/hvm/save.h
@@ -89,8 +89,8 @@ DECLARE_HVM_SAVE_TYPE(END, 0, struct hvm_save_end);
 #include "../arch-x86/hvm/save.h"
 #elif defined(__arm__) || defined(__aarch64__)
 #include "../arch-arm/hvm/save.h"
-#elif defined(__powerpc64__)
-#include "../arch-ppc.h"
+#elif defined(__powerpc64__) || defined(__riscv)
+/* no specific header to include */
 #else
 #error "unsupported architecture"
 #endif
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:22:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:22:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680238.1058200 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAXJ-0007bj-Vp; Wed, 14 Feb 2024 08:22:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680238.1058200; Wed, 14 Feb 2024 08:22:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAXJ-0007bb-T8; Wed, 14 Feb 2024 08:22:33 +0000
Received: by outflank-mailman (input) for mailman id 680238;
 Wed, 14 Feb 2024 08:22:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAXI-0007bN-Ul
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAXI-0005wG-Tb
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAXI-0003L8-Sd
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=g1VuEarOyZsDyCAm9Wjh21zgS8YIdUlxrROulyXhS50=; b=ivGZs+lZJuF389sGg688CGRf5G
	zflDF5jHCWTdf+i3aFAd+zVPThc8D5AiG3odS0hAxVMiBXrYHIwJsPjylVEcsYsOD9b+zVS2PHoc6
	+lkFLL8BTFpR7P5lZMOv9rux6Jt4dcKW1/w9ifEObpUMyeBpyQhyZeUvwKKUX8Z4XCz4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/riscv: introduce cpufeature.h
Message-Id: <E1raAXI-0003L8-Sd@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:22:32 +0000

commit d42ebc95e24deb87b26ce1a49d7e2c2359410fd1
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Mon Feb 5 16:32:11 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:30:02 2024 +0100

    xen/riscv: introduce cpufeature.h
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/riscv/include/asm/cpufeature.h | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/xen/arch/riscv/include/asm/cpufeature.h b/xen/arch/riscv/include/asm/cpufeature.h
new file mode 100644
index 0000000000..c08b7d67ad
--- /dev/null
+++ b/xen/arch/riscv/include/asm/cpufeature.h
@@ -0,0 +1,23 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_RISCV_CPUFEATURE_H
+#define __ASM_RISCV_CPUFEATURE_H
+
+#ifndef __ASSEMBLY__
+
+static inline unsigned int cpu_nr_siblings(unsigned int cpu)
+{
+    return 1;
+}
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* __ASM_RISCV_CPUFEATURE_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:22:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:22:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680239.1058203 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAXU-0007eV-0w; Wed, 14 Feb 2024 08:22:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680239.1058203; Wed, 14 Feb 2024 08:22:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAXT-0007eO-Ue; Wed, 14 Feb 2024 08:22:43 +0000
Received: by outflank-mailman (input) for mailman id 680239;
 Wed, 14 Feb 2024 08:22:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAXT-0007eD-1W
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:43 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAXT-0005wj-0q
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAXS-0003Lf-Vg
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=XNi9TwWk8ON153z9tKiM3ZsfJnoPTAovvbBKiCzMmOE=; b=EOJXAC3A2Bhp5IY1YHVqGjzfWc
	+bgk58c8M86/sNSDmKB9I/NYzf05dGIGDEEzf69u/bLnENKvFf3fhZvoegh2L2sI3s7xlBT7V8Ihk
	9IW1qfrUTZBz+0g4Abofa+LaNxOQxh75fWhJ0xWQ/x/CkZzfElaTOSY9V8/GvAaylUtA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/riscv: introduce guest_atomics.h
Message-Id: <E1raAXS-0003Lf-Vg@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:22:42 +0000

commit 2c162e2f69f79c21f2ea942de84150076d50e5c3
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Mon Feb 5 16:32:12 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:30:13 2024 +0100

    xen/riscv: introduce guest_atomics.h
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/riscv/include/asm/guest_atomics.h | 44 ++++++++++++++++++++++++++++++
 1 file changed, 44 insertions(+)

diff --git a/xen/arch/riscv/include/asm/guest_atomics.h b/xen/arch/riscv/include/asm/guest_atomics.h
new file mode 100644
index 0000000000..de54914454
--- /dev/null
+++ b/xen/arch/riscv/include/asm/guest_atomics.h
@@ -0,0 +1,44 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_RISCV_GUEST_ATOMICS_H
+#define __ASM_RISCV_GUEST_ATOMICS_H
+
+#include <xen/bug.h>
+
+#define guest_testop(name)                                                  \
+static inline int guest_##name(struct domain *d, int nr, volatile void *p)  \
+{                                                                           \
+    BUG_ON("unimplemented");                                                \
+                                                                            \
+    return 0;                                                               \
+}
+
+#define guest_bitop(name)                                                   \
+static inline void guest_##name(struct domain *d, int nr, volatile void *p) \
+{                                                                           \
+    BUG_ON("unimplemented");                                                \
+}
+
+guest_bitop(set_bit)
+guest_bitop(clear_bit)
+guest_bitop(change_bit)
+
+#undef guest_bitop
+
+guest_testop(test_and_set_bit)
+guest_testop(test_and_clear_bit)
+guest_testop(test_and_change_bit)
+
+#undef guest_testop
+
+#define guest_test_bit(d, nr, p) ((void)(d), test_bit(nr, p))
+
+#endif /* __ASM_RISCV_GUEST_ATOMICS_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:22:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:22:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680240.1058207 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAXe-0007hP-2Q; Wed, 14 Feb 2024 08:22:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680240.1058207; Wed, 14 Feb 2024 08:22:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAXd-0007hH-WD; Wed, 14 Feb 2024 08:22:54 +0000
Received: by outflank-mailman (input) for mailman id 680240;
 Wed, 14 Feb 2024 08:22:53 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAXd-0007h3-4O
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:53 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAXd-0005ws-3f
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:53 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAXd-0003MB-2v
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:22:53 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=4lTn8Zvk2yXRg4656TjHB7Y+63DZfnzRlNBDiUEAry8=; b=BH6x9edYATKcF14A1wxQn+1Rhv
	WFIdICzEslcsFMbkv/MJmkRDRVo4XELxqa3LaWXyIdLQs0OG0iD9ExZEUugDHSF9gNK6+6NWL6wli
	mUT/luUR0wBp41x5tyNuv82e5Js+ONwpIl+IH3rXFv8xq3YYURgqyySHRbzDLQofk5Kg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen: avoid generation of empty asm/iommu.h
Message-Id: <E1raAXd-0003MB-2v@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:22:53 +0000

commit f9f339d33f9efabbd50b9a48537a1d029a997274
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Mon Feb 5 16:32:13 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:30:18 2024 +0100

    xen: avoid generation of empty asm/iommu.h
    
    asm/iommu.h shouldn't need to be included when CONFIG_HAS_PASSTHROUGH
    isn't enabled.
    As <asm/iommu.h> is ifdef-ed by CONFIG_HAS_PASSTHROUGH it should
    be also ifdef-ed field "struct arch_iommu arch" in struct domain_iommu
    as definition of arch_iommu is located in <asm/iommu.h>.
    
    These amount of changes are just enough to avoid generation of empty
    asm/iommu.h for now.
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/include/xen/iommu.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
index a21f25df9f..7aa6a77209 100644
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -337,7 +337,9 @@ extern int iommu_add_extra_reserved_device_memory(unsigned long start,
 extern int iommu_get_extra_reserved_device_memory(iommu_grdm_t *func,
                                                   void *ctxt);
 
+#ifdef CONFIG_HAS_PASSTHROUGH
 #include <asm/iommu.h>
+#endif
 
 #ifndef iommu_call
 # define iommu_call(ops, fn, args...) ((ops)->fn(args))
@@ -345,7 +347,9 @@ extern int iommu_get_extra_reserved_device_memory(iommu_grdm_t *func,
 #endif
 
 struct domain_iommu {
+#ifdef CONFIG_HAS_PASSTHROUGH
     struct arch_iommu arch;
+#endif
 
     /* iommu_ops */
     const struct iommu_ops *platform_ops;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:23:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:23:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680241.1058212 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAXo-0007kI-4H; Wed, 14 Feb 2024 08:23:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680241.1058212; Wed, 14 Feb 2024 08:23:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAXo-0007kA-1H; Wed, 14 Feb 2024 08:23:04 +0000
Received: by outflank-mailman (input) for mailman id 680241;
 Wed, 14 Feb 2024 08:23:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAXn-0007k2-7R
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAXn-0005xF-6g
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAXn-0003Mn-5p
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=a5lncyuRggc+AyOBbwFHuicpE0sY/z4aVpEwdj5OmC8=; b=V21dcT95jNI2saL2m2prY30xk6
	EEPEusPAP4Ccjdum3utseekpM2EITRYnA/rTWYeBRX4+QhGRCUmL0GgRvmRfnkSSpxJTiaWZ5QuEx
	0BuSM81l4IeXhXIUrhLxSqGAZjiQpFVJXp7MGg8SOYDw05cVhMteNF8wfeFYLqmXHiP4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/riscv: introduce setup.h
Message-Id: <E1raAXn-0003Mn-5p@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:23:03 +0000

commit 392c0c871dbd3a25c39e182ef0a27bcf59a4e705
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Mon Feb 5 16:32:15 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:30:35 2024 +0100

    xen/riscv: introduce setup.h
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/riscv/include/asm/setup.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/xen/arch/riscv/include/asm/setup.h b/xen/arch/riscv/include/asm/setup.h
new file mode 100644
index 0000000000..7613a5dbd0
--- /dev/null
+++ b/xen/arch/riscv/include/asm/setup.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef __ASM_RISCV_SETUP_H__
+#define __ASM_RISCV_SETUP_H__
+
+#define max_init_domid (0)
+
+#endif /* __ASM_RISCV_SETUP_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:23:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:23:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680242.1058216 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAXy-0007nU-6g; Wed, 14 Feb 2024 08:23:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680242.1058216; Wed, 14 Feb 2024 08:23:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAXy-0007nM-3s; Wed, 14 Feb 2024 08:23:14 +0000
Received: by outflank-mailman (input) for mailman id 680242;
 Wed, 14 Feb 2024 08:23:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAXx-0007nG-Ak
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAXx-0005xP-A4
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAXx-0003Nd-8t
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=MfsPdgGH8ZAK9swyZQVf5Mm5S8konKeqB/bCw3BLqn0=; b=l/PFLeC+iQ7RzaD2qMdM5wTi/V
	LVGeYohKnzEYEuZ8ixJPUTx6B3RMTFeCghnr8mhXDTE/hsL5sjinwZgXf4QTfiSFRRmkKckbay+kF
	XBv7pYgWP+NRsa535ggoKRfUmufFykkT8vQbMhusy2Q4uVmZieG72s4BvH3nyUpvXjuo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/riscv: introduce flushtlb.h
Message-Id: <E1raAXx-0003Nd-8t@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:23:13 +0000

commit 05ff18b4f0fd3586a305971d46b243da92d63569
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Mon Feb 5 16:32:17 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:30:42 2024 +0100

    xen/riscv: introduce flushtlb.h
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/riscv/include/asm/flushtlb.h | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/xen/arch/riscv/include/asm/flushtlb.h b/xen/arch/riscv/include/asm/flushtlb.h
new file mode 100644
index 0000000000..7ce32bea0b
--- /dev/null
+++ b/xen/arch/riscv/include/asm/flushtlb.h
@@ -0,0 +1,34 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_RISCV_FLUSHTLB_H__
+#define __ASM_RISCV_FLUSHTLB_H__
+
+#include <xen/bug.h>
+#include <xen/cpumask.h>
+
+/*
+ * Filter the given set of CPUs, removing those that definitely flushed their
+ * TLB since @page_timestamp.
+ */
+/* XXX lazy implementation just doesn't clear anything.... */
+static inline void tlbflush_filter(cpumask_t *mask, uint32_t page_timestamp) {}
+
+#define tlbflush_current_time() (0)
+
+static inline void page_set_tlbflush_timestamp(struct page_info *page)
+{
+    BUG_ON("unimplemented");
+}
+
+/* Flush specified CPUs' TLBs */
+void arch_flush_tlb_mask(const cpumask_t *mask);
+
+#endif /* __ASM_RISCV_FLUSHTLB_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:23:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:23:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680243.1058220 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAY9-0007rv-7v; Wed, 14 Feb 2024 08:23:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680243.1058220; Wed, 14 Feb 2024 08:23:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAY9-0007ro-5O; Wed, 14 Feb 2024 08:23:25 +0000
Received: by outflank-mailman (input) for mailman id 680243;
 Wed, 14 Feb 2024 08:23:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAY7-0007rb-EH
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAY7-0005xX-Da
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAY7-0003OW-CC
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=r/wL8/9RstxkZfx3+10Ed7GldWVhhU/XM9BmOO3LgaY=; b=Q71YdGpZUw79j59JjpzpaBlxbG
	mwzBM+6XDuzOMkGv7JnjH/0UrK/PQEzKxyWOmNsO8TsvBkpAKAG6qqjoUAyJtVnkYwECAkIbIkhlR
	H71CGx/rQZ1kkuNeZWGdQX2XaPzZ7yL3lMXuFEDb4LI7JhMAXKom46Wbg+AUzYyGg1vo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/riscv: introduce smp.h
Message-Id: <E1raAY7-0003OW-CC@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:23:23 +0000

commit ebb64781dd3333b2fa1ab6e3dabf829a64891230
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Mon Feb 5 16:32:18 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:30:48 2024 +0100

    xen/riscv: introduce smp.h
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/riscv/include/asm/smp.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/xen/arch/riscv/include/asm/smp.h b/xen/arch/riscv/include/asm/smp.h
new file mode 100644
index 0000000000..b1ea91b1eb
--- /dev/null
+++ b/xen/arch/riscv/include/asm/smp.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_RISCV_SMP_H
+#define __ASM_RISCV_SMP_H
+
+#include <xen/cpumask.h>
+#include <xen/percpu.h>
+
+DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_mask);
+DECLARE_PER_CPU(cpumask_var_t, cpu_core_mask);
+
+/*
+ * Do we, for platform reasons, need to actually keep CPUs online when we
+ * would otherwise prefer them to be off?
+ */
+#define park_offline_cpus false
+
+#endif
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:23:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:23:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680244.1058224 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAYJ-0007vV-9d; Wed, 14 Feb 2024 08:23:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680244.1058224; Wed, 14 Feb 2024 08:23:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAYJ-0007vM-6z; Wed, 14 Feb 2024 08:23:35 +0000
Received: by outflank-mailman (input) for mailman id 680244;
 Wed, 14 Feb 2024 08:23:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAYH-0007uw-HE
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAYH-0005xi-GW
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAYH-0003Oy-Fl
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Tx5mvZrFX829oVuy9ww0utp5MtEO6LnMyGXJVwY6508=; b=T85yANsnpWPRn2cREndj5wH50t
	GfHDzOV8IN8F/axjyhfHMY1LJZu1GykU84CEW4lwZKthOT0LJaFJpIJDpgjHFnuoXM13OtMRRxdOr
	TkpljKJvB9WiSuK8bTomjCtPc/C78wPvbMKe9SS/XAp1T0kTspkksDITkEjcprQBF/pI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/riscv: introduce irq.h
Message-Id: <E1raAYH-0003Oy-Fl@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:23:33 +0000

commit 6cb8ced1e8b87d8e1f3474f60c5c076bea19414f
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Mon Feb 5 16:32:22 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:31:04 2024 +0100

    xen/riscv: introduce irq.h
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/riscv/include/asm/irq.h | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/xen/arch/riscv/include/asm/irq.h b/xen/arch/riscv/include/asm/irq.h
new file mode 100644
index 0000000000..0dfd4d6e8a
--- /dev/null
+++ b/xen/arch/riscv/include/asm/irq.h
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_RISCV_IRQ_H__
+#define __ASM_RISCV_IRQ_H__
+
+#include <xen/bug.h>
+
+/* TODO */
+#define nr_irqs 0U
+#define nr_static_irqs 0
+#define arch_hwdom_irqs(domid) 0U
+
+#define domain_pirq_to_irq(d, pirq) (pirq)
+
+#define arch_evtchn_bind_pirq(d, pirq) ((void)((d) + (pirq)))
+
+struct arch_pirq {
+};
+
+struct arch_irq_desc {
+    unsigned int type;
+};
+
+static inline void arch_move_irqs(struct vcpu *v)
+{
+    BUG_ON("unimplemented");
+}
+
+#endif /* __ASM_RISCV_IRQ_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:23:45 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:23:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680246.1058229 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAYT-0007yf-Be; Wed, 14 Feb 2024 08:23:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680246.1058229; Wed, 14 Feb 2024 08:23:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAYT-0007yX-8N; Wed, 14 Feb 2024 08:23:45 +0000
Received: by outflank-mailman (input) for mailman id 680246;
 Wed, 14 Feb 2024 08:23:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAYR-0007yI-KD
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:43 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAYR-0005y8-JY
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAYR-0003QC-Ih
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=tEK0W61qpgl3mFiLHJNoyL3rO53O8qAeO/gH98xHFWw=; b=T9QROamU9pePDmbdXnHz0jyEAo
	2IASxTvPg+2Phkoo/5YXKBLFhNmpmPMY5lbzhbWn4REnY97gSDnFsbOZfM3adrR7nlxosUoohkue8
	UrR933eJS4HMBkPIIuqz8gSekVptZ8Ou3O1qGzego8SbX1E8m8MSD3/NZ3/UkQMyJ0N8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/riscv: introduce p2m.h
Message-Id: <E1raAYR-0003QC-Ih@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:23:43 +0000

commit 4988704e00d88ce8b69a9cceafed8a6c1f10742d
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Mon Feb 5 16:32:23 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:31:10 2024 +0100

    xen/riscv: introduce p2m.h
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/riscv/include/asm/p2m.h | 102 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 102 insertions(+)

diff --git a/xen/arch/riscv/include/asm/p2m.h b/xen/arch/riscv/include/asm/p2m.h
new file mode 100644
index 0000000000..87b13f8979
--- /dev/null
+++ b/xen/arch/riscv/include/asm/p2m.h
@@ -0,0 +1,102 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_RISCV_P2M_H__
+#define __ASM_RISCV_P2M_H__
+
+#include <asm/page-bits.h>
+
+#define paddr_bits PADDR_BITS
+
+/*
+ * List of possible type for each page in the p2m entry.
+ * The number of available bit per page in the pte for this purpose is 2 bits.
+ * So it's possible to only have 4 fields. If we run out of value in the
+ * future, it's possible to use higher value for pseudo-type and don't store
+ * them in the p2m entry.
+ */
+typedef enum {
+    p2m_invalid = 0,    /* Nothing mapped here */
+    p2m_ram_rw,         /* Normal read/write domain RAM */
+} p2m_type_t;
+
+#include <xen/p2m-common.h>
+
+static inline int get_page_and_type(struct page_info *page,
+                                    struct domain *domain,
+                                    unsigned long type)
+{
+    BUG_ON("unimplemented");
+    return -EINVAL;
+}
+
+/* Look up a GFN and take a reference count on the backing page. */
+typedef unsigned int p2m_query_t;
+#define P2M_ALLOC    (1u<<0)   /* Populate PoD and paged-out entries */
+#define P2M_UNSHARE  (1u<<1)   /* Break CoW sharing */
+
+static inline struct page_info *get_page_from_gfn(
+    struct domain *d, unsigned long gfn, p2m_type_t *t, p2m_query_t q)
+{
+    BUG_ON("unimplemented");
+    return NULL;
+}
+
+static inline void memory_type_changed(struct domain *d)
+{
+    BUG_ON("unimplemented");
+}
+
+
+static inline int guest_physmap_mark_populate_on_demand(struct domain *d,
+                                                        unsigned long gfn,
+                                                        unsigned int order)
+{
+    return -EOPNOTSUPP;
+}
+
+static inline int guest_physmap_add_entry(struct domain *d,
+                                          gfn_t gfn, mfn_t mfn,
+                                          unsigned long page_order,
+                                          p2m_type_t t)
+{
+    BUG_ON("unimplemented");
+    return -EINVAL;
+}
+
+/* Untyped version for RAM only, for compatibility */
+static inline int __must_check
+guest_physmap_add_page(struct domain *d, gfn_t gfn, mfn_t mfn,
+                       unsigned int page_order)
+{
+    return guest_physmap_add_entry(d, gfn, mfn, page_order, p2m_ram_rw);
+}
+
+static inline mfn_t gfn_to_mfn(struct domain *d, gfn_t gfn)
+{
+    BUG_ON("unimplemented");
+    return INVALID_MFN;
+}
+
+static inline bool arch_acquire_resource_check(struct domain *d)
+{
+    /*
+     * The reference counting of foreign entries in set_foreign_p2m_entry()
+     * is supported on RISCV.
+     */
+    return true;
+}
+
+static inline void p2m_altp2m_check(struct vcpu *v, uint16_t idx)
+{
+    /* Not supported on RISCV. */
+}
+
+#endif /* __ASM_RISCV_P2M_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:23:55 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:23:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680247.1058232 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAYd-00081o-Cr; Wed, 14 Feb 2024 08:23:55 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680247.1058232; Wed, 14 Feb 2024 08:23:55 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAYd-00081h-9o; Wed, 14 Feb 2024 08:23:55 +0000
Received: by outflank-mailman (input) for mailman id 680247;
 Wed, 14 Feb 2024 08:23:53 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAYb-00081U-NL
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:53 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAYb-0005yH-Mb
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:53 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAYb-0003RB-Ll
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:23:53 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ObYCrKTOVB/+kUSLNTndQA3sZd6Sr/R1oL64HiKKBDE=; b=nyTXv5AOekTpgRGjivXuka8Cs6
	+A+s6JKTOTVt7i+uhkeuPKxwGw5qJLc1VBkDO1rvJu3J0v12vZ1ZQ82y35zCpTA3k5+uh85hpJ77C
	jBWgG26sBrGwaxUBlcKbEuzj/sJULjy22Mt9kds3cHb0eXSveuk9PHgo4OKn5YMRE5mI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/riscv: introduce regs.h
Message-Id: <E1raAYb-0003RB-Ll@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:23:53 +0000

commit af46249ad8bd14a9d2ee74a9a73d93b92d912861
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Mon Feb 5 16:32:24 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:31:16 2024 +0100

    xen/riscv: introduce regs.h
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    ------
    Changes in V4:
     - add Acked-by: Jan Beulich <jbeulich@suse.com>
     - s/BUG()/BUG_ON("unimplemented")
---
 xen/arch/riscv/include/asm/regs.h | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/xen/arch/riscv/include/asm/regs.h b/xen/arch/riscv/include/asm/regs.h
new file mode 100644
index 0000000000..c70ea2aa0c
--- /dev/null
+++ b/xen/arch/riscv/include/asm/regs.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ARM_RISCV_REGS_H__
+#define __ARM_RISCV_REGS_H__
+
+#ifndef __ASSEMBLY__
+
+#include <xen/bug.h>
+
+#define hyp_mode(r)     (0)
+
+struct cpu_user_regs;
+
+static inline bool guest_mode(const struct cpu_user_regs *r)
+{
+    BUG_ON("unimplemented");
+}
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* __ARM_RISCV_REGS_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:24:05 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:24:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680249.1058235 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAYn-00084o-E3; Wed, 14 Feb 2024 08:24:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680249.1058235; Wed, 14 Feb 2024 08:24:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAYn-00084h-Bb; Wed, 14 Feb 2024 08:24:05 +0000
Received: by outflank-mailman (input) for mailman id 680249;
 Wed, 14 Feb 2024 08:24:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAYl-00084T-Rs
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAYl-0005yd-Ph
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAYl-0003Sa-Oo
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=L3mgV9m/aVh85PNoRDv0tDi9x4OnocrAXaTsFQwiLHc=; b=46t37DE+oCil0HlDK9xiCt9Mnr
	xPi88oyhL24wF3/HdMlREyszlO1ct4+tJDYzQ6WcouSCdpS/67HVzFl5KpB6bKHXWGs08rQnOfgqs
	HDoK3eMb46mZJZqzUEQLzQJdlbBgeHhpj5NHeTOjWqtFuX3Kg6/mjTLInakS0Xv0D3V0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/riscv: introduce time.h
Message-Id: <E1raAYl-0003Sa-Oo@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:24:03 +0000

commit a541ddadec0ae1b67ee5c2ba91fab325bc31fcbd
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Mon Feb 5 16:32:25 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:31:27 2024 +0100

    xen/riscv: introduce time.h
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/riscv/include/asm/time.h | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/xen/arch/riscv/include/asm/time.h b/xen/arch/riscv/include/asm/time.h
new file mode 100644
index 0000000000..affeb0506a
--- /dev/null
+++ b/xen/arch/riscv/include/asm/time.h
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_RISCV_TIME_H__
+#define __ASM_RISCV_TIME_H__
+
+#include <xen/bug.h>
+#include <asm/csr.h>
+
+struct vcpu;
+
+static inline void force_update_vcpu_system_time(struct vcpu *v)
+{
+    BUG_ON("unimplemented");
+}
+
+typedef unsigned long cycles_t;
+
+static inline cycles_t get_cycles(void)
+{
+    return csr_read(CSR_TIME);
+}
+
+#endif /* __ASM_RISCV_TIME_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:24:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:24:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680250.1058240 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAYx-00087V-Fm; Wed, 14 Feb 2024 08:24:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680250.1058240; Wed, 14 Feb 2024 08:24:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAYx-00087O-D4; Wed, 14 Feb 2024 08:24:15 +0000
Received: by outflank-mailman (input) for mailman id 680250;
 Wed, 14 Feb 2024 08:24:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAYv-00087C-TZ
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAYv-0005ym-Ss
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAYv-0003T4-S2
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=6xTpZiyCutdwkiFCzJcjlVSEOG+PSqITxQk+wL0U59o=; b=K5IHbbvee62eh2rzGVZhRY8YrW
	cnGzhezfPbe0uiPl2nOhKO2tHZhoEE9RAu9swt2do9cr76Ql891bLcZ3GecjizA96f6ui5RELmofg
	yPtZrVls2hTAQQdoP6UCNl0JWxRp46azdDh+yCQoEKommZwy8tYbegTLGfdLop9b1sfY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/riscv: introduce event.h
Message-Id: <E1raAYv-0003T4-S2@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:24:13 +0000

commit 2fb516157f8f9a42a4b1db8d7e1e11ec15a98110
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Mon Feb 5 16:32:26 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:31:33 2024 +0100

    xen/riscv: introduce event.h
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/riscv/include/asm/event.h | 40 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/xen/arch/riscv/include/asm/event.h b/xen/arch/riscv/include/asm/event.h
new file mode 100644
index 0000000000..fbad8543fa
--- /dev/null
+++ b/xen/arch/riscv/include/asm/event.h
@@ -0,0 +1,40 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_RISCV_EVENT_H__
+#define __ASM_RISCV_EVENT_H__
+
+#include <xen/lib.h>
+
+void vcpu_mark_events_pending(struct vcpu *v);
+
+static inline int vcpu_event_delivery_is_enabled(struct vcpu *v)
+{
+    BUG_ON("unimplemented");
+    return 0;
+}
+
+static inline int local_events_need_delivery(void)
+{
+    BUG_ON("unimplemented");
+    return 0;
+}
+
+static inline void local_event_delivery_enable(void)
+{
+    BUG_ON("unimplemented");
+}
+
+/* No arch specific virq definition now. Default to global. */
+static inline bool arch_virq_is_global(unsigned int virq)
+{
+    return true;
+}
+
+#endif /* __ASM_RISCV_EVENT_H__ */
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:24:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:24:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680251.1058244 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAZ7-0008AJ-HH; Wed, 14 Feb 2024 08:24:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680251.1058244; Wed, 14 Feb 2024 08:24:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAZ7-0008AB-Ec; Wed, 14 Feb 2024 08:24:25 +0000
Received: by outflank-mailman (input) for mailman id 680251;
 Wed, 14 Feb 2024 08:24:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAZ6-00089z-0S
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAZ5-0005yw-Vx
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAZ5-0003Tc-VC
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=5x5x0SlNERmJc2OoRdTaYdPRjHxbjd8L3pjObPqqdCE=; b=arIb3vKGq1EdACUVhMdz6/pQPM
	932XtMVe+drT+fxP2UfCxyxUeyoMA9GeJGtViPkfL8GIKg14YV82MJMp7q9jH1CfPlzyLws/MXtke
	uZuyv6XDkSYXFw09Oi/7CEdtMoZUTP5uUoZUrv8R7D2epRtNGnVoGDC7dp1SIMoiHrAs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/HVM: tidy state on hvmemul_map_linear_addr()'s error path
Message-Id: <E1raAZ5-0003Tc-VC@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:24:23 +0000

commit e72f951df407bc3be82faac64d8733a270036ba1
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 13 09:36:14 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:36:14 2024 +0100

    x86/HVM: tidy state on hvmemul_map_linear_addr()'s error path
    
    While in the vast majority of cases failure of the function will not
    be followed by re-invocation with the same emulation context, a few
    very specific insns - involving multiple independent writes, e.g. ENTER
    and PUSHA - exist where this can happen. Since failure of the function
    only signals to the caller that it ought to try an MMIO write instead,
    such failure also cannot be assumed to result in wholesale failure of
    emulation of the current insn. Instead we have to maintain internal
    state such that another invocation of the function with the same
    emulation context remains possible. To achieve that we need to reset MFN
    slots after putting page references on the error path.
    
    Note that all of this affects debugging code only, in causing an
    assertion to trigger (higher up in the function). There's otherwise no
    misbehavior - such a "leftover" slot would simply be overwritten by new
    contents in a release build.
    
    Also extend the related unmap() assertion, to further check for MFN 0.
    
    Fixes: 8cbd4fb0b7ea ("x86/hvm: implement hvmemul_write() using real mappings")
    Reported-by: Manuel Andreas <manuel.andreas@tum.de>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Paul Durrant <paul@xen.org>
---
 xen/arch/x86/hvm/emulate.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 15d9962f3a..ab1bc51683 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -696,7 +696,12 @@ static void *hvmemul_map_linear_addr(
  out:
     /* Drop all held references. */
     while ( mfn-- > hvmemul_ctxt->mfn )
+    {
         put_page(mfn_to_page(*mfn));
+#ifndef NDEBUG /* Clean slot for a subsequent map()'s error checking. */
+        *mfn = _mfn(0);
+#endif
+    }
 
     return err;
 }
@@ -718,7 +723,7 @@ static void hvmemul_unmap_linear_addr(
 
     for ( i = 0; i < nr_frames; i++ )
     {
-        ASSERT(mfn_valid(*mfn));
+        ASSERT(mfn_x(*mfn) && mfn_valid(*mfn));
         paging_mark_dirty(currd, *mfn);
         put_page(mfn_to_page(*mfn));
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:24:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:24:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680252.1058249 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAZH-0008Dw-Kv; Wed, 14 Feb 2024 08:24:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680252.1058249; Wed, 14 Feb 2024 08:24:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAZH-0008Do-HZ; Wed, 14 Feb 2024 08:24:35 +0000
Received: by outflank-mailman (input) for mailman id 680252;
 Wed, 14 Feb 2024 08:24:34 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAZG-0008DU-3J
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAZG-0005z4-2c
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAZG-0003UD-1w
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:34 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=RFGJ+UhlfqHmNVZsj9E2sJpuBDkZ2L1zAfga95jIfOg=; b=GepDqxJSNJrfhLye2TMSThRTsN
	pTi28OqnCYWyq08/k2cDgz5Sdz+TjkgQ+f19Mt8JMk0Uc6AbsZl10vzy85Co04xum4JWbDsXuFh7J
	TF4jNJdNzHpdiX3tYyIc/Bte9kzKJwrI5q5u0Qgdmh3rcjXfEwxkeolYK2jLia6V8lAw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] iommu/x86: introduce a generic IVMD/RMRR range validity helper
Message-Id: <E1raAZG-0003UD-1w@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:24:34 +0000

commit e45801dea17bbbb28f443f73e99c14f22d4f2ea8
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 13 09:36:52 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:36:52 2024 +0100

    iommu/x86: introduce a generic IVMD/RMRR range validity helper
    
    IVMD and RMRR ranges are functionally equivalent, and as so could use the same
    validity checker.
    
    Move the IVMD to x86 common IOMMU code and adjust the function to take a pair
    of [start, end] mfn parameters.
    
    So far only the AMD-Vi side is adjusted to use the newly introduced helper, the
    VT-d side will be adjusted in a further change.
    
    No functional change intended.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/include/asm/iommu.h         |  3 +++
 xen/drivers/passthrough/amd/iommu_acpi.c | 38 +++-----------------------
 xen/drivers/passthrough/x86/iommu.c      | 46 ++++++++++++++++++++++++++++++++
 3 files changed, 52 insertions(+), 35 deletions(-)

diff --git a/xen/arch/x86/include/asm/iommu.h b/xen/arch/x86/include/asm/iommu.h
index 15a848ddc3..2b97cb442e 100644
--- a/xen/arch/x86/include/asm/iommu.h
+++ b/xen/arch/x86/include/asm/iommu.h
@@ -135,6 +135,9 @@ struct page_info *__must_check iommu_alloc_pgtable(struct domain_iommu *hd,
                                                    uint64_t contig_mask);
 void iommu_queue_free_pgtable(struct domain_iommu *hd, struct page_info *pg);
 
+/* Check [start, end] unity map range for correctness. */
+bool iommu_unity_region_ok(const char *prefix, mfn_t start, mfn_t end);
+
 #endif /* !__ARCH_X86_IOMMU_H__ */
 /*
  * Local variables:
diff --git a/xen/drivers/passthrough/amd/iommu_acpi.c b/xen/drivers/passthrough/amd/iommu_acpi.c
index ca70f4f3ae..3f5508eba0 100644
--- a/xen/drivers/passthrough/amd/iommu_acpi.c
+++ b/xen/drivers/passthrough/amd/iommu_acpi.c
@@ -405,41 +405,9 @@ static int __init parse_ivmd_block(const struct acpi_ivrs_memory *ivmd_block)
         return 0;
     }
 
-    if ( !e820_all_mapped(base, limit + PAGE_SIZE, E820_RESERVED) )
-    {
-        paddr_t addr;
-
-        AMD_IOMMU_WARN("IVMD: [%lx,%lx) is not (entirely) in reserved memory\n",
-                       base, limit + PAGE_SIZE);
-
-        for ( addr = base; addr <= limit; addr += PAGE_SIZE )
-        {
-            unsigned int type = page_get_ram_type(maddr_to_mfn(addr));
-
-            if ( type == RAM_TYPE_UNKNOWN )
-            {
-                if ( e820_add_range(addr, addr + PAGE_SIZE,
-                                    E820_RESERVED) )
-                    continue;
-                AMD_IOMMU_ERROR("IVMD: page at %lx couldn't be reserved\n",
-                                addr);
-                return -EIO;
-            }
-
-            /*
-             * Types which aren't RAM are considered good enough.
-             * Note that a page being partially RESERVED, ACPI or UNUSABLE will
-             * force Xen into assuming the whole page as having that type in
-             * practice.
-             */
-            if ( type & (RAM_TYPE_RESERVED | RAM_TYPE_ACPI |
-                         RAM_TYPE_UNUSABLE) )
-                continue;
-
-            AMD_IOMMU_ERROR("IVMD: page at %lx can't be converted\n", addr);
-            return -EIO;
-        }
-    }
+    if ( !iommu_unity_region_ok("IVMD", maddr_to_mfn(base),
+                                maddr_to_mfn(limit)) )
+        return -EIO;
 
     if ( ivmd_block->header.flags & ACPI_IVMD_EXCLUSION_RANGE )
         exclusion = true;
diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c
index c90755ff58..1c8cf3271a 100644
--- a/xen/drivers/passthrough/x86/iommu.c
+++ b/xen/drivers/passthrough/x86/iommu.c
@@ -792,6 +792,52 @@ static int __init cf_check adjust_irq_affinities(void)
 }
 __initcall(adjust_irq_affinities);
 
+bool __init iommu_unity_region_ok(const char *prefix, mfn_t start, mfn_t end)
+{
+    mfn_t addr;
+
+    if ( e820_all_mapped(mfn_to_maddr(start), mfn_to_maddr(end) + PAGE_SIZE,
+                         E820_RESERVED) )
+        return true;
+
+    printk(XENLOG_WARNING
+           "%s: [%#" PRI_mfn " ,%#" PRI_mfn "] is not (entirely) in reserved memory\n",
+           prefix, mfn_x(start), mfn_x(end));
+
+    for ( addr = start; mfn_x(addr) <= mfn_x(end); mfn_add(addr, 1) )
+    {
+        unsigned int type = page_get_ram_type(addr);
+
+        if ( type == RAM_TYPE_UNKNOWN )
+        {
+            if ( e820_add_range(mfn_to_maddr(addr),
+                                mfn_to_maddr(addr) + PAGE_SIZE, E820_RESERVED) )
+                continue;
+            printk(XENLOG_ERR
+                   "%s: page at %#" PRI_mfn " couldn't be reserved\n",
+                   prefix, mfn_x(addr));
+            return false;
+        }
+
+        /*
+         * Types which aren't RAM are considered good enough.
+         * Note that a page being partially RESERVED, ACPI or UNUSABLE will
+         * force Xen into assuming the whole page as having that type in
+         * practice.
+         */
+        if ( type & (RAM_TYPE_RESERVED | RAM_TYPE_ACPI |
+                     RAM_TYPE_UNUSABLE) )
+            continue;
+
+        printk(XENLOG_ERR
+               "%s: page at %#" PRI_mfn " can't be converted\n",
+               prefix, mfn_x(addr));
+        return false;
+    }
+
+    return true;
+}
+
 /*
  * Local variables:
  * mode: C
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:24:45 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:24:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680253.1058252 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAZR-0008Gq-La; Wed, 14 Feb 2024 08:24:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680253.1058252; Wed, 14 Feb 2024 08:24:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAZR-0008Gj-Iy; Wed, 14 Feb 2024 08:24:45 +0000
Received: by outflank-mailman (input) for mailman id 680253;
 Wed, 14 Feb 2024 08:24:44 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAZQ-0008GP-68
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:44 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAZQ-0005zS-5S
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:44 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAZQ-0003Un-4n
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:44 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=SpxeqCcr3iIIKyC5puZ/TzSzz0q5iZzy8pFX27lg4gQ=; b=cUYMmrj3wvKnFhBRGLtdWiK3tg
	qggbQWKzyqGuih63bBrhgCoJgQ0eUT0GOMxSF9dpi3aYzw1PN4+ldhWCMP2+zSVra5tRTJQIyDx5P
	BCKwkd//MpUNMhnbjtgEW+0R77Sb3nvTIOXz/gCibzWnwVDG8wfg68yXNVfwEl2vHyH4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] iommu/vt-d: switch to common RMRR checker
Message-Id: <E1raAZQ-0003Un-4n@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:24:44 +0000

commit a185f88e9858987e05d91eb3e9bda68d4a6b4f1d
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 13 09:37:20 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 13 09:37:20 2024 +0100

    iommu/vt-d: switch to common RMRR checker
    
    Use the newly introduced generic unity map checker.
    
    Also drop the message recommending the usage of iommu_inclusive_mapping: the
    ranges would end up being mapped anyway even if some of the checks above
    failed, regardless of whether iommu_inclusive_mapping is set.  Plus such option
    is not supported for PVH, and it's deprecated.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/drivers/passthrough/vtd/dmar.c | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/xen/drivers/passthrough/vtd/dmar.c b/xen/drivers/passthrough/vtd/dmar.c
index 07772f178f..76aade816c 100644
--- a/xen/drivers/passthrough/vtd/dmar.c
+++ b/xen/drivers/passthrough/vtd/dmar.c
@@ -642,17 +642,9 @@ acpi_parse_one_rmrr(struct acpi_dmar_header *header)
            return -EEXIST;
        }
 
-    /* This check is here simply to detect when RMRR values are
-     * not properly represented in the system memory map and
-     * inform the user
-     */
-    if ( !e820_all_mapped(base_addr, end_addr + 1, E820_RESERVED) &&
-         !e820_all_mapped(base_addr, end_addr + 1, E820_NVS) &&
-         !e820_all_mapped(base_addr, end_addr + 1, E820_ACPI) )
-        printk(XENLOG_WARNING VTDPREFIX
-               " RMRR [%"PRIx64",%"PRIx64"] not in reserved memory;"
-               " need \"iommu_inclusive_mapping=1\"?\n",
-                base_addr, end_addr);
+    if ( !iommu_unity_region_ok("RMRR", maddr_to_mfn(base_addr),
+                                maddr_to_mfn(end_addr)) )
+        return -EIO;
 
     rmrru = xzalloc(struct acpi_rmrr_unit);
     if ( !rmrru )
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 08:24:55 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 08:24:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680254.1058256 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAZb-0008JL-NA; Wed, 14 Feb 2024 08:24:55 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680254.1058256; Wed, 14 Feb 2024 08:24:55 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raAZb-0008JD-KS; Wed, 14 Feb 2024 08:24:55 +0000
Received: by outflank-mailman (input) for mailman id 680254;
 Wed, 14 Feb 2024 08:24:54 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAZa-0008J1-8x
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:54 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAZa-0005zc-8E
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:54 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raAZa-0003VC-7X
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 08:24:54 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=3eUMfDwM5WrJfHKIwa4c26rHM+aK/9sqXSH/je6rCKk=; b=zQwT2NK5ohpEZ3u5dxbEIXlMfY
	78tNnDZf6VKrUmgR2jZHxsM1iCKvJH0IsrAdnX9dxzxIjzv8V5uQI+QL+ABDXNocr3vdGAurbKKRW
	RlmmjkEPsIRncYfFu9g2OLJewGdpf9/s+VZo8iHBqS/20/9/4a3phVfgNqTHoBNxinXg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] docs/misra: add asm-offset.c to exclude-list
Message-Id: <E1raAZa-0003VC-7X@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 08:24:54 +0000

commit b3bea912a737a0db39a89b0da0033c4bfda82f03
Author:     Nicola Vetrini <nicola.vetrini@bugseng.com>
AuthorDate: Thu Feb 8 16:50:09 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Tue Feb 13 10:20:38 2024 +0000

    docs/misra: add asm-offset.c to exclude-list
    
    These files contain several deliberate violations of MISRA C rules such
    as:
      * R20.12 for macros DEFINE and OFFSET, where the second argument
        of OFFSET is a macro and is used as a normal parameter and a
        stringification operand.
      * R2.1 because the file is not linked. That said it was decided to
        deviate the rule itself to address that aspect).
    
    No functional change.
    
    Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 docs/misra/exclude-list.json | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/docs/misra/exclude-list.json b/docs/misra/exclude-list.json
index 7971d0e70f..bfd967f0e4 100644
--- a/docs/misra/exclude-list.json
+++ b/docs/misra/exclude-list.json
@@ -101,6 +101,10 @@
             "rel_path": "arch/x86/efi/check.c",
             "comment": "The resulting code is not included in the final Xen binary, ignore for now"
         },
+        {
+            "rel_path": "arch/*/*/asm-offsets.c",
+            "comment": "The resulting code is not included in the final Xen binary, ignore for now"
+        },
         {
             "rel_path": "common/coverage/*",
             "comment": "Files to support gcov, ignore for now"
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:55:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:55:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680864.1059033 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfC-0003EW-1v; Wed, 14 Feb 2024 14:55:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680864.1059033; Wed, 14 Feb 2024 14:55:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfB-0003EO-Vb; Wed, 14 Feb 2024 14:55:05 +0000
Received: by outflank-mailman (input) for mailman id 680864;
 Wed, 14 Feb 2024 14:55:05 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfA-0003EB-Un
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:05 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfA-0005Wv-Rg
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfA-0007bo-QX
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=+yr7WxT6WhRHg6fESvQtBsxkOkbZodp/2DpUbPmUzvI=; b=lHM1f1DjpkNsKaxzwuxBwBn45o
	Rr8+3BvRsXNR1IfRO3yNjOm++RmBAKkI44uMjab3G/d7uDpJh1aOxj0sAf/5V6SL8cf+REhWf6YnB
	l395GyxEFQje3w9Odv5gnogz7gbUdzmye9fKNZg7xuK8Um/XTQtQhedrg2T6MCKCTrOI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] iommu/x86: fix IVMD/RMRR range checker loop increment
Message-Id: <E1raGfA-0007bo-QX@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:55:04 +0000

*** New tip has no discernable common ancestor with previous history ***
    Previously reported histories end at:
        0751a75e3996cf6efd3925a90b4776660d8df2bc

commit d9bfc2810e1cbe4cd27555bdc48315d36ee91f14
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Wed Feb 14 14:18:06 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Feb 14 14:18:06 2024 +0100

    iommu/x86: fix IVMD/RMRR range checker loop increment
    
    mfn_add() doesn't store the incremented value in the parameter, and instead
    returns it to the caller.  As a result, the loop in iommu_unity_region_ok()
    didn't make progress.  Fix it by storing the incremented value.
    
    Fixes: e45801dea17b ('iommu/x86: introduce a generic IVMD/RMRR range validity helper')
    Coverity-ID: 1592056
    Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:55:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:55:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680867.1059041 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfF-0003Gs-4L; Wed, 14 Feb 2024 14:55:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680867.1059041; Wed, 14 Feb 2024 14:55:09 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfF-0003Gk-1j; Wed, 14 Feb 2024 14:55:09 +0000
Received: by outflank-mailman (input) for mailman id 680867;
 Wed, 14 Feb 2024 14:55:08 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfE-0003Fq-1m
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:08 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfE-0005X9-0x
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:08 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfD-0007zx-W7
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:07 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=BcOinoKQwdo9LURl/bztUNX57hcmsScK5sOtBa/YGcw=; b=RqMcRKUSpwnOjkFYT9fcNd/Y5k
	mJSZuyb+oEfi0Vd15qf+sidsezFfzpqz/wzjbgS2PdFuM4u6rOJTrojGyoARHDOOlHFJbk6UbR80O
	gEYzdRM6Qa+b6BJV4C0zwm8r1m2iP+5ACJkB66Jo+6gy8wMexy6Urdh+IbDpUqpFmbMU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.17] x86/p2m-pt: fix off by one in entry check assert
Message-Id: <E1raGfD-0007zx-W7@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:55:07 +0000

*** New tip has no discernable common ancestor with previous history ***
    Previously reported histories end at:
        0751a75e3996cf6efd3925a90b4776660d8df2bc

commit 091466ba55d1e2e75738f751818ace2e3ed08ccf
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Fri Feb 2 08:04:33 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri Feb 2 08:04:33 2024 +0100

    x86/p2m-pt: fix off by one in entry check assert
    
    The MMIO RO rangeset overlap check is bogus: the rangeset is inclusive so the
    passed end mfn should be the last mfn to be mapped (not last + 1).
    
    Fixes: 6fa1755644d0 ('amd/npt/shadow: replace assert that prevents creating 2M/1G MMIO entries')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: George Dunlap <george.dunlap@cloud.com>
    master commit: 610775d0dd61c1bd2f4720c755986098e6a5bafd
    master date: 2024-01-25 16:09:04 +0100
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:55:11 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:55:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680866.1059036 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfE-0003Fh-3a; Wed, 14 Feb 2024 14:55:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680866.1059036; Wed, 14 Feb 2024 14:55:08 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfE-0003FZ-0d; Wed, 14 Feb 2024 14:55:08 +0000
Received: by outflank-mailman (input) for mailman id 680866;
 Wed, 14 Feb 2024 14:55:06 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfC-0003FS-H5
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:06 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfC-0005X1-GH
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:06 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfC-0007ns-Bk
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:06 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=8zFOZiHf5saxF7+TDkQsSYrHF7DckeRxjwRfq/a5Z7g=; b=DdE3bfLv3veTRAmfHy7h6Bve78
	oTg0JCQ8GHi96QcH7dBHyU54bRiueSU+RPj06I0Ol88UHWM4Lu3/ymIOCM7Q98s5lfk+YscjwCSNR
	ihzukXv+c3Q58RdOhxVievjl65dd9nxbDHElZvI/5B4/yf4gfU9Fu6CiMM7xknJe88ZY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.18] x86/ucode: Fix stability of the raw CPU Policy rescan
Message-Id: <E1raGfC-0007ns-Bk@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:55:06 +0000

*** New tip has no discernable common ancestor with previous history ***
    Previously reported histories end at:
        0751a75e3996cf6efd3925a90b4776660d8df2bc

commit b1fdd7d0e47e0831ac7a99d0417385fc10d3068c
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Thu Feb 1 18:02:24 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 1 18:02:24 2024 +0100

    x86/ucode: Fix stability of the raw CPU Policy rescan
    
    Always run microcode_update_helper() on the BSP, so the the updated Raw CPU
    policy doesn't get non-BSP topology details included.
    
    Have calculate_raw_cpu_policy() clear the instantanious XSTATE sizes.  The
    value XCR0 | MSR_XSS had when we scanned the policy isn't terribly interesting
    to report.
    
    When CPUID Masking is active, it affects CPUID instructions issued by Xen
    too.  Transiently disable masking to get a clean scan.
    
    Fixes: 694d79ed5aac ("x86/ucode: Refresh raw CPU policy after microcode load")
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: cf7fe8b72deaa94157ddf97d4bb391480205e9c2
    master date: 2024-01-25 17:46:57 +0000
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:55:11 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:55:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680868.1059045 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfH-0003Ir-5a; Wed, 14 Feb 2024 14:55:11 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680868.1059045; Wed, 14 Feb 2024 14:55:11 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfH-0003Ik-2s; Wed, 14 Feb 2024 14:55:11 +0000
Received: by outflank-mailman (input) for mailman id 680868;
 Wed, 14 Feb 2024 14:55:09 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfF-0003Hp-KF
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:09 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfF-0005XD-JJ
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:09 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfF-0008C1-Hv
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:09 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=hjU1/S0J/TgWIKcQv2nAZPSL8LB9x+a/PNL9KaCD9HM=; b=Th/yrRBsI+bEgx44zI5XNPccX2
	u9UZgIWrdEsgyzHbno+gQNABqgr5tdc2IiayuPtVbRH6EQEBKYVfIc8rhkeZDiRIaLCM97q2+Z8pQ
	H8wMI+1ojzodpABVl9C0eA6udzN4niJf3LILo+jV4a25FCLm8HTpyoDLZUBapIcNZY+s=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.16] pci: fail device assignment if phantom functions cannot be assigned
Message-Id: <E1raGfF-0008C1-Hv@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:55:09 +0000

*** New tip has no discernable common ancestor with previous history ***
    Previously reported histories end at:
        1bdd7c438b399e2ecce9e3c72bd7c1ae56df60f8

commit e481fc9f32339ebf9ddd171a3995a3e44527d148
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Jan 30 14:42:41 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Jan 30 14:42:41 2024 +0100

    pci: fail device assignment if phantom functions cannot be assigned
    
    The current behavior is that no error is reported if (some) phantom functions
    fail to be assigned during device add or assignment, so the operation succeeds
    even if some phantom functions are not correctly setup.
    
    This can lead to devices possibly being successfully assigned to a domU while
    some of the device phantom functions are still assigned to dom0.  Even when the
    device is assigned domIO before being assigned to a domU phantom functions
    might fail to be assigned to domIO, and also fail to be assigned to the domU,
    leaving them assigned to dom0.
    
    Since the device can generate requests using the IDs of those phantom
    functions, given the scenario above a device in such state would be in control
    of a domU, but still capable of generating transactions that use a context ID
    targeting dom0 owned memory.
    
    Modify device assign in order to attempt to deassign the device if phantom
    functions failed to be assigned.
    
    Note that device addition is not modified in the same way, as in that case the
    device is assigned to a trusted domain, and hence partial assign can lead to
    device malfunction but not a security issue.
    
    This is XSA-449 / CVE-2023-46839
    
    Fixes: 4e9950dc1bd2 ('IOMMU: add phantom function support')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: cb4ecb3cc17b02c2814bc817efd05f3f3ba33d1e
    master date: 2024-01-30 14:28:01 +0100
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.16


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:55:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:55:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680869.1059048 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfI-0003KO-6h; Wed, 14 Feb 2024 14:55:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680869.1059048; Wed, 14 Feb 2024 14:55:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfI-0003KG-4B; Wed, 14 Feb 2024 14:55:12 +0000
Received: by outflank-mailman (input) for mailman id 680869;
 Wed, 14 Feb 2024 14:55:11 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfH-0003J4-5J
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:11 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfH-0005XH-4H
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfH-0008O7-3c
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:11 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=HKd0EcI2x0kxYl/rd7FKluPncCtDUgEZ4vpMHq+1Wo8=; b=rrr2ilVYgekKVTdXZ+Ys1jh5zn
	QteyWEy5r/nG4n9zp+axBKzxf5YvtfWNuDBS3j9vs8Y/S5tAO49iZXqEN30SvNYOTvO3hZvhnnX1f
	HuipoKBKmLhyLvnQQfpSgliNSqPB7vycATpp4eDTPGzr4yUIS7VYCCM8KOmtxeS+ii38=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.15] pci: fail device assignment if phantom functions cannot be assigned
Message-Id: <E1raGfH-0008O7-3c@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:55:11 +0000

*** New tip has no discernable common ancestor with previous history ***
    Previously reported histories end at:
        e818f4f0dabf83a6138cd77d7464495fab7bfc16

commit dfafb3ec959b20307d4c640a48b3b55a2896ac30
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Jan 30 14:44:39 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Jan 30 14:44:39 2024 +0100

    pci: fail device assignment if phantom functions cannot be assigned
    
    The current behavior is that no error is reported if (some) phantom functions
    fail to be assigned during device add or assignment, so the operation succeeds
    even if some phantom functions are not correctly setup.
    
    This can lead to devices possibly being successfully assigned to a domU while
    some of the device phantom functions are still assigned to dom0.  Even when the
    device is assigned domIO before being assigned to a domU phantom functions
    might fail to be assigned to domIO, and also fail to be assigned to the domU,
    leaving them assigned to dom0.
    
    Since the device can generate requests using the IDs of those phantom
    functions, given the scenario above a device in such state would be in control
    of a domU, but still capable of generating transactions that use a context ID
    targeting dom0 owned memory.
    
    Modify device assign in order to attempt to deassign the device if phantom
    functions failed to be assigned.
    
    Note that device addition is not modified in the same way, as in that case the
    device is assigned to a trusted domain, and hence partial assign can lead to
    device malfunction but not a security issue.
    
    This is XSA-449 / CVE-2023-46839
    
    Fixes: 4e9950dc1bd2 ('IOMMU: add phantom function support')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: cb4ecb3cc17b02c2814bc817efd05f3f3ba33d1e
    master date: 2024-01-30 14:28:01 +0100
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.15


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:55:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:55:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680870.1059053 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfK-0003MW-8M; Wed, 14 Feb 2024 14:55:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680870.1059053; Wed, 14 Feb 2024 14:55:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfK-0003MO-5L; Wed, 14 Feb 2024 14:55:14 +0000
Received: by outflank-mailman (input) for mailman id 680870;
 Wed, 14 Feb 2024 14:55:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfI-0003Lh-ER
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfI-0005XM-Bu
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfI-00006n-B1
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=3RP8xCLs/Q3+4KpeqXr3hZjOde45Iq+XgYAz+8sthY4=; b=4hV6+dA/O0gb1SOzCFX3Jy/GHe
	duTyLIZP+qUjTVk34mNHJsNeco67n0tGI9sQ2dlANqV173hBNRoS1CQAPjEOhSWd4LvdJszSPusbE
	1ANVW2RKNr8DFiMpLa+0qc7H2Yc7A2yoMwE261cQNSkrKNN+Jh3anjm24Qg6gOw/tU6U=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/spec-ctrl: Enumeration for IBPB_RET
Message-Id: <E1raGfI-00006n-B1@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:55:12 +0000

commit 013a27047ca63834236bfd38ba4d3a8b9d828781
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Jun 14 16:18:36 2022 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Nov 4 13:23:21 2022 +0000

    x86/spec-ctrl: Enumeration for IBPB_RET
    
    The IBPB_RET bit indicates that the CPU's implementation of MSR_PRED_CMD.IBPB
    does flush the RSB/RAS too.
    
    This is part of XSA-422 / CVE-2022-23824.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 24496558e650535bdbd22cc04731e82276cd1b3f)
---
 tools/libxl/libxl_cpuid.c                   | 1 +
 tools/misc/xen-cpuid.c                      | 1 +
 xen/arch/x86/spec_ctrl.c                    | 5 +++--
 xen/include/public/arch-x86/cpufeatureset.h | 1 +
 4 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c
index 25576b4d99..1b7626f7d4 100644
--- a/tools/libxl/libxl_cpuid.c
+++ b/tools/libxl/libxl_cpuid.c
@@ -281,6 +281,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str)
         {"ssb-no",       0x80000008, NA, CPUID_REG_EBX, 26,  1},
         {"psfd",         0x80000008, NA, CPUID_REG_EBX, 28,  1},
         {"btc-no",       0x80000008, NA, CPUID_REG_EBX, 29,  1},
+        {"ibpb-ret",     0x80000008, NA, CPUID_REG_EBX, 30,  1},
 
         {"nc",           0x80000008, NA, CPUID_REG_ECX,  0,  8},
         {"apicidsize",   0x80000008, NA, CPUID_REG_ECX, 12,  4},
diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
index e5208cfa45..7771da4953 100644
--- a/tools/misc/xen-cpuid.c
+++ b/tools/misc/xen-cpuid.c
@@ -158,6 +158,7 @@ static const char *const str_e8b[32] =
     [24] = "amd-ssbd",         [25] = "virt-ssbd",
     [26] = "ssb-no",
     [28] = "psfd",             [29] = "btc-no",
+    [30] = "ibpb-ret",
 };
 
 static const char *const str_7d0[32] =
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 563519ce0e..679fbac57e 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -419,7 +419,7 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)
      * Hardware read-only information, stating immunity to certain issues, or
      * suggestions of which mitigation to use.
      */
-    printk("  Hardware hints:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+    printk("  Hardware hints:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
            (caps & ARCH_CAPS_RDCL_NO)                        ? " RDCL_NO"        : "",
            (caps & ARCH_CAPS_IBRS_ALL)                       ? " IBRS_ALL"       : "",
            (caps & ARCH_CAPS_RSBA)                           ? " RSBA"           : "",
@@ -435,7 +435,8 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)
            (e8b  & cpufeat_mask(X86_FEATURE_STIBP_ALWAYS))   ? " STIBP_ALWAYS"   : "",
            (e8b  & cpufeat_mask(X86_FEATURE_IBRS_FAST))      ? " IBRS_FAST"      : "",
            (e8b  & cpufeat_mask(X86_FEATURE_IBRS_SAME_MODE)) ? " IBRS_SAME_MODE" : "",
-           (e8b  & cpufeat_mask(X86_FEATURE_BTC_NO))         ? " BTC_NO"         : "");
+           (e8b  & cpufeat_mask(X86_FEATURE_BTC_NO))         ? " BTC_NO"         : "",
+           (e8b  & cpufeat_mask(X86_FEATURE_IBPB_RET))       ? " IBPB_RET"       : "");
 
     /* Hardware features which need driving to mitigate issues. */
     printk("  Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s\n",
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index 746a75200a..e536ab42b3 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -265,6 +265,7 @@ XEN_CPUFEATURE(VIRT_SSBD,     8*32+25) /*   MSR_VIRT_SPEC_CTRL.SSBD */
 XEN_CPUFEATURE(SSB_NO,        8*32+26) /*A  Hardware not vulnerable to SSB */
 XEN_CPUFEATURE(PSFD,          8*32+28) /*S  MSR_SPEC_CTRL.PSFD */
 XEN_CPUFEATURE(BTC_NO,        8*32+29) /*A  Hardware not vulnerable to Branch Type Confusion */
+XEN_CPUFEATURE(IBPB_RET,      8*32+30) /*A  IBPB clears RSB/RAS too. */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:0.edx, word 9 */
 XEN_CPUFEATURE(AVX512_4VNNIW, 9*32+ 2) /*A  AVX512 Neural Network Instructions */
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:55:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:55:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680871.1059057 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfU-0003RT-9H; Wed, 14 Feb 2024 14:55:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680871.1059057; Wed, 14 Feb 2024 14:55:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfU-0003RJ-6o; Wed, 14 Feb 2024 14:55:24 +0000
Received: by outflank-mailman (input) for mailman id 680871;
 Wed, 14 Feb 2024 14:55:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfS-0003Qn-GD
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfS-0005Xj-FQ
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfS-00007I-EV
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=EN8MFxuTKF+29I2QZnSuSYKjEDFB6hF6ROvgU+66Hf8=; b=YL6nKQwpAtSxVBvNjptJKJbsoq
	pfav1omvnypA4zW4BFc371fqsjVbmhwtCXCsu5or7ymHo1vPnqPX20IzAD7jiJSpHWtdizb9zDrK2
	tZ6K2LO+RzLHN9WcBASu7tA2VlNWxv/t8NyfpPF301uLx7iT3i+aalQoIuoPortXNpHc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/spec-ctrl: Mitigate IBPB not flushing the RSB/RAS
Message-Id: <E1raGfS-00007I-EV@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:55:22 +0000

commit 46040a5fe68831530b8ffdea7d264e52ae316c87
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Jun 14 16:18:36 2022 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Nov 4 13:23:22 2022 +0000

    x86/spec-ctrl: Mitigate IBPB not flushing the RSB/RAS
    
    Introduce spec_ctrl_new_guest_context() to encapsulate all logic pertaining to
    using MSR_PRED_CMD for a new guest context, even if it only has one user
    presently.
    
    Introduce X86_BUG_IBPB_NO_RET, and use it extend spec_ctrl_new_guest_context()
    with a manual fixup for hardware which mis-implements IBPB.
    
    This is part of XSA-422 / CVE-2022-23824.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 2b27967fb89d7904a1571a2fb963b1c9cac548db)
---
 xen/arch/x86/asm-macros.c         |  1 +
 xen/arch/x86/domain.c             |  2 +-
 xen/arch/x86/spec_ctrl.c          |  8 ++++++++
 xen/include/asm-x86/cpufeatures.h |  1 +
 xen/include/asm-x86/spec_ctrl.h   | 22 ++++++++++++++++++++++
 5 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/asm-macros.c b/xen/arch/x86/asm-macros.c
index b963d56a56..8c585697b9 100644
--- a/xen/arch/x86/asm-macros.c
+++ b/xen/arch/x86/asm-macros.c
@@ -1 +1,2 @@
 #include <asm/alternative-asm.h>
+#include <asm/spec_ctrl_asm.h>
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 4fb78d38e7..b3774af1a5 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -1832,7 +1832,7 @@ void context_switch(struct vcpu *prev, struct vcpu *next)
              */
             if ( *last_id != next_id )
             {
-                wrmsrl(MSR_PRED_CMD, PRED_CMD_IBPB);
+                spec_ctrl_new_guest_context();
                 *last_id = next_id;
             }
         }
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 679fbac57e..c650e07b06 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -776,6 +776,14 @@ static void __init ibpb_calculations(void)
         return;
     }
 
+    /*
+     * AMD/Hygon CPUs to date (June 2022) don't flush the the RAS.  Future
+     * CPUs are expected to enumerate IBPB_RET when this has been fixed.
+     * Until then, cover the difference with the software sequence.
+     */
+    if ( boot_cpu_has(X86_FEATURE_IBPB) && !boot_cpu_has(X86_FEATURE_IBPB_RET) )
+        setup_force_cpu_cap(X86_BUG_IBPB_NO_RET);
+
     /*
      * IBPB-on-entry mitigations for Branch Type Confusion.
      *
diff --git a/xen/include/asm-x86/cpufeatures.h b/xen/include/asm-x86/cpufeatures.h
index b233e5835f..bdb119a34c 100644
--- a/xen/include/asm-x86/cpufeatures.h
+++ b/xen/include/asm-x86/cpufeatures.h
@@ -48,6 +48,7 @@ XEN_CPUFEATURE(IBPB_ENTRY_HVM,    X86_SYNTH(29)) /* MSR_PRED_CMD used by Xen for
 
 #define X86_BUG_FPU_PTRS          X86_BUG( 0) /* (F)X{SAVE,RSTOR} doesn't save/restore FOP/FIP/FDP. */
 #define X86_BUG_CLFLUSH_MFENCE    X86_BUG( 2) /* MFENCE needed to serialise CLFLUSH */
+#define X86_BUG_IBPB_NO_RET       X86_BUG( 3) /* IBPB doesn't flush the RSB/RAS */
 
 /* Total number of capability words, inc synth and bug words. */
 #define NCAPINTS (FSCAPINTS + X86_NR_SYNTH + X86_NR_BUG) /* N 32-bit words worth of info */
diff --git a/xen/include/asm-x86/spec_ctrl.h b/xen/include/asm-x86/spec_ctrl.h
index 33e845991b..e400ff2273 100644
--- a/xen/include/asm-x86/spec_ctrl.h
+++ b/xen/include/asm-x86/spec_ctrl.h
@@ -65,6 +65,28 @@
 void init_speculation_mitigations(void);
 void spec_ctrl_init_domain(struct domain *d);
 
+/*
+ * Switch to a new guest prediction context.
+ *
+ * This flushes all indirect branch predictors (BTB, RSB/RAS), so guest code
+ * which has previously run on this CPU can't attack subsequent guest code.
+ *
+ * As this flushes the RSB/RAS, it destroys the predictions of the calling
+ * context.  For best performace, arrange for this to be used when we're going
+ * to jump out of the current context, e.g. with reset_stack_and_jump().
+ *
+ * For hardware which mis-implements IBPB, fix up by flushing the RSB/RAS
+ * manually.
+ */
+static always_inline void spec_ctrl_new_guest_context(void)
+{
+    wrmsrl(MSR_PRED_CMD, PRED_CMD_IBPB);
+
+    /* (ab)use alternative_input() to specify clobbers. */
+    alternative_input("", "DO_OVERWRITE_RSB", X86_BUG_IBPB_NO_RET,
+                      : "rax", "rcx");
+}
+
 extern int8_t opt_ibpb_ctxt_switch;
 extern bool opt_ssbd;
 extern int8_t opt_eager_fpu;
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:55:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:55:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680872.1059061 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfe-0003WR-CH; Wed, 14 Feb 2024 14:55:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680872.1059061; Wed, 14 Feb 2024 14:55:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfe-0003WI-9a; Wed, 14 Feb 2024 14:55:34 +0000
Received: by outflank-mailman (input) for mailman id 680872;
 Wed, 14 Feb 2024 14:55:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfc-0003Vo-L1
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfc-0005Xu-KE
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfc-00007u-Hi
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=bQ6nlZQxxAEK4mJn6t8OzrnzKEheXy6dIymtH2hbfnk=; b=J9NELHy4G+igBE3RCUdw6GnHvl
	hr5+Rk9KV5NzJxs3jOXMPRBx/sqU0bbj0wSXXKO/Lu3u4IBy93AL3Fj8j7ICDMek6eNhTWfdQT/XW
	3Q96287sUDOqwxziwXdYMpxTUBohifOu3dAmUDBrUO8uoqchx16eyCQnSnTlbZOseZ7E=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] automation: Remove clang-8 from Debian unstable container
Message-Id: <E1raGfc-00007u-Hi@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:55:32 +0000

commit c267abfaf2d8176371eda037f9b9152458e0656d
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Tue Feb 21 16:55:38 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Feb 22 14:14:35 2023 +0000

    automation: Remove clang-8 from Debian unstable container
    
    First, apt complain that it isn't the right way to add keys anymore,
    but hopefully that's just a warning.
    
    Second, we can't install clang-8:
    The following packages have unmet dependencies:
     clang-8 : Depends: libstdc++-8-dev but it is not installable
               Depends: libgcc-8-dev but it is not installable
               Depends: libobjc-8-dev but it is not installable
               Recommends: llvm-8-dev but it is not going to be installed
               Recommends: libomp-8-dev but it is not going to be installed
     libllvm8 : Depends: libffi7 (>= 3.3~20180313) but it is not installable
    E: Unable to correct problems, you have held broken packages.
    
    clang on Debian unstable is now version 14.0.6.
    
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    (cherry picked from commit a6b1e2b80fe2053b1c9c9843fb086a668513ea36)
---
 automation/build/debian/unstable-llvm-8.list |  3 ---
 automation/build/debian/unstable.dockerfile  | 12 ------------
 automation/gitlab-ci/build.yaml              | 10 ----------
 3 files changed, 25 deletions(-)

diff --git a/automation/build/debian/unstable-llvm-8.list b/automation/build/debian/unstable-llvm-8.list
deleted file mode 100644
index dc119fa0b4..0000000000
--- a/automation/build/debian/unstable-llvm-8.list
+++ /dev/null
@@ -1,3 +0,0 @@
-# Unstable LLVM 8 repos
-deb http://apt.llvm.org/unstable/ llvm-toolchain-8 main
-deb-src http://apt.llvm.org/unstable/ llvm-toolchain-8 main
diff --git a/automation/build/debian/unstable.dockerfile b/automation/build/debian/unstable.dockerfile
index aeb4f3448b..98384db9dd 100644
--- a/automation/build/debian/unstable.dockerfile
+++ b/automation/build/debian/unstable.dockerfile
@@ -50,15 +50,3 @@ RUN apt-get update && \
         apt-get autoremove -y && \
         apt-get clean && \
         rm -rf /var/lib/apt/lists* /tmp/* /var/tmp/*
-
-RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|apt-key add -
-COPY unstable-llvm-8.list /etc/apt/sources.list.d/
-
-RUN apt-get update && \
-    apt-get --quiet --yes install \
-        clang-8 \
-        lld-8 \
-        && \
-        apt-get autoremove -y && \
-        apt-get clean && \
-        rm -rf /var/lib/apt/lists* /tmp/* /var/tmp/*
diff --git a/automation/gitlab-ci/build.yaml b/automation/gitlab-ci/build.yaml
index 1e61d30c85..2ca12226cd 100644
--- a/automation/gitlab-ci/build.yaml
+++ b/automation/gitlab-ci/build.yaml
@@ -286,16 +286,6 @@ debian-unstable-clang-debug:
   variables:
     CONTAINER: debian:unstable
 
-debian-unstable-clang-8:
-  extends: .clang-8-x86-64-build
-  variables:
-    CONTAINER: debian:unstable
-
-debian-unstable-clang-8-debug:
-  extends: .clang-8-x86-64-build-debug
-  variables:
-    CONTAINER: debian:unstable
-
 debian-unstable-gcc:
   extends: .gcc-x86-64-build
   variables:
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:55:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:55:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680873.1059064 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfo-0003Zj-De; Wed, 14 Feb 2024 14:55:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680873.1059064; Wed, 14 Feb 2024 14:55:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfo-0003Zd-B3; Wed, 14 Feb 2024 14:55:44 +0000
Received: by outflank-mailman (input) for mailman id 680873;
 Wed, 14 Feb 2024 14:55:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfm-0003ZD-OV
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfm-0005Yq-Nf
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfm-00008J-Mj
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Jtok78CZx3YoWWGexgm3n1ukk35kU36hjw7lykrU7gM=; b=PazCHnKSrnF5Eh3GiqlEDUahhh
	6NpQL7akYoF9tdGQ1onx44ZRtV44nDW3rK6dHH0iUCMv0magXHZrEbuR8199FFCBdTg+KJngaEFB1
	eMygBqFyfpEpBEonIxgbmr1xGgucT0c3jvtNY7ji/dJrr/34TggtsQ3txNCLLYeqvZjA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/shadow: account for log-dirty mode when pre-allocating
Message-Id: <E1raGfm-00008J-Mj@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:55:42 +0000

commit 254663bec2bcae8b0a658f3db7a4dfb5ab6a0c83
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Mar 21 12:00:14 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Tue Mar 21 12:07:44 2023 +0000

    x86/shadow: account for log-dirty mode when pre-allocating
    
    Pre-allocation is intended to ensure that in the course of constructing
    or updating shadows there won't be any risk of just made shadows or
    shadows being acted upon can disappear under our feet. The amount of
    pages pre-allocated then, however, needs to account for all possible
    subsequent allocations. While the use in sh_page_fault() accounts for
    all shadows which may need making, so far it didn't account for
    allocations coming from log-dirty tracking (which piggybacks onto the
    P2M allocation functions).
    
    Since shadow_prealloc() takes a count of shadows (or other data
    structures) rather than a count of pages, putting the adjustment at the
    call site of this function won't work very well: We simply can't express
    the correct count that way in all cases. Instead take care of this in
    the function itself, by "snooping" for L1 type requests. (While not
    applicable right now, future new request sites of L1 tables would then
    also be covered right away.)
    
    It is relevant to note here that pre-allocations like the one done from
    shadow_alloc_p2m_page() are benign when they fall in the "scope" of an
    earlier pre-alloc which already included that count: The inner call will
    simply find enough pages available then; it'll bail right away.
    
    This is CVE-2022-42332 / XSA-427.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Tim Deegan <tim@xen.org>
    (cherry picked from commit 91767a71061035ae42be93de495cd976f863a41a)
---
 xen/arch/x86/mm/paging.c         |  1 +
 xen/arch/x86/mm/shadow/common.c  | 12 +++++++++++-
 xen/arch/x86/mm/shadow/private.h |  1 +
 xen/include/asm-x86/paging.h     |  4 ++++
 4 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/mm/paging.c b/xen/arch/x86/mm/paging.c
index 7662db1ad4..75573df9ab 100644
--- a/xen/arch/x86/mm/paging.c
+++ b/xen/arch/x86/mm/paging.c
@@ -278,6 +278,7 @@ void paging_mark_pfn_dirty(struct domain *d, pfn_t pfn)
     if ( unlikely(!VALID_M2P(pfn_x(pfn))) )
         return;
 
+    BUILD_BUG_ON(paging_logdirty_levels() != 4);
     i1 = L1_LOGDIRTY_IDX(pfn);
     i2 = L2_LOGDIRTY_IDX(pfn);
     i3 = L3_LOGDIRTY_IDX(pfn);
diff --git a/xen/arch/x86/mm/shadow/common.c b/xen/arch/x86/mm/shadow/common.c
index e803ac7866..96d77fec87 100644
--- a/xen/arch/x86/mm/shadow/common.c
+++ b/xen/arch/x86/mm/shadow/common.c
@@ -1012,7 +1012,17 @@ bool shadow_prealloc(struct domain *d, unsigned int type, unsigned int count)
     if ( unlikely(d->is_dying) )
        return false;
 
-    ret = _shadow_prealloc(d, shadow_size(type) * count);
+    count *= shadow_size(type);
+    /*
+     * Log-dirty handling may result in allocations when populating its
+     * tracking structures.  Tie this to the caller requesting space for L1
+     * shadows.
+     */
+    if ( paging_mode_log_dirty(d) &&
+         ((SHF_L1_ANY | SHF_FL1_ANY) & (1u << type)) )
+        count += paging_logdirty_levels();
+
+    ret = _shadow_prealloc(d, count);
     if ( !ret && (!d->is_shutting_down || d->shutdown_code != SHUTDOWN_crash) )
         /*
          * Failing to allocate memory required for shadow usage can only result in
diff --git a/xen/arch/x86/mm/shadow/private.h b/xen/arch/x86/mm/shadow/private.h
index e2100f0f34..25803b7e07 100644
--- a/xen/arch/x86/mm/shadow/private.h
+++ b/xen/arch/x86/mm/shadow/private.h
@@ -269,6 +269,7 @@ static inline void sh_terminate_list(struct page_list_head *tmp_list)
 #define SHF_64  (SHF_L1_64|SHF_FL1_64|SHF_L2_64|SHF_L2H_64|SHF_L3_64|SHF_L4_64)
 
 #define SHF_L1_ANY  (SHF_L1_32|SHF_L1_PAE|SHF_L1_64)
+#define SHF_FL1_ANY (SHF_FL1_32|SHF_FL1_PAE|SHF_FL1_64)
 
 #if (SHADOW_OPTIMIZATIONS & SHOPT_OUT_OF_SYNC)
 /* Marks a guest L1 page table which is shadowed but not write-protected.
diff --git a/xen/include/asm-x86/paging.h b/xen/include/asm-x86/paging.h
index 2ca6325c5f..2c2709b9d3 100644
--- a/xen/include/asm-x86/paging.h
+++ b/xen/include/asm-x86/paging.h
@@ -190,6 +190,10 @@ int paging_mfn_is_dirty(struct domain *d, mfn_t gmfn);
 #define L4_LOGDIRTY_IDX(pfn) ((pfn_x(pfn) >> (PAGE_SHIFT + 3 + PAGETABLE_ORDER * 2)) & \
                               (LOGDIRTY_NODE_ENTRIES-1))
 
+#define paging_logdirty_levels() \
+    (DIV_ROUND_UP(PADDR_BITS - PAGE_SHIFT - (PAGE_SHIFT + 3), \
+                  PAGE_SHIFT - ilog2(sizeof(mfn_t))) + 1)
+
 /* VRAM dirty tracking support */
 struct sh_dirty_vram {
     unsigned long begin_pfn;
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:55:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:55:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680874.1059068 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfy-0003cT-Ey; Wed, 14 Feb 2024 14:55:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680874.1059068; Wed, 14 Feb 2024 14:55:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGfy-0003cM-CS; Wed, 14 Feb 2024 14:55:54 +0000
Received: by outflank-mailman (input) for mailman id 680874;
 Wed, 14 Feb 2024 14:55:52 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfw-0003cB-RM
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:52 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfw-0005a6-Qj
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGfw-00008p-Px
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:55:52 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Rt07CgIv4UZWEKwGwouII5jZaWnFv0w+mY4gYlR1YV0=; b=btkpat+Z/W6syEYFeZiTa0UsaM
	1NSp1nZekJwGr2LO9UoYSpXH8cn52saqJoyVfKFkypOdW/ExwgDlw0b5NdGaTcahRiidvl1nU8afX
	sWNKuCI0gEk6L5E3WNtRJQmDcAyDShfyGbwMZbcL0voD9jJ7AeVqxNzMvlA/x8h8ToNg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/HVM: bound number of pinned cache attribute regions
Message-Id: <E1raGfw-00008p-Px@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:55:52 +0000

commit 71b344955525caa6f7586b5c9ff2d2b69a64e210
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Mar 21 12:01:01 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Tue Mar 21 12:07:44 2023 +0000

    x86/HVM: bound number of pinned cache attribute regions
    
    This is exposed via DMOP, i.e. to potentially not fully privileged
    device models. With that we may not permit registration of an (almost)
    unbounded amount of such regions.
    
    This is CVE-2022-42333 / part of XSA-428.
    
    Fixes: 642123c5123f ("x86/hvm: provide XEN_DMOP_pin_memory_cacheattr")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    (cherry picked from commit a5e768640f786b681063f4e08af45d0c4e91debf)
---
 xen/arch/x86/hvm/mtrr.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/xen/arch/x86/hvm/mtrr.c b/xen/arch/x86/hvm/mtrr.c
index 2bd64e8025..752524684e 100644
--- a/xen/arch/x86/hvm/mtrr.c
+++ b/xen/arch/x86/hvm/mtrr.c
@@ -596,6 +596,7 @@ int hvm_set_mem_pinned_cacheattr(struct domain *d, uint64_t gfn_start,
                                  uint64_t gfn_end, uint32_t type)
 {
     struct hvm_mem_pinned_cacheattr_range *range;
+    unsigned int nr = 0;
     int rc = 1;
 
     if ( !is_hvm_domain(d) )
@@ -667,11 +668,15 @@ int hvm_set_mem_pinned_cacheattr(struct domain *d, uint64_t gfn_start,
             rc = -EBUSY;
             break;
         }
+        ++nr;
     }
     rcu_read_unlock(&pinned_cacheattr_rcu_lock);
     if ( rc <= 0 )
         return rc;
 
+    if ( nr >= 64 /* The limit is arbitrary. */ )
+        return -ENOSPC;
+
     range = xzalloc(struct hvm_mem_pinned_cacheattr_range);
     if ( range == NULL )
         return -ENOMEM;
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:56:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:56:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680875.1059074 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGg8-0003fE-Ht; Wed, 14 Feb 2024 14:56:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680875.1059074; Wed, 14 Feb 2024 14:56:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGg8-0003f6-E0; Wed, 14 Feb 2024 14:56:04 +0000
Received: by outflank-mailman (input) for mailman id 680875;
 Wed, 14 Feb 2024 14:56:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGg6-0003es-UN
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGg6-0005aQ-Te
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGg6-0000AR-Sy
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=kDm5jXYa7GhiohdKhUCwPhofvAJDJkmQkARifZHIHuo=; b=zsnhiMNR2PaHFWARMtPtXFxFhS
	viaLrvu1SqmeOzj7lCxGLNj77Hgk7Q+RlrRIzvF+dr+l94IgOWuNfRp+Dgb+421OWx2xJeGPdo4RI
	Dt0Nr2r3xFCMQJWPtVK33e1C6JNe8XxhRkms/l6nJyBPkyqvo2WDA8PWw9GM06Evg3RI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/HVM: serialize pinned cache attribute list manipulation
Message-Id: <E1raGg6-0000AR-Sy@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:56:02 +0000

commit 99e9afaeb00b5a00d6fc3e2d2e593f9ed35695d5
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Mar 21 12:01:01 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Tue Mar 21 12:07:44 2023 +0000

    x86/HVM: serialize pinned cache attribute list manipulation
    
    While the RCU variants of list insertion and removal allow lockless list
    traversal (with RCU just read-locked), insertions and removals still
    need serializing amongst themselves. To keep things simple, use the
    domain lock for this purpose.
    
    This is CVE-2022-42334 / part of XSA-428.
    
    Fixes: 642123c5123f ("x86/hvm: provide XEN_DMOP_pin_memory_cacheattr")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
    (cherry picked from commit 829ec245cf66560e3b50d140ccb3168e7fb7c945)
---
 xen/arch/x86/hvm/mtrr.c | 51 ++++++++++++++++++++++++++++++-------------------
 1 file changed, 31 insertions(+), 20 deletions(-)

diff --git a/xen/arch/x86/hvm/mtrr.c b/xen/arch/x86/hvm/mtrr.c
index 752524684e..97ddc2075e 100644
--- a/xen/arch/x86/hvm/mtrr.c
+++ b/xen/arch/x86/hvm/mtrr.c
@@ -595,7 +595,7 @@ static void free_pinned_cacheattr_entry(struct rcu_head *rcu)
 int hvm_set_mem_pinned_cacheattr(struct domain *d, uint64_t gfn_start,
                                  uint64_t gfn_end, uint32_t type)
 {
-    struct hvm_mem_pinned_cacheattr_range *range;
+    struct hvm_mem_pinned_cacheattr_range *range, *newr;
     unsigned int nr = 0;
     int rc = 1;
 
@@ -609,14 +609,15 @@ int hvm_set_mem_pinned_cacheattr(struct domain *d, uint64_t gfn_start,
     {
     case XEN_DOMCTL_DELETE_MEM_CACHEATTR:
         /* Remove the requested range. */
-        rcu_read_lock(&pinned_cacheattr_rcu_lock);
-        list_for_each_entry_rcu ( range,
-                                  &d->arch.hvm.pinned_cacheattr_ranges,
-                                  list )
+        domain_lock(d);
+        list_for_each_entry ( range,
+                              &d->arch.hvm.pinned_cacheattr_ranges,
+                              list )
             if ( range->start == gfn_start && range->end == gfn_end )
             {
-                rcu_read_unlock(&pinned_cacheattr_rcu_lock);
                 list_del_rcu(&range->list);
+                domain_unlock(d);
+
                 type = range->type;
                 call_rcu(&range->rcu, free_pinned_cacheattr_entry);
                 p2m_memory_type_changed(d);
@@ -637,7 +638,7 @@ int hvm_set_mem_pinned_cacheattr(struct domain *d, uint64_t gfn_start,
                 }
                 return 0;
             }
-        rcu_read_unlock(&pinned_cacheattr_rcu_lock);
+        domain_unlock(d);
         return -ENOENT;
 
     case PAT_TYPE_UC_MINUS:
@@ -652,7 +653,10 @@ int hvm_set_mem_pinned_cacheattr(struct domain *d, uint64_t gfn_start,
         return -EINVAL;
     }
 
-    rcu_read_lock(&pinned_cacheattr_rcu_lock);
+    newr = xzalloc(struct hvm_mem_pinned_cacheattr_range);
+
+    domain_lock(d);
+
     list_for_each_entry_rcu ( range,
                               &d->arch.hvm.pinned_cacheattr_ranges,
                               list )
@@ -670,27 +674,34 @@ int hvm_set_mem_pinned_cacheattr(struct domain *d, uint64_t gfn_start,
         }
         ++nr;
     }
-    rcu_read_unlock(&pinned_cacheattr_rcu_lock);
+
     if ( rc <= 0 )
-        return rc;
+        /* nothing */;
+    else if ( nr >= 64 /* The limit is arbitrary. */ )
+        rc = -ENOSPC;
+    else if ( !newr )
+        rc = -ENOMEM;
+    else
+    {
+        newr->start = gfn_start;
+        newr->end = gfn_end;
+        newr->type = type;
 
-    if ( nr >= 64 /* The limit is arbitrary. */ )
-        return -ENOSPC;
+        list_add_rcu(&newr->list, &d->arch.hvm.pinned_cacheattr_ranges);
 
-    range = xzalloc(struct hvm_mem_pinned_cacheattr_range);
-    if ( range == NULL )
-        return -ENOMEM;
+        newr = NULL;
+        rc = 0;
+    }
+
+    domain_unlock(d);
 
-    range->start = gfn_start;
-    range->end = gfn_end;
-    range->type = type;
+    xfree(newr);
 
-    list_add_rcu(&range->list, &d->arch.hvm.pinned_cacheattr_ranges);
     p2m_memory_type_changed(d);
     if ( type != PAT_TYPE_WRBACK )
         flush_all(FLUSH_CACHE);
 
-    return 0;
+    return rc;
 }
 
 static int hvm_save_mtrr_msr(struct vcpu *v, hvm_domain_context_t *h)
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:56:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:56:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680876.1059077 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGgI-0003i7-IM; Wed, 14 Feb 2024 14:56:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680876.1059077; Wed, 14 Feb 2024 14:56:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGgI-0003hz-FZ; Wed, 14 Feb 2024 14:56:14 +0000
Received: by outflank-mailman (input) for mailman id 680876;
 Wed, 14 Feb 2024 14:56:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGgH-0003hl-1C
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGgH-0005af-0Q
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGgG-0000B1-Vx
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=KY+cO0pJ9f1wIofU34MfNxWVyVKufIpdnm3i7BEutTc=; b=McydSJfMY+IBxc7SykuLAVaQgg
	T41GtGJyf58KadlzcGSfVs7PPCt7NO2je0aV1reUTJkc86dPCx2s/UoWWY4mVteaEuc6bsWuikOyk
	m5uD2NAG2Ap2EqhSev5ueyThVaZiXO04Ny+7JqsTgeE+jwriXvM6iXBs12Cs5LFxfucs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/spec-ctrl: Defer CR4_PV32_RESTORE on the cstar_enter path
Message-Id: <E1raGgG-0000B1-Vx@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:56:12 +0000

commit e49571868d67944b9f4a546ade130e0b6e506b65
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Feb 10 21:11:14 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Tue Mar 21 12:07:44 2023 +0000

    x86/spec-ctrl: Defer CR4_PV32_RESTORE on the cstar_enter path
    
    As stated (correctly) by the comment next to SPEC_CTRL_ENTRY_FROM_PV, between
    the two hunks visible in the patch, RET's are not safe prior to this point.
    
    CR4_PV32_RESTORE hides a CALL/RET pair in certain configurations (PV32
    compiled in, SMEP or SMAP active), and the RET can be attacked with one of
    several known speculative issues.
    
    Furthermore, CR4_PV32_RESTORE also hides a reference to the cr4_pv32_mask
    global variable, which is not safe when XPTI is active before restoring Xen's
    full pagetables.
    
    This crash has gone unnoticed because it is only AMD CPUs which permit the
    SYSCALL instruction in compatibility mode, and these are not vulnerable to
    Meltdown so don't activate XPTI by default.
    
    This is XSA-429 / CVE-2022-42331
    
    Fixes: 5e7962901131 ("x86/entry: Organise the use of MSR_SPEC_CTRL at each entry/exit point")
    Fixes: 5784de3e2067 ("x86: Meltdown band-aid against malicious 64-bit PV guests")
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit df5b055b12116d9e63ced59ae5389e69a2a3de48)
---
 xen/arch/x86/x86_64/compat/entry.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compat/entry.S
index 302530e65e..84a8c97b77 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -202,7 +202,6 @@ ENTRY(cstar_enter)
         ALTERNATIVE "", "setssbsy", X86_FEATURE_XEN_SHSTK
 #endif
         push  %rax          /* Guest %rsp */
-        CR4_PV32_RESTORE
         movq  8(%rsp), %rax /* Restore guest %rax. */
         movq  $FLAT_USER_SS32, 8(%rsp) /* Assume a 64bit domain.  Compat handled lower. */
         pushq %r11
@@ -226,6 +225,8 @@ ENTRY(cstar_enter)
 .Lcstar_cr3_okay:
         sti
 
+        CR4_PV32_RESTORE
+
         movq  STACK_CPUINFO_FIELD(current_vcpu)(%rbx), %rbx
         movq  VCPU_domain(%rbx),%rcx
         cmpb  $0,DOMAIN_is_32bit_pv(%rcx)
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:56:28 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:56:28 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680877.1059081 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGgS-0003kk-Jv; Wed, 14 Feb 2024 14:56:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680877.1059081; Wed, 14 Feb 2024 14:56:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGgS-0003kd-Gx; Wed, 14 Feb 2024 14:56:24 +0000
Received: by outflank-mailman (input) for mailman id 680877;
 Wed, 14 Feb 2024 14:56:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGgR-0003kQ-4b
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGgR-0005am-3p
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGgR-0000Bg-33
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=67weRNXKYnhWaeg0EiJ/vnZtnN3pqlsm3VExVD3zvL0=; b=j9wapP3Z+I/P0blS58edikTnp3
	yOVV4qG50KdND1vdbhefMfA4wT/LWBcOf7FOfex/H/C1QWTKcRg/ppDc83gc0i2H5UM54V/Wr5oM/
	v/gtcu9ua+Cic9yxtRXO+QJpdvnvT6U2Acu61PKoDlHMyQ+n5Li7Z3/lrMwu4oPUpnHI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] tools: Drop gettext as a build dependency
Message-Id: <E1raGgR-0000Bg-33@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:56:23 +0000

commit b5e3e6294ffaffef0e371315e3b4bdf4b0c4f181
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Mar 26 11:25:07 2021 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Apr 12 09:00:36 2023 +0100

    tools: Drop gettext as a build dependency
    
    It has not been a dependency since at least 4.13.  Remove its mandatory check
    from ./configure.
    
    Annotate the dependency in the CI dockerfiles, and drop them from CirrusCI and
    TravisCI.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Roger Pau Monné <roger.pau@citrix.com>
    (cherry picked from commit e21a6a4f966a7e91cb0bb014dbe15d15cc0502ad)
---
 .travis.yml        |  1 -
 README             |  1 -
 tools/configure    | 49 -------------------------------------------------
 tools/configure.ac |  2 --
 4 files changed, 53 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 15ca9e9047..dd1cf4709a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -54,7 +54,6 @@ addons:
             - pkg-config
             - flex
             - bison
-            - gettext
             - acpica-tools
             - bin86
             - bcc
diff --git a/README b/README
index c7da4b06e2..6b726cfb68 100644
--- a/README
+++ b/README
@@ -60,7 +60,6 @@ provided by your OS distributor:
     * bridge-utils package (/sbin/brctl)
     * iproute package (/sbin/ip)
     * GNU bison and GNU flex
-    * GNU gettext
     * ACPI ASL compiler (iasl)
     * Libc multiarch package (e.g. libc6-dev-i386 / glibc-devel.i686).
       Required when building on a 64-bit platform to build
diff --git a/tools/configure b/tools/configure
index f3f19c1a90..cf937c9b7a 100755
--- a/tools/configure
+++ b/tools/configure
@@ -685,7 +685,6 @@ INSTALL_PROGRAM
 SET_MAKE
 AWK
 IASL
-XGETTEXT
 BASH
 FLEX
 BISON
@@ -844,7 +843,6 @@ PERL
 BISON
 FLEX
 BASH
-XGETTEXT
 AS86
 LD86
 BCC
@@ -1590,7 +1588,6 @@ Some influential environment variables:
   BISON       Path to Bison parser generator
   FLEX        Path to Flex lexical analyser generator
   BASH        Path to bash shell
-  XGETTEXT    Path to xgetttext tool
   AS86        Path to as86 tool
   LD86        Path to ld86 tool
   BCC         Path to bcc tool
@@ -4718,7 +4715,6 @@ LDFLAGS="$PREPEND_LDFLAGS $LDFLAGS $APPEND_LDFLAGS"
 
 
 
-
 # Checks for programs.
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
@@ -7826,51 +7822,6 @@ fi
 
 if ! $rump; then
 
-# Extract the first word of "xgettext", so it can be a program name with args.
-set dummy xgettext; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_path_XGETTEXT+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  case $XGETTEXT in
-  [\\/]* | ?:[\\/]*)
-  ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path.
-  ;;
-  *)
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
-    ac_cv_path_XGETTEXT="$as_dir/$ac_word$ac_exec_ext"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-  test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT="no"
-  ;;
-esac
-fi
-XGETTEXT=$ac_cv_path_XGETTEXT
-if test -n "$XGETTEXT"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5
-$as_echo "$XGETTEXT" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-if test x"${XGETTEXT}" = x"no"
-then
-    as_fn_error $? "Unable to find xgettext, please install xgettext" "$LINENO" 5
-fi
 case "$host_cpu" in
 i[3456]86|x86_64|aarch64)
     # Extract the first word of "iasl", so it can be a program name with args.
diff --git a/tools/configure.ac b/tools/configure.ac
index 9d126b7a14..1808cffafb 100644
--- a/tools/configure.ac
+++ b/tools/configure.ac
@@ -298,7 +298,6 @@ AC_ARG_VAR([PERL], [Path to Perl parser])
 AC_ARG_VAR([BISON], [Path to Bison parser generator])
 AC_ARG_VAR([FLEX], [Path to Flex lexical analyser generator])
 AC_ARG_VAR([BASH], [Path to bash shell])
-AC_ARG_VAR([XGETTEXT], [Path to xgetttext tool])
 AC_ARG_VAR([AS86], [Path to as86 tool])
 AC_ARG_VAR([LD86], [Path to ld86 tool])
 AC_ARG_VAR([BCC], [Path to bcc tool])
@@ -381,7 +380,6 @@ AS_IF([test "$cross_compiling" != yes], [
 
 if ! $rump; then
 
-AX_PATH_PROG_OR_FAIL([XGETTEXT], [xgettext])
 dnl as86, ld86, bcc and iasl are only required when the host system is x86*.
 dnl "host" here means the platform on which the hypervisor and tools is
 dnl going to run, not the platform on which we are building (known as
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:56:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:56:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680878.1059085 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGgc-0003nr-N0; Wed, 14 Feb 2024 14:56:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680878.1059085; Wed, 14 Feb 2024 14:56:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGgc-0003nj-KC; Wed, 14 Feb 2024 14:56:34 +0000
Received: by outflank-mailman (input) for mailman id 680878;
 Wed, 14 Feb 2024 14:56:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGgb-0003nZ-7b
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGgb-0005at-6s
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGgb-0000C7-6B
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=WUv5lsezrAhnG00It5vBnUtTJsoluW7wJCRBWJTvqj8=; b=Lw4Y/LN0wWasjnMugIBaasaICa
	ZYz+wpBvwhTxdTu5Xsxd23tibpvxjeQeQ8BpCA1GLVsZGDoRH6Zt46nRLx1Sxi7ePaSfAWaYUvfsI
	xsMDsSN+dfEIxRtuVYRXwHRFdlN7yJgibqh8XgN5eu9VD9oevLSeAInKY59c/dK08NMw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] CI: Drop TravisCI
Message-Id: <E1raGgb-0000C7-6B@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:56:33 +0000

commit eccd4d0d75a75b6cc59f2a55488e906c7fb52991
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Apr 21 10:16:13 2021 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Apr 12 09:00:36 2023 +0100

    CI: Drop TravisCI
    
    Travis-ci.org is shutting down shortly.  The arm cross-compile testing has
    been broken for a long time now, and all testing has now been superseded by
    our Gitlab infrastructure.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Wei Liu <wl@xen.org>
    (cherry picked from commit e0dc9b095e7c73dcf6dbfe5c87c33c4708da4d1f)
    
    CI: Drop more TravisCI remnants
    
    This was missed from previous attempts to remove Travis.
    
    Fixes: e0dc9b095e7c ("CI: Drop TravisCI")
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
    Release-acked-by: Henry Wang <Henry.Wang@arm.com>
    (cherry picked from commit bad4832710c7261fad1abe2d0e8e2e1d259b3e8d)
---
 .travis.yml          | 87 ----------------------------------------------------
 MAINTAINERS          |  1 -
 scripts/travis-build | 27 ----------------
 3 files changed, 115 deletions(-)

diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index dd1cf4709a..0000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,87 +0,0 @@
-language: c
-dist: trusty
-sudo: required
-# don't test master, smoke and coverity branches
-branches:
-    except:
-        - master
-        - smoke
-        - /^coverity-tested\/.*/
-        - /^stable-.*/
-matrix:
-    include:
-        - compiler: gcc
-          env: XEN_TARGET_ARCH=x86_64 debug=n
-        - compiler: gcc
-          env: XEN_TARGET_ARCH=x86_64 XEN_CONFIG_EXPERT=y RANDCONFIG=y debug=n
-        - compiler: gcc-5
-          env: XEN_TARGET_ARCH=x86_64 debug=n
-        - compiler: gcc
-          env: XEN_TARGET_ARCH=x86_64 debug=y
-        - compiler: gcc-5
-          env: XEN_TARGET_ARCH=x86_64 debug=y
-        - compiler: clang
-          env: XEN_TARGET_ARCH=x86_64 clang=y debug=n
-        - compiler: clang
-          env: XEN_TARGET_ARCH=x86_64 clang=y debug=y
-        - compiler: gcc
-          env: XEN_TARGET_ARCH=arm32 CROSS_COMPILE=arm-linux-gnueabihf- debug=n
-        - compiler: gcc
-          env: XEN_TARGET_ARCH=arm32 CROSS_COMPILE=arm-linux-gnueabihf- XEN_CONFIG_EXPERT=y RANDCONFIG=y debug=n
-        - compiler: gcc
-          env: XEN_TARGET_ARCH=arm32 CROSS_COMPILE=arm-linux-gnueabihf- debug=y
-        - compiler: gcc
-          env: XEN_TARGET_ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- debug=n
-        - compiler: gcc
-          env: XEN_TARGET_ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- XEN_CONFIG_EXPERT=y RANDCONFIG=y debug=n
-        - compiler: gcc
-          env: XEN_TARGET_ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- debug=y
-addons:
-    apt:
-        sources:
-            - ubuntu-toolchain-r-test
-        packages:
-            - zlib1g-dev
-            - libncurses5-dev
-            - libssl-dev
-            - python-dev
-            - xorg-dev
-            - uuid-dev
-            - libyajl-dev
-            - libaio-dev
-            - libglib2.0-dev
-            - libpixman-1-dev
-            - pkg-config
-            - flex
-            - bison
-            - acpica-tools
-            - bin86
-            - bcc
-            - libc6-dev-i386
-            - libnl-3-dev
-            - ocaml-nox
-            - libfindlib-ocaml-dev
-            - transfig
-            - pandoc
-            - gcc-arm-linux-gnueabihf
-            - gcc-aarch64-linux-gnu
-            - gcc-5
-            - g++-5
-            - seabios
-            - checkpolicy
-            - ghostscript
-# we must set CXX manually instead of using 'language: cpp' due to
-# travis-ci/travis-ci#3871
-before_script:
-    - export CXX=${CC/cc/++}
-    - export CXX=${CXX/clang/clang++}
-script:
-    - ./scripts/travis-build
-after_script:
-    - cat xen/.config
-    - cat tools/config.log
-    - cat docs/config.log
-notifications:
-    irc:
-        channels:
-            - secure: "mPIFllF6eW3F3talvccMy55Tfcid66IPkkXZYCxDKRF2DQrMyvmg4qt0xN6gGZsdfOBMNr+/YfO5PxusBCUkVdBGBzd3QhFoIDYZbJZgzVh3yNDQ+x4L7p1cZNrwJ2loMmSX6KxGKZxZX9NRStrTUkVyp0jGZB9xkwT8Rl6jXj7EQkgQ95K1Wqafx0ycLfyDQmzX9bzi/3KIBFKMGmK18AFMh+R30zK0FPUUsS4+VhepIkVqO5puU3OYePd34wRnWlt7hjU2Vj5vYmVXp3UOE+E8/Lf9IGVAhitDi+EC35b8zo2BHJ9z6xZARYPvfSqbXcXV20RycabI+e3ufZJ40eatssly5QjWH+HhKS42C4gV1psmQhkTCNCM62Ty5uf6R1hsZJQuiOZrc8ojdje8ey2MxJk4R+Xz+Igg1/kD6+WX9/Y6Y3iRuj5HL1xCYfpTbK4mC7ofw0SofW2aAGI68jHpCqJdQCDzMl6748PlDMM0eKe0MPKIEenYHcoBnOEC/jciXUDa6wduV75EEip7oq2i+m44MopcsEDTpdliH077GhKapF0ActjvBTLpyoTRSfkKm0NZol/dgwd3PGG/mY8clIoeXWRb4opk93ejPC967KmSNC68SlfwaJmFZS5T9vAgb6k7r6i9G3dmYtrLKzws8IV1CPWqLzk58+v4pRk="
diff --git a/MAINTAINERS b/MAINTAINERS
index 04eb361222..e1e6ea0707 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -189,7 +189,6 @@ S:	Supported
 F:	.gitlab-ci.yml
 F:	.travis.yml
 F:	automation/
-F:	scripts/travis-build
 
 CPU POOLS
 M:	Juergen Gross <jgross@suse.com>
diff --git a/scripts/travis-build b/scripts/travis-build
deleted file mode 100755
index 0cb15a89e4..0000000000
--- a/scripts/travis-build
+++ /dev/null
@@ -1,27 +0,0 @@
-#!/bin/bash -ex
-
-$CC --version
-
-# random config or default config
-if [[ "${RANDCONFIG}" == "y" ]]; then
-    make -C xen KCONFIG_ALLCONFIG=tools/kconfig/allrandom.config randconfig
-else
-    make -C xen defconfig
-fi
-
-# build up our configure options
-cfgargs=()
-cfgargs+=("--disable-stubdom") # more work needed into building this
-cfgargs+=("--disable-rombios")
-cfgargs+=("--enable-docs")
-cfgargs+=("--with-system-seabios=/usr/share/seabios/bios.bin")
-
-if [[ "${XEN_TARGET_ARCH}" == "x86_64" ]]; then
-    cfgargs+=("--enable-tools")
-else
-    cfgargs+=("--disable-tools") # we don't have the cross depends installed
-fi
-
-./configure "${cfgargs[@]}"
-
-make dist
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:56:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:56:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680879.1059088 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGgm-0003r3-O6; Wed, 14 Feb 2024 14:56:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680879.1059088; Wed, 14 Feb 2024 14:56:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGgm-0003qw-Lg; Wed, 14 Feb 2024 14:56:44 +0000
Received: by outflank-mailman (input) for mailman id 680879;
 Wed, 14 Feb 2024 14:56:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGgl-0003qh-Ab
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:43 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGgl-0005bB-9t
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGgl-0000CY-99
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Uvf/83juI6g9nir+AstWhVC1ngbpj0Il+fkxUP5vRSk=; b=UKnLBXTFdQHfjMOcuoxYfmyUvF
	YV9f+s1FP2Wq94kpvf6x1DctpNTZXuYBFqg89tl9W9a/hdiwKXR2yct+PqslspBoe3pHHaJjsJVPr
	M4US3C7QwPWxANr+tk876dWmRbrLajVDjOB7U+G7IS8PDX6ijkbakX0IAgv9nNtjfqU0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] build: add --full to version.sh to guess $(XEN_FULLVERSION)
Message-Id: <E1raGgl-0000CY-99@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:56:43 +0000

commit d76c89122b70f17a94109cb03de99670664f0e18
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Thu Sep 9 15:33:06 2021 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Apr 12 09:00:36 2023 +0100

    build: add --full to version.sh to guess $(XEN_FULLVERSION)
    
    Running $(MAKE) like that in a $(shell ) while parsing the Makefile
    doesn't work reliably. In some case, make will complain with
    "jobserver unavailable: using -j1.  Add '+' to parent make rule.".
    Also, it isn't possible to distinguish between the output produced by
    the target "xenversion" and `make`'s own output.
    
    Instead of running make, this patch "improve" `version.sh` to try to
    guess the output of `make xenversion`.
    
    In order to have version.sh works in more scenario, it will use
    XEN_EXTRAVERSION and XEN_VENDORVERSION from the environment when
    present. As for the cases were those two variables are overridden by a
    make command line arguments, we export them when invoking version.sh
    via a new $(XEN_FULLVERSION) macro.
    
    That should hopefully get us to having ./version.sh returning the same
    value that `make xenversion` would.
    
    This fix GitLab CI's build job "debian-unstable-gcc-arm64".
    
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Daniel P. Smith <dpsmith@apertussolutions.com>
    Reviewed-by: Ian Jackson <iwj@xenproject.org>
    (cherry picked from commit ab4a83023eda9f04ad864877c1956b087ec6fc4f)
---
 tools/Rules.mk                     |  5 +++++
 tools/flask/policy/Makefile.common |  2 +-
 version.sh                         | 18 +++++++++++++++++-
 3 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/tools/Rules.mk b/tools/Rules.mk
index 67747110b8..ff54a0794d 100644
--- a/tools/Rules.mk
+++ b/tools/Rules.mk
@@ -6,6 +6,11 @@ all:
 -include $(XEN_ROOT)/config/Tools.mk
 include $(XEN_ROOT)/Config.mk
 
+XEN_FULLVERSION=$(shell env \
+    XEN_EXTRAVERSION=$(XEN_EXTRAVERSION) \
+    XEN_VENDORVERSION=$(XEN_VENDORVERSION) \
+    $(SHELL) $(XEN_ROOT)/version.sh --full $(XEN_ROOT)/xen/Makefile)
+
 export _INSTALL := $(INSTALL)
 INSTALL = $(XEN_ROOT)/tools/cross-install
 
diff --git a/tools/flask/policy/Makefile.common b/tools/flask/policy/Makefile.common
index bea5ba4b6a..e5ed58200e 100644
--- a/tools/flask/policy/Makefile.common
+++ b/tools/flask/policy/Makefile.common
@@ -35,7 +35,7 @@ OUTPUT_POLICY ?= $(BEST_POLICY_VER)
 #
 ########################################
 
-POLICY_FILENAME = $(FLASK_BUILD_DIR)/xenpolicy-$(shell $(MAKE) -C $(XEN_ROOT)/xen xenversion --no-print-directory)
+POLICY_FILENAME = $(FLASK_BUILD_DIR)/xenpolicy-$(XEN_FULLVERSION)
 POLICY_LOADPATH = /boot
 
 # List of policy versions supported by the hypervisor
diff --git a/version.sh b/version.sh
index e894ee7e04..c6a5692c19 100755
--- a/version.sh
+++ b/version.sh
@@ -1,5 +1,21 @@
 #!/bin/sh
 
+opt_full=false
+while [ $# -gt 1 ]; do
+    case "$1" in
+        --full) opt_full=true ;;
+        *) break ;;
+    esac
+    shift
+done
+
 MAJOR=`grep "export XEN_VERSION" $1 | sed 's/.*=//g' | tr -s " "`
 MINOR=`grep "export XEN_SUBVERSION" $1 | sed 's/.*=//g' | tr -s " "`
-printf "%d.%d" $MAJOR $MINOR
+
+if $opt_full; then
+    extraversion=$(grep "export XEN_EXTRAVERSION" $1 | sed 's/^.* ?=\s\+//; s/\$([^)]*)//g; s/ //g')
+    : ${XEN_EXTRAVERSION:=${extraversion}${XEN_VENDORVERSION}}
+else
+    unset XEN_EXTRAVERSION
+fi
+printf "%d.%d%s" $MAJOR $MINOR $XEN_EXTRAVERSION
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:56:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:56:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680880.1059093 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGgw-0003th-Po; Wed, 14 Feb 2024 14:56:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680880.1059093; Wed, 14 Feb 2024 14:56:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGgw-0003ta-N7; Wed, 14 Feb 2024 14:56:54 +0000
Received: by outflank-mailman (input) for mailman id 680880;
 Wed, 14 Feb 2024 14:56:53 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGgv-0003tN-Df
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:53 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGgv-0005bb-Cw
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:53 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGgv-0000DG-C4
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:56:53 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=z3urw5Uu34oo8PjLck2zUfLb7H9hfAYTHRuMnpyrZ0Y=; b=LBu9zv0pUQJMlOFzeLl7D8/cu8
	Iqm8LJb7PYmfB5HPgrYtnSDxZFI01mIQRMA3NhhUM2K8S/CJFrNnNobrssyizNJEyDyDqUgNVhcrw
	tW+0e0b20OZX2fq6Sa6RKFKisJ9d6Q7H0k0308IrWl4raKIz7CUh/vyoDOOC2Vhs4/cY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] bump default SeaBIOS version to 1.16.0
Message-Id: <E1raGgv-0000DG-C4@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:56:53 +0000

commit 62406f6fbd48eb8de2abcca5cb80ee1ffcea3bb6
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 6 14:46:52 2022 +0200
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Apr 12 09:00:36 2023 +0100

    bump default SeaBIOS version to 1.16.0
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    (cherry picked from commit 944e389daa133dd310d87c4eebacba9f6da76018)
---
 Config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Config.mk b/Config.mk
index ba5eb4ea3c..4a0f717894 100644
--- a/Config.mk
+++ b/Config.mk
@@ -247,7 +247,7 @@ OVMF_UPSTREAM_REVISION ?= 20d2e5a125e34fc8501026613a71549b2a1a3e54
 QEMU_UPSTREAM_REVISION ?= qemu-xen-4.14.5
 MINIOS_UPSTREAM_REVISION ?= xen-RELEASE-4.14.5
 
-SEABIOS_UPSTREAM_REVISION ?= rel-1.13.0
+SEABIOS_UPSTREAM_REVISION ?= rel-1.16.0
 
 ETHERBOOT_NICS ?= rtl8139 8086100e
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:57:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:57:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680881.1059097 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGh6-0003wW-R7; Wed, 14 Feb 2024 14:57:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680881.1059097; Wed, 14 Feb 2024 14:57:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGh6-0003wP-Ob; Wed, 14 Feb 2024 14:57:04 +0000
Received: by outflank-mailman (input) for mailman id 680881;
 Wed, 14 Feb 2024 14:57:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGh5-0003wE-Ge
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGh5-0005bx-G0
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGh5-0000Ds-FF
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=t4+YfoeipXMOpefCfIP/e+h4mWZ3UJ4GdaqMtp39qgU=; b=oev+KArPh4JjrjfBmYIjVFRUx7
	j3eF4sFSjXtFEyaghqPoeo0EszavAR7AaQQHLjyVAr0wd3XjHsRAinBlTY91WelYU4rBlQI00qgEe
	KgoS9cd3TuwoujscDwWQpdHmo2D/lR8XvwY6qbVLBUlM7JlyarsASdx7Igp0yxKc1iPo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] CI: Drop automation/configs/
Message-Id: <E1raGh5-0000Ds-FF@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:57:03 +0000

commit 4fcd2f59a7b8aa3ac6a0ed688069c4000b3fa803
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Thu Dec 29 15:39:13 2022 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Apr 12 09:00:36 2023 +0100

    CI: Drop automation/configs/
    
    Having 3 extra hypervisor builds on the end of a full build is deeply
    confusing to debug if one of them fails, because the .config file presented in
    the artefacts is not the one which caused a build failure.  Also, the log
    tends to be truncated in the UI.
    
    PV-only is tested as part of PV-Shim in a full build anyway, so doesn't need
    repeating.  HVM-only and neither appear frequently in randconfig, so drop all
    the logic here to simplify things.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Michal Orzel <michal.orzel@amd.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    (cherry picked from commit 7b20009a812f26e74bdbde2ab96165376b3dad34)
---
 automation/configs/x86/hvm_only_config  |  3 ---
 automation/configs/x86/no_hvm_pv_config |  3 ---
 automation/configs/x86/pv_only_config   |  3 ---
 automation/scripts/build                | 15 ---------------
 4 files changed, 24 deletions(-)

diff --git a/automation/configs/x86/hvm_only_config b/automation/configs/x86/hvm_only_config
deleted file mode 100644
index 9efbddd535..0000000000
--- a/automation/configs/x86/hvm_only_config
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_HVM=y
-# CONFIG_PV is not set
-# CONFIG_DEBUG is not set
diff --git a/automation/configs/x86/no_hvm_pv_config b/automation/configs/x86/no_hvm_pv_config
deleted file mode 100644
index 0bf6a8e468..0000000000
--- a/automation/configs/x86/no_hvm_pv_config
+++ /dev/null
@@ -1,3 +0,0 @@
-# CONFIG_HVM is not set
-# CONFIG_PV is not set
-# CONFIG_DEBUG is not set
diff --git a/automation/configs/x86/pv_only_config b/automation/configs/x86/pv_only_config
deleted file mode 100644
index e9d8b4a7c7..0000000000
--- a/automation/configs/x86/pv_only_config
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_PV=y
-# CONFIG_HVM is not set
-# CONFIG_DEBUG is not set
diff --git a/automation/scripts/build b/automation/scripts/build
index 0cd0f3971d..f280d62c81 100755
--- a/automation/scripts/build
+++ b/automation/scripts/build
@@ -48,18 +48,3 @@ mkdir binaries
 if [[ "${XEN_TARGET_ARCH}" == "x86_64" ]]; then
     cp xen/xen binaries/xen
 fi
-
-# Build all the configs we care about
-case ${XEN_TARGET_ARCH} in
-    x86_64) arch=x86 ;;
-    *) exit 0 ;;
-esac
-
-cfg_dir="automation/configs/${arch}"
-for cfg in `ls ${cfg_dir}`; do
-    echo "Building $cfg"
-    make -j$(nproc) -C xen clean
-    rm -f xen/.config
-    make -C xen KBUILD_DEFCONFIG=../../../../${cfg_dir}/${cfg} XEN_CONFIG_EXPERT=y defconfig
-    make -j$(nproc) -C xen XEN_CONFIG_EXPERT=y
-done
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:57:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:57:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680882.1059101 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGhG-0003zG-Sx; Wed, 14 Feb 2024 14:57:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680882.1059101; Wed, 14 Feb 2024 14:57:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGhG-0003z8-Q7; Wed, 14 Feb 2024 14:57:14 +0000
Received: by outflank-mailman (input) for mailman id 680882;
 Wed, 14 Feb 2024 14:57:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGhF-0003yx-Ja
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGhF-0005c6-Iq
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGhF-0000GC-IH
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=If1r2QDFPREXkCO+KT93229URl99vKjpxjmf8walfwA=; b=4auUa+hv8OBBf9nRNTonQZBhcU
	FSSSsfiq6w+AIhrHrUvrVSX8LfXB4Pfat1GPjU8Im/trk/JlXz8M2RtQmWTWV8LyOpoqTT/fzFrsa
	R9ur5tstUQq+2b7F3o/BNqM8sBFQcP2/SD6JRVMXSyZiZMz2Zgf05sKZZjy3gZcIIZeE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] automation: Remove CentOS 7.2 containers and builds
Message-Id: <E1raGhF-0000GC-IH@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:57:13 +0000

commit ce5c9feadf779c9f8416d70ad233f0de985f8fc5
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Tue Feb 21 16:55:36 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Apr 12 09:00:36 2023 +0100

    automation: Remove CentOS 7.2 containers and builds
    
    We already have a container which track the latest CentOS 7, no need
    for this one as well.
    
    Also, 7.2 have outdated root certificate which prevent connection to
    website which use Let's Encrypt.
    
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    (cherry picked from commit ba512629f76dfddb39ea9133ee51cdd9e392a927)
---
 automation/build/centos/7.2.dockerfile  | 50 ---------------------------------
 automation/build/centos/CentOS-7.2.repo | 35 -----------------------
 automation/gitlab-ci/build.yaml         | 10 -------
 3 files changed, 95 deletions(-)

diff --git a/automation/build/centos/7.2.dockerfile b/automation/build/centos/7.2.dockerfile
deleted file mode 100644
index c2f46b694c..0000000000
--- a/automation/build/centos/7.2.dockerfile
+++ /dev/null
@@ -1,50 +0,0 @@
-FROM centos:7.2.1511
-LABEL maintainer.name="The Xen Project" \
-      maintainer.email="xen-devel@lists.xenproject.org"
-
-# ensure we only get bits from the vault for
-# the version we want
-COPY CentOS-7.2.repo /etc/yum.repos.d/CentOS-Base.repo
-
-# install EPEL for dev86, xz-devel and possibly other packages
-RUN yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm && \
-        yum clean all
-
-RUN mkdir /build
-WORKDIR /build
-
-# work around https://github.com/moby/moby/issues/10180
-# and install Xen depends
-RUN rpm --rebuilddb && \
-    yum -y install \
-        yum-plugin-ovl \
-        gcc \
-        gcc-c++ \
-        ncurses-devel \
-        zlib-devel \
-        openssl-devel \
-        python-devel \
-        libuuid-devel \
-        pkgconfig \
-        gettext \
-        flex \
-        bison \
-        libaio-devel \
-        glib2-devel \
-        yajl-devel \
-        pixman-devel \
-        glibc-devel \
-        glibc-devel.i686 \
-        make \
-        binutils \
-        git \
-        wget \
-        acpica-tools \
-        python-markdown \
-        patch \
-        checkpolicy \
-        dev86 \
-        xz-devel \
-        bzip2 \
-        nasm \
-    && yum clean all
diff --git a/automation/build/centos/CentOS-7.2.repo b/automation/build/centos/CentOS-7.2.repo
deleted file mode 100644
index 4da27faeb5..0000000000
--- a/automation/build/centos/CentOS-7.2.repo
+++ /dev/null
@@ -1,35 +0,0 @@
-# CentOS-Base.repo
-#
-# This is a replacement file that pins things to just use CentOS 7.2
-# from the CentOS Vault.
-#
-
-[base]
-name=CentOS-7.2.1511 - Base
-baseurl=http://vault.centos.org/7.2.1511/os/$basearch/
-gpgcheck=1
-gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
-
-#released updates 
-[updates]
-name=CentOS-7.2.1511 - Updates
-baseurl=http://vault.centos.org/7.2.1511/updates/$basearch/
-gpgcheck=1
-gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
-
-#additional packages that may be useful
-[extras]
-name=CentOS-7.2.1511 - Extras
-baseurl=http://vault.centos.org/7.2.1511/extras/$basearch/
-gpgcheck=1
-gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
-
-#additional packages that extend functionality of existing packages
-[centosplus]
-name=CentOS-7.2.1511 - Plus
-baseurl=http://vault.centos.org/7.2.1511/centosplus/$basearch/
-gpgcheck=1
-gpgcheck=1
-enabled=0
-gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
-
diff --git a/automation/gitlab-ci/build.yaml b/automation/gitlab-ci/build.yaml
index 2ca12226cd..1ecf77e092 100644
--- a/automation/gitlab-ci/build.yaml
+++ b/automation/gitlab-ci/build.yaml
@@ -156,16 +156,6 @@ archlinux-gcc-debug:
   variables:
     CONTAINER: archlinux:current
 
-centos-7-2-gcc:
-  extends: .gcc-x86-64-build
-  variables:
-    CONTAINER: centos:7.2
-
-centos-7-2-gcc-debug:
-  extends: .gcc-x86-64-build-debug
-  variables:
-    CONTAINER: centos:7.2
-
 centos-7-gcc:
   extends: .gcc-x86-64-build
   variables:
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:57:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:57:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680883.1059104 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGhR-00041l-UA; Wed, 14 Feb 2024 14:57:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680883.1059104; Wed, 14 Feb 2024 14:57:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGhR-00041e-Rd; Wed, 14 Feb 2024 14:57:25 +0000
Received: by outflank-mailman (input) for mailman id 680883;
 Wed, 14 Feb 2024 14:57:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGhP-00041R-Mb
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGhP-0005cI-Lr
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGhP-0000Gr-L7
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=erXe/7ZqAF4Fv6z3dsqtI0UE/u8ViAyyZ369Ji/Lios=; b=I5BmP95XSdqhqrqA9uh+l+dYPL
	fUwPZRgWtL5bhpxCcjA65nu8u5/W7Sg/u3Zw7MnDmtgLbtgzJcKI3byZ/BbnnUzT4UBSX8pxPQtAW
	0xZBm4F1ckqpBDq3wPlZRua/SCo6nW+VowDQS6/kv8bCOY02EzNxLyPDe//7PK2PWwgg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] automation: Remove non-debug x86_32 build jobs
Message-Id: <E1raGhP-0000Gr-L7@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:57:23 +0000

commit b13f939a7651ae89b99839412b2e01b68e1db54e
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Fri Feb 24 17:29:15 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Apr 12 09:00:36 2023 +0100

    automation: Remove non-debug x86_32 build jobs
    
    In the interest of having less jobs, we remove the x86_32 build jobs
    that do release build. Debug build is very likely to be enough to find
    32bit build issues.
    
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    (cherry picked from commit 7b66792ea7f77fb9e587e1e9c530a7c869eecba1)
---
 automation/gitlab-ci/build.yaml | 20 --------------------
 1 file changed, 20 deletions(-)

diff --git a/automation/gitlab-ci/build.yaml b/automation/gitlab-ci/build.yaml
index 1ecf77e092..02ac74ebce 100644
--- a/automation/gitlab-ci/build.yaml
+++ b/automation/gitlab-ci/build.yaml
@@ -246,21 +246,11 @@ debian-stretch-gcc-debug:
   variables:
     CONTAINER: debian:stretch
 
-debian-stretch-32-clang:
-  extends: .clang-x86-32-build
-  variables:
-    CONTAINER: debian:stretch-i386
-
 debian-stretch-32-clang-debug:
   extends: .clang-x86-32-build-debug
   variables:
     CONTAINER: debian:stretch-i386
 
-debian-stretch-32-gcc:
-  extends: .gcc-x86-32-build
-  variables:
-    CONTAINER: debian:stretch-i386
-
 debian-stretch-32-gcc-debug:
   extends: .gcc-x86-32-build-debug
   variables:
@@ -298,21 +288,11 @@ debian-unstable-gcc-debug-randconfig:
     CONTAINER: debian:unstable
     RANDCONFIG: y
 
-debian-unstable-32-clang:
-  extends: .clang-x86-32-build
-  variables:
-    CONTAINER: debian:unstable-i386
-
 debian-unstable-32-clang-debug:
   extends: .clang-x86-32-build-debug
   variables:
     CONTAINER: debian:unstable-i386
 
-debian-unstable-32-gcc:
-  extends: .gcc-x86-32-build
-  variables:
-    CONTAINER: debian:unstable-i386
-
 debian-unstable-32-gcc-debug:
   extends: .gcc-x86-32-build-debug
   variables:
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:57:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:57:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680884.1059111 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGhb-00044h-1j; Wed, 14 Feb 2024 14:57:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680884.1059111; Wed, 14 Feb 2024 14:57:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGha-00044X-Ui; Wed, 14 Feb 2024 14:57:34 +0000
Received: by outflank-mailman (input) for mailman id 680884;
 Wed, 14 Feb 2024 14:57:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGhZ-00044O-PZ
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGhZ-0005cW-Oq
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGhZ-0000HY-OI
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=b62kJhhDEjtCWEltmYjjbUpQGRURUITQPQQt+O7XiNQ=; b=i9+SqpUt/qFkvz34ANt/51kYnc
	AACdmyt+D77HFAvDuGECxLAfFQPrqQbPQiMfHLMNcntxxiJEMORJSVpKnOCrf34VvII671+p8QBsg
	yDZWB//0wXe5pK9MPk8/T6V8X+k2Tg9fTj7WnSpiKKF4OI2//H1m3v4WF8zQuaMevp6I=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] CI: Remove llvm-8 from the Debian Stretch container
Message-Id: <E1raGhZ-0000HY-OI@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:57:33 +0000

commit 622675cdbc5f249bddfe970054f43a867d3ebed0
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Mar 24 17:59:56 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Apr 12 09:00:36 2023 +0100

    CI: Remove llvm-8 from the Debian Stretch container
    
    For similar reasons to c/s a6b1e2b80fe20.  While this container is still
    build-able for now, all the other problems with explicitly-versioned compilers
    remain.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    (cherry picked from commit 7a298375721636290a57f31bb0f7c2a5a38956a4)
---
 automation/build/debian/stretch-llvm-8.list |  3 ---
 automation/build/debian/stretch.dockerfile  | 12 ------------
 automation/gitlab-ci/build.yaml             | 27 ---------------------------
 3 files changed, 42 deletions(-)

diff --git a/automation/build/debian/stretch-llvm-8.list b/automation/build/debian/stretch-llvm-8.list
deleted file mode 100644
index 09fe843fb2..0000000000
--- a/automation/build/debian/stretch-llvm-8.list
+++ /dev/null
@@ -1,3 +0,0 @@
-# Strech LLVM 8 repos
-deb http://apt.llvm.org/stretch/ llvm-toolchain-stretch-8 main
-deb-src http://apt.llvm.org/stretch/ llvm-toolchain-stretch-8 main
diff --git a/automation/build/debian/stretch.dockerfile b/automation/build/debian/stretch.dockerfile
index 32742f7f39..16dfc3cdda 100644
--- a/automation/build/debian/stretch.dockerfile
+++ b/automation/build/debian/stretch.dockerfile
@@ -49,15 +49,3 @@ RUN apt-get update && \
         apt-get autoremove -y && \
         apt-get clean && \
         rm -rf /var/lib/apt/lists* /tmp/* /var/tmp/*
-
-RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
-COPY stretch-llvm-8.list /etc/apt/sources.list.d/
-
-RUN apt-get update && \
-    apt-get --quiet --yes install \
-        clang-8 \
-        lld-8 \
-        && \
-        apt-get autoremove -y && \
-        apt-get clean && \
-        rm -rf /var/lib/apt/lists* /tmp/* /var/tmp/*
diff --git a/automation/gitlab-ci/build.yaml b/automation/gitlab-ci/build.yaml
index 02ac74ebce..ab480bfff8 100644
--- a/automation/gitlab-ci/build.yaml
+++ b/automation/gitlab-ci/build.yaml
@@ -26,13 +26,6 @@
     CXX: clang++
     clang: y
 
-.clang-8-tmpl:
-  variables: &clang-8
-    CC: clang-8
-    CXX: clang++-8
-    LD: ld.lld-8
-    clang: y
-
 .x86-64-build-tmpl:
   <<: *build
   variables:
@@ -97,16 +90,6 @@
   variables:
     <<: *clang
 
-.clang-8-x86-64-build:
-  extends: .x86-64-build
-  variables:
-    <<: *clang-8
-
-.clang-8-x86-64-build-debug:
-  extends: .x86-64-build-debug
-  variables:
-    <<: *clang-8
-
 .clang-x86-32-build:
   extends: .x86-32-build
   variables:
@@ -226,16 +209,6 @@ debian-stretch-clang-debug:
   variables:
     CONTAINER: debian:stretch
 
-debian-stretch-clang-8:
-  extends: .clang-8-x86-64-build
-  variables:
-    CONTAINER: debian:stretch
-
-debian-stretch-clang-8-debug:
-  extends: .clang-8-x86-64-build-debug
-  variables:
-    CONTAINER: debian:stretch
-
 debian-stretch-gcc:
   extends: .gcc-x86-64-build
   variables:
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:57:45 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:57:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680885.1059112 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGhl-00047x-2L; Wed, 14 Feb 2024 14:57:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680885.1059112; Wed, 14 Feb 2024 14:57:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGhk-00047q-W9; Wed, 14 Feb 2024 14:57:44 +0000
Received: by outflank-mailman (input) for mailman id 680885;
 Wed, 14 Feb 2024 14:57:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGhj-00047e-SQ
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:43 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGhj-0005cc-Rj
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGhj-0000Hx-R5
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=YSQHNDQ5y62nRCR+P65ttZdYPDUvEd8l7kjN4MzI1io=; b=6xwOU4Z2iheVAG/U0G8J/AU1hp
	il4GkWVkoFW+gzmQnS/dLPr5Pc4pEb//uMrE59719uxGCiAi5kLkaNQ8f1SaonrQifTjKPWcrQ3Ex
	q2nW5npjg2kKyndlHDJeNDGrVPX1ro6lrFpxT9RfMqGkIxc1XYtTs9bNUXmQzFqM+uuc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] automation: Remove installation of packages from test scripts
Message-Id: <E1raGhj-0000Hx-R5@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:57:43 +0000

commit 98ec8ad2eeb96eb9d4b7f9bfd1ef3a994c63af17
Author:     Michal Orzel <michal.orzel@amd.com>
AuthorDate: Wed Apr 26 09:29:45 2023 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Apr 26 09:29:45 2023 +0200

    automation: Remove installation of packages from test scripts
    
    Now, when these packages are already installed in the respective
    containers, we can remove them from the test scripts.
    
    Signed-off-by: Michal Orzel <michal.orzel@amd.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    master commit: 72cfe1c3ad1fae95f4f0ac51dbdd6838264fdd7f
    master date: 2022-12-09 14:55:33 -0800
---
 automation/scripts/qemu-smoke-x86-64.sh | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/automation/scripts/qemu-smoke-x86-64.sh b/automation/scripts/qemu-smoke-x86-64.sh
index 09152e3e9c..be7e21872e 100755
--- a/automation/scripts/qemu-smoke-x86-64.sh
+++ b/automation/scripts/qemu-smoke-x86-64.sh
@@ -5,11 +5,6 @@ set -ex
 # variant should be either pv or pvh
 variant=$1
 
-# Install QEMU
-export DEBIAN_FRONTENT=noninteractive
-apt-get -qy update
-apt-get -qy install qemu-system-x86
-
 # Clone and build XTF
 git clone https://xenbits.xen.org/git-http/xtf.git
 cd xtf && make -j$(nproc) && cd -
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:57:55 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:57:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680886.1059116 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGhv-0004Aq-3o; Wed, 14 Feb 2024 14:57:55 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680886.1059116; Wed, 14 Feb 2024 14:57:55 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGhv-0004Aj-1O; Wed, 14 Feb 2024 14:57:55 +0000
Received: by outflank-mailman (input) for mailman id 680886;
 Wed, 14 Feb 2024 14:57:54 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGht-0004AW-VQ
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:53 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGht-0005d7-Un
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:53 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGht-0000IP-UB
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:57:53 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=2VgRvoLEamuP1wugFPrgPBB3SYaqp+quzjp3BpBz0Q4=; b=oaClL3UwaGpT7unw6mzVbdEIhk
	+vo7nVwy4xCTA12E7UzKAcT/E4arW17L2vXW5GkhLT4kfKZyhaFobEAKrS4mTwuG22K4opdhAcpJf
	fGlB9LEJew352uFRPHQ6De8XXmIfr23wdcyGJQV+YoxZKj4HoUv2YlaWjWBmjW6VgUjg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/amd: Mitigations for Zenbleed
Message-Id: <E1raGht-0000IP-UB@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:57:53 +0000

commit 64b40594f589c9069fb8cf3899d4aac59c86d4f1
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon May 22 23:03:00 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Jul 24 17:16:41 2023 +0100

    x86/amd: Mitigations for Zenbleed
    
    Zenbleed is a malfunction on AMD Zen2 uarch parts which results in corruption
    of the vector registers.  An attacker can trigger this bug deliberately in
    order to access stale data in the physical vector register file.  This can
    include data from sibling threads, or a higher-privilege context.
    
    Microcode is the preferred mitigation but in the case that's not available use
    the chickenbit as instructed by AMD.  Re-evaluate the mitigation on late
    microcode load too.
    
    This is XSA-433 / CVE-2023-20593.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Roger Pau Monné <roger.pau@citrix.com>
    (cherry picked from commit f91c5ea970675637721bb7f18adaa189837eb783)
---
 xen/arch/x86/cpu/amd.c           | 69 ++++++++++++++++++++++++++++++++++++++++
 xen/arch/x86/cpu/microcode/amd.c |  2 ++
 xen/include/asm-x86/processor.h  |  2 ++
 3 files changed, 73 insertions(+)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index b670ab6cd1..9db79f409a 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -13,6 +13,7 @@
 #include <asm/spec_ctrl.h>
 #include <asm/acpi.h>
 #include <asm/apic.h>
+#include <asm/microcode.h>
 
 #include "cpu.h"
 
@@ -756,6 +757,72 @@ void amd_init_spectral_chicken(void)
 		wrmsr_safe(MSR_AMD64_DE_CFG2, val | chickenbit);
 }
 
+void amd_check_zenbleed(void)
+{
+	const struct cpu_signature *sig = &this_cpu(cpu_sig);
+	unsigned int good_rev, chickenbit = (1 << 9);
+	uint64_t val, old_val;
+
+	/*
+	 * If we're virtualised, we can't do family/model checks safely, and
+	 * we likely wouldn't have access to DE_CFG even if we could see a
+	 * microcode revision.
+	 *
+	 * A hypervisor may hide AVX as a stopgap mitigation.  We're not in a
+	 * position to care either way.  An admin doesn't want to be disabling
+	 * AVX as a mitigation on any build of Xen with this logic present.
+	 */
+	if (cpu_has_hypervisor || boot_cpu_data.x86 != 0x17)
+		return;
+
+	switch (boot_cpu_data.x86_model) {
+	case 0x30 ... 0x3f: good_rev = 0x0830107a; break;
+	case 0x60 ... 0x67: good_rev = 0x0860010b; break;
+	case 0x68 ... 0x6f: good_rev = 0x08608105; break;
+	case 0x70 ... 0x7f: good_rev = 0x08701032; break;
+	case 0xa0 ... 0xaf: good_rev = 0x08a00008; break;
+	default:
+		/*
+		 * With the Fam17h check above, parts getting here are Zen1.
+		 * They're not affected.
+		 */
+		return;
+	}
+
+	rdmsrl(MSR_AMD64_DE_CFG, val);
+	old_val = val;
+
+	/*
+	 * Microcode is the preferred mitigation, in terms of performance.
+	 * However, without microcode, this chickenbit (specific to the Zen2
+	 * uarch) disables Floating Point Mov-Elimination to mitigate the
+	 * issue.
+	 */
+	val &= ~chickenbit;
+	if (sig->rev < good_rev)
+		val |= chickenbit;
+
+	if (val == old_val)
+		/* Nothing to change. */
+		return;
+
+	/*
+	 * DE_CFG is a Core-scoped MSR, and this write is racy during late
+	 * microcode load.  However, both threads calculate the new value from
+	 * state which is shared, and unrelated to the old value, so the
+	 * result should be consistent.
+	 */
+	wrmsrl(MSR_AMD64_DE_CFG, val);
+
+	/*
+	 * Inform the admin that we changed something, but don't spam,
+	 * especially during a late microcode load.
+	 */
+	if (smp_processor_id() == 0)
+		printk(XENLOG_INFO "Zenbleed mitigation - using %s\n",
+		       val & chickenbit ? "chickenbit" : "microcode");
+}
+
 static void init_amd(struct cpuinfo_x86 *c)
 {
 	u32 l, h;
@@ -1016,6 +1083,8 @@ static void init_amd(struct cpuinfo_x86 *c)
 	if ((smp_processor_id() == 1) && !cpu_has(c, X86_FEATURE_ITSC))
 		disable_c1_ramping();
 
+	amd_check_zenbleed();
+
 	check_syscfg_dram_mod_en();
 
 	amd_log_freq(c);
diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/amd.c
index 5eb93195c3..9101f93e42 100644
--- a/xen/arch/x86/cpu/microcode/amd.c
+++ b/xen/arch/x86/cpu/microcode/amd.c
@@ -251,6 +251,8 @@ static int apply_microcode(const struct microcode_patch *patch)
     printk(XENLOG_WARNING "microcode: CPU%u updated from revision %#x to %#x\n",
            cpu, old_rev, rev);
 
+    amd_check_zenbleed();
+
     return 0;
 }
 
diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h
index 3ff7cc5807..71b454d984 100644
--- a/xen/include/asm-x86/processor.h
+++ b/xen/include/asm-x86/processor.h
@@ -635,6 +635,8 @@ void tsx_init(void);
 void update_mcu_opt_ctrl(void);
 void set_in_mcu_opt_ctrl(uint32_t mask, uint32_t val);
 
+void amd_check_zenbleed(void);
+
 #endif /* !__ASSEMBLY__ */
 
 #endif /* __ASM_X86_PROCESSOR_H */
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:58:05 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:58:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680887.1059121 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGi5-0004DT-5Q; Wed, 14 Feb 2024 14:58:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680887.1059121; Wed, 14 Feb 2024 14: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 <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGi5-0004DL-2o; Wed, 14 Feb 2024 14:58:05 +0000
Received: by outflank-mailman (input) for mailman id 680887;
 Wed, 14 Feb 2024 14:58:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGi4-0004DA-2N
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGi4-0005dS-1f
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGi4-0000JM-0m
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=LqpbdQgiqs3XGfJsZnKK/HQbLiKfZIpylvE7rnlFZq8=; b=GR9bPe3vT98u87dmCdhOsrFCAK
	SQbTTKnoeZF8YZfddhJTsOivYkIR0OcoFSaARxXCdAjJ+OouCocvaHKYG271TlMTsro5Btsl7eu/L
	5ODTJn+XZ+mRZXAYoMmuizZIdzE697/RPZYJq4pJe2CQhwIUJL32GrEiNSboz+cawJDc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/amd: Fix DE_CFG truncation in amd_check_zenbleed()
Message-Id: <E1raGi4-0000JM-0m@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:58:04 +0000

commit 602ee4c2954ed3f9f8552e08043146bee60ec012
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Jul 28 18:42:12 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Jul 31 13:55:36 2023 +0100

    x86/amd: Fix DE_CFG truncation in amd_check_zenbleed()
    
    This line:
    
            val &= ~chickenbit;
    
    ends up truncating val to 32 bits, and turning off various errata workarounds
    in Zen2 systems.
    
    Fixes: f91c5ea97067 ("x86/amd: Mitigations for Zenbleed")
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit c0dd53b8cbd1e47e9c89873a9265a7170bdc6b4c)
---
 xen/arch/x86/cpu/amd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/cpu/amd.c b/xen/arch/x86/cpu/amd.c
index 9db79f409a..a1447f37ec 100644
--- a/xen/arch/x86/cpu/amd.c
+++ b/xen/arch/x86/cpu/amd.c
@@ -760,8 +760,8 @@ void amd_init_spectral_chicken(void)
 void amd_check_zenbleed(void)
 {
 	const struct cpu_signature *sig = &this_cpu(cpu_sig);
-	unsigned int good_rev, chickenbit = (1 << 9);
-	uint64_t val, old_val;
+	unsigned int good_rev;
+	uint64_t val, old_val, chickenbit = (1 << 9);
 
 	/*
 	 * If we're virtualised, we can't do family/model checks safely, and
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:58:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:58:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680888.1059125 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGiF-0004GP-72; Wed, 14 Feb 2024 14:58:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680888.1059125; Wed, 14 Feb 2024 14: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 <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGiF-0004G1-4E; Wed, 14 Feb 2024 14:58:15 +0000
Received: by outflank-mailman (input) for mailman id 680888;
 Wed, 14 Feb 2024 14:58:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGiE-0004Fq-5J
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGiE-0005dc-4e
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGiE-0000Jp-3u
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=rUbcJWVd1crozUIZBdV3vqqwEJjnKg5BOJtFmSA6C1k=; b=XZlXSK9SS3zauRY0v10O3CIcyj
	o34wSlM23jN6QM2m6NSopJNTK49g9/eTo26lxdPfVNEa2pGjDIngRwPOU5EDjLF0picUf58Y4nd/p
	zvbmHnlFpRkM4SOcZsibaWCH87Kjs+mlpaNqCMPk7fNjbqo4g0UQZ4UwAlT5PuYMtpzQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/msr: Expose MSR_ARCH_CAPS in the raw and host policies
Message-Id: <E1raGiE-0000Jp-3u@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:58:14 +0000

commit 62549f81869638a65efe879d23c9c4573b7e45d4
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Jun 11 11:37:53 2021 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:18 2023 +0100

    x86/msr: Expose MSR_ARCH_CAPS in the raw and host policies
    
    MSR_ARCH_CAPS is still not supported for guests yet (other than the hardware
    domain), until the toolstack learns how to construct an MSR policy.
    
    However, we want access to the host ARCH_CAPS_TSX_CTRL value in particular for
    testing purposes.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit b672695e748869b2e2e2cb03f671f12003d2b079)
    
    Also the remnants of:
    
      x86: Expose more MSR_ARCH_CAPS to hwdom
      (cherry picked from commit e83cd54611fec5b7a539fa1281a14319143490e6)
    
      x86/spec-ctrl: Enumeration for PBRSB_NO
      (cherry picked from commit b874e47eb13feb75be3ee7b5dc4ae9c97d80d774)
    
    which have both partially been backported already.
---
 xen/arch/x86/msr.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index 576235e507..7b2add4f8d 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -47,8 +47,13 @@ struct msr_policy __read_mostly hvm_def_msr_policy;
 
 static void __init calculate_raw_policy(void)
 {
+    struct msr_policy *mp = &raw_msr_policy;
+
     /* 0x000000ce  MSR_INTEL_PLATFORM_INFO */
     /* Was already added by probe_cpuid_faulting() */
+
+    if ( cpu_has_arch_caps )
+        rdmsrl(MSR_ARCH_CAPABILITIES, mp->arch_caps.raw);
 }
 
 static void __init calculate_host_policy(void)
@@ -60,6 +65,12 @@ static void __init calculate_host_policy(void)
     /* 0x000000ce  MSR_INTEL_PLATFORM_INFO */
     /* probe_cpuid_faulting() sanity checks presence of MISC_FEATURES_ENABLES */
     mp->platform_info.cpuid_faulting = cpu_has_cpuid_faulting;
+
+    /* Temporary, until we have known_features[] for feature bits in MSRs. */
+    mp->arch_caps.raw &=
+        (ARCH_CAPS_RDCL_NO | ARCH_CAPS_IBRS_ALL | ARCH_CAPS_RSBA |
+         ARCH_CAPS_SKIP_L1DFL | ARCH_CAPS_SSB_NO | ARCH_CAPS_MDS_NO |
+         ARCH_CAPS_IF_PSCHANGE_MC_NO | ARCH_CAPS_TSX_CTRL | ARCH_CAPS_TAA_NO);
 }
 
 static void __init calculate_pv_max_policy(void)
@@ -67,6 +78,8 @@ static void __init calculate_pv_max_policy(void)
     struct msr_policy *mp = &pv_max_msr_policy;
 
     *mp = host_msr_policy;
+
+    mp->arch_caps.raw = 0; /* Not supported yet. */
 }
 
 static void __init calculate_pv_def_policy(void)
@@ -84,6 +97,8 @@ static void __init calculate_hvm_max_policy(void)
 
     /* It's always possible to emulate CPUID faulting for HVM guests */
     mp->platform_info.cpuid_faulting = true;
+
+    mp->arch_caps.raw = 0; /* Not supported yet. */
 }
 
 static void __init calculate_hvm_def_policy(void)
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:58:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:58:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680889.1059128 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGiP-0004KK-86; Wed, 14 Feb 2024 14:58:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680889.1059128; Wed, 14 Feb 2024 14:58:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGiP-0004KD-5e; Wed, 14 Feb 2024 14:58:25 +0000
Received: by outflank-mailman (input) for mailman id 680889;
 Wed, 14 Feb 2024 14:58:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGiO-0004K7-8F
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGiO-0005di-7b
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGiO-0000KQ-6y
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:24 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=xWWfLRJGtJj5OikjPOKIPOgwn02vQPW9SA0hSV0+hEU=; b=qfzdYLzIPedbwKbWyHv/6RXR27
	mYCQRwQ5HM3Oi+wKKBrsVOmtqwx4ILhjtUW+Eei+Lsu+zD8I/aAjmc+ymtW6clG2eRad7bYl+mTir
	H+7wlnrMC46EneCzwjQixuvoYak664XPioYHovZdYlEHxqb5tfBICwJLelb8IeMcy2mY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86: Expose more MSR_ARCH_CAPS to hwdom
Message-Id: <E1raGiO-0000KQ-6y@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:58:24 +0000

commit 155d38c76c3f04a20f7603e533a5ab247dd6d3ea
Author:     Jason Andryuk <jandryuk@gmail.com>
AuthorDate: Tue Jul 19 16:08:15 2022 -0400
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86: Expose more MSR_ARCH_CAPS to hwdom
    
    commit e46474278a0e ("x86/intel: Expose MSR_ARCH_CAPS to dom0") started
    exposing MSR_ARCH_CAPS to dom0.  More bits in MSR_ARCH_CAPS have since
    been defined, but they haven't been exposed.  Update the list to allow
    them through.
    
    As one example, this allows a Linux Dom0 to know that it has the
    appropriate microcode via FB_CLEAR.  Notably, and with the updated
    microcode, this changes dom0's
    /sys/devices/system/cpu/vulnerabilities/mmio_stale_data changes from:
    
      "Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host state unknown"
    
    to:
    
      "Mitigation: Clear CPU buffers; SMT Host state unknown"
    
    This exposes the MMIO Stale Data and Intel Branch History Injection
    (BHI) controls as well as the page size change MCE issue bit.
    
    Fixes: commit 2ebe8fe9b7e0 ("x86/spec-ctrl: Enumeration for MMIO Stale Data controls")
    Fixes: commit cea9ae062295 ("x86/spec-ctrl: Enumeration for new Intel BHI controls")
    Fixes: commit 59e89cdabc71 ("x86/vtx: Disable executable EPT superpages to work around CVE-2018-12207")
    Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    (cherry picked from commit e83cd54611fec5b7a539fa1281a14319143490e6)
---
 xen/arch/x86/msr.c              | 9 +++++++--
 xen/include/asm-x86/msr-index.h | 2 ++
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index 7b2add4f8d..527205518c 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -70,7 +70,9 @@ static void __init calculate_host_policy(void)
     mp->arch_caps.raw &=
         (ARCH_CAPS_RDCL_NO | ARCH_CAPS_IBRS_ALL | ARCH_CAPS_RSBA |
          ARCH_CAPS_SKIP_L1DFL | ARCH_CAPS_SSB_NO | ARCH_CAPS_MDS_NO |
-         ARCH_CAPS_IF_PSCHANGE_MC_NO | ARCH_CAPS_TSX_CTRL | ARCH_CAPS_TAA_NO);
+         ARCH_CAPS_IF_PSCHANGE_MC_NO | ARCH_CAPS_TSX_CTRL | ARCH_CAPS_TAA_NO |
+         ARCH_CAPS_SBDR_SSDP_NO | ARCH_CAPS_FBSDP_NO | ARCH_CAPS_PSDP_NO |
+         ARCH_CAPS_FB_CLEAR | ARCH_CAPS_RRSBA | ARCH_CAPS_BHI_NO);
 }
 
 static void __init calculate_pv_max_policy(void)
@@ -159,7 +161,10 @@ int init_domain_msr_policy(struct domain *d)
 
         mp->arch_caps.raw = val &
             (ARCH_CAPS_RDCL_NO | ARCH_CAPS_IBRS_ALL | ARCH_CAPS_RSBA |
-             ARCH_CAPS_SSB_NO | ARCH_CAPS_MDS_NO | ARCH_CAPS_TAA_NO);
+             ARCH_CAPS_SSB_NO | ARCH_CAPS_MDS_NO | ARCH_CAPS_IF_PSCHANGE_MC_NO |
+             ARCH_CAPS_TAA_NO | ARCH_CAPS_SBDR_SSDP_NO | ARCH_CAPS_FBSDP_NO |
+             ARCH_CAPS_PSDP_NO | ARCH_CAPS_FB_CLEAR | ARCH_CAPS_RRSBA |
+             ARCH_CAPS_BHI_NO);
     }
 
     d->arch.msr = mp;
diff --git a/xen/include/asm-x86/msr-index.h b/xen/include/asm-x86/msr-index.h
index 4c1cba589d..63b77cd19a 100644
--- a/xen/include/asm-x86/msr-index.h
+++ b/xen/include/asm-x86/msr-index.h
@@ -61,6 +61,8 @@
 #define  ARCH_CAPS_PSDP_NO                  (_AC(1, ULL) << 15)
 #define  ARCH_CAPS_FB_CLEAR                 (_AC(1, ULL) << 17)
 #define  ARCH_CAPS_FB_CLEAR_CTRL            (_AC(1, ULL) << 18)
+#define  ARCH_CAPS_RRSBA                    (_AC(1, ULL) << 19)
+#define  ARCH_CAPS_BHI_NO                   (_AC(1, ULL) << 20)
 
 #define MSR_FLUSH_CMD                       0x0000010b
 #define  FLUSH_CMD_L1D                      (_AC(1, ULL) <<  0)
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:58:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:58:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680890.1059134 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGiZ-0004Mo-AD; Wed, 14 Feb 2024 14:58:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680890.1059134; Wed, 14 Feb 2024 14:58:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGiZ-0004Mg-72; Wed, 14 Feb 2024 14:58:35 +0000
Received: by outflank-mailman (input) for mailman id 680890;
 Wed, 14 Feb 2024 14:58:34 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGiY-0004MZ-BP
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGiY-0005dt-Ai
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGiY-0000L5-A6
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:34 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=bs21bBTNeymhff4762pa9Eh2d/kYyTiZ9rE6RNbu4Tc=; b=uFjp5Dz3Y32767pReHd38qyzwd
	SGdiSPUuD3TPze4n9IH99GWIopFSsLUKMO2AKuAEdBUO4pmogKmIEoIM7GKedn9XXDmtSUBDt0To7
	glsQ23IAxL1C8Ca00GCP6vdODt687lwJp7waKJwUIse3bxSfj/ytoa9usngVJIhcgYzI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/spec-ctrl: Enumeration for PBRSB_NO
Message-Id: <E1raGiY-0000L5-A6@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:58:34 +0000

commit c47bfc94c0817361f7bbfe62f215e17b0125d551
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Jul 29 14:22:53 2022 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/spec-ctrl: Enumeration for PBRSB_NO
    
    The PBRSB_NO bit indicates that the CPU is not vulnerable to the Post-Barrier
    RSB speculative vulnerability.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit b874e47eb13feb75be3ee7b5dc4ae9c97d80d774)
---
 xen/arch/x86/msr.c              | 5 +++--
 xen/arch/x86/spec_ctrl.c        | 3 ++-
 xen/include/asm-x86/msr-index.h | 1 +
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index 527205518c..6517e50c9f 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -72,7 +72,8 @@ static void __init calculate_host_policy(void)
          ARCH_CAPS_SKIP_L1DFL | ARCH_CAPS_SSB_NO | ARCH_CAPS_MDS_NO |
          ARCH_CAPS_IF_PSCHANGE_MC_NO | ARCH_CAPS_TSX_CTRL | ARCH_CAPS_TAA_NO |
          ARCH_CAPS_SBDR_SSDP_NO | ARCH_CAPS_FBSDP_NO | ARCH_CAPS_PSDP_NO |
-         ARCH_CAPS_FB_CLEAR | ARCH_CAPS_RRSBA | ARCH_CAPS_BHI_NO);
+         ARCH_CAPS_FB_CLEAR | ARCH_CAPS_RRSBA | ARCH_CAPS_BHI_NO |
+         ARCH_CAPS_PBRSB_NO);
 }
 
 static void __init calculate_pv_max_policy(void)
@@ -164,7 +165,7 @@ int init_domain_msr_policy(struct domain *d)
              ARCH_CAPS_SSB_NO | ARCH_CAPS_MDS_NO | ARCH_CAPS_IF_PSCHANGE_MC_NO |
              ARCH_CAPS_TAA_NO | ARCH_CAPS_SBDR_SSDP_NO | ARCH_CAPS_FBSDP_NO |
              ARCH_CAPS_PSDP_NO | ARCH_CAPS_FB_CLEAR | ARCH_CAPS_RRSBA |
-             ARCH_CAPS_BHI_NO);
+             ARCH_CAPS_BHI_NO | ARCH_CAPS_PBRSB_NO);
     }
 
     d->arch.msr = mp;
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index c650e07b06..9ce493d6bc 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -419,7 +419,7 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)
      * Hardware read-only information, stating immunity to certain issues, or
      * suggestions of which mitigation to use.
      */
-    printk("  Hardware hints:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+    printk("  Hardware hints:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
            (caps & ARCH_CAPS_RDCL_NO)                        ? " RDCL_NO"        : "",
            (caps & ARCH_CAPS_IBRS_ALL)                       ? " IBRS_ALL"       : "",
            (caps & ARCH_CAPS_RSBA)                           ? " RSBA"           : "",
@@ -431,6 +431,7 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)
            (caps & ARCH_CAPS_SBDR_SSDP_NO)                   ? " SBDR_SSDP_NO"   : "",
            (caps & ARCH_CAPS_FBSDP_NO)                       ? " FBSDP_NO"       : "",
            (caps & ARCH_CAPS_PSDP_NO)                        ? " PSDP_NO"        : "",
+           (caps & ARCH_CAPS_PBRSB_NO)                       ? " PBRSB_NO"       : "",
            (e8b  & cpufeat_mask(X86_FEATURE_IBRS_ALWAYS))    ? " IBRS_ALWAYS"    : "",
            (e8b  & cpufeat_mask(X86_FEATURE_STIBP_ALWAYS))   ? " STIBP_ALWAYS"   : "",
            (e8b  & cpufeat_mask(X86_FEATURE_IBRS_FAST))      ? " IBRS_FAST"      : "",
diff --git a/xen/include/asm-x86/msr-index.h b/xen/include/asm-x86/msr-index.h
index 63b77cd19a..ce5677f3b6 100644
--- a/xen/include/asm-x86/msr-index.h
+++ b/xen/include/asm-x86/msr-index.h
@@ -63,6 +63,7 @@
 #define  ARCH_CAPS_FB_CLEAR_CTRL            (_AC(1, ULL) << 18)
 #define  ARCH_CAPS_RRSBA                    (_AC(1, ULL) << 19)
 #define  ARCH_CAPS_BHI_NO                   (_AC(1, ULL) << 20)
+#define  ARCH_CAPS_PBRSB_NO                 (_AC(1, ULL) << 24)
 
 #define MSR_FLUSH_CMD                       0x0000010b
 #define  FLUSH_CMD_L1D                      (_AC(1, ULL) <<  0)
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:58:45 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:58:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680891.1059139 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGij-0004Qn-DR; Wed, 14 Feb 2024 14:58:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680891.1059139; Wed, 14 Feb 2024 14:58:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGij-0004Qb-9p; Wed, 14 Feb 2024 14:58:45 +0000
Received: by outflank-mailman (input) for mailman id 680891;
 Wed, 14 Feb 2024 14:58:44 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGii-0004QR-EF
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:44 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGii-0005dz-Db
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:44 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGii-0000LW-Cw
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:44 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=rUuEgy4vNk1ktB042DTAeTnYD4IKhP07NVU4Qjdd1Jo=; b=crZZkLzQXQYOTkCRc8UTOBxc1b
	uERlv8zmuiWkYLAHk62q/Q0cIyPmH2CRIgH8rTa93WMjtHxr3SkFoBzfTnGb0I6bRZ2RtL1WHpQ+i
	4M0LHt1I1Ekqia/FB8iXeE+Fya6ra27wB9bcSzMhtZJGbEFcFAYVpyWU9/9binP79lYM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/cpuid: Calculate FEATURESET_NR_ENTRIES more helpfully
Message-Id: <E1raGii-0000LW-Cw@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:58:44 +0000

commit f99038fe4fba605e77a54cf8a57e9dadc90d4851
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed May 10 19:58:43 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/cpuid: Calculate FEATURESET_NR_ENTRIES more helpfully
    
    When adding new featureset words, it is convenient to split the work into
    several patches.  However, GCC 12 spotted that the way we prefer to split the
    work results in a real (transient) breakage whereby the policy <-> featureset
    helpers perform out-of-bounds accesses on the featureset array.
    
    Fix this by having gen-cpuid.py calculate FEATURESET_NR_ENTRIES from the
    comments describing the word blocks, rather than from the XEN_CPUFEATURE()
    with the greatest value.
    
    For simplicty, require that the word blocks appear in order.  This can be
    revisted if we find a good reason to have blocks out of order.
    
    No functional change.
    
    Reported-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 56e2c8e5860090a35d5f0cafe168223a2a7c0e62)
---
 xen/tools/gen-cpuid.py | 42 ++++++++++++++++++++++++++++++++++++------
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py
index e77672ddcd..d813e92118 100755
--- a/xen/tools/gen-cpuid.py
+++ b/xen/tools/gen-cpuid.py
@@ -50,13 +50,37 @@ def parse_definitions(state):
         "\s+([\s\d]+\*[\s\d]+\+[\s\d]+)\)"
         "\s+/\*([\w!]*) .*$")
 
+    word_regex = re.compile(
+        r"^/\* .* word (\d*) \*/$")
+    last_word = -1
+
     this = sys.modules[__name__]
 
     for l in state.input.readlines():
-        # Short circuit the regex...
-        if not l.startswith("XEN_CPUFEATURE("):
+
+        # Short circuit the regexes...
+        if not (l.startswith("XEN_CPUFEATURE(") or
+                l.startswith("/* ")):
             continue
 
+        # Handle /* ... word $N */ lines
+        if l.startswith("/* "):
+
+            res = word_regex.match(l)
+            if res is None:
+                continue # Some other comment
+
+            word = int(res.groups()[0])
+
+            if word != last_word + 1:
+                raise Fail("Featureset word %u out of order (last word %u)"
+                           % (word, last_word))
+
+            last_word = word
+            state.nr_entries = word + 1
+            continue
+
+        # Handle XEN_CPUFEATURE( lines
         res = feat_regex.match(l)
 
         if res is None:
@@ -94,6 +118,15 @@ def parse_definitions(state):
     if len(state.names) == 0:
         raise Fail("No features found")
 
+    if state.nr_entries == 0:
+        raise Fail("No featureset word info found")
+
+    max_val = max(state.names.keys())
+    if (max_val >> 5) >= state.nr_entries:
+        max_name = state.names[max_val]
+        raise Fail("Feature %s (%d*32+%d) exceeds FEATURESET_NR_ENTRIES (%d)"
+                   % (max_name, max_val >> 5, max_val & 31, state.nr_entries))
+
 def featureset_to_uint32s(fs, nr):
     """ Represent a featureset as a list of C-compatible uint32_t's """
 
@@ -122,9 +155,6 @@ def format_uint32s(state, featureset, indent):
 
 def crunch_numbers(state):
 
-    # Size of bitmaps
-    state.nr_entries = nr_entries = (max(state.names.keys()) >> 5) + 1
-
     # Features common between 1d and e1d.
     common_1d = (FPU, VME, DE, PSE, TSC, MSR, PAE, MCE, CX8, APIC,
                  MTRR, PGE, MCA, CMOV, PAT, PSE36, MMX, FXSR)
@@ -325,7 +355,7 @@ def crunch_numbers(state):
     state.nr_deep_deps = len(state.deep_deps.keys())
 
     # Calculate the bitfield name declarations
-    for word in range(nr_entries):
+    for word in range(state.nr_entries):
 
         names = []
         for bit in range(32):
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:58:55 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:58:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680892.1059142 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGit-0004TP-EA; Wed, 14 Feb 2024 14:58:55 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680892.1059142; Wed, 14 Feb 2024 14:58:55 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGit-0004TH-BI; Wed, 14 Feb 2024 14:58:55 +0000
Received: by outflank-mailman (input) for mailman id 680892;
 Wed, 14 Feb 2024 14:58:54 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGis-0004T9-HP
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:54 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGis-0005eN-Gg
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:54 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGis-0000M3-G5
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:58:54 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=kXTOveJw4gtZ3+7Jw5UD/vxp3E8DJKUxkXCF1y4h9xo=; b=Et6uk0XZyl+R3OIY2IaAzqyyX5
	FFYeNm7xbptMGwXPDKw42TVhsRV3UbT8eBwgMnrp4GFp4g+n9bovAXpes5+Vljlbw46UHuDf2q1R0
	KtDnEc3pGGix6JwkXVx8BGSJNgM86iJn3apcL2/Od1gF2vFjwvNsMHLMM3b3QlwBt+fs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/cpuid: Infrastructure for leaves 7:1{ecx,edx}
Message-Id: <E1raGis-0000M3-G5@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:58:54 +0000

commit 56c68aec53154ee8f28a713f6fa141e1dc3f2dd4
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Mar 3 08:06:44 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/cpuid: Infrastructure for leaves 7:1{ecx,edx}
    
    We don't actually need ecx yet, but adding it in now will reduce the amount to
    which leaf 7 is out of order in a featureset.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit b4a23bf6293aadecfd03bf9e83974443e2eac9cb)
---
 tools/misc/xen-cpuid.c                      | 10 ++++++++++
 xen/arch/x86/cpu/common.c                   |  3 ++-
 xen/include/public/arch-x86/cpufeatureset.h |  4 ++++
 xen/include/xen/lib/x86/cpuid.h             | 17 +++++++++++++++--
 4 files changed, 31 insertions(+), 3 deletions(-)

diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
index 7771da4953..913e0e5dc1 100644
--- a/tools/misc/xen-cpuid.c
+++ b/tools/misc/xen-cpuid.c
@@ -193,6 +193,14 @@ static const char *const str_7b1[32] =
 {
 };
 
+static const char *const str_7c1[32] =
+{
+};
+
+static const char *const str_7d1[32] =
+{
+};
+
 static const char *const str_7d2[32] =
 {
     [ 0] = "intel-psfd",
@@ -218,6 +226,8 @@ static const struct {
     { "0x80000021.eax",  "e21a", str_e21a },
     { "0x00000007:1.ebx", "7b1", str_7b1 },
     { "0x00000007:2.edx", "7d2", str_7d2 },
+    { "0x00000007:1.ecx", "7c1", str_7c1 },
+    { "0x00000007:1.edx", "7d1", str_7d1 },
 };
 
 #define COL_ALIGN "18"
diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index dd592a69c5..70e6dea04a 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -435,7 +435,8 @@ static void generic_identify(struct cpuinfo_x86 *c)
 			cpuid_count(7, 1,
 				    &c->x86_capability[FEATURESET_7a1],
 				    &c->x86_capability[FEATURESET_7b1],
-				    &tmp, &tmp);
+				    &c->x86_capability[FEATURESET_7c1],
+				    &c->x86_capability[FEATURESET_7d1]);
 		if (max_subleaf >= 2)
 			cpuid_count(7, 2,
 				    &tmp, &tmp, &tmp,
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index e536ab42b3..b09d5bd907 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -295,6 +295,10 @@ XEN_CPUFEATURE(LFENCE_DISPATCH,    11*32+ 2) /*A  LFENCE always serializing */
 /* Intel-defined CPU features, CPUID level 0x00000007:2.edx, word 13 */
 XEN_CPUFEATURE(INTEL_PSFD,         13*32+ 0) /*A  MSR_SPEC_CTRL.PSFD */
 
+/* Intel-defined CPU features, CPUID level 0x00000007:1.ecx, word 14 */
+
+/* Intel-defined CPU features, CPUID level 0x00000007:1.edx, word 15 */
+
 #endif /* XEN_CPUFEATURE */
 
 /* Clean up from a default include.  Close the enum (for C). */
diff --git a/xen/include/xen/lib/x86/cpuid.h b/xen/include/xen/lib/x86/cpuid.h
index 50be07c0eb..fa98b371ee 100644
--- a/xen/include/xen/lib/x86/cpuid.h
+++ b/xen/include/xen/lib/x86/cpuid.h
@@ -17,7 +17,9 @@
 #define FEATURESET_7a1   10 /* 0x00000007:1.eax    */
 #define FEATURESET_e21a  11 /* 0x80000021.eax      */
 #define FEATURESET_7b1   12 /* 0x00000007:1.ebx    */
-#define FEATURESET_7d2   13 /* 0x80000007:2.edx    */
+#define FEATURESET_7d2   13 /* 0x00000007:2.edx    */
+#define FEATURESET_7c1   14 /* 0x00000007:1.ecx    */
+#define FEATURESET_7d1   15 /* 0x00000007:1.edx    */
 
 struct cpuid_leaf
 {
@@ -194,7 +196,14 @@ struct cpuid_policy
                 uint32_t _7b1;
                 struct { DECL_BITFIELD(7b1); };
             };
-            uint32_t /* c */:32, /* d */:32;
+            union {
+                uint32_t _7c1;
+                struct { DECL_BITFIELD(7c1); };
+            };
+            union {
+                uint32_t _7d1;
+                struct { DECL_BITFIELD(7d1); };
+            };
 
             /* Subleaf 2. */
             uint32_t /* a */:32, /* b */:32, /* c */:32;
@@ -343,6 +352,8 @@ static inline void cpuid_policy_to_featureset(
     fs[FEATURESET_e21a] = p->extd.e21a;
     fs[FEATURESET_7b1] = p->feat._7b1;
     fs[FEATURESET_7d2] = p->feat._7d2;
+    fs[FEATURESET_7c1] = p->feat._7c1;
+    fs[FEATURESET_7d1] = p->feat._7d1;
 }
 
 /* Fill in a CPUID policy from a featureset bitmap. */
@@ -363,6 +374,8 @@ static inline void cpuid_featureset_to_policy(
     p->extd.e21a  = fs[FEATURESET_e21a];
     p->feat._7b1  = fs[FEATURESET_7b1];
     p->feat._7d2  = fs[FEATURESET_7d2];
+    p->feat._7c1  = fs[FEATURESET_7c1];
+    p->feat._7d1  = fs[FEATURESET_7d1];
 }
 
 static inline uint64_t cpuid_policy_xcr0_max(const struct cpuid_policy *p)
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:59:05 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:59:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680893.1059145 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGj3-0004WC-GK; Wed, 14 Feb 2024 14:59:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680893.1059145; Wed, 14 Feb 2024 14:59:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGj3-0004W5-Ci; Wed, 14 Feb 2024 14:59:05 +0000
Received: by outflank-mailman (input) for mailman id 680893;
 Wed, 14 Feb 2024 14:59:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGj2-0004Vo-KM
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGj2-0005ee-Jf
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGj2-0000Mb-J0
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Eo6KYaDVcZ8gKUPs/L+VKL4J881n2BTm9TKHnKbZGe4=; b=GbpcHC0FiOeo6pOVGIzu6ERJ3b
	x3mvqj894LiFVssUyhC9rzlvcwctJHR9XnxZl6OM9gZOjUrVTlhjCudfE3jzPSkNpBK0Zt9TniB+v
	w4E4NhWjvS9QZIg5nij1vXE7QkkXq3bnGNNkPiFv4IO9GguE1XMtSnq1Ve2HrkBpliXM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/cpuid: Drop special_features[]
Message-Id: <E1raGj2-0000Mb-J0@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:59:04 +0000

commit 0eafe6ac6ac0df7c92dfb50caf02c27a16cb4a3c
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon Jun 7 13:38:53 2021 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/cpuid: Drop special_features[]
    
    While the ! annotation is useful to indicate that something special is
    happening, an array of bits is not.  Drop it, to prevent mistakes.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 69e1472d21cf7e5cf0795ef38b99d00de78a910e)
    
    x86/cpuid: Half revert "x86/cpuid: Drop special_features[]"
    
    xen-cpuid does print out the list of special features, and this is helpful to
    keep.
    
    Fixes: 69e1472d21cf ("x86/cpuid: Drop special_features[]")
    Reported-by: Jan Beulich <JBeulich@suse.com>
    Reported-by: Sander Eikelenboom <linux@eikelenboom.it>
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 0ba0663b1b32d9351890dfd02bdebb3d238897bd)
---
 xen/arch/x86/cpuid.c        | 2 --
 xen/include/asm-x86/cpuid.h | 1 -
 2 files changed, 3 deletions(-)

diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index 587de66545..3a7c3f497c 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -14,7 +14,6 @@
 #include <asm/xstate.h>
 
 const uint32_t known_features[] = INIT_KNOWN_FEATURES;
-const uint32_t special_features[] = INIT_SPECIAL_FEATURES;
 
 static const uint32_t pv_max_featuremask[] = INIT_PV_MAX_FEATURES;
 static const uint32_t hvm_shadow_max_featuremask[] = INIT_HVM_SHADOW_MAX_FEATURES;
@@ -1133,7 +1132,6 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf,
 static void __init __maybe_unused build_assertions(void)
 {
     BUILD_BUG_ON(ARRAY_SIZE(known_features) != FSCAPINTS);
-    BUILD_BUG_ON(ARRAY_SIZE(special_features) != FSCAPINTS);
     BUILD_BUG_ON(ARRAY_SIZE(pv_max_featuremask) != FSCAPINTS);
     BUILD_BUG_ON(ARRAY_SIZE(hvm_shadow_max_featuremask) != FSCAPINTS);
     BUILD_BUG_ON(ARRAY_SIZE(hvm_hap_max_featuremask) != FSCAPINTS);
diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h
index 7baf6c9628..46904061d0 100644
--- a/xen/include/asm-x86/cpuid.h
+++ b/xen/include/asm-x86/cpuid.h
@@ -14,7 +14,6 @@
 #include <public/sysctl.h>
 
 extern const uint32_t known_features[FSCAPINTS];
-extern const uint32_t special_features[FSCAPINTS];
 
 void init_guest_cpuid(void);
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:59:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:59:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680894.1059149 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGjD-0004bG-H9; Wed, 14 Feb 2024 14:59:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680894.1059149; Wed, 14 Feb 2024 14:59:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGjD-0004b8-EI; Wed, 14 Feb 2024 14:59:15 +0000
Received: by outflank-mailman (input) for mailman id 680894;
 Wed, 14 Feb 2024 14:59:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGjC-0004Zm-NK
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGjC-0005eo-Ma
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGjC-0000N7-Ly
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=3N/bNz4ddTrZ3rH84UnwDFVUDtblFBZTY2b/bZAfvFQ=; b=dgp0vfBjZ6YFtq7wkpFxJ0nWkW
	dDs/zCnhZlB3HMmllpDWa8DrTwjYRNJmzDcMArjrjKGC/Rd8NVSWKz5M+B6qiGnUOlW+3H1bfv51K
	YHoqOIRpsUGeORaarKXblDZTemJ94UhtAbBuATdDLQ1LdjRKThDm1eKUZx6WsUPC0pJg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/CPUID: move some static masks into .init
Message-Id: <E1raGjC-0000N7-Ly@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:59:14 +0000

commit 1814dd3df7f9b93bfd840d5192477596774f85fb
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri Apr 9 09:14:25 2021 +0200
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/CPUID: move some static masks into .init
    
    Except for hvm_shadow_max_featuremask and deep_features they're
    referenced by __init functions only.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Roger Pau Monné <roger.pau@citrix.com>
    (cherry picked from commit 186b09ea01c925c3997f1a05f585b35151d32d1a)
---
 xen/arch/x86/cpuid.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index 3a7c3f497c..88eae2a09e 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -15,12 +15,15 @@
 
 const uint32_t known_features[] = INIT_KNOWN_FEATURES;
 
-static const uint32_t pv_max_featuremask[] = INIT_PV_MAX_FEATURES;
+static const uint32_t __initconst pv_max_featuremask[] = INIT_PV_MAX_FEATURES;
 static const uint32_t hvm_shadow_max_featuremask[] = INIT_HVM_SHADOW_MAX_FEATURES;
-static const uint32_t hvm_hap_max_featuremask[] = INIT_HVM_HAP_MAX_FEATURES;
-static const uint32_t pv_def_featuremask[] = INIT_PV_DEF_FEATURES;
-static const uint32_t hvm_shadow_def_featuremask[] = INIT_HVM_SHADOW_DEF_FEATURES;
-static const uint32_t hvm_hap_def_featuremask[] = INIT_HVM_HAP_DEF_FEATURES;
+static const uint32_t __initconst hvm_hap_max_featuremask[] =
+    INIT_HVM_HAP_MAX_FEATURES;
+static const uint32_t __initconst pv_def_featuremask[] = INIT_PV_DEF_FEATURES;
+static const uint32_t __initconst hvm_shadow_def_featuremask[] =
+    INIT_HVM_SHADOW_DEF_FEATURES;
+static const uint32_t __initconst hvm_hap_def_featuremask[] =
+    INIT_HVM_HAP_DEF_FEATURES;
 static const uint32_t deep_features[] = INIT_DEEP_FEATURES;
 
 static int __init parse_xen_cpuid(const char *s)
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:59:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:59:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680895.1059152 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGjN-0004gd-IF; Wed, 14 Feb 2024 14:59:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680895.1059152; Wed, 14 Feb 2024 14:59:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGjN-0004gV-Fk; Wed, 14 Feb 2024 14:59:25 +0000
Received: by outflank-mailman (input) for mailman id 680895;
 Wed, 14 Feb 2024 14:59:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGjM-0004gH-QI
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGjM-0005f2-PW
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGjM-0000NZ-Ov
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:24 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ydPGQBMsn5R7UfHNEq7nstgQoX5TtaJk7OWBB/9jad8=; b=Ba3Fl6mfeLZMkbKIxypsrcXK/u
	SJuOT4JZLbPagVsRQWAw/7zQUSflISo+kDymcRC/PGL+1S8baRyQ2dZ5nMBQsX/Lt+U4ZfUaoaoaz
	i/MrM4xcxLXWCKVrNxfpxMYFM/DM6NjEbKQQbGpWaqY7N7+GUfdfNbUJzKyFWo6XZfZk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/cpuid: Split dom0 handling out of init_domain_cpuid_policy()
Message-Id: <E1raGjM-0000NZ-Ov@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:59:24 +0000

commit ceea0ecc3ec6fecdf834bcec5bf32acb55a7831e
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Dec 15 15:36:59 2021 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/cpuid: Split dom0 handling out of init_domain_cpuid_policy()
    
    To implement dom0-cpuid= support, the special cases would need extending.
    However there is already a problem with late hwdom where the special cases
    override toolstack settings, which is unintended and poor behaviour.
    
    Introduce a new init_dom0_cpuid_policy() for the purpose, moving the ITSC and
    ARCH_CAPS logic.  The is_hardware_domain() can be dropped, and for now there
    is no need to rerun recalculate_cpuid_policy(); this is a relatively expensive
    operation, and will become more-so over time.
    
    Rearrange the logic in create_dom0() to make room for a call to
    init_dom0_cpuid_policy().  The AMX plans for having variable sized XSAVE
    states require that modifications to the policy happen before vCPUs are
    created.
    
    Additionally, factor out domid into a variable so we can be slightly more
    correct in the case of a failure, and also print the error from
    domain_create().  This will at least help distinguish -EINVAL from -ENOMEM.
    
    No practical change in behaviour.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit c17072fc164a72583fda8e2b836c71d2e3f8e84d)
---
 xen/arch/x86/cpuid.c        | 24 +++++++++++++++---------
 xen/arch/x86/setup.c        | 15 +++++++++++----
 xen/include/asm-x86/cpuid.h |  3 +++
 3 files changed, 29 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index 88eae2a09e..01fd016522 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -744,22 +744,28 @@ int init_domain_cpuid_policy(struct domain *d)
     if ( !p )
         return -ENOMEM;
 
-    if ( d->disable_migrate )
-        p->extd.itsc = cpu_has_itsc;
+    d->arch.cpuid = p;
+
+    recalculate_cpuid_policy(d);
+
+    return 0;
+}
+
+void __init init_dom0_cpuid_policy(struct domain *d)
+{
+    struct cpuid_policy *p = d->arch.cpuid;
+
+    /* dom0 can't migrate.  Give it ITSC if available. */
+    if ( cpu_has_itsc )
+        p->extd.itsc = true;
 
     /*
      * Expose the "hardware speculation behaviour" bits of ARCH_CAPS to dom0,
      * so dom0 can turn off workarounds as appropriate.  Temporary, until the
      * domain policy logic gains a better understanding of MSRs.
      */
-    if ( is_hardware_domain(d) && cpu_has_arch_caps )
+    if ( cpu_has_arch_caps )
         p->feat.arch_caps = true;
-
-    d->arch.cpuid = p;
-
-    recalculate_cpuid_policy(d);
-
-    return 0;
 }
 
 void guest_cpuid(const struct vcpu *v, uint32_t leaf,
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 29d71087a7..44b09b8be9 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -770,6 +770,7 @@ static struct domain *__init create_dom0(const module_t *image,
     };
     struct domain *d;
     char *cmdline;
+    domid_t domid;
 
     if ( opt_dom0_pvh )
     {
@@ -784,10 +785,16 @@ static struct domain *__init create_dom0(const module_t *image,
     if ( iommu_enabled )
         dom0_cfg.flags |= XEN_DOMCTL_CDF_iommu;
 
-    /* Create initial domain 0. */
-    d = domain_create(get_initial_domain_id(), &dom0_cfg, !pv_shim);
-    if ( IS_ERR(d) || (alloc_dom0_vcpu0(d) == NULL) )
-        panic("Error creating domain 0\n");
+    /* Create initial domain.  Not d0 for pvshim. */
+    domid = get_initial_domain_id();
+    d = domain_create(domid, &dom0_cfg, !pv_shim);
+    if ( IS_ERR(d) )
+        panic("Error creating d%u: %ld\n", domid, PTR_ERR(d));
+
+    init_dom0_cpuid_policy(d);
+
+    if ( alloc_dom0_vcpu0(d) == NULL )
+        panic("Error creating d%uv0\n", domid);
 
     /* Grab the DOM0 command line. */
     cmdline = image->string ? __va(image->string) : NULL;
diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h
index 46904061d0..9c3637549a 100644
--- a/xen/include/asm-x86/cpuid.h
+++ b/xen/include/asm-x86/cpuid.h
@@ -59,6 +59,9 @@ bool recheck_cpu_features(unsigned int cpu);
 /* Allocate and initialise a CPUID policy suitable for the domain. */
 int init_domain_cpuid_policy(struct domain *d);
 
+/* Apply dom0-specific tweaks to the CPUID policy. */
+void init_dom0_cpuid_policy(struct domain *d);
+
 /* Clamp the CPUID policy to reality. */
 void recalculate_cpuid_policy(struct domain *d);
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:59:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:59:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680896.1059157 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGjX-0004qW-KS; Wed, 14 Feb 2024 14:59:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680896.1059157; Wed, 14 Feb 2024 14:59:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGjX-0004qP-HM; Wed, 14 Feb 2024 14:59:35 +0000
Received: by outflank-mailman (input) for mailman id 680896;
 Wed, 14 Feb 2024 14:59:34 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGjW-0004qH-T2
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGjW-0005fA-SM
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGjW-0000Ny-Rm
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:34 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=cVgm43lDw9b6y2KhBNbj3lyUpKQRPLPqRTgwkl4n/kQ=; b=LUc4E1p0qIj4FTHAR+o+MTWwfp
	0M/64zV4pN8QqpL2Kfe5dUT2E38bI4Q3hHRU6uIE0GMjwLHBmiuLK2WYOZLVpVhua5EhyId83jjaW
	BgStIOIZ/H7A7eJrvl3y0gRuTsu+Y1qSiu/OmFEbeACf9qm5ejIYvgGIIq7O5h9GYd1c=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/cpuid: Factor common parsing out of parse_xen_cpuid()
Message-Id: <E1raGjW-0000Ny-Rm@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:59:34 +0000

commit 6a3b0205d5c737ef5ef9b34f04de8539f091f145
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Dec 15 16:30:25 2021 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/cpuid: Factor common parsing out of parse_xen_cpuid()
    
    dom0-cpuid= is going to want to reuse the common parsing loop, so factor it
    out into parse_cpuid().
    
    Irritatingly, despite being static const, the features[] array gets duplicated
    each time parse_cpuid() is inlined.  As it is a large (and ever growing with
    new CPU features) datastructure, move it to being file scope so all inlines
    use the same single object.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 94c3df9188d6deed6fe213754492b11b9d409262)
---
 xen/arch/x86/cpuid.c | 45 ++++++++++++++++++++++++++++++++-------------
 1 file changed, 32 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index 01fd016522..4c98d3348b 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -26,17 +26,26 @@ static const uint32_t __initconst hvm_hap_def_featuremask[] =
     INIT_HVM_HAP_DEF_FEATURES;
 static const uint32_t deep_features[] = INIT_DEEP_FEATURES;
 
-static int __init parse_xen_cpuid(const char *s)
+static const struct feature_name {
+    const char *name;
+    unsigned int bit;
+} feature_names[] __initconstrel = INIT_FEATURE_NAMES;
+
+/*
+ * Parse a list of cpuid feature names -> bool, calling the callback for any
+ * matches found.
+ *
+ * always_inline, because this is init code only and we really don't want a
+ * function pointer call in the middle of the loop.
+ */
+static int __init always_inline parse_cpuid(
+    const char *s, void (*callback)(unsigned int feat, bool val))
 {
     const char *ss;
     int val, rc = 0;
 
     do {
-        static const struct feature {
-            const char *name;
-            unsigned int bit;
-        } features[] __initconstrel = INIT_FEATURE_NAMES;
-        const struct feature *lhs, *rhs, *mid = NULL /* GCC... */;
+        const struct feature_name *lhs, *rhs, *mid = NULL /* GCC... */;
         const char *feat;
 
         ss = strchr(s, ',');
@@ -49,8 +58,8 @@ static int __init parse_xen_cpuid(const char *s)
             feat += 3;
 
         /* (Re)initalise lhs and rhs for binary search. */
-        lhs = features;
-        rhs = features + ARRAY_SIZE(features);
+        lhs = feature_names;
+        rhs = feature_names + ARRAY_SIZE(feature_names);
 
         while ( lhs < rhs )
         {
@@ -72,11 +81,7 @@ static int __init parse_xen_cpuid(const char *s)
 
             if ( (val = parse_boolean(mid->name, s, ss)) >= 0 )
             {
-                if ( !val )
-                    setup_clear_cpu_cap(mid->bit);
-                else if ( mid->bit == X86_FEATURE_RDRAND &&
-                          (cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_RDRAND)) )
-                    setup_force_cpu_cap(X86_FEATURE_RDRAND);
+                callback(mid->bit, val);
                 mid = NULL;
             }
 
@@ -95,6 +100,20 @@ static int __init parse_xen_cpuid(const char *s)
 
     return rc;
 }
+
+static void __init _parse_xen_cpuid(unsigned int feat, bool val)
+{
+    if ( !val )
+        setup_clear_cpu_cap(feat);
+    else if ( feat == X86_FEATURE_RDRAND &&
+              (cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_RDRAND)) )
+        setup_force_cpu_cap(X86_FEATURE_RDRAND);
+}
+
+static int __init parse_xen_cpuid(const char *s)
+{
+    return parse_cpuid(s, _parse_xen_cpuid);
+}
 custom_param("cpuid", parse_xen_cpuid);
 
 #define EMPTY_LEAF ((struct cpuid_leaf){})
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:59:45 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:59:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680897.1059161 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGjh-00050i-Mv; Wed, 14 Feb 2024 14:59:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680897.1059161; Wed, 14 Feb 2024 14:59:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGjh-00050a-KL; Wed, 14 Feb 2024 14:59:45 +0000
Received: by outflank-mailman (input) for mailman id 680897;
 Wed, 14 Feb 2024 14:59:45 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGjg-00050S-W4
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:44 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGjg-0005fG-VP
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:44 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGjg-0000OO-Ur
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:44 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=aN/Op8qDINtRAEZIy36PNFZyx5BXAJ2WiUXQxIBhVVw=; b=SEg2D8uBEPV2+546OLqUTwQVV6
	Ansy4LGU/jswhw3cPlCIf4rTOI4846NHeTU0sx0247bQZRAQb/Um0eC7hogdh2GXLCycXMRVdHyWB
	nMXrGM/Tr/XqpApf5vrWAb8Mt70AOzznvZDR9bQ4rK8SocSU0i3DlxfXIxEeMxzXfajg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/cpuid: Introduce dom0-cpuid command line option
Message-Id: <E1raGjg-0000OO-Ur@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:59:44 +0000

commit 3690ddda21b1ea24177a3434c75f189f5b19e47b
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Dec 14 16:53:36 2021 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/cpuid: Introduce dom0-cpuid command line option
    
    Specifically, this lets the user opt in to non-default features.
    
    Collect all dom0 settings together in dom0_{en,dis}able_feat[], and apply it
    to dom0's policy when other tweaks are being made.
    
    As recalculate_cpuid_policy() is an expensive action, and dom0-cpuid= is
    likely to only be used by the x86 maintainers for development purposes, forgo
    the recalculation in the general case.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 5bd2b82df28cb7390f5ffb00fac635d0b9e36674)
---
 docs/misc/xen-command-line.pandoc | 16 ++++++++++++++++
 xen/arch/x86/cpuid.c              | 37 +++++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
index f13304ef4e..2fd6a9a552 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -756,6 +756,22 @@ Controls for how dom0 is constructed on x86 systems.
     restore the pre-4.13 behaviour.  If specifying `no-cpuid-faulting` fixes
     an issue in dom0, please report a bug.
 
+### dom0-cpuid
+    = List of comma separated booleans
+
+    Applicability: x86
+
+This option allows for fine tuning of the facilities dom0 will use, after
+accounting for hardware capabilities and Xen settings as enumerated via CPUID.
+
+Options are accepted in positive and negative form, to enable or disable
+specific features.  All selections via this mechanism are subject to normal
+CPU Policy safety and dependency logic.
+
+This option is intended for developers to opt dom0 into non-default features,
+and is not intended for use in production circumstances.  If using this option
+is necessary to fix an issue, please report a bug.
+
 ### dom0-iommu
     = List of [ passthrough=<bool>, strict=<bool>, map-inclusive=<bool>,
                 map-reserved=<bool>, none ]
diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index 4c98d3348b..832a5e95c9 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -116,6 +116,24 @@ static int __init parse_xen_cpuid(const char *s)
 }
 custom_param("cpuid", parse_xen_cpuid);
 
+static bool __initdata dom0_cpuid_cmdline;
+static uint32_t __initdata dom0_enable_feat[FSCAPINTS];
+static uint32_t __initdata dom0_disable_feat[FSCAPINTS];
+
+static void __init _parse_dom0_cpuid(unsigned int feat, bool val)
+{
+    __set_bit  (feat, val ? dom0_enable_feat  : dom0_disable_feat);
+    __clear_bit(feat, val ? dom0_disable_feat : dom0_enable_feat );
+}
+
+static int __init parse_dom0_cpuid(const char *s)
+{
+    dom0_cpuid_cmdline = true;
+
+    return parse_cpuid(s, _parse_dom0_cpuid);
+}
+custom_param("dom0-cpuid", parse_dom0_cpuid);
+
 #define EMPTY_LEAF ((struct cpuid_leaf){})
 static void zero_leaves(struct cpuid_leaf *l,
                         unsigned int first, unsigned int last)
@@ -785,6 +803,25 @@ void __init init_dom0_cpuid_policy(struct domain *d)
      */
     if ( cpu_has_arch_caps )
         p->feat.arch_caps = true;
+
+    /* Apply dom0-cpuid= command line settings, if provided. */
+    if ( dom0_cpuid_cmdline )
+    {
+        uint32_t fs[FSCAPINTS];
+        unsigned int i;
+
+        cpuid_policy_to_featureset(p, fs);
+
+        for ( i = 0; i < ARRAY_SIZE(fs); ++i )
+        {
+            fs[i] |=  dom0_enable_feat [i];
+            fs[i] &= ~dom0_disable_feat[i];
+        }
+
+        cpuid_featureset_to_policy(fs, p);
+
+        recalculate_cpuid_policy(d);
+    }
 }
 
 void guest_cpuid(const struct vcpu *v, uint32_t leaf,
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 14:59:56 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 14:59:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680898.1059165 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGjs-00059D-Oj; Wed, 14 Feb 2024 14:59:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680898.1059165; Wed, 14 Feb 2024 14:59:56 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGjs-000596-M6; Wed, 14 Feb 2024 14:59:56 +0000
Received: by outflank-mailman (input) for mailman id 680898;
 Wed, 14 Feb 2024 14:59:55 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGjr-00058k-2c
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:55 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGjr-0005fg-1w
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:55 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGjr-0000Op-1N
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 14:59:55 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=85Z/pWWFJoxOExWn2Dguwlf/X64z7XO4njKeDDA6ZK0=; b=nw8ywtHaCgsCw89cz0Dyk+e+jw
	kVJqdiO3QYMhJwesBjav7NrlQtE1mx0cYJ/yDQaasRnV0gqU39gtCJh5iE0k/lTgMv7ZLx6gmQkAn
	VnmTOVW160pnSMXtq5+W65xPWI1diV44gcjOHMfL1XG4PeM24OYS2eHGnTq4dxw0sIb8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] tools/xen-cpuid: Rework the handling of dynamic featuresets
Message-Id: <E1raGjr-0000Op-1N@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 14:59:55 +0000

commit 25eb98c93cb084d935a51986b6323999c7d1e4be
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Mar 10 19:04:22 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    tools/xen-cpuid: Rework the handling of dynamic featuresets
    
    struct fsinfo is the vestigial remnant of an older internal design which
    didn't survive very long.
    
    Simplify things by inlining get_featureset() and having a single memory
    allocation that gets reused.  This in turn changes featuresets[] to be a
    simple list of names, so rename it to fs_names[].
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit ec3474e1dd42e6f410601f50b6e74fb7c442cfb9)
---
 tools/misc/xen-cpuid.c | 53 +++++++++++++++++++++-----------------------------
 1 file changed, 22 insertions(+), 31 deletions(-)

diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
index 913e0e5dc1..6cb805c162 100644
--- a/tools/misc/xen-cpuid.c
+++ b/tools/misc/xen-cpuid.c
@@ -232,16 +232,11 @@ static const struct {
 
 #define COL_ALIGN "18"
 
-static struct fsinfo {
-    const char *name;
-    uint32_t len;
-    uint32_t *fs;
-} featuresets[] =
-{
-    [XEN_SYSCTL_cpu_featureset_host] = { "Host", 0, NULL },
-    [XEN_SYSCTL_cpu_featureset_raw]  = { "Raw",  0, NULL },
-    [XEN_SYSCTL_cpu_featureset_pv]   = { "PV",   0, NULL },
-    [XEN_SYSCTL_cpu_featureset_hvm]  = { "HVM",  0, NULL },
+static const char *const fs_names[] = {
+    [XEN_SYSCTL_cpu_featureset_host] = "Host",
+    [XEN_SYSCTL_cpu_featureset_raw]  = "Raw",
+    [XEN_SYSCTL_cpu_featureset_pv]   = "PV",
+    [XEN_SYSCTL_cpu_featureset_hvm]  = "HVM",
 };
 
 static void dump_leaf(uint32_t leaf, const char *const *strs)
@@ -288,22 +283,10 @@ static void decode_featureset(const uint32_t *features,
     }
 }
 
-static int get_featureset(xc_interface *xch, unsigned int idx)
-{
-    struct fsinfo *f = &featuresets[idx];
-
-    f->len = nr_features;
-    f->fs = calloc(nr_features, sizeof(*f->fs));
-
-    if ( !f->fs )
-        err(1, "calloc(, featureset)");
-
-    return xc_get_cpu_featureset(xch, idx, &f->len, f->fs);
-}
-
 static void dump_info(xc_interface *xch, bool detail)
 {
     unsigned int i;
+    uint32_t *fs;
 
     printf("nr_features: %u\n", nr_features);
 
@@ -334,26 +317,34 @@ static void dump_info(xc_interface *xch, bool detail)
                       nr_features, "HVM Hap Default", detail);
 
     printf("\nDynamic sets:\n");
-    for ( i = 0; i < ARRAY_SIZE(featuresets); ++i )
+
+    fs = malloc(sizeof(*fs) * nr_features);
+    if ( !fs )
+        err(1, "malloc(featureset)");
+
+    for ( i = 0; i < ARRAY_SIZE(fs_names); ++i )
     {
-        if ( get_featureset(xch, i) )
+        uint32_t len = nr_features;
+        int ret;
+
+        memset(fs, 0, sizeof(*fs) * nr_features);
+
+        ret = xc_get_cpu_featureset(xch, i, &len, fs);
+        if ( ret )
         {
             if ( errno == EOPNOTSUPP )
             {
-                printf("%s featureset not supported by Xen\n",
-                       featuresets[i].name);
+                printf("%s featureset not supported by Xen\n", fs_names[i]);
                 continue;
             }
 
             err(1, "xc_get_featureset()");
         }
 
-        decode_featureset(featuresets[i].fs, featuresets[i].len,
-                          featuresets[i].name, detail);
+        decode_featureset(fs, len, fs_names[i], detail);
     }
 
-    for ( i = 0; i < ARRAY_SIZE(featuresets); ++i )
-        free(featuresets[i].fs);
+    free(fs);
 }
 
 static void print_policy(const char *name,
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:00:07 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:00:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680899.1059169 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGk2-00063K-QP; Wed, 14 Feb 2024 15:00:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680899.1059169; Wed, 14 Feb 2024 15:00:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGk2-000632-Nc; Wed, 14 Feb 2024 15:00:06 +0000
Received: by outflank-mailman (input) for mailman id 680899;
 Wed, 14 Feb 2024 15:00:05 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGk1-0005tg-6U
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:05 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGk1-0005iA-58
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGk1-0000QT-4W
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:05 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=8Dlwe4XR28ZbzPZ+LDMtjDIQUfFyGzexUASI4jcmxL8=; b=mWqbhG/bpaX5ikuOoe0rcRoqZq
	XVEXyaHYFGspH1qFzKodxipNq1FIox9PBSGT3pr2ZUcRrgsMjmKp32RcgBPexzYV+gK35LMSwntWG
	ABVFTawrOXfWdmPdH6bGlt11EQ8XIrDdcEKPmTRXcHq3szewnZlIqZ36DrjgcKxWzY9Q=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/sysctl: Retrofit XEN_SYSCTL_cpu_featureset_{pv,hvm}_max
Message-Id: <E1raGk1-0000QT-4W@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:00:05 +0000

commit 0307a3f68eed7fe9fd3fc6dddf9706244b2bf86f
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Mar 10 19:37:56 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/sysctl: Retrofit XEN_SYSCTL_cpu_featureset_{pv,hvm}_max
    
    Featuresets are supposed to be disappearing when the CPU policy infrastructure
    is complete, but that has taken longer than expected, and isn't going to be
    complete imminently either.
    
    In the meantime, Xen does have proper default/max featuresets, and xen-cpuid
    can even get them via the XEN_SYSCTL_cpu_policy_* interface, but only knows
    now to render them nicely via the featureset interface.
    
    Differences between default and max are a frequent source of errors,
    frequently too in secret leading up to an embargo, so extend the featureset
    sysctl to allow xen-cpuid to render them all nicely.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Christian Lindig <christian.lindig@cloud.com>
    (cherry picked from commit 433d012c6c2737ad5a9aaa994355a4140d601852)
---
 tools/misc/xen-cpuid.c          | 10 ++++++----
 tools/ocaml/libs/xc/xenctrl.ml  |  8 +++++++-
 tools/ocaml/libs/xc/xenctrl.mli |  8 +++++++-
 xen/arch/x86/sysctl.c           |  4 +++-
 xen/include/public/sysctl.h     |  2 ++
 5 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
index 6cb805c162..1e6baf98f6 100644
--- a/tools/misc/xen-cpuid.c
+++ b/tools/misc/xen-cpuid.c
@@ -233,10 +233,12 @@ static const struct {
 #define COL_ALIGN "18"
 
 static const char *const fs_names[] = {
-    [XEN_SYSCTL_cpu_featureset_host] = "Host",
-    [XEN_SYSCTL_cpu_featureset_raw]  = "Raw",
-    [XEN_SYSCTL_cpu_featureset_pv]   = "PV",
-    [XEN_SYSCTL_cpu_featureset_hvm]  = "HVM",
+    [XEN_SYSCTL_cpu_featureset_raw]     = "Raw",
+    [XEN_SYSCTL_cpu_featureset_host]    = "Host",
+    [XEN_SYSCTL_cpu_featureset_pv]      = "PV Default",
+    [XEN_SYSCTL_cpu_featureset_hvm]     = "HVM Default",
+    [XEN_SYSCTL_cpu_featureset_pv_max]  = "PV Max",
+    [XEN_SYSCTL_cpu_featureset_hvm_max] = "HVM Max",
 };
 
 static void dump_leaf(uint32_t leaf, const char *const *strs)
diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml
index 497ded7ce2..780cc71278 100644
--- a/tools/ocaml/libs/xc/xenctrl.ml
+++ b/tools/ocaml/libs/xc/xenctrl.ml
@@ -274,7 +274,13 @@ external version_changeset: handle -> string = "stub_xc_version_changeset"
 external version_capabilities: handle -> string =
   "stub_xc_version_capabilities"
 
-type featureset_index = Featureset_raw | Featureset_host | Featureset_pv | Featureset_hvm
+type featureset_index =
+  | Featureset_raw
+  | Featureset_host
+  | Featureset_pv
+  | Featureset_hvm
+  | Featureset_pv_max
+  | Featureset_hvm_max
 external get_cpu_featureset : handle -> featureset_index -> int64 array = "stub_xc_get_cpu_featureset"
 
 external watchdog : handle -> int -> int32 -> int
diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli
index 26ec7e59b1..508f4ae829 100644
--- a/tools/ocaml/libs/xc/xenctrl.mli
+++ b/tools/ocaml/libs/xc/xenctrl.mli
@@ -212,7 +212,13 @@ external version_changeset : handle -> string = "stub_xc_version_changeset"
 external version_capabilities : handle -> string
   = "stub_xc_version_capabilities"
 
-type featureset_index = Featureset_raw | Featureset_host | Featureset_pv | Featureset_hvm
+type featureset_index =
+  | Featureset_raw
+  | Featureset_host
+  | Featureset_pv
+  | Featureset_hvm
+  | Featureset_pv_max
+  | Featureset_hvm_max
 external get_cpu_featureset : handle -> featureset_index -> int64 array = "stub_xc_get_cpu_featureset"
 
 external pages_to_kib : int64 -> int64 = "stub_pages_to_kib"
diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c
index b0cb1b57e7..dc105cb463 100644
--- a/xen/arch/x86/sysctl.c
+++ b/xen/arch/x86/sysctl.c
@@ -357,14 +357,16 @@ long arch_do_sysctl(
 
     case XEN_SYSCTL_get_cpu_featureset:
     {
-        static const struct cpuid_policy *const policy_table[4] = {
+        static const struct cpuid_policy *const policy_table[6] = {
             [XEN_SYSCTL_cpu_featureset_raw]  = &raw_cpuid_policy,
             [XEN_SYSCTL_cpu_featureset_host] = &host_cpuid_policy,
 #ifdef CONFIG_PV
             [XEN_SYSCTL_cpu_featureset_pv]   = &pv_def_cpuid_policy,
+            [XEN_SYSCTL_cpu_featureset_pv_max] = &pv_max_cpuid_policy,
 #endif
 #ifdef CONFIG_HVM
             [XEN_SYSCTL_cpu_featureset_hvm]  = &hvm_def_cpuid_policy,
+            [XEN_SYSCTL_cpu_featureset_hvm_max] = &hvm_max_cpuid_policy,
 #endif
         };
         const struct cpuid_policy *p = NULL;
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index 7439cc154f..9091b469e2 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -804,6 +804,8 @@ struct xen_sysctl_cpu_featureset {
 #define XEN_SYSCTL_cpu_featureset_host     1
 #define XEN_SYSCTL_cpu_featureset_pv       2
 #define XEN_SYSCTL_cpu_featureset_hvm      3
+#define XEN_SYSCTL_cpu_featureset_pv_max   4
+#define XEN_SYSCTL_cpu_featureset_hvm_max  5
     uint32_t index;       /* IN: Which featureset to query? */
     uint32_t nr_features; /* IN/OUT: Number of entries in/written to
                            * 'features', or the maximum number of features if
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:00:18 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:00:18 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680900.1059173 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGkC-0006Bs-Rm; Wed, 14 Feb 2024 15:00:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680900.1059173; Wed, 14 Feb 2024 15:00:16 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGkC-0006Bk-P6; Wed, 14 Feb 2024 15:00:16 +0000
Received: by outflank-mailman (input) for mailman id 680900;
 Wed, 14 Feb 2024 15:00:15 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkB-0006Ba-9B
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:15 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkB-0005iO-8L
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:15 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkB-0000RY-7U
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:15 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=9I9Z+QdWSzPy3WKanNX5xhYfHRTPTLTHrEXKd1/atcU=; b=uueOu7GTmdjkaLz6xeVKXjZNn+
	OpBvx9BcKjXgvyybbSWmDp9CFEnmuA9aFRFOtOIOn/qUpNBkThl7vDfWwxIsE2G8MhwIS1hylyrQt
	Fv4WtxlGpLbSMabvH7Cew9sTjatRTyiWe8y780kyt1wxGr9hmc5khaK5VJO1jSz5PRv4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86: Rename struct cpu_policy to struct old_cpuid_policy
Message-Id: <E1raGkB-0000RY-7U@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:00:15 +0000

commit edc64afe1757410c0afe71683ff23d0e0e6aed14
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Mar 28 20:31:33 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86: Rename struct cpu_policy to struct old_cpuid_policy
    
    We want to merge struct cpuid_policy and struct msr_policy together, and the
    result wants to be called struct cpu_policy.
    
    The current struct cpu_policy, being a pair of pointers, isn't terribly
    useful.  Rename the type to struct old_cpu_policy, but it will disappear
    entirely once the merge is complete.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit c2ec94c370f211d73f336ccfbdb32499f1b05f82)
---
 tools/tests/cpu-policy/test-cpu-policy.c | 4 ++--
 xen/arch/x86/domctl.c                    | 4 ++--
 xen/arch/x86/sysctl.c                    | 4 ++--
 xen/include/asm-x86/cpuid.h              | 2 +-
 xen/include/xen/lib/x86/cpu-policy.h     | 6 +++---
 xen/lib/x86/policy.c                     | 4 ++--
 6 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/tools/tests/cpu-policy/test-cpu-policy.c b/tools/tests/cpu-policy/test-cpu-policy.c
index 0fa209f1ea..d8af5581ab 100644
--- a/tools/tests/cpu-policy/test-cpu-policy.c
+++ b/tools/tests/cpu-policy/test-cpu-policy.c
@@ -585,7 +585,7 @@ static void test_is_compatible_success(void)
     for ( size_t i = 0; i < ARRAY_SIZE(tests); ++i )
     {
         struct test *t = &tests[i];
-        struct cpu_policy sys = {
+        struct old_cpu_policy sys = {
             &t->host_cpuid,
             &t->host_msr,
         }, new = {
@@ -637,7 +637,7 @@ static void test_is_compatible_failure(void)
     for ( size_t i = 0; i < ARRAY_SIZE(tests); ++i )
     {
         struct test *t = &tests[i];
-        struct cpu_policy sys = {
+        struct old_cpu_policy sys = {
             &t->host_cpuid,
             &t->host_msr,
         }, new = {
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 6f2c69788d..20855cb40d 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -219,8 +219,8 @@ void domain_cpu_policy_changed(struct domain *d)
 static int update_domain_cpu_policy(struct domain *d,
                                     xen_domctl_cpu_policy_t *xdpc)
 {
-    struct cpu_policy new = {};
-    const struct cpu_policy *sys = is_pv_domain(d)
+    struct old_cpu_policy new = {};
+    const struct old_cpu_policy *sys = is_pv_domain(d)
         ? &system_policies[XEN_SYSCTL_cpu_policy_pv_max]
         : &system_policies[XEN_SYSCTL_cpu_policy_hvm_max];
     struct cpu_policy_errors err = INIT_CPU_POLICY_ERRORS;
diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c
index dc105cb463..444aa82cc0 100644
--- a/xen/arch/x86/sysctl.c
+++ b/xen/arch/x86/sysctl.c
@@ -33,7 +33,7 @@
 #include <asm/psr.h>
 #include <asm/cpuid.h>
 
-const struct cpu_policy system_policies[6] = {
+const struct old_cpu_policy system_policies[6] = {
     [ XEN_SYSCTL_cpu_policy_raw ] = {
         &raw_cpuid_policy,
         &raw_msr_policy,
@@ -422,7 +422,7 @@ long arch_do_sysctl(
 
     case XEN_SYSCTL_get_cpu_policy:
     {
-        const struct cpu_policy *policy;
+        const struct old_cpu_policy *policy;
 
         /* Reserved field set, or bad policy index? */
         if ( sysctl->u.cpu_policy._rsvd ||
diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h
index 9c3637549a..49b3128f06 100644
--- a/xen/include/asm-x86/cpuid.h
+++ b/xen/include/asm-x86/cpuid.h
@@ -51,7 +51,7 @@ extern struct cpuid_policy raw_cpuid_policy, host_cpuid_policy,
     pv_max_cpuid_policy, pv_def_cpuid_policy,
     hvm_max_cpuid_policy, hvm_def_cpuid_policy;
 
-extern const struct cpu_policy system_policies[];
+extern const struct old_cpu_policy system_policies[];
 
 /* Check that all previously present features are still available. */
 bool recheck_cpu_features(unsigned int cpu);
diff --git a/xen/include/xen/lib/x86/cpu-policy.h b/xen/include/xen/lib/x86/cpu-policy.h
index 5a2c4c7b2d..3a5300d107 100644
--- a/xen/include/xen/lib/x86/cpu-policy.h
+++ b/xen/include/xen/lib/x86/cpu-policy.h
@@ -5,7 +5,7 @@
 #include <xen/lib/x86/cpuid.h>
 #include <xen/lib/x86/msr.h>
 
-struct cpu_policy
+struct old_cpu_policy
 {
     struct cpuid_policy *cpuid;
     struct msr_policy *msr;
@@ -33,8 +33,8 @@ struct cpu_policy_errors
  * incompatibility is detected, the optional err pointer may identify the
  * problematic leaf/subleaf and/or MSR.
  */
-int x86_cpu_policies_are_compatible(const struct cpu_policy *host,
-                                    const struct cpu_policy *guest,
+int x86_cpu_policies_are_compatible(const struct old_cpu_policy *host,
+                                    const struct old_cpu_policy *guest,
                                     struct cpu_policy_errors *err);
 
 #endif /* !XEN_LIB_X86_POLICIES_H */
diff --git a/xen/lib/x86/policy.c b/xen/lib/x86/policy.c
index 4beca8767a..cb2d3b8dfa 100644
--- a/xen/lib/x86/policy.c
+++ b/xen/lib/x86/policy.c
@@ -2,8 +2,8 @@
 
 #include <xen/lib/x86/cpu-policy.h>
 
-int x86_cpu_policies_are_compatible(const struct cpu_policy *host,
-                                    const struct cpu_policy *guest,
+int x86_cpu_policies_are_compatible(const struct old_cpu_policy *host,
+                                    const struct old_cpu_policy *guest,
                                     struct cpu_policy_errors *err)
 {
     struct cpu_policy_errors e = INIT_CPU_POLICY_ERRORS;
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:00:26 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:00:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680901.1059177 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGkM-0006EJ-TQ; Wed, 14 Feb 2024 15:00:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680901.1059177; Wed, 14 Feb 2024 15:00:26 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGkM-0006EC-QY; Wed, 14 Feb 2024 15:00:26 +0000
Received: by outflank-mailman (input) for mailman id 680901;
 Wed, 14 Feb 2024 15:00:25 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkL-0006Dz-CZ
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:25 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkL-0005iW-Bo
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:25 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkL-0000SA-Aw
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:25 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=7Sivdc2FQ5yfUUadnsLhGTP5dPMeVo+QKaBmDnubrJE=; b=r5ZrCUmtIbAIqv+N7vM56XX4IN
	ByXvghuC0jmxXkcIYxwSfylEJtckolu0ck7KIUtG/pkKinKoyMp6+uzf1xIsQRAry+/jzP/rcDG8P
	jQExgZAwU/LOsIO0AzO7tj9eJo/6qaPdrKpDykGnCYOyHXs/i6eIlQpmmCrGUsUwyeG4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86: Rename {domctl,sysctl}.cpu_policy.{cpuid,msr}_policy fields
Message-Id: <E1raGkL-0000SA-Aw@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:00:25 +0000

commit 3747c51a6803693a338999080b5bbda6a69ff2d3
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Mar 28 20:48:29 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86: Rename {domctl,sysctl}.cpu_policy.{cpuid,msr}_policy fields
    
    These weren't great names to begin with, and using {leaves,msrs} matches up
    better with the existing nr_{leaves,msr} parameters anyway.
    
    Furthermore, by renaming these fields we can get away with using some #define
    trickery to avoid the struct {cpuid,msr}_policy merge needing to happen in a
    single changeset.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 21e3ef57e0406b6b9a783f721f29df8f91a00f99)
    
    xen: Correct comments after renaming xen_{dom,sys}ctl_cpu_policy fields
    
    Fixes: 21e3ef57e040 ("x86: Rename {domctl,sysctl}.cpu_policy.{cpuid,msr}_policy fields")
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    (cherry picked from commit 6e06d229d538ea51b92dc189546c522f5e903511)
---
 tools/libxc/xc_cpuid_x86.c  | 12 ++++++------
 xen/arch/x86/domctl.c       | 12 ++++++------
 xen/arch/x86/sysctl.c       |  8 ++++----
 xen/include/public/domctl.h | 10 ++++------
 xen/include/public/sysctl.h | 14 ++++++--------
 5 files changed, 26 insertions(+), 30 deletions(-)

diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index a0202ecbc9..08e8772417 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -148,9 +148,9 @@ int xc_get_system_cpu_policy(xc_interface *xch, uint32_t index,
     sysctl.cmd = XEN_SYSCTL_get_cpu_policy;
     sysctl.u.cpu_policy.index = index;
     sysctl.u.cpu_policy.nr_leaves = *nr_leaves;
-    set_xen_guest_handle(sysctl.u.cpu_policy.cpuid_policy, leaves);
+    set_xen_guest_handle(sysctl.u.cpu_policy.leaves, leaves);
     sysctl.u.cpu_policy.nr_msrs = *nr_msrs;
-    set_xen_guest_handle(sysctl.u.cpu_policy.msr_policy, msrs);
+    set_xen_guest_handle(sysctl.u.cpu_policy.msrs, msrs);
 
     ret = do_sysctl(xch, &sysctl);
 
@@ -186,9 +186,9 @@ int xc_get_domain_cpu_policy(xc_interface *xch, uint32_t domid,
     domctl.cmd = XEN_DOMCTL_get_cpu_policy;
     domctl.domain = domid;
     domctl.u.cpu_policy.nr_leaves = *nr_leaves;
-    set_xen_guest_handle(domctl.u.cpu_policy.cpuid_policy, leaves);
+    set_xen_guest_handle(domctl.u.cpu_policy.leaves, leaves);
     domctl.u.cpu_policy.nr_msrs = *nr_msrs;
-    set_xen_guest_handle(domctl.u.cpu_policy.msr_policy, msrs);
+    set_xen_guest_handle(domctl.u.cpu_policy.msrs, msrs);
 
     ret = do_domctl(xch, &domctl);
 
@@ -235,9 +235,9 @@ int xc_set_domain_cpu_policy(xc_interface *xch, uint32_t domid,
     domctl.cmd = XEN_DOMCTL_set_cpu_policy;
     domctl.domain = domid;
     domctl.u.cpu_policy.nr_leaves = nr_leaves;
-    set_xen_guest_handle(domctl.u.cpu_policy.cpuid_policy, leaves);
+    set_xen_guest_handle(domctl.u.cpu_policy.leaves, leaves);
     domctl.u.cpu_policy.nr_msrs = nr_msrs;
-    set_xen_guest_handle(domctl.u.cpu_policy.msr_policy, msrs);
+    set_xen_guest_handle(domctl.u.cpu_policy.msrs, msrs);
     domctl.u.cpu_policy.err_leaf = -1;
     domctl.u.cpu_policy.err_subleaf = -1;
     domctl.u.cpu_policy.err_msr = -1;
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 20855cb40d..64a4e17f88 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -233,10 +233,10 @@ static int update_domain_cpu_policy(struct domain *d,
 
     /* Merge the toolstack provided data. */
     if ( (ret = x86_cpuid_copy_from_buffer(
-              new.cpuid, xdpc->cpuid_policy, xdpc->nr_leaves,
+              new.cpuid, xdpc->leaves, xdpc->nr_leaves,
               &err.leaf, &err.subleaf)) ||
          (ret = x86_msr_copy_from_buffer(
-              new.msr, xdpc->msr_policy, xdpc->nr_msrs, &err.msr)) )
+              new.msr, xdpc->msrs, xdpc->nr_msrs, &err.msr)) )
         goto out;
 
     /* Trim any newly-stale out-of-range leaves. */
@@ -1451,20 +1451,20 @@ long arch_do_domctl(
 
     case XEN_DOMCTL_get_cpu_policy:
         /* Process the CPUID leaves. */
-        if ( guest_handle_is_null(domctl->u.cpu_policy.cpuid_policy) )
+        if ( guest_handle_is_null(domctl->u.cpu_policy.leaves) )
             domctl->u.cpu_policy.nr_leaves = CPUID_MAX_SERIALISED_LEAVES;
         else if ( (ret = x86_cpuid_copy_to_buffer(
                        d->arch.cpuid,
-                       domctl->u.cpu_policy.cpuid_policy,
+                       domctl->u.cpu_policy.leaves,
                        &domctl->u.cpu_policy.nr_leaves)) )
             break;
 
         /* Process the MSR entries. */
-        if ( guest_handle_is_null(domctl->u.cpu_policy.msr_policy) )
+        if ( guest_handle_is_null(domctl->u.cpu_policy.msrs) )
             domctl->u.cpu_policy.nr_msrs = MSR_MAX_SERIALISED_ENTRIES;
         else if ( (ret = x86_msr_copy_to_buffer(
                        d->arch.msr,
-                       domctl->u.cpu_policy.msr_policy,
+                       domctl->u.cpu_policy.msrs,
                        &domctl->u.cpu_policy.nr_msrs)) )
             break;
 
diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c
index 444aa82cc0..04e90c596a 100644
--- a/xen/arch/x86/sysctl.c
+++ b/xen/arch/x86/sysctl.c
@@ -442,11 +442,11 @@ long arch_do_sysctl(
         }
 
         /* Process the CPUID leaves. */
-        if ( guest_handle_is_null(sysctl->u.cpu_policy.cpuid_policy) )
+        if ( guest_handle_is_null(sysctl->u.cpu_policy.leaves) )
             sysctl->u.cpu_policy.nr_leaves = CPUID_MAX_SERIALISED_LEAVES;
         else if ( (ret = x86_cpuid_copy_to_buffer(
                        policy->cpuid,
-                       sysctl->u.cpu_policy.cpuid_policy,
+                       sysctl->u.cpu_policy.leaves,
                        &sysctl->u.cpu_policy.nr_leaves)) )
             break;
 
@@ -458,11 +458,11 @@ long arch_do_sysctl(
         }
 
         /* Process the MSR entries. */
-        if ( guest_handle_is_null(sysctl->u.cpu_policy.msr_policy) )
+        if ( guest_handle_is_null(sysctl->u.cpu_policy.msrs) )
             sysctl->u.cpu_policy.nr_msrs = MSR_MAX_SERIALISED_ENTRIES;
         else if ( (ret = x86_msr_copy_to_buffer(
                        policy->msr,
-                       sysctl->u.cpu_policy.msr_policy,
+                       sysctl->u.cpu_policy.msrs,
                        &sysctl->u.cpu_policy.nr_msrs)) )
             break;
 
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index f416722491..11b96e27ec 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -673,12 +673,10 @@ struct xen_domctl_set_target {
  * Query or set the CPUID and MSR policies for a specific domain.
  */
 struct xen_domctl_cpu_policy {
-    uint32_t nr_leaves; /* IN/OUT: Number of leaves in/written to
-                         * 'cpuid_policy'. */
-    uint32_t nr_msrs;   /* IN/OUT: Number of MSRs in/written to
-                         * 'msr_policy' */
-    XEN_GUEST_HANDLE_64(xen_cpuid_leaf_t) cpuid_policy; /* IN/OUT */
-    XEN_GUEST_HANDLE_64(xen_msr_entry_t) msr_policy;    /* IN/OUT */
+    uint32_t nr_leaves; /* IN/OUT: Number of leaves in/written to 'leaves' */
+    uint32_t nr_msrs;   /* IN/OUT: Number of MSRs in/written to 'msrs' */
+    XEN_GUEST_HANDLE_64(xen_cpuid_leaf_t) leaves; /* IN/OUT */
+    XEN_GUEST_HANDLE_64(xen_msr_entry_t)  msrs;   /* IN/OUT */
 
     /*
      * OUT, set_policy only.  Written in some (but not all) error cases to
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index 9091b469e2..72d41802bb 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -1051,15 +1051,13 @@ struct xen_sysctl_cpu_policy {
 #define XEN_SYSCTL_cpu_policy_pv_default   4
 #define XEN_SYSCTL_cpu_policy_hvm_default  5
     uint32_t index;       /* IN: Which policy to query? */
-    uint32_t nr_leaves;   /* IN/OUT: Number of leaves in/written to
-                           * 'cpuid_policy', or the maximum number of leaves
-                           * if the guest handle is NULL. */
-    uint32_t nr_msrs;     /* IN/OUT: Number of MSRs in/written to
-                           * 'msr_policy', or the maximum number of MSRs if
-                           * the guest handle is NULL. */
+    uint32_t nr_leaves;   /* IN/OUT: Number of leaves in/written to 'leaves',
+                           * or the max number if 'leaves' is NULL. */
+    uint32_t nr_msrs;     /* IN/OUT: Number of MSRs in/written to 'msrs', or
+                           * the max number of if 'msrs' is NULL. */
     uint32_t _rsvd;       /* Must be zero. */
-    XEN_GUEST_HANDLE_64(xen_cpuid_leaf_t) cpuid_policy; /* OUT */
-    XEN_GUEST_HANDLE_64(xen_msr_entry_t) msr_policy;    /* OUT */
+    XEN_GUEST_HANDLE_64(xen_cpuid_leaf_t) leaves; /* OUT */
+    XEN_GUEST_HANDLE_64(xen_msr_entry_t)  msrs;   /* OUT */
 };
 typedef struct xen_sysctl_cpu_policy xen_sysctl_cpu_policy_t;
 DEFINE_XEN_GUEST_HANDLE(xen_sysctl_cpu_policy_t);
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:00:37 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:00:37 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680902.1059181 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGkX-0006Hj-0f; Wed, 14 Feb 2024 15:00:37 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680902.1059181; Wed, 14 Feb 2024 15:00:36 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGkW-0006Hc-Th; Wed, 14 Feb 2024 15:00:36 +0000
Received: by outflank-mailman (input) for mailman id 680902;
 Wed, 14 Feb 2024 15:00:35 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkV-0006HP-G8
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:35 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkV-0005ic-FK
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:35 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkV-0000T5-EI
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:35 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=OOUvZPRudcta/+J/9PvvpdGm2AJ9UnbMRmED0UM9hhY=; b=Fhb7tL5SaDtv9Il2YLPbnsoJZ2
	FeB2uCjV/SRkkRQfjFWIp9WI6o2E1ert8NS8wn/7S7HWN45rQo8MgSoxUk+65aMru7Y36elQTxgA1
	bG0KVKiXbWGbroIky7cj8aB/W7HIvubEkS+Mn8sPfk+J7afGrShlILnIFt3MoBmjK/mY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86: Rename struct cpuid_policy to struct cpu_policy
Message-Id: <E1raGkV-0000T5-EI@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:00:35 +0000

commit 2e54fb9fec5a73e3dd47801eff37f91c23e94b64
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Mar 28 18:55:19 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86: Rename struct cpuid_policy to struct cpu_policy
    
    Also merge lib/x86/cpuid.h entirely into lib/x86/cpu-policy.h
    
    Use a temporary define to make struct cpuid_policy still work.
    
    There's one forward declaration of struct cpuid_policy in
    tools/tests/x86_emulator/x86-emulate.h that isn't covered by the define, and
    it's easier to rename that now than to rearrange the includes.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 743e530380a007774017df9dc2d8cb0659040ee3)
---
 tools/fuzz/cpu-policy/afl-policy-fuzzer.c    |   2 +-
 tools/fuzz/x86_instruction_emulator/Makefile |   2 +-
 tools/tests/x86_emulator/Makefile            |   2 +-
 tools/tests/x86_emulator/x86-emulate.h       |   2 +-
 xen/arch/x86/x86_emulate/x86_emulate.h       |   2 +-
 xen/include/asm-x86/cpuid.h                  |   1 -
 xen/include/xen/lib/x86/cpu-policy.h         | 463 +++++++++++++++++++++++++-
 xen/include/xen/lib/x86/cpuid.h              | 475 ---------------------------
 xen/lib/x86/cpuid.c                          |   2 +-
 9 files changed, 468 insertions(+), 483 deletions(-)

diff --git a/tools/fuzz/cpu-policy/afl-policy-fuzzer.c b/tools/fuzz/cpu-policy/afl-policy-fuzzer.c
index 79a849a044..7ebe8ee7c3 100644
--- a/tools/fuzz/cpu-policy/afl-policy-fuzzer.c
+++ b/tools/fuzz/cpu-policy/afl-policy-fuzzer.c
@@ -9,7 +9,7 @@
 #include <getopt.h>
 
 #include <xen-tools/libs.h>
-#include <xen/lib/x86/cpuid.h>
+#include <xen/lib/x86/cpu-policy.h>
 #include <xen/lib/x86/msr.h>
 #include <xen/domctl.h>
 
diff --git a/tools/fuzz/x86_instruction_emulator/Makefile b/tools/fuzz/x86_instruction_emulator/Makefile
index 1a6dbf94e1..2284887761 100644
--- a/tools/fuzz/x86_instruction_emulator/Makefile
+++ b/tools/fuzz/x86_instruction_emulator/Makefile
@@ -28,7 +28,7 @@ GCOV_FLAGS := --coverage
 x86.h := $(addprefix $(XEN_ROOT)/tools/include/xen/asm/,\
                      x86-vendors.h x86-defns.h msr-index.h) \
          $(addprefix $(XEN_ROOT)/tools/include/xen/lib/x86/, \
-                     cpuid.h cpuid-autogen.h)
+                     cpu-policy.h cpuid-autogen.h)
 x86_emulate.h := x86-emulate.h x86_emulate/x86_emulate.h $(x86.h)
 
 # x86-emulate.c will be implicit for both
diff --git a/tools/tests/x86_emulator/Makefile b/tools/tests/x86_emulator/Makefile
index 48b3e6dce1..18a3f3a9c0 100644
--- a/tools/tests/x86_emulator/Makefile
+++ b/tools/tests/x86_emulator/Makefile
@@ -286,7 +286,7 @@ HOSTCFLAGS += $(CFLAGS_xeninclude) -I. $(HOSTCFLAGS-$(XEN_COMPILE_ARCH))
 x86.h := $(addprefix $(XEN_ROOT)/tools/include/xen/asm/,\
                      x86-vendors.h x86-defns.h msr-index.h) \
          $(addprefix $(XEN_ROOT)/tools/include/xen/lib/x86/, \
-                     cpuid.h cpuid-autogen.h)
+                     cpu-policy.h cpuid-autogen.h)
 x86_emulate.h := x86-emulate.h x86_emulate/x86_emulate.h $(x86.h)
 
 x86-emulate.o cpuid.o test_x86_emulator.o evex-disp8.o predicates.o wrappers.o: %.o: %.c $(x86_emulate.h)
diff --git a/tools/tests/x86_emulator/x86-emulate.h b/tools/tests/x86_emulator/x86-emulate.h
index 6ea6cbc658..0ec065a59d 100644
--- a/tools/tests/x86_emulator/x86-emulate.h
+++ b/tools/tests/x86_emulator/x86-emulate.h
@@ -68,7 +68,7 @@
 #define is_canonical_address(x) (((int64_t)(x) >> 47) == ((int64_t)(x) >> 63))
 
 extern uint32_t mxcsr_mask;
-extern struct cpuid_policy cp;
+extern struct cpu_policy cp;
 
 #define MMAP_SZ 16384
 bool emul_test_init(void);
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.h b/xen/arch/x86/x86_emulate/x86_emulate.h
index d8fb3a9909..ce8226bd4c 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.h
+++ b/xen/arch/x86/x86_emulate/x86_emulate.h
@@ -23,7 +23,7 @@
 #ifndef __X86_EMULATE_H__
 #define __X86_EMULATE_H__
 
-#include <xen/lib/x86/cpuid.h>
+#include <xen/lib/x86/cpu-policy.h>
 
 #define MAX_INST_LEN 15
 
diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h
index 49b3128f06..d418e8100d 100644
--- a/xen/include/asm-x86/cpuid.h
+++ b/xen/include/asm-x86/cpuid.h
@@ -9,7 +9,6 @@
 #include <xen/percpu.h>
 
 #include <xen/lib/x86/cpu-policy.h>
-#include <xen/lib/x86/cpuid.h>
 
 #include <public/sysctl.h>
 
diff --git a/xen/include/xen/lib/x86/cpu-policy.h b/xen/include/xen/lib/x86/cpu-policy.h
index 3a5300d107..666505964d 100644
--- a/xen/include/xen/lib/x86/cpu-policy.h
+++ b/xen/include/xen/lib/x86/cpu-policy.h
@@ -2,9 +2,342 @@
 #ifndef XEN_LIB_X86_POLICIES_H
 #define XEN_LIB_X86_POLICIES_H
 
-#include <xen/lib/x86/cpuid.h>
+#include <xen/lib/x86/cpuid-autogen.h>
 #include <xen/lib/x86/msr.h>
 
+#define FEATURESET_1d     0 /* 0x00000001.edx      */
+#define FEATURESET_1c     1 /* 0x00000001.ecx      */
+#define FEATURESET_e1d    2 /* 0x80000001.edx      */
+#define FEATURESET_e1c    3 /* 0x80000001.ecx      */
+#define FEATURESET_Da1    4 /* 0x0000000d:1.eax    */
+#define FEATURESET_7b0    5 /* 0x00000007:0.ebx    */
+#define FEATURESET_7c0    6 /* 0x00000007:0.ecx    */
+#define FEATURESET_e7d    7 /* 0x80000007.edx      */
+#define FEATURESET_e8b    8 /* 0x80000008.ebx      */
+#define FEATURESET_7d0    9 /* 0x00000007:0.edx    */
+#define FEATURESET_7a1   10 /* 0x00000007:1.eax    */
+#define FEATURESET_e21a  11 /* 0x80000021.eax      */
+#define FEATURESET_7b1   12 /* 0x00000007:1.ebx    */
+#define FEATURESET_7d2   13 /* 0x00000007:2.edx    */
+#define FEATURESET_7c1   14 /* 0x00000007:1.ecx    */
+#define FEATURESET_7d1   15 /* 0x00000007:1.edx    */
+
+struct cpuid_leaf
+{
+    uint32_t a, b, c, d;
+};
+
+/*
+ * Versions of GCC before 5 unconditionally reserve %rBX as the PIC hard
+ * register, and are unable to cope with spilling it.  This results in a
+ * rather cryptic error:
+ *    error: inconsistent operand constraints in an ‘asm’
+ *
+ * In affected situations, work around the issue by using a separate register
+ * to hold the the %rBX output, and xchg twice to leave %rBX preserved around
+ * the asm() statement.
+ */
+#if defined(__PIC__) && __GNUC__ < 5 && !defined(__clang__) && defined(__i386__)
+# define XCHG_BX "xchg %%ebx, %[bx];"
+# define BX_CON [bx] "=&r"
+#elif defined(__PIC__) && __GNUC__ < 5 && !defined(__clang__) && \
+    defined(__x86_64__) && (defined(__code_model_medium__) || \
+                            defined(__code_model_large__))
+# define XCHG_BX "xchg %%rbx, %q[bx];"
+# define BX_CON [bx] "=&r"
+#else
+# define XCHG_BX ""
+# define BX_CON "=&b"
+#endif
+
+static inline void cpuid_leaf(uint32_t leaf, struct cpuid_leaf *l)
+{
+    asm ( XCHG_BX
+          "cpuid;"
+          XCHG_BX
+          : "=a" (l->a), BX_CON (l->b), "=&c" (l->c), "=&d" (l->d)
+          : "a" (leaf) );
+}
+
+static inline void cpuid_count_leaf(
+    uint32_t leaf, uint32_t subleaf, struct cpuid_leaf *l)
+{
+    asm ( XCHG_BX
+          "cpuid;"
+          XCHG_BX
+          : "=a" (l->a), BX_CON (l->b), "=c" (l->c), "=&d" (l->d)
+          : "a" (leaf), "c" (subleaf) );
+}
+
+#undef BX_CON
+#undef XCHG
+
+/**
+ * Given the vendor id from CPUID leaf 0, look up Xen's internal integer
+ * vendor ID.  Returns X86_VENDOR_UNKNOWN for any unknown vendor.
+ */
+unsigned int x86_cpuid_lookup_vendor(uint32_t ebx, uint32_t ecx, uint32_t edx);
+
+/**
+ * Given Xen's internal vendor ID, return a string suitable for printing.
+ * Returns "Unknown" for any unrecognised ID.
+ */
+const char *x86_cpuid_vendor_to_str(unsigned int vendor);
+
+#define CPUID_GUEST_NR_BASIC      (0xdu + 1)
+#define CPUID_GUEST_NR_CACHE      (5u + 1)
+#define CPUID_GUEST_NR_FEAT       (2u + 1)
+#define CPUID_GUEST_NR_TOPO       (1u + 1)
+#define CPUID_GUEST_NR_XSTATE     (62u + 1)
+#define CPUID_GUEST_NR_EXTD_INTEL (0x8u + 1)
+#define CPUID_GUEST_NR_EXTD_AMD   (0x21u + 1)
+#define CPUID_GUEST_NR_EXTD       MAX(CPUID_GUEST_NR_EXTD_INTEL, \
+                                      CPUID_GUEST_NR_EXTD_AMD)
+
+/*
+ * Maximum number of leaves a struct cpu_policy turns into when serialised for
+ * interaction with the toolstack.  (Sum of all leaves in each union, less the
+ * entries in basic which sub-unions hang off of.)
+ */
+#define CPUID_MAX_SERIALISED_LEAVES                     \
+    (CPUID_GUEST_NR_BASIC +                             \
+     CPUID_GUEST_NR_FEAT   - !!CPUID_GUEST_NR_FEAT +    \
+     CPUID_GUEST_NR_CACHE  - !!CPUID_GUEST_NR_CACHE +   \
+     CPUID_GUEST_NR_TOPO   - !!CPUID_GUEST_NR_TOPO +    \
+     CPUID_GUEST_NR_XSTATE - !!CPUID_GUEST_NR_XSTATE +  \
+     CPUID_GUEST_NR_EXTD + 2 /* hv_limit and hv2_limit */ )
+
+struct cpu_policy
+{
+#define DECL_BITFIELD(word) _DECL_BITFIELD(FEATURESET_ ## word)
+#define _DECL_BITFIELD(x)   __DECL_BITFIELD(x)
+#define __DECL_BITFIELD(x)  CPUID_BITFIELD_ ## x
+
+    /* Basic leaves: 0x000000xx */
+    union {
+        struct cpuid_leaf raw[CPUID_GUEST_NR_BASIC];
+        struct {
+            /* Leaf 0x0 - Max and vendor. */
+            uint32_t max_leaf, vendor_ebx, vendor_ecx, vendor_edx;
+
+            /* Leaf 0x1 - Family/model/stepping and features. */
+            uint32_t raw_fms;
+            uint8_t :8,       /* Brand ID. */
+                clflush_size, /* Number of 8-byte blocks per cache line. */
+                lppp,         /* Logical processors per package. */
+                apic_id;      /* Initial APIC ID. */
+            union {
+                uint32_t _1c;
+                struct { DECL_BITFIELD(1c); };
+            };
+            union {
+                uint32_t _1d;
+                struct { DECL_BITFIELD(1d); };
+            };
+
+            /* Leaf 0x2 - TLB/Cache/Prefetch. */
+            uint8_t l2_nr_queries; /* Documented as fixed to 1. */
+            uint8_t l2_desc[15];
+
+            uint64_t :64, :64; /* Leaf 0x3 - PSN. */
+            uint64_t :64, :64; /* Leaf 0x4 - Structured Cache. */
+            uint64_t :64, :64; /* Leaf 0x5 - MONITOR. */
+            uint64_t :64, :64; /* Leaf 0x6 - Therm/Perf. */
+            uint64_t :64, :64; /* Leaf 0x7 - Structured Features. */
+            uint64_t :64, :64; /* Leaf 0x8 - rsvd */
+            uint64_t :64, :64; /* Leaf 0x9 - DCA */
+
+            /* Leaf 0xa - Intel PMU. */
+            uint8_t pmu_version, _pmu[15];
+
+            uint64_t :64, :64; /* Leaf 0xb - Topology. */
+            uint64_t :64, :64; /* Leaf 0xc - rsvd */
+            uint64_t :64, :64; /* Leaf 0xd - XSTATE. */
+        };
+    } basic;
+
+    /* Structured cache leaf: 0x00000004[xx] */
+    union {
+        struct cpuid_leaf raw[CPUID_GUEST_NR_CACHE];
+        struct cpuid_cache_leaf {
+            uint32_t /* a */ type:5, level:3;
+            bool self_init:1, fully_assoc:1;
+            uint32_t :4, threads_per_cache:12, cores_per_package:6;
+            uint32_t /* b */ line_size:12, partitions:10, ways:10;
+            uint32_t /* c */ sets;
+            bool /* d */ wbinvd:1, inclusive:1, complex:1;
+        } subleaf[CPUID_GUEST_NR_CACHE];
+    } cache;
+
+    /* Structured feature leaf: 0x00000007[xx] */
+    union {
+        struct cpuid_leaf raw[CPUID_GUEST_NR_FEAT];
+        struct {
+            /* Subleaf 0. */
+            uint32_t max_subleaf;
+            union {
+                uint32_t _7b0;
+                struct { DECL_BITFIELD(7b0); };
+            };
+            union {
+                uint32_t _7c0;
+                struct { DECL_BITFIELD(7c0); };
+            };
+            union {
+                uint32_t _7d0;
+                struct { DECL_BITFIELD(7d0); };
+            };
+
+            /* Subleaf 1. */
+            union {
+                uint32_t _7a1;
+                struct { DECL_BITFIELD(7a1); };
+            };
+            union {
+                uint32_t _7b1;
+                struct { DECL_BITFIELD(7b1); };
+            };
+            union {
+                uint32_t _7c1;
+                struct { DECL_BITFIELD(7c1); };
+            };
+            union {
+                uint32_t _7d1;
+                struct { DECL_BITFIELD(7d1); };
+            };
+
+            /* Subleaf 2. */
+            uint32_t /* a */:32, /* b */:32, /* c */:32;
+            union {
+                uint32_t _7d2;
+                struct { DECL_BITFIELD(7d2); };
+            };
+        };
+    } feat;
+
+    /* Extended topology enumeration: 0x0000000B[xx] */
+    union {
+        struct cpuid_leaf raw[CPUID_GUEST_NR_TOPO];
+        struct cpuid_topo_leaf {
+            uint32_t id_shift:5, :27;
+            uint16_t nr_logical, :16;
+            uint8_t level, type, :8, :8;
+            uint32_t x2apic_id;
+        } subleaf[CPUID_GUEST_NR_TOPO];
+    } topo;
+
+    /* Xstate feature leaf: 0x0000000D[xx] */
+    union {
+        struct cpuid_leaf raw[CPUID_GUEST_NR_XSTATE];
+
+        struct {
+            /* Subleaf 0. */
+            uint32_t xcr0_low, /* b */:32, max_size, xcr0_high;
+
+            /* Subleaf 1. */
+            union {
+                uint32_t Da1;
+                struct { DECL_BITFIELD(Da1); };
+            };
+            uint32_t /* b */:32, xss_low, xss_high;
+        };
+
+        /* Per-component common state.  Valid for i >= 2. */
+        struct {
+            uint32_t size, offset;
+            bool xss:1, align:1;
+            uint32_t _res_d;
+        } comp[CPUID_GUEST_NR_XSTATE];
+    } xstate;
+
+    /* Extended leaves: 0x800000xx */
+    union {
+        struct cpuid_leaf raw[CPUID_GUEST_NR_EXTD];
+        struct {
+            /* Leaf 0x80000000 - Max and vendor. */
+            uint32_t max_leaf, vendor_ebx, vendor_ecx, vendor_edx;
+
+            /* Leaf 0x80000001 - Family/model/stepping and features. */
+            uint32_t raw_fms, /* b */:32;
+            union {
+                uint32_t e1c;
+                struct { DECL_BITFIELD(e1c); };
+            };
+            union {
+                uint32_t e1d;
+                struct { DECL_BITFIELD(e1d); };
+            };
+
+            uint64_t :64, :64; /* Brand string. */
+            uint64_t :64, :64; /* Brand string. */
+            uint64_t :64, :64; /* Brand string. */
+            uint64_t :64, :64; /* L1 cache/TLB. */
+            uint64_t :64, :64; /* L2/3 cache/TLB. */
+
+            /* Leaf 0x80000007 - Advanced Power Management. */
+            uint32_t /* a */:32, /* b */:32, /* c */:32;
+            union {
+                uint32_t e7d;
+                struct { DECL_BITFIELD(e7d); };
+            };
+
+            /* Leaf 0x80000008 - Misc addr/feature info. */
+            uint8_t maxphysaddr, maxlinaddr, :8, :8;
+            union {
+                uint32_t e8b;
+                struct { DECL_BITFIELD(e8b); };
+            };
+            uint32_t nc:8, :4, apic_id_size:4, :16;
+            uint32_t /* d */:32;
+
+            uint64_t :64, :64; /* Leaf 0x80000009. */
+            uint64_t :64, :64; /* Leaf 0x8000000a - SVM rev and features. */
+            uint64_t :64, :64; /* Leaf 0x8000000b. */
+            uint64_t :64, :64; /* Leaf 0x8000000c. */
+            uint64_t :64, :64; /* Leaf 0x8000000d. */
+            uint64_t :64, :64; /* Leaf 0x8000000e. */
+            uint64_t :64, :64; /* Leaf 0x8000000f. */
+            uint64_t :64, :64; /* Leaf 0x80000010. */
+            uint64_t :64, :64; /* Leaf 0x80000011. */
+            uint64_t :64, :64; /* Leaf 0x80000012. */
+            uint64_t :64, :64; /* Leaf 0x80000013. */
+            uint64_t :64, :64; /* Leaf 0x80000014. */
+            uint64_t :64, :64; /* Leaf 0x80000015. */
+            uint64_t :64, :64; /* Leaf 0x80000016. */
+            uint64_t :64, :64; /* Leaf 0x80000017. */
+            uint64_t :64, :64; /* Leaf 0x80000018. */
+            uint64_t :64, :64; /* Leaf 0x80000019 - TLB 1GB Identifiers. */
+            uint64_t :64, :64; /* Leaf 0x8000001a - Performance related info. */
+            uint64_t :64, :64; /* Leaf 0x8000001b - IBS feature information. */
+            uint64_t :64, :64; /* Leaf 0x8000001c. */
+            uint64_t :64, :64; /* Leaf 0x8000001d - Cache properties. */
+            uint64_t :64, :64; /* Leaf 0x8000001e - Extd APIC/Core/Node IDs. */
+            uint64_t :64, :64; /* Leaf 0x8000001f - AMD Secure Encryption. */
+            uint64_t :64, :64; /* Leaf 0x80000020 - Platform QoS. */
+
+            /* Leaf 0x80000021 - Extended Feature 2 */
+            union {
+                uint32_t e21a;
+                struct { DECL_BITFIELD(e21a); };
+            };
+            uint32_t /* b */:32, /* c */:32, /* d */:32;
+        };
+    } extd;
+
+#undef __DECL_BITFIELD
+#undef _DECL_BITFIELD
+#undef DECL_BITFIELD
+
+    /* Toolstack selected Hypervisor max_leaf (if non-zero). */
+    uint8_t hv_limit, hv2_limit;
+
+    /* Value calculated from raw data above. */
+    uint8_t x86_vendor;
+};
+
+/* Temporary */
+#define cpuid_policy cpu_policy
+
 struct old_cpu_policy
 {
     struct cpuid_policy *cpuid;
@@ -19,6 +352,134 @@ struct cpu_policy_errors
 
 #define INIT_CPU_POLICY_ERRORS { -1, -1, -1 }
 
+/* Fill in a featureset bitmap from a CPUID policy. */
+static inline void cpuid_policy_to_featureset(
+    const struct cpuid_policy *p, uint32_t fs[FEATURESET_NR_ENTRIES])
+{
+    fs[FEATURESET_1d]  = p->basic._1d;
+    fs[FEATURESET_1c]  = p->basic._1c;
+    fs[FEATURESET_e1d] = p->extd.e1d;
+    fs[FEATURESET_e1c] = p->extd.e1c;
+    fs[FEATURESET_Da1] = p->xstate.Da1;
+    fs[FEATURESET_7b0] = p->feat._7b0;
+    fs[FEATURESET_7c0] = p->feat._7c0;
+    fs[FEATURESET_e7d] = p->extd.e7d;
+    fs[FEATURESET_e8b] = p->extd.e8b;
+    fs[FEATURESET_7d0] = p->feat._7d0;
+    fs[FEATURESET_7a1] = p->feat._7a1;
+    fs[FEATURESET_e21a] = p->extd.e21a;
+    fs[FEATURESET_7b1] = p->feat._7b1;
+    fs[FEATURESET_7d2] = p->feat._7d2;
+    fs[FEATURESET_7c1] = p->feat._7c1;
+    fs[FEATURESET_7d1] = p->feat._7d1;
+}
+
+/* Fill in a CPUID policy from a featureset bitmap. */
+static inline void cpuid_featureset_to_policy(
+    const uint32_t fs[FEATURESET_NR_ENTRIES], struct cpuid_policy *p)
+{
+    p->basic._1d  = fs[FEATURESET_1d];
+    p->basic._1c  = fs[FEATURESET_1c];
+    p->extd.e1d   = fs[FEATURESET_e1d];
+    p->extd.e1c   = fs[FEATURESET_e1c];
+    p->xstate.Da1 = fs[FEATURESET_Da1];
+    p->feat._7b0  = fs[FEATURESET_7b0];
+    p->feat._7c0  = fs[FEATURESET_7c0];
+    p->extd.e7d   = fs[FEATURESET_e7d];
+    p->extd.e8b   = fs[FEATURESET_e8b];
+    p->feat._7d0  = fs[FEATURESET_7d0];
+    p->feat._7a1  = fs[FEATURESET_7a1];
+    p->extd.e21a  = fs[FEATURESET_e21a];
+    p->feat._7b1  = fs[FEATURESET_7b1];
+    p->feat._7d2  = fs[FEATURESET_7d2];
+    p->feat._7c1  = fs[FEATURESET_7c1];
+    p->feat._7d1  = fs[FEATURESET_7d1];
+}
+
+static inline uint64_t cpuid_policy_xcr0_max(const struct cpuid_policy *p)
+{
+    return ((uint64_t)p->xstate.xcr0_high << 32) | p->xstate.xcr0_low;
+}
+
+static inline uint64_t cpuid_policy_xstates(const struct cpuid_policy *p)
+{
+    uint64_t val = p->xstate.xcr0_high | p->xstate.xss_high;
+
+    return (val << 32) | p->xstate.xcr0_low | p->xstate.xss_low;
+}
+
+const uint32_t *x86_cpuid_lookup_deep_deps(uint32_t feature);
+
+/**
+ * Recalculate the content in a CPUID policy which is derived from raw data.
+ */
+void x86_cpuid_policy_recalc_synth(struct cpuid_policy *p);
+
+/**
+ * Fill a CPUID policy using the native CPUID instruction.
+ *
+ * No sanitisation is performed, but synthesised values are calculated.
+ * Values may be influenced by a hypervisor or from masking/faulting
+ * configuration.
+ */
+void x86_cpuid_policy_fill_native(struct cpuid_policy *p);
+
+/**
+ * Clear leaf data beyond the policies max leaf/subleaf settings.
+ *
+ * Policy serialisation purposefully omits out-of-range leaves, because there
+ * are a large number of them due to vendor differences.  However, when
+ * constructing new policies (e.g. levelling down), it is possible to end up
+ * with out-of-range leaves with stale content in them.  This helper clears
+ * them.
+ */
+void x86_cpuid_policy_clear_out_of_range_leaves(struct cpuid_policy *p);
+
+#ifdef __XEN__
+#include <public/arch-x86/xen.h>
+typedef XEN_GUEST_HANDLE_64(xen_cpuid_leaf_t) cpuid_leaf_buffer_t;
+#else
+#include <xen/arch-x86/xen.h>
+typedef xen_cpuid_leaf_t cpuid_leaf_buffer_t[];
+#endif
+
+/**
+ * Serialise a cpuid_policy object into an array of cpuid leaves.
+ *
+ * @param policy     The cpuid_policy to serialise.
+ * @param leaves     The array of leaves to serialise into.
+ * @param nr_entries The number of entries in 'leaves'.
+ * @returns -errno
+ *
+ * Writes at most CPUID_MAX_SERIALISED_LEAVES.  May fail with -ENOBUFS if the
+ * leaves array is too short.  On success, nr_entries is updated with the
+ * actual number of leaves written.
+ */
+int x86_cpuid_copy_to_buffer(const struct cpuid_policy *policy,
+                             cpuid_leaf_buffer_t leaves, uint32_t *nr_entries);
+
+/**
+ * Unserialise a cpuid_policy object from an array of cpuid leaves.
+ *
+ * @param policy      The cpuid_policy to unserialise into.
+ * @param leaves      The array of leaves to unserialise from.
+ * @param nr_entries  The number of entries in 'leaves'.
+ * @param err_leaf    Optional hint for error diagnostics.
+ * @param err_subleaf Optional hint for error diagnostics.
+ * @returns -errno
+ *
+ * Reads at most CPUID_MAX_SERIALISED_LEAVES.  May return -ERANGE if an
+ * incoming leaf is out of range of cpuid_policy, in which case the optional
+ * err_* pointers will identify the out-of-range indicies.
+ *
+ * No content validation of in-range leaves is performed.  Synthesised data is
+ * recalculated.
+ */
+int x86_cpuid_copy_from_buffer(struct cpuid_policy *policy,
+                               const cpuid_leaf_buffer_t leaves,
+                               uint32_t nr_entries, uint32_t *err_leaf,
+                               uint32_t *err_subleaf);
+
 /*
  * Calculate whether two policies are compatible.
  *
diff --git a/xen/include/xen/lib/x86/cpuid.h b/xen/include/xen/lib/x86/cpuid.h
deleted file mode 100644
index fa98b371ee..0000000000
--- a/xen/include/xen/lib/x86/cpuid.h
+++ /dev/null
@@ -1,475 +0,0 @@
-/* Common data structures and functions consumed by hypervisor and toolstack */
-#ifndef XEN_LIB_X86_CPUID_H
-#define XEN_LIB_X86_CPUID_H
-
-#include <xen/lib/x86/cpuid-autogen.h>
-
-#define FEATURESET_1d     0 /* 0x00000001.edx      */
-#define FEATURESET_1c     1 /* 0x00000001.ecx      */
-#define FEATURESET_e1d    2 /* 0x80000001.edx      */
-#define FEATURESET_e1c    3 /* 0x80000001.ecx      */
-#define FEATURESET_Da1    4 /* 0x0000000d:1.eax    */
-#define FEATURESET_7b0    5 /* 0x00000007:0.ebx    */
-#define FEATURESET_7c0    6 /* 0x00000007:0.ecx    */
-#define FEATURESET_e7d    7 /* 0x80000007.edx      */
-#define FEATURESET_e8b    8 /* 0x80000008.ebx      */
-#define FEATURESET_7d0    9 /* 0x00000007:0.edx    */
-#define FEATURESET_7a1   10 /* 0x00000007:1.eax    */
-#define FEATURESET_e21a  11 /* 0x80000021.eax      */
-#define FEATURESET_7b1   12 /* 0x00000007:1.ebx    */
-#define FEATURESET_7d2   13 /* 0x00000007:2.edx    */
-#define FEATURESET_7c1   14 /* 0x00000007:1.ecx    */
-#define FEATURESET_7d1   15 /* 0x00000007:1.edx    */
-
-struct cpuid_leaf
-{
-    uint32_t a, b, c, d;
-};
-
-/*
- * Versions of GCC before 5 unconditionally reserve %rBX as the PIC hard
- * register, and are unable to cope with spilling it.  This results in a
- * rather cryptic error:
- *    error: inconsistent operand constraints in an ‘asm’
- *
- * In affected situations, work around the issue by using a separate register
- * to hold the the %rBX output, and xchg twice to leave %rBX preserved around
- * the asm() statement.
- */
-#if defined(__PIC__) && __GNUC__ < 5 && !defined(__clang__) && defined(__i386__)
-# define XCHG_BX "xchg %%ebx, %[bx];"
-# define BX_CON [bx] "=&r"
-#elif defined(__PIC__) && __GNUC__ < 5 && !defined(__clang__) && \
-    defined(__x86_64__) && (defined(__code_model_medium__) || \
-                            defined(__code_model_large__))
-# define XCHG_BX "xchg %%rbx, %q[bx];"
-# define BX_CON [bx] "=&r"
-#else
-# define XCHG_BX ""
-# define BX_CON "=&b"
-#endif
-
-static inline void cpuid_leaf(uint32_t leaf, struct cpuid_leaf *l)
-{
-    asm ( XCHG_BX
-          "cpuid;"
-          XCHG_BX
-          : "=a" (l->a), BX_CON (l->b), "=&c" (l->c), "=&d" (l->d)
-          : "a" (leaf) );
-}
-
-static inline void cpuid_count_leaf(
-    uint32_t leaf, uint32_t subleaf, struct cpuid_leaf *l)
-{
-    asm ( XCHG_BX
-          "cpuid;"
-          XCHG_BX
-          : "=a" (l->a), BX_CON (l->b), "=c" (l->c), "=&d" (l->d)
-          : "a" (leaf), "c" (subleaf) );
-}
-
-#undef BX_CON
-#undef XCHG
-
-/**
- * Given the vendor id from CPUID leaf 0, look up Xen's internal integer
- * vendor ID.  Returns X86_VENDOR_UNKNOWN for any unknown vendor.
- */
-unsigned int x86_cpuid_lookup_vendor(uint32_t ebx, uint32_t ecx, uint32_t edx);
-
-/**
- * Given Xen's internal vendor ID, return a string suitable for printing.
- * Returns "Unknown" for any unrecognised ID.
- */
-const char *x86_cpuid_vendor_to_str(unsigned int vendor);
-
-#define CPUID_GUEST_NR_BASIC      (0xdu + 1)
-#define CPUID_GUEST_NR_CACHE      (5u + 1)
-#define CPUID_GUEST_NR_FEAT       (2u + 1)
-#define CPUID_GUEST_NR_TOPO       (1u + 1)
-#define CPUID_GUEST_NR_XSTATE     (62u + 1)
-#define CPUID_GUEST_NR_EXTD_INTEL (0x8u + 1)
-#define CPUID_GUEST_NR_EXTD_AMD   (0x21u + 1)
-#define CPUID_GUEST_NR_EXTD       MAX(CPUID_GUEST_NR_EXTD_INTEL, \
-                                      CPUID_GUEST_NR_EXTD_AMD)
-
-/*
- * Maximum number of leaves a struct cpuid_policy turns into when serialised
- * for interaction with the toolstack.  (Sum of all leaves in each union, less
- * the entries in basic which sub-unions hang off of.)
- */
-#define CPUID_MAX_SERIALISED_LEAVES                     \
-    (CPUID_GUEST_NR_BASIC +                             \
-     CPUID_GUEST_NR_FEAT   - !!CPUID_GUEST_NR_FEAT +    \
-     CPUID_GUEST_NR_CACHE  - !!CPUID_GUEST_NR_CACHE +   \
-     CPUID_GUEST_NR_TOPO   - !!CPUID_GUEST_NR_TOPO +    \
-     CPUID_GUEST_NR_XSTATE - !!CPUID_GUEST_NR_XSTATE +  \
-     CPUID_GUEST_NR_EXTD + 2 /* hv_limit and hv2_limit */ )
-
-struct cpuid_policy
-{
-#define DECL_BITFIELD(word) _DECL_BITFIELD(FEATURESET_ ## word)
-#define _DECL_BITFIELD(x)   __DECL_BITFIELD(x)
-#define __DECL_BITFIELD(x)  CPUID_BITFIELD_ ## x
-
-    /* Basic leaves: 0x000000xx */
-    union {
-        struct cpuid_leaf raw[CPUID_GUEST_NR_BASIC];
-        struct {
-            /* Leaf 0x0 - Max and vendor. */
-            uint32_t max_leaf, vendor_ebx, vendor_ecx, vendor_edx;
-
-            /* Leaf 0x1 - Family/model/stepping and features. */
-            uint32_t raw_fms;
-            uint8_t :8,       /* Brand ID. */
-                clflush_size, /* Number of 8-byte blocks per cache line. */
-                lppp,         /* Logical processors per package. */
-                apic_id;      /* Initial APIC ID. */
-            union {
-                uint32_t _1c;
-                struct { DECL_BITFIELD(1c); };
-            };
-            union {
-                uint32_t _1d;
-                struct { DECL_BITFIELD(1d); };
-            };
-
-            /* Leaf 0x2 - TLB/Cache/Prefetch. */
-            uint8_t l2_nr_queries; /* Documented as fixed to 1. */
-            uint8_t l2_desc[15];
-
-            uint64_t :64, :64; /* Leaf 0x3 - PSN. */
-            uint64_t :64, :64; /* Leaf 0x4 - Structured Cache. */
-            uint64_t :64, :64; /* Leaf 0x5 - MONITOR. */
-            uint64_t :64, :64; /* Leaf 0x6 - Therm/Perf. */
-            uint64_t :64, :64; /* Leaf 0x7 - Structured Features. */
-            uint64_t :64, :64; /* Leaf 0x8 - rsvd */
-            uint64_t :64, :64; /* Leaf 0x9 - DCA */
-
-            /* Leaf 0xa - Intel PMU. */
-            uint8_t pmu_version, _pmu[15];
-
-            uint64_t :64, :64; /* Leaf 0xb - Topology. */
-            uint64_t :64, :64; /* Leaf 0xc - rsvd */
-            uint64_t :64, :64; /* Leaf 0xd - XSTATE. */
-        };
-    } basic;
-
-    /* Structured cache leaf: 0x00000004[xx] */
-    union {
-        struct cpuid_leaf raw[CPUID_GUEST_NR_CACHE];
-        struct cpuid_cache_leaf {
-            uint32_t /* a */ type:5, level:3;
-            bool self_init:1, fully_assoc:1;
-            uint32_t :4, threads_per_cache:12, cores_per_package:6;
-            uint32_t /* b */ line_size:12, partitions:10, ways:10;
-            uint32_t /* c */ sets;
-            bool /* d */ wbinvd:1, inclusive:1, complex:1;
-        } subleaf[CPUID_GUEST_NR_CACHE];
-    } cache;
-
-    /* Structured feature leaf: 0x00000007[xx] */
-    union {
-        struct cpuid_leaf raw[CPUID_GUEST_NR_FEAT];
-        struct {
-            /* Subleaf 0. */
-            uint32_t max_subleaf;
-            union {
-                uint32_t _7b0;
-                struct { DECL_BITFIELD(7b0); };
-            };
-            union {
-                uint32_t _7c0;
-                struct { DECL_BITFIELD(7c0); };
-            };
-            union {
-                uint32_t _7d0;
-                struct { DECL_BITFIELD(7d0); };
-            };
-
-            /* Subleaf 1. */
-            union {
-                uint32_t _7a1;
-                struct { DECL_BITFIELD(7a1); };
-            };
-            union {
-                uint32_t _7b1;
-                struct { DECL_BITFIELD(7b1); };
-            };
-            union {
-                uint32_t _7c1;
-                struct { DECL_BITFIELD(7c1); };
-            };
-            union {
-                uint32_t _7d1;
-                struct { DECL_BITFIELD(7d1); };
-            };
-
-            /* Subleaf 2. */
-            uint32_t /* a */:32, /* b */:32, /* c */:32;
-            union {
-                uint32_t _7d2;
-                struct { DECL_BITFIELD(7d2); };
-            };
-        };
-    } feat;
-
-    /* Extended topology enumeration: 0x0000000B[xx] */
-    union {
-        struct cpuid_leaf raw[CPUID_GUEST_NR_TOPO];
-        struct cpuid_topo_leaf {
-            uint32_t id_shift:5, :27;
-            uint16_t nr_logical, :16;
-            uint8_t level, type, :8, :8;
-            uint32_t x2apic_id;
-        } subleaf[CPUID_GUEST_NR_TOPO];
-    } topo;
-
-    /* Xstate feature leaf: 0x0000000D[xx] */
-    union {
-        struct cpuid_leaf raw[CPUID_GUEST_NR_XSTATE];
-
-        struct {
-            /* Subleaf 0. */
-            uint32_t xcr0_low, /* b */:32, max_size, xcr0_high;
-
-            /* Subleaf 1. */
-            union {
-                uint32_t Da1;
-                struct { DECL_BITFIELD(Da1); };
-            };
-            uint32_t /* b */:32, xss_low, xss_high;
-        };
-
-        /* Per-component common state.  Valid for i >= 2. */
-        struct {
-            uint32_t size, offset;
-            bool xss:1, align:1;
-            uint32_t _res_d;
-        } comp[CPUID_GUEST_NR_XSTATE];
-    } xstate;
-
-    /* Extended leaves: 0x800000xx */
-    union {
-        struct cpuid_leaf raw[CPUID_GUEST_NR_EXTD];
-        struct {
-            /* Leaf 0x80000000 - Max and vendor. */
-            uint32_t max_leaf, vendor_ebx, vendor_ecx, vendor_edx;
-
-            /* Leaf 0x80000001 - Family/model/stepping and features. */
-            uint32_t raw_fms, /* b */:32;
-            union {
-                uint32_t e1c;
-                struct { DECL_BITFIELD(e1c); };
-            };
-            union {
-                uint32_t e1d;
-                struct { DECL_BITFIELD(e1d); };
-            };
-
-            uint64_t :64, :64; /* Brand string. */
-            uint64_t :64, :64; /* Brand string. */
-            uint64_t :64, :64; /* Brand string. */
-            uint64_t :64, :64; /* L1 cache/TLB. */
-            uint64_t :64, :64; /* L2/3 cache/TLB. */
-
-            /* Leaf 0x80000007 - Advanced Power Management. */
-            uint32_t /* a */:32, /* b */:32, /* c */:32;
-            union {
-                uint32_t e7d;
-                struct { DECL_BITFIELD(e7d); };
-            };
-
-            /* Leaf 0x80000008 - Misc addr/feature info. */
-            uint8_t maxphysaddr, maxlinaddr, :8, :8;
-            union {
-                uint32_t e8b;
-                struct { DECL_BITFIELD(e8b); };
-            };
-            uint32_t nc:8, :4, apic_id_size:4, :16;
-            uint32_t /* d */:32;
-
-            uint64_t :64, :64; /* Leaf 0x80000009. */
-            uint64_t :64, :64; /* Leaf 0x8000000a - SVM rev and features. */
-            uint64_t :64, :64; /* Leaf 0x8000000b. */
-            uint64_t :64, :64; /* Leaf 0x8000000c. */
-            uint64_t :64, :64; /* Leaf 0x8000000d. */
-            uint64_t :64, :64; /* Leaf 0x8000000e. */
-            uint64_t :64, :64; /* Leaf 0x8000000f. */
-            uint64_t :64, :64; /* Leaf 0x80000010. */
-            uint64_t :64, :64; /* Leaf 0x80000011. */
-            uint64_t :64, :64; /* Leaf 0x80000012. */
-            uint64_t :64, :64; /* Leaf 0x80000013. */
-            uint64_t :64, :64; /* Leaf 0x80000014. */
-            uint64_t :64, :64; /* Leaf 0x80000015. */
-            uint64_t :64, :64; /* Leaf 0x80000016. */
-            uint64_t :64, :64; /* Leaf 0x80000017. */
-            uint64_t :64, :64; /* Leaf 0x80000018. */
-            uint64_t :64, :64; /* Leaf 0x80000019 - TLB 1GB Identifiers. */
-            uint64_t :64, :64; /* Leaf 0x8000001a - Performance related info. */
-            uint64_t :64, :64; /* Leaf 0x8000001b - IBS feature information. */
-            uint64_t :64, :64; /* Leaf 0x8000001c. */
-            uint64_t :64, :64; /* Leaf 0x8000001d - Cache properties. */
-            uint64_t :64, :64; /* Leaf 0x8000001e - Extd APIC/Core/Node IDs. */
-            uint64_t :64, :64; /* Leaf 0x8000001f - AMD Secure Encryption. */
-            uint64_t :64, :64; /* Leaf 0x80000020 - Platform QoS. */
-
-            /* Leaf 0x80000021 - Extended Feature 2 */
-            union {
-                uint32_t e21a;
-                struct { DECL_BITFIELD(e21a); };
-            };
-            uint32_t /* b */:32, /* c */:32, /* d */:32;
-        };
-    } extd;
-
-#undef __DECL_BITFIELD
-#undef _DECL_BITFIELD
-#undef DECL_BITFIELD
-
-    /* Toolstack selected Hypervisor max_leaf (if non-zero). */
-    uint8_t hv_limit, hv2_limit;
-
-    /* Value calculated from raw data above. */
-    uint8_t x86_vendor;
-};
-
-/* Fill in a featureset bitmap from a CPUID policy. */
-static inline void cpuid_policy_to_featureset(
-    const struct cpuid_policy *p, uint32_t fs[FEATURESET_NR_ENTRIES])
-{
-    fs[FEATURESET_1d]  = p->basic._1d;
-    fs[FEATURESET_1c]  = p->basic._1c;
-    fs[FEATURESET_e1d] = p->extd.e1d;
-    fs[FEATURESET_e1c] = p->extd.e1c;
-    fs[FEATURESET_Da1] = p->xstate.Da1;
-    fs[FEATURESET_7b0] = p->feat._7b0;
-    fs[FEATURESET_7c0] = p->feat._7c0;
-    fs[FEATURESET_e7d] = p->extd.e7d;
-    fs[FEATURESET_e8b] = p->extd.e8b;
-    fs[FEATURESET_7d0] = p->feat._7d0;
-    fs[FEATURESET_7a1] = p->feat._7a1;
-    fs[FEATURESET_e21a] = p->extd.e21a;
-    fs[FEATURESET_7b1] = p->feat._7b1;
-    fs[FEATURESET_7d2] = p->feat._7d2;
-    fs[FEATURESET_7c1] = p->feat._7c1;
-    fs[FEATURESET_7d1] = p->feat._7d1;
-}
-
-/* Fill in a CPUID policy from a featureset bitmap. */
-static inline void cpuid_featureset_to_policy(
-    const uint32_t fs[FEATURESET_NR_ENTRIES], struct cpuid_policy *p)
-{
-    p->basic._1d  = fs[FEATURESET_1d];
-    p->basic._1c  = fs[FEATURESET_1c];
-    p->extd.e1d   = fs[FEATURESET_e1d];
-    p->extd.e1c   = fs[FEATURESET_e1c];
-    p->xstate.Da1 = fs[FEATURESET_Da1];
-    p->feat._7b0  = fs[FEATURESET_7b0];
-    p->feat._7c0  = fs[FEATURESET_7c0];
-    p->extd.e7d   = fs[FEATURESET_e7d];
-    p->extd.e8b   = fs[FEATURESET_e8b];
-    p->feat._7d0  = fs[FEATURESET_7d0];
-    p->feat._7a1  = fs[FEATURESET_7a1];
-    p->extd.e21a  = fs[FEATURESET_e21a];
-    p->feat._7b1  = fs[FEATURESET_7b1];
-    p->feat._7d2  = fs[FEATURESET_7d2];
-    p->feat._7c1  = fs[FEATURESET_7c1];
-    p->feat._7d1  = fs[FEATURESET_7d1];
-}
-
-static inline uint64_t cpuid_policy_xcr0_max(const struct cpuid_policy *p)
-{
-    return ((uint64_t)p->xstate.xcr0_high << 32) | p->xstate.xcr0_low;
-}
-
-static inline uint64_t cpuid_policy_xstates(const struct cpuid_policy *p)
-{
-    uint64_t val = p->xstate.xcr0_high | p->xstate.xss_high;
-
-    return (val << 32) | p->xstate.xcr0_low | p->xstate.xss_low;
-}
-
-const uint32_t *x86_cpuid_lookup_deep_deps(uint32_t feature);
-
-/**
- * Recalculate the content in a CPUID policy which is derived from raw data.
- */
-void x86_cpuid_policy_recalc_synth(struct cpuid_policy *p);
-
-/**
- * Fill a CPUID policy using the native CPUID instruction.
- *
- * No sanitisation is performed, but synthesised values are calculated.
- * Values may be influenced by a hypervisor or from masking/faulting
- * configuration.
- */
-void x86_cpuid_policy_fill_native(struct cpuid_policy *p);
-
-/**
- * Clear leaf data beyond the policies max leaf/subleaf settings.
- *
- * Policy serialisation purposefully omits out-of-range leaves, because there
- * are a large number of them due to vendor differences.  However, when
- * constructing new policies (e.g. levelling down), it is possible to end up
- * with out-of-range leaves with stale content in them.  This helper clears
- * them.
- */
-void x86_cpuid_policy_clear_out_of_range_leaves(struct cpuid_policy *p);
-
-#ifdef __XEN__
-#include <public/arch-x86/xen.h>
-typedef XEN_GUEST_HANDLE_64(xen_cpuid_leaf_t) cpuid_leaf_buffer_t;
-#else
-#include <xen/arch-x86/xen.h>
-typedef xen_cpuid_leaf_t cpuid_leaf_buffer_t[];
-#endif
-
-/**
- * Serialise a cpuid_policy object into an array of cpuid leaves.
- *
- * @param policy     The cpuid_policy to serialise.
- * @param leaves     The array of leaves to serialise into.
- * @param nr_entries The number of entries in 'leaves'.
- * @returns -errno
- *
- * Writes at most CPUID_MAX_SERIALISED_LEAVES.  May fail with -ENOBUFS if the
- * leaves array is too short.  On success, nr_entries is updated with the
- * actual number of leaves written.
- */
-int x86_cpuid_copy_to_buffer(const struct cpuid_policy *policy,
-                             cpuid_leaf_buffer_t leaves, uint32_t *nr_entries);
-
-/**
- * Unserialise a cpuid_policy object from an array of cpuid leaves.
- *
- * @param policy      The cpuid_policy to unserialise into.
- * @param leaves      The array of leaves to unserialise from.
- * @param nr_entries  The number of entries in 'leaves'.
- * @param err_leaf    Optional hint for error diagnostics.
- * @param err_subleaf Optional hint for error diagnostics.
- * @returns -errno
- *
- * Reads at most CPUID_MAX_SERIALISED_LEAVES.  May return -ERANGE if an
- * incoming leaf is out of range of cpuid_policy, in which case the optional
- * err_* pointers will identify the out-of-range indicies.
- *
- * No content validation of in-range leaves is performed.  Synthesised data is
- * recalculated.
- */
-int x86_cpuid_copy_from_buffer(struct cpuid_policy *policy,
-                               const cpuid_leaf_buffer_t leaves,
-                               uint32_t nr_entries, uint32_t *err_leaf,
-                               uint32_t *err_subleaf);
-
-#endif /* !XEN_LIB_X86_CPUID_H */
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/lib/x86/cpuid.c b/xen/lib/x86/cpuid.c
index c7a0508148..b2def4c9bc 100644
--- a/xen/lib/x86/cpuid.c
+++ b/xen/lib/x86/cpuid.c
@@ -1,6 +1,6 @@
 #include "private.h"
 
-#include <xen/lib/x86/cpuid.h>
+#include <xen/lib/x86/cpu-policy.h>
 
 static void zero_leaves(struct cpuid_leaf *l,
                         unsigned int first, unsigned int last)
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:00:47 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:00:47 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680903.1059185 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGkh-0006MK-3t; Wed, 14 Feb 2024 15:00:47 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680903.1059185; Wed, 14 Feb 2024 15:00:47 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGkh-0006MD-1I; Wed, 14 Feb 2024 15:00:47 +0000
Received: by outflank-mailman (input) for mailman id 680903;
 Wed, 14 Feb 2024 15:00:45 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkf-0006M1-J6
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:45 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkf-0005kH-IK
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:45 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkf-0000Td-Hg
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:45 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=4pqnruenxr/W7+9U9Xpht8sxrHTGbVmBCiylh4figlY=; b=haitNj88wC+rpSskt0Ei6m28L7
	hfpRdGKohrQRqABo80BZzRTF+xi31syDRYT0dLBehwA05+hAxSgMas7rJHKr9J08jP5SUpah/RgBL
	SJqQ2udc+T8G+KAm7RqgqY1aIt/t2Q5RTed7P87l0Ly27ynLZ5OYnwGKF/GBYma2v3fA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86: Merge struct msr_policy into struct cpu_policy
Message-Id: <E1raGkf-0000Td-Hg@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:00:45 +0000

commit 63e4aa3d3b56d57f6d3d3a86d593f60e79e8a1ff
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Mar 28 21:24:20 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86: Merge struct msr_policy into struct cpu_policy
    
    As with the cpuid side, use a temporary define to make struct msr_policy still
    work.
    
    Note, this means that domains now have two separate struct cpu_policy
    allocations with disjoint information, and system policies are in a similar
    position, as well as xc_cpu_policy objects in libxenguest.  All of these
    duplications will be addressed in the following patches.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 03812da3754d550dd8cbee7289469069ea6f0073)
---
 tools/fuzz/cpu-policy/afl-policy-fuzzer.c |   1 -
 xen/include/asm-x86/msr.h                 |   3 +-
 xen/include/xen/lib/x86/cpu-policy.h      |  81 ++++++++++++++++++++++-
 xen/include/xen/lib/x86/msr.h             | 104 ------------------------------
 xen/lib/x86/msr.c                         |   2 +-
 5 files changed, 83 insertions(+), 108 deletions(-)

diff --git a/tools/fuzz/cpu-policy/afl-policy-fuzzer.c b/tools/fuzz/cpu-policy/afl-policy-fuzzer.c
index 7ebe8ee7c3..316eb0efe0 100644
--- a/tools/fuzz/cpu-policy/afl-policy-fuzzer.c
+++ b/tools/fuzz/cpu-policy/afl-policy-fuzzer.c
@@ -10,7 +10,6 @@
 
 #include <xen-tools/libs.h>
 #include <xen/lib/x86/cpu-policy.h>
-#include <xen/lib/x86/msr.h>
 #include <xen/domctl.h>
 
 static bool debug;
diff --git a/xen/include/asm-x86/msr.h b/xen/include/asm-x86/msr.h
index 743c40e2c0..86fe27cc14 100644
--- a/xen/include/asm-x86/msr.h
+++ b/xen/include/asm-x86/msr.h
@@ -6,8 +6,9 @@
 #include <xen/types.h>
 #include <xen/percpu.h>
 #include <xen/errno.h>
+#include <xen/kernel.h>
 
-#include <xen/lib/x86/msr.h>
+#include <xen/lib/x86/cpu-policy.h>
 
 #include <asm/asm_defns.h>
 #include <asm/cpufeature.h>
diff --git a/xen/include/xen/lib/x86/cpu-policy.h b/xen/include/xen/lib/x86/cpu-policy.h
index 666505964d..53fffca552 100644
--- a/xen/include/xen/lib/x86/cpu-policy.h
+++ b/xen/include/xen/lib/x86/cpu-policy.h
@@ -3,7 +3,6 @@
 #define XEN_LIB_X86_POLICIES_H
 
 #include <xen/lib/x86/cpuid-autogen.h>
-#include <xen/lib/x86/msr.h>
 
 #define FEATURESET_1d     0 /* 0x00000001.edx      */
 #define FEATURESET_1c     1 /* 0x00000001.ecx      */
@@ -107,6 +106,9 @@ const char *x86_cpuid_vendor_to_str(unsigned int vendor);
      CPUID_GUEST_NR_XSTATE - !!CPUID_GUEST_NR_XSTATE +  \
      CPUID_GUEST_NR_EXTD + 2 /* hv_limit and hv2_limit */ )
 
+/* Maximum number of MSRs written when serialising a cpu_policy. */
+#define MSR_MAX_SERIALISED_ENTRIES 2
+
 struct cpu_policy
 {
 #define DECL_BITFIELD(word) _DECL_BITFIELD(FEATURESET_ ## word)
@@ -324,6 +326,44 @@ struct cpu_policy
         };
     } extd;
 
+    /*
+     * 0x000000ce - MSR_INTEL_PLATFORM_INFO
+     *
+     * This MSR is non-architectural, but for simplicy we allow it to be read
+     * unconditionally.  CPUID Faulting support can be fully emulated for HVM
+     * guests so can be offered unconditionally, while support for PV guests
+     * is dependent on real hardware support.
+     */
+    union {
+        uint32_t raw;
+        struct {
+            uint32_t :31;
+            bool cpuid_faulting:1;
+        };
+    } platform_info;
+
+    /*
+     * 0x0000010a - MSR_ARCH_CAPABILITIES
+     *
+     * This is an Intel-only MSR, which provides miscellaneous enumeration,
+     * including those which indicate that microarchitectrual sidechannels are
+     * fixed in hardware.
+     */
+    union {
+        uint32_t raw;
+        struct {
+            bool rdcl_no:1;
+            bool ibrs_all:1;
+            bool rsba:1;
+            bool skip_l1dfl:1;
+            bool ssb_no:1;
+            bool mds_no:1;
+            bool if_pschange_mc_no:1;
+            bool tsx_ctrl:1;
+            bool taa_no:1;
+        };
+    } arch_caps;
+
 #undef __DECL_BITFIELD
 #undef _DECL_BITFIELD
 #undef DECL_BITFIELD
@@ -337,6 +377,7 @@ struct cpu_policy
 
 /* Temporary */
 #define cpuid_policy cpu_policy
+#define msr_policy cpu_policy
 
 struct old_cpu_policy
 {
@@ -438,9 +479,11 @@ void x86_cpuid_policy_clear_out_of_range_leaves(struct cpuid_policy *p);
 #ifdef __XEN__
 #include <public/arch-x86/xen.h>
 typedef XEN_GUEST_HANDLE_64(xen_cpuid_leaf_t) cpuid_leaf_buffer_t;
+typedef XEN_GUEST_HANDLE_64(xen_msr_entry_t) msr_entry_buffer_t;
 #else
 #include <xen/arch-x86/xen.h>
 typedef xen_cpuid_leaf_t cpuid_leaf_buffer_t[];
+typedef xen_msr_entry_t msr_entry_buffer_t[];
 #endif
 
 /**
@@ -480,6 +523,42 @@ int x86_cpuid_copy_from_buffer(struct cpuid_policy *policy,
                                uint32_t nr_entries, uint32_t *err_leaf,
                                uint32_t *err_subleaf);
 
+/**
+ * Serialise an msr_policy object into an array.
+ *
+ * @param policy     The msr_policy to serialise.
+ * @param msrs       The array of msrs to serialise into.
+ * @param nr_entries The number of entries in 'msrs'.
+ * @returns -errno
+ *
+ * Writes at most MSR_MAX_SERIALISED_ENTRIES.  May fail with -ENOBUFS if the
+ * buffer array is too short.  On success, nr_entries is updated with the
+ * actual number of msrs written.
+ */
+int x86_msr_copy_to_buffer(const struct msr_policy *policy,
+                           msr_entry_buffer_t msrs, uint32_t *nr_entries);
+
+/**
+ * Unserialise an msr_policy object from an array of msrs.
+ *
+ * @param policy     The msr_policy object to unserialise into.
+ * @param msrs       The array of msrs to unserialise from.
+ * @param nr_entries The number of entries in 'msrs'.
+ * @param err_msr    Optional hint for error diagnostics.
+ * @returns -errno
+ *
+ * Reads at most MSR_MAX_SERIALISED_ENTRIES.  May fail for a number of reasons
+ * based on the content in an individual 'msrs' entry, including the MSR index
+ * not being valid in the policy, the flags field being nonzero, or if the
+ * value provided would truncate when stored in the policy.  In such cases,
+ * the optional err_* pointer will identify the problematic MSR.
+ *
+ * No content validation is performed on the data stored in the policy object.
+ */
+int x86_msr_copy_from_buffer(struct msr_policy *policy,
+                             const msr_entry_buffer_t msrs, uint32_t nr_entries,
+                             uint32_t *err_msr);
+
 /*
  * Calculate whether two policies are compatible.
  *
diff --git a/xen/include/xen/lib/x86/msr.h b/xen/include/xen/lib/x86/msr.h
deleted file mode 100644
index 48ba4a59c0..0000000000
--- a/xen/include/xen/lib/x86/msr.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/* Common data structures and functions consumed by hypervisor and toolstack */
-#ifndef XEN_LIB_X86_MSR_H
-#define XEN_LIB_X86_MSR_H
-
-/* Maximum number of MSRs written when serialising msr_policy. */
-#define MSR_MAX_SERIALISED_ENTRIES 2
-
-/* MSR policy object for shared per-domain MSRs */
-struct msr_policy
-{
-    /*
-     * 0x000000ce - MSR_INTEL_PLATFORM_INFO
-     *
-     * This MSR is non-architectural, but for simplicy we allow it to be read
-     * unconditionally.  CPUID Faulting support can be fully emulated for HVM
-     * guests so can be offered unconditionally, while support for PV guests
-     * is dependent on real hardware support.
-     */
-    union {
-        uint32_t raw;
-        struct {
-            uint32_t :31;
-            bool cpuid_faulting:1;
-        };
-    } platform_info;
-
-    /*
-     * 0x0000010a - MSR_ARCH_CAPABILITIES
-     *
-     * This is an Intel-only MSR, which provides miscellaneous enumeration,
-     * including those which indicate that microarchitectrual sidechannels are
-     * fixed in hardware.
-     */
-    union {
-        uint32_t raw;
-        struct {
-            bool rdcl_no:1;
-            bool ibrs_all:1;
-            bool rsba:1;
-            bool skip_l1dfl:1;
-            bool ssb_no:1;
-            bool mds_no:1;
-            bool if_pschange_mc_no:1;
-            bool tsx_ctrl:1;
-            bool taa_no:1;
-        };
-    } arch_caps;
-};
-
-#ifdef __XEN__
-#include <public/arch-x86/xen.h>
-typedef XEN_GUEST_HANDLE_64(xen_msr_entry_t) msr_entry_buffer_t;
-#else
-#include <xen/arch-x86/xen.h>
-typedef xen_msr_entry_t msr_entry_buffer_t[];
-#endif
-
-/**
- * Serialise an msr_policy object into an array.
- *
- * @param policy     The msr_policy to serialise.
- * @param msrs       The array of msrs to serialise into.
- * @param nr_entries The number of entries in 'msrs'.
- * @returns -errno
- *
- * Writes at most MSR_MAX_SERIALISED_ENTRIES.  May fail with -ENOBUFS if the
- * buffer array is too short.  On success, nr_entries is updated with the
- * actual number of msrs written.
- */
-int x86_msr_copy_to_buffer(const struct msr_policy *policy,
-                           msr_entry_buffer_t msrs, uint32_t *nr_entries);
-
-/**
- * Unserialise an msr_policy object from an array of msrs.
- *
- * @param policy     The msr_policy object to unserialise into.
- * @param msrs       The array of msrs to unserialise from.
- * @param nr_entries The number of entries in 'msrs'.
- * @param err_msr    Optional hint for error diagnostics.
- * @returns -errno
- *
- * Reads at most MSR_MAX_SERIALISED_ENTRIES.  May fail for a number of reasons
- * based on the content in an individual 'msrs' entry, including the MSR index
- * not being valid in the policy, the flags field being nonzero, or if the
- * value provided would truncate when stored in the policy.  In such cases,
- * the optional err_* pointer will identify the problematic MSR.
- *
- * No content validation is performed on the data stored in the policy object.
- */
-int x86_msr_copy_from_buffer(struct msr_policy *policy,
-                             const msr_entry_buffer_t msrs, uint32_t nr_entries,
-                             uint32_t *err_msr);
-
-#endif /* !XEN_LIB_X86_MSR_H */
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * tab-width: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/lib/x86/msr.c b/xen/lib/x86/msr.c
index 7d71e92a38..c4d885e7b5 100644
--- a/xen/lib/x86/msr.c
+++ b/xen/lib/x86/msr.c
@@ -1,6 +1,6 @@
 #include "private.h"
 
-#include <xen/lib/x86/msr.h>
+#include <xen/lib/x86/cpu-policy.h>
 
 /*
  * Copy a single MSR into the provided msr_entry_buffer_t buffer, performing a
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:00:57 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:00:57 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680904.1059188 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGkr-0006Ox-5S; Wed, 14 Feb 2024 15:00:57 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680904.1059188; Wed, 14 Feb 2024 15:00:57 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGkr-0006Oq-2p; Wed, 14 Feb 2024 15:00:57 +0000
Received: by outflank-mailman (input) for mailman id 680904;
 Wed, 14 Feb 2024 15:00:55 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkp-0006Oe-MZ
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:55 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkp-0005kb-Lo
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:55 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkp-0000UY-L0
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:00:55 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=PUhVEefGoF7ytQw8M07j6s09bdIF7jMECpuZFP+0sPo=; b=XDCRtQ9vbDzr3aqXYouBux0zu7
	JgvbIvZ4zTEgaXq2bZ5BQoI5rbN2ygG7JMS8VtLiZajmzSAG5QLVC705vSF3Ubh8c+dQqWY9GZhvv
	z1qXJ4v4fuKSmN2fXj9d4KtQtsVJlH/jnIRZhzmMsweIcswFi/QddoBSpjaPsF2d+RUI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86: Merge the system {cpuid,msr} policy objects
Message-Id: <E1raGkp-0000UY-L0@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:00:55 +0000

commit 83a720e9129903ae0dce6d797d2319c1f99ad3b8
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Mar 29 07:39:44 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86: Merge the system {cpuid,msr} policy objects
    
    Right now, they're the same underlying type, containing disjoint information.
    
    Introduce a new cpu-policy.{h,c} to be the new location for all policy
    handling logic.  Place the combined objects in __ro_after_init, which is new
    since the original logic was written.
    
    As we're trying to phase out the use of struct old_cpu_policy entirely, rework
    update_domain_cpu_policy() to not pointer-chase through system_policies[].
    
    This in turn allows system_policies[] in sysctl.c to become static and reduced
    in scope to XEN_SYSCTL_get_cpu_policy.
    
    No practical change.  This undoes the transient doubling of storage space from
    earlier patches.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 6bc33366795d14a21a3244d0f3b63f7dccea87ef)
---
 xen/arch/x86/Makefile            |  1 +
 xen/arch/x86/cpu-policy.c        | 18 ++++++++++
 xen/arch/x86/cpu/common.c        |  4 ++-
 xen/arch/x86/cpuid.c             | 66 ++++++++++++++++---------------------
 xen/arch/x86/domctl.c            | 17 +++++++---
 xen/arch/x86/msr.c               | 38 ++++++++-------------
 xen/arch/x86/sysctl.c            | 71 +++++++++++++++-------------------------
 xen/include/asm-x86/cpu-policy.h | 14 ++++++++
 xen/include/asm-x86/cpuid.h      |  6 ----
 xen/include/asm-x86/msr.h        |  7 ----
 10 files changed, 116 insertions(+), 126 deletions(-)

diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index fd0acd566a..d918e99c5e 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -16,6 +16,7 @@ obj-y += bitops.o
 obj-bin-y += bzimage.init.o
 obj-bin-y += clear_page.o
 obj-bin-y += copy_page.o
+obj-y += cpu-policy.o
 obj-y += cpuid.o
 obj-$(CONFIG_PV) += compat.o x86_64/compat.o
 obj-$(CONFIG_KEXEC) += crash.o
diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
new file mode 100644
index 0000000000..e47fbeb04d
--- /dev/null
+++ b/xen/arch/x86/cpu-policy.c
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#include <xen/cache.h>
+#include <xen/kernel.h>
+
+#include <xen/lib/x86/cpu-policy.h>
+
+#include <asm/cpu-policy.h>
+
+struct cpu_policy __read_mostly       raw_cpu_policy;
+struct cpu_policy __read_mostly      host_cpu_policy;
+#ifdef CONFIG_PV
+struct cpu_policy __read_mostly    pv_max_cpu_policy;
+struct cpu_policy __read_mostly    pv_def_cpu_policy;
+#endif
+#ifdef CONFIG_HVM
+struct cpu_policy __read_mostly   hvm_max_cpu_policy;
+struct cpu_policy __read_mostly   hvm_def_cpu_policy;
+#endif
diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index 70e6dea04a..088a871969 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -3,6 +3,8 @@
 #include <xen/delay.h>
 #include <xen/param.h>
 #include <xen/smp.h>
+
+#include <asm/cpu-policy.h>
 #include <asm/current.h>
 #include <asm/debugreg.h>
 #include <asm/processor.h>
@@ -135,7 +137,7 @@ bool __init probe_cpuid_faulting(void)
 		return false;
 
 	if ((rc = rdmsr_safe(MSR_INTEL_PLATFORM_INFO, val)) == 0)
-		raw_msr_policy.platform_info.cpuid_faulting =
+		raw_cpu_policy.platform_info.cpuid_faulting =
 			val & MSR_PLATFORM_INFO_CPUID_FAULTING;
 
 	if (rc ||
diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index 832a5e95c9..3368d07efc 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -3,6 +3,7 @@
 #include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/nospec.h>
+#include <asm/cpu-policy.h>
 #include <asm/cpuid.h>
 #include <asm/hvm/hvm.h>
 #include <asm/hvm/nestedhvm.h>
@@ -141,17 +142,6 @@ static void zero_leaves(struct cpuid_leaf *l,
     memset(&l[first], 0, sizeof(*l) * (last - first + 1));
 }
 
-struct cpuid_policy __read_mostly     raw_cpuid_policy,
-                    __read_mostly    host_cpuid_policy;
-#ifdef CONFIG_PV
-struct cpuid_policy __read_mostly  pv_max_cpuid_policy;
-struct cpuid_policy __read_mostly  pv_def_cpuid_policy;
-#endif
-#ifdef CONFIG_HVM
-struct cpuid_policy __read_mostly hvm_max_cpuid_policy;
-struct cpuid_policy __read_mostly hvm_def_cpuid_policy;
-#endif
-
 static void sanitise_featureset(uint32_t *fs)
 {
     /* for_each_set_bit() uses unsigned longs.  Extend with zeroes. */
@@ -343,7 +333,7 @@ static void recalculate_misc(struct cpuid_policy *p)
 
 static void __init calculate_raw_policy(void)
 {
-    struct cpuid_policy *p = &raw_cpuid_policy;
+    struct cpuid_policy *p = &raw_cpu_policy;
 
     x86_cpuid_policy_fill_native(p);
 
@@ -353,10 +343,10 @@ static void __init calculate_raw_policy(void)
 
 static void __init calculate_host_policy(void)
 {
-    struct cpuid_policy *p = &host_cpuid_policy;
+    struct cpuid_policy *p = &host_cpu_policy;
     unsigned int max_extd_leaf;
 
-    *p = raw_cpuid_policy;
+    *p = raw_cpu_policy;
 
     p->basic.max_leaf =
         min_t(uint32_t, p->basic.max_leaf,   ARRAY_SIZE(p->basic.raw) - 1);
@@ -448,17 +438,17 @@ static void __init guest_common_feature_adjustments(uint32_t *fs)
      * of IBRS by using the AMD feature bit.  An administrator may wish for
      * performance reasons to offer IBPB without IBRS.
      */
-    if ( host_cpuid_policy.feat.ibrsb )
+    if ( host_cpu_policy.feat.ibrsb )
         __set_bit(X86_FEATURE_IBPB, fs);
 }
 
 static void __init calculate_pv_max_policy(void)
 {
-    struct cpuid_policy *p = &pv_max_cpuid_policy;
+    struct cpuid_policy *p = &pv_max_cpu_policy;
     uint32_t pv_featureset[FSCAPINTS];
     unsigned int i;
 
-    *p = host_cpuid_policy;
+    *p = host_cpu_policy;
     cpuid_policy_to_featureset(p, pv_featureset);
 
     for ( i = 0; i < ARRAY_SIZE(pv_featureset); ++i )
@@ -485,11 +475,11 @@ static void __init calculate_pv_max_policy(void)
 
 static void __init calculate_pv_def_policy(void)
 {
-    struct cpuid_policy *p = &pv_def_cpuid_policy;
+    struct cpuid_policy *p = &pv_def_cpu_policy;
     uint32_t pv_featureset[FSCAPINTS];
     unsigned int i;
 
-    *p = pv_max_cpuid_policy;
+    *p = pv_max_cpu_policy;
     cpuid_policy_to_featureset(p, pv_featureset);
 
     for ( i = 0; i < ARRAY_SIZE(pv_featureset); ++i )
@@ -505,12 +495,12 @@ static void __init calculate_pv_def_policy(void)
 
 static void __init calculate_hvm_max_policy(void)
 {
-    struct cpuid_policy *p = &hvm_max_cpuid_policy;
+    struct cpuid_policy *p = &hvm_max_cpu_policy;
     uint32_t hvm_featureset[FSCAPINTS];
     unsigned int i;
     const uint32_t *hvm_featuremask;
 
-    *p = host_cpuid_policy;
+    *p = host_cpu_policy;
     cpuid_policy_to_featureset(p, hvm_featureset);
 
     hvm_featuremask = hvm_hap_supported() ?
@@ -532,7 +522,7 @@ static void __init calculate_hvm_max_policy(void)
      * HVM guests are able if running in protected mode.
      */
     if ( (boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) &&
-         raw_cpuid_policy.basic.sep )
+         raw_cpu_policy.basic.sep )
         __set_bit(X86_FEATURE_SEP, hvm_featureset);
 
     /*
@@ -567,12 +557,12 @@ static void __init calculate_hvm_max_policy(void)
 
 static void __init calculate_hvm_def_policy(void)
 {
-    struct cpuid_policy *p = &hvm_def_cpuid_policy;
+    struct cpuid_policy *p = &hvm_def_cpu_policy;
     uint32_t hvm_featureset[FSCAPINTS];
     unsigned int i;
     const uint32_t *hvm_featuremask;
 
-    *p = hvm_max_cpuid_policy;
+    *p = hvm_max_cpu_policy;
     cpuid_policy_to_featureset(p, hvm_featureset);
 
     hvm_featuremask = hvm_hap_supported() ?
@@ -633,8 +623,8 @@ void recalculate_cpuid_policy(struct domain *d)
 {
     struct cpuid_policy *p = d->arch.cpuid;
     const struct cpuid_policy *max = is_pv_domain(d)
-        ? (IS_ENABLED(CONFIG_PV)  ?  &pv_max_cpuid_policy : NULL)
-        : (IS_ENABLED(CONFIG_HVM) ? &hvm_max_cpuid_policy : NULL);
+        ? (IS_ENABLED(CONFIG_PV)  ?  &pv_max_cpu_policy : NULL)
+        : (IS_ENABLED(CONFIG_HVM) ? &hvm_max_cpu_policy : NULL);
     uint32_t fs[FSCAPINTS], max_fs[FSCAPINTS];
     unsigned int i;
 
@@ -717,7 +707,7 @@ void recalculate_cpuid_policy(struct domain *d)
     /* Fold host's FDP_EXCP_ONLY and NO_FPU_SEL into guest's view. */
     fs[FEATURESET_7b0] &= ~(cpufeat_mask(X86_FEATURE_FDP_EXCP_ONLY) |
                             cpufeat_mask(X86_FEATURE_NO_FPU_SEL));
-    fs[FEATURESET_7b0] |= (host_cpuid_policy.feat._7b0 &
+    fs[FEATURESET_7b0] |= (host_cpu_policy.feat._7b0 &
                            (cpufeat_mask(X86_FEATURE_FDP_EXCP_ONLY) |
                             cpufeat_mask(X86_FEATURE_NO_FPU_SEL)));
 
@@ -768,8 +758,8 @@ void recalculate_cpuid_policy(struct domain *d)
 int init_domain_cpuid_policy(struct domain *d)
 {
     struct cpuid_policy *p = is_pv_domain(d)
-        ? (IS_ENABLED(CONFIG_PV)  ?  &pv_def_cpuid_policy : NULL)
-        : (IS_ENABLED(CONFIG_HVM) ? &hvm_def_cpuid_policy : NULL);
+        ? (IS_ENABLED(CONFIG_PV)  ?  &pv_def_cpu_policy : NULL)
+        : (IS_ENABLED(CONFIG_HVM) ? &hvm_def_cpu_policy : NULL);
 
     if ( !p )
     {
@@ -1073,7 +1063,7 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf,
         if ( is_pv_domain(d) && is_hardware_domain(d) &&
              guest_kernel_mode(v, regs) && cpu_has_monitor &&
              regs->entry_vector == TRAP_gp_fault )
-            *res = raw_cpuid_policy.basic.raw[5];
+            *res = raw_cpu_policy.basic.raw[5];
         break;
 
     case 0x7:
@@ -1205,14 +1195,14 @@ static void __init __maybe_unused build_assertions(void)
     /* Find some more clever allocation scheme if this trips. */
     BUILD_BUG_ON(sizeof(struct cpuid_policy) > PAGE_SIZE);
 
-    BUILD_BUG_ON(sizeof(raw_cpuid_policy.basic) !=
-                 sizeof(raw_cpuid_policy.basic.raw));
-    BUILD_BUG_ON(sizeof(raw_cpuid_policy.feat) !=
-                 sizeof(raw_cpuid_policy.feat.raw));
-    BUILD_BUG_ON(sizeof(raw_cpuid_policy.xstate) !=
-                 sizeof(raw_cpuid_policy.xstate.raw));
-    BUILD_BUG_ON(sizeof(raw_cpuid_policy.extd) !=
-                 sizeof(raw_cpuid_policy.extd.raw));
+    BUILD_BUG_ON(sizeof(raw_cpu_policy.basic) !=
+                 sizeof(raw_cpu_policy.basic.raw));
+    BUILD_BUG_ON(sizeof(raw_cpu_policy.feat) !=
+                 sizeof(raw_cpu_policy.feat.raw));
+    BUILD_BUG_ON(sizeof(raw_cpu_policy.xstate) !=
+                 sizeof(raw_cpu_policy.xstate.raw));
+    BUILD_BUG_ON(sizeof(raw_cpu_policy.extd) !=
+                 sizeof(raw_cpu_policy.extd.raw));
 }
 
 /*
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 64a4e17f88..61c638f5c3 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -35,7 +35,7 @@
 #include <asm/xstate.h>
 #include <asm/debugger.h>
 #include <asm/psr.h>
-#include <asm/cpuid.h>
+#include <asm/cpu-policy.h>
 
 #ifdef CONFIG_GDBSX
 static int gdbsx_guest_mem_io(domid_t domid, struct xen_domctl_gdbsx_memio *iop)
@@ -220,12 +220,19 @@ static int update_domain_cpu_policy(struct domain *d,
                                     xen_domctl_cpu_policy_t *xdpc)
 {
     struct old_cpu_policy new = {};
-    const struct old_cpu_policy *sys = is_pv_domain(d)
-        ? &system_policies[XEN_SYSCTL_cpu_policy_pv_max]
-        : &system_policies[XEN_SYSCTL_cpu_policy_hvm_max];
+    struct cpu_policy *sys = is_pv_domain(d)
+        ? (IS_ENABLED(CONFIG_PV)  ?  &pv_max_cpu_policy : NULL)
+        : (IS_ENABLED(CONFIG_HVM) ? &hvm_max_cpu_policy : NULL);
+    struct old_cpu_policy old_sys = { sys, sys };
     struct cpu_policy_errors err = INIT_CPU_POLICY_ERRORS;
     int ret = -ENOMEM;
 
+    if ( !sys )
+    {
+        ASSERT_UNREACHABLE();
+        return -EOPNOTSUPP;
+    }
+
     /* Start by copying the domain's existing policies. */
     if ( !(new.cpuid = xmemdup(d->arch.cpuid)) ||
          !(new.msr   = xmemdup(d->arch.msr)) )
@@ -243,7 +250,7 @@ static int update_domain_cpu_policy(struct domain *d,
     x86_cpuid_policy_clear_out_of_range_leaves(new.cpuid);
 
     /* Audit the combined dataset. */
-    ret = x86_cpu_policies_are_compatible(sys, &new, &err);
+    ret = x86_cpu_policies_are_compatible(&old_sys, &new, &err);
     if ( ret )
         goto out;
 
diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index 6517e50c9f..bc19ec356e 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -24,6 +24,7 @@
 #include <xen/nospec.h>
 #include <xen/sched.h>
 
+#include <asm/cpu-policy.h>
 #include <asm/debugreg.h>
 #include <asm/hvm/viridian.h>
 #include <asm/msr.h>
@@ -34,20 +35,9 @@
 
 DEFINE_PER_CPU(uint32_t, tsc_aux);
 
-struct msr_policy __read_mostly     raw_msr_policy,
-                  __read_mostly    host_msr_policy;
-#ifdef CONFIG_PV
-struct msr_policy __read_mostly  pv_max_msr_policy;
-struct msr_policy __read_mostly  pv_def_msr_policy;
-#endif
-#ifdef CONFIG_HVM
-struct msr_policy __read_mostly hvm_max_msr_policy;
-struct msr_policy __read_mostly hvm_def_msr_policy;
-#endif
-
 static void __init calculate_raw_policy(void)
 {
-    struct msr_policy *mp = &raw_msr_policy;
+    struct msr_policy *mp = &raw_cpu_policy;
 
     /* 0x000000ce  MSR_INTEL_PLATFORM_INFO */
     /* Was already added by probe_cpuid_faulting() */
@@ -58,9 +48,9 @@ static void __init calculate_raw_policy(void)
 
 static void __init calculate_host_policy(void)
 {
-    struct msr_policy *mp = &host_msr_policy;
+    struct msr_policy *mp = &host_cpu_policy;
 
-    *mp = raw_msr_policy;
+    *mp = raw_cpu_policy;
 
     /* 0x000000ce  MSR_INTEL_PLATFORM_INFO */
     /* probe_cpuid_faulting() sanity checks presence of MISC_FEATURES_ENABLES */
@@ -78,25 +68,25 @@ static void __init calculate_host_policy(void)
 
 static void __init calculate_pv_max_policy(void)
 {
-    struct msr_policy *mp = &pv_max_msr_policy;
+    struct msr_policy *mp = &pv_max_cpu_policy;
 
-    *mp = host_msr_policy;
+    *mp = host_cpu_policy;
 
     mp->arch_caps.raw = 0; /* Not supported yet. */
 }
 
 static void __init calculate_pv_def_policy(void)
 {
-    struct msr_policy *mp = &pv_def_msr_policy;
+    struct msr_policy *mp = &pv_def_cpu_policy;
 
-    *mp = pv_max_msr_policy;
+    *mp = pv_max_cpu_policy;
 }
 
 static void __init calculate_hvm_max_policy(void)
 {
-    struct msr_policy *mp = &hvm_max_msr_policy;
+    struct msr_policy *mp = &hvm_max_cpu_policy;
 
-    *mp = host_msr_policy;
+    *mp = host_cpu_policy;
 
     /* It's always possible to emulate CPUID faulting for HVM guests */
     mp->platform_info.cpuid_faulting = true;
@@ -106,9 +96,9 @@ static void __init calculate_hvm_max_policy(void)
 
 static void __init calculate_hvm_def_policy(void)
 {
-    struct msr_policy *mp = &hvm_def_msr_policy;
+    struct msr_policy *mp = &hvm_def_cpu_policy;
 
-    *mp = hvm_max_msr_policy;
+    *mp = hvm_max_cpu_policy;
 }
 
 void __init init_guest_msr_policy(void)
@@ -132,8 +122,8 @@ void __init init_guest_msr_policy(void)
 int init_domain_msr_policy(struct domain *d)
 {
     struct msr_policy *mp = is_pv_domain(d)
-        ? (IS_ENABLED(CONFIG_PV)  ?  &pv_def_msr_policy : NULL)
-        : (IS_ENABLED(CONFIG_HVM) ? &hvm_def_msr_policy : NULL);
+        ? (IS_ENABLED(CONFIG_PV)  ?  &pv_def_cpu_policy : NULL)
+        : (IS_ENABLED(CONFIG_HVM) ? &hvm_def_cpu_policy : NULL);
 
     if ( !mp )
     {
diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c
index 04e90c596a..99d5c1b85b 100644
--- a/xen/arch/x86/sysctl.c
+++ b/xen/arch/x86/sysctl.c
@@ -31,38 +31,7 @@
 #include <xen/cpu.h>
 #include <xsm/xsm.h>
 #include <asm/psr.h>
-#include <asm/cpuid.h>
-
-const struct old_cpu_policy system_policies[6] = {
-    [ XEN_SYSCTL_cpu_policy_raw ] = {
-        &raw_cpuid_policy,
-        &raw_msr_policy,
-    },
-    [ XEN_SYSCTL_cpu_policy_host ] = {
-        &host_cpuid_policy,
-        &host_msr_policy,
-    },
-#ifdef CONFIG_PV
-    [ XEN_SYSCTL_cpu_policy_pv_max ] = {
-        &pv_max_cpuid_policy,
-        &pv_max_msr_policy,
-    },
-    [ XEN_SYSCTL_cpu_policy_pv_default ] = {
-        &pv_def_cpuid_policy,
-        &pv_def_msr_policy,
-    },
-#endif
-#ifdef CONFIG_HVM
-    [ XEN_SYSCTL_cpu_policy_hvm_max ] = {
-        &hvm_max_cpuid_policy,
-        &hvm_max_msr_policy,
-    },
-    [ XEN_SYSCTL_cpu_policy_hvm_default ] = {
-        &hvm_def_cpuid_policy,
-        &hvm_def_msr_policy,
-    },
-#endif
-};
+#include <asm/cpu-policy.h>
 
 struct l3_cache_info {
     int ret;
@@ -357,19 +326,19 @@ long arch_do_sysctl(
 
     case XEN_SYSCTL_get_cpu_featureset:
     {
-        static const struct cpuid_policy *const policy_table[6] = {
-            [XEN_SYSCTL_cpu_featureset_raw]  = &raw_cpuid_policy,
-            [XEN_SYSCTL_cpu_featureset_host] = &host_cpuid_policy,
+        static const struct cpu_policy *const policy_table[6] = {
+            [XEN_SYSCTL_cpu_featureset_raw]  = &raw_cpu_policy,
+            [XEN_SYSCTL_cpu_featureset_host] = &host_cpu_policy,
 #ifdef CONFIG_PV
-            [XEN_SYSCTL_cpu_featureset_pv]   = &pv_def_cpuid_policy,
-            [XEN_SYSCTL_cpu_featureset_pv_max] = &pv_max_cpuid_policy,
+            [XEN_SYSCTL_cpu_featureset_pv]   = &pv_def_cpu_policy,
+            [XEN_SYSCTL_cpu_featureset_pv_max] = &pv_max_cpu_policy,
 #endif
 #ifdef CONFIG_HVM
-            [XEN_SYSCTL_cpu_featureset_hvm]  = &hvm_def_cpuid_policy,
-            [XEN_SYSCTL_cpu_featureset_hvm_max] = &hvm_max_cpuid_policy,
+            [XEN_SYSCTL_cpu_featureset_hvm]  = &hvm_def_cpu_policy,
+            [XEN_SYSCTL_cpu_featureset_hvm_max] = &hvm_max_cpu_policy,
 #endif
         };
-        const struct cpuid_policy *p = NULL;
+        const struct cpu_policy *p = NULL;
         uint32_t featureset[FSCAPINTS];
         unsigned int nr;
 
@@ -422,7 +391,19 @@ long arch_do_sysctl(
 
     case XEN_SYSCTL_get_cpu_policy:
     {
-        const struct old_cpu_policy *policy;
+        static const struct cpu_policy *const system_policies[6] = {
+            [XEN_SYSCTL_cpu_policy_raw]         = &raw_cpu_policy,
+            [XEN_SYSCTL_cpu_policy_host]        = &host_cpu_policy,
+#ifdef CONFIG_PV
+            [XEN_SYSCTL_cpu_policy_pv_max]      = &pv_max_cpu_policy,
+            [XEN_SYSCTL_cpu_policy_pv_default]  = &pv_def_cpu_policy,
+#endif
+#ifdef CONFIG_HVM
+            [XEN_SYSCTL_cpu_policy_hvm_max]     = &hvm_max_cpu_policy,
+            [XEN_SYSCTL_cpu_policy_hvm_default] = &hvm_def_cpu_policy,
+#endif
+        };
+        const struct cpu_policy *policy;
 
         /* Reserved field set, or bad policy index? */
         if ( sysctl->u.cpu_policy._rsvd ||
@@ -431,11 +412,11 @@ long arch_do_sysctl(
             ret = -EINVAL;
             break;
         }
-        policy = &system_policies[
+        policy = system_policies[
             array_index_nospec(sysctl->u.cpu_policy.index,
                                ARRAY_SIZE(system_policies))];
 
-        if ( !policy->cpuid || !policy->msr )
+        if ( !policy )
         {
             ret = -EOPNOTSUPP;
             break;
@@ -445,7 +426,7 @@ long arch_do_sysctl(
         if ( guest_handle_is_null(sysctl->u.cpu_policy.leaves) )
             sysctl->u.cpu_policy.nr_leaves = CPUID_MAX_SERIALISED_LEAVES;
         else if ( (ret = x86_cpuid_copy_to_buffer(
-                       policy->cpuid,
+                       policy,
                        sysctl->u.cpu_policy.leaves,
                        &sysctl->u.cpu_policy.nr_leaves)) )
             break;
@@ -461,7 +442,7 @@ long arch_do_sysctl(
         if ( guest_handle_is_null(sysctl->u.cpu_policy.msrs) )
             sysctl->u.cpu_policy.nr_msrs = MSR_MAX_SERIALISED_ENTRIES;
         else if ( (ret = x86_msr_copy_to_buffer(
-                       policy->msr,
+                       policy,
                        sysctl->u.cpu_policy.msrs,
                        &sysctl->u.cpu_policy.nr_msrs)) )
             break;
diff --git a/xen/include/asm-x86/cpu-policy.h b/xen/include/asm-x86/cpu-policy.h
new file mode 100644
index 0000000000..eef14bb426
--- /dev/null
+++ b/xen/include/asm-x86/cpu-policy.h
@@ -0,0 +1,14 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+#ifndef X86_CPU_POLICY_H
+#define X86_CPU_POLICY_H
+
+struct cpu_policy;
+
+extern struct cpu_policy     raw_cpu_policy;
+extern struct cpu_policy    host_cpu_policy;
+extern struct cpu_policy  pv_max_cpu_policy;
+extern struct cpu_policy  pv_def_cpu_policy;
+extern struct cpu_policy hvm_max_cpu_policy;
+extern struct cpu_policy hvm_def_cpu_policy;
+
+#endif /* X86_CPU_POLICY_H */
diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h
index d418e8100d..ea05862773 100644
--- a/xen/include/asm-x86/cpuid.h
+++ b/xen/include/asm-x86/cpuid.h
@@ -46,12 +46,6 @@ DECLARE_PER_CPU(struct cpuidmasks, cpuidmasks);
 /* Default masking MSR values, calculated at boot. */
 extern struct cpuidmasks cpuidmask_defaults;
 
-extern struct cpuid_policy raw_cpuid_policy, host_cpuid_policy,
-    pv_max_cpuid_policy, pv_def_cpuid_policy,
-    hvm_max_cpuid_policy, hvm_def_cpuid_policy;
-
-extern const struct old_cpu_policy system_policies[];
-
 /* Check that all previously present features are still available. */
 bool recheck_cpu_features(unsigned int cpu);
 
diff --git a/xen/include/asm-x86/msr.h b/xen/include/asm-x86/msr.h
index 86fe27cc14..130c80c9cf 100644
--- a/xen/include/asm-x86/msr.h
+++ b/xen/include/asm-x86/msr.h
@@ -270,13 +270,6 @@ static inline void wrmsr_tsc_aux(uint32_t val)
 
 uint64_t msr_spec_ctrl_valid_bits(const struct cpuid_policy *cp);
 
-extern struct msr_policy     raw_msr_policy,
-                            host_msr_policy,
-                          pv_max_msr_policy,
-                          pv_def_msr_policy,
-                         hvm_max_msr_policy,
-                         hvm_def_msr_policy;
-
 /* Container object for per-vCPU MSRs */
 struct vcpu_msrs
 {
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:01:07 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:01:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680905.1059193 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGl1-0006SG-9w; Wed, 14 Feb 2024 15:01:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680905.1059193; Wed, 14 Feb 2024 15:01:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGl1-0006S6-71; Wed, 14 Feb 2024 15:01:07 +0000
Received: by outflank-mailman (input) for mailman id 680905;
 Wed, 14 Feb 2024 15:01:05 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkz-0006Rq-Pz
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:05 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkz-0005ky-PB
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGkz-0000Vr-OP
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:05 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=LgSqRKGtYhvdlA7thQwct3AgDeyqGfK7Yz+sB0/ztVc=; b=kkg13ikiFS/I80Ii4/B7pOZuNC
	fyONkU3Ruy9eZWmgRny2fCkl016OiIPXrmvB0Us5hiOZYc0z6JC1mfRzyjxQ/7+dvDs2zCPbWtySX
	y+A49VKIKduFyWESsfxecKX4UfeX/pQMjvBK2yLQLy2n5Y9EiFSkym+p4pr5kZubBUro=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86: Merge a domain's {cpuid,msr} policy objects
Message-Id: <E1raGkz-0000Vr-OP@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:01:05 +0000

commit 99d01e372938be424a3622ff4e40bf3a77604acc
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Mar 29 11:32:25 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86: Merge a domain's {cpuid,msr} policy objects
    
    Right now, they're the same underlying type, containing disjoint information.
    
    Drop the d->arch.msr pointer, and union d->arch.cpuid to give it a second name
    of cpu_policy in the interim.
    
    Merge init_domain_{cpuid,msr}_policy() into a single init_domain_cpu_policy(),
    moving the implementation into cpu-policy.c
    
    No practical change.  This undoes the transient doubling of storage space from
    earlier patches.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit bd13dae34809e61e37ba1cd5de893c5c10c46256)
---
 xen/arch/x86/cpu-policy.c        | 49 ++++++++++++++++++++++++++++++++++++++++
 xen/arch/x86/cpuid.c             | 23 -------------------
 xen/arch/x86/domain.c            | 15 ++++--------
 xen/arch/x86/domctl.c            | 35 ++++++++++++++--------------
 xen/arch/x86/msr.c               | 44 ------------------------------------
 xen/include/asm-x86/cpu-policy.h |  4 ++++
 xen/include/asm-x86/cpuid.h      |  3 ---
 xen/include/asm-x86/domain.h     | 13 ++++++++---
 xen/include/asm-x86/msr.h        |  1 -
 9 files changed, 85 insertions(+), 102 deletions(-)

diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
index e47fbeb04d..4c5fd70cf1 100644
--- a/xen/arch/x86/cpu-policy.c
+++ b/xen/arch/x86/cpu-policy.c
@@ -1,10 +1,13 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 #include <xen/cache.h>
 #include <xen/kernel.h>
+#include <xen/sched.h>
 
 #include <xen/lib/x86/cpu-policy.h>
 
 #include <asm/cpu-policy.h>
+#include <asm/msr-index.h>
+#include <asm/setup.h>
 
 struct cpu_policy __read_mostly       raw_cpu_policy;
 struct cpu_policy __read_mostly      host_cpu_policy;
@@ -16,3 +19,49 @@ struct cpu_policy __read_mostly    pv_def_cpu_policy;
 struct cpu_policy __read_mostly   hvm_max_cpu_policy;
 struct cpu_policy __read_mostly   hvm_def_cpu_policy;
 #endif
+
+int init_domain_cpu_policy(struct domain *d)
+{
+    struct cpu_policy *p = is_pv_domain(d)
+        ? (IS_ENABLED(CONFIG_PV)  ?  &pv_def_cpu_policy : NULL)
+        : (IS_ENABLED(CONFIG_HVM) ? &hvm_def_cpu_policy : NULL);
+
+    if ( !p )
+    {
+        ASSERT_UNREACHABLE();
+        return -EOPNOTSUPP;
+    }
+
+    p = xmemdup(p);
+    if ( !p )
+        return -ENOMEM;
+
+    /* See comment in ctxt_switch_levelling() */
+    if ( !opt_dom0_cpuid_faulting && is_control_domain(d) && is_pv_domain(d) )
+        p->platform_info.cpuid_faulting = false;
+
+    /*
+     * Expose the "hardware speculation behaviour" bits of ARCH_CAPS to dom0,
+     * so dom0 can turn off workarounds as appropriate.  Temporary, until the
+     * domain policy logic gains a better understanding of MSRs.
+     */
+    if ( is_hardware_domain(d) && cpu_has_arch_caps )
+    {
+        uint64_t val;
+
+        rdmsrl(MSR_ARCH_CAPABILITIES, val);
+
+        p->arch_caps.raw = val &
+            (ARCH_CAPS_RDCL_NO | ARCH_CAPS_IBRS_ALL | ARCH_CAPS_RSBA |
+             ARCH_CAPS_SSB_NO | ARCH_CAPS_MDS_NO | ARCH_CAPS_IF_PSCHANGE_MC_NO |
+             ARCH_CAPS_TAA_NO | ARCH_CAPS_SBDR_SSDP_NO | ARCH_CAPS_FBSDP_NO |
+             ARCH_CAPS_PSDP_NO | ARCH_CAPS_FB_CLEAR | ARCH_CAPS_RRSBA |
+             ARCH_CAPS_BHI_NO | ARCH_CAPS_PBRSB_NO);
+    }
+
+    d->arch.cpu_policy = p;
+
+    recalculate_cpuid_policy(d);
+
+    return 0;
+}
diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index 3368d07efc..026a6cc523 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -755,29 +755,6 @@ void recalculate_cpuid_policy(struct domain *d)
         p->extd.raw[0x19] = EMPTY_LEAF;
 }
 
-int init_domain_cpuid_policy(struct domain *d)
-{
-    struct cpuid_policy *p = is_pv_domain(d)
-        ? (IS_ENABLED(CONFIG_PV)  ?  &pv_def_cpu_policy : NULL)
-        : (IS_ENABLED(CONFIG_HVM) ? &hvm_def_cpu_policy : NULL);
-
-    if ( !p )
-    {
-        ASSERT_UNREACHABLE();
-        return -EOPNOTSUPP;
-    }
-
-    p = xmemdup(p);
-    if ( !p )
-        return -ENOMEM;
-
-    d->arch.cpuid = p;
-
-    recalculate_cpuid_policy(d);
-
-    return 0;
-}
-
 void __init init_dom0_cpuid_policy(struct domain *d)
 {
     struct cpuid_policy *p = d->arch.cpuid;
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index b3774af1a5..314b42d04e 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -64,6 +64,7 @@
 #include <xen/numa.h>
 #include <xen/iommu.h>
 #include <compat/vcpu.h>
+#include <asm/cpu-policy.h>
 #include <asm/psr.h>
 #include <asm/pv/domain.h>
 #include <asm/pv/mm.h>
@@ -534,8 +535,7 @@ int arch_domain_create(struct domain *d,
 
         d->arch.ctxt_switch = &idle_csw;
 
-        d->arch.cpuid = ZERO_BLOCK_PTR; /* Catch stray misuses. */
-        d->arch.msr = ZERO_BLOCK_PTR;
+        d->arch.cpu_policy = ZERO_BLOCK_PTR; /* Catch stray misuses. */
 
         return 0;
     }
@@ -588,10 +588,7 @@ int arch_domain_create(struct domain *d,
         goto fail;
     paging_initialised = true;
 
-    if ( (rc = init_domain_cpuid_policy(d)) )
-        goto fail;
-
-    if ( (rc = init_domain_msr_policy(d)) )
+    if ( (rc = init_domain_cpu_policy(d)) )
         goto fail;
 
     d->arch.ioport_caps =
@@ -660,8 +657,7 @@ int arch_domain_create(struct domain *d,
     iommu_domain_destroy(d);
     cleanup_domain_irq_mapping(d);
     free_xenheap_page(d->shared_info);
-    xfree(d->arch.cpuid);
-    xfree(d->arch.msr);
+    XFREE(d->arch.cpu_policy);
     if ( paging_initialised )
         paging_final_teardown(d);
     free_perdomain_mappings(d);
@@ -675,8 +671,7 @@ void arch_domain_destroy(struct domain *d)
         hvm_domain_destroy(d);
 
     xfree(d->arch.e820);
-    xfree(d->arch.cpuid);
-    xfree(d->arch.msr);
+    XFREE(d->arch.cpu_policy);
 
     free_domain_pirqs(d);
     if ( !is_idle_domain(d) )
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 61c638f5c3..c000ed71bd 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -219,11 +219,11 @@ void domain_cpu_policy_changed(struct domain *d)
 static int update_domain_cpu_policy(struct domain *d,
                                     xen_domctl_cpu_policy_t *xdpc)
 {
-    struct old_cpu_policy new = {};
+    struct cpu_policy *new;
     struct cpu_policy *sys = is_pv_domain(d)
         ? (IS_ENABLED(CONFIG_PV)  ?  &pv_max_cpu_policy : NULL)
         : (IS_ENABLED(CONFIG_HVM) ? &hvm_max_cpu_policy : NULL);
-    struct old_cpu_policy old_sys = { sys, sys };
+    struct old_cpu_policy old_sys = { sys, sys }, old_new;
     struct cpu_policy_errors err = INIT_CPU_POLICY_ERRORS;
     int ret = -ENOMEM;
 
@@ -233,33 +233,33 @@ static int update_domain_cpu_policy(struct domain *d,
         return -EOPNOTSUPP;
     }
 
-    /* Start by copying the domain's existing policies. */
-    if ( !(new.cpuid = xmemdup(d->arch.cpuid)) ||
-         !(new.msr   = xmemdup(d->arch.msr)) )
+    /* Start by copying the domain's existing policy. */
+    if ( !(new = xmemdup(d->arch.cpu_policy)) )
         goto out;
 
+    old_new = (struct old_cpu_policy){ new, new };
+
     /* Merge the toolstack provided data. */
     if ( (ret = x86_cpuid_copy_from_buffer(
-              new.cpuid, xdpc->leaves, xdpc->nr_leaves,
+              new, xdpc->leaves, xdpc->nr_leaves,
               &err.leaf, &err.subleaf)) ||
          (ret = x86_msr_copy_from_buffer(
-              new.msr, xdpc->msrs, xdpc->nr_msrs, &err.msr)) )
+              new, xdpc->msrs, xdpc->nr_msrs, &err.msr)) )
         goto out;
 
     /* Trim any newly-stale out-of-range leaves. */
-    x86_cpuid_policy_clear_out_of_range_leaves(new.cpuid);
+    x86_cpuid_policy_clear_out_of_range_leaves(new);
 
     /* Audit the combined dataset. */
-    ret = x86_cpu_policies_are_compatible(&old_sys, &new, &err);
+    ret = x86_cpu_policies_are_compatible(&old_sys, &old_new, &err);
     if ( ret )
         goto out;
 
     /*
-     * Audit was successful.  Replace existing policies, leaving the old
-     * policies to be freed.
+     * Audit was successful.  Replace the existing policy, leaving the old one
+     * to be freed.
      */
-    SWAP(new.cpuid, d->arch.cpuid);
-    SWAP(new.msr,   d->arch.msr);
+    SWAP(new, d->arch.cpu_policy);
 
     /* TODO: Drop when x86_cpu_policies_are_compatible() is completed. */
     recalculate_cpuid_policy(d);
@@ -268,9 +268,8 @@ static int update_domain_cpu_policy(struct domain *d,
     domain_cpu_policy_changed(d);
 
  out:
-    /* Free whichever cpuid/msr structs are not installed in struct domain. */
-    xfree(new.cpuid);
-    xfree(new.msr);
+    /* Free whichever struct is not installed in struct domain. */
+    xfree(new);
 
     if ( ret )
     {
@@ -1461,7 +1460,7 @@ long arch_do_domctl(
         if ( guest_handle_is_null(domctl->u.cpu_policy.leaves) )
             domctl->u.cpu_policy.nr_leaves = CPUID_MAX_SERIALISED_LEAVES;
         else if ( (ret = x86_cpuid_copy_to_buffer(
-                       d->arch.cpuid,
+                       d->arch.cpu_policy,
                        domctl->u.cpu_policy.leaves,
                        &domctl->u.cpu_policy.nr_leaves)) )
             break;
@@ -1470,7 +1469,7 @@ long arch_do_domctl(
         if ( guest_handle_is_null(domctl->u.cpu_policy.msrs) )
             domctl->u.cpu_policy.nr_msrs = MSR_MAX_SERIALISED_ENTRIES;
         else if ( (ret = x86_msr_copy_to_buffer(
-                       d->arch.msr,
+                       d->arch.cpu_policy,
                        domctl->u.cpu_policy.msrs,
                        &domctl->u.cpu_policy.nr_msrs)) )
             break;
diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index bc19ec356e..7bf8516e26 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -119,50 +119,6 @@ void __init init_guest_msr_policy(void)
     }
 }
 
-int init_domain_msr_policy(struct domain *d)
-{
-    struct msr_policy *mp = is_pv_domain(d)
-        ? (IS_ENABLED(CONFIG_PV)  ?  &pv_def_cpu_policy : NULL)
-        : (IS_ENABLED(CONFIG_HVM) ? &hvm_def_cpu_policy : NULL);
-
-    if ( !mp )
-    {
-        ASSERT_UNREACHABLE();
-        return -EOPNOTSUPP;
-    }
-
-    mp = xmemdup(mp);
-    if ( !mp )
-        return -ENOMEM;
-
-    /* See comment in ctxt_switch_levelling() */
-    if ( !opt_dom0_cpuid_faulting && is_control_domain(d) && is_pv_domain(d) )
-        mp->platform_info.cpuid_faulting = false;
-
-    /*
-     * Expose the "hardware speculation behaviour" bits of ARCH_CAPS to dom0,
-     * so dom0 can turn off workarounds as appropriate.  Temporary, until the
-     * domain policy logic gains a better understanding of MSRs.
-     */
-    if ( is_hardware_domain(d) && cpu_has_arch_caps )
-    {
-        uint64_t val;
-
-        rdmsrl(MSR_ARCH_CAPABILITIES, val);
-
-        mp->arch_caps.raw = val &
-            (ARCH_CAPS_RDCL_NO | ARCH_CAPS_IBRS_ALL | ARCH_CAPS_RSBA |
-             ARCH_CAPS_SSB_NO | ARCH_CAPS_MDS_NO | ARCH_CAPS_IF_PSCHANGE_MC_NO |
-             ARCH_CAPS_TAA_NO | ARCH_CAPS_SBDR_SSDP_NO | ARCH_CAPS_FBSDP_NO |
-             ARCH_CAPS_PSDP_NO | ARCH_CAPS_FB_CLEAR | ARCH_CAPS_RRSBA |
-             ARCH_CAPS_BHI_NO | ARCH_CAPS_PBRSB_NO);
-    }
-
-    d->arch.msr = mp;
-
-    return 0;
-}
-
 int init_vcpu_msr_policy(struct vcpu *v)
 {
     struct vcpu_msrs *msrs = xzalloc(struct vcpu_msrs);
diff --git a/xen/include/asm-x86/cpu-policy.h b/xen/include/asm-x86/cpu-policy.h
index eef14bb426..9ba34bbf5e 100644
--- a/xen/include/asm-x86/cpu-policy.h
+++ b/xen/include/asm-x86/cpu-policy.h
@@ -3,6 +3,7 @@
 #define X86_CPU_POLICY_H
 
 struct cpu_policy;
+struct domain;
 
 extern struct cpu_policy     raw_cpu_policy;
 extern struct cpu_policy    host_cpu_policy;
@@ -11,4 +12,7 @@ extern struct cpu_policy  pv_def_cpu_policy;
 extern struct cpu_policy hvm_max_cpu_policy;
 extern struct cpu_policy hvm_def_cpu_policy;
 
+/* Allocate and initialise a CPU policy suitable for the domain. */
+int init_domain_cpu_policy(struct domain *d);
+
 #endif /* X86_CPU_POLICY_H */
diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h
index ea05862773..7f81b998ce 100644
--- a/xen/include/asm-x86/cpuid.h
+++ b/xen/include/asm-x86/cpuid.h
@@ -49,9 +49,6 @@ extern struct cpuidmasks cpuidmask_defaults;
 /* Check that all previously present features are still available. */
 bool recheck_cpu_features(unsigned int cpu);
 
-/* Allocate and initialise a CPUID policy suitable for the domain. */
-int init_domain_cpuid_policy(struct domain *d);
-
 /* Apply dom0-specific tweaks to the CPUID policy. */
 void init_dom0_cpuid_policy(struct domain *d);
 
diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h
index 53d5a43ec0..8175ef1a51 100644
--- a/xen/include/asm-x86/domain.h
+++ b/xen/include/asm-x86/domain.h
@@ -368,9 +368,16 @@ struct arch_domain
      */
     uint8_t x87_fip_width;
 
-    /* CPUID and MSR policy objects. */
-    struct cpuid_policy *cpuid;
-    struct msr_policy *msr;
+    /*
+     * The domain's CPU Policy.  "cpu_policy" is considered the canonical
+     * pointer, but the "cpuid" and "msr" aliases exist so the most
+     * appropriate one can be used for local code clarity.
+     */
+    union {
+        struct cpu_policy *cpu_policy;
+        struct cpu_policy *cpuid;
+        struct cpu_policy *msr;
+    };
 
     struct PITState vpit;
 
diff --git a/xen/include/asm-x86/msr.h b/xen/include/asm-x86/msr.h
index 130c80c9cf..b9d0a96d9d 100644
--- a/xen/include/asm-x86/msr.h
+++ b/xen/include/asm-x86/msr.h
@@ -334,7 +334,6 @@ struct vcpu_msrs
 };
 
 void init_guest_msr_policy(void);
-int init_domain_msr_policy(struct domain *d);
 int init_vcpu_msr_policy(struct vcpu *v);
 
 /*
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:01:17 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:01:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680906.1059196 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGlB-0006WZ-BN; Wed, 14 Feb 2024 15:01:17 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680906.1059196; Wed, 14 Feb 2024 15:01:17 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGlB-0006WR-8U; Wed, 14 Feb 2024 15:01:17 +0000
Received: by outflank-mailman (input) for mailman id 680906;
 Wed, 14 Feb 2024 15:01:15 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGl9-0006Uq-Sz
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:15 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGl9-0005lG-SI
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:15 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGl9-0000Wk-RV
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:15 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=x4oSFRyQfbyKZ73zC3qfWhUoIltuSUGzraeWn8rYRe8=; b=BLTlNPwikAIbpPDT0wJ14p3xXY
	rgdm2ujExjsltQnQv6vKDEanXguMS0px4hCkxTmg62sPA3v2QNkX6ciXkSEvtNqCWlv3399RKe3Jn
	E0VKAEJDsksH3NztxaOgWKlC1n8IeMC09rK1HawiZnkSfG1JVEbdKYEUVWy6cgAqS4R0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86: Merge xc_cpu_policy's cpuid and msr objects
Message-Id: <E1raGl9-0000Wk-RV@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:01:15 +0000

commit cfcf8333505bc5591a9b512cee52f55cbf2b1719
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Mar 29 12:37:33 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86: Merge xc_cpu_policy's cpuid and msr objects
    
    Right now, they're the same underlying type, containing disjoint information.
    
    Use a single object instead.  Also take the opportunity to rename 'entries' to
    'msrs' which is more descriptive, and more in line with nr_msrs being the
    count of MSR entries in the API.
    
    test-tsx uses xg_private.h to access the internals of xc_cpu_policy, so needs
    updating at the same time.  Take the opportunity to improve the code clarity
    by passing a cpu_policy rather than an xc_cpu_policy into some functions.
    
    No practical change.  This undoes the transient doubling of storage space from
    earlier patches.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit c9985233ca663fea20fc8807cf509d2e3fef0dca)
---
 tools/libxc/xc_cpuid_x86.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index 08e8772417..539b0d2bde 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -434,7 +434,7 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, bool restore,
     xc_dominfo_t di;
     unsigned int i, nr_leaves, nr_msrs;
     xen_cpuid_leaf_t *leaves = NULL;
-    struct cpuid_policy *p = NULL;
+    struct cpu_policy *p = NULL;
     uint32_t err_leaf = -1, err_subleaf = -1, err_msr = -1;
     uint32_t host_featureset[FEATURESET_NR_ENTRIES] = {};
     uint32_t len = ARRAY_SIZE(host_featureset);
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:01:27 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:01:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680907.1059200 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGlL-0006Z0-DL; Wed, 14 Feb 2024 15:01:27 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680907.1059200; Wed, 14 Feb 2024 15:01:27 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGlL-0006Yt-A9; Wed, 14 Feb 2024 15:01:27 +0000
Received: by outflank-mailman (input) for mailman id 680907;
 Wed, 14 Feb 2024 15:01:26 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGlJ-0006Yb-WB
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:26 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGlJ-0005lK-VP
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:25 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGlJ-0000Xh-Ui
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:25 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=BNuu7SzrK/UfWuKdP4OfMDWf4vByWNF9uaXRzuesFFQ=; b=ppDeX8ZM3gDLFj5/ChEupkroo8
	wBJFWBV0YwrN//cSRnjUE2lWpVXLGU+PQYcq65m7V5b+VI/zqxjDPTSCQNl7/8gZAKeUmimXCCKZs
	MGpTNXEOPTR4AkolFQQXX/uSSR7ZizldBGMZ/o7nxYw7PZjg1nshE3BK+aV861RC6fFE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86: Drop struct old_cpu_policy
Message-Id: <E1raGlJ-0000Xh-Ui@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:01:25 +0000

commit bdcc1765f184e2b3678b5c1fc77bb9dd8681e426
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Mar 29 12:01:33 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86: Drop struct old_cpu_policy
    
    With all the complicated callers of x86_cpu_policies_are_compatible() updated
    to use a single cpu_policy object, we can drop the final user of struct
    old_cpu_policy.
    
    Update x86_cpu_policies_are_compatible() to take (new) cpu_policy pointers,
    reducing the amount of internal pointer chasing, and update all callers to
    pass their cpu_policy objects directly.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 66c5c99656314451ff9520f91cff5bb39fee9fed)
---
 tools/tests/cpu-policy/test-cpu-policy.c | 50 ++++++++++----------------------
 xen/arch/x86/domctl.c                    |  7 ++---
 xen/include/xen/lib/x86/cpu-policy.h     | 12 ++------
 xen/lib/x86/policy.c                     | 10 +++----
 4 files changed, 25 insertions(+), 54 deletions(-)

diff --git a/tools/tests/cpu-policy/test-cpu-policy.c b/tools/tests/cpu-policy/test-cpu-policy.c
index d8af5581ab..a7c19be63f 100644
--- a/tools/tests/cpu-policy/test-cpu-policy.c
+++ b/tools/tests/cpu-policy/test-cpu-policy.c
@@ -88,7 +88,7 @@ static bool leaves_are_sorted(const xen_cpuid_leaf_t *leaves, unsigned int nr)
 
 static void test_cpuid_current(void)
 {
-    struct cpuid_policy p;
+    struct cpu_policy p;
     xen_cpuid_leaf_t leaves[CPUID_MAX_SERIALISED_LEAVES];
     unsigned int nr = ARRAY_SIZE(leaves);
     int rc;
@@ -108,7 +108,7 @@ static void test_cpuid_current(void)
 static void test_cpuid_serialise_success(void)
 {
     static const struct test {
-        struct cpuid_policy p;
+        struct cpu_policy p;
         const char *name;
         unsigned int nr_leaves;
     } tests[] = {
@@ -232,7 +232,7 @@ static void test_cpuid_serialise_success(void)
 static void test_msr_serialise_success(void)
 {
     static const struct test {
-        struct msr_policy p;
+        struct cpu_policy p;
         const char *name;
         unsigned int nr_msrs;
     } tests[] = {
@@ -413,7 +413,7 @@ static void test_cpuid_out_of_range_clearing(void)
     static const struct test {
         const char *name;
         unsigned int nr_markers;
-        struct cpuid_policy p;
+        struct cpu_policy p;
     } tests[] = {
         {
             .name = "basic",
@@ -533,7 +533,7 @@ static void test_cpuid_out_of_range_clearing(void)
     for ( size_t i = 0; i < ARRAY_SIZE(tests); ++i )
     {
         const struct test *t = &tests[i];
-        struct cpuid_policy *p = memdup(&t->p);
+        struct cpu_policy *p = memdup(&t->p);
         void *ptr;
         unsigned int nr_markers;
 
@@ -557,23 +557,20 @@ static void test_is_compatible_success(void)
 {
     static struct test {
         const char *name;
-        struct cpuid_policy host_cpuid;
-        struct cpuid_policy guest_cpuid;
-        struct msr_policy host_msr;
-        struct msr_policy guest_msr;
+        struct cpu_policy host, guest;
     } tests[] = {
         {
             .name = "Host CPUID faulting, Guest not",
-            .host_msr = {
+            .host = {
                 .platform_info.cpuid_faulting = true,
             },
         },
         {
             .name = "Host CPUID faulting, Guest wanted",
-            .host_msr = {
+            .host = {
                 .platform_info.cpuid_faulting = true,
             },
-            .guest_msr = {
+            .guest = {
                 .platform_info.cpuid_faulting = true,
             },
         },
@@ -585,15 +582,8 @@ static void test_is_compatible_success(void)
     for ( size_t i = 0; i < ARRAY_SIZE(tests); ++i )
     {
         struct test *t = &tests[i];
-        struct old_cpu_policy sys = {
-            &t->host_cpuid,
-            &t->host_msr,
-        }, new = {
-            &t->guest_cpuid,
-            &t->guest_msr,
-        };
         struct cpu_policy_errors e;
-        int res = x86_cpu_policies_are_compatible(&sys, &new, &e);
+        int res = x86_cpu_policies_are_compatible(&t->host, &t->guest, &e);
 
         /* Check the expected error output. */
         if ( res != 0 || memcmp(&no_errors, &e, sizeof(no_errors)) )
@@ -607,25 +597,22 @@ static void test_is_compatible_failure(void)
 {
     static struct test {
         const char *name;
-        struct cpuid_policy host_cpuid;
-        struct cpuid_policy guest_cpuid;
-        struct msr_policy host_msr;
-        struct msr_policy guest_msr;
+        struct cpu_policy host, guest;
         struct cpu_policy_errors e;
     } tests[] = {
         {
             .name = "Host basic.max_leaf out of range",
-            .guest_cpuid.basic.max_leaf = 1,
+            .guest.basic.max_leaf = 1,
             .e = { 0, -1, -1 },
         },
         {
             .name = "Host extd.max_leaf out of range",
-            .guest_cpuid.extd.max_leaf = 1,
+            .guest.extd.max_leaf = 1,
             .e = { 0x80000000, -1, -1 },
         },
         {
             .name = "Host no CPUID faulting, Guest wanted",
-            .guest_msr = {
+            .guest = {
                 .platform_info.cpuid_faulting = true,
             },
             .e = { -1, -1, 0xce },
@@ -637,15 +624,8 @@ static void test_is_compatible_failure(void)
     for ( size_t i = 0; i < ARRAY_SIZE(tests); ++i )
     {
         struct test *t = &tests[i];
-        struct old_cpu_policy sys = {
-            &t->host_cpuid,
-            &t->host_msr,
-        }, new = {
-            &t->guest_cpuid,
-            &t->guest_msr,
-        };
         struct cpu_policy_errors e;
-        int res = x86_cpu_policies_are_compatible(&sys, &new, &e);
+        int res = x86_cpu_policies_are_compatible(&t->host, &t->guest, &e);
 
         /* Check the expected error output. */
         if ( res == 0 || memcmp(&t->e, &e, sizeof(t->e)) )
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index c000ed71bd..adf70607c7 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -220,10 +220,9 @@ static int update_domain_cpu_policy(struct domain *d,
                                     xen_domctl_cpu_policy_t *xdpc)
 {
     struct cpu_policy *new;
-    struct cpu_policy *sys = is_pv_domain(d)
+    const struct cpu_policy *sys = is_pv_domain(d)
         ? (IS_ENABLED(CONFIG_PV)  ?  &pv_max_cpu_policy : NULL)
         : (IS_ENABLED(CONFIG_HVM) ? &hvm_max_cpu_policy : NULL);
-    struct old_cpu_policy old_sys = { sys, sys }, old_new;
     struct cpu_policy_errors err = INIT_CPU_POLICY_ERRORS;
     int ret = -ENOMEM;
 
@@ -237,8 +236,6 @@ static int update_domain_cpu_policy(struct domain *d,
     if ( !(new = xmemdup(d->arch.cpu_policy)) )
         goto out;
 
-    old_new = (struct old_cpu_policy){ new, new };
-
     /* Merge the toolstack provided data. */
     if ( (ret = x86_cpuid_copy_from_buffer(
               new, xdpc->leaves, xdpc->nr_leaves,
@@ -251,7 +248,7 @@ static int update_domain_cpu_policy(struct domain *d,
     x86_cpuid_policy_clear_out_of_range_leaves(new);
 
     /* Audit the combined dataset. */
-    ret = x86_cpu_policies_are_compatible(&old_sys, &old_new, &err);
+    ret = x86_cpu_policies_are_compatible(sys, new, &err);
     if ( ret )
         goto out;
 
diff --git a/xen/include/xen/lib/x86/cpu-policy.h b/xen/include/xen/lib/x86/cpu-policy.h
index 53fffca552..8b27a0725b 100644
--- a/xen/include/xen/lib/x86/cpu-policy.h
+++ b/xen/include/xen/lib/x86/cpu-policy.h
@@ -379,12 +379,6 @@ struct cpu_policy
 #define cpuid_policy cpu_policy
 #define msr_policy cpu_policy
 
-struct old_cpu_policy
-{
-    struct cpuid_policy *cpuid;
-    struct msr_policy *msr;
-};
-
 struct cpu_policy_errors
 {
     uint32_t leaf, subleaf;
@@ -559,7 +553,7 @@ int x86_msr_copy_from_buffer(struct msr_policy *policy,
                              const msr_entry_buffer_t msrs, uint32_t nr_entries,
                              uint32_t *err_msr);
 
-/*
+/**
  * Calculate whether two policies are compatible.
  *
  * i.e. Can a VM configured with @guest run on a CPU supporting @host.
@@ -573,8 +567,8 @@ int x86_msr_copy_from_buffer(struct msr_policy *policy,
  * incompatibility is detected, the optional err pointer may identify the
  * problematic leaf/subleaf and/or MSR.
  */
-int x86_cpu_policies_are_compatible(const struct old_cpu_policy *host,
-                                    const struct old_cpu_policy *guest,
+int x86_cpu_policies_are_compatible(const struct cpu_policy *host,
+                                    const struct cpu_policy *guest,
                                     struct cpu_policy_errors *err);
 
 #endif /* !XEN_LIB_X86_POLICIES_H */
diff --git a/xen/lib/x86/policy.c b/xen/lib/x86/policy.c
index cb2d3b8dfa..29597af833 100644
--- a/xen/lib/x86/policy.c
+++ b/xen/lib/x86/policy.c
@@ -2,8 +2,8 @@
 
 #include <xen/lib/x86/cpu-policy.h>
 
-int x86_cpu_policies_are_compatible(const struct old_cpu_policy *host,
-                                    const struct old_cpu_policy *guest,
+int x86_cpu_policies_are_compatible(const struct cpu_policy *host,
+                                    const struct cpu_policy *guest,
                                     struct cpu_policy_errors *err)
 {
     struct cpu_policy_errors e = INIT_CPU_POLICY_ERRORS;
@@ -15,15 +15,15 @@ int x86_cpu_policies_are_compatible(const struct old_cpu_policy *host,
 #define FAIL_MSR(m) \
     do { e.msr = (m); goto out; } while ( 0 )
 
-    if ( guest->cpuid->basic.max_leaf > host->cpuid->basic.max_leaf )
+    if ( guest->basic.max_leaf > host->basic.max_leaf )
         FAIL_CPUID(0, NA);
 
-    if ( guest->cpuid->extd.max_leaf > host->cpuid->extd.max_leaf )
+    if ( guest->extd.max_leaf > host->extd.max_leaf )
         FAIL_CPUID(0x80000000, NA);
 
     /* TODO: Audit more CPUID data. */
 
-    if ( ~host->msr->platform_info.raw & guest->msr->platform_info.raw )
+    if ( ~host->platform_info.raw & guest->platform_info.raw )
         FAIL_MSR(MSR_INTEL_PLATFORM_INFO);
 
 #undef FAIL_MSR
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:01:37 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:01:37 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680908.1059204 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGlV-0006cZ-Fn; Wed, 14 Feb 2024 15:01:37 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680908.1059204; Wed, 14 Feb 2024 15:01:37 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGlV-0006cS-DH; Wed, 14 Feb 2024 15:01:37 +0000
Received: by outflank-mailman (input) for mailman id 680908;
 Wed, 14 Feb 2024 15:01:36 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGlU-0006bv-3M
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:36 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGlU-0005lQ-2T
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:36 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGlU-0000YU-1e
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:36 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=+Ba57+jzgfamVRU/7dtzYqLXnF3lfLMXA9SNCPE5At0=; b=NKMrOkvfojdsguWEoDmvDwRbnH
	BrSgBPXvGiO44bJ4yJrqY3+sF7JcS4xIHEyejbPKlJx1IcaMCecUo28dMHBijDRMqopG9Q5tq2zhV
	t7P+S7i3Hz+mtLom/tFtoMNSDduMtAGPWo4InHIXdWHpW92tAq9kZTfCChC0VE3eYzvQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86: Out-of-inline the policy<->featureset convertors
Message-Id: <E1raGlU-0000YU-1e@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:01:36 +0000

commit 4ff61b27a3a7f258fdd38fb39e8f26b5755a72f6
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Thu Mar 30 18:21:01 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86: Out-of-inline the policy<->featureset convertors
    
    These are already getting over-large for being inline functions, and are only
    going to grow further over time.  Out of line them, yielding the following net
    delta from bloat-o-meter:
    
      add/remove: 2/0 grow/shrink: 0/4 up/down: 276/-1877 (-1601)
    
    Switch to the newer cpu_policy terminology while doing so.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 1027df4c00823f8b448e3a6861cc7b6ce61ba4e4)
---
 tools/libxc/xc_cpuid_x86.c           |  2 +-
 xen/arch/x86/cpuid.c                 | 28 +++++++++----------
 xen/arch/x86/sysctl.c                |  2 +-
 xen/include/xen/lib/x86/cpu-policy.h | 52 +++++++-----------------------------
 xen/lib/x86/cpuid.c                  | 42 +++++++++++++++++++++++++++++
 5 files changed, 68 insertions(+), 58 deletions(-)

diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index 539b0d2bde..b936e1d0e0 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -568,7 +568,7 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, bool restore,
             }
         }
 
-        cpuid_featureset_to_policy(feat, p);
+        x86_cpu_featureset_to_policy(feat, p);
     }
     else
     {
diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index 026a6cc523..f096713044 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -367,7 +367,7 @@ static void __init calculate_host_policy(void)
     p->extd.max_leaf = 0x80000000 | min_t(uint32_t, max_extd_leaf & 0xffff,
                                           ARRAY_SIZE(p->extd.raw) - 1);
 
-    cpuid_featureset_to_policy(boot_cpu_data.x86_capability, p);
+    x86_cpu_featureset_to_policy(boot_cpu_data.x86_capability, p);
     recalculate_xstate(p);
     recalculate_misc(p);
 
@@ -449,7 +449,7 @@ static void __init calculate_pv_max_policy(void)
     unsigned int i;
 
     *p = host_cpu_policy;
-    cpuid_policy_to_featureset(p, pv_featureset);
+    x86_cpu_policy_to_featureset(p, pv_featureset);
 
     for ( i = 0; i < ARRAY_SIZE(pv_featureset); ++i )
         pv_featureset[i] &= pv_max_featuremask[i];
@@ -467,7 +467,7 @@ static void __init calculate_pv_max_policy(void)
     guest_common_feature_adjustments(pv_featureset);
 
     sanitise_featureset(pv_featureset);
-    cpuid_featureset_to_policy(pv_featureset, p);
+    x86_cpu_featureset_to_policy(pv_featureset, p);
     recalculate_xstate(p);
 
     p->extd.raw[0xa] = EMPTY_LEAF; /* No SVM for PV guests. */
@@ -480,7 +480,7 @@ static void __init calculate_pv_def_policy(void)
     unsigned int i;
 
     *p = pv_max_cpu_policy;
-    cpuid_policy_to_featureset(p, pv_featureset);
+    x86_cpu_policy_to_featureset(p, pv_featureset);
 
     for ( i = 0; i < ARRAY_SIZE(pv_featureset); ++i )
         pv_featureset[i] &= pv_def_featuremask[i];
@@ -489,7 +489,7 @@ static void __init calculate_pv_def_policy(void)
     guest_common_default_feature_adjustments(pv_featureset);
 
     sanitise_featureset(pv_featureset);
-    cpuid_featureset_to_policy(pv_featureset, p);
+    x86_cpu_featureset_to_policy(pv_featureset, p);
     recalculate_xstate(p);
 }
 
@@ -501,7 +501,7 @@ static void __init calculate_hvm_max_policy(void)
     const uint32_t *hvm_featuremask;
 
     *p = host_cpu_policy;
-    cpuid_policy_to_featureset(p, hvm_featureset);
+    x86_cpu_policy_to_featureset(p, hvm_featureset);
 
     hvm_featuremask = hvm_hap_supported() ?
         hvm_hap_max_featuremask : hvm_shadow_max_featuremask;
@@ -551,7 +551,7 @@ static void __init calculate_hvm_max_policy(void)
     guest_common_feature_adjustments(hvm_featureset);
 
     sanitise_featureset(hvm_featureset);
-    cpuid_featureset_to_policy(hvm_featureset, p);
+    x86_cpu_featureset_to_policy(hvm_featureset, p);
     recalculate_xstate(p);
 }
 
@@ -563,7 +563,7 @@ static void __init calculate_hvm_def_policy(void)
     const uint32_t *hvm_featuremask;
 
     *p = hvm_max_cpu_policy;
-    cpuid_policy_to_featureset(p, hvm_featureset);
+    x86_cpu_policy_to_featureset(p, hvm_featureset);
 
     hvm_featuremask = hvm_hap_supported() ?
         hvm_hap_def_featuremask : hvm_shadow_def_featuremask;
@@ -575,7 +575,7 @@ static void __init calculate_hvm_def_policy(void)
     guest_common_default_feature_adjustments(hvm_featureset);
 
     sanitise_featureset(hvm_featureset);
-    cpuid_featureset_to_policy(hvm_featureset, p);
+    x86_cpu_featureset_to_policy(hvm_featureset, p);
     recalculate_xstate(p);
 }
 
@@ -645,8 +645,8 @@ void recalculate_cpuid_policy(struct domain *d)
                                             ? CPUID_GUEST_NR_EXTD_AMD
                                             : CPUID_GUEST_NR_EXTD_INTEL) - 1);
 
-    cpuid_policy_to_featureset(p, fs);
-    cpuid_policy_to_featureset(max, max_fs);
+    x86_cpu_policy_to_featureset(p, fs);
+    x86_cpu_policy_to_featureset(max, max_fs);
 
     if ( is_hvm_domain(d) )
     {
@@ -711,7 +711,7 @@ void recalculate_cpuid_policy(struct domain *d)
                            (cpufeat_mask(X86_FEATURE_FDP_EXCP_ONLY) |
                             cpufeat_mask(X86_FEATURE_NO_FPU_SEL)));
 
-    cpuid_featureset_to_policy(fs, p);
+    x86_cpu_featureset_to_policy(fs, p);
 
     /* Pass host cacheline size through to guests. */
     p->basic.clflush_size = max->basic.clflush_size;
@@ -777,7 +777,7 @@ void __init init_dom0_cpuid_policy(struct domain *d)
         uint32_t fs[FSCAPINTS];
         unsigned int i;
 
-        cpuid_policy_to_featureset(p, fs);
+        x86_cpu_policy_to_featureset(p, fs);
 
         for ( i = 0; i < ARRAY_SIZE(fs); ++i )
         {
@@ -785,7 +785,7 @@ void __init init_dom0_cpuid_policy(struct domain *d)
             fs[i] &= ~dom0_disable_feat[i];
         }
 
-        cpuid_featureset_to_policy(fs, p);
+        x86_cpu_featureset_to_policy(fs, p);
 
         recalculate_cpuid_policy(d);
     }
diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c
index 99d5c1b85b..4492525735 100644
--- a/xen/arch/x86/sysctl.c
+++ b/xen/arch/x86/sysctl.c
@@ -369,7 +369,7 @@ long arch_do_sysctl(
             ret = -EINVAL;
 
         if ( !ret )
-            cpuid_policy_to_featureset(p, featureset);
+            x86_cpu_policy_to_featureset(p, featureset);
 
         /* Copy the requested featureset into place. */
         if ( !ret && copy_to_guest(sysctl->u.cpu_featureset.features,
diff --git a/xen/include/xen/lib/x86/cpu-policy.h b/xen/include/xen/lib/x86/cpu-policy.h
index 8b27a0725b..57b4633c86 100644
--- a/xen/include/xen/lib/x86/cpu-policy.h
+++ b/xen/include/xen/lib/x86/cpu-policy.h
@@ -387,49 +387,17 @@ struct cpu_policy_errors
 
 #define INIT_CPU_POLICY_ERRORS { -1, -1, -1 }
 
-/* Fill in a featureset bitmap from a CPUID policy. */
-static inline void cpuid_policy_to_featureset(
-    const struct cpuid_policy *p, uint32_t fs[FEATURESET_NR_ENTRIES])
-{
-    fs[FEATURESET_1d]  = p->basic._1d;
-    fs[FEATURESET_1c]  = p->basic._1c;
-    fs[FEATURESET_e1d] = p->extd.e1d;
-    fs[FEATURESET_e1c] = p->extd.e1c;
-    fs[FEATURESET_Da1] = p->xstate.Da1;
-    fs[FEATURESET_7b0] = p->feat._7b0;
-    fs[FEATURESET_7c0] = p->feat._7c0;
-    fs[FEATURESET_e7d] = p->extd.e7d;
-    fs[FEATURESET_e8b] = p->extd.e8b;
-    fs[FEATURESET_7d0] = p->feat._7d0;
-    fs[FEATURESET_7a1] = p->feat._7a1;
-    fs[FEATURESET_e21a] = p->extd.e21a;
-    fs[FEATURESET_7b1] = p->feat._7b1;
-    fs[FEATURESET_7d2] = p->feat._7d2;
-    fs[FEATURESET_7c1] = p->feat._7c1;
-    fs[FEATURESET_7d1] = p->feat._7d1;
-}
+/**
+ * Copy the featureset words out of a cpu_policy object.
+ */
+void x86_cpu_policy_to_featureset(const struct cpu_policy *p,
+                                  uint32_t fs[FEATURESET_NR_ENTRIES]);
 
-/* Fill in a CPUID policy from a featureset bitmap. */
-static inline void cpuid_featureset_to_policy(
-    const uint32_t fs[FEATURESET_NR_ENTRIES], struct cpuid_policy *p)
-{
-    p->basic._1d  = fs[FEATURESET_1d];
-    p->basic._1c  = fs[FEATURESET_1c];
-    p->extd.e1d   = fs[FEATURESET_e1d];
-    p->extd.e1c   = fs[FEATURESET_e1c];
-    p->xstate.Da1 = fs[FEATURESET_Da1];
-    p->feat._7b0  = fs[FEATURESET_7b0];
-    p->feat._7c0  = fs[FEATURESET_7c0];
-    p->extd.e7d   = fs[FEATURESET_e7d];
-    p->extd.e8b   = fs[FEATURESET_e8b];
-    p->feat._7d0  = fs[FEATURESET_7d0];
-    p->feat._7a1  = fs[FEATURESET_7a1];
-    p->extd.e21a  = fs[FEATURESET_e21a];
-    p->feat._7b1  = fs[FEATURESET_7b1];
-    p->feat._7d2  = fs[FEATURESET_7d2];
-    p->feat._7c1  = fs[FEATURESET_7c1];
-    p->feat._7d1  = fs[FEATURESET_7d1];
-}
+/**
+ * Copy the featureset words back into a cpu_policy object.
+ */
+void x86_cpu_featureset_to_policy(const uint32_t fs[FEATURESET_NR_ENTRIES],
+                                  struct cpu_policy *p);
 
 static inline uint64_t cpuid_policy_xcr0_max(const struct cpuid_policy *p)
 {
diff --git a/xen/lib/x86/cpuid.c b/xen/lib/x86/cpuid.c
index b2def4c9bc..275bea7dff 100644
--- a/xen/lib/x86/cpuid.c
+++ b/xen/lib/x86/cpuid.c
@@ -60,6 +60,48 @@ const char *x86_cpuid_vendor_to_str(unsigned int vendor)
     }
 }
 
+void x86_cpu_policy_to_featureset(
+    const struct cpu_policy *p, uint32_t fs[FEATURESET_NR_ENTRIES])
+{
+    fs[FEATURESET_1d]        = p->basic._1d;
+    fs[FEATURESET_1c]        = p->basic._1c;
+    fs[FEATURESET_e1d]       = p->extd.e1d;
+    fs[FEATURESET_e1c]       = p->extd.e1c;
+    fs[FEATURESET_Da1]       = p->xstate.Da1;
+    fs[FEATURESET_7b0]       = p->feat._7b0;
+    fs[FEATURESET_7c0]       = p->feat._7c0;
+    fs[FEATURESET_e7d]       = p->extd.e7d;
+    fs[FEATURESET_e8b]       = p->extd.e8b;
+    fs[FEATURESET_7d0]       = p->feat._7d0;
+    fs[FEATURESET_7a1]       = p->feat._7a1;
+    fs[FEATURESET_e21a]      = p->extd.e21a;
+    fs[FEATURESET_7b1]       = p->feat._7b1;
+    fs[FEATURESET_7d2]       = p->feat._7d2;
+    fs[FEATURESET_7c1]       = p->feat._7c1;
+    fs[FEATURESET_7d1]       = p->feat._7d1;
+}
+
+void x86_cpu_featureset_to_policy(
+    const uint32_t fs[FEATURESET_NR_ENTRIES], struct cpu_policy *p)
+{
+    p->basic._1d             = fs[FEATURESET_1d];
+    p->basic._1c             = fs[FEATURESET_1c];
+    p->extd.e1d              = fs[FEATURESET_e1d];
+    p->extd.e1c              = fs[FEATURESET_e1c];
+    p->xstate.Da1            = fs[FEATURESET_Da1];
+    p->feat._7b0             = fs[FEATURESET_7b0];
+    p->feat._7c0             = fs[FEATURESET_7c0];
+    p->extd.e7d              = fs[FEATURESET_e7d];
+    p->extd.e8b              = fs[FEATURESET_e8b];
+    p->feat._7d0             = fs[FEATURESET_7d0];
+    p->feat._7a1             = fs[FEATURESET_7a1];
+    p->extd.e21a             = fs[FEATURESET_e21a];
+    p->feat._7b1             = fs[FEATURESET_7b1];
+    p->feat._7d2             = fs[FEATURESET_7d2];
+    p->feat._7c1             = fs[FEATURESET_7c1];
+    p->feat._7d1             = fs[FEATURESET_7d1];
+}
+
 void x86_cpuid_policy_recalc_synth(struct cpuid_policy *p)
 {
     p->x86_vendor = x86_cpuid_lookup_vendor(
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:01:46 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:01:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680909.1059209 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGle-0006fA-HY; Wed, 14 Feb 2024 15:01:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680909.1059209; Wed, 14 Feb 2024 15:01:46 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGle-0006f3-El; Wed, 14 Feb 2024 15:01:46 +0000
Received: by outflank-mailman (input) for mailman id 680909;
 Wed, 14 Feb 2024 15:01:46 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGle-0006et-6i
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:46 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGle-0005lY-5t
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:46 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGle-0000ZJ-59
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:46 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=VFPd+2f2S2DPYKXniHK+EM9Andrzg6Dhlkj3NGDE3N8=; b=C9VoIP1co63LKO7Yvw9MbNg5hb
	/EbrrG4RBClhtNshnqA6kTaDCvnWcN95n62WYH3gWuOo4I//pPxRHK8B+VO2K89srVuk12GkA6+jV
	jfTruNRvFGPWvgxOJO7rsCIWO15rTgwcmug7XNhHdRhBYNeCfUKpfEyMakfdHA2C0E8I=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/boot: Move MSR policy initialisation logic into cpu-policy.c
Message-Id: <E1raGle-0000ZJ-59@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:01:46 +0000

commit 279c1fb626141a6b007c172dcacbe4d07de2f948
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon Apr 3 17:48:43 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/boot: Move MSR policy initialisation logic into cpu-policy.c
    
    Switch to the newer cpu_policy nomenclature.
    
    No practical change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 4f20f596ce9bd95bde077a1ae0d7e07d20a5f6be)
---
 xen/arch/x86/cpu-policy.c        | 84 ++++++++++++++++++++++++++++++++++++++++
 xen/arch/x86/msr.c               | 84 ----------------------------------------
 xen/arch/x86/setup.c             |  3 +-
 xen/include/asm-x86/cpu-policy.h |  3 ++
 xen/include/asm-x86/msr.h        |  1 -
 5 files changed, 89 insertions(+), 86 deletions(-)

diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
index 4c5fd70cf1..d774d281c2 100644
--- a/xen/arch/x86/cpu-policy.c
+++ b/xen/arch/x86/cpu-policy.c
@@ -20,6 +20,90 @@ struct cpu_policy __read_mostly   hvm_max_cpu_policy;
 struct cpu_policy __read_mostly   hvm_def_cpu_policy;
 #endif
 
+static void __init calculate_raw_policy(void)
+{
+    struct cpu_policy *p = &raw_cpu_policy;
+
+    /* 0x000000ce  MSR_INTEL_PLATFORM_INFO */
+    /* Was already added by probe_cpuid_faulting() */
+
+    if ( cpu_has_arch_caps )
+        rdmsrl(MSR_ARCH_CAPABILITIES, p->arch_caps.raw);
+}
+
+static void __init calculate_host_policy(void)
+{
+    struct cpu_policy *p = &host_cpu_policy;
+
+    *p = raw_cpu_policy;
+
+    /* 0x000000ce  MSR_INTEL_PLATFORM_INFO */
+    /* probe_cpuid_faulting() sanity checks presence of MISC_FEATURES_ENABLES */
+    p->platform_info.cpuid_faulting = cpu_has_cpuid_faulting;
+
+    /* Temporary, until we have known_features[] for feature bits in MSRs. */
+    p->arch_caps.raw &=
+        (ARCH_CAPS_RDCL_NO | ARCH_CAPS_IBRS_ALL | ARCH_CAPS_RSBA |
+         ARCH_CAPS_SKIP_L1DFL | ARCH_CAPS_SSB_NO | ARCH_CAPS_MDS_NO |
+         ARCH_CAPS_IF_PSCHANGE_MC_NO | ARCH_CAPS_TSX_CTRL | ARCH_CAPS_TAA_NO |
+         ARCH_CAPS_SBDR_SSDP_NO | ARCH_CAPS_FBSDP_NO | ARCH_CAPS_PSDP_NO |
+         ARCH_CAPS_FB_CLEAR | ARCH_CAPS_RRSBA | ARCH_CAPS_BHI_NO |
+         ARCH_CAPS_PBRSB_NO);
+}
+
+static void __init calculate_pv_max_policy(void)
+{
+    struct cpu_policy *p = &pv_max_cpu_policy;
+
+    *p = host_cpu_policy;
+
+    p->arch_caps.raw = 0; /* Not supported yet. */
+}
+
+static void __init calculate_pv_def_policy(void)
+{
+    struct cpu_policy *p = &pv_def_cpu_policy;
+
+    *p = pv_max_cpu_policy;
+}
+
+static void __init calculate_hvm_max_policy(void)
+{
+    struct cpu_policy *p = &hvm_max_cpu_policy;
+
+    *p = host_cpu_policy;
+
+    /* It's always possible to emulate CPUID faulting for HVM guests */
+    p->platform_info.cpuid_faulting = true;
+
+    p->arch_caps.raw = 0; /* Not supported yet. */
+}
+
+static void __init calculate_hvm_def_policy(void)
+{
+    struct cpu_policy *p = &hvm_def_cpu_policy;
+
+    *p = hvm_max_cpu_policy;
+}
+
+void __init init_guest_cpu_policies(void)
+{
+    calculate_raw_policy();
+    calculate_host_policy();
+
+    if ( IS_ENABLED(CONFIG_PV) )
+    {
+        calculate_pv_max_policy();
+        calculate_pv_def_policy();
+    }
+
+    if ( hvm_enabled )
+    {
+        calculate_hvm_max_policy();
+        calculate_hvm_def_policy();
+    }
+}
+
 int init_domain_cpu_policy(struct domain *d)
 {
     struct cpu_policy *p = is_pv_domain(d)
diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index 7bf8516e26..40a7a93b24 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -35,90 +35,6 @@
 
 DEFINE_PER_CPU(uint32_t, tsc_aux);
 
-static void __init calculate_raw_policy(void)
-{
-    struct msr_policy *mp = &raw_cpu_policy;
-
-    /* 0x000000ce  MSR_INTEL_PLATFORM_INFO */
-    /* Was already added by probe_cpuid_faulting() */
-
-    if ( cpu_has_arch_caps )
-        rdmsrl(MSR_ARCH_CAPABILITIES, mp->arch_caps.raw);
-}
-
-static void __init calculate_host_policy(void)
-{
-    struct msr_policy *mp = &host_cpu_policy;
-
-    *mp = raw_cpu_policy;
-
-    /* 0x000000ce  MSR_INTEL_PLATFORM_INFO */
-    /* probe_cpuid_faulting() sanity checks presence of MISC_FEATURES_ENABLES */
-    mp->platform_info.cpuid_faulting = cpu_has_cpuid_faulting;
-
-    /* Temporary, until we have known_features[] for feature bits in MSRs. */
-    mp->arch_caps.raw &=
-        (ARCH_CAPS_RDCL_NO | ARCH_CAPS_IBRS_ALL | ARCH_CAPS_RSBA |
-         ARCH_CAPS_SKIP_L1DFL | ARCH_CAPS_SSB_NO | ARCH_CAPS_MDS_NO |
-         ARCH_CAPS_IF_PSCHANGE_MC_NO | ARCH_CAPS_TSX_CTRL | ARCH_CAPS_TAA_NO |
-         ARCH_CAPS_SBDR_SSDP_NO | ARCH_CAPS_FBSDP_NO | ARCH_CAPS_PSDP_NO |
-         ARCH_CAPS_FB_CLEAR | ARCH_CAPS_RRSBA | ARCH_CAPS_BHI_NO |
-         ARCH_CAPS_PBRSB_NO);
-}
-
-static void __init calculate_pv_max_policy(void)
-{
-    struct msr_policy *mp = &pv_max_cpu_policy;
-
-    *mp = host_cpu_policy;
-
-    mp->arch_caps.raw = 0; /* Not supported yet. */
-}
-
-static void __init calculate_pv_def_policy(void)
-{
-    struct msr_policy *mp = &pv_def_cpu_policy;
-
-    *mp = pv_max_cpu_policy;
-}
-
-static void __init calculate_hvm_max_policy(void)
-{
-    struct msr_policy *mp = &hvm_max_cpu_policy;
-
-    *mp = host_cpu_policy;
-
-    /* It's always possible to emulate CPUID faulting for HVM guests */
-    mp->platform_info.cpuid_faulting = true;
-
-    mp->arch_caps.raw = 0; /* Not supported yet. */
-}
-
-static void __init calculate_hvm_def_policy(void)
-{
-    struct msr_policy *mp = &hvm_def_cpu_policy;
-
-    *mp = hvm_max_cpu_policy;
-}
-
-void __init init_guest_msr_policy(void)
-{
-    calculate_raw_policy();
-    calculate_host_policy();
-
-    if ( IS_ENABLED(CONFIG_PV) )
-    {
-        calculate_pv_max_policy();
-        calculate_pv_def_policy();
-    }
-
-    if ( hvm_enabled )
-    {
-        calculate_hvm_max_policy();
-        calculate_hvm_def_policy();
-    }
-}
-
 int init_vcpu_msr_policy(struct vcpu *v)
 {
     struct vcpu_msrs *msrs = xzalloc(struct vcpu_msrs);
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 44b09b8be9..7a5253fd40 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -49,6 +49,7 @@
 #include <asm/nmi.h>
 #include <asm/alternative.h>
 #include <asm/mc146818rtc.h>
+#include <asm/cpu-policy.h>
 #include <asm/cpuid.h>
 #include <asm/spec_ctrl.h>
 #include <asm/guest.h>
@@ -1945,7 +1946,7 @@ void __init noreturn __start_xen(unsigned long mbi_p)
         panic("Could not protect TXT memory regions\n");
 
     init_guest_cpuid();
-    init_guest_msr_policy();
+    init_guest_cpu_policies();
 
     if ( xen_cpuidle )
         xen_processor_pmbits |= XEN_PROCESSOR_PM_CX;
diff --git a/xen/include/asm-x86/cpu-policy.h b/xen/include/asm-x86/cpu-policy.h
index 9ba34bbf5e..13e2a1f86d 100644
--- a/xen/include/asm-x86/cpu-policy.h
+++ b/xen/include/asm-x86/cpu-policy.h
@@ -12,6 +12,9 @@ extern struct cpu_policy  pv_def_cpu_policy;
 extern struct cpu_policy hvm_max_cpu_policy;
 extern struct cpu_policy hvm_def_cpu_policy;
 
+/* Initialise the guest cpu_policy objects. */
+void init_guest_cpu_policies(void);
+
 /* Allocate and initialise a CPU policy suitable for the domain. */
 int init_domain_cpu_policy(struct domain *d);
 
diff --git a/xen/include/asm-x86/msr.h b/xen/include/asm-x86/msr.h
index b9d0a96d9d..b509a5e564 100644
--- a/xen/include/asm-x86/msr.h
+++ b/xen/include/asm-x86/msr.h
@@ -333,7 +333,6 @@ struct vcpu_msrs
     uint32_t dr_mask[4];
 };
 
-void init_guest_msr_policy(void);
 int init_vcpu_msr_policy(struct vcpu *v);
 
 /*
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:01:57 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:01:57 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680910.1059213 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGlp-0006he-JQ; Wed, 14 Feb 2024 15:01:57 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680910.1059213; Wed, 14 Feb 2024 15:01:57 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGlp-0006hX-GW; Wed, 14 Feb 2024 15:01:57 +0000
Received: by outflank-mailman (input) for mailman id 680910;
 Wed, 14 Feb 2024 15:01:56 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGlo-0006hN-AZ
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:56 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGlo-0005m0-9h
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:56 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGlo-0000a6-8q
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:01:56 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=5/yk6gjgl5GbRhjQjl6yWSAEXEnjl/w3t+YrxkLfXZk=; b=djpe3z+5SAwMiApfgVxD/7WEcg
	3MiWX7u9PI9MMfVCOqKb8h6kd2M+Mgm+QZ+7fz2j8ybkUdhiJ737ap+ut5nmKrVoEc9hQtgelgQIX
	FilRp5pk/aLDROw6Ayduy9vEANO+v5Exbj2g7x0PNiTdiTsN5+O5zqQBRvFujfDPbFPQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/boot: Merge CPUID policy initialisation logic into cpu-policy.c
Message-Id: <E1raGlo-0000a6-8q@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:01:56 +0000

commit 4e093cb4605ff043e200ff4d7d6bf367dba95c95
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon Apr 3 19:06:02 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/boot: Merge CPUID policy initialisation logic into cpu-policy.c
    
    Switch to the newer cpu_policy nomenclature.  Do some easy cleanup of
    includes.
    
    No practical change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 8eb56eb959a50bf9afd0fd590ec394e9145970a4)
---
 xen/arch/x86/cpu-policy.c        | 724 +++++++++++++++++++++++++++++++++++
 xen/arch/x86/cpuid.c             | 787 +--------------------------------------
 xen/arch/x86/hvm/hvm.c           |   1 -
 xen/arch/x86/pv/domain.c         |   1 +
 xen/arch/x86/setup.c             |   2 -
 xen/arch/x86/time.c              |   1 +
 xen/include/asm-x86/cpu-policy.h |   6 +
 xen/include/asm-x86/cpuid.h      |  11 +-
 8 files changed, 737 insertions(+), 796 deletions(-)

diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
index d774d281c2..a4ba8e9dea 100644
--- a/xen/arch/x86/cpu-policy.c
+++ b/xen/arch/x86/cpu-policy.c
@@ -1,13 +1,19 @@
 /* SPDX-License-Identifier: GPL-2.0-or-later */
 #include <xen/cache.h>
 #include <xen/kernel.h>
+#include <xen/param.h>
 #include <xen/sched.h>
 
 #include <xen/lib/x86/cpu-policy.h>
 
+#include <asm/amd.h>
 #include <asm/cpu-policy.h>
+#include <asm/hvm/nestedhvm.h>
+#include <asm/hvm/svm/svm.h>
 #include <asm/msr-index.h>
+#include <asm/paging.h>
 #include <asm/setup.h>
+#include <asm/xstate.h>
 
 struct cpu_policy __read_mostly       raw_cpu_policy;
 struct cpu_policy __read_mostly      host_cpu_policy;
@@ -20,10 +26,332 @@ struct cpu_policy __read_mostly   hvm_max_cpu_policy;
 struct cpu_policy __read_mostly   hvm_def_cpu_policy;
 #endif
 
+const uint32_t known_features[] = INIT_KNOWN_FEATURES;
+
+static const uint32_t __initconst pv_max_featuremask[] = INIT_PV_MAX_FEATURES;
+static const uint32_t hvm_shadow_max_featuremask[] = INIT_HVM_SHADOW_MAX_FEATURES;
+static const uint32_t __initconst hvm_hap_max_featuremask[] =
+    INIT_HVM_HAP_MAX_FEATURES;
+static const uint32_t __initconst pv_def_featuremask[] = INIT_PV_DEF_FEATURES;
+static const uint32_t __initconst hvm_shadow_def_featuremask[] =
+    INIT_HVM_SHADOW_DEF_FEATURES;
+static const uint32_t __initconst hvm_hap_def_featuremask[] =
+    INIT_HVM_HAP_DEF_FEATURES;
+static const uint32_t deep_features[] = INIT_DEEP_FEATURES;
+
+static const struct feature_name {
+    const char *name;
+    unsigned int bit;
+} feature_names[] __initconstrel = INIT_FEATURE_NAMES;
+
+/*
+ * Parse a list of cpuid feature names -> bool, calling the callback for any
+ * matches found.
+ *
+ * always_inline, because this is init code only and we really don't want a
+ * function pointer call in the middle of the loop.
+ */
+static int __init always_inline parse_cpuid(
+    const char *s, void (*callback)(unsigned int feat, bool val))
+{
+    const char *ss;
+    int val, rc = 0;
+
+    do {
+        const struct feature_name *lhs, *rhs, *mid = NULL /* GCC... */;
+        const char *feat;
+
+        ss = strchr(s, ',');
+        if ( !ss )
+            ss = strchr(s, '\0');
+
+        /* Skip the 'no-' prefix for name comparisons. */
+        feat = s;
+        if ( strncmp(s, "no-", 3) == 0 )
+            feat += 3;
+
+        /* (Re)initalise lhs and rhs for binary search. */
+        lhs = feature_names;
+        rhs = feature_names + ARRAY_SIZE(feature_names);
+
+        while ( lhs < rhs )
+        {
+            int res;
+
+            mid = lhs + (rhs - lhs) / 2;
+            res = cmdline_strcmp(feat, mid->name);
+
+            if ( res < 0 )
+            {
+                rhs = mid;
+                continue;
+            }
+            if ( res > 0 )
+            {
+                lhs = mid + 1;
+                continue;
+            }
+
+            if ( (val = parse_boolean(mid->name, s, ss)) >= 0 )
+            {
+                callback(mid->bit, val);
+                mid = NULL;
+            }
+
+            break;
+        }
+
+        /*
+         * Mid being NULL means that the name and boolean were successfully
+         * identified.  Everything else is an error.
+         */
+        if ( mid )
+            rc = -EINVAL;
+
+        s = ss + 1;
+    } while ( *ss );
+
+    return rc;
+}
+
+static void __init _parse_xen_cpuid(unsigned int feat, bool val)
+{
+    if ( !val )
+        setup_clear_cpu_cap(feat);
+    else if ( feat == X86_FEATURE_RDRAND &&
+              (cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_RDRAND)) )
+        setup_force_cpu_cap(X86_FEATURE_RDRAND);
+}
+
+static int __init parse_xen_cpuid(const char *s)
+{
+    return parse_cpuid(s, _parse_xen_cpuid);
+}
+custom_param("cpuid", parse_xen_cpuid);
+
+static bool __initdata dom0_cpuid_cmdline;
+static uint32_t __initdata dom0_enable_feat[FSCAPINTS];
+static uint32_t __initdata dom0_disable_feat[FSCAPINTS];
+
+static void __init _parse_dom0_cpuid(unsigned int feat, bool val)
+{
+    __set_bit  (feat, val ? dom0_enable_feat  : dom0_disable_feat);
+    __clear_bit(feat, val ? dom0_disable_feat : dom0_enable_feat );
+}
+
+static int __init parse_dom0_cpuid(const char *s)
+{
+    dom0_cpuid_cmdline = true;
+
+    return parse_cpuid(s, _parse_dom0_cpuid);
+}
+custom_param("dom0-cpuid", parse_dom0_cpuid);
+
+#define EMPTY_LEAF ((struct cpuid_leaf){})
+static void zero_leaves(struct cpuid_leaf *l,
+                        unsigned int first, unsigned int last)
+{
+    memset(&l[first], 0, sizeof(*l) * (last - first + 1));
+}
+
+static void sanitise_featureset(uint32_t *fs)
+{
+    /* for_each_set_bit() uses unsigned longs.  Extend with zeroes. */
+    uint32_t disabled_features[
+        ROUNDUP(FSCAPINTS, sizeof(unsigned long)/sizeof(uint32_t))] = {};
+    unsigned int i;
+
+    for ( i = 0; i < FSCAPINTS; ++i )
+    {
+        /* Clamp to known mask. */
+        fs[i] &= known_features[i];
+
+        /*
+         * Identify which features with deep dependencies have been
+         * disabled.
+         */
+        disabled_features[i] = ~fs[i] & deep_features[i];
+    }
+
+    for_each_set_bit(i, (void *)disabled_features,
+                     sizeof(disabled_features) * 8)
+    {
+        const uint32_t *dfs = x86_cpuid_lookup_deep_deps(i);
+        unsigned int j;
+
+        ASSERT(dfs); /* deep_features[] should guarentee this. */
+
+        for ( j = 0; j < FSCAPINTS; ++j )
+        {
+            fs[j] &= ~dfs[j];
+            disabled_features[j] &= ~dfs[j];
+        }
+    }
+}
+
+static void recalculate_xstate(struct cpu_policy *p)
+{
+    uint64_t xstates = XSTATE_FP_SSE;
+    uint32_t xstate_size = XSTATE_AREA_MIN_SIZE;
+    unsigned int i, Da1 = p->xstate.Da1;
+
+    /*
+     * The Da1 leaf is the only piece of information preserved in the common
+     * case.  Everything else is derived from other feature state.
+     */
+    memset(&p->xstate, 0, sizeof(p->xstate));
+
+    if ( !p->basic.xsave )
+        return;
+
+    if ( p->basic.avx )
+    {
+        xstates |= X86_XCR0_YMM;
+        xstate_size = max(xstate_size,
+                          xstate_offsets[X86_XCR0_YMM_POS] +
+                          xstate_sizes[X86_XCR0_YMM_POS]);
+    }
+
+    if ( p->feat.mpx )
+    {
+        xstates |= X86_XCR0_BNDREGS | X86_XCR0_BNDCSR;
+        xstate_size = max(xstate_size,
+                          xstate_offsets[X86_XCR0_BNDCSR_POS] +
+                          xstate_sizes[X86_XCR0_BNDCSR_POS]);
+    }
+
+    if ( p->feat.avx512f )
+    {
+        xstates |= X86_XCR0_OPMASK | X86_XCR0_ZMM | X86_XCR0_HI_ZMM;
+        xstate_size = max(xstate_size,
+                          xstate_offsets[X86_XCR0_HI_ZMM_POS] +
+                          xstate_sizes[X86_XCR0_HI_ZMM_POS]);
+    }
+
+    if ( p->feat.pku )
+    {
+        xstates |= X86_XCR0_PKRU;
+        xstate_size = max(xstate_size,
+                          xstate_offsets[X86_XCR0_PKRU_POS] +
+                          xstate_sizes[X86_XCR0_PKRU_POS]);
+    }
+
+    p->xstate.max_size  =  xstate_size;
+    p->xstate.xcr0_low  =  xstates & ~XSTATE_XSAVES_ONLY;
+    p->xstate.xcr0_high = (xstates & ~XSTATE_XSAVES_ONLY) >> 32;
+
+    p->xstate.Da1 = Da1;
+    if ( p->xstate.xsaves )
+    {
+        p->xstate.xss_low   =  xstates & XSTATE_XSAVES_ONLY;
+        p->xstate.xss_high  = (xstates & XSTATE_XSAVES_ONLY) >> 32;
+    }
+    else
+        xstates &= ~XSTATE_XSAVES_ONLY;
+
+    for ( i = 2; i < min(63ul, ARRAY_SIZE(p->xstate.comp)); ++i )
+    {
+        uint64_t curr_xstate = 1ul << i;
+
+        if ( !(xstates & curr_xstate) )
+            continue;
+
+        p->xstate.comp[i].size   = xstate_sizes[i];
+        p->xstate.comp[i].offset = xstate_offsets[i];
+        p->xstate.comp[i].xss    = curr_xstate & XSTATE_XSAVES_ONLY;
+        p->xstate.comp[i].align  = curr_xstate & xstate_align;
+    }
+}
+
+/*
+ * Misc adjustments to the policy.  Mostly clobbering reserved fields and
+ * duplicating shared fields.  Intentionally hidden fields are annotated.
+ */
+static void recalculate_misc(struct cpu_policy *p)
+{
+    p->basic.raw_fms &= 0x0fff0fff; /* Clobber Processor Type on Intel. */
+    p->basic.apic_id = 0; /* Dynamic. */
+
+    p->basic.raw[0x5] = EMPTY_LEAF; /* MONITOR not exposed to guests. */
+    p->basic.raw[0x6] = EMPTY_LEAF; /* Therm/Power not exposed to guests. */
+
+    p->basic.raw[0x8] = EMPTY_LEAF;
+
+    /* TODO: Rework topology logic. */
+    memset(p->topo.raw, 0, sizeof(p->topo.raw));
+
+    p->basic.raw[0xc] = EMPTY_LEAF;
+
+    p->extd.e1d &= ~CPUID_COMMON_1D_FEATURES;
+
+    /* Most of Power/RAS hidden from guests. */
+    p->extd.raw[0x7].a = p->extd.raw[0x7].b = p->extd.raw[0x7].c = 0;
+
+    p->extd.raw[0x8].d = 0;
+
+    switch ( p->x86_vendor )
+    {
+    case X86_VENDOR_INTEL:
+        p->basic.l2_nr_queries = 1; /* Fixed to 1 query. */
+        p->basic.raw[0x3] = EMPTY_LEAF; /* PSN - always hidden. */
+        p->basic.raw[0x9] = EMPTY_LEAF; /* DCA - always hidden. */
+
+        p->extd.vendor_ebx = 0;
+        p->extd.vendor_ecx = 0;
+        p->extd.vendor_edx = 0;
+
+        p->extd.raw[0x1].a = p->extd.raw[0x1].b = 0;
+
+        p->extd.raw[0x5] = EMPTY_LEAF;
+        p->extd.raw[0x6].a = p->extd.raw[0x6].b = p->extd.raw[0x6].d = 0;
+
+        p->extd.raw[0x8].a &= 0x0000ffff;
+        p->extd.raw[0x8].c = 0;
+        break;
+
+    case X86_VENDOR_AMD:
+    case X86_VENDOR_HYGON:
+        zero_leaves(p->basic.raw, 0x2, 0x3);
+        memset(p->cache.raw, 0, sizeof(p->cache.raw));
+        zero_leaves(p->basic.raw, 0x9, 0xa);
+
+        p->extd.vendor_ebx = p->basic.vendor_ebx;
+        p->extd.vendor_ecx = p->basic.vendor_ecx;
+        p->extd.vendor_edx = p->basic.vendor_edx;
+
+        p->extd.raw_fms = p->basic.raw_fms;
+        p->extd.raw[0x1].b &= 0xff00ffff;
+        p->extd.e1d |= p->basic._1d & CPUID_COMMON_1D_FEATURES;
+
+        p->extd.raw[0x8].a &= 0x0000ffff; /* GuestMaxPhysAddr hidden. */
+        p->extd.raw[0x8].c &= 0x0003f0ff;
+
+        p->extd.raw[0x9] = EMPTY_LEAF;
+
+        zero_leaves(p->extd.raw, 0xb, 0x18);
+
+        /* 0x19 - TLB details.  Pass through. */
+        /* 0x1a - Perf hints.   Pass through. */
+
+        p->extd.raw[0x1b] = EMPTY_LEAF; /* IBS - not supported. */
+        p->extd.raw[0x1c] = EMPTY_LEAF; /* LWP - not supported. */
+        p->extd.raw[0x1d] = EMPTY_LEAF; /* TopoExt Cache */
+        p->extd.raw[0x1e] = EMPTY_LEAF; /* TopoExt APIC ID/Core/Node */
+        p->extd.raw[0x1f] = EMPTY_LEAF; /* SEV */
+        p->extd.raw[0x20] = EMPTY_LEAF; /* Platform QoS */
+        break;
+    }
+}
+
 static void __init calculate_raw_policy(void)
 {
     struct cpu_policy *p = &raw_cpu_policy;
 
+    x86_cpuid_policy_fill_native(p);
+
+    /* Nothing good will come from Xen and libx86 disagreeing on vendor. */
+    ASSERT(p->x86_vendor == boot_cpu_data.x86_vendor);
+
     /* 0x000000ce  MSR_INTEL_PLATFORM_INFO */
     /* Was already added by probe_cpuid_faulting() */
 
@@ -34,9 +362,50 @@ static void __init calculate_raw_policy(void)
 static void __init calculate_host_policy(void)
 {
     struct cpu_policy *p = &host_cpu_policy;
+    unsigned int max_extd_leaf;
 
     *p = raw_cpu_policy;
 
+    p->basic.max_leaf =
+        min_t(uint32_t, p->basic.max_leaf,   ARRAY_SIZE(p->basic.raw) - 1);
+    p->feat.max_subleaf =
+        min_t(uint32_t, p->feat.max_subleaf, ARRAY_SIZE(p->feat.raw) - 1);
+
+    max_extd_leaf = p->extd.max_leaf;
+
+    /*
+     * For AMD/Hygon hardware before Zen3, we unilaterally modify LFENCE to be
+     * dispatch serialising for Spectre mitigations.  Extend max_extd_leaf
+     * beyond what hardware supports, to include the feature leaf containing
+     * this information.
+     */
+    if ( cpu_has_lfence_dispatch )
+        max_extd_leaf = max(max_extd_leaf, 0x80000021);
+
+    p->extd.max_leaf = 0x80000000 | min_t(uint32_t, max_extd_leaf & 0xffff,
+                                          ARRAY_SIZE(p->extd.raw) - 1);
+
+    x86_cpu_featureset_to_policy(boot_cpu_data.x86_capability, p);
+    recalculate_xstate(p);
+    recalculate_misc(p);
+
+    /* When vPMU is disabled, drop it from the host policy. */
+    if ( vpmu_mode == XENPMU_MODE_OFF )
+        p->basic.raw[0xa] = EMPTY_LEAF;
+
+    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) |
+                               (1u << SVM_FEATURE_TSCRATEMSR));
+    }
+
     /* 0x000000ce  MSR_INTEL_PLATFORM_INFO */
     /* probe_cpuid_faulting() sanity checks presence of MISC_FEATURES_ENABLES */
     p->platform_info.cpuid_faulting = cpu_has_cpuid_faulting;
@@ -51,11 +420,88 @@ static void __init calculate_host_policy(void)
          ARCH_CAPS_PBRSB_NO);
 }
 
+static void __init guest_common_default_feature_adjustments(uint32_t *fs)
+{
+    /*
+     * IvyBridge client parts suffer from leakage of RDRAND data due to SRBDS
+     * (XSA-320 / CVE-2020-0543), and won't be receiving microcode to
+     * compensate.
+     *
+     * Mitigate by hiding RDRAND from guests by default, unless explicitly
+     * overridden on the Xen command line (cpuid=rdrand).  Irrespective of the
+     * default setting, guests can use RDRAND if explicitly enabled
+     * (cpuid="host,rdrand=1") in the VM's config file, and VMs which were
+     * previously using RDRAND can migrate in.
+     */
+    if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
+         boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model == 0x3a &&
+         cpu_has_rdrand && !is_forced_cpu_cap(X86_FEATURE_RDRAND) )
+        __clear_bit(X86_FEATURE_RDRAND, fs);
+
+    /*
+     * On certain hardware, speculative or errata workarounds can result in
+     * TSX being placed in "force-abort" mode, where it doesn't actually
+     * function as expected, but is technically compatible with the ISA.
+     *
+     * Do not advertise RTM to guests by default if it won't actually work.
+     */
+    if ( rtm_disabled )
+        __clear_bit(X86_FEATURE_RTM, fs);
+}
+
+static void __init guest_common_feature_adjustments(uint32_t *fs)
+{
+    /* Unconditionally claim to be able to set the hypervisor bit. */
+    __set_bit(X86_FEATURE_HYPERVISOR, fs);
+
+    /*
+     * If IBRS is offered to the guest, unconditionally offer STIBP.  It is a
+     * nop on non-HT hardware, and has this behaviour to make heterogeneous
+     * setups easier to manage.
+     */
+    if ( test_bit(X86_FEATURE_IBRSB, fs) )
+        __set_bit(X86_FEATURE_STIBP, fs);
+    if ( test_bit(X86_FEATURE_IBRS, fs) )
+        __set_bit(X86_FEATURE_AMD_STIBP, fs);
+
+    /*
+     * On hardware which supports IBRS/IBPB, we can offer IBPB independently
+     * of IBRS by using the AMD feature bit.  An administrator may wish for
+     * performance reasons to offer IBPB without IBRS.
+     */
+    if ( host_cpu_policy.feat.ibrsb )
+        __set_bit(X86_FEATURE_IBPB, fs);
+}
+
 static void __init calculate_pv_max_policy(void)
 {
     struct cpu_policy *p = &pv_max_cpu_policy;
+    uint32_t fs[FSCAPINTS];
+    unsigned int i;
 
     *p = host_cpu_policy;
+    x86_cpu_policy_to_featureset(p, fs);
+
+    for ( i = 0; i < ARRAY_SIZE(fs); ++i )
+        fs[i] &= pv_max_featuremask[i];
+
+    /*
+     * If Xen isn't virtualising MSR_SPEC_CTRL for PV guests (functional
+     * availability, or admin choice), hide the feature.
+     */
+    if ( !boot_cpu_has(X86_FEATURE_SC_MSR_PV) )
+    {
+        __clear_bit(X86_FEATURE_IBRSB, fs);
+        __clear_bit(X86_FEATURE_IBRS, fs);
+    }
+
+    guest_common_feature_adjustments(fs);
+
+    sanitise_featureset(fs);
+    x86_cpu_featureset_to_policy(fs, p);
+    recalculate_xstate(p);
+
+    p->extd.raw[0xa] = EMPTY_LEAF; /* No SVM for PV guests. */
 
     p->arch_caps.raw = 0; /* Not supported yet. */
 }
@@ -63,15 +509,83 @@ static void __init calculate_pv_max_policy(void)
 static void __init calculate_pv_def_policy(void)
 {
     struct cpu_policy *p = &pv_def_cpu_policy;
+    uint32_t fs[FSCAPINTS];
+    unsigned int i;
 
     *p = pv_max_cpu_policy;
+    x86_cpu_policy_to_featureset(p, fs);
+
+    for ( i = 0; i < ARRAY_SIZE(fs); ++i )
+        fs[i] &= pv_def_featuremask[i];
+
+    guest_common_feature_adjustments(fs);
+    guest_common_default_feature_adjustments(fs);
+
+    sanitise_featureset(fs);
+    x86_cpu_featureset_to_policy(fs, p);
+    recalculate_xstate(p);
 }
 
 static void __init calculate_hvm_max_policy(void)
 {
     struct cpu_policy *p = &hvm_max_cpu_policy;
+    uint32_t fs[FSCAPINTS];
+    unsigned int i;
+    const uint32_t *mask;
 
     *p = host_cpu_policy;
+    x86_cpu_policy_to_featureset(p, fs);
+
+    mask = hvm_hap_supported() ?
+        hvm_hap_max_featuremask : hvm_shadow_max_featuremask;
+
+    for ( i = 0; i < ARRAY_SIZE(fs); ++i )
+        fs[i] &= mask[i];
+
+    /*
+     * Xen can provide an (x2)APIC emulation to HVM guests even if the host's
+     * (x2)APIC isn't enabled.
+     */
+    __set_bit(X86_FEATURE_APIC, fs);
+    __set_bit(X86_FEATURE_X2APIC, fs);
+
+    /*
+     * On AMD, PV guests are entirely unable to use SYSENTER as Xen runs in
+     * long mode (and init_amd() has cleared it out of host capabilities), but
+     * HVM guests are able if running in protected mode.
+     */
+    if ( (boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) &&
+         raw_cpu_policy.basic.sep )
+        __set_bit(X86_FEATURE_SEP, fs);
+
+    /*
+     * If Xen isn't virtualising MSR_SPEC_CTRL for HVM guests (functional
+     * availability, or admin choice), hide the feature.
+     */
+    if ( !boot_cpu_has(X86_FEATURE_SC_MSR_HVM) )
+    {
+        __clear_bit(X86_FEATURE_IBRSB, fs);
+        __clear_bit(X86_FEATURE_IBRS, fs);
+    }
+
+    /*
+     * With VT-x, some features are only supported by Xen if dedicated
+     * hardware support is also available.
+     */
+    if ( cpu_has_vmx )
+    {
+        if ( !cpu_has_vmx_mpx )
+            __clear_bit(X86_FEATURE_MPX, fs);
+
+        if ( !cpu_has_vmx_xsaves )
+            __clear_bit(X86_FEATURE_XSAVES, fs);
+    }
+
+    guest_common_feature_adjustments(fs);
+
+    sanitise_featureset(fs);
+    x86_cpu_featureset_to_policy(fs, p);
+    recalculate_xstate(p);
 
     /* It's always possible to emulate CPUID faulting for HVM guests */
     p->platform_info.cpuid_faulting = true;
@@ -82,8 +596,25 @@ static void __init calculate_hvm_max_policy(void)
 static void __init calculate_hvm_def_policy(void)
 {
     struct cpu_policy *p = &hvm_def_cpu_policy;
+    uint32_t fs[FSCAPINTS];
+    unsigned int i;
+    const uint32_t *mask;
 
     *p = hvm_max_cpu_policy;
+    x86_cpu_policy_to_featureset(p, fs);
+
+    mask = hvm_hap_supported() ?
+        hvm_hap_def_featuremask : hvm_shadow_def_featuremask;
+
+    for ( i = 0; i < ARRAY_SIZE(fs); ++i )
+        fs[i] &= mask[i];
+
+    guest_common_feature_adjustments(fs);
+    guest_common_default_feature_adjustments(fs);
+
+    sanitise_featureset(fs);
+    x86_cpu_featureset_to_policy(fs, p);
+    recalculate_xstate(p);
 }
 
 void __init init_guest_cpu_policies(void)
@@ -149,3 +680,196 @@ int init_domain_cpu_policy(struct domain *d)
 
     return 0;
 }
+
+void recalculate_cpuid_policy(struct domain *d)
+{
+    struct cpu_policy *p = d->arch.cpuid;
+    const struct cpu_policy *max = is_pv_domain(d)
+        ? (IS_ENABLED(CONFIG_PV)  ?  &pv_max_cpu_policy : NULL)
+        : (IS_ENABLED(CONFIG_HVM) ? &hvm_max_cpu_policy : NULL);
+    uint32_t fs[FSCAPINTS], max_fs[FSCAPINTS];
+    unsigned int i;
+
+    if ( !max )
+    {
+        ASSERT_UNREACHABLE();
+        return;
+    }
+
+    p->x86_vendor = x86_cpuid_lookup_vendor(
+        p->basic.vendor_ebx, p->basic.vendor_ecx, p->basic.vendor_edx);
+
+    p->basic.max_leaf   = min(p->basic.max_leaf,   max->basic.max_leaf);
+    p->feat.max_subleaf = min(p->feat.max_subleaf, max->feat.max_subleaf);
+    p->extd.max_leaf    = 0x80000000 | min(p->extd.max_leaf & 0xffff,
+                                           ((p->x86_vendor & (X86_VENDOR_AMD |
+                                                              X86_VENDOR_HYGON))
+                                            ? CPUID_GUEST_NR_EXTD_AMD
+                                            : CPUID_GUEST_NR_EXTD_INTEL) - 1);
+
+    x86_cpu_policy_to_featureset(p, fs);
+    x86_cpu_policy_to_featureset(max, max_fs);
+
+    if ( is_hvm_domain(d) )
+    {
+        /*
+         * HVM domains using Shadow paging have further restrictions on their
+         * available paging features.
+         */
+        if ( !hap_enabled(d) )
+        {
+            for ( i = 0; i < ARRAY_SIZE(max_fs); i++ )
+                max_fs[i] &= hvm_shadow_max_featuremask[i];
+        }
+
+        /* Hide nested-virt if it hasn't been explicitly configured. */
+        if ( !nestedhvm_enabled(d) )
+        {
+            __clear_bit(X86_FEATURE_VMX, max_fs);
+            __clear_bit(X86_FEATURE_SVM, max_fs);
+        }
+    }
+
+    /*
+     * Allow the toolstack to set HTT, X2APIC and CMP_LEGACY.  These bits
+     * affect how to interpret topology information in other cpuid leaves.
+     */
+    __set_bit(X86_FEATURE_HTT, max_fs);
+    __set_bit(X86_FEATURE_X2APIC, max_fs);
+    __set_bit(X86_FEATURE_CMP_LEGACY, max_fs);
+
+    /*
+     * 32bit PV domains can't use any Long Mode features, and cannot use
+     * SYSCALL on non-AMD hardware.
+     */
+    if ( is_pv_32bit_domain(d) )
+    {
+        __clear_bit(X86_FEATURE_LM, max_fs);
+        if ( !(boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) )
+            __clear_bit(X86_FEATURE_SYSCALL, max_fs);
+    }
+
+    /*
+     * ITSC is masked by default (so domains are safe to migrate), but a
+     * toolstack which has configured disable_migrate or vTSC for a domain may
+     * safely select it, and needs a way of doing so.
+     */
+    if ( cpu_has_itsc && (d->disable_migrate || d->arch.vtsc) )
+        __set_bit(X86_FEATURE_ITSC, max_fs);
+
+    /* Clamp the toolstacks choices to reality. */
+    for ( i = 0; i < ARRAY_SIZE(fs); i++ )
+        fs[i] &= max_fs[i];
+
+    if ( p->basic.max_leaf < XSTATE_CPUID )
+        __clear_bit(X86_FEATURE_XSAVE, fs);
+
+    sanitise_featureset(fs);
+
+    /* Fold host's FDP_EXCP_ONLY and NO_FPU_SEL into guest's view. */
+    fs[FEATURESET_7b0] &= ~(cpufeat_mask(X86_FEATURE_FDP_EXCP_ONLY) |
+                            cpufeat_mask(X86_FEATURE_NO_FPU_SEL));
+    fs[FEATURESET_7b0] |= (host_cpu_policy.feat._7b0 &
+                           (cpufeat_mask(X86_FEATURE_FDP_EXCP_ONLY) |
+                            cpufeat_mask(X86_FEATURE_NO_FPU_SEL)));
+
+    x86_cpu_featureset_to_policy(fs, p);
+
+    /* Pass host cacheline size through to guests. */
+    p->basic.clflush_size = max->basic.clflush_size;
+
+    p->extd.maxphysaddr = min(p->extd.maxphysaddr, max->extd.maxphysaddr);
+    p->extd.maxphysaddr = min_t(uint8_t, p->extd.maxphysaddr,
+                                paging_max_paddr_bits(d));
+    p->extd.maxphysaddr = max_t(uint8_t, p->extd.maxphysaddr,
+                                (p->basic.pae || p->basic.pse36) ? 36 : 32);
+
+    p->extd.maxlinaddr = p->extd.lm ? 48 : 32;
+
+    recalculate_xstate(p);
+    recalculate_misc(p);
+
+    for ( i = 0; i < ARRAY_SIZE(p->cache.raw); ++i )
+    {
+        if ( p->cache.subleaf[i].type >= 1 &&
+             p->cache.subleaf[i].type <= 3 )
+        {
+            /* Subleaf has a valid cache type. Zero reserved fields. */
+            p->cache.raw[i].a &= 0xffffc3ffu;
+            p->cache.raw[i].d &= 0x00000007u;
+        }
+        else
+        {
+            /* Subleaf is not valid.  Zero the rest of the union. */
+            zero_leaves(p->cache.raw, i, ARRAY_SIZE(p->cache.raw) - 1);
+            break;
+        }
+    }
+
+    if ( vpmu_mode == XENPMU_MODE_OFF ||
+         ((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;
+}
+
+void __init init_dom0_cpuid_policy(struct domain *d)
+{
+    struct cpu_policy *p = d->arch.cpuid;
+
+    /* dom0 can't migrate.  Give it ITSC if available. */
+    if ( cpu_has_itsc )
+        p->extd.itsc = true;
+
+    /*
+     * Expose the "hardware speculation behaviour" bits of ARCH_CAPS to dom0,
+     * so dom0 can turn off workarounds as appropriate.  Temporary, until the
+     * domain policy logic gains a better understanding of MSRs.
+     */
+    if ( cpu_has_arch_caps )
+        p->feat.arch_caps = true;
+
+    /* Apply dom0-cpuid= command line settings, if provided. */
+    if ( dom0_cpuid_cmdline )
+    {
+        uint32_t fs[FSCAPINTS];
+        unsigned int i;
+
+        x86_cpu_policy_to_featureset(p, fs);
+
+        for ( i = 0; i < ARRAY_SIZE(fs); ++i )
+        {
+            fs[i] |=  dom0_enable_feat [i];
+            fs[i] &= ~dom0_disable_feat[i];
+        }
+
+        x86_cpu_featureset_to_policy(fs, p);
+
+        recalculate_cpuid_policy(d);
+    }
+}
+
+static void __init __maybe_unused build_assertions(void)
+{
+    BUILD_BUG_ON(ARRAY_SIZE(known_features) != FSCAPINTS);
+    BUILD_BUG_ON(ARRAY_SIZE(pv_max_featuremask) != FSCAPINTS);
+    BUILD_BUG_ON(ARRAY_SIZE(hvm_shadow_max_featuremask) != FSCAPINTS);
+    BUILD_BUG_ON(ARRAY_SIZE(hvm_hap_max_featuremask) != FSCAPINTS);
+    BUILD_BUG_ON(ARRAY_SIZE(deep_features) != FSCAPINTS);
+
+    /* Find some more clever allocation scheme if this trips. */
+    BUILD_BUG_ON(sizeof(struct cpu_policy) > PAGE_SIZE);
+
+    BUILD_BUG_ON(sizeof(raw_cpu_policy.basic) !=
+                 sizeof(raw_cpu_policy.basic.raw));
+    BUILD_BUG_ON(sizeof(raw_cpu_policy.feat) !=
+                 sizeof(raw_cpu_policy.feat.raw));
+    BUILD_BUG_ON(sizeof(raw_cpu_policy.xstate) !=
+                 sizeof(raw_cpu_policy.xstate.raw));
+    BUILD_BUG_ON(sizeof(raw_cpu_policy.extd) !=
+                 sizeof(raw_cpu_policy.extd.raw));
+}
diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index f096713044..f33dd29d4d 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -1,601 +1,15 @@
-#include <xen/init.h>
-#include <xen/lib.h>
-#include <xen/param.h>
 #include <xen/sched.h>
 #include <xen/nospec.h>
+#include <xen/types.h>
+
+#include <public/hvm/params.h>
+
 #include <asm/cpu-policy.h>
 #include <asm/cpuid.h>
-#include <asm/hvm/hvm.h>
-#include <asm/hvm/nestedhvm.h>
-#include <asm/hvm/svm/svm.h>
 #include <asm/hvm/viridian.h>
-#include <asm/hvm/vmx/vmcs.h>
-#include <asm/paging.h>
-#include <asm/processor.h>
 #include <asm/xstate.h>
 
-const uint32_t known_features[] = INIT_KNOWN_FEATURES;
-
-static const uint32_t __initconst pv_max_featuremask[] = INIT_PV_MAX_FEATURES;
-static const uint32_t hvm_shadow_max_featuremask[] = INIT_HVM_SHADOW_MAX_FEATURES;
-static const uint32_t __initconst hvm_hap_max_featuremask[] =
-    INIT_HVM_HAP_MAX_FEATURES;
-static const uint32_t __initconst pv_def_featuremask[] = INIT_PV_DEF_FEATURES;
-static const uint32_t __initconst hvm_shadow_def_featuremask[] =
-    INIT_HVM_SHADOW_DEF_FEATURES;
-static const uint32_t __initconst hvm_hap_def_featuremask[] =
-    INIT_HVM_HAP_DEF_FEATURES;
-static const uint32_t deep_features[] = INIT_DEEP_FEATURES;
-
-static const struct feature_name {
-    const char *name;
-    unsigned int bit;
-} feature_names[] __initconstrel = INIT_FEATURE_NAMES;
-
-/*
- * Parse a list of cpuid feature names -> bool, calling the callback for any
- * matches found.
- *
- * always_inline, because this is init code only and we really don't want a
- * function pointer call in the middle of the loop.
- */
-static int __init always_inline parse_cpuid(
-    const char *s, void (*callback)(unsigned int feat, bool val))
-{
-    const char *ss;
-    int val, rc = 0;
-
-    do {
-        const struct feature_name *lhs, *rhs, *mid = NULL /* GCC... */;
-        const char *feat;
-
-        ss = strchr(s, ',');
-        if ( !ss )
-            ss = strchr(s, '\0');
-
-        /* Skip the 'no-' prefix for name comparisons. */
-        feat = s;
-        if ( strncmp(s, "no-", 3) == 0 )
-            feat += 3;
-
-        /* (Re)initalise lhs and rhs for binary search. */
-        lhs = feature_names;
-        rhs = feature_names + ARRAY_SIZE(feature_names);
-
-        while ( lhs < rhs )
-        {
-            int res;
-
-            mid = lhs + (rhs - lhs) / 2;
-            res = cmdline_strcmp(feat, mid->name);
-
-            if ( res < 0 )
-            {
-                rhs = mid;
-                continue;
-            }
-            if ( res > 0 )
-            {
-                lhs = mid + 1;
-                continue;
-            }
-
-            if ( (val = parse_boolean(mid->name, s, ss)) >= 0 )
-            {
-                callback(mid->bit, val);
-                mid = NULL;
-            }
-
-            break;
-        }
-
-        /*
-         * Mid being NULL means that the name and boolean were successfully
-         * identified.  Everything else is an error.
-         */
-        if ( mid )
-            rc = -EINVAL;
-
-        s = ss + 1;
-    } while ( *ss );
-
-    return rc;
-}
-
-static void __init _parse_xen_cpuid(unsigned int feat, bool val)
-{
-    if ( !val )
-        setup_clear_cpu_cap(feat);
-    else if ( feat == X86_FEATURE_RDRAND &&
-              (cpuid_ecx(1) & cpufeat_mask(X86_FEATURE_RDRAND)) )
-        setup_force_cpu_cap(X86_FEATURE_RDRAND);
-}
-
-static int __init parse_xen_cpuid(const char *s)
-{
-    return parse_cpuid(s, _parse_xen_cpuid);
-}
-custom_param("cpuid", parse_xen_cpuid);
-
-static bool __initdata dom0_cpuid_cmdline;
-static uint32_t __initdata dom0_enable_feat[FSCAPINTS];
-static uint32_t __initdata dom0_disable_feat[FSCAPINTS];
-
-static void __init _parse_dom0_cpuid(unsigned int feat, bool val)
-{
-    __set_bit  (feat, val ? dom0_enable_feat  : dom0_disable_feat);
-    __clear_bit(feat, val ? dom0_disable_feat : dom0_enable_feat );
-}
-
-static int __init parse_dom0_cpuid(const char *s)
-{
-    dom0_cpuid_cmdline = true;
-
-    return parse_cpuid(s, _parse_dom0_cpuid);
-}
-custom_param("dom0-cpuid", parse_dom0_cpuid);
-
 #define EMPTY_LEAF ((struct cpuid_leaf){})
-static void zero_leaves(struct cpuid_leaf *l,
-                        unsigned int first, unsigned int last)
-{
-    memset(&l[first], 0, sizeof(*l) * (last - first + 1));
-}
-
-static void sanitise_featureset(uint32_t *fs)
-{
-    /* for_each_set_bit() uses unsigned longs.  Extend with zeroes. */
-    uint32_t disabled_features[
-        ROUNDUP(FSCAPINTS, sizeof(unsigned long)/sizeof(uint32_t))] = {};
-    unsigned int i;
-
-    for ( i = 0; i < FSCAPINTS; ++i )
-    {
-        /* Clamp to known mask. */
-        fs[i] &= known_features[i];
-
-        /*
-         * Identify which features with deep dependencies have been
-         * disabled.
-         */
-        disabled_features[i] = ~fs[i] & deep_features[i];
-    }
-
-    for_each_set_bit(i, (void *)disabled_features,
-                     sizeof(disabled_features) * 8)
-    {
-        const uint32_t *dfs = x86_cpuid_lookup_deep_deps(i);
-        unsigned int j;
-
-        ASSERT(dfs); /* deep_features[] should guarentee this. */
-
-        for ( j = 0; j < FSCAPINTS; ++j )
-        {
-            fs[j] &= ~dfs[j];
-            disabled_features[j] &= ~dfs[j];
-        }
-    }
-}
-
-static void recalculate_xstate(struct cpuid_policy *p)
-{
-    uint64_t xstates = XSTATE_FP_SSE;
-    uint32_t xstate_size = XSTATE_AREA_MIN_SIZE;
-    unsigned int i, Da1 = p->xstate.Da1;
-
-    /*
-     * The Da1 leaf is the only piece of information preserved in the common
-     * case.  Everything else is derived from other feature state.
-     */
-    memset(&p->xstate, 0, sizeof(p->xstate));
-
-    if ( !p->basic.xsave )
-        return;
-
-    if ( p->basic.avx )
-    {
-        xstates |= X86_XCR0_YMM;
-        xstate_size = max(xstate_size,
-                          xstate_offsets[X86_XCR0_YMM_POS] +
-                          xstate_sizes[X86_XCR0_YMM_POS]);
-    }
-
-    if ( p->feat.mpx )
-    {
-        xstates |= X86_XCR0_BNDREGS | X86_XCR0_BNDCSR;
-        xstate_size = max(xstate_size,
-                          xstate_offsets[X86_XCR0_BNDCSR_POS] +
-                          xstate_sizes[X86_XCR0_BNDCSR_POS]);
-    }
-
-    if ( p->feat.avx512f )
-    {
-        xstates |= X86_XCR0_OPMASK | X86_XCR0_ZMM | X86_XCR0_HI_ZMM;
-        xstate_size = max(xstate_size,
-                          xstate_offsets[X86_XCR0_HI_ZMM_POS] +
-                          xstate_sizes[X86_XCR0_HI_ZMM_POS]);
-    }
-
-    if ( p->feat.pku )
-    {
-        xstates |= X86_XCR0_PKRU;
-        xstate_size = max(xstate_size,
-                          xstate_offsets[X86_XCR0_PKRU_POS] +
-                          xstate_sizes[X86_XCR0_PKRU_POS]);
-    }
-
-    p->xstate.max_size  =  xstate_size;
-    p->xstate.xcr0_low  =  xstates & ~XSTATE_XSAVES_ONLY;
-    p->xstate.xcr0_high = (xstates & ~XSTATE_XSAVES_ONLY) >> 32;
-
-    p->xstate.Da1 = Da1;
-    if ( p->xstate.xsaves )
-    {
-        p->xstate.xss_low   =  xstates & XSTATE_XSAVES_ONLY;
-        p->xstate.xss_high  = (xstates & XSTATE_XSAVES_ONLY) >> 32;
-    }
-    else
-        xstates &= ~XSTATE_XSAVES_ONLY;
-
-    for ( i = 2; i < min(63ul, ARRAY_SIZE(p->xstate.comp)); ++i )
-    {
-        uint64_t curr_xstate = 1ul << i;
-
-        if ( !(xstates & curr_xstate) )
-            continue;
-
-        p->xstate.comp[i].size   = xstate_sizes[i];
-        p->xstate.comp[i].offset = xstate_offsets[i];
-        p->xstate.comp[i].xss    = curr_xstate & XSTATE_XSAVES_ONLY;
-        p->xstate.comp[i].align  = curr_xstate & xstate_align;
-    }
-}
-
-/*
- * Misc adjustments to the policy.  Mostly clobbering reserved fields and
- * duplicating shared fields.  Intentionally hidden fields are annotated.
- */
-static void recalculate_misc(struct cpuid_policy *p)
-{
-    p->basic.raw_fms &= 0x0fff0fff; /* Clobber Processor Type on Intel. */
-    p->basic.apic_id = 0; /* Dynamic. */
-
-    p->basic.raw[0x5] = EMPTY_LEAF; /* MONITOR not exposed to guests. */
-    p->basic.raw[0x6] = EMPTY_LEAF; /* Therm/Power not exposed to guests. */
-
-    p->basic.raw[0x8] = EMPTY_LEAF;
-
-    /* TODO: Rework topology logic. */
-    memset(p->topo.raw, 0, sizeof(p->topo.raw));
-
-    p->basic.raw[0xc] = EMPTY_LEAF;
-
-    p->extd.e1d &= ~CPUID_COMMON_1D_FEATURES;
-
-    /* Most of Power/RAS hidden from guests. */
-    p->extd.raw[0x7].a = p->extd.raw[0x7].b = p->extd.raw[0x7].c = 0;
-
-    p->extd.raw[0x8].d = 0;
-
-    switch ( p->x86_vendor )
-    {
-    case X86_VENDOR_INTEL:
-        p->basic.l2_nr_queries = 1; /* Fixed to 1 query. */
-        p->basic.raw[0x3] = EMPTY_LEAF; /* PSN - always hidden. */
-        p->basic.raw[0x9] = EMPTY_LEAF; /* DCA - always hidden. */
-
-        p->extd.vendor_ebx = 0;
-        p->extd.vendor_ecx = 0;
-        p->extd.vendor_edx = 0;
-
-        p->extd.raw[0x1].a = p->extd.raw[0x1].b = 0;
-
-        p->extd.raw[0x5] = EMPTY_LEAF;
-        p->extd.raw[0x6].a = p->extd.raw[0x6].b = p->extd.raw[0x6].d = 0;
-
-        p->extd.raw[0x8].a &= 0x0000ffff;
-        p->extd.raw[0x8].c = 0;
-        break;
-
-    case X86_VENDOR_AMD:
-    case X86_VENDOR_HYGON:
-        zero_leaves(p->basic.raw, 0x2, 0x3);
-        memset(p->cache.raw, 0, sizeof(p->cache.raw));
-        zero_leaves(p->basic.raw, 0x9, 0xa);
-
-        p->extd.vendor_ebx = p->basic.vendor_ebx;
-        p->extd.vendor_ecx = p->basic.vendor_ecx;
-        p->extd.vendor_edx = p->basic.vendor_edx;
-
-        p->extd.raw_fms = p->basic.raw_fms;
-        p->extd.raw[0x1].b &= 0xff00ffff;
-        p->extd.e1d |= p->basic._1d & CPUID_COMMON_1D_FEATURES;
-
-        p->extd.raw[0x8].a &= 0x0000ffff; /* GuestMaxPhysAddr hidden. */
-        p->extd.raw[0x8].c &= 0x0003f0ff;
-
-        p->extd.raw[0x9] = EMPTY_LEAF;
-
-        zero_leaves(p->extd.raw, 0xb, 0x18);
-
-        /* 0x19 - TLB details.  Pass through. */
-        /* 0x1a - Perf hints.   Pass through. */
-
-        p->extd.raw[0x1b] = EMPTY_LEAF; /* IBS - not supported. */
-        p->extd.raw[0x1c] = EMPTY_LEAF; /* LWP - not supported. */
-        p->extd.raw[0x1d] = EMPTY_LEAF; /* TopoExt Cache */
-        p->extd.raw[0x1e] = EMPTY_LEAF; /* TopoExt APIC ID/Core/Node */
-        p->extd.raw[0x1f] = EMPTY_LEAF; /* SEV */
-        p->extd.raw[0x20] = EMPTY_LEAF; /* Platform QoS */
-        break;
-    }
-}
-
-static void __init calculate_raw_policy(void)
-{
-    struct cpuid_policy *p = &raw_cpu_policy;
-
-    x86_cpuid_policy_fill_native(p);
-
-    /* Nothing good will come from Xen and libx86 disagreeing on vendor. */
-    ASSERT(p->x86_vendor == boot_cpu_data.x86_vendor);
-}
-
-static void __init calculate_host_policy(void)
-{
-    struct cpuid_policy *p = &host_cpu_policy;
-    unsigned int max_extd_leaf;
-
-    *p = raw_cpu_policy;
-
-    p->basic.max_leaf =
-        min_t(uint32_t, p->basic.max_leaf,   ARRAY_SIZE(p->basic.raw) - 1);
-    p->feat.max_subleaf =
-        min_t(uint32_t, p->feat.max_subleaf, ARRAY_SIZE(p->feat.raw) - 1);
-
-    max_extd_leaf = p->extd.max_leaf;
-
-    /*
-     * For AMD/Hygon hardware before Zen3, we unilaterally modify LFENCE to be
-     * dispatch serialising for Spectre mitigations.  Extend max_extd_leaf
-     * beyond what hardware supports, to include the feature leaf containing
-     * this information.
-     */
-    if ( cpu_has_lfence_dispatch )
-        max_extd_leaf = max(max_extd_leaf, 0x80000021);
-
-    p->extd.max_leaf = 0x80000000 | min_t(uint32_t, max_extd_leaf & 0xffff,
-                                          ARRAY_SIZE(p->extd.raw) - 1);
-
-    x86_cpu_featureset_to_policy(boot_cpu_data.x86_capability, p);
-    recalculate_xstate(p);
-    recalculate_misc(p);
-
-    /* When vPMU is disabled, drop it from the host policy. */
-    if ( vpmu_mode == XENPMU_MODE_OFF )
-        p->basic.raw[0xa] = EMPTY_LEAF;
-
-    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) |
-                               (1u << SVM_FEATURE_TSCRATEMSR));
-    }
-}
-
-static void __init guest_common_default_feature_adjustments(uint32_t *fs)
-{
-    /*
-     * IvyBridge client parts suffer from leakage of RDRAND data due to SRBDS
-     * (XSA-320 / CVE-2020-0543), and won't be receiving microcode to
-     * compensate.
-     *
-     * Mitigate by hiding RDRAND from guests by default, unless explicitly
-     * overridden on the Xen command line (cpuid=rdrand).  Irrespective of the
-     * default setting, guests can use RDRAND if explicitly enabled
-     * (cpuid="host,rdrand=1") in the VM's config file, and VMs which were
-     * previously using RDRAND can migrate in.
-     */
-    if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
-         boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model == 0x3a &&
-         cpu_has_rdrand && !is_forced_cpu_cap(X86_FEATURE_RDRAND) )
-        __clear_bit(X86_FEATURE_RDRAND, fs);
-
-    /*
-     * On certain hardware, speculative or errata workarounds can result in
-     * TSX being placed in "force-abort" mode, where it doesn't actually
-     * function as expected, but is technically compatible with the ISA.
-     *
-     * Do not advertise RTM to guests by default if it won't actually work.
-     */
-    if ( rtm_disabled )
-        __clear_bit(X86_FEATURE_RTM, fs);
-}
-
-static void __init guest_common_feature_adjustments(uint32_t *fs)
-{
-    /* Unconditionally claim to be able to set the hypervisor bit. */
-    __set_bit(X86_FEATURE_HYPERVISOR, fs);
-
-    /*
-     * If IBRS is offered to the guest, unconditionally offer STIBP.  It is a
-     * nop on non-HT hardware, and has this behaviour to make heterogeneous
-     * setups easier to manage.
-     */
-    if ( test_bit(X86_FEATURE_IBRSB, fs) )
-        __set_bit(X86_FEATURE_STIBP, fs);
-    if ( test_bit(X86_FEATURE_IBRS, fs) )
-        __set_bit(X86_FEATURE_AMD_STIBP, fs);
-
-    /*
-     * On hardware which supports IBRS/IBPB, we can offer IBPB independently
-     * of IBRS by using the AMD feature bit.  An administrator may wish for
-     * performance reasons to offer IBPB without IBRS.
-     */
-    if ( host_cpu_policy.feat.ibrsb )
-        __set_bit(X86_FEATURE_IBPB, fs);
-}
-
-static void __init calculate_pv_max_policy(void)
-{
-    struct cpuid_policy *p = &pv_max_cpu_policy;
-    uint32_t pv_featureset[FSCAPINTS];
-    unsigned int i;
-
-    *p = host_cpu_policy;
-    x86_cpu_policy_to_featureset(p, pv_featureset);
-
-    for ( i = 0; i < ARRAY_SIZE(pv_featureset); ++i )
-        pv_featureset[i] &= pv_max_featuremask[i];
-
-    /*
-     * If Xen isn't virtualising MSR_SPEC_CTRL for PV guests (functional
-     * availability, or admin choice), hide the feature.
-     */
-    if ( !boot_cpu_has(X86_FEATURE_SC_MSR_PV) )
-    {
-        __clear_bit(X86_FEATURE_IBRSB, pv_featureset);
-        __clear_bit(X86_FEATURE_IBRS, pv_featureset);
-    }
-
-    guest_common_feature_adjustments(pv_featureset);
-
-    sanitise_featureset(pv_featureset);
-    x86_cpu_featureset_to_policy(pv_featureset, p);
-    recalculate_xstate(p);
-
-    p->extd.raw[0xa] = EMPTY_LEAF; /* No SVM for PV guests. */
-}
-
-static void __init calculate_pv_def_policy(void)
-{
-    struct cpuid_policy *p = &pv_def_cpu_policy;
-    uint32_t pv_featureset[FSCAPINTS];
-    unsigned int i;
-
-    *p = pv_max_cpu_policy;
-    x86_cpu_policy_to_featureset(p, pv_featureset);
-
-    for ( i = 0; i < ARRAY_SIZE(pv_featureset); ++i )
-        pv_featureset[i] &= pv_def_featuremask[i];
-
-    guest_common_feature_adjustments(pv_featureset);
-    guest_common_default_feature_adjustments(pv_featureset);
-
-    sanitise_featureset(pv_featureset);
-    x86_cpu_featureset_to_policy(pv_featureset, p);
-    recalculate_xstate(p);
-}
-
-static void __init calculate_hvm_max_policy(void)
-{
-    struct cpuid_policy *p = &hvm_max_cpu_policy;
-    uint32_t hvm_featureset[FSCAPINTS];
-    unsigned int i;
-    const uint32_t *hvm_featuremask;
-
-    *p = host_cpu_policy;
-    x86_cpu_policy_to_featureset(p, hvm_featureset);
-
-    hvm_featuremask = hvm_hap_supported() ?
-        hvm_hap_max_featuremask : hvm_shadow_max_featuremask;
-
-    for ( i = 0; i < ARRAY_SIZE(hvm_featureset); ++i )
-        hvm_featureset[i] &= hvm_featuremask[i];
-
-    /*
-     * Xen can provide an (x2)APIC emulation to HVM guests even if the host's
-     * (x2)APIC isn't enabled.
-     */
-    __set_bit(X86_FEATURE_APIC, hvm_featureset);
-    __set_bit(X86_FEATURE_X2APIC, hvm_featureset);
-
-    /*
-     * On AMD, PV guests are entirely unable to use SYSENTER as Xen runs in
-     * long mode (and init_amd() has cleared it out of host capabilities), but
-     * HVM guests are able if running in protected mode.
-     */
-    if ( (boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) &&
-         raw_cpu_policy.basic.sep )
-        __set_bit(X86_FEATURE_SEP, hvm_featureset);
-
-    /*
-     * If Xen isn't virtualising MSR_SPEC_CTRL for HVM guests (functional
-     * availability, or admin choice), hide the feature.
-     */
-    if ( !boot_cpu_has(X86_FEATURE_SC_MSR_HVM) )
-    {
-        __clear_bit(X86_FEATURE_IBRSB, hvm_featureset);
-        __clear_bit(X86_FEATURE_IBRS, hvm_featureset);
-    }
-
-    /*
-     * With VT-x, some features are only supported by Xen if dedicated
-     * hardware support is also available.
-     */
-    if ( cpu_has_vmx )
-    {
-        if ( !cpu_has_vmx_mpx )
-            __clear_bit(X86_FEATURE_MPX, hvm_featureset);
-
-        if ( !cpu_has_vmx_xsaves )
-            __clear_bit(X86_FEATURE_XSAVES, hvm_featureset);
-    }
-
-    guest_common_feature_adjustments(hvm_featureset);
-
-    sanitise_featureset(hvm_featureset);
-    x86_cpu_featureset_to_policy(hvm_featureset, p);
-    recalculate_xstate(p);
-}
-
-static void __init calculate_hvm_def_policy(void)
-{
-    struct cpuid_policy *p = &hvm_def_cpu_policy;
-    uint32_t hvm_featureset[FSCAPINTS];
-    unsigned int i;
-    const uint32_t *hvm_featuremask;
-
-    *p = hvm_max_cpu_policy;
-    x86_cpu_policy_to_featureset(p, hvm_featureset);
-
-    hvm_featuremask = hvm_hap_supported() ?
-        hvm_hap_def_featuremask : hvm_shadow_def_featuremask;
-
-    for ( i = 0; i < ARRAY_SIZE(hvm_featureset); ++i )
-        hvm_featureset[i] &= hvm_featuremask[i];
-
-    guest_common_feature_adjustments(hvm_featureset);
-    guest_common_default_feature_adjustments(hvm_featureset);
-
-    sanitise_featureset(hvm_featureset);
-    x86_cpu_featureset_to_policy(hvm_featureset, p);
-    recalculate_xstate(p);
-}
-
-void __init init_guest_cpuid(void)
-{
-    calculate_raw_policy();
-    calculate_host_policy();
-
-    if ( IS_ENABLED(CONFIG_PV) )
-    {
-        calculate_pv_max_policy();
-        calculate_pv_def_policy();
-    }
-
-    if ( hvm_enabled )
-    {
-        calculate_hvm_max_policy();
-        calculate_hvm_def_policy();
-    }
-}
 
 bool recheck_cpu_features(unsigned int cpu)
 {
@@ -619,178 +33,6 @@ bool recheck_cpu_features(unsigned int cpu)
     return okay;
 }
 
-void recalculate_cpuid_policy(struct domain *d)
-{
-    struct cpuid_policy *p = d->arch.cpuid;
-    const struct cpuid_policy *max = is_pv_domain(d)
-        ? (IS_ENABLED(CONFIG_PV)  ?  &pv_max_cpu_policy : NULL)
-        : (IS_ENABLED(CONFIG_HVM) ? &hvm_max_cpu_policy : NULL);
-    uint32_t fs[FSCAPINTS], max_fs[FSCAPINTS];
-    unsigned int i;
-
-    if ( !max )
-    {
-        ASSERT_UNREACHABLE();
-        return;
-    }
-
-    p->x86_vendor = x86_cpuid_lookup_vendor(
-        p->basic.vendor_ebx, p->basic.vendor_ecx, p->basic.vendor_edx);
-
-    p->basic.max_leaf   = min(p->basic.max_leaf,   max->basic.max_leaf);
-    p->feat.max_subleaf = min(p->feat.max_subleaf, max->feat.max_subleaf);
-    p->extd.max_leaf    = 0x80000000 | min(p->extd.max_leaf & 0xffff,
-                                           ((p->x86_vendor & (X86_VENDOR_AMD |
-                                                              X86_VENDOR_HYGON))
-                                            ? CPUID_GUEST_NR_EXTD_AMD
-                                            : CPUID_GUEST_NR_EXTD_INTEL) - 1);
-
-    x86_cpu_policy_to_featureset(p, fs);
-    x86_cpu_policy_to_featureset(max, max_fs);
-
-    if ( is_hvm_domain(d) )
-    {
-        /*
-         * HVM domains using Shadow paging have further restrictions on their
-         * available paging features.
-         */
-        if ( !hap_enabled(d) )
-        {
-            for ( i = 0; i < ARRAY_SIZE(max_fs); i++ )
-                max_fs[i] &= hvm_shadow_max_featuremask[i];
-        }
-
-        /* Hide nested-virt if it hasn't been explicitly configured. */
-        if ( !nestedhvm_enabled(d) )
-        {
-            __clear_bit(X86_FEATURE_VMX, max_fs);
-            __clear_bit(X86_FEATURE_SVM, max_fs);
-        }
-    }
-
-    /*
-     * Allow the toolstack to set HTT, X2APIC and CMP_LEGACY.  These bits
-     * affect how to interpret topology information in other cpuid leaves.
-     */
-    __set_bit(X86_FEATURE_HTT, max_fs);
-    __set_bit(X86_FEATURE_X2APIC, max_fs);
-    __set_bit(X86_FEATURE_CMP_LEGACY, max_fs);
-
-    /*
-     * 32bit PV domains can't use any Long Mode features, and cannot use
-     * SYSCALL on non-AMD hardware.
-     */
-    if ( is_pv_32bit_domain(d) )
-    {
-        __clear_bit(X86_FEATURE_LM, max_fs);
-        if ( !(boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) )
-            __clear_bit(X86_FEATURE_SYSCALL, max_fs);
-    }
-
-    /*
-     * ITSC is masked by default (so domains are safe to migrate), but a
-     * toolstack which has configured disable_migrate or vTSC for a domain may
-     * safely select it, and needs a way of doing so.
-     */
-    if ( cpu_has_itsc && (d->disable_migrate || d->arch.vtsc) )
-        __set_bit(X86_FEATURE_ITSC, max_fs);
-
-    /* Clamp the toolstacks choices to reality. */
-    for ( i = 0; i < ARRAY_SIZE(fs); i++ )
-        fs[i] &= max_fs[i];
-
-    if ( p->basic.max_leaf < XSTATE_CPUID )
-        __clear_bit(X86_FEATURE_XSAVE, fs);
-
-    sanitise_featureset(fs);
-
-    /* Fold host's FDP_EXCP_ONLY and NO_FPU_SEL into guest's view. */
-    fs[FEATURESET_7b0] &= ~(cpufeat_mask(X86_FEATURE_FDP_EXCP_ONLY) |
-                            cpufeat_mask(X86_FEATURE_NO_FPU_SEL));
-    fs[FEATURESET_7b0] |= (host_cpu_policy.feat._7b0 &
-                           (cpufeat_mask(X86_FEATURE_FDP_EXCP_ONLY) |
-                            cpufeat_mask(X86_FEATURE_NO_FPU_SEL)));
-
-    x86_cpu_featureset_to_policy(fs, p);
-
-    /* Pass host cacheline size through to guests. */
-    p->basic.clflush_size = max->basic.clflush_size;
-
-    p->extd.maxphysaddr = min(p->extd.maxphysaddr, max->extd.maxphysaddr);
-    p->extd.maxphysaddr = min_t(uint8_t, p->extd.maxphysaddr,
-                                paging_max_paddr_bits(d));
-    p->extd.maxphysaddr = max_t(uint8_t, p->extd.maxphysaddr,
-                                (p->basic.pae || p->basic.pse36) ? 36 : 32);
-
-    p->extd.maxlinaddr = p->extd.lm ? 48 : 32;
-
-    recalculate_xstate(p);
-    recalculate_misc(p);
-
-    for ( i = 0; i < ARRAY_SIZE(p->cache.raw); ++i )
-    {
-        if ( p->cache.subleaf[i].type >= 1 &&
-             p->cache.subleaf[i].type <= 3 )
-        {
-            /* Subleaf has a valid cache type. Zero reserved fields. */
-            p->cache.raw[i].a &= 0xffffc3ffu;
-            p->cache.raw[i].d &= 0x00000007u;
-        }
-        else
-        {
-            /* Subleaf is not valid.  Zero the rest of the union. */
-            zero_leaves(p->cache.raw, i, ARRAY_SIZE(p->cache.raw) - 1);
-            break;
-        }
-    }
-
-    if ( vpmu_mode == XENPMU_MODE_OFF ||
-         ((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;
-}
-
-void __init init_dom0_cpuid_policy(struct domain *d)
-{
-    struct cpuid_policy *p = d->arch.cpuid;
-
-    /* dom0 can't migrate.  Give it ITSC if available. */
-    if ( cpu_has_itsc )
-        p->extd.itsc = true;
-
-    /*
-     * Expose the "hardware speculation behaviour" bits of ARCH_CAPS to dom0,
-     * so dom0 can turn off workarounds as appropriate.  Temporary, until the
-     * domain policy logic gains a better understanding of MSRs.
-     */
-    if ( cpu_has_arch_caps )
-        p->feat.arch_caps = true;
-
-    /* Apply dom0-cpuid= command line settings, if provided. */
-    if ( dom0_cpuid_cmdline )
-    {
-        uint32_t fs[FSCAPINTS];
-        unsigned int i;
-
-        x86_cpu_policy_to_featureset(p, fs);
-
-        for ( i = 0; i < ARRAY_SIZE(fs); ++i )
-        {
-            fs[i] |=  dom0_enable_feat [i];
-            fs[i] &= ~dom0_disable_feat[i];
-        }
-
-        x86_cpu_featureset_to_policy(fs, p);
-
-        recalculate_cpuid_policy(d);
-    }
-}
-
 void guest_cpuid(const struct vcpu *v, uint32_t leaf,
                  uint32_t subleaf, struct cpuid_leaf *res)
 {
@@ -1161,27 +403,6 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf,
     }
 }
 
-static void __init __maybe_unused build_assertions(void)
-{
-    BUILD_BUG_ON(ARRAY_SIZE(known_features) != FSCAPINTS);
-    BUILD_BUG_ON(ARRAY_SIZE(pv_max_featuremask) != FSCAPINTS);
-    BUILD_BUG_ON(ARRAY_SIZE(hvm_shadow_max_featuremask) != FSCAPINTS);
-    BUILD_BUG_ON(ARRAY_SIZE(hvm_hap_max_featuremask) != FSCAPINTS);
-    BUILD_BUG_ON(ARRAY_SIZE(deep_features) != FSCAPINTS);
-
-    /* Find some more clever allocation scheme if this trips. */
-    BUILD_BUG_ON(sizeof(struct cpuid_policy) > PAGE_SIZE);
-
-    BUILD_BUG_ON(sizeof(raw_cpu_policy.basic) !=
-                 sizeof(raw_cpu_policy.basic.raw));
-    BUILD_BUG_ON(sizeof(raw_cpu_policy.feat) !=
-                 sizeof(raw_cpu_policy.feat.raw));
-    BUILD_BUG_ON(sizeof(raw_cpu_policy.xstate) !=
-                 sizeof(raw_cpu_policy.xstate.raw));
-    BUILD_BUG_ON(sizeof(raw_cpu_policy.extd) !=
-                 sizeof(raw_cpu_policy.extd.raw));
-}
-
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 487ca4fe0c..72a30ad9b5 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -77,7 +77,6 @@
 #include <public/memory.h>
 #include <public/vm_event.h>
 #include <public/arch-x86/cpuid.h>
-#include <asm/cpuid.h>
 
 #include <compat/hvm/hvm_op.h>
 
diff --git a/xen/arch/x86/pv/domain.c b/xen/arch/x86/pv/domain.c
index fe3d22dce6..f6cc6c606b 100644
--- a/xen/arch/x86/pv/domain.c
+++ b/xen/arch/x86/pv/domain.c
@@ -10,6 +10,7 @@
 #include <xen/param.h>
 #include <xen/sched.h>
 
+#include <asm/cpu-policy.h>
 #include <asm/cpufeature.h>
 #include <asm/invpcid.h>
 #include <asm/spec_ctrl.h>
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 7a5253fd40..73da5b24ff 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -50,7 +50,6 @@
 #include <asm/alternative.h>
 #include <asm/mc146818rtc.h>
 #include <asm/cpu-policy.h>
-#include <asm/cpuid.h>
 #include <asm/spec_ctrl.h>
 #include <asm/guest.h>
 #include <asm/microcode.h>
@@ -1945,7 +1944,6 @@ void __init noreturn __start_xen(unsigned long mbi_p)
     if ( !tboot_protect_mem_regions() )
         panic("Could not protect TXT memory regions\n");
 
-    init_guest_cpuid();
     init_guest_cpu_policies();
 
     if ( xen_cpuidle )
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index 3488d21b18..37f8fea9db 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -26,6 +26,7 @@
 #include <xen/symbols.h>
 #include <xen/keyhandler.h>
 #include <xen/guest_access.h>
+#include <asm/cpu-policy.h>
 #include <asm/io.h>
 #include <asm/iocap.h>
 #include <asm/msr.h>
diff --git a/xen/include/asm-x86/cpu-policy.h b/xen/include/asm-x86/cpu-policy.h
index 13e2a1f86d..b361537a60 100644
--- a/xen/include/asm-x86/cpu-policy.h
+++ b/xen/include/asm-x86/cpu-policy.h
@@ -18,4 +18,10 @@ void init_guest_cpu_policies(void);
 /* Allocate and initialise a CPU policy suitable for the domain. */
 int init_domain_cpu_policy(struct domain *d);
 
+/* Apply dom0-specific tweaks to the CPUID policy. */
+void init_dom0_cpuid_policy(struct domain *d);
+
+/* Clamp the CPUID policy to reality. */
+void recalculate_cpuid_policy(struct domain *d);
+
 #endif /* X86_CPU_POLICY_H */
diff --git a/xen/include/asm-x86/cpuid.h b/xen/include/asm-x86/cpuid.h
index 7f81b998ce..b32ba0bbfe 100644
--- a/xen/include/asm-x86/cpuid.h
+++ b/xen/include/asm-x86/cpuid.h
@@ -8,14 +8,10 @@
 #include <xen/kernel.h>
 #include <xen/percpu.h>
 
-#include <xen/lib/x86/cpu-policy.h>
-
 #include <public/sysctl.h>
 
 extern const uint32_t known_features[FSCAPINTS];
 
-void init_guest_cpuid(void);
-
 /*
  * Expected levelling capabilities (given cpuid vendor/family information),
  * and levelling capabilities actually available (given MSR probing).
@@ -49,13 +45,8 @@ extern struct cpuidmasks cpuidmask_defaults;
 /* Check that all previously present features are still available. */
 bool recheck_cpu_features(unsigned int cpu);
 
-/* Apply dom0-specific tweaks to the CPUID policy. */
-void init_dom0_cpuid_policy(struct domain *d);
-
-/* Clamp the CPUID policy to reality. */
-void recalculate_cpuid_policy(struct domain *d);
-
 struct vcpu;
+struct cpuid_leaf;
 void guest_cpuid(const struct vcpu *v, uint32_t leaf,
                  uint32_t subleaf, struct cpuid_leaf *res);
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:02:07 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:02:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680911.1059217 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGlz-0006lG-NJ; Wed, 14 Feb 2024 15:02:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680911.1059217; Wed, 14 Feb 2024 15:02:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGlz-0006l8-KF; Wed, 14 Feb 2024 15:02:07 +0000
Received: by outflank-mailman (input) for mailman id 680911;
 Wed, 14 Feb 2024 15:02:06 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGly-0006kl-EA
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:06 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGly-0005mN-DN
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:06 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGly-0000ba-Ca
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:06 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Q22W/oTJemuHavntskio3YPhGHFmTGMRDHC/WwK50dE=; b=GP7mWnoul1Wj9WjpsKgaJsdPdT
	b3kW8qND/cRd6y8CK6u3j2BaS7anIDMVeXPpDZXyY5UVtJP0nikWtHlSENuIi1G7avodPZNOD98mU
	/CtpxlBs4+Ycw+OxgQ6/quT7uyfyJZjk46PDM7XuhcNztOOIc9BPpUV1J6FEX9RD8xg8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/emul: Switch x86_emulate_ctxt to cpu_policy
Message-Id: <E1raGly-0000ba-Ca@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:02:06 +0000

commit 72895c4e97796d6613aa437f80cf9ba4b4cf6cb3
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon Apr 3 20:03:57 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/emul: Switch x86_emulate_ctxt to cpu_policy
    
    As with struct domain, retain cpuid as a valid alias for local code clarity.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 441b1b2a50ea3656954d75e06d42c96d619ea0fc)
---
 tools/fuzz/x86_instruction_emulator/fuzz-emul.c | 2 +-
 tools/tests/x86_emulator/test_x86_emulator.c    | 2 +-
 tools/tests/x86_emulator/x86-emulate.c          | 2 +-
 xen/arch/x86/hvm/emulate.c                      | 4 ++--
 xen/arch/x86/mm/shadow/hvm.c                    | 2 +-
 xen/arch/x86/pv/emul-priv-op.c                  | 2 +-
 xen/arch/x86/pv/ro-page-fault.c                 | 2 +-
 xen/arch/x86/x86_emulate/x86_emulate.h          | 7 +++++--
 8 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c
index 28285aad24..a5453abc5a 100644
--- a/tools/fuzz/x86_instruction_emulator/fuzz-emul.c
+++ b/tools/fuzz/x86_instruction_emulator/fuzz-emul.c
@@ -896,7 +896,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data_p, size_t size)
     struct x86_emulate_ctxt ctxt = {
         .data = &state,
         .regs = &input.regs,
-        .cpuid = &cp,
+        .cpu_policy = &cp,
         .addr_size = 8 * sizeof(void *),
         .sp_size = 8 * sizeof(void *),
     };
diff --git a/tools/tests/x86_emulator/test_x86_emulator.c b/tools/tests/x86_emulator/test_x86_emulator.c
index 4b01fa8b8d..3ae07738c2 100644
--- a/tools/tests/x86_emulator/test_x86_emulator.c
+++ b/tools/tests/x86_emulator/test_x86_emulator.c
@@ -885,7 +885,7 @@ int main(int argc, char **argv)
 
     ctxt.regs = &regs;
     ctxt.force_writeback = 0;
-    ctxt.cpuid     = &cp;
+    ctxt.cpu_policy = &cp;
     ctxt.lma       = sizeof(void *) == 8;
     ctxt.addr_size = 8 * sizeof(void *);
     ctxt.sp_size   = 8 * sizeof(void *);
diff --git a/tools/tests/x86_emulator/x86-emulate.c b/tools/tests/x86_emulator/x86-emulate.c
index c32d9a55b4..9fb9046501 100644
--- a/tools/tests/x86_emulator/x86-emulate.c
+++ b/tools/tests/x86_emulator/x86-emulate.c
@@ -38,7 +38,7 @@
 #define put_stub(stb) ((stb).addr = 0)
 
 uint32_t mxcsr_mask = 0x0000ffbf;
-struct cpuid_policy cp;
+struct cpu_policy cp;
 
 static char fpu_save_area[4096] __attribute__((__aligned__((64))));
 static bool use_xsave;
diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index ee940c33ca..b6e95dc79d 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -2775,7 +2775,7 @@ int hvm_emulate_one_mmio(unsigned long mfn, unsigned long gla)
 void hvm_emulate_one_vm_event(enum emul_kind kind, unsigned int trapnr,
     unsigned int errcode)
 {
-    struct hvm_emulate_ctxt ctx = {{ 0 }};
+    struct hvm_emulate_ctxt ctx = {};
     int rc;
 
     hvm_emulate_init_once(&ctx, NULL, guest_cpu_user_regs());
@@ -2850,7 +2850,7 @@ void hvm_emulate_init_once(
 
     hvmemul_ctxt->validate = validate;
     hvmemul_ctxt->ctxt.regs = regs;
-    hvmemul_ctxt->ctxt.cpuid = curr->domain->arch.cpuid;
+    hvmemul_ctxt->ctxt.cpu_policy = curr->domain->arch.cpu_policy;
     hvmemul_ctxt->ctxt.force_writeback = true;
 }
 
diff --git a/xen/arch/x86/mm/shadow/hvm.c b/xen/arch/x86/mm/shadow/hvm.c
index 608360daec..5b3ce7526a 100644
--- a/xen/arch/x86/mm/shadow/hvm.c
+++ b/xen/arch/x86/mm/shadow/hvm.c
@@ -322,7 +322,7 @@ const struct x86_emulate_ops *shadow_init_emulation(
     memset(sh_ctxt, 0, sizeof(*sh_ctxt));
 
     sh_ctxt->ctxt.regs = regs;
-    sh_ctxt->ctxt.cpuid = curr->domain->arch.cpuid;
+    sh_ctxt->ctxt.cpu_policy = curr->domain->arch.cpu_policy;
     sh_ctxt->ctxt.lma = hvm_long_mode_active(curr);
 
     /* Segment cache initialisation. Primed with CS. */
diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c
index 6a69af46ba..9508aaf20c 100644
--- a/xen/arch/x86/pv/emul-priv-op.c
+++ b/xen/arch/x86/pv/emul-priv-op.c
@@ -1254,7 +1254,7 @@ int pv_emulate_privileged_op(struct cpu_user_regs *regs)
     struct domain *currd = curr->domain;
     struct priv_op_ctxt ctxt = {
         .ctxt.regs = regs,
-        .ctxt.cpuid = currd->arch.cpuid,
+        .ctxt.cpu_policy = currd->arch.cpu_policy,
         .ctxt.lma = !is_pv_32bit_domain(currd),
     };
     int rc;
diff --git a/xen/arch/x86/pv/ro-page-fault.c b/xen/arch/x86/pv/ro-page-fault.c
index 0eedb70002..b8f8fb4d45 100644
--- a/xen/arch/x86/pv/ro-page-fault.c
+++ b/xen/arch/x86/pv/ro-page-fault.c
@@ -340,7 +340,7 @@ int pv_ro_page_fault(unsigned long addr, struct cpu_user_regs *regs)
     unsigned int addr_size = is_pv_32bit_domain(currd) ? 32 : BITS_PER_LONG;
     struct x86_emulate_ctxt ctxt = {
         .regs      = regs,
-        .cpuid     = currd->arch.cpuid,
+        .cpu_policy = currd->arch.cpu_policy,
         .addr_size = addr_size,
         .sp_size   = addr_size,
         .lma       = addr_size > 32,
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.h b/xen/arch/x86/x86_emulate/x86_emulate.h
index ce8226bd4c..cb9a8c41f2 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.h
+++ b/xen/arch/x86/x86_emulate/x86_emulate.h
@@ -566,8 +566,11 @@ struct x86_emulate_ctxt
      * Input-only state:
      */
 
-    /* CPUID Policy for the domain. */
-    const struct cpuid_policy *cpuid;
+    /* CPU policy for the domain.  Allow aliases for local code clarity. */
+    union {
+        struct cpu_policy *cpu_policy;
+        struct cpu_policy *cpuid;
+    };
 
     /* Set this if writes may have side effects. */
     bool force_writeback;
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:02:17 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:02:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680912.1059221 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGm9-0006nv-O9; Wed, 14 Feb 2024 15:02:17 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680912.1059221; Wed, 14 Feb 2024 15:02:17 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGm9-0006no-Le; Wed, 14 Feb 2024 15:02:17 +0000
Received: by outflank-mailman (input) for mailman id 680912;
 Wed, 14 Feb 2024 15:02:16 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGm8-0006ne-HT
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:16 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGm8-0005mU-Gh
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:16 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGm8-0000e0-Fe
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:16 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=t2oPVrNQh3RR17lkCTG8VJISnF11BbH57ZJgjNlxqMo=; b=J3kRwr20+QW/SH1Itg0XYfERUS
	t0cuhUCHHVxj7oXZm9s9/zXljbx9rzptYPhhiuWZFe5ZnDWwhWLZHcHNZ5FCS8xzT0eNy0ArM+QGX
	l3SQNCdObeAPFlOheK2QBK91EGL/5qDGN5hYLaznEAx1nRDQbZKARwyfvGyKqzdGaF+I=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] tools/fuzz: Rework afl-policy-fuzzer
Message-Id: <E1raGm8-0000e0-Fe@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:02:16 +0000

commit 738d89d31fa935090cdc14ff437cafadbc40ba9a
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon Apr 3 17:14:14 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    tools/fuzz: Rework afl-policy-fuzzer
    
    With cpuid_policy and msr_policy merged to form cpu_policy, merge the
    respective fuzzing logic.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit a16dcd48c2db3f6820a15ea482551d289bd9cdec)
---
 tools/fuzz/cpu-policy/afl-policy-fuzzer.c | 57 +++++++++++--------------------
 1 file changed, 20 insertions(+), 37 deletions(-)

diff --git a/tools/fuzz/cpu-policy/afl-policy-fuzzer.c b/tools/fuzz/cpu-policy/afl-policy-fuzzer.c
index 316eb0efe0..585324e417 100644
--- a/tools/fuzz/cpu-policy/afl-policy-fuzzer.c
+++ b/tools/fuzz/cpu-policy/afl-policy-fuzzer.c
@@ -16,16 +16,19 @@ static bool debug;
 
 #define EMPTY_LEAF ((struct cpuid_leaf){})
 
-static void check_cpuid(struct cpuid_policy *cp)
+static void check_policy(struct cpu_policy *cp)
 {
-    struct cpuid_policy new = {};
+    struct cpu_policy new = {};
     size_t data_end;
     xen_cpuid_leaf_t *leaves = malloc(CPUID_MAX_SERIALISED_LEAVES *
                                       sizeof(xen_cpuid_leaf_t));
-    unsigned int nr = CPUID_MAX_SERIALISED_LEAVES;
+    xen_msr_entry_t *msrs = malloc(MSR_MAX_SERIALISED_ENTRIES *
+                                   sizeof(xen_cpuid_leaf_t));
+    unsigned int nr_leaves = CPUID_MAX_SERIALISED_LEAVES;
+    unsigned int nr_msrs = MSR_MAX_SERIALISED_ENTRIES;
     int rc;
 
-    if ( !leaves )
+    if ( !leaves || !msrs )
         return;
 
     /*
@@ -49,12 +52,19 @@ static void check_cpuid(struct cpuid_policy *cp)
     x86_cpuid_policy_recalc_synth(cp);
 
     /* Serialise... */
-    rc = x86_cpuid_copy_to_buffer(cp, leaves, &nr);
+    rc = x86_cpuid_copy_to_buffer(cp, leaves, &nr_leaves);
+    assert(rc == 0);
+    assert(nr_leaves <= CPUID_MAX_SERIALISED_LEAVES);
+
+    rc = x86_msr_copy_to_buffer(cp, msrs, &nr_msrs);
     assert(rc == 0);
-    assert(nr <= CPUID_MAX_SERIALISED_LEAVES);
+    assert(nr_msrs <= MSR_MAX_SERIALISED_ENTRIES);
 
     /* ... and deserialise. */
-    rc = x86_cpuid_copy_from_buffer(&new, leaves, nr, NULL, NULL);
+    rc = x86_cpuid_copy_from_buffer(&new, leaves, nr_leaves, NULL, NULL);
+    assert(rc == 0);
+
+    rc = x86_msr_copy_from_buffer(&new, msrs, nr_msrs, NULL);
     assert(rc == 0);
 
     /* The result after serialisation/deserialisaion should be identical... */
@@ -76,28 +86,6 @@ static void check_cpuid(struct cpuid_policy *cp)
     free(leaves);
 }
 
-static void check_msr(struct msr_policy *mp)
-{
-    struct msr_policy new = {};
-    xen_msr_entry_t *msrs = malloc(MSR_MAX_SERIALISED_ENTRIES *
-                                   sizeof(xen_msr_entry_t));
-    unsigned int nr = MSR_MAX_SERIALISED_ENTRIES;
-    int rc;
-
-    if ( !msrs )
-        return;
-
-    rc = x86_msr_copy_to_buffer(mp, msrs, &nr);
-    assert(rc == 0);
-    assert(nr <= MSR_MAX_SERIALISED_ENTRIES);
-
-    rc = x86_msr_copy_from_buffer(&new, msrs, nr, NULL);
-    assert(rc == 0);
-    assert(memcmp(mp, &new, sizeof(*mp)) == 0);
-
-    free(msrs);
-}
-
 int main(int argc, char **argv)
 {
     FILE *fp = NULL;
@@ -144,8 +132,7 @@ int main(int argc, char **argv)
     while ( __AFL_LOOP(1000) )
 #endif
     {
-        struct cpuid_policy *cp = NULL;
-        struct msr_policy *mp = NULL;
+        struct cpu_policy *cp = NULL;
 
         if ( fp != stdin )
         {
@@ -160,22 +147,18 @@ int main(int argc, char **argv)
         }
 
         cp = calloc(1, sizeof(*cp));
-        mp = calloc(1, sizeof(*mp));
-        if ( !cp || !mp )
+        if ( !cp )
             goto skip;
 
         fread(cp, sizeof(*cp), 1, fp);
-        fread(mp, sizeof(*mp), 1, fp);
 
         if ( !feof(fp) )
             goto skip;
 
-        check_cpuid(cp);
-        check_msr(mp);
+        check_policy(cp);
 
     skip:
         free(cp);
-        free(mp);
 
         if ( fp != stdin )
         {
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:02:27 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:02:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680913.1059225 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGmJ-0006ql-Q1; Wed, 14 Feb 2024 15:02:27 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680913.1059225; Wed, 14 Feb 2024 15:02:27 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGmJ-0006qe-NF; Wed, 14 Feb 2024 15:02:27 +0000
Received: by outflank-mailman (input) for mailman id 680913;
 Wed, 14 Feb 2024 15:02:26 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGmI-0006qU-Kc
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:26 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGmI-0005mk-Jw
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:26 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGmI-0000es-JB
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:26 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=VAqQcyJ610GmLNZzIjoBt85ZkpecJOLHZgGuZr8j9VM=; b=tikDMqrmDQh6fSVW7Q6Y/TGXuP
	tqlMJ255dTsHkzdfn3R4G2yEU4ynAnp483qmgns8+cge1kxQQb2twthGLuFiMk+NTRdjC+EP7dujg
	BMXvViGqdlV8b7Iy7SJub2jJkadpUvBo5hc5KFHzcGTIo/lDpByUKrYm3IKIErDavYA4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] libx86: Update library API for cpu_policy
Message-Id: <E1raGmI-0000es-JB@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:02:26 +0000

commit c1adeb47797808a7655187b9ae6486f5d92f3ed1
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon Apr 3 14:18:43 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    libx86: Update library API for cpu_policy
    
    Adjust the API and comments appropriately.
    
    x86_cpu_policy_fill_native() will eventually contain MSR reads, but leave a
    TODO in the short term.
    
    No practical change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 1b67fccf3b02825f6a036bad06cd17963d0972d2)
    
    tools/libs/guest: Fix build following libx86 changes
    
    I appear to have lost this hunk somewhere...
    
    Fixes: 1b67fccf3b02 ("libx86: Update library API for cpu_policy")
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Roger Pau Monné <roger.pau@citrix.com>
    (cherry picked from commit 48d76e6da92f9ef76c8468e299349a2f698362fa)
---
 tools/fuzz/cpu-policy/afl-policy-fuzzer.c |  4 +--
 tools/libxc/xc_cpuid_x86.c                |  2 +-
 tools/tests/cpu-policy/test-cpu-policy.c  |  4 +--
 tools/tests/x86_emulator/x86-emulate.c    |  2 +-
 xen/arch/x86/cpu-policy.c                 |  4 +--
 xen/arch/x86/cpu/common.c                 |  2 +-
 xen/arch/x86/domctl.c                     |  2 +-
 xen/arch/x86/xstate.c                     |  4 +--
 xen/include/xen/lib/x86/cpu-policy.h      | 49 ++++++++++++++++++-------------
 xen/lib/x86/cpuid.c                       | 26 ++++++++--------
 xen/lib/x86/msr.c                         |  4 +--
 11 files changed, 56 insertions(+), 47 deletions(-)

diff --git a/tools/fuzz/cpu-policy/afl-policy-fuzzer.c b/tools/fuzz/cpu-policy/afl-policy-fuzzer.c
index 585324e417..11df2f7802 100644
--- a/tools/fuzz/cpu-policy/afl-policy-fuzzer.c
+++ b/tools/fuzz/cpu-policy/afl-policy-fuzzer.c
@@ -48,8 +48,8 @@ static void check_policy(struct cpu_policy *cp)
      * Fix up the data in the source policy which isn't expected to survive
      * serialisation.
      */
-    x86_cpuid_policy_clear_out_of_range_leaves(cp);
-    x86_cpuid_policy_recalc_synth(cp);
+    x86_cpu_policy_clear_out_of_range_leaves(cp);
+    x86_cpu_policy_recalc_synth(cp);
 
     /* Serialise... */
     rc = x86_cpuid_copy_to_buffer(cp, leaves, &nr_leaves);
diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index b936e1d0e0..3067fb2169 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -558,7 +558,7 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, bool restore,
             const uint32_t *dfs;
 
             if ( !test_bit(b, disabled_features) ||
-                 !(dfs = x86_cpuid_lookup_deep_deps(b)) )
+                 !(dfs = x86_cpu_policy_lookup_deep_deps(b)) )
                 continue;
 
             for ( i = 0; i < ARRAY_SIZE(disabled_features); ++i )
diff --git a/tools/tests/cpu-policy/test-cpu-policy.c b/tools/tests/cpu-policy/test-cpu-policy.c
index a7c19be63f..88d35c6c8e 100644
--- a/tools/tests/cpu-policy/test-cpu-policy.c
+++ b/tools/tests/cpu-policy/test-cpu-policy.c
@@ -95,7 +95,7 @@ static void test_cpuid_current(void)
 
     printf("Testing CPUID on current CPU\n");
 
-    x86_cpuid_policy_fill_native(&p);
+    x86_cpu_policy_fill_native(&p);
 
     rc = x86_cpuid_copy_to_buffer(&p, leaves, &nr);
     if ( rc != 0 )
@@ -537,7 +537,7 @@ static void test_cpuid_out_of_range_clearing(void)
         void *ptr;
         unsigned int nr_markers;
 
-        x86_cpuid_policy_clear_out_of_range_leaves(p);
+        x86_cpu_policy_clear_out_of_range_leaves(p);
 
         /* Count the number of 0xc2's still remaining. */
         for ( ptr = p, nr_markers = 0;
diff --git a/tools/tests/x86_emulator/x86-emulate.c b/tools/tests/x86_emulator/x86-emulate.c
index 9fb9046501..7e794df11a 100644
--- a/tools/tests/x86_emulator/x86-emulate.c
+++ b/tools/tests/x86_emulator/x86-emulate.c
@@ -85,7 +85,7 @@ bool emul_test_init(void)
 
     unsigned long sp;
 
-    x86_cpuid_policy_fill_native(&cp);
+    x86_cpu_policy_fill_native(&cp);
 
     /*
      * The emulator doesn't use these instructions, so can always emulate
diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
index a4ba8e9dea..59ea49ac1b 100644
--- a/xen/arch/x86/cpu-policy.c
+++ b/xen/arch/x86/cpu-policy.c
@@ -176,7 +176,7 @@ static void sanitise_featureset(uint32_t *fs)
     for_each_set_bit(i, (void *)disabled_features,
                      sizeof(disabled_features) * 8)
     {
-        const uint32_t *dfs = x86_cpuid_lookup_deep_deps(i);
+        const uint32_t *dfs = x86_cpu_policy_lookup_deep_deps(i);
         unsigned int j;
 
         ASSERT(dfs); /* deep_features[] should guarentee this. */
@@ -347,7 +347,7 @@ static void __init calculate_raw_policy(void)
 {
     struct cpu_policy *p = &raw_cpu_policy;
 
-    x86_cpuid_policy_fill_native(p);
+    x86_cpu_policy_fill_native(p);
 
     /* Nothing good will come from Xen and libx86 disagreeing on vendor. */
     ASSERT(p->x86_vendor == boot_cpu_data.x86_vendor);
diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index 088a871969..29460135eb 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -72,7 +72,7 @@ void __init setup_clear_cpu_cap(unsigned int cap)
 		       __builtin_return_address(0), cap);
 
 	__clear_bit(cap, boot_cpu_data.x86_capability);
-	dfs = x86_cpuid_lookup_deep_deps(cap);
+	dfs = x86_cpu_policy_lookup_deep_deps(cap);
 
 	if (!dfs)
 		return;
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index adf70607c7..3cda239210 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -245,7 +245,7 @@ static int update_domain_cpu_policy(struct domain *d,
         goto out;
 
     /* Trim any newly-stale out-of-range leaves. */
-    x86_cpuid_policy_clear_out_of_range_leaves(new);
+    x86_cpu_policy_clear_out_of_range_leaves(new);
 
     /* Audit the combined dataset. */
     ret = x86_cpu_policies_are_compatible(sys, new, &err);
diff --git a/xen/arch/x86/xstate.c b/xen/arch/x86/xstate.c
index 3bcc523f80..7d935354ae 100644
--- a/xen/arch/x86/xstate.c
+++ b/xen/arch/x86/xstate.c
@@ -677,7 +677,7 @@ static bool valid_xcr0(u64 xcr0)
 int validate_xstate(const struct domain *d, uint64_t xcr0, uint64_t xcr0_accum,
                     const struct xsave_hdr *hdr)
 {
-    uint64_t xcr0_max = cpuid_policy_xcr0_max(d->arch.cpuid);
+    uint64_t xcr0_max = cpu_policy_xcr0_max(d->arch.cpuid);
     unsigned int i;
 
     if ( (hdr->xstate_bv & ~xcr0_accum) ||
@@ -701,7 +701,7 @@ int validate_xstate(const struct domain *d, uint64_t xcr0, uint64_t xcr0_accum,
 int handle_xsetbv(u32 index, u64 new_bv)
 {
     struct vcpu *curr = current;
-    uint64_t xcr0_max = cpuid_policy_xcr0_max(curr->domain->arch.cpuid);
+    uint64_t xcr0_max = cpu_policy_xcr0_max(curr->domain->arch.cpuid);
     u64 mask;
 
     if ( index != XCR_XFEATURE_ENABLED_MASK )
diff --git a/xen/include/xen/lib/x86/cpu-policy.h b/xen/include/xen/lib/x86/cpu-policy.h
index 57b4633c86..cf7de0f29c 100644
--- a/xen/include/xen/lib/x86/cpu-policy.h
+++ b/xen/include/xen/lib/x86/cpu-policy.h
@@ -399,33 +399,38 @@ void x86_cpu_policy_to_featureset(const struct cpu_policy *p,
 void x86_cpu_featureset_to_policy(const uint32_t fs[FEATURESET_NR_ENTRIES],
                                   struct cpu_policy *p);
 
-static inline uint64_t cpuid_policy_xcr0_max(const struct cpuid_policy *p)
+static inline uint64_t cpu_policy_xcr0_max(const struct cpu_policy *p)
 {
     return ((uint64_t)p->xstate.xcr0_high << 32) | p->xstate.xcr0_low;
 }
 
-static inline uint64_t cpuid_policy_xstates(const struct cpuid_policy *p)
+static inline uint64_t cpu_policy_xstates(const struct cpu_policy *p)
 {
     uint64_t val = p->xstate.xcr0_high | p->xstate.xss_high;
 
     return (val << 32) | p->xstate.xcr0_low | p->xstate.xss_low;
 }
 
-const uint32_t *x86_cpuid_lookup_deep_deps(uint32_t feature);
+/**
+ * For a specific feature, look up the dependent features.  Returns NULL if
+ * this feature has no dependencies.  Otherwise return a featureset of
+ * dependent features, which has been recursively flattened.
+ */
+const uint32_t *x86_cpu_policy_lookup_deep_deps(uint32_t feature);
 
 /**
- * Recalculate the content in a CPUID policy which is derived from raw data.
+ * Recalculate the content in a CPU policy which is derived from raw data.
  */
-void x86_cpuid_policy_recalc_synth(struct cpuid_policy *p);
+void x86_cpu_policy_recalc_synth(struct cpu_policy *p);
 
 /**
- * Fill a CPUID policy using the native CPUID instruction.
+ * Fill CPU policy using the native CPUID/RDMSR instruction.
  *
  * No sanitisation is performed, but synthesised values are calculated.
  * Values may be influenced by a hypervisor or from masking/faulting
  * configuration.
  */
-void x86_cpuid_policy_fill_native(struct cpuid_policy *p);
+void x86_cpu_policy_fill_native(struct cpu_policy *p);
 
 /**
  * Clear leaf data beyond the policies max leaf/subleaf settings.
@@ -436,7 +441,7 @@ void x86_cpuid_policy_fill_native(struct cpuid_policy *p);
  * with out-of-range leaves with stale content in them.  This helper clears
  * them.
  */
-void x86_cpuid_policy_clear_out_of_range_leaves(struct cpuid_policy *p);
+void x86_cpu_policy_clear_out_of_range_leaves(struct cpu_policy *p);
 
 #ifdef __XEN__
 #include <public/arch-x86/xen.h>
@@ -449,9 +454,10 @@ typedef xen_msr_entry_t msr_entry_buffer_t[];
 #endif
 
 /**
- * Serialise a cpuid_policy object into an array of cpuid leaves.
+ * Serialise the CPUID leaves of a cpu_policy object into an array of cpuid
+ * leaves.
  *
- * @param policy     The cpuid_policy to serialise.
+ * @param policy     The cpu_policy to serialise.
  * @param leaves     The array of leaves to serialise into.
  * @param nr_entries The number of entries in 'leaves'.
  * @returns -errno
@@ -460,13 +466,14 @@ typedef xen_msr_entry_t msr_entry_buffer_t[];
  * leaves array is too short.  On success, nr_entries is updated with the
  * actual number of leaves written.
  */
-int x86_cpuid_copy_to_buffer(const struct cpuid_policy *policy,
+int x86_cpuid_copy_to_buffer(const struct cpu_policy *policy,
                              cpuid_leaf_buffer_t leaves, uint32_t *nr_entries);
 
 /**
- * Unserialise a cpuid_policy object from an array of cpuid leaves.
+ * Unserialise the CPUID leaves of a cpu_policy object into an array of cpuid
+ * leaves.
  *
- * @param policy      The cpuid_policy to unserialise into.
+ * @param policy      The cpu_policy to unserialise into.
  * @param leaves      The array of leaves to unserialise from.
  * @param nr_entries  The number of entries in 'leaves'.
  * @param err_leaf    Optional hint for error diagnostics.
@@ -474,21 +481,21 @@ int x86_cpuid_copy_to_buffer(const struct cpuid_policy *policy,
  * @returns -errno
  *
  * Reads at most CPUID_MAX_SERIALISED_LEAVES.  May return -ERANGE if an
- * incoming leaf is out of range of cpuid_policy, in which case the optional
+ * incoming leaf is out of range of cpu_policy, in which case the optional
  * err_* pointers will identify the out-of-range indicies.
  *
  * No content validation of in-range leaves is performed.  Synthesised data is
  * recalculated.
  */
-int x86_cpuid_copy_from_buffer(struct cpuid_policy *policy,
+int x86_cpuid_copy_from_buffer(struct cpu_policy *policy,
                                const cpuid_leaf_buffer_t leaves,
                                uint32_t nr_entries, uint32_t *err_leaf,
                                uint32_t *err_subleaf);
 
 /**
- * Serialise an msr_policy object into an array.
+ * Serialise the MSRs of a cpu_policy object into an array.
  *
- * @param policy     The msr_policy to serialise.
+ * @param policy     The cpu_policy to serialise.
  * @param msrs       The array of msrs to serialise into.
  * @param nr_entries The number of entries in 'msrs'.
  * @returns -errno
@@ -497,13 +504,13 @@ int x86_cpuid_copy_from_buffer(struct cpuid_policy *policy,
  * buffer array is too short.  On success, nr_entries is updated with the
  * actual number of msrs written.
  */
-int x86_msr_copy_to_buffer(const struct msr_policy *policy,
+int x86_msr_copy_to_buffer(const struct cpu_policy *policy,
                            msr_entry_buffer_t msrs, uint32_t *nr_entries);
 
 /**
- * Unserialise an msr_policy object from an array of msrs.
+ * Unserialise the MSRs of a cpu_policy object from an array of msrs.
  *
- * @param policy     The msr_policy object to unserialise into.
+ * @param policy     The cpu_policy object to unserialise into.
  * @param msrs       The array of msrs to unserialise from.
  * @param nr_entries The number of entries in 'msrs'.
  * @param err_msr    Optional hint for error diagnostics.
@@ -517,7 +524,7 @@ int x86_msr_copy_to_buffer(const struct msr_policy *policy,
  *
  * No content validation is performed on the data stored in the policy object.
  */
-int x86_msr_copy_from_buffer(struct msr_policy *policy,
+int x86_msr_copy_from_buffer(struct cpu_policy *policy,
                              const msr_entry_buffer_t msrs, uint32_t nr_entries,
                              uint32_t *err_msr);
 
diff --git a/xen/lib/x86/cpuid.c b/xen/lib/x86/cpuid.c
index 275bea7dff..1b83f7c576 100644
--- a/xen/lib/x86/cpuid.c
+++ b/xen/lib/x86/cpuid.c
@@ -102,13 +102,13 @@ void x86_cpu_featureset_to_policy(
     p->feat._7d1             = fs[FEATURESET_7d1];
 }
 
-void x86_cpuid_policy_recalc_synth(struct cpuid_policy *p)
+void x86_cpu_policy_recalc_synth(struct cpu_policy *p)
 {
     p->x86_vendor = x86_cpuid_lookup_vendor(
         p->basic.vendor_ebx, p->basic.vendor_ecx, p->basic.vendor_edx);
 }
 
-void x86_cpuid_policy_fill_native(struct cpuid_policy *p)
+void x86_cpu_policy_fill_native(struct cpu_policy *p)
 {
     unsigned int i;
 
@@ -199,7 +199,7 @@ void x86_cpuid_policy_fill_native(struct cpuid_policy *p)
         cpuid_count_leaf(0xd, 0, &p->xstate.raw[0]);
         cpuid_count_leaf(0xd, 1, &p->xstate.raw[1]);
 
-        xstates = cpuid_policy_xstates(p);
+        xstates = cpu_policy_xstates(p);
 
         /* This logic will probably need adjusting when XCR0[63] gets used. */
         BUILD_BUG_ON(ARRAY_SIZE(p->xstate.raw) > 63);
@@ -222,10 +222,12 @@ void x86_cpuid_policy_fill_native(struct cpuid_policy *p)
     p->hv_limit = 0;
     p->hv2_limit = 0;
 
-    x86_cpuid_policy_recalc_synth(p);
+    /* TODO MSRs */
+
+    x86_cpu_policy_recalc_synth(p);
 }
 
-void x86_cpuid_policy_clear_out_of_range_leaves(struct cpuid_policy *p)
+void x86_cpu_policy_clear_out_of_range_leaves(struct cpu_policy *p)
 {
     unsigned int i;
 
@@ -260,7 +262,7 @@ void x86_cpuid_policy_clear_out_of_range_leaves(struct cpuid_policy *p)
         zero_leaves(p->topo.raw, i, ARRAY_SIZE(p->topo.raw) - 1);
     }
 
-    if ( p->basic.max_leaf < 0xd || !cpuid_policy_xstates(p) )
+    if ( p->basic.max_leaf < 0xd || !cpu_policy_xstates(p) )
         memset(p->xstate.raw, 0, sizeof(p->xstate.raw));
     else
     {
@@ -268,7 +270,7 @@ void x86_cpuid_policy_clear_out_of_range_leaves(struct cpuid_policy *p)
         BUILD_BUG_ON(ARRAY_SIZE(p->xstate.raw) > 63);
 
         /* First two leaves always valid.  Rest depend on xstates. */
-        i = max(2, 64 - __builtin_clzll(cpuid_policy_xstates(p)));
+        i = max(2, 64 - __builtin_clzll(cpu_policy_xstates(p)));
 
         zero_leaves(p->xstate.raw, i,
                     ARRAY_SIZE(p->xstate.raw) - 1);
@@ -278,7 +280,7 @@ void x86_cpuid_policy_clear_out_of_range_leaves(struct cpuid_policy *p)
                 ARRAY_SIZE(p->extd.raw) - 1);
 }
 
-const uint32_t *x86_cpuid_lookup_deep_deps(uint32_t feature)
+const uint32_t *x86_cpu_policy_lookup_deep_deps(uint32_t feature)
 {
     static const uint32_t deep_features[] = INIT_DEEP_FEATURES;
     static const struct {
@@ -333,7 +335,7 @@ static int copy_leaf_to_buffer(uint32_t leaf, uint32_t subleaf,
     return 0;
 }
 
-int x86_cpuid_copy_to_buffer(const struct cpuid_policy *p,
+int x86_cpuid_copy_to_buffer(const struct cpu_policy *p,
                              cpuid_leaf_buffer_t leaves, uint32_t *nr_entries_p)
 {
     const uint32_t nr_entries = *nr_entries_p;
@@ -383,7 +385,7 @@ int x86_cpuid_copy_to_buffer(const struct cpuid_policy *p,
 
         case 0xd:
         {
-            uint64_t xstates = cpuid_policy_xstates(p);
+            uint64_t xstates = cpu_policy_xstates(p);
 
             COPY_LEAF(leaf, 0, &p->xstate.raw[0]);
             COPY_LEAF(leaf, 1, &p->xstate.raw[1]);
@@ -419,7 +421,7 @@ int x86_cpuid_copy_to_buffer(const struct cpuid_policy *p,
     return 0;
 }
 
-int x86_cpuid_copy_from_buffer(struct cpuid_policy *p,
+int x86_cpuid_copy_from_buffer(struct cpu_policy *p,
                                const cpuid_leaf_buffer_t leaves,
                                uint32_t nr_entries, uint32_t *err_leaf,
                                uint32_t *err_subleaf)
@@ -522,7 +524,7 @@ int x86_cpuid_copy_from_buffer(struct cpuid_policy *p,
         }
     }
 
-    x86_cpuid_policy_recalc_synth(p);
+    x86_cpu_policy_recalc_synth(p);
 
     return 0;
 
diff --git a/xen/lib/x86/msr.c b/xen/lib/x86/msr.c
index c4d885e7b5..e04b9ca013 100644
--- a/xen/lib/x86/msr.c
+++ b/xen/lib/x86/msr.c
@@ -23,7 +23,7 @@ static int copy_msr_to_buffer(uint32_t idx, uint64_t val,
     return 0;
 }
 
-int x86_msr_copy_to_buffer(const struct msr_policy *p,
+int x86_msr_copy_to_buffer(const struct cpu_policy *p,
                            msr_entry_buffer_t msrs, uint32_t *nr_entries_p)
 {
     const uint32_t nr_entries = *nr_entries_p;
@@ -48,7 +48,7 @@ int x86_msr_copy_to_buffer(const struct msr_policy *p,
     return 0;
 }
 
-int x86_msr_copy_from_buffer(struct msr_policy *p,
+int x86_msr_copy_from_buffer(struct cpu_policy *p,
                              const msr_entry_buffer_t msrs, uint32_t nr_entries,
                              uint32_t *err_msr)
 {
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:02:38 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:02:38 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680915.1059239 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGmU-0007Bk-75; Wed, 14 Feb 2024 15:02:38 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680915.1059239; Wed, 14 Feb 2024 15:02:38 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGmU-0007Bd-3z; Wed, 14 Feb 2024 15:02:38 +0000
Received: by outflank-mailman (input) for mailman id 680915;
 Wed, 14 Feb 2024 15:02:36 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGmS-00079G-Or
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:36 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGmS-0005n6-O4
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:36 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGmS-0000fL-NO
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:36 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=tGKmIESyN95uWdIZlL8StBI9LoWLYp6ycQXp5DN6S+o=; b=Tw5AJCeWjL6+bz7eEUtZtxUpwM
	klH9K6WZXnQYQWo5iMywEd9rdODcsPQs3Q0nT3PSzSUaBNRjHmM9dqfhSUzcsVTElaU40GnM8oW7Z
	QJLixKGG82Qfx20do8pCz8SZuzXw8ETLPwnaMkwhUDxeytNhUAW6DMwFSjpK6NJhfLSY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86: Remove temporary {cpuid,msr}_policy defines
Message-Id: <E1raGmS-0000fL-NO@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:02:36 +0000

commit f5b0f486dc3e9b94cf6a44a8877fb090cd6af911
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Mar 29 13:07:03 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86: Remove temporary {cpuid,msr}_policy defines
    
    With all code areas updated, drop the temporary defines and adjust all
    remaining users.
    
    No practical change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 994c1553a158ada9db5ab64c9178a0d23c0a42ce)
---
 xen/arch/x86/cpuid.c                   |  2 +-
 xen/arch/x86/domctl.c                  |  2 +-
 xen/arch/x86/hvm/hvm.c                 |  4 ++--
 xen/arch/x86/hvm/svm/svm.c             |  2 +-
 xen/arch/x86/hvm/vlapic.c              |  2 +-
 xen/arch/x86/hvm/vmx/vmx.c             |  4 ++--
 xen/arch/x86/msr.c                     | 20 +++++++++-----------
 xen/arch/x86/pv/domain.c               |  2 +-
 xen/arch/x86/traps.c                   |  2 +-
 xen/arch/x86/x86_emulate/x86_emulate.c |  6 +++---
 xen/include/asm-x86/msr.h              |  2 +-
 xen/include/xen/lib/x86/cpu-policy.h   |  4 ----
 12 files changed, 23 insertions(+), 29 deletions(-)

diff --git a/xen/arch/x86/cpuid.c b/xen/arch/x86/cpuid.c
index f33dd29d4d..ef4dca8b8d 100644
--- a/xen/arch/x86/cpuid.c
+++ b/xen/arch/x86/cpuid.c
@@ -37,7 +37,7 @@ void guest_cpuid(const struct vcpu *v, uint32_t leaf,
                  uint32_t subleaf, struct cpuid_leaf *res)
 {
     const struct domain *d = v->domain;
-    const struct cpuid_policy *p = d->arch.cpuid;
+    const struct cpu_policy *p = d->arch.cpu_policy;
 
     *res = EMPTY_LEAF;
 
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 3cda239210..7fbd46e5b5 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -51,7 +51,7 @@ static int gdbsx_guest_mem_io(domid_t domid, struct xen_domctl_gdbsx_memio *iop)
 
 void domain_cpu_policy_changed(struct domain *d)
 {
-    const struct cpuid_policy *p = d->arch.cpuid;
+    const struct cpu_policy *p = d->arch.cpu_policy;
     struct vcpu *v;
 
     if ( is_pv_domain(d) )
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 72a30ad9b5..c9a57f3177 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -936,7 +936,7 @@ const char *hvm_efer_valid(const struct vcpu *v, uint64_t value,
                            signed int cr0_pg)
 {
     const struct domain *d = v->domain;
-    const struct cpuid_policy *p = d->arch.cpuid;
+    const struct cpu_policy *p = d->arch.cpu_policy;
 
     if ( value & ~EFER_KNOWN_MASK )
         return "Unknown bits set";
@@ -973,7 +973,7 @@ const char *hvm_efer_valid(const struct vcpu *v, uint64_t value,
 /* These bits in CR4 can be set by the guest. */
 unsigned long hvm_cr4_guest_valid_bits(const struct domain *d, bool restore)
 {
-    const struct cpuid_policy *p = d->arch.cpuid;
+    const struct cpu_policy *p = d->arch.cpu_policy;
     bool mce, vmxe;
 
     /* Logic broken out simply to aid readability below. */
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 68db3c8f88..bffca24d93 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -593,7 +593,7 @@ static void svm_cpuid_policy_changed(struct vcpu *v)
 {
     struct svm_vcpu *svm = &v->arch.hvm.svm;
     struct vmcb_struct *vmcb = svm->vmcb;
-    const struct cpuid_policy *cp = v->domain->arch.cpuid;
+    const struct cpu_policy *cp = v->domain->arch.cpu_policy;
     u32 bitmap = vmcb_get_exception_intercepts(vmcb);
 
     if ( opt_hvm_fep ||
diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c
index 30007a999e..c5fbb6b05a 100644
--- a/xen/arch/x86/hvm/vlapic.c
+++ b/xen/arch/x86/hvm/vlapic.c
@@ -1083,7 +1083,7 @@ static void set_x2apic_id(struct vlapic *vlapic)
 
 int guest_wrmsr_apic_base(struct vcpu *v, uint64_t value)
 {
-    const struct cpuid_policy *cp = v->domain->arch.cpuid;
+    const struct cpu_policy *cp = v->domain->arch.cpu_policy;
     struct vlapic *vlapic = vcpu_vlapic(v);
 
     if ( !has_vlapic(v->domain) )
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 7adb3a94a4..b919b728c8 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -557,7 +557,7 @@ void vmx_update_exception_bitmap(struct vcpu *v)
 
 static void vmx_cpuid_policy_changed(struct vcpu *v)
 {
-    const struct cpuid_policy *cp = v->domain->arch.cpuid;
+    const struct cpu_policy *cp = v->domain->arch.cpu_policy;
     int rc = 0;
 
     if ( opt_hvm_fep ||
@@ -3258,7 +3258,7 @@ void vmx_vlapic_msr_changed(struct vcpu *v)
 static int vmx_msr_write_intercept(unsigned int msr, uint64_t msr_content)
 {
     struct vcpu *v = current;
-    const struct cpuid_policy *cp = v->domain->arch.cpuid;
+    const struct cpu_policy *cp = v->domain->arch.cpu_policy;
 
     HVM_DBG_LOG(DBG_LEVEL_MSR, "ecx=%#x, msr_value=%#"PRIx64, msr, msr_content);
 
diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index 40a7a93b24..ded8897a14 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -51,8 +51,7 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val)
 {
     const struct vcpu *curr = current;
     const struct domain *d = v->domain;
-    const struct cpuid_policy *cp = d->arch.cpuid;
-    const struct msr_policy *mp = d->arch.msr;
+    const struct cpu_policy *cp = d->arch.cpu_policy;
     const struct vcpu_msrs *msrs = v->arch.msrs;
     int ret = X86EMUL_OKAY;
 
@@ -124,13 +123,13 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val)
         goto get_reg;
 
     case MSR_INTEL_PLATFORM_INFO:
-        *val = mp->platform_info.raw;
+        *val = cp->platform_info.raw;
         break;
 
     case MSR_ARCH_CAPABILITIES:
         if ( !cp->feat.arch_caps )
             goto gp_fault;
-        *val = mp->arch_caps.raw;
+        *val = cp->arch_caps.raw;
         break;
 
     case MSR_INTEL_MISC_FEATURES_ENABLES:
@@ -248,7 +247,7 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val)
  * separate CPUID features for this functionality, but only set will be
  * active.
  */
-uint64_t msr_spec_ctrl_valid_bits(const struct cpuid_policy *cp)
+uint64_t msr_spec_ctrl_valid_bits(const struct cpu_policy *cp)
 {
     bool ssbd = cp->feat.ssbd || cp->extd.amd_ssbd;
     bool psfd = cp->feat.intel_psfd || cp->extd.psfd;
@@ -267,8 +266,7 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)
 {
     const struct vcpu *curr = current;
     struct domain *d = v->domain;
-    const struct cpuid_policy *cp = d->arch.cpuid;
-    const struct msr_policy *mp = d->arch.msr;
+    const struct cpu_policy *cp = d->arch.cpu_policy;
     struct vcpu_msrs *msrs = v->arch.msrs;
     int ret = X86EMUL_OKAY;
 
@@ -318,7 +316,7 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)
          * for backwards compatiblity, the OS should write 0 to it before
          * trying to access the current microcode version.
          */
-        if ( d->arch.cpuid->x86_vendor != X86_VENDOR_INTEL || val != 0 )
+        if ( cp->x86_vendor != X86_VENDOR_INTEL || val != 0 )
             goto gp_fault;
         break;
 
@@ -328,7 +326,7 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)
          * to AMD CPUs as well (at least the architectural/CPUID part does).
          */
         if ( is_pv_domain(d) ||
-             d->arch.cpuid->x86_vendor != X86_VENDOR_AMD )
+             cp->x86_vendor != X86_VENDOR_AMD )
             goto gp_fault;
         break;
 
@@ -340,7 +338,7 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)
          * by any CPUID bit.
          */
         if ( is_pv_domain(d) ||
-             d->arch.cpuid->x86_vendor != X86_VENDOR_INTEL )
+             cp->x86_vendor != X86_VENDOR_INTEL )
             goto gp_fault;
         break;
 
@@ -377,7 +375,7 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)
         bool old_cpuid_faulting = msrs->misc_features_enables.cpuid_faulting;
 
         rsvd = ~0ull;
-        if ( mp->platform_info.cpuid_faulting )
+        if ( cp->platform_info.cpuid_faulting )
             rsvd &= ~MSR_MISC_FEATURES_CPUID_FAULTING;
 
         if ( val & rsvd )
diff --git a/xen/arch/x86/pv/domain.c b/xen/arch/x86/pv/domain.c
index f6cc6c606b..aafd7ea6f2 100644
--- a/xen/arch/x86/pv/domain.c
+++ b/xen/arch/x86/pv/domain.c
@@ -152,7 +152,7 @@ static void release_compat_l4(struct vcpu *v)
 
 unsigned long pv_fixup_guest_cr4(const struct vcpu *v, unsigned long cr4)
 {
-    const struct cpuid_policy *p = v->domain->arch.cpuid;
+    const struct cpu_policy *p = v->domain->arch.cpu_policy;
 
     /* Discard attempts to set guest controllable bits outside of the policy. */
     cr4 &= ~((p->basic.tsc     ? 0 : X86_CR4_TSD)      |
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index de372853d1..0cc950e0d3 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -962,7 +962,7 @@ void cpuid_hypervisor_leaves(const struct vcpu *v, uint32_t leaf,
                              uint32_t subleaf, struct cpuid_leaf *res)
 {
     const struct domain *d = v->domain;
-    const struct cpuid_policy *p = d->arch.cpuid;
+    const struct cpu_policy *p = d->arch.cpu_policy;
     uint32_t base = is_viridian_domain(d) ? 0x40000100 : 0x40000000;
     uint32_t idx  = leaf - base;
     unsigned int limit = is_viridian_domain(d) ? p->hv2_limit : p->hv_limit;
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index c0f91dd4b3..8b7faab8b2 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -1922,7 +1922,7 @@ in_protmode(
 }
 
 static bool
-_amd_like(const struct cpuid_policy *cp)
+_amd_like(const struct cpu_policy *cp)
 {
     return cp->x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON);
 }
@@ -1930,7 +1930,7 @@ _amd_like(const struct cpuid_policy *cp)
 static bool
 amd_like(const struct x86_emulate_ctxt *ctxt)
 {
-    return _amd_like(ctxt->cpuid);
+    return _amd_like(ctxt->cpu_policy);
 }
 
 #define vcpu_has_fpu()         (ctxt->cpuid->basic.fpu)
@@ -2074,7 +2074,7 @@ protmode_load_seg(
     struct x86_emulate_ctxt *ctxt,
     const struct x86_emulate_ops *ops)
 {
-    const struct cpuid_policy *cp = ctxt->cpuid;
+    const struct cpu_policy *cp = ctxt->cpu_policy;
     enum x86_segment sel_seg = (sel & 4) ? x86_seg_ldtr : x86_seg_gdtr;
     struct { uint32_t a, b; } desc, desc_hi = {};
     uint8_t dpl, rpl;
diff --git a/xen/include/asm-x86/msr.h b/xen/include/asm-x86/msr.h
index b509a5e564..1f4917c4f6 100644
--- a/xen/include/asm-x86/msr.h
+++ b/xen/include/asm-x86/msr.h
@@ -268,7 +268,7 @@ static inline void wrmsr_tsc_aux(uint32_t val)
     }
 }
 
-uint64_t msr_spec_ctrl_valid_bits(const struct cpuid_policy *cp);
+uint64_t msr_spec_ctrl_valid_bits(const struct cpu_policy *cp);
 
 /* Container object for per-vCPU MSRs */
 struct vcpu_msrs
diff --git a/xen/include/xen/lib/x86/cpu-policy.h b/xen/include/xen/lib/x86/cpu-policy.h
index cf7de0f29c..bfa4250604 100644
--- a/xen/include/xen/lib/x86/cpu-policy.h
+++ b/xen/include/xen/lib/x86/cpu-policy.h
@@ -375,10 +375,6 @@ struct cpu_policy
     uint8_t x86_vendor;
 };
 
-/* Temporary */
-#define cpuid_policy cpu_policy
-#define msr_policy cpu_policy
-
 struct cpu_policy_errors
 {
     uint32_t leaf, subleaf;
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:02:48 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:02:48 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680916.1059242 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGme-0007He-83; Wed, 14 Feb 2024 15:02:48 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680916.1059242; Wed, 14 Feb 2024 15:02:48 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGme-0007HX-5O; Wed, 14 Feb 2024 15:02:48 +0000
Received: by outflank-mailman (input) for mailman id 680916;
 Wed, 14 Feb 2024 15:02:46 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGmc-0007Gv-Rk
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:46 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGmc-0005nV-R2
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:46 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGmc-0000fr-QL
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:46 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=SjmBKZNSQgnKwEe84564asmuGkuB+x23EMpsGzGDVwY=; b=hgcBC09YOPwtYRZTJx6QfoUY6E
	JNehBMTO7iaRUaPqjddMUlJki3tUQoCn07TdM/7x3+RNAJLV2fFeMXMva0nZTGfmM1U9zRHyJPD/9
	7A+nfOzoidjwtMTCZUe5HyVQpxUPBFm8ku8rc1mO0an9yL9Nq1NJsqdkyDGxR5bCelI4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/boot: Rework dom0 feature configuration
Message-Id: <E1raGmc-0000fr-QL@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:02:46 +0000

commit 5d624f0fb7fefb99c4bbcc8154ffbf55a9c2465c
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri May 12 13:52:39 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/boot: Rework dom0 feature configuration
    
    Right now, dom0's feature configuration is split between between the common
    path and a dom0-specific one.  This mostly is by accident, and causes some
    very subtle bugs.
    
    First, start by clearly defining init_dom0_cpuid_policy() to be the domain
    that Xen builds automatically.  The late hwdom case is still constructed in a
    mostly normal way, with the control domain having full discretion over the CPU
    policy.
    
    Identifying this highlights a latent bug - the two halves of the MSR_ARCH_CAPS
    bodge are asymmetric with respect to the hardware domain.  This means that
    shim, or a control-only dom0 sees the MSR_ARCH_CAPS CPUID bit but none of the
    MSR content.  This in turn declares the hardware to be retpoline-safe by
    failing to advertise the {R,}RSBA bits appropriately.  Restrict this logic to
    the hardware domain, although the special case will cease to exist shortly.
    
    For the CPUID Faulting adjustment, the comment in ctxt_switch_levelling()
    isn't actually relevant.  Provide a better explanation.
    
    Move the recalculate_cpuid_policy() call outside of the dom0-cpuid= case.
    This is no change for now, but will become necessary shortly.
    
    Finally, place the second half of the MSR_ARCH_CAPS bodge after the
    recalculate_cpuid_policy() call.  This is necessary to avoid transiently
    breaking the hardware domain's view while the handling is cleaned up.  This
    special case will cease to exist shortly.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit ef1987fcb0fdfaa7ee148024037cb5fa335a7b2d)
---
 xen/arch/x86/cpu-policy.c | 57 ++++++++++++++++++++++++++---------------------
 1 file changed, 31 insertions(+), 26 deletions(-)

diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
index 59ea49ac1b..45ba238227 100644
--- a/xen/arch/x86/cpu-policy.c
+++ b/xen/arch/x86/cpu-policy.c
@@ -651,29 +651,6 @@ int init_domain_cpu_policy(struct domain *d)
     if ( !p )
         return -ENOMEM;
 
-    /* See comment in ctxt_switch_levelling() */
-    if ( !opt_dom0_cpuid_faulting && is_control_domain(d) && is_pv_domain(d) )
-        p->platform_info.cpuid_faulting = false;
-
-    /*
-     * Expose the "hardware speculation behaviour" bits of ARCH_CAPS to dom0,
-     * so dom0 can turn off workarounds as appropriate.  Temporary, until the
-     * domain policy logic gains a better understanding of MSRs.
-     */
-    if ( is_hardware_domain(d) && cpu_has_arch_caps )
-    {
-        uint64_t val;
-
-        rdmsrl(MSR_ARCH_CAPABILITIES, val);
-
-        p->arch_caps.raw = val &
-            (ARCH_CAPS_RDCL_NO | ARCH_CAPS_IBRS_ALL | ARCH_CAPS_RSBA |
-             ARCH_CAPS_SSB_NO | ARCH_CAPS_MDS_NO | ARCH_CAPS_IF_PSCHANGE_MC_NO |
-             ARCH_CAPS_TAA_NO | ARCH_CAPS_SBDR_SSDP_NO | ARCH_CAPS_FBSDP_NO |
-             ARCH_CAPS_PSDP_NO | ARCH_CAPS_FB_CLEAR | ARCH_CAPS_RRSBA |
-             ARCH_CAPS_BHI_NO | ARCH_CAPS_PBRSB_NO);
-    }
-
     d->arch.cpu_policy = p;
 
     recalculate_cpuid_policy(d);
@@ -817,11 +794,15 @@ void recalculate_cpuid_policy(struct domain *d)
         p->extd.raw[0x19] = EMPTY_LEAF;
 }
 
+/*
+ * Adjust the CPU policy for dom0.  Really, this is "the domain Xen builds
+ * automatically on boot", and might not have the domid 0 (e.g. pvshim).
+ */
 void __init init_dom0_cpuid_policy(struct domain *d)
 {
     struct cpu_policy *p = d->arch.cpuid;
 
-    /* dom0 can't migrate.  Give it ITSC if available. */
+    /* Dom0 doesn't migrate relative to Xen.  Give it ITSC if available. */
     if ( cpu_has_itsc )
         p->extd.itsc = true;
 
@@ -830,7 +811,7 @@ void __init init_dom0_cpuid_policy(struct domain *d)
      * so dom0 can turn off workarounds as appropriate.  Temporary, until the
      * domain policy logic gains a better understanding of MSRs.
      */
-    if ( cpu_has_arch_caps )
+    if ( is_hardware_domain(d) && cpu_has_arch_caps )
         p->feat.arch_caps = true;
 
     /* Apply dom0-cpuid= command line settings, if provided. */
@@ -848,8 +829,32 @@ void __init init_dom0_cpuid_policy(struct domain *d)
         }
 
         x86_cpu_featureset_to_policy(fs, p);
+    }
+
+    /*
+     * PV Control domains used to require unfiltered CPUID.  This was fixed in
+     * Xen 4.13, but there is an cmdline knob to restore the prior behaviour.
+     *
+     * If the domain is getting unfiltered CPUID, don't let the guest kernel
+     * play with CPUID faulting either, as Xen's CPUID path won't cope.
+     */
+    if ( !opt_dom0_cpuid_faulting && is_control_domain(d) && is_pv_domain(d) )
+        p->platform_info.cpuid_faulting = false;
 
-        recalculate_cpuid_policy(d);
+    recalculate_cpuid_policy(d);
+
+    if ( is_hardware_domain(d) && cpu_has_arch_caps )
+    {
+        uint64_t val;
+
+        rdmsrl(MSR_ARCH_CAPABILITIES, val);
+
+        p->arch_caps.raw = val &
+            (ARCH_CAPS_RDCL_NO | ARCH_CAPS_IBRS_ALL | ARCH_CAPS_RSBA |
+             ARCH_CAPS_SSB_NO | ARCH_CAPS_MDS_NO | ARCH_CAPS_IF_PSCHANGE_MC_NO |
+             ARCH_CAPS_TAA_NO | ARCH_CAPS_SBDR_SSDP_NO | ARCH_CAPS_FBSDP_NO |
+             ARCH_CAPS_PSDP_NO | ARCH_CAPS_FB_CLEAR | ARCH_CAPS_RRSBA |
+             ARCH_CAPS_BHI_NO | ARCH_CAPS_PBRSB_NO);
     }
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:02:58 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:02:58 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680918.1059249 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGmo-0007PK-Ai; Wed, 14 Feb 2024 15:02:58 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680918.1059249; Wed, 14 Feb 2024 15:02:58 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGmo-0007P1-6u; Wed, 14 Feb 2024 15:02:58 +0000
Received: by outflank-mailman (input) for mailman id 680918;
 Wed, 14 Feb 2024 15:02:56 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGmm-0007NR-Uc
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:56 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGmm-0005ng-Ty
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:56 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGmm-0000gG-TF
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:02:56 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=KbvH2QeRK6AdG2P/r/d3Jg0h4/PvM+mrABbKjtVo6TU=; b=hNDI7hZ7ql3zMHd9HW6PuqKett
	eijbMjxRwjKRjFSV78aGO6z1lTlyXE0YjfN2RSmLMPevFJK+dbyj37v5hpauO/mlJc6mppj/lRSSq
	2FwkV/9TtQMaODTAnjR8rR+5ihG9MAJXdpBnS6asJS+RPQsgGzzY3C2QEP8dQrcr49lY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/boot: Adjust MSR_ARCH_CAPS handling for the Host policy
Message-Id: <E1raGmm-0000gG-TF@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:02:56 +0000

commit 775b544ebe83a06d9120f119b38b00a56dcc2a86
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon May 15 14:14:53 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/boot: Adjust MSR_ARCH_CAPS handling for the Host policy
    
    We are about to move MSR_ARCH_CAPS into featureset, but the order of
    operations (copy raw policy, then copy x86_capabilitiles[] in) will end up
    clobbering the ARCH_CAPS value.
    
    Some toolstacks use this information to handle TSX compatibility across the
    CPUs and microcode versions where support was removed.
    
    To avoid this transient breakage, read from raw_cpu_policy rather than
    modifying it in place.  This logic will be removed entirely in due course.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 43912f8dbb1888ffd7f00adb10724c70e71927c4)
---
 xen/arch/x86/cpu-policy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
index 45ba238227..261d1daf0e 100644
--- a/xen/arch/x86/cpu-policy.c
+++ b/xen/arch/x86/cpu-policy.c
@@ -411,7 +411,7 @@ static void __init calculate_host_policy(void)
     p->platform_info.cpuid_faulting = cpu_has_cpuid_faulting;
 
     /* Temporary, until we have known_features[] for feature bits in MSRs. */
-    p->arch_caps.raw &=
+    p->arch_caps.raw = raw_cpu_policy.arch_caps.raw &
         (ARCH_CAPS_RDCL_NO | ARCH_CAPS_IBRS_ALL | ARCH_CAPS_RSBA |
          ARCH_CAPS_SKIP_L1DFL | ARCH_CAPS_SSB_NO | ARCH_CAPS_MDS_NO |
          ARCH_CAPS_IF_PSCHANGE_MC_NO | ARCH_CAPS_TSX_CTRL | ARCH_CAPS_TAA_NO |
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:03:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:03:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680920.1059250 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGmy-0007VA-B3; Wed, 14 Feb 2024 15:03:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680920.1059250; Wed, 14 Feb 2024 15:03:08 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGmy-0007V2-8Q; Wed, 14 Feb 2024 15:03:08 +0000
Received: by outflank-mailman (input) for mailman id 680920;
 Wed, 14 Feb 2024 15:03:07 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGmx-0007Uh-1U
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:07 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGmx-0005o6-0j
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:07 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGmx-0000go-01
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:07 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=BrgjH0BPGWapxCKc4Were7VOzt2+atOyhNupKHW7EK4=; b=kWH5QFH71hwKsCkiMBqowkXAce
	UzmeXGQ5xr8HY2ZQCBf7UkYPqeKhJXFa0+JVgnEhyCBqavvYhURlAgn+jRHIrFljtc9NULOU3PE2N
	h0aD+xO6nm/fLYPEJXwM2qCuu5QHFsEJksDgP5AzRBTTsgPW4u3U0/ygwRdM3AeB/rp0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/cpu-policy: Infrastructure for MSR_ARCH_CAPS
Message-Id: <E1raGmx-0000go-01@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:03:07 +0000

commit eed3654beed98fd1f7b8adab86c8d60e56d273ad
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri May 12 17:55:21 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/cpu-policy: Infrastructure for MSR_ARCH_CAPS
    
    Bits through 24 are already defined, meaning that we're not far off needing
    the second word.  Put both in right away.
    
    As both halves are present now, the arch_caps field is full width.  Adjust the
    unit test, which notices.
    
    The bool bitfield names in the arch_caps union are unused, and somewhat out of
    date.  They'll shortly be automatically generated.
    
    Add CPUID and MSR prefixes to the ./xen-cpuid verbose output, now that there
    are a mix of the two.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit d9fe459ffad8a6eac2f695adb2331aff83c345d1)
---
 tools/misc/xen-cpuid.c                      | 44 +++++++++++++++----------
 tools/tests/cpu-policy/test-cpu-policy.c    |  5 ---
 xen/include/public/arch-x86/cpufeatureset.h |  4 +++
 xen/include/xen/lib/x86/cpu-policy.h        | 50 ++++++++++++++---------------
 xen/lib/x86/cpuid.c                         |  4 +++
 5 files changed, 59 insertions(+), 48 deletions(-)

diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
index 1e6baf98f6..ae8c0b2d14 100644
--- a/tools/misc/xen-cpuid.c
+++ b/tools/misc/xen-cpuid.c
@@ -206,31 +206,41 @@ static const char *const str_7d2[32] =
     [ 0] = "intel-psfd",
 };
 
+static const char *const str_m10Al[32] =
+{
+};
+
+static const char *const str_m10Ah[32] =
+{
+};
+
 static const struct {
     const char *name;
     const char *abbr;
     const char *const *strs;
 } decodes[] =
 {
-    { "0x00000001.edx",   "1d",  str_1d },
-    { "0x00000001.ecx",   "1c",  str_1c },
-    { "0x80000001.edx",   "e1d", str_e1d },
-    { "0x80000001.ecx",   "e1c", str_e1c },
-    { "0x0000000d:1.eax", "Da1", str_Da1 },
-    { "0x00000007:0.ebx", "7b0", str_7b0 },
-    { "0x00000007:0.ecx", "7c0", str_7c0 },
-    { "0x80000007.edx",   "e7d", str_e7d },
-    { "0x80000008.ebx",   "e8b", str_e8b },
-    { "0x00000007:0.edx", "7d0", str_7d0 },
-    { "0x00000007:1.eax", "7a1", str_7a1 },
-    { "0x80000021.eax",  "e21a", str_e21a },
-    { "0x00000007:1.ebx", "7b1", str_7b1 },
-    { "0x00000007:2.edx", "7d2", str_7d2 },
-    { "0x00000007:1.ecx", "7c1", str_7c1 },
-    { "0x00000007:1.edx", "7d1", str_7d1 },
+    { "CPUID 0x00000001.edx",        "1d", str_1d },
+    { "CPUID 0x00000001.ecx",        "1c", str_1c },
+    { "CPUID 0x80000001.edx",       "e1d", str_e1d },
+    { "CPUID 0x80000001.ecx",       "e1c", str_e1c },
+    { "CPUID 0x0000000d:1.eax",     "Da1", str_Da1 },
+    { "CPUID 0x00000007:0.ebx",     "7b0", str_7b0 },
+    { "CPUID 0x00000007:0.ecx",     "7c0", str_7c0 },
+    { "CPUID 0x80000007.edx",       "e7d", str_e7d },
+    { "CPUID 0x80000008.ebx",       "e8b", str_e8b },
+    { "CPUID 0x00000007:0.edx",     "7d0", str_7d0 },
+    { "CPUID 0x00000007:1.eax",     "7a1", str_7a1 },
+    { "CPUID 0x80000021.eax",      "e21a", str_e21a },
+    { "CPUID 0x00000007:1.ebx",     "7b1", str_7b1 },
+    { "CPUID 0x00000007:2.edx",     "7d2", str_7d2 },
+    { "CPUID 0x00000007:1.ecx",     "7c1", str_7c1 },
+    { "CPUID 0x00000007:1.edx",     "7d1", str_7d1 },
+    { "MSR_ARCH_CAPS.lo",         "m10Al", str_m10Al },
+    { "MSR_ARCH_CAPS.hi",         "m10Ah", str_m10Ah },
 };
 
-#define COL_ALIGN "18"
+#define COL_ALIGN "24"
 
 static const char *const fs_names[] = {
     [XEN_SYSCTL_cpu_featureset_raw]     = "Raw",
diff --git a/tools/tests/cpu-policy/test-cpu-policy.c b/tools/tests/cpu-policy/test-cpu-policy.c
index 88d35c6c8e..093b980801 100644
--- a/tools/tests/cpu-policy/test-cpu-policy.c
+++ b/tools/tests/cpu-policy/test-cpu-policy.c
@@ -374,11 +374,6 @@ static void test_msr_deserialise_failure(void)
             .msr = { .idx = 0xce, .val = ~0ull },
             .rc = -EOVERFLOW,
         },
-        {
-            .name = "truncated val",
-            .msr = { .idx = 0x10a, .val = ~0ull },
-            .rc = -EOVERFLOW,
-        },
     };
 
     printf("Testing MSR deserialise failure:\n");
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index b09d5bd907..cae12e23de 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -299,6 +299,10 @@ XEN_CPUFEATURE(INTEL_PSFD,         13*32+ 0) /*A  MSR_SPEC_CTRL.PSFD */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:1.edx, word 15 */
 
+/* Intel-defined CPU features, MSR_ARCH_CAPS 0x10a.eax, word 16 */
+
+/* Intel-defined CPU features, MSR_ARCH_CAPS 0x10a.edx, word 17 */
+
 #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 bfa4250604..6d5e9edd26 100644
--- a/xen/include/xen/lib/x86/cpu-policy.h
+++ b/xen/include/xen/lib/x86/cpu-policy.h
@@ -4,22 +4,24 @@
 
 #include <xen/lib/x86/cpuid-autogen.h>
 
-#define FEATURESET_1d     0 /* 0x00000001.edx      */
-#define FEATURESET_1c     1 /* 0x00000001.ecx      */
-#define FEATURESET_e1d    2 /* 0x80000001.edx      */
-#define FEATURESET_e1c    3 /* 0x80000001.ecx      */
-#define FEATURESET_Da1    4 /* 0x0000000d:1.eax    */
-#define FEATURESET_7b0    5 /* 0x00000007:0.ebx    */
-#define FEATURESET_7c0    6 /* 0x00000007:0.ecx    */
-#define FEATURESET_e7d    7 /* 0x80000007.edx      */
-#define FEATURESET_e8b    8 /* 0x80000008.ebx      */
-#define FEATURESET_7d0    9 /* 0x00000007:0.edx    */
-#define FEATURESET_7a1   10 /* 0x00000007:1.eax    */
-#define FEATURESET_e21a  11 /* 0x80000021.eax      */
-#define FEATURESET_7b1   12 /* 0x00000007:1.ebx    */
-#define FEATURESET_7d2   13 /* 0x00000007:2.edx    */
-#define FEATURESET_7c1   14 /* 0x00000007:1.ecx    */
-#define FEATURESET_7d1   15 /* 0x00000007:1.edx    */
+#define FEATURESET_1d         0 /* 0x00000001.edx      */
+#define FEATURESET_1c         1 /* 0x00000001.ecx      */
+#define FEATURESET_e1d        2 /* 0x80000001.edx      */
+#define FEATURESET_e1c        3 /* 0x80000001.ecx      */
+#define FEATURESET_Da1        4 /* 0x0000000d:1.eax    */
+#define FEATURESET_7b0        5 /* 0x00000007:0.ebx    */
+#define FEATURESET_7c0        6 /* 0x00000007:0.ecx    */
+#define FEATURESET_e7d        7 /* 0x80000007.edx      */
+#define FEATURESET_e8b        8 /* 0x80000008.ebx      */
+#define FEATURESET_7d0        9 /* 0x00000007:0.edx    */
+#define FEATURESET_7a1       10 /* 0x00000007:1.eax    */
+#define FEATURESET_e21a      11 /* 0x80000021.eax      */
+#define FEATURESET_7b1       12 /* 0x00000007:1.ebx    */
+#define FEATURESET_7d2       13 /* 0x00000007:2.edx    */
+#define FEATURESET_7c1       14 /* 0x00000007:1.ecx    */
+#define FEATURESET_7d1       15 /* 0x00000007:1.edx    */
+#define FEATURESET_m10Al     16 /* 0x0000010a.eax      */
+#define FEATURESET_m10Ah     17 /* 0x0000010a.edx      */
 
 struct cpuid_leaf
 {
@@ -350,17 +352,13 @@ struct cpu_policy
      * fixed in hardware.
      */
     union {
-        uint32_t raw;
+        uint64_t raw;
+        struct {
+            uint32_t lo, hi;
+        };
         struct {
-            bool rdcl_no:1;
-            bool ibrs_all:1;
-            bool rsba:1;
-            bool skip_l1dfl:1;
-            bool ssb_no:1;
-            bool mds_no:1;
-            bool if_pschange_mc_no:1;
-            bool tsx_ctrl:1;
-            bool taa_no:1;
+            DECL_BITFIELD(m10Al);
+            DECL_BITFIELD(m10Ah);
         };
     } arch_caps;
 
diff --git a/xen/lib/x86/cpuid.c b/xen/lib/x86/cpuid.c
index 1b83f7c576..a95588d40b 100644
--- a/xen/lib/x86/cpuid.c
+++ b/xen/lib/x86/cpuid.c
@@ -79,6 +79,8 @@ void x86_cpu_policy_to_featureset(
     fs[FEATURESET_7d2]       = p->feat._7d2;
     fs[FEATURESET_7c1]       = p->feat._7c1;
     fs[FEATURESET_7d1]       = p->feat._7d1;
+    fs[FEATURESET_m10Al]     = p->arch_caps.lo;
+    fs[FEATURESET_m10Ah]     = p->arch_caps.hi;
 }
 
 void x86_cpu_featureset_to_policy(
@@ -100,6 +102,8 @@ void x86_cpu_featureset_to_policy(
     p->feat._7d2             = fs[FEATURESET_7d2];
     p->feat._7c1             = fs[FEATURESET_7c1];
     p->feat._7d1             = fs[FEATURESET_7d1];
+    p->arch_caps.lo          = fs[FEATURESET_m10Al];
+    p->arch_caps.hi          = fs[FEATURESET_m10Ah];
 }
 
 void x86_cpu_policy_recalc_synth(struct cpu_policy *p)
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:03:18 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:03:18 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680921.1059255 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGn8-0007bm-EX; Wed, 14 Feb 2024 15:03:18 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680921.1059255; Wed, 14 Feb 2024 15:03:18 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGn8-0007bg-BS; Wed, 14 Feb 2024 15:03:18 +0000
Received: by outflank-mailman (input) for mailman id 680921;
 Wed, 14 Feb 2024 15:03:17 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGn7-0007bS-4b
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:17 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGn7-0005oG-3u
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:17 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGn7-0000hV-3J
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:17 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=UlcO31DoKEnBDBJE7pmpTFDiYuksV69TpNmB5bbA/80=; b=rrHDqDrzT+upUNUqTckWto7mBK
	g1XATQi1+7c0rn+/COUlE6Pygv8+s8EP5+7Z92/yGMKRUp8PGxTyzkMABaCYBKb9SO3bai+3WoDv8
	2+DnOWENdiqOwypG8lS5XoOGgFbFR4xiNqMEEse4K3r4qa8uZfOP1A5Qw8MM9FOXWJhM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/cpu-policy: MSR_ARCH_CAPS feature names
Message-Id: <E1raGn7-0000hV-3J@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:03:17 +0000

commit 1ba3e81d73bfaba2a1f6539aa7418eda2c9f52d1
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri May 12 18:50:59 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/cpu-policy: MSR_ARCH_CAPS feature names
    
    Seed the default visibility from the dom0 special case, which for the most
    part just exposes the *_NO bits.  EIBRS is the one non-*_NO bit, which is
    "just" a status bit to the guest indicating a change in implemention of IBRS
    which is already fully supported.
    
    Insert a block dependency from the ARCH_CAPS CPUID bit to the entire content
    of the MSR.  This is because MSRs have no structure information similar to
    CPUID, and used by x86_cpu_policy_clear_out_of_range_leaves(), in order to
    bulk-clear inaccessable words.
    
    The overall CPUID bit is still max-only, so all of MSR_ARCH_CAPS is hidden in
    the default policies.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit ce8c930851a5ca21c4e70f83be7e8b290ce1b519)
---
 tools/misc/xen-cpuid.c                      | 13 +++++++++++++
 xen/include/public/arch-x86/cpufeatureset.h | 23 +++++++++++++++++++++++
 xen/tools/gen-cpuid.py                      |  3 +++
 3 files changed, 39 insertions(+)

diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
index ae8c0b2d14..ceb8a29c75 100644
--- a/tools/misc/xen-cpuid.c
+++ b/tools/misc/xen-cpuid.c
@@ -208,6 +208,19 @@ static const char *const str_7d2[32] =
 
 static const char *const str_m10Al[32] =
 {
+    [ 0] = "rdcl-no",             [ 1] = "eibrs",
+    [ 2] = "rsba",                [ 3] = "skip-l1dfl",
+    [ 4] = "intel-ssb-no",        [ 5] = "mds-no",
+    [ 6] = "if-pschange-mc-no",   [ 7] = "tsx-ctrl",
+    [ 8] = "taa-no",              [ 9] = "mcu-ctrl",
+    [10] = "misc-pkg-ctrl",       [11] = "energy-ctrl",
+    [12] = "doitm",               [13] = "sbdr-ssdp-no",
+    [14] = "fbsdp-no",            [15] = "psdp-no",
+    /* 16 */                      [17] = "fb-clear",
+    [18] = "fb-clear-ctrl",       [19] = "rrsba",
+    [20] = "bhi-no",              [21] = "xapic-status",
+    /* 22 */                      [23] = "ovrclk-status",
+    [24] = "pbrsb-no",
 };
 
 static const char *const str_m10Ah[32] =
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index cae12e23de..e87b37ab63 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -300,6 +300,29 @@ XEN_CPUFEATURE(INTEL_PSFD,         13*32+ 0) /*A  MSR_SPEC_CTRL.PSFD */
 /* Intel-defined CPU features, CPUID level 0x00000007:1.edx, word 15 */
 
 /* Intel-defined CPU features, MSR_ARCH_CAPS 0x10a.eax, word 16 */
+XEN_CPUFEATURE(RDCL_NO,            16*32+ 0) /*A  No Rogue Data Cache Load (Meltdown) */
+XEN_CPUFEATURE(EIBRS,              16*32+ 1) /*A  Enhanced IBRS */
+XEN_CPUFEATURE(RSBA,               16*32+ 2) /*!A RSB Alternative (Retpoline not safe) */
+XEN_CPUFEATURE(SKIP_L1DFL,         16*32+ 3) /*   Don't need to flush L1D on VMEntry */
+XEN_CPUFEATURE(INTEL_SSB_NO,       16*32+ 4) /*A  No Speculative Store Bypass */
+XEN_CPUFEATURE(MDS_NO,             16*32+ 5) /*A  No Microarchitectural Data Sampling */
+XEN_CPUFEATURE(IF_PSCHANGE_MC_NO,  16*32+ 6) /*A  No Instruction fetch #MC */
+XEN_CPUFEATURE(TSX_CTRL,           16*32+ 7) /*   MSR_TSX_CTRL */
+XEN_CPUFEATURE(TAA_NO,             16*32+ 8) /*A  No TSX Async Abort */
+XEN_CPUFEATURE(MCU_CTRL,           16*32+ 9) /*   MSR_MCU_CTRL */
+XEN_CPUFEATURE(MISC_PKG_CTRL,      16*32+10) /*   MSR_MISC_PKG_CTRL */
+XEN_CPUFEATURE(ENERGY_FILTERING,   16*32+11) /*   MSR_MISC_PKG_CTRL.ENERGY_FILTERING */
+XEN_CPUFEATURE(DOITM,              16*32+12) /*   Data Operand Invariant Timing Mode */
+XEN_CPUFEATURE(SBDR_SSDP_NO,       16*32+13) /*A  No Shared Buffer Data Read or Sideband Stale Data Propagation */
+XEN_CPUFEATURE(FBSDP_NO,           16*32+14) /*A  No Fill Buffer Stale Data Propagation */
+XEN_CPUFEATURE(PSDP_NO,            16*32+15) /*A  No Primary Stale Data Propagation */
+XEN_CPUFEATURE(FB_CLEAR,           16*32+17) /*A  Fill Buffers cleared by VERW */
+XEN_CPUFEATURE(FB_CLEAR_CTRL,      16*32+18) /*   MSR_OPT_CPU_CTRL.FB_CLEAR_DIS */
+XEN_CPUFEATURE(RRSBA,              16*32+19) /*!A Restricted RSB Alternative */
+XEN_CPUFEATURE(BHI_NO,             16*32+20) /*A  No Branch History Injection  */
+XEN_CPUFEATURE(XAPIC_STATUS,       16*32+21) /*   MSR_XAPIC_DISABLE_STATUS */
+XEN_CPUFEATURE(OVRCLK_STATUS,      16*32+23) /*   MSR_OVERCLOCKING_STATUS */
+XEN_CPUFEATURE(PBRSB_NO,           16*32+24) /*A  No Post-Barrier RSB predictions */
 
 /* Intel-defined CPU features, MSR_ARCH_CAPS 0x10a.edx, word 17 */
 
diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py
index d813e92118..54246ad209 100755
--- a/xen/tools/gen-cpuid.py
+++ b/xen/tools/gen-cpuid.py
@@ -322,6 +322,9 @@ def crunch_numbers(state):
 
         # In principle the TSXLDTRK insns could also be considered independent.
         RTM: [TSXLDTRK],
+
+        # The ARCH_CAPS CPUID bit enumerates the availability of the whole register.
+        ARCH_CAPS: list(range(RDCL_NO, RDCL_NO + 64)),
     }
 
     deep_features = tuple(sorted(deps.keys()))
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:03:28 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:03:28 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680922.1059258 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGnI-0007gG-Fk; Wed, 14 Feb 2024 15:03:28 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680922.1059258; Wed, 14 Feb 2024 15:03:28 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGnI-0007g8-D4; Wed, 14 Feb 2024 15:03:28 +0000
Received: by outflank-mailman (input) for mailman id 680922;
 Wed, 14 Feb 2024 15:03:27 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGnH-0007fu-7V
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:27 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGnH-0005oP-6n
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:27 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGnH-0000iC-69
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:27 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=3HoDHYcAXk/4GpJ67uTt4O92/jntpVCtNr2dmiexs3k=; b=uRGOXd+Fyzl75NhASt65tA8SRZ
	7YjmRUqvuLXMpYJ6y5imA28SbOBPFSA12ev7sZSUAzYZ2qXZ/Vd/7XUZ6otoR5XptfAbve51DA37g
	n5eDtrtu85/KhBMJBrhzahgWqSlmit0CHmgO250GMPMVOvypOsbspqdVguAUHyuFz8iE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/boot: Record MSR_ARCH_CAPS for the Raw and Host CPU policy
Message-Id: <E1raGnH-0000iC-69@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:03:27 +0000

commit 12f895ef395d18022d127d775e0a2c54893731aa
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri May 12 15:37:02 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/boot: Record MSR_ARCH_CAPS for the Raw and Host CPU policy
    
    Extend x86_cpu_policy_fill_native() with a read of ARCH_CAPS based on the
    CPUID information just read, removing the specially handling in
    calculate_raw_cpu_policy().
    
    Right now, the only use of x86_cpu_policy_fill_native() outside of Xen is the
    unit tests.  Getting MSR data in this context is left to whomever first
    encounters a genuine need to have it.
    
    Extend generic_identify() to read ARCH_CAPS into x86_capability[], which is
    fed into the Host Policy.  This in turn means there's no need to special case
    arch_caps in calculate_host_policy().
    
    No practical change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 70553000d6b44dd7c271a35932b0b3e1f22c5532)
---
 xen/arch/x86/cpu-policy.c | 12 ------------
 xen/arch/x86/cpu/common.c |  5 +++++
 xen/lib/x86/cpuid.c       |  7 ++++++-
 3 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
index 261d1daf0e..900f448802 100644
--- a/xen/arch/x86/cpu-policy.c
+++ b/xen/arch/x86/cpu-policy.c
@@ -354,9 +354,6 @@ static void __init calculate_raw_policy(void)
 
     /* 0x000000ce  MSR_INTEL_PLATFORM_INFO */
     /* Was already added by probe_cpuid_faulting() */
-
-    if ( cpu_has_arch_caps )
-        rdmsrl(MSR_ARCH_CAPABILITIES, p->arch_caps.raw);
 }
 
 static void __init calculate_host_policy(void)
@@ -409,15 +406,6 @@ static void __init calculate_host_policy(void)
     /* 0x000000ce  MSR_INTEL_PLATFORM_INFO */
     /* probe_cpuid_faulting() sanity checks presence of MISC_FEATURES_ENABLES */
     p->platform_info.cpuid_faulting = cpu_has_cpuid_faulting;
-
-    /* Temporary, until we have known_features[] for feature bits in MSRs. */
-    p->arch_caps.raw = raw_cpu_policy.arch_caps.raw &
-        (ARCH_CAPS_RDCL_NO | ARCH_CAPS_IBRS_ALL | ARCH_CAPS_RSBA |
-         ARCH_CAPS_SKIP_L1DFL | ARCH_CAPS_SSB_NO | ARCH_CAPS_MDS_NO |
-         ARCH_CAPS_IF_PSCHANGE_MC_NO | ARCH_CAPS_TSX_CTRL | ARCH_CAPS_TAA_NO |
-         ARCH_CAPS_SBDR_SSDP_NO | ARCH_CAPS_FBSDP_NO | ARCH_CAPS_PSDP_NO |
-         ARCH_CAPS_FB_CLEAR | ARCH_CAPS_RRSBA | ARCH_CAPS_BHI_NO |
-         ARCH_CAPS_PBRSB_NO);
 }
 
 static void __init guest_common_default_feature_adjustments(uint32_t *fs)
diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index 29460135eb..aac3529a9a 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -449,6 +449,11 @@ static void generic_identify(struct cpuinfo_x86 *c)
 		cpuid_count(0xd, 1,
 			    &c->x86_capability[FEATURESET_Da1],
 			    &tmp, &tmp, &tmp);
+
+	if (test_bit(X86_FEATURE_ARCH_CAPS, c->x86_capability))
+		rdmsr(MSR_ARCH_CAPABILITIES,
+		      c->x86_capability[FEATURESET_m10Al],
+		      c->x86_capability[FEATURESET_m10Ah]);
 }
 
 /*
diff --git a/xen/lib/x86/cpuid.c b/xen/lib/x86/cpuid.c
index a95588d40b..baf692cb0a 100644
--- a/xen/lib/x86/cpuid.c
+++ b/xen/lib/x86/cpuid.c
@@ -226,7 +226,12 @@ void x86_cpu_policy_fill_native(struct cpu_policy *p)
     p->hv_limit = 0;
     p->hv2_limit = 0;
 
-    /* TODO MSRs */
+#ifdef __XEN__
+    /* TODO MSR_PLATFORM_INFO */
+
+    if ( p->feat.arch_caps )
+        rdmsrl(MSR_ARCH_CAPABILITIES, p->arch_caps.raw);
+#endif
 
     x86_cpu_policy_recalc_synth(p);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:03:38 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:03:38 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680923.1059263 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGnS-0007lT-I1; Wed, 14 Feb 2024 15:03:38 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680923.1059263; Wed, 14 Feb 2024 15:03:38 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGnS-0007lH-ET; Wed, 14 Feb 2024 15:03:38 +0000
Received: by outflank-mailman (input) for mailman id 680923;
 Wed, 14 Feb 2024 15:03:37 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGnR-0007l7-AP
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:37 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGnR-0005oa-9l
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:37 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGnR-0000ib-97
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:37 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=C+IPk8SOMlcG/uztpRx2Hwbs+XozAVPBylPOLE7tLiY=; b=cvaegYH0m0+LBrqxceZD/FrxP0
	XMbfyyDj13T0G0SwLmMb84RFk625gn3TpW0/jMPnyW6Y8AoF3W+MOIcnkOfwP+nhp6dzWzkJ6cVJB
	LRc9ckshK96JQ+Htbka8ZZF8QEAT+QFI07BK0eHPNAdSwCaSc5jYLDUJ3YSZio+XqDsI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/boot: Expose MSR_ARCH_CAPS data in guest max policies
Message-Id: <E1raGnR-0000ib-97@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:03:37 +0000

commit 834fd82b8e6113b94e3de5fff6d4cc873a75d07e
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri May 12 15:53:35 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/boot: Expose MSR_ARCH_CAPS data in guest max policies
    
    We already have common and default feature adjustment helpers.  Introduce one
    for max featuresets too.
    
    Offer MSR_ARCH_CAPS unconditionally in the max policy, and stop clobbering the
    data inherited from the Host policy.  This will be necessary to level a VM
    safely for migration.  Annotate the ARCH_CAPS CPUID bit as special.  Note:
    ARCH_CAPS is still max-only for now, so will not be inhereted by the default
    policies.
    
    With this done, the special case for dom0 can be shrunk to just resampling the
    Host policy (as ARCH_CAPS isn't visible by default yet).
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit bbb289f3d5bdd3358af748d7c567343532ac45b5)
---
 xen/arch/x86/cpu-policy.c                   | 42 ++++++++++++++++-------------
 xen/include/public/arch-x86/cpufeatureset.h |  2 +-
 2 files changed, 25 insertions(+), 19 deletions(-)

diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
index 900f448802..99cae5b145 100644
--- a/xen/arch/x86/cpu-policy.c
+++ b/xen/arch/x86/cpu-policy.c
@@ -408,6 +408,25 @@ static void __init calculate_host_policy(void)
     p->platform_info.cpuid_faulting = cpu_has_cpuid_faulting;
 }
 
+static void __init guest_common_max_feature_adjustments(uint32_t *fs)
+{
+    if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL )
+    {
+        /*
+         * MSR_ARCH_CAPS is just feature data, and we can offer it to guests
+         * unconditionally, although limit it to Intel systems as it is highly
+         * uarch-specific.
+         *
+         * In particular, the RSBA and RRSBA bits mean "you might migrate to a
+         * system where RSB underflow uses alternative predictors (a.k.a
+         * Retpoline not safe)", so these need to be visible to a guest in all
+         * cases, even when it's only some other server in the pool which
+         * suffers the identified behaviour.
+         */
+        __set_bit(X86_FEATURE_ARCH_CAPS, fs);
+    }
+}
+
 static void __init guest_common_default_feature_adjustments(uint32_t *fs)
 {
     /*
@@ -483,6 +502,7 @@ static void __init calculate_pv_max_policy(void)
         __clear_bit(X86_FEATURE_IBRS, fs);
     }
 
+    guest_common_max_feature_adjustments(fs);
     guest_common_feature_adjustments(fs);
 
     sanitise_featureset(fs);
@@ -490,8 +510,6 @@ static void __init calculate_pv_max_policy(void)
     recalculate_xstate(p);
 
     p->extd.raw[0xa] = EMPTY_LEAF; /* No SVM for PV guests. */
-
-    p->arch_caps.raw = 0; /* Not supported yet. */
 }
 
 static void __init calculate_pv_def_policy(void)
@@ -569,6 +587,7 @@ static void __init calculate_hvm_max_policy(void)
             __clear_bit(X86_FEATURE_XSAVES, fs);
     }
 
+    guest_common_max_feature_adjustments(fs);
     guest_common_feature_adjustments(fs);
 
     sanitise_featureset(fs);
@@ -577,8 +596,6 @@ static void __init calculate_hvm_max_policy(void)
 
     /* It's always possible to emulate CPUID faulting for HVM guests */
     p->platform_info.cpuid_faulting = true;
-
-    p->arch_caps.raw = 0; /* Not supported yet. */
 }
 
 static void __init calculate_hvm_def_policy(void)
@@ -800,7 +817,10 @@ void __init init_dom0_cpuid_policy(struct domain *d)
      * domain policy logic gains a better understanding of MSRs.
      */
     if ( is_hardware_domain(d) && cpu_has_arch_caps )
+    {
         p->feat.arch_caps = true;
+        p->arch_caps.raw = host_cpu_policy.arch_caps.raw;
+    }
 
     /* Apply dom0-cpuid= command line settings, if provided. */
     if ( dom0_cpuid_cmdline )
@@ -830,20 +850,6 @@ void __init init_dom0_cpuid_policy(struct domain *d)
         p->platform_info.cpuid_faulting = false;
 
     recalculate_cpuid_policy(d);
-
-    if ( is_hardware_domain(d) && cpu_has_arch_caps )
-    {
-        uint64_t val;
-
-        rdmsrl(MSR_ARCH_CAPABILITIES, val);
-
-        p->arch_caps.raw = val &
-            (ARCH_CAPS_RDCL_NO | ARCH_CAPS_IBRS_ALL | ARCH_CAPS_RSBA |
-             ARCH_CAPS_SSB_NO | ARCH_CAPS_MDS_NO | ARCH_CAPS_IF_PSCHANGE_MC_NO |
-             ARCH_CAPS_TAA_NO | ARCH_CAPS_SBDR_SSDP_NO | ARCH_CAPS_FBSDP_NO |
-             ARCH_CAPS_PSDP_NO | ARCH_CAPS_FB_CLEAR | ARCH_CAPS_RRSBA |
-             ARCH_CAPS_BHI_NO | ARCH_CAPS_PBRSB_NO);
-    }
 }
 
 static void __init __maybe_unused build_assertions(void)
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index e87b37ab63..cd3fcee813 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -280,7 +280,7 @@ XEN_CPUFEATURE(CET_IBT,       9*32+20) /*   CET - Indirect Branch Tracking */
 XEN_CPUFEATURE(IBRSB,         9*32+26) /*A  IBRS and IBPB support (used by Intel) */
 XEN_CPUFEATURE(STIBP,         9*32+27) /*A  STIBP */
 XEN_CPUFEATURE(L1D_FLUSH,     9*32+28) /*S  MSR_FLUSH_CMD and L1D flush. */
-XEN_CPUFEATURE(ARCH_CAPS,     9*32+29) /*a  IA32_ARCH_CAPABILITIES MSR */
+XEN_CPUFEATURE(ARCH_CAPS,     9*32+29) /*!a IA32_ARCH_CAPABILITIES MSR */
 XEN_CPUFEATURE(CORE_CAPS,     9*32+30) /*   IA32_CORE_CAPABILITIES MSR */
 XEN_CPUFEATURE(SSBD,          9*32+31) /*A  MSR_SPEC_CTRL.SSBD available */
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:03:48 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:03:48 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680924.1059267 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGnc-0007nw-Ip; Wed, 14 Feb 2024 15:03:48 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680924.1059267; Wed, 14 Feb 2024 15:03:48 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGnc-0007np-G3; Wed, 14 Feb 2024 15:03:48 +0000
Received: by outflank-mailman (input) for mailman id 680924;
 Wed, 14 Feb 2024 15:03:47 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGnb-0007nb-Db
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:47 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGnb-0005p1-Cv
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:47 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGnb-0000j0-CG
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:47 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=vel3EEgkxtx6n4ejcEjSSoCXYtadD/sNcV/hEvP3v5Y=; b=f0PckiOnMnzr2LABTp6ZBk3g1V
	S1/dFvcHr9f9C71oSb2Y7DRmiBtKZzDSONySmatR/EaVIWFbXn/IIiUrR01wVI3di9GTXLB3F6CQy
	KPl+w/OZE9fkRnLaDCfsQZdODJ3kYjrtE8p6wJ4oWq1WhDqhX7vpORuX1k3ouzFVgusc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/vtx: Remove opencoded MSR_ARCH_CAPS check
Message-Id: <E1raGnb-0000j0-CG@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:03:47 +0000

commit 7320e9aa80f5da23abf76b41b2e93708fa1689b4
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon May 15 16:59:25 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/vtx: Remove opencoded MSR_ARCH_CAPS check
    
    MSR_ARCH_CAPS data is now included in featureset information.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 8f6bc7f9b72eb7cf0c8c5ae5d80498a58ba0b7c3)
---
 xen/arch/x86/hvm/vmx/vmx.c       | 8 ++------
 xen/include/asm-x86/cpufeature.h | 3 +++
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index b919b728c8..ed8c8f15bb 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2464,8 +2464,6 @@ static void __init ler_to_fixup_check(void);
  */
 static bool __init has_if_pschange_mc(void)
 {
-    uint64_t caps = 0;
-
     /*
      * If we are virtualised, there is nothing we can do.  Our EPT tables are
      * shadowed by our hypervisor, and not walked by hardware.
@@ -2473,10 +2471,8 @@ static bool __init has_if_pschange_mc(void)
     if ( cpu_has_hypervisor )
         return false;
 
-    if ( cpu_has_arch_caps )
-        rdmsrl(MSR_ARCH_CAPABILITIES, caps);
-
-    if ( caps & ARCH_CAPS_IF_PSCHANGE_MC_NO )
+    /* Hardware reports itself as fixed. */
+    if ( cpu_has_if_pschange_mc_no )
         return false;
 
     /*
diff --git a/xen/include/asm-x86/cpufeature.h b/xen/include/asm-x86/cpufeature.h
index e93e72bbbd..e44643e393 100644
--- a/xen/include/asm-x86/cpufeature.h
+++ b/xen/include/asm-x86/cpufeature.h
@@ -142,6 +142,9 @@
 /* CPUID level 0x00000007:1.eax */
 #define cpu_has_avx512_bf16     boot_cpu_has(X86_FEATURE_AVX512_BF16)
 
+/* MSR_ARCH_CAPS */
+#define cpu_has_if_pschange_mc_no boot_cpu_has(X86_FEATURE_IF_PSCHANGE_MC_NO)
+
 /* Synthesized. */
 #define cpu_has_arch_perfmon    boot_cpu_has(X86_FEATURE_ARCH_PERFMON)
 #define cpu_has_cpuid_faulting  boot_cpu_has(X86_FEATURE_CPUID_FAULTING)
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:03:58 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:03:58 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680925.1059270 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGnm-0007qs-KO; Wed, 14 Feb 2024 15:03:58 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680925.1059270; Wed, 14 Feb 2024 15:03:58 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGnm-0007qj-Hh; Wed, 14 Feb 2024 15:03:58 +0000
Received: by outflank-mailman (input) for mailman id 680925;
 Wed, 14 Feb 2024 15:03:57 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGnl-0007qP-Gk
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:57 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGnl-0005p9-Fz
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:57 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGnl-0000jT-FD
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:03:57 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=5DLtwZc+0O5S6Pcq/ZIHcqwXUExWp3nEVQNtNMGd4xE=; b=eTt7T9PVTm8HkjBXG5/26zJ4q0
	tcL4Lp5UnjqOBpBs/YOgLAzlpHYHXCVj2KCh76Zo0h8n3M/VM7oQd1fosYF9bqLF5qc/5mloP4RBW
	3uOkn6GdDPRtdtHlYlIErVdLD9T3rdQ7scJZ0vbNyuseNwC5Vgu6aynCYQa5LylMPZaE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/tsx: Remove opencoded MSR_ARCH_CAPS check
Message-Id: <E1raGnl-0000jT-FD@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:03:57 +0000

commit ad084937fac247991b9344e9b9f3846bc42b2c30
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon May 15 19:05:01 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/tsx: Remove opencoded MSR_ARCH_CAPS check
    
    The current cpu_has_tsx_ctrl tristate is serving double pupose; to signal the
    first pass through tsx_init(), and the availability of MSR_TSX_CTRL.
    
    Drop the variable, replacing it with a once boolean, and altering
    cpu_has_tsx_ctrl to come out of the feature information.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 205a9f970378c31ae3e00b52d59103a2e881b9e0)
---
 xen/arch/x86/tsx.c               | 13 ++++++++-----
 xen/include/asm-x86/cpufeature.h |  1 +
 xen/include/asm-x86/processor.h  |  2 +-
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/xen/arch/x86/tsx.c b/xen/arch/x86/tsx.c
index be89741a2f..287812ec2b 100644
--- a/xen/arch/x86/tsx.c
+++ b/xen/arch/x86/tsx.c
@@ -19,7 +19,6 @@
  * controlling TSX behaviour, and where TSX isn't force-disabled by firmware.
  */
 int8_t __read_mostly opt_tsx = -1;
-int8_t __read_mostly cpu_has_tsx_ctrl = -1;
 bool __read_mostly rtm_disabled;
 
 static int __init parse_tsx(const char *s)
@@ -37,24 +36,28 @@ custom_param("tsx", parse_tsx);
 
 void tsx_init(void)
 {
+    static bool __read_mostly once;
+
     /*
      * This function is first called between microcode being loaded, and CPUID
      * being scanned generally.  Read into boot_cpu_data.x86_capability[] for
      * the cpu_has_* bits we care about using here.
      */
-    if ( unlikely(cpu_has_tsx_ctrl < 0) )
+    if ( unlikely(!once) )
     {
-        uint64_t caps = 0;
         bool has_rtm_always_abort;
 
+        once = true;
+
         if ( boot_cpu_data.cpuid_level >= 7 )
             boot_cpu_data.x86_capability[cpufeat_word(X86_FEATURE_ARCH_CAPS)]
                 = cpuid_count_edx(7, 0);
 
         if ( cpu_has_arch_caps )
-            rdmsrl(MSR_ARCH_CAPABILITIES, caps);
+            rdmsr(MSR_ARCH_CAPABILITIES,
+                  boot_cpu_data.x86_capability[FEATURESET_m10Al],
+                  boot_cpu_data.x86_capability[FEATURESET_m10Ah]);
 
-        cpu_has_tsx_ctrl = !!(caps & ARCH_CAPS_TSX_CTRL);
         has_rtm_always_abort = cpu_has_rtm_always_abort;
 
         if ( cpu_has_tsx_ctrl && cpu_has_srbds_ctrl )
diff --git a/xen/include/asm-x86/cpufeature.h b/xen/include/asm-x86/cpufeature.h
index e44643e393..53623d31df 100644
--- a/xen/include/asm-x86/cpufeature.h
+++ b/xen/include/asm-x86/cpufeature.h
@@ -144,6 +144,7 @@
 
 /* MSR_ARCH_CAPS */
 #define cpu_has_if_pschange_mc_no boot_cpu_has(X86_FEATURE_IF_PSCHANGE_MC_NO)
+#define cpu_has_tsx_ctrl        boot_cpu_has(X86_FEATURE_TSX_CTRL)
 
 /* Synthesized. */
 #define cpu_has_arch_perfmon    boot_cpu_has(X86_FEATURE_ARCH_PERFMON)
diff --git a/xen/include/asm-x86/processor.h b/xen/include/asm-x86/processor.h
index 71b454d984..b4d4fe9930 100644
--- a/xen/include/asm-x86/processor.h
+++ b/xen/include/asm-x86/processor.h
@@ -628,7 +628,7 @@ static inline uint8_t get_cpu_family(uint32_t raw, uint8_t *model,
     return fam;
 }
 
-extern int8_t opt_tsx, cpu_has_tsx_ctrl;
+extern int8_t opt_tsx;
 extern bool rtm_disabled;
 void tsx_init(void);
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:04:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:04:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680926.1059276 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGnw-0007xq-O7; Wed, 14 Feb 2024 15:04:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680926.1059276; Wed, 14 Feb 2024 15:04:08 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGnw-0007xi-Kk; Wed, 14 Feb 2024 15:04:08 +0000
Received: by outflank-mailman (input) for mailman id 680926;
 Wed, 14 Feb 2024 15:04:07 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGnv-0007xa-Ja
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:07 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGnv-0005pV-It
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:07 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGnv-0000ka-IH
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:07 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=+Mmoe3Q6hQMAc1xTkbotjYgxhYoMYiwNZAE0Pp76+fc=; b=GS0nJQyW33jX6O3XHwUbEh4aCJ
	JWk0NHJS5YdGkv8y3ZexEpZW/VqcKeeRjjdjVZn+jsd72VbNdR0OKGVWWrgbLuSJ9zKfPlx/SazDH
	8nz4tPvm8Bgacu7KlH/hWALMqiwm2Wm/oYSbkE+oYbmQAm7vzp9NGqDCQ8P5mC+Cpgeo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/spec-ctrl: Remove opencoded MSR_ARCH_CAPS check
Message-Id: <E1raGnv-0000ka-IH@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:04:07 +0000

commit dc89d1f6f3df7259be44a8e392a1a0e7792e8c63
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon May 15 19:15:48 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/spec-ctrl: Remove opencoded MSR_ARCH_CAPS check
    
    MSR_ARCH_CAPS data is now included in featureset information.  Replace
    opencoded checks with regular feature ones.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 511b9f286c3dadd041e0d90beeff7d47c9bf3b7a)
---
 xen/arch/x86/spec_ctrl.c         | 56 +++++++++++++++++++---------------------
 xen/include/asm-x86/cpufeature.h |  7 +++++
 2 files changed, 33 insertions(+), 30 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 9ce493d6bc..549c6f2e5a 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -293,12 +293,10 @@ custom_param("spec-ctrl", parse_spec_ctrl);
 int8_t __read_mostly opt_xpti_hwdom = -1;
 int8_t __read_mostly opt_xpti_domu = -1;
 
-static __init void xpti_init_default(uint64_t caps)
+static __init void xpti_init_default(void)
 {
-    if ( boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON) )
-        caps = ARCH_CAPS_RDCL_NO;
-
-    if ( caps & ARCH_CAPS_RDCL_NO )
+    if ( (boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) ||
+         cpu_has_rdcl_no )
     {
         if ( opt_xpti_hwdom < 0 )
             opt_xpti_hwdom = 0;
@@ -401,9 +399,10 @@ static __init int parse_pv_l1tf(const char *s)
 }
 custom_param("pv-l1tf", parse_pv_l1tf);
 
-static void __init print_details(enum ind_thunk thunk, uint64_t caps)
+static void __init print_details(enum ind_thunk thunk)
 {
     unsigned int _7d0 = 0, _7d2 = 0, e8b = 0, max = 0, tmp;
+    uint64_t caps = 0;
 
     /* Collect diagnostics about available mitigations. */
     if ( boot_cpu_data.cpuid_level >= 7 )
@@ -412,6 +411,8 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)
         cpuid_count(7, 2, &tmp, &tmp, &tmp, &_7d2);
     if ( boot_cpu_data.extended_cpuid_level >= 0x80000008 )
         cpuid(0x80000008, &tmp, &e8b, &tmp, &tmp);
+    if ( cpu_has_arch_caps )
+        rdmsrl(MSR_ARCH_CAPABILITIES, caps);
 
     printk("Speculative mitigation facilities:\n");
 
@@ -587,7 +588,7 @@ static bool __init check_smt_enabled(void)
 }
 
 /* Calculate whether Retpoline is known-safe on this CPU. */
-static bool __init retpoline_safe(uint64_t caps)
+static bool __init retpoline_safe(void)
 {
     unsigned int ucode_rev = this_cpu(cpu_sig).rev;
 
@@ -605,7 +606,7 @@ static bool __init retpoline_safe(uint64_t caps)
      * Processors offering Enhanced IBRS are not guarenteed to be
      * repoline-safe.
      */
-    if ( caps & (ARCH_CAPS_RSBA | ARCH_CAPS_IBRS_ALL) )
+    if ( cpu_has_rsba || cpu_has_eibrs )
         return false;
 
     switch ( boot_cpu_data.x86_model )
@@ -825,7 +826,7 @@ static void __init ibpb_calculations(void)
 }
 
 /* Calculate whether this CPU is vulnerable to L1TF. */
-static __init void l1tf_calculations(uint64_t caps)
+static __init void l1tf_calculations(void)
 {
     bool hit_default = false;
 
@@ -913,7 +914,7 @@ static __init void l1tf_calculations(uint64_t caps)
     }
 
     /* Any processor advertising RDCL_NO should be not vulnerable to L1TF. */
-    if ( caps & ARCH_CAPS_RDCL_NO )
+    if ( cpu_has_rdcl_no )
         cpu_has_bug_l1tf = false;
 
     if ( cpu_has_bug_l1tf && hit_default )
@@ -972,7 +973,7 @@ static __init void l1tf_calculations(uint64_t caps)
 }
 
 /* Calculate whether this CPU is vulnerable to MDS. */
-static __init void mds_calculations(uint64_t caps)
+static __init void mds_calculations(void)
 {
     /* MDS is only known to affect Intel Family 6 processors at this time. */
     if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ||
@@ -980,7 +981,7 @@ static __init void mds_calculations(uint64_t caps)
         return;
 
     /* Any processor advertising MDS_NO should be not vulnerable to MDS. */
-    if ( caps & ARCH_CAPS_MDS_NO )
+    if ( cpu_has_mds_no )
         return;
 
     switch ( boot_cpu_data.x86_model )
@@ -1093,10 +1094,6 @@ void __init init_speculation_mitigations(void)
     enum ind_thunk thunk = THUNK_DEFAULT;
     bool has_spec_ctrl, ibrs = false, hw_smt_enabled;
     bool cpu_has_bug_taa;
-    uint64_t caps = 0;
-
-    if ( cpu_has_arch_caps )
-        rdmsrl(MSR_ARCH_CAPABILITIES, caps);
 
     hw_smt_enabled = check_smt_enabled();
 
@@ -1143,7 +1140,7 @@ void __init init_speculation_mitigations(void)
              * On all hardware, we'd like to use retpoline in preference to
              * IBRS, but only if it is safe on this hardware.
              */
-            if ( retpoline_safe(caps) )
+            if ( retpoline_safe() )
                 thunk = THUNK_RETPOLINE;
             else if ( has_spec_ctrl )
                 ibrs = true;
@@ -1308,13 +1305,13 @@ void __init init_speculation_mitigations(void)
      * threads.  Activate this if SMT is enabled, and Xen is using a non-zero
      * MSR_SPEC_CTRL setting.
      */
-    if ( boot_cpu_has(X86_FEATURE_IBRSB) && !(caps & ARCH_CAPS_IBRS_ALL) &&
+    if ( boot_cpu_has(X86_FEATURE_IBRSB) && !cpu_has_eibrs &&
          hw_smt_enabled && default_xen_spec_ctrl )
         setup_force_cpu_cap(X86_FEATURE_SC_MSR_IDLE);
 
-    xpti_init_default(caps);
+    xpti_init_default();
 
-    l1tf_calculations(caps);
+    l1tf_calculations();
 
     /*
      * By default, enable PV domU L1TF mitigations on all L1TF-vulnerable
@@ -1335,7 +1332,7 @@ void __init init_speculation_mitigations(void)
     if ( !boot_cpu_has(X86_FEATURE_L1D_FLUSH) )
         opt_l1d_flush = 0;
     else if ( opt_l1d_flush == -1 )
-        opt_l1d_flush = cpu_has_bug_l1tf && !(caps & ARCH_CAPS_SKIP_L1DFL);
+        opt_l1d_flush = cpu_has_bug_l1tf && !cpu_has_skip_l1dfl;
 
     if ( opt_branch_harden )
         setup_force_cpu_cap(X86_FEATURE_SC_BRANCH_HARDEN);
@@ -1357,7 +1354,7 @@ void __init init_speculation_mitigations(void)
             "enabled.  Please assess your configuration and choose an\n"
             "explicit 'smt=<bool>' setting.  See XSA-273.\n");
 
-    mds_calculations(caps);
+    mds_calculations();
 
     /*
      * Parts which enumerate FB_CLEAR are those which are post-MDS_NO and have
@@ -1369,7 +1366,7 @@ void __init init_speculation_mitigations(void)
      * the return-to-guest path.
      */
     if ( opt_unpriv_mmio )
-        opt_fb_clear_mmio = caps & ARCH_CAPS_FB_CLEAR;
+        opt_fb_clear_mmio = cpu_has_fb_clear;
 
     /*
      * By default, enable PV and HVM mitigations on MDS-vulnerable hardware.
@@ -1399,7 +1396,7 @@ void __init init_speculation_mitigations(void)
      */
     if ( opt_md_clear_pv || opt_md_clear_hvm || opt_fb_clear_mmio )
         setup_force_cpu_cap(X86_FEATURE_SC_VERW_IDLE);
-    opt_md_clear_hvm &= !(caps & ARCH_CAPS_SKIP_L1DFL) && !opt_l1d_flush;
+    opt_md_clear_hvm &= !cpu_has_skip_l1dfl && !opt_l1d_flush;
 
     /*
      * Warn the user if they are on MLPDS/MFBDS-vulnerable hardware with HT
@@ -1430,8 +1427,7 @@ void __init init_speculation_mitigations(void)
      *       we check both to spot TSX in a microcode/cmdline independent way.
      */
     cpu_has_bug_taa =
-        (cpu_has_rtm || (caps & ARCH_CAPS_TSX_CTRL)) &&
-        (caps & (ARCH_CAPS_MDS_NO | ARCH_CAPS_TAA_NO)) == ARCH_CAPS_MDS_NO;
+        (cpu_has_rtm || cpu_has_tsx_ctrl) && cpu_has_mds_no && !cpu_has_taa_no;
 
     /*
      * On TAA-affected hardware, disabling TSX is the preferred mitigation, vs
@@ -1450,7 +1446,7 @@ void __init init_speculation_mitigations(void)
      * plausibly value TSX higher than Hyperthreading...), disable TSX to
      * mitigate TAA.
      */
-    if ( opt_tsx == -1 && cpu_has_bug_taa && (caps & ARCH_CAPS_TSX_CTRL) &&
+    if ( opt_tsx == -1 && cpu_has_bug_taa && cpu_has_tsx_ctrl &&
          ((hw_smt_enabled && opt_smt) ||
           !boot_cpu_has(X86_FEATURE_SC_VERW_IDLE)) )
     {
@@ -1475,15 +1471,15 @@ void __init init_speculation_mitigations(void)
     if ( cpu_has_srbds_ctrl )
     {
         if ( opt_srb_lock == -1 && !opt_unpriv_mmio &&
-             (caps & (ARCH_CAPS_MDS_NO|ARCH_CAPS_TAA_NO)) == ARCH_CAPS_MDS_NO &&
-             (!cpu_has_hle || ((caps & ARCH_CAPS_TSX_CTRL) && rtm_disabled)) )
+             cpu_has_mds_no && !cpu_has_taa_no &&
+             (!cpu_has_hle || (cpu_has_tsx_ctrl && rtm_disabled)) )
             opt_srb_lock = 0;
 
         set_in_mcu_opt_ctrl(MCU_OPT_CTRL_RNGDS_MITG_DIS,
                             opt_srb_lock ? 0 : MCU_OPT_CTRL_RNGDS_MITG_DIS);
     }
 
-    print_details(thunk, caps);
+    print_details(thunk);
 
     /*
      * If MSR_SPEC_CTRL is available, apply Xen's default setting and discard
diff --git a/xen/include/asm-x86/cpufeature.h b/xen/include/asm-x86/cpufeature.h
index 53623d31df..c0415c06cb 100644
--- a/xen/include/asm-x86/cpufeature.h
+++ b/xen/include/asm-x86/cpufeature.h
@@ -143,8 +143,15 @@
 #define cpu_has_avx512_bf16     boot_cpu_has(X86_FEATURE_AVX512_BF16)
 
 /* MSR_ARCH_CAPS */
+#define cpu_has_rdcl_no         boot_cpu_has(X86_FEATURE_RDCL_NO)
+#define cpu_has_eibrs           boot_cpu_has(X86_FEATURE_EIBRS)
+#define cpu_has_rsba            boot_cpu_has(X86_FEATURE_RSBA)
+#define cpu_has_skip_l1dfl      boot_cpu_has(X86_FEATURE_SKIP_L1DFL)
+#define cpu_has_mds_no          boot_cpu_has(X86_FEATURE_MDS_NO)
 #define cpu_has_if_pschange_mc_no boot_cpu_has(X86_FEATURE_IF_PSCHANGE_MC_NO)
 #define cpu_has_tsx_ctrl        boot_cpu_has(X86_FEATURE_TSX_CTRL)
+#define cpu_has_taa_no          boot_cpu_has(X86_FEATURE_TAA_NO)
+#define cpu_has_fb_clear        boot_cpu_has(X86_FEATURE_FB_CLEAR)
 
 /* Synthesized. */
 #define cpu_has_arch_perfmon    boot_cpu_has(X86_FEATURE_ARCH_PERFMON)
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:04:19 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:04:19 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680927.1059280 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGo7-00080c-PY; Wed, 14 Feb 2024 15:04:19 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680927.1059280; Wed, 14 Feb 2024 15:04:19 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGo7-00080U-MC; Wed, 14 Feb 2024 15:04:19 +0000
Received: by outflank-mailman (input) for mailman id 680927;
 Wed, 14 Feb 2024 15:04:17 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGo5-00080E-Mp
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:17 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGo5-0005pb-M3
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:17 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGo5-0000lS-LK
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:17 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=mPtYpfIkEbxKnsqYIWoUqddZPQEdc8D3nUyc559nIZc=; b=G+kfiuuuTfSUjnbSDcRfoWynRB
	5yCxfQiaw3ewojR3PYLNIMDsoV9G2gijK6zc0Z1S2N/kEtQlPUq9YERFpwT4ZVhHRpNk2YK64y2hP
	zwra0+kME6+qpwzVmMxX7tuv/4GFXLgwvUCH6koF2/ODnjhWYgeI1vJPqP/ApPu6PkHg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/spec-ctrl: Update hardware hints
Message-Id: <E1raGo5-0000lS-LK@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:04:17 +0000

commit 06a2b62145f742816f8377fae22a21fe1dfe2059
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue May 30 16:03:16 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/spec-ctrl: Update hardware hints
    
     * Rename IBRS_ALL to EIBRS.  EIBRS is the term that everyone knows, and this
       makes ARCH_CAPS_EIBRS match the X86_FEATURE_EIBRS form.
     * Print RRSBA too, which is also a hint about behaviour.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 94200e1bae07e725cc07238c11569c5cab7befb7)
---
 xen/arch/x86/spec_ctrl.c        | 5 +++--
 xen/include/asm-x86/msr-index.h | 2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 549c6f2e5a..20d1bac126 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -420,10 +420,11 @@ static void __init print_details(enum ind_thunk thunk)
      * Hardware read-only information, stating immunity to certain issues, or
      * suggestions of which mitigation to use.
      */
-    printk("  Hardware hints:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+    printk("  Hardware hints:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
            (caps & ARCH_CAPS_RDCL_NO)                        ? " RDCL_NO"        : "",
-           (caps & ARCH_CAPS_IBRS_ALL)                       ? " IBRS_ALL"       : "",
+           (caps & ARCH_CAPS_EIBRS)                          ? " EIBRS"          : "",
            (caps & ARCH_CAPS_RSBA)                           ? " RSBA"           : "",
+           (caps & ARCH_CAPS_RRSBA)                          ? " RRSBA"          : "",
            (caps & ARCH_CAPS_SKIP_L1DFL)                     ? " SKIP_L1DFL"     : "",
            (e8b  & cpufeat_mask(X86_FEATURE_SSB_NO)) ||
            (caps & ARCH_CAPS_SSB_NO)                         ? " SSB_NO"         : "",
diff --git a/xen/include/asm-x86/msr-index.h b/xen/include/asm-x86/msr-index.h
index ce5677f3b6..7befa60abd 100644
--- a/xen/include/asm-x86/msr-index.h
+++ b/xen/include/asm-x86/msr-index.h
@@ -48,7 +48,7 @@
 
 #define MSR_ARCH_CAPABILITIES               0x0000010a
 #define  ARCH_CAPS_RDCL_NO                  (_AC(1, ULL) <<  0)
-#define  ARCH_CAPS_IBRS_ALL                 (_AC(1, ULL) <<  1)
+#define  ARCH_CAPS_EIBRS                    (_AC(1, ULL) <<  1)
 #define  ARCH_CAPS_RSBA                     (_AC(1, ULL) <<  2)
 #define  ARCH_CAPS_SKIP_L1DFL               (_AC(1, ULL) <<  3)
 #define  ARCH_CAPS_SSB_NO                   (_AC(1, ULL) <<  4)
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:04:29 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:04:29 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680928.1059284 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGoH-00083Y-Qz; Wed, 14 Feb 2024 15:04:29 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680928.1059284; Wed, 14 Feb 2024 15:04:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGoH-00083N-Ni; Wed, 14 Feb 2024 15:04:29 +0000
Received: by outflank-mailman (input) for mailman id 680928;
 Wed, 14 Feb 2024 15:04:27 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGoF-000835-Pc
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:27 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGoF-0005ph-Oz
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:27 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGoF-0000mO-OM
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:27 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=BHMJ4gCyZ1Oi3okGloSzMaZWxs3jM6n57us/NPL/Hfw=; b=rzaRVHN1VPmSfIbHg1o2voM2TU
	N29QiGkZ5U522YtsmN+pl/b+RMh2xCyaX7/6Xk15otr6ZGJ9tAHW/RvmMTF0etk2AwRNCeDKLWAkm
	NKRt8sAqMWhTyHXddEbg24DFg85d5udDhaBk+JLiBUlbBgtOvY/tmqQBVck+/MJc7bR0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/cpu-policy: Rearrange guest_common_default_feature_adjustments()
Message-Id: <E1raGoF-0000mO-OM@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:04:27 +0000

commit 5619a526ead8f8c05e5180a4d69dd70007ca2660
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Mar 10 16:23:20 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/cpu-policy: Rearrange guest_common_default_feature_adjustments()
    
    This is prep work, split out to simply the diff on the following change.
    
     * Split the INTEL check out of the IvyBridge RDRAND check, as the former will
       be reused.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 064f572f96f1558faae0a74cad616ba95ec8ff34)
---
 xen/arch/x86/cpu-policy.c | 33 ++++++++++++++++++---------------
 1 file changed, 18 insertions(+), 15 deletions(-)

diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
index 99cae5b145..7905d1f042 100644
--- a/xen/arch/x86/cpu-policy.c
+++ b/xen/arch/x86/cpu-policy.c
@@ -429,21 +429,24 @@ static void __init guest_common_max_feature_adjustments(uint32_t *fs)
 
 static void __init guest_common_default_feature_adjustments(uint32_t *fs)
 {
-    /*
-     * IvyBridge client parts suffer from leakage of RDRAND data due to SRBDS
-     * (XSA-320 / CVE-2020-0543), and won't be receiving microcode to
-     * compensate.
-     *
-     * Mitigate by hiding RDRAND from guests by default, unless explicitly
-     * overridden on the Xen command line (cpuid=rdrand).  Irrespective of the
-     * default setting, guests can use RDRAND if explicitly enabled
-     * (cpuid="host,rdrand=1") in the VM's config file, and VMs which were
-     * previously using RDRAND can migrate in.
-     */
-    if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
-         boot_cpu_data.x86 == 6 && boot_cpu_data.x86_model == 0x3a &&
-         cpu_has_rdrand && !is_forced_cpu_cap(X86_FEATURE_RDRAND) )
-        __clear_bit(X86_FEATURE_RDRAND, fs);
+    if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL )
+    {
+        /*
+         * IvyBridge client parts suffer from leakage of RDRAND data due to SRBDS
+         * (XSA-320 / CVE-2020-0543), and won't be receiving microcode to
+         * compensate.
+         *
+         * Mitigate by hiding RDRAND from guests by default, unless explicitly
+         * overridden on the Xen command line (cpuid=rdrand).  Irrespective of the
+         * default setting, guests can use RDRAND if explicitly enabled
+         * (cpuid="host,rdrand=1") in the VM's config file, and VMs which were
+         * previously using RDRAND can migrate in.
+         */
+        if ( boot_cpu_data.x86 == 6 &&
+             boot_cpu_data.x86_model == 0x3a /* INTEL_FAM6_IVYBRIDGE */ &&
+             cpu_has_rdrand && !is_forced_cpu_cap(X86_FEATURE_RDRAND) )
+            __clear_bit(X86_FEATURE_RDRAND, fs);
+    }
 
     /*
      * On certain hardware, speculative or errata workarounds can result in
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:04:39 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:04:39 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680929.1059287 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGoR-00086j-Ry; Wed, 14 Feb 2024 15:04:39 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680929.1059287; Wed, 14 Feb 2024 15:04:39 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGoR-00086b-PB; Wed, 14 Feb 2024 15:04:39 +0000
Received: by outflank-mailman (input) for mailman id 680929;
 Wed, 14 Feb 2024 15:04:37 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGoP-00086P-Sd
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:37 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGoP-0005pu-Ru
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:37 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGoP-0000nD-RE
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:37 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=h4T/m5J954cKNc/jvQvEAvI1xqGQ3AH8GiK/mO7LSNU=; b=n41CZ74QCbHEiWqlxi3Oua/cat
	+a+rjqh3TtYbJ8NrmCLhsxJXIlbolVk2vsl/U5SUxT2Pk7RYNQxpsZ/X6Nht7uhwXOGaJHT+Or1ka
	4soDyCubVQTfzeG5zcAlYtrgxlhbF1tBK7unuMq9jxbfSoUDAAjlNDyHebSbAMkLEOZc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/spec-ctrl: Fix the rendering of FB_CLEAR
Message-Id: <E1raGoP-0000nD-RE@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:04:37 +0000

commit 18e759cb87c6375bc6cd0e9ce7e51f7af1be67f1
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon Jun 12 20:24:00 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/spec-ctrl: Fix the rendering of FB_CLEAR
    
    FB_CLEAR is a read-only status bit, not a read-write control.  Move it from
    "Hardware features" into "Hardware hints".
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 921afcbae843bb3f575a8f4a270b8e6cf471f4ca)
---
 xen/arch/x86/spec_ctrl.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 20d1bac126..9efc49ace7 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -420,7 +420,7 @@ static void __init print_details(enum ind_thunk thunk)
      * Hardware read-only information, stating immunity to certain issues, or
      * suggestions of which mitigation to use.
      */
-    printk("  Hardware hints:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+    printk("  Hardware hints:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
            (caps & ARCH_CAPS_RDCL_NO)                        ? " RDCL_NO"        : "",
            (caps & ARCH_CAPS_EIBRS)                          ? " EIBRS"          : "",
            (caps & ARCH_CAPS_RSBA)                           ? " RSBA"           : "",
@@ -433,6 +433,7 @@ static void __init print_details(enum ind_thunk thunk)
            (caps & ARCH_CAPS_SBDR_SSDP_NO)                   ? " SBDR_SSDP_NO"   : "",
            (caps & ARCH_CAPS_FBSDP_NO)                       ? " FBSDP_NO"       : "",
            (caps & ARCH_CAPS_PSDP_NO)                        ? " PSDP_NO"        : "",
+           (caps & ARCH_CAPS_FB_CLEAR)                       ? " FB_CLEAR"       : "",
            (caps & ARCH_CAPS_PBRSB_NO)                       ? " PBRSB_NO"       : "",
            (e8b  & cpufeat_mask(X86_FEATURE_IBRS_ALWAYS))    ? " IBRS_ALWAYS"    : "",
            (e8b  & cpufeat_mask(X86_FEATURE_STIBP_ALWAYS))   ? " STIBP_ALWAYS"   : "",
@@ -442,7 +443,7 @@ static void __init print_details(enum ind_thunk thunk)
            (e8b  & cpufeat_mask(X86_FEATURE_IBPB_RET))       ? " IBPB_RET"       : "");
 
     /* Hardware features which need driving to mitigate issues. */
-    printk("  Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s\n",
+    printk("  Hardware features:%s%s%s%s%s%s%s%s%s%s%s\n",
            (e8b  & cpufeat_mask(X86_FEATURE_IBPB)) ||
            (_7d0 & cpufeat_mask(X86_FEATURE_IBRSB))          ? " IBPB"           : "",
            (e8b  & cpufeat_mask(X86_FEATURE_IBRS)) ||
@@ -458,7 +459,6 @@ static void __init print_details(enum ind_thunk thunk)
            (_7d0 & cpufeat_mask(X86_FEATURE_SRBDS_CTRL))     ? " SRBDS_CTRL"     : "",
            (e8b  & cpufeat_mask(X86_FEATURE_VIRT_SSBD))      ? " VIRT_SSBD"      : "",
            (caps & ARCH_CAPS_TSX_CTRL)                       ? " TSX_CTRL"       : "",
-           (caps & ARCH_CAPS_FB_CLEAR)                       ? " FB_CLEAR"       : "",
            (caps & ARCH_CAPS_FB_CLEAR_CTRL)                  ? " FB_CLEAR_CTRL"  : "");
 
     /* Compiled-in support which pertains to mitigations. */
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:04:49 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:04:49 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680932.1059291 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGob-0008BW-Tm; Wed, 14 Feb 2024 15:04:49 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680932.1059291; Wed, 14 Feb 2024 15:04:49 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGob-0008BO-Qh; Wed, 14 Feb 2024 15:04:49 +0000
Received: by outflank-mailman (input) for mailman id 680932;
 Wed, 14 Feb 2024 15:04:48 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGoZ-0008B3-Ve
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:47 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGoZ-0005qH-V0
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:47 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGoZ-0000o1-UQ
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:47 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=D4nNklVA63k/ADGYQKA8HO3jPTMJyUFgD0OVI8kQy+Q=; b=5ynkkCNV8NeVf5swBOHcWksqM9
	ff4Tv4kRdoDhbP6RcLNFCyeTMaDCkw7mrDVOo2PxwfzWpbL6BaglsqbIu1QwMv+7JCS/TfxHDyHze
	mztkyqgWxxlFzBF8xLJL62EDqj/M3TtxjlDtYMDoH4TUEgakoYzVK3Jm/MXjCjBX8DF0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/spec-ctrl: Use a taint for CET without MSR_SPEC_CTRL
Message-Id: <E1raGoZ-0000o1-UQ@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:04:47 +0000

commit efc4bdd2c969e858fe41e3a1eff8aa99dc093132
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon Jun 5 11:09:11 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/spec-ctrl: Use a taint for CET without MSR_SPEC_CTRL
    
    Reword the comment for 'S' to include an incompatible set of features on the
    same core.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 3f63f4510422c29fda7ba238b880cbb53eca34fe)
    
    Also minimal fragments from:
    
      c/s 0bf9efb9ee4c ("xen/arm: Sanitize cpuinfo ID registers fields")
    
    to introduce TAINT_CPU_OUT_OF_SPEC.
---
 xen/arch/x86/spec_ctrl.c | 3 +++
 xen/common/kernel.c      | 6 ++++--
 xen/include/xen/lib.h    | 1 +
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 9efc49ace7..44fb4c9d45 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -1112,7 +1112,10 @@ void __init init_speculation_mitigations(void)
     if ( read_cr4() & X86_CR4_CET )
     {
         if ( !has_spec_ctrl )
+        {
             printk(XENLOG_WARNING "?!? CET active, but no MSR_SPEC_CTRL?\n");
+            add_taint(TAINT_CPU_OUT_OF_SPEC);
+        }
         else if ( opt_ibrs == -1 )
             opt_ibrs = ibrs = true;
 
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index f07ff41d88..35c9489929 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -338,6 +338,7 @@ unsigned int tainted;
  *  'E' - An error (e.g. a machine check exceptions) has been injected.
  *  'H' - HVM forced emulation prefix is permitted.
  *  'M' - Machine had a machine check experience.
+ *  'S' - Out of spec CPU (Incompatible features on one or more cores).
  *
  *      The string is overwritten by the next call to print_taint().
  */
@@ -345,11 +346,12 @@ char *print_tainted(char *str)
 {
     if ( tainted )
     {
-        snprintf(str, TAINT_STRING_MAX_LEN, "Tainted: %c%c%c%c",
+        snprintf(str, TAINT_STRING_MAX_LEN, "Tainted: %c%c%c%c%c",
                  tainted & TAINT_MACHINE_CHECK ? 'M' : ' ',
                  tainted & TAINT_SYNC_CONSOLE ? 'C' : ' ',
                  tainted & TAINT_ERROR_INJECT ? 'E' : ' ',
-                 tainted & TAINT_HVM_FEP ? 'H' : ' ');
+                 tainted & TAINT_HVM_FEP ? 'H' : ' ',
+                 tainted & TAINT_CPU_OUT_OF_SPEC ? 'S' : ' ');
     }
     else
     {
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index 900c0ce3e4..c072d5a597 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -183,6 +183,7 @@ uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
 #define TAINT_MACHINE_CHECK             (1u << 1)
 #define TAINT_ERROR_INJECT              (1u << 2)
 #define TAINT_HVM_FEP                   (1u << 3)
+#define TAINT_CPU_OUT_OF_SPEC           (1u << 5)
 extern unsigned int tainted;
 #define TAINT_STRING_MAX_LEN            20
 extern char *print_tainted(char *str);
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:05:00 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:05:00 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680933.1059295 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGom-0008Eu-0L; Wed, 14 Feb 2024 15:05:00 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680933.1059295; Wed, 14 Feb 2024 15:04:59 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGol-0008Em-U0; Wed, 14 Feb 2024 15:04:59 +0000
Received: by outflank-mailman (input) for mailman id 680933;
 Wed, 14 Feb 2024 15:04:58 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGok-0008Ea-2n
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:58 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGok-0005qZ-27
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:58 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGok-0000oz-1N
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:04:58 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=qWekc5qCgS4e7qQmU5umqY7dff5bcAHpDDBw26FP3sQ=; b=HMoAJMPyT7RKrkNnUnytha8Drx
	7qEoH+y2A2TmROVL8Lf8F71yDdvu9XfQrkKosJUAyJxyBhy5KL7TKhhvDjHAMTohbWIc57C3Lz54g
	t9pcMYGIkkaHUGUlQxjmClvAPE1wlv66EjEW464pZ8dJTmgAY+yHmuCMtmW69QRTmjnk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/spec-ctrl: Rename retpoline_safe() to retpoline_calculations()
Message-Id: <E1raGok-0000oz-1N@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:04:58 +0000

commit 927a168c39accff6ec7ddee0d530bccdad47412a
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri May 26 10:35:47 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/spec-ctrl: Rename retpoline_safe() to retpoline_calculations()
    
    This is prep work, split out to simply the diff on the following change.
    
     * Rename to retpoline_calculations(), and call unconditionally.  It is
       shortly going to synthesise missing enumerations required for guest safety.
     * For the model check switch statement, store the result in a variable and
       break rather than returning directly.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 724c0d94ff79b208312d30676392bfdd693403be)
---
 xen/arch/x86/spec_ctrl.c | 41 ++++++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 15 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 44fb4c9d45..1ca46ac33d 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -589,9 +589,10 @@ static bool __init check_smt_enabled(void)
 }
 
 /* Calculate whether Retpoline is known-safe on this CPU. */
-static bool __init retpoline_safe(void)
+static bool __init retpoline_calculations(void)
 {
     unsigned int ucode_rev = this_cpu(cpu_sig).rev;
+    bool safe = false;
 
     if ( boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON) )
         return true;
@@ -629,29 +630,31 @@ static bool __init retpoline_safe(void)
     case 0x3f: /* Haswell EX/EP */
     case 0x45: /* Haswell D */
     case 0x46: /* Haswell H */
-        return true;
+        safe = true;
+        break;
 
         /*
          * Broadwell processors are retpoline-safe after specific microcode
          * versions.
          */
     case 0x3d: /* Broadwell */
-        return ucode_rev >= 0x2a;
+        safe = ucode_rev >= 0x2a;      break;
     case 0x47: /* Broadwell H */
-        return ucode_rev >= 0x1d;
+        safe = ucode_rev >= 0x1d;      break;
     case 0x4f: /* Broadwell EP/EX */
-        return ucode_rev >= 0xb000021;
+        safe = ucode_rev >= 0xb000021; break;
     case 0x56: /* Broadwell D */
         switch ( boot_cpu_data.x86_mask )
         {
-        case 2:  return ucode_rev >= 0x15;
-        case 3:  return ucode_rev >= 0x7000012;
-        case 4:  return ucode_rev >= 0xf000011;
-        case 5:  return ucode_rev >= 0xe000009;
+        case 2:  safe = ucode_rev >= 0x15;      break;
+        case 3:  safe = ucode_rev >= 0x7000012; break;
+        case 4:  safe = ucode_rev >= 0xf000011; break;
+        case 5:  safe = ucode_rev >= 0xe000009; break;
         default:
             printk("Unrecognised CPU stepping %#x - assuming not reptpoline safe\n",
                    boot_cpu_data.x86_mask);
-            return false;
+            safe = false;
+            break;
         }
         break;
 
@@ -665,7 +668,8 @@ static bool __init retpoline_safe(void)
     case 0x67: /* Cannonlake? */
     case 0x8e: /* Kabylake M */
     case 0x9e: /* Kabylake D */
-        return false;
+        safe = false;
+        break;
 
         /*
          * Atom processors before Goldmont Plus/Gemini Lake are retpoline-safe.
@@ -684,13 +688,17 @@ static bool __init retpoline_safe(void)
     case 0x5c: /* Goldmont */
     case 0x5f: /* Denverton */
     case 0x85: /* Knights Mill */
-        return true;
+        safe = true;
+        break;
 
     default:
         printk("Unrecognised CPU model %#x - assuming not reptpoline safe\n",
                boot_cpu_data.x86_model);
-        return false;
+        safe = false;
+        break;
     }
+
+    return safe;
 }
 
 /* Calculate whether this CPU speculates past #NM */
@@ -1094,7 +1102,7 @@ void __init init_speculation_mitigations(void)
 {
     enum ind_thunk thunk = THUNK_DEFAULT;
     bool has_spec_ctrl, ibrs = false, hw_smt_enabled;
-    bool cpu_has_bug_taa;
+    bool cpu_has_bug_taa, retpoline_safe;
 
     hw_smt_enabled = check_smt_enabled();
 
@@ -1123,6 +1131,9 @@ void __init init_speculation_mitigations(void)
             thunk = THUNK_JMP;
     }
 
+    /* Determine if retpoline is safe on this CPU. */
+    retpoline_safe = retpoline_calculations();
+
     /*
      * Has the user specified any custom BTI mitigations?  If so, follow their
      * instructions exactly and disable all heuristics.
@@ -1144,7 +1155,7 @@ void __init init_speculation_mitigations(void)
              * On all hardware, we'd like to use retpoline in preference to
              * IBRS, but only if it is safe on this hardware.
              */
-            if ( retpoline_safe() )
+            if ( retpoline_safe )
                 thunk = THUNK_RETPOLINE;
             else if ( has_spec_ctrl )
                 ibrs = true;
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:05:09 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:05:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680934.1059298 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGov-0008Ho-1g; Wed, 14 Feb 2024 15:05:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680934.1059298; Wed, 14 Feb 2024 15:05:09 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGou-0008Hh-VP; Wed, 14 Feb 2024 15:05:08 +0000
Received: by outflank-mailman (input) for mailman id 680934;
 Wed, 14 Feb 2024 15:05:08 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGou-0008HO-70
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:08 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGou-0005qz-53
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:08 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGou-0000q3-4W
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:08 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=6ZKXp2NYZwmuBT5tE3g1nCSvpyDmRabnSSpnZ4TebG8=; b=kRotRSWpRskwjibPLfUU+5bX3U
	kWIi7LYmzNZ9plSPC7N17ilfcM/CZEYfGVsMKWm0uR+GtaFUZT4+azjrsdVtBS+VUe+Vv5gvIAiTu
	kJ7Iw0hYttKA5RP6vI/2+Evqb48vKDMpqV7HavkjfzzONqSHN5GKYJLJ2mcEo+sFEOXs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/spec-ctrl: Fix up the RSBA/RRSBA bits as appropriate
Message-Id: <E1raGou-0000q3-4W@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:05:08 +0000

commit 5059ff1349f7641b6d95ce8a2a181383a1e2814e
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Thu May 25 20:31:22 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/spec-ctrl: Fix up the RSBA/RRSBA bits as appropriate
    
    In order to level a VM safely for migration, the toolstack needs to know the
    RSBA/RRSBA properties of the CPU, whether or not they happen to be enumerated.
    
    See the code comment for details.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 36525a964fb629d0bd26e5a1c42de467af7a42a7)
---
 xen/arch/x86/spec_ctrl.c         | 100 +++++++++++++++++++++++++++++++++++++--
 xen/include/asm-x86/cpufeature.h |   1 +
 2 files changed, 96 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 1ca46ac33d..9a8d6987ca 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -588,7 +588,10 @@ static bool __init check_smt_enabled(void)
     return false;
 }
 
-/* Calculate whether Retpoline is known-safe on this CPU. */
+/*
+ * Calculate whether Retpoline is known-safe on this CPU.  Fix up the
+ * RSBA/RRSBA bits as necessary.
+ */
 static bool __init retpoline_calculations(void)
 {
     unsigned int ucode_rev = this_cpu(cpu_sig).rev;
@@ -602,15 +605,93 @@ static bool __init retpoline_calculations(void)
         return false;
 
     /*
-     * RSBA may be set by a hypervisor to indicate that we may move to a
-     * processor which isn't retpoline-safe.
+     * The meaning of the RSBA and RRSBA bits have evolved over time.  The
+     * agreed upon meaning at the time of writing (May 2023) is thus:
+     *
+     * - RSBA (RSB Alternative) means that an RSB may fall back to an
+     *   alternative predictor on underflow.  Skylake uarch and later all have
+     *   this property.  Broadwell too, when running microcode versions prior
+     *   to Jan 2018.
+     *
+     * - All eIBRS-capable processors suffer RSBA, but eIBRS also introduces
+     *   tagging of predictions with the mode in which they were learned.  So
+     *   when eIBRS is active, RSBA becomes RRSBA (Restricted RSBA).
+     *
+     * - CPUs are not expected to enumerate both RSBA and RRSBA.
+     *
+     * Some parts (Broadwell) are not expected to ever enumerate this
+     * behaviour directly.  Other parts have differing enumeration with
+     * microcode version.  Fix up Xen's idea, so we can advertise them safely
+     * to guests, and so toolstacks can level a VM safety for migration.
+     *
+     * The following states exist:
+     *
+     * |   | RSBA | EIBRS | RRSBA | Notes              | Action (in principle) |
+     * |---+------+-------+-------+--------------------+-----------------------|
+     * | 1 |    0 |     0 |     0 | OK (older parts)   | Maybe +RSBA           |
+     * | 2 |    0 |     0 |     1 | Broken             | (+RSBA, -RRSBA)       |
+     * | 3 |    0 |     1 |     0 | OK (pre-Aug ucode) | +RRSBA                |
+     * | 4 |    0 |     1 |     1 | OK                 |                       |
+     * | 5 |    1 |     0 |     0 | OK                 |                       |
+     * | 6 |    1 |     0 |     1 | Broken             | (-RRSBA)              |
+     * | 7 |    1 |     1 |     0 | Broken             | (-RSBA, +RRSBA)       |
+     * | 8 |    1 |     1 |     1 | Broken             | (-RSBA)               |
+     *
+     * However, we don't need perfect adherence to the spec.  We only need
+     * RSBA || RRSBA to indicate "alternative predictors potentially in use".
+     * Rows 1 & 3 are fixed up by later logic, as they're known configurations
+     * which exist in the world.
      *
+     * Complain loudly at the broken cases. They're safe for Xen to use (so we
+     * don't attempt to correct), and may or may not exist in reality, but if
+     * we ever encounter them in practice, something is wrong and needs
+     * further investigation.
+     */
+    if ( cpu_has_eibrs ? cpu_has_rsba  /* Rows 7, 8 */
+                       : cpu_has_rrsba /* Rows 2, 6 */ )
+    {
+        printk(XENLOG_ERR
+               "FIRMWARE BUG: CPU %02x-%02x-%02x, ucode 0x%08x: RSBA %u, EIBRS %u, RRSBA %u\n",
+               boot_cpu_data.x86, boot_cpu_data.x86_model,
+               boot_cpu_data.x86_mask, ucode_rev,
+               cpu_has_rsba, cpu_has_eibrs, cpu_has_rrsba);
+        add_taint(TAINT_CPU_OUT_OF_SPEC);
+    }
+
+    /*
      * Processors offering Enhanced IBRS are not guarenteed to be
      * repoline-safe.
      */
-    if ( cpu_has_rsba || cpu_has_eibrs )
+    if ( cpu_has_eibrs )
+    {
+        /*
+         * Prior to the August 2023 microcode, many eIBRS-capable parts did
+         * not enumerate RRSBA.
+         */
+        if ( !cpu_has_rrsba )
+            setup_force_cpu_cap(X86_FEATURE_RRSBA);
+
+        return false;
+    }
+
+    /*
+     * RSBA is explicitly enumerated in some cases, but may also be set by a
+     * hypervisor to indicate that we may move to a processor which isn't
+     * retpoline-safe.
+     */
+    if ( cpu_has_rsba )
         return false;
 
+    /*
+     * At this point, we've filtered all the legal RSBA || RRSBA cases (or the
+     * known non-ideal cases).  If ARCH_CAPS is visible, trust the absence of
+     * RSBA || RRSBA.  There's no known microcode which advertises ARCH_CAPS
+     * without RSBA or EIBRS, and if we're virtualised we can't rely the model
+     * check anyway.
+     */
+    if ( cpu_has_arch_caps )
+        return true;
+
     switch ( boot_cpu_data.x86_model )
     {
     case 0x17: /* Penryn */
@@ -698,6 +779,15 @@ static bool __init retpoline_calculations(void)
         break;
     }
 
+    if ( !safe )
+    {
+        /*
+         * Note: the eIBRS-capable parts are filtered out earlier, so the
+         * remainder here are the ones which suffer RSBA behaviour.
+         */
+        setup_force_cpu_cap(X86_FEATURE_RSBA);
+    }
+
     return safe;
 }
 
@@ -1131,7 +1221,7 @@ void __init init_speculation_mitigations(void)
             thunk = THUNK_JMP;
     }
 
-    /* Determine if retpoline is safe on this CPU. */
+    /* Determine if retpoline is safe on this CPU.  Fix up RSBA/RRSBA enumerations. */
     retpoline_safe = retpoline_calculations();
 
     /*
diff --git a/xen/include/asm-x86/cpufeature.h b/xen/include/asm-x86/cpufeature.h
index c0415c06cb..90684fac95 100644
--- a/xen/include/asm-x86/cpufeature.h
+++ b/xen/include/asm-x86/cpufeature.h
@@ -152,6 +152,7 @@
 #define cpu_has_tsx_ctrl        boot_cpu_has(X86_FEATURE_TSX_CTRL)
 #define cpu_has_taa_no          boot_cpu_has(X86_FEATURE_TAA_NO)
 #define cpu_has_fb_clear        boot_cpu_has(X86_FEATURE_FB_CLEAR)
+#define cpu_has_rrsba           boot_cpu_has(X86_FEATURE_RRSBA)
 
 /* Synthesized. */
 #define cpu_has_arch_perfmon    boot_cpu_has(X86_FEATURE_ARCH_PERFMON)
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:05:21 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:05:21 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680935.1059303 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGp5-0008Kg-3k; Wed, 14 Feb 2024 15:05:19 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680935.1059303; Wed, 14 Feb 2024 15:05:19 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGp5-0008KY-0p; Wed, 14 Feb 2024 15:05:19 +0000
Received: by outflank-mailman (input) for mailman id 680935;
 Wed, 14 Feb 2024 15:05:18 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGp4-0008KP-8i
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:18 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGp4-0005r6-7z
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:18 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGp4-0000qy-7O
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:18 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=3UXa3+PLKXSJSQ9+JLG2s5MmBxTIT40HhTmtJCVlDQo=; b=p6ouw6R1V9H027muVyPAKbOpHR
	SrqYz3FQqNTWslJkjy+OaRSBclwNOe6R/S6ryivz+trKKLx2K/yBLEVG0/RRAKBHcY2Wp0rpcQSbE
	rOfoPPn6NYnJVmiui5PX7GtvBu1Lga/nfIh0MN+qhcOk2CLhjFu1MjARcQrhCF84+AjQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/cpu-policy: Derive RSBA/RRSBA for guest policies
Message-Id: <E1raGp4-0000qy-7O@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:05:18 +0000

commit cf02b6efed412eef35d3967756d4ba9f0ded1cbf
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed May 24 15:41:21 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/cpu-policy: Derive RSBA/RRSBA for guest policies
    
    The RSBA bit, "RSB Alternative", means that the RSB may use alternative
    predictors when empty.  From a practical point of view, this mean "Retpoline
    not safe".
    
    Enhanced IBRS (officially IBRS_ALL in Intel's docs, previously IBRS_ATT) is a
    statement that IBRS is implemented in hardware (as opposed to the form
    retrofitted to existing CPUs in microcode).
    
    The RRSBA bit, "Restricted-RSBA", is a combination of RSBA, and the eIBRS
    property that predictions are tagged with the mode in which they were learnt.
    Therefore, it means "when eIBRS is active, the RSB may fall back to
    alternative predictors but restricted to the current prediction mode".  As
    such, it's stronger statement than RSBA, but still means "Retpoline not safe".
    
    CPUs are not expected to enumerate both RSBA and RRSBA.
    
    Add feature dependencies for EIBRS and RRSBA.  While technically they're not
    linked, absolutely nothing good can come of letting the guest see RRSBA
    without EIBRS.  Nor a guest seeing EIBRS without IBRSB.  Furthermore, we use
    this dependency to simplify the max derivation logic.
    
    The max policies gets RSBA and RRSBA unconditionally set (with the EIBRS
    dependency maybe hiding RRSBA).  We can run any VM, even if it has been told
    "somewhere you might run, Retpoline isn't safe".
    
    The default policies are more complicated.  A guest shouldn't see both bits,
    but it needs to see one if the current host suffers from any form of RSBA, and
    which bit it needs to see depends on whether eIBRS is visible or not.
    Therefore, the calculation must be performed after sanitise_featureset().
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit e0586a4ff514590eec50185e2440b97f9a31cb7f)
---
 xen/arch/x86/cpu-policy.c                   | 39 +++++++++++++++++++++++++++++
 xen/include/public/arch-x86/cpufeatureset.h |  4 +--
 xen/tools/gen-cpuid.py                      |  5 +++-
 3 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
index 7905d1f042..9d70e41306 100644
--- a/xen/arch/x86/cpu-policy.c
+++ b/xen/arch/x86/cpu-policy.c
@@ -422,8 +422,17 @@ static void __init guest_common_max_feature_adjustments(uint32_t *fs)
          * Retpoline not safe)", so these need to be visible to a guest in all
          * cases, even when it's only some other server in the pool which
          * suffers the identified behaviour.
+         *
+         * We can always run any VM which has previously (or will
+         * subsequently) run on hardware where Retpoline is not safe.
+         * Note:
+         *  - The dependency logic may hide RRSBA for other reasons.
+         *  - The max policy does not constitute a sensible configuration to
+         *    run a guest in.
          */
         __set_bit(X86_FEATURE_ARCH_CAPS, fs);
+        __set_bit(X86_FEATURE_RSBA, fs);
+        __set_bit(X86_FEATURE_RRSBA, fs);
     }
 }
 
@@ -531,6 +540,21 @@ static void __init calculate_pv_def_policy(void)
     guest_common_default_feature_adjustments(fs);
 
     sanitise_featureset(fs);
+
+    /*
+     * If the host suffers from RSBA of any form, and the guest can see
+     * MSR_ARCH_CAPS, reflect the appropriate RSBA/RRSBA property to the guest
+     * depending on the visibility of eIBRS.
+     */
+    if ( test_bit(X86_FEATURE_ARCH_CAPS, fs) &&
+         (cpu_has_rsba || cpu_has_rrsba) )
+    {
+        bool eibrs = test_bit(X86_FEATURE_EIBRS, fs);
+
+        __set_bit(eibrs ? X86_FEATURE_RRSBA
+                        : X86_FEATURE_RSBA, fs);
+    }
+
     x86_cpu_featureset_to_policy(fs, p);
     recalculate_xstate(p);
 }
@@ -621,6 +645,21 @@ static void __init calculate_hvm_def_policy(void)
     guest_common_default_feature_adjustments(fs);
 
     sanitise_featureset(fs);
+
+    /*
+     * If the host suffers from RSBA of any form, and the guest can see
+     * MSR_ARCH_CAPS, reflect the appropriate RSBA/RRSBA property to the guest
+     * depending on the visibility of eIBRS.
+     */
+    if ( test_bit(X86_FEATURE_ARCH_CAPS, fs) &&
+         (cpu_has_rsba || cpu_has_rrsba) )
+    {
+        bool eibrs = test_bit(X86_FEATURE_EIBRS, fs);
+
+        __set_bit(eibrs ? X86_FEATURE_RRSBA
+                        : X86_FEATURE_RSBA, fs);
+    }
+
     x86_cpu_featureset_to_policy(fs, p);
     recalculate_xstate(p);
 }
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index cd3fcee813..357a86521e 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -302,7 +302,7 @@ XEN_CPUFEATURE(INTEL_PSFD,         13*32+ 0) /*A  MSR_SPEC_CTRL.PSFD */
 /* Intel-defined CPU features, MSR_ARCH_CAPS 0x10a.eax, word 16 */
 XEN_CPUFEATURE(RDCL_NO,            16*32+ 0) /*A  No Rogue Data Cache Load (Meltdown) */
 XEN_CPUFEATURE(EIBRS,              16*32+ 1) /*A  Enhanced IBRS */
-XEN_CPUFEATURE(RSBA,               16*32+ 2) /*!A RSB Alternative (Retpoline not safe) */
+XEN_CPUFEATURE(RSBA,               16*32+ 2) /*!  RSB Alternative (Retpoline not safe) */
 XEN_CPUFEATURE(SKIP_L1DFL,         16*32+ 3) /*   Don't need to flush L1D on VMEntry */
 XEN_CPUFEATURE(INTEL_SSB_NO,       16*32+ 4) /*A  No Speculative Store Bypass */
 XEN_CPUFEATURE(MDS_NO,             16*32+ 5) /*A  No Microarchitectural Data Sampling */
@@ -318,7 +318,7 @@ XEN_CPUFEATURE(FBSDP_NO,           16*32+14) /*A  No Fill Buffer Stale Data Prop
 XEN_CPUFEATURE(PSDP_NO,            16*32+15) /*A  No Primary Stale Data Propagation */
 XEN_CPUFEATURE(FB_CLEAR,           16*32+17) /*A  Fill Buffers cleared by VERW */
 XEN_CPUFEATURE(FB_CLEAR_CTRL,      16*32+18) /*   MSR_OPT_CPU_CTRL.FB_CLEAR_DIS */
-XEN_CPUFEATURE(RRSBA,              16*32+19) /*!A Restricted RSB Alternative */
+XEN_CPUFEATURE(RRSBA,              16*32+19) /*!  Restricted RSB Alternative */
 XEN_CPUFEATURE(BHI_NO,             16*32+20) /*A  No Branch History Injection  */
 XEN_CPUFEATURE(XAPIC_STATUS,       16*32+21) /*   MSR_XAPIC_DISABLE_STATUS */
 XEN_CPUFEATURE(OVRCLK_STATUS,      16*32+23) /*   MSR_OVERCLOCKING_STATUS */
diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py
index 54246ad209..1be3ddbb85 100755
--- a/xen/tools/gen-cpuid.py
+++ b/xen/tools/gen-cpuid.py
@@ -315,7 +315,7 @@ def crunch_numbers(state):
         # IBRSB/IBRS, and we pass this MSR directly to guests.  Treating them
         # as dependent features simplifies Xen's logic, and prevents the guest
         # from seeing implausible configurations.
-        IBRSB: [STIBP, SSBD, INTEL_PSFD],
+        IBRSB: [STIBP, SSBD, INTEL_PSFD, EIBRS],
         IBRS: [AMD_STIBP, AMD_SSBD, PSFD,
                IBRS_ALWAYS, IBRS_FAST, IBRS_SAME_MODE],
         AMD_STIBP: [STIBP_ALWAYS],
@@ -325,6 +325,9 @@ def crunch_numbers(state):
 
         # The ARCH_CAPS CPUID bit enumerates the availability of the whole register.
         ARCH_CAPS: list(range(RDCL_NO, RDCL_NO + 64)),
+
+        # The behaviour described by RRSBA depend on eIBRS being active.
+        EIBRS: [RRSBA],
     }
 
     deep_features = tuple(sorted(deps.keys()))
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:05:29 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:05:29 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680936.1059307 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGpF-0008N0-56; Wed, 14 Feb 2024 15:05:29 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680936.1059307; Wed, 14 Feb 2024 15:05:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGpF-0008Ms-2F; Wed, 14 Feb 2024 15:05:29 +0000
Received: by outflank-mailman (input) for mailman id 680936;
 Wed, 14 Feb 2024 15:05:28 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGpE-0008Mm-CB
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:28 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGpE-0005rG-BP
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:28 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGpE-0000ro-Ah
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:28 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=HzCPElPv8UVq+TN15gR3Y0X1CBj9f8ih3RODYc45WrY=; b=gQG3VM7gbGhIJkyOEcU8v/wa8d
	IfrPBlbgyMdfMkPEORJI5dyxu7Svzz6CGnja7ZTfmdBj6hso31IiFQPlNqB50M2DaD68LPilWsHJ1
	kUXgKvroan13x6kwHyIKcxma7AjDWC76Yc/M/Q+U2km1H+hSP1z3xj2CBVQ95euWib/s=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] libxl: don't ignore the return value from xc_cpuid_apply_policy
Message-Id: <E1raGpE-0000ro-Ah@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:05:28 +0000

commit 1e082c9eca04d731dd0b386878f16a40a585a6ab
Author:     Roger Pau Monne <roger.pau@citrix.com>
AuthorDate: Thu Mar 18 11:11:22 2021 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    libxl: don't ignore the return value from xc_cpuid_apply_policy
    
    Also change libxl__cpuid_legacy to propagate the error from
    xc_cpuid_apply_policy into callers.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    (cherry picked from commit 34990446ca91d9e201ff17bd4e3f43bfe3ad308e)
    
    libs/light: Propagate libxl__arch_domain_create() return code
    
    Commit 34990446ca91 started to overwrite the `rc` value from
    libxl__arch_domain_create(), thus error aren't propagated anymore.
    
    Check `rc` value before doing the next thing.
    
    Fixes: 34990446ca91 ("libxl: don't ignore the return value from xc_cpuid_apply_policy")
    Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Release-acked-by: Henry Wang <Henry.Wang@arm.com>
    (cherry picked from commit 8cdfbf95b19c01fbb741c41d5ea5a94f8823964c)
    
    libxl: fix guest kexec - skip cpuid policy
    
    When a domain performs a kexec (soft reset), libxl__build_pre() is
    called with the existing domid.  Calling libxl__cpuid_legacy() on the
    existing domain fails since the cpuid policy has already been set, and
    the guest isn't rebuilt and doesn't kexec.
    
    xc: error: Failed to set d1's policy (err leaf 0xffffffff, subleaf 0xffffffff, msr 0xffffffff) (17 = File exists): Internal error
    libxl: error: libxl_cpuid.c:494:libxl__cpuid_legacy: Domain 1:Failed to apply CPUID policy: File exists
    libxl: error: libxl_create.c:1641:domcreate_rebuild_done: Domain 1:cannot (re-)build domain: -3
    libxl: error: libxl_xshelp.c:201:libxl__xs_read_mandatory: xenstore read failed: `/libxl/1/type': No such file or directory
    libxl: warning: libxl_dom.c:49:libxl__domain_type: unable to get domain type for domid=1, assuming HVM
    
    During a soft_reset, skip calling libxl__cpuid_legacy() to avoid the
    issue.  Before commit 34990446ca91, the libxl__cpuid_legacy() failure
    would have been ignored, so kexec would continue.
    
    Fixes: 34990446ca91 ("libxl: don't ignore the return value from xc_cpuid_apply_policy")
    Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    (cherry picked from commit 1e454c2b5b1172e0fc7457e411ebaba61db8fc87)
---
 tools/libxl/libxl_cpuid.c    | 14 +++++++++++---
 tools/libxl/libxl_create.c   |  7 +++++--
 tools/libxl/libxl_dom.c      |  6 ++++--
 tools/libxl/libxl_internal.h |  5 +++--
 tools/libxl/libxl_nocpuid.c  |  5 +++--
 5 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c
index 1b7626f7d4..72fc220de8 100644
--- a/tools/libxl/libxl_cpuid.c
+++ b/tools/libxl/libxl_cpuid.c
@@ -432,10 +432,12 @@ int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_list *cpuid,
     return 0;
 }
 
-void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore,
-                         libxl_domain_build_info *info)
+int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore,
+                        libxl_domain_build_info *info)
 {
+    GC_INIT(ctx);
     bool pae = true;
+    int r;
 
     /*
      * For PV guests, PAE is Xen-controlled (it is the 'p' that differentiates
@@ -450,7 +452,13 @@ void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore,
     if (info->type == LIBXL_DOMAIN_TYPE_HVM)
         pae = libxl_defbool_val(info->u.hvm.pae);
 
-    xc_cpuid_apply_policy(ctx->xch, domid, restore, NULL, 0, pae, info->cpuid);
+    r = xc_cpuid_apply_policy(ctx->xch, domid, restore, NULL, 0,
+                              pae, info->cpuid);
+    if (r)
+        LOGEVD(ERROR, -r, domid, "Failed to apply CPUID policy");
+
+    GC_FREE;
+    return r ? ERROR_FAIL : 0;
 }
 
 static const char *input_names[2] = { "leaf", "subleaf" };
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index daf3ff0a55..1554bcca1b 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1438,6 +1438,7 @@ int libxl__srm_callout_callback_static_data_done(unsigned int missing,
 
     libxl_domain_config *d_config = dcs->guest_config;
     libxl_domain_build_info *info = &d_config->b_info;
+    int rc = 0;
 
     /*
      * CPUID/MSR information is not present in pre Xen-4.14 streams.
@@ -1447,9 +1448,9 @@ int libxl__srm_callout_callback_static_data_done(unsigned int missing,
      * stream doesn't contain any CPUID data.
      */
     if (missing & XGR_SDD_MISSING_CPUID)
-        libxl__cpuid_legacy(ctx, dcs->guest_domid, true, info);
+        rc = libxl__cpuid_legacy(ctx, dcs->guest_domid, true, info);
 
-    return 0;
+    return rc;
 }
 
 void libxl__srm_callout_callback_restore_results(xen_pfn_t store_mfn,
@@ -2141,6 +2142,8 @@ static int do_domain_soft_reset(libxl_ctx *ctx,
                               aop_console_how);
     cdcs->domid_out = &domid_out;
 
+    state->soft_reset = true;
+
     dom_path = libxl__xs_get_dompath(gc, domid);
     if (!dom_path) {
         LOGD(ERROR, domid, "failed to read domain path");
diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c
index f8661e90d4..e68ba07ee8 100644
--- a/tools/libxl/libxl_dom.c
+++ b/tools/libxl/libxl_dom.c
@@ -386,13 +386,15 @@ int libxl__build_pre(libxl__gc *gc, uint32_t domid,
     state->console_port = xc_evtchn_alloc_unbound(ctx->xch, domid, state->console_domid);
 
     rc = libxl__arch_domain_create(gc, d_config, domid);
+    if (rc) goto out;
 
     /* Construct a CPUID policy, but only for brand new domains.  Domains
      * being migrated-in/restored have CPUID handled during the
      * static_data_done() callback. */
-    if (!state->restore)
-        libxl__cpuid_legacy(ctx, domid, false, info);
+    if (!state->restore && !state->soft_reset)
+        rc = libxl__cpuid_legacy(ctx, domid, false, info);
 
+out:
     return rc;
 }
 
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 3bc3bbcf84..2f531174e6 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1403,6 +1403,7 @@ typedef struct {
     /* Whether this domain is being migrated/restored, or booting fresh.  Only
      * applicable to the primary domain, not support domains (e.g. stub QEMU). */
     bool restore;
+    bool soft_reset;
 } libxl__domain_build_state;
 
 _hidden void libxl__domain_build_state_init(libxl__domain_build_state *s);
@@ -2056,8 +2057,8 @@ typedef yajl_gen_status (*libxl__gen_json_callback)(yajl_gen hand, void *);
 _hidden char *libxl__object_to_json(libxl_ctx *ctx, const char *type,
                                     libxl__gen_json_callback gen, void *p);
 
-_hidden void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool retore,
-                                 libxl_domain_build_info *info);
+_hidden int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool retore,
+                                libxl_domain_build_info *info);
 
 /* Calls poll() again - useful to check whether a signaled condition
  * is still true.  Cannot fail.  Returns currently-true revents. */
diff --git a/tools/libxl/libxl_nocpuid.c b/tools/libxl/libxl_nocpuid.c
index f47336565b..0630959e76 100644
--- a/tools/libxl/libxl_nocpuid.c
+++ b/tools/libxl/libxl_nocpuid.c
@@ -34,9 +34,10 @@ int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_list *cpuid,
     return 0;
 }
 
-void libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore,
-                         libxl_domain_build_info *info)
+int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore,
+                        libxl_domain_build_info *info)
 {
+    return 0;
 }
 
 yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_gen hand,
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:05:39 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:05:39 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680937.1059310 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGpP-0008Qu-7Z; Wed, 14 Feb 2024 15:05:39 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680937.1059310; Wed, 14 Feb 2024 15:05:39 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGpP-0008Qm-55; Wed, 14 Feb 2024 15:05:39 +0000
Received: by outflank-mailman (input) for mailman id 680937;
 Wed, 14 Feb 2024 15:05:38 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGpO-0008Qc-FA
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:38 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGpO-0005rN-EM
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:38 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGpO-0000sZ-Dm
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:38 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=vTzOzYqjxGszAGfSYqx15VLXatlMviMEHInMD+7pNzo=; b=4kSqK9VhV5tnncetH2yiy1zc84
	noC8FM/RjNrX7UsrOK1eJ1JpHYW1uNMT2IMyadyo7AdczVYuDcKb/5ymPQYAS2bJ/jjtSMzurG13o
	/UfBTYdZ5UjsrvM07QCgvZZY1ccTZf6Ftw0qH1yt3qZkjj5HlFNYlycJq0Mv//5G43eM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] libs/guest: introduce support for setting guest MSRs
Message-Id: <E1raGpO-0000sZ-Dm@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:05:38 +0000

commit 44fde35fdd5abb99a9d7de79ffe95176260b50fe
Author:     Roger Pau Monne <roger.pau@citrix.com>
AuthorDate: Tue Jul 25 15:05:53 2023 +0200
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    libs/guest: introduce support for setting guest MSRs
    
    Like it's done with CPUID, introduce support for passing MSR values to
    xc_cpuid_apply_policy().  The chosen format for expressing MSR policy
    data matches the current one used for CPUID.  Note that existing
    callers of xc_cpuid_apply_policy() can pass NULL as the value for the
    newly introduced 'msr' parameter in order to preserve the same
    functionality, and in fact that's done in libxl on this patch.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    (cherry picked from commit ed742cf1b65c822759833027ca5cbb087c506a41)
---
 tools/libxc/include/xenctrl.h |  21 +++++-
 tools/libxc/xc_cpuid_x86.c    | 170 +++++++++++++++++++++++++++++++++++++++++-
 tools/libxl/libxl_cpuid.c     |   2 +-
 3 files changed, 189 insertions(+), 4 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 4c89b7294c..687010df77 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -1819,6 +1819,21 @@ struct xc_xend_cpuid {
     char *policy[4];
 };
 
+/*
+ * MSR policy data.
+ *
+ * The format of the policy string is the following:
+ *   '1' -> force to 1
+ *   '0' -> force to 0
+ *   'x' -> we don't care (use default)
+ *   'k' -> pass through host value
+ */
+struct xc_msr {
+    uint32_t index;
+    char policy[65];
+};
+#define XC_MSR_INPUT_UNUSED 0xffffffffu
+
 /*
  * Make adjustments to the CPUID settings for a domain.
  *
@@ -1830,13 +1845,15 @@ struct xc_xend_cpuid {
  * Either pass a full new @featureset (and @nr_features), or adjust individual
  * features (@pae).
  *
- * Then (optionally) apply legacy XEND overrides (@xend) to the result.
+ * Then (optionally) apply legacy XEND CPUID overrides (@xend) or MSR (@msr)
+ * to the result.
  */
 int xc_cpuid_apply_policy(xc_interface *xch,
                           uint32_t domid, bool restore,
                           const uint32_t *featureset,
                           unsigned int nr_features, bool pae,
-                          const struct xc_xend_cpuid *xend);
+                          const struct xc_xend_cpuid *xend,
+                          const struct xc_msr *msr);
 int xc_mca_op(xc_interface *xch, struct xen_mc *mc);
 int xc_mca_op_inject_v2(xc_interface *xch, unsigned int flags,
                         xc_cpumap_t cpumap, unsigned int nr_cpus);
diff --git a/tools/libxc/xc_cpuid_x86.c b/tools/libxc/xc_cpuid_x86.c
index 3067fb2169..07d204a67e 100644
--- a/tools/libxc/xc_cpuid_x86.c
+++ b/tools/libxc/xc_cpuid_x86.c
@@ -425,10 +425,171 @@ static int xc_cpuid_xend_policy(
     return rc;
 }
 
+static int compare_msr(const void *l, const void *r)
+{
+    const xen_msr_entry_t *lhs = l;
+    const xen_msr_entry_t *rhs = r;
+
+    if ( lhs->idx == rhs->idx )
+        return 0;
+
+    return lhs->idx < rhs->idx ? -1 : 1;
+}
+
+static xen_msr_entry_t *find_msr(
+    xen_msr_entry_t *msrs, unsigned int nr_msrs,
+    uint32_t index)
+{
+    const xen_msr_entry_t key = { .idx = index };
+
+    return bsearch(&key, msrs, nr_msrs, sizeof(*msrs), compare_msr);
+}
+
+
+static int xc_msr_policy(xc_interface *xch, domid_t domid,
+                         const struct xc_msr *msr)
+{
+    int rc;
+    bool hvm;
+    xc_dominfo_t di;
+    unsigned int nr_leaves, nr_msrs;
+    uint32_t err_leaf = -1, err_subleaf = -1, err_msr = -1;
+    /*
+     * Three full policies.  The host, default for the domain type,
+     * and domain current.
+     */
+    xen_msr_entry_t *host = NULL, *def = NULL, *cur = NULL;
+    unsigned int nr_host, nr_def, nr_cur;
+
+    if ( xc_domain_getinfo(xch, domid, 1, &di) != 1 ||
+         di.domid != domid )
+    {
+        ERROR("Failed to obtain d%d info", domid);
+        rc = -ESRCH;
+        goto out;
+    }
+    hvm = di.hvm;
+
+    rc = xc_get_cpu_policy_size(xch, &nr_leaves, &nr_msrs);
+    if ( rc )
+    {
+        PERROR("Failed to obtain policy info size");
+        rc = -errno;
+        goto out;
+    }
+
+    if ( (host = calloc(nr_msrs, sizeof(*host))) == NULL ||
+         (def  = calloc(nr_msrs, sizeof(*def)))  == NULL ||
+         (cur  = calloc(nr_msrs, sizeof(*cur)))  == NULL )
+    {
+        ERROR("Unable to allocate memory for %u CPUID leaves", nr_leaves);
+        rc = -ENOMEM;
+        goto out;
+    }
+
+    /* Get the domain's current policy. */
+    nr_leaves = 0;
+    nr_cur = nr_msrs;
+    rc = xc_get_domain_cpu_policy(xch, domid, &nr_leaves, NULL, &nr_cur, cur);
+    if ( rc )
+    {
+        PERROR("Failed to obtain d%d current policy", domid);
+        rc = -errno;
+        goto out;
+    }
+
+    /* Get the domain type's default policy. */
+    nr_leaves = 0;
+    nr_def = nr_msrs;
+    rc = xc_get_system_cpu_policy(xch, hvm ? XEN_SYSCTL_cpu_policy_hvm_default
+                                           : XEN_SYSCTL_cpu_policy_pv_default,
+                                  &nr_leaves, NULL, &nr_def, def);
+    if ( rc )
+    {
+        PERROR("Failed to obtain %s def policy", hvm ? "hvm" : "pv");
+        rc = -errno;
+        goto out;
+    }
+
+    /* Get the host policy. */
+    nr_leaves = 0;
+    nr_host = nr_msrs;
+    rc = xc_get_system_cpu_policy(xch, XEN_SYSCTL_cpu_policy_host,
+                                  &nr_leaves, NULL, &nr_host, host);
+    if ( rc )
+    {
+        PERROR("Failed to obtain host policy");
+        rc = -errno;
+        goto out;
+    }
+
+    for ( ; msr->index != XC_MSR_INPUT_UNUSED; ++msr )
+    {
+        xen_msr_entry_t *cur_msr = find_msr(cur, nr_cur, msr->index);
+        const xen_msr_entry_t *def_msr = find_msr(def, nr_def, msr->index);
+        const xen_msr_entry_t *host_msr = find_msr(host, nr_host, msr->index);
+        unsigned int i;
+
+        if ( cur_msr == NULL || def_msr == NULL || host_msr == NULL )
+        {
+            ERROR("Missing MSR %#x", msr->index);
+            rc = -ENOENT;
+            goto out;
+        }
+
+        for ( i = 0; i < ARRAY_SIZE(msr->policy) - 1; i++ )
+        {
+            bool val;
+
+            if ( msr->policy[i] == '1' )
+                val = true;
+            else if ( msr->policy[i] == '0' )
+                val = false;
+            else if ( msr->policy[i] == 'x' )
+                val = test_bit(63 - i, &def_msr->val);
+            else if ( msr->policy[i] == 'k' )
+                val = test_bit(63 - i, &host_msr->val);
+            else
+            {
+                ERROR("MSR index %#x: bad character '%c' in policy string '%s'",
+                      msr->index, msr->policy[i], msr->policy);
+                rc = -EINVAL;
+                goto out;
+            }
+
+            if ( val )
+                set_bit(63 - i, &cur_msr->val);
+            else
+                clear_bit(63 - i, &cur_msr->val);
+        }
+    }
+
+    /* Feed the transformed policy back up to Xen. */
+    rc = xc_set_domain_cpu_policy(xch, domid, 0, NULL, nr_cur, cur,
+                                  &err_leaf, &err_subleaf, &err_msr);
+    if ( rc )
+    {
+        PERROR("Failed to set d%d's policy (err leaf %#x, subleaf %#x, msr %#x)",
+               domid, err_leaf, err_subleaf, err_msr);
+        rc = -errno;
+        goto out;
+    }
+
+    /* Success! */
+
+ out:
+    free(cur);
+    free(def);
+    free(host);
+
+    return rc;
+}
+
 int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, bool restore,
                           const uint32_t *featureset, unsigned int nr_features,
                           bool pae,
-                          const struct xc_xend_cpuid *xend)
+                          const struct xc_xend_cpuid *xend,
+                          const struct xc_msr *msr)
 {
     int rc;
     xc_dominfo_t di;
@@ -671,6 +832,13 @@ int xc_cpuid_apply_policy(xc_interface *xch, uint32_t domid, bool restore,
     if ( xend && (rc = xc_cpuid_xend_policy(xch, domid, xend)) )
         goto out;
 
+    if ( msr )
+    {
+        rc = xc_msr_policy(xch, domid, msr);
+        if ( rc )
+            goto out;
+    }
+
     rc = 0;
 
 out:
diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c
index 72fc220de8..ba795469dd 100644
--- a/tools/libxl/libxl_cpuid.c
+++ b/tools/libxl/libxl_cpuid.c
@@ -453,7 +453,7 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore,
         pae = libxl_defbool_val(info->u.hvm.pae);
 
     r = xc_cpuid_apply_policy(ctx->xch, domid, restore, NULL, 0,
-                              pae, info->cpuid);
+                              pae, info->cpuid, NULL);
     if (r)
         LOGEVD(ERROR, -r, domid, "Failed to apply CPUID policy");
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:05:49 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:05:49 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680938.1059315 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGpZ-0008TM-99; Wed, 14 Feb 2024 15:05:49 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680938.1059315; Wed, 14 Feb 2024 15:05:49 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGpZ-0008TD-6X; Wed, 14 Feb 2024 15:05:49 +0000
Received: by outflank-mailman (input) for mailman id 680938;
 Wed, 14 Feb 2024 15:05:48 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGpY-0008T7-Id
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:48 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGpY-0005tO-Hw
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:48 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGpY-0000tM-Gx
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:48 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=VXn5EBeTEjqPSBQ6PUas2RX2zUWzZjvQRiFVx/ivDm8=; b=tJCjWnNw5puEDXZPrasZU4sKIU
	L8lgROcrmrWIH+uenXkWzrbti4YAlgozZzbaGTCH7q64pnW3c7qdCBu6eEr5a1VSdnbpJRVXsHO2V
	ZPdPYEOfXin+jxPNawBaWU9IxZoJtiXNw162vcXzPAsB6xlPAib07R1RZxOYN1chGc/w=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] libxl: change the type of libxl_cpuid_policy_list
Message-Id: <E1raGpY-0000tM-Gx@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:05:48 +0000

commit 9f6f7e07d0920fa3b000f6447982f13322ac5e86
Author:     Roger Pau Monne <roger.pau@citrix.com>
AuthorDate: Tue Jul 25 15:05:54 2023 +0200
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    libxl: change the type of libxl_cpuid_policy_list
    
    Currently libxl_cpuid_policy_list is an opaque type to the users of
    libxl, and internally it's an array of xc_xend_cpuid objects.
    
    Change the type to instead be a structure that contains one array for
    CPUID policies, in preparation for it also holding another array for
    MSR policies.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    (cherry picked from commit 4825d19603580949144ac2ac5cb22df75c9da954)
---
 tools/libxl/libxl.h          |  8 +---
 tools/libxl/libxl_cpuid.c    | 87 +++++++++++++++++++++++++++++---------------
 tools/libxl/libxl_internal.h |  4 ++
 3 files changed, 63 insertions(+), 36 deletions(-)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 1cd6c38e83..43f8ca269e 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -1310,12 +1310,8 @@ typedef struct {
 void libxl_bitmap_init(libxl_bitmap *map);
 void libxl_bitmap_dispose(libxl_bitmap *map);
 
-/*
- * libxl_cpuid_policy is opaque in the libxl ABI.  Users of both libxl and
- * libxc may not make assumptions about xc_xend_cpuid.
- */
-typedef struct xc_xend_cpuid libxl_cpuid_policy;
-typedef libxl_cpuid_policy * libxl_cpuid_policy_list;
+struct libxl__cpu_policy;
+typedef struct libxl__cpu_policy *libxl_cpuid_policy_list;
 void libxl_cpuid_dispose(libxl_cpuid_policy_list *cpuid_list);
 int libxl_cpuid_policy_list_length(const libxl_cpuid_policy_list *l);
 void libxl_cpuid_policy_list_copy(libxl_ctx *ctx,
diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c
index ba795469dd..4045136319 100644
--- a/tools/libxl/libxl_cpuid.c
+++ b/tools/libxl/libxl_cpuid.c
@@ -19,22 +19,29 @@ int libxl__cpuid_policy_is_empty(libxl_cpuid_policy_list *pl)
     return !libxl_cpuid_policy_list_length(pl);
 }
 
-void libxl_cpuid_dispose(libxl_cpuid_policy_list *p_cpuid_list)
+void libxl_cpuid_dispose(libxl_cpuid_policy_list *pl)
 {
-    int i, j;
-    libxl_cpuid_policy_list cpuid_list = *p_cpuid_list;
+    libxl_cpuid_policy_list policy = *pl;
 
-    if (cpuid_list == NULL)
+    if (policy == NULL)
         return;
-    for (i = 0; cpuid_list[i].input[0] != XEN_CPUID_INPUT_UNUSED; i++) {
-        for (j = 0; j < 4; j++)
-            if (cpuid_list[i].policy[j] != NULL) {
-                free(cpuid_list[i].policy[j]);
-                cpuid_list[i].policy[j] = NULL;
+
+    if (policy->cpuid) {
+        unsigned int i, j;
+        struct xc_xend_cpuid *cpuid_list = policy->cpuid;
+
+        for (i = 0; cpuid_list[i].input[0] != XEN_CPUID_INPUT_UNUSED; i++) {
+            for (j = 0; j < 4; j++) {
+                if (cpuid_list[i].policy[j] != NULL) {
+                    free(cpuid_list[i].policy[j]);
+                }
             }
+        }
+        free(policy->cpuid);
     }
-    free(cpuid_list);
-    *p_cpuid_list = NULL;
+
+    free(policy);
+    *pl = NULL;
     return;
 }
 
@@ -62,11 +69,17 @@ struct cpuid_flags {
 /* go through the dynamic array finding the entry for a specified leaf.
  * if no entry exists, allocate one and return that.
  */
-static libxl_cpuid_policy_list cpuid_find_match(libxl_cpuid_policy_list *list,
-                                          uint32_t leaf, uint32_t subleaf)
+static struct xc_xend_cpuid *cpuid_find_match(libxl_cpuid_policy_list *pl,
+                                              uint32_t leaf, uint32_t subleaf)
 {
+    libxl_cpuid_policy_list policy = *pl;
+    struct xc_xend_cpuid **list;
     int i = 0;
 
+    if (policy == NULL)
+        policy = *pl = calloc(1, sizeof(*policy));
+
+    list = &policy->cpuid;
     if (*list != NULL) {
         for (i = 0; (*list)[i].input[0] != XEN_CPUID_INPUT_UNUSED; i++) {
             if ((*list)[i].input[0] == leaf && (*list)[i].input[1] == subleaf)
@@ -86,7 +99,7 @@ static libxl_cpuid_policy_list cpuid_find_match(libxl_cpuid_policy_list *list,
  * Will overwrite earlier entries and thus can be called multiple
  * times.
  */
-int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str)
+int libxl_cpuid_parse_config(libxl_cpuid_policy_list *policy, const char* str)
 {
 #define NA XEN_CPUID_INPUT_UNUSED
     static const struct cpuid_flags cpuid_flags[] = {
@@ -321,7 +334,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str)
     if (flag->name == NULL) {
         return 2;
     }
-    entry = cpuid_find_match(cpuid, flag->leaf, flag->subleaf);
+    entry = cpuid_find_match(policy, flag->leaf, flag->subleaf);
     resstr = entry->policy[flag->reg - 1];
     num = strtoull(val, &endptr, 0);
     flags[flag->length] = 0;
@@ -376,7 +389,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str)
  * the strings for each register were directly exposed to the user.
  * Used for maintaining compatibility with older config files
  */
-int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_list *cpuid,
+int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_list *policy,
                                   const char* str)
 {
     char *endptr;
@@ -403,7 +416,7 @@ int libxl_cpuid_parse_config_xend(libxl_cpuid_policy_list *cpuid,
         return 3;
     }
     str = endptr + 1;
-    entry = cpuid_find_match(cpuid, leaf, subleaf);
+    entry = cpuid_find_match(policy, leaf, subleaf);
     for (str = endptr + 1; *str != 0;) {
         if (str[0] != 'e' || str[2] != 'x') {
             return 4;
@@ -453,7 +466,8 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore,
         pae = libxl_defbool_val(info->u.hvm.pae);
 
     r = xc_cpuid_apply_policy(ctx->xch, domid, restore, NULL, 0,
-                              pae, info->cpuid, NULL);
+                              pae,
+                              info->cpuid ? info->cpuid->cpuid : NULL, NULL);
     if (r)
         LOGEVD(ERROR, -r, domid, "Failed to apply CPUID policy");
 
@@ -478,16 +492,18 @@ static const char *policy_names[4] = { "eax", "ebx", "ecx", "edx" };
  */
 
 yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_gen hand,
-                                libxl_cpuid_policy_list *pcpuid)
+                                libxl_cpuid_policy_list *pl)
 {
-    libxl_cpuid_policy_list cpuid = *pcpuid;
+    libxl_cpuid_policy_list policy = *pl;
+    struct xc_xend_cpuid *cpuid;
     yajl_gen_status s;
     int i, j;
 
     s = yajl_gen_array_open(hand);
     if (s != yajl_gen_status_ok) goto out;
 
-    if (cpuid == NULL) goto empty;
+    if (policy == NULL || policy->cpuid == NULL) goto empty;
+    cpuid = policy->cpuid;
 
     for (i = 0; cpuid[i].input[0] != XEN_CPUID_INPUT_UNUSED; i++) {
         s = yajl_gen_map_open(hand);
@@ -526,7 +542,7 @@ int libxl__cpuid_policy_list_parse_json(libxl__gc *gc,
                                         libxl_cpuid_policy_list *p)
 {
     int i, size;
-    libxl_cpuid_policy_list l;
+    struct xc_xend_cpuid *l;
     flexarray_t *array;
 
     if (!libxl__json_object_is_array(o))
@@ -537,8 +553,10 @@ int libxl__cpuid_policy_list_parse_json(libxl__gc *gc,
         return 0;
 
     size = array->count;
+    *p = libxl__calloc(NOGC, 1, sizeof(**p));
     /* need one extra slot as sentinel */
-    l = *p = libxl__calloc(NOGC, size + 1, sizeof(libxl_cpuid_policy));
+    l = (*p)->cpuid = libxl__calloc(NOGC, size + 1,
+                                    sizeof(struct xc_xend_cpuid));
 
     l[size].input[0] = XEN_CPUID_INPUT_UNUSED;
     l[size].input[1] = XEN_CPUID_INPUT_UNUSED;
@@ -581,8 +599,12 @@ int libxl__cpuid_policy_list_parse_json(libxl__gc *gc,
 int libxl_cpuid_policy_list_length(const libxl_cpuid_policy_list *pl)
 {
     int i = 0;
-    libxl_cpuid_policy_list l = *pl;
+    const struct xc_xend_cpuid *l;
+
+    if (*pl == NULL)
+        return 0;
 
+    l = (*pl)->cpuid;
     if (l) {
         while (l[i].input[0] != XEN_CPUID_INPUT_UNUSED)
             i++;
@@ -592,20 +614,25 @@ int libxl_cpuid_policy_list_length(const libxl_cpuid_policy_list *pl)
 }
 
 void libxl_cpuid_policy_list_copy(libxl_ctx *ctx,
-                                  libxl_cpuid_policy_list *dst,
-                                  const libxl_cpuid_policy_list *src)
+                                  libxl_cpuid_policy_list *pdst,
+                                  const libxl_cpuid_policy_list *psrc)
 {
+    struct xc_xend_cpuid **dst;
+    struct xc_xend_cpuid *const *src;
     GC_INIT(ctx);
     int i, j, len;
 
-    if (*src == NULL) {
-        *dst = NULL;
+    if (*psrc == NULL) {
+        *pdst = NULL;
         goto out;
     }
 
-    len = libxl_cpuid_policy_list_length(src);
+    *pdst = libxl__calloc(NOGC, 1, sizeof(**pdst));
+    dst = &(*pdst)->cpuid;
+    src = &(*psrc)->cpuid;
+    len = libxl_cpuid_policy_list_length(psrc);
     /* one extra slot for sentinel */
-    *dst = libxl__calloc(NOGC, len + 1, sizeof(libxl_cpuid_policy));
+    *dst = libxl__calloc(NOGC, len + 1, sizeof(struct xc_xend_cpuid));
     (*dst)[len].input[0] = XEN_CPUID_INPUT_UNUSED;
     (*dst)[len].input[1] = XEN_CPUID_INPUT_UNUSED;
 
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 2f531174e6..5c8c19bc00 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -4838,6 +4838,10 @@ _hidden int libxl__domain_pvcontrol(libxl__egc *egc,
 /* Check whether a domid is recent */
 int libxl__is_domid_recent(libxl__gc *gc, uint32_t domid, bool *recent);
 
+struct libxl__cpu_policy {
+    struct xc_xend_cpuid *cpuid;
+};
+
 #endif
 
 /*
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:05:59 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:05:59 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680939.1059319 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGpj-0008Vv-Aw; Wed, 14 Feb 2024 15:05:59 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680939.1059319; Wed, 14 Feb 2024 15:05:59 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGpj-0008Vn-82; Wed, 14 Feb 2024 15:05:59 +0000
Received: by outflank-mailman (input) for mailman id 680939;
 Wed, 14 Feb 2024 15:05:58 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGpi-0008Vh-Lt
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:58 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGpi-0005tb-LA
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:58 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGpi-0000uF-KV
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:05:58 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=J6vHIHkDlU4igYa/Ai9Iah3ovO27fRDLdtXMsF1FH50=; b=rxlACI6SD0kqWn4rumu3EBnQVN
	/n4JjkDxJDZZmSlMSvuj2GIZ31kmO8Ij7Ut240r2FZtibicqsD3eEwQhMGS1QUpkAm9sDO8S6F+mp
	vN/3leHtB55O11DF/Pq1c+7ivPerbyyDZ0yyTVRSdGDy9mOVDZsj/IYb0iC4Gx3vkK6s=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] libxl: introduce MSR data in libxl_cpuid_policy
Message-Id: <E1raGpi-0000uF-KV@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:05:58 +0000

commit 53307f5c5d71b0e05b7840fcae4ad76e0fca9fa0
Author:     Roger Pau Monne <roger.pau@citrix.com>
AuthorDate: Wed Jul 26 09:47:53 2023 +0200
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    libxl: introduce MSR data in libxl_cpuid_policy
    
    Add a new array field to libxl_cpuid_policy in order to store the MSR
    policies.
    
    Adding the MSR data in the libxl_cpuid_policy_list type is done so
    that existing users can seamlessly pass MSR features as part of the
    CPUID data, without requiring the introduction of a separate
    domain_build_info field, and a new set of handlers functions.
    
    Note that support for parsing the old JSON format is kept, as that's
    required in order to restore domains or received migrations from
    previous tool versions.  Differentiation between the old and the new
    formats is done based on whether the contents of the 'cpuid' field is
    an array or a map JSON object.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    (cherry picked from commit 5b80cecb747b2176b9e85f6e7aa7be83416d77e1)
---
 tools/libxl/libxl_cpuid.c    | 160 ++++++++++++++++++++++++++++++++++++++-----
 tools/libxl/libxl_internal.h |   1 +
 tools/libxl/libxl_types.idl  |   2 +-
 3 files changed, 146 insertions(+), 17 deletions(-)

diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c
index 4045136319..b4c3a12565 100644
--- a/tools/libxl/libxl_cpuid.c
+++ b/tools/libxl/libxl_cpuid.c
@@ -16,7 +16,7 @@
 
 int libxl__cpuid_policy_is_empty(libxl_cpuid_policy_list *pl)
 {
-    return !libxl_cpuid_policy_list_length(pl);
+    return !*pl || (!libxl_cpuid_policy_list_length(pl) && !(*pl)->msr);
 }
 
 void libxl_cpuid_dispose(libxl_cpuid_policy_list *pl)
@@ -40,6 +40,8 @@ void libxl_cpuid_dispose(libxl_cpuid_policy_list *pl)
         free(policy->cpuid);
     }
 
+    free(policy->msr);
+
     free(policy);
     *pl = NULL;
     return;
@@ -467,7 +469,8 @@ int libxl__cpuid_legacy(libxl_ctx *ctx, uint32_t domid, bool restore,
 
     r = xc_cpuid_apply_policy(ctx->xch, domid, restore, NULL, 0,
                               pae,
-                              info->cpuid ? info->cpuid->cpuid : NULL, NULL);
+                              info->cpuid ? info->cpuid->cpuid : NULL,
+                              info->cpuid ? info->cpuid->msr : NULL);
     if (r)
         LOGEVD(ERROR, -r, domid, "Failed to apply CPUID policy");
 
@@ -479,16 +482,22 @@ static const char *input_names[2] = { "leaf", "subleaf" };
 static const char *policy_names[4] = { "eax", "ebx", "ecx", "edx" };
 /*
  * Aiming for:
- * [
- *     { 'leaf':    'val-eax',
- *       'subleaf': 'val-ecx',
- *       'eax':     'filter',
- *       'ebx':     'filter',
- *       'ecx':     'filter',
- *       'edx':     'filter' },
- *     { 'leaf':    'val-eax', ..., 'eax': 'filter', ... },
- *     ... etc ...
- * ]
+ * {   'cpuid': [
+ *              { 'leaf':    'val-eax',
+ *                'subleaf': 'val-ecx',
+ *                'eax':     'filter',
+ *                'ebx':     'filter',
+ *                'ecx':     'filter',
+ *                'edx':     'filter' },
+ *              { 'leaf':    'val-eax', ..., 'eax': 'filter', ... },
+ *              ... etc ...
+ *     ],
+ *     'msr': [
+ *            { 'index': 'val-index',
+ *              'policy': 'filter', },
+ *              ... etc ...
+ *     ],
+ * }
  */
 
 yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_gen hand,
@@ -496,9 +505,16 @@ yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_gen hand,
 {
     libxl_cpuid_policy_list policy = *pl;
     struct xc_xend_cpuid *cpuid;
+    const struct xc_msr *msr;
     yajl_gen_status s;
     int i, j;
 
+    s = yajl_gen_map_open(hand);
+    if (s != yajl_gen_status_ok) goto out;
+
+    s = libxl__yajl_gen_asciiz(hand, "cpuid");
+    if (s != yajl_gen_status_ok) goto out;
+
     s = yajl_gen_array_open(hand);
     if (s != yajl_gen_status_ok) goto out;
 
@@ -533,6 +549,39 @@ yajl_gen_status libxl_cpuid_policy_list_gen_json(yajl_gen hand,
 
 empty:
     s = yajl_gen_array_close(hand);
+    if (s != yajl_gen_status_ok) goto out;
+
+    s = libxl__yajl_gen_asciiz(hand, "msr");
+    if (s != yajl_gen_status_ok) goto out;
+
+    s = yajl_gen_array_open(hand);
+    if (s != yajl_gen_status_ok) goto out;
+
+    if (!policy || !policy->msr) goto done;
+    msr = policy->msr;
+
+    for (i = 0; msr[i].index != XC_MSR_INPUT_UNUSED; i++) {
+        s = yajl_gen_map_open(hand);
+        if (s != yajl_gen_status_ok) goto out;
+
+        s = libxl__yajl_gen_asciiz(hand, "index");
+        if (s != yajl_gen_status_ok) goto out;
+        s = yajl_gen_integer(hand, msr[i].index);
+        if (s != yajl_gen_status_ok) goto out;
+        s = libxl__yajl_gen_asciiz(hand, "policy");
+        if (s != yajl_gen_status_ok) goto out;
+        s = yajl_gen_string(hand,
+                            (const unsigned char *)msr[i].policy, 64);
+        if (s != yajl_gen_status_ok) goto out;
+
+        s = yajl_gen_map_close(hand);
+        if (s != yajl_gen_status_ok) goto out;
+    }
+
+done:
+    s = yajl_gen_array_close(hand);
+    if (s != yajl_gen_status_ok) goto out;
+    s = yajl_gen_map_close(hand);
 out:
     return s;
 }
@@ -543,17 +592,40 @@ int libxl__cpuid_policy_list_parse_json(libxl__gc *gc,
 {
     int i, size;
     struct xc_xend_cpuid *l;
+    struct xc_msr *msr;
+    const libxl__json_object *co;
     flexarray_t *array;
+    bool cpuid_only = false;
+
+    /*
+     * Old JSON field was an array with just the CPUID data.  With the addition
+     * of MSRs the object is now a map with two array fields.
+     *
+     * Use the object format to detect whether the passed data contains just
+     * CPUID leafs and thus is an array, or does also contain MSRs and is a
+     * map.
+     */
+    if (libxl__json_object_is_array(o)) {
+        co = o;
+        cpuid_only = true;
+        goto parse_cpuid;
+    }
 
-    if (!libxl__json_object_is_array(o))
+    if (!libxl__json_object_is_map(o))
         return ERROR_FAIL;
 
-    array = libxl__json_object_get_array(o);
+    co = libxl__json_map_get("cpuid", o, JSON_ARRAY);
+    if (!libxl__json_object_is_array(co))
+        return ERROR_FAIL;
+
+parse_cpuid:
+    *p = libxl__calloc(NOGC, 1, sizeof(**p));
+
+    array = libxl__json_object_get_array(co);
     if (!array->count)
-        return 0;
+        goto cpuid_empty;
 
     size = array->count;
-    *p = libxl__calloc(NOGC, 1, sizeof(**p));
     /* need one extra slot as sentinel */
     l = (*p)->cpuid = libxl__calloc(NOGC, size + 1,
                                     sizeof(struct xc_xend_cpuid));
@@ -592,6 +664,42 @@ int libxl__cpuid_policy_list_parse_json(libxl__gc *gc,
                     libxl__strdup(NOGC, libxl__json_object_get_string(r));
         }
     }
+    if (cpuid_only)
+        return 0;
+
+cpuid_empty:
+    co = libxl__json_map_get("msr", o, JSON_ARRAY);
+    if (!libxl__json_object_is_array(co))
+        return ERROR_FAIL;
+
+    array = libxl__json_object_get_array(co);
+    if (!array->count)
+        return 0;
+    size = array->count;
+    /* need one extra slot as sentinel */
+    msr = (*p)->msr = libxl__calloc(NOGC, size + 1, sizeof(struct xc_msr));
+
+    msr[size].index = XC_MSR_INPUT_UNUSED;
+
+    for (i = 0; i < size; i++) {
+        const libxl__json_object *t, *r;
+
+        if (flexarray_get(array, i, (void**)&t) != 0)
+            return ERROR_FAIL;
+
+        if (!libxl__json_object_is_map(t))
+            return ERROR_FAIL;
+
+        r = libxl__json_map_get("index", t, JSON_INTEGER);
+        if (!r) return ERROR_FAIL;
+        msr[i].index = libxl__json_object_get_integer(r);
+        r = libxl__json_map_get("policy", t, JSON_STRING);
+        if (!r) return ERROR_FAIL;
+        if (strlen(libxl__json_object_get_string(r)) !=
+            ARRAY_SIZE(msr[i].policy) - 1)
+            return ERROR_FAIL;
+        strcpy(msr[i].policy, libxl__json_object_get_string(r));
+    }
 
     return 0;
 }
@@ -628,6 +736,10 @@ void libxl_cpuid_policy_list_copy(libxl_ctx *ctx,
     }
 
     *pdst = libxl__calloc(NOGC, 1, sizeof(**pdst));
+
+    if (!(*psrc)->cpuid)
+        goto copy_msr;
+
     dst = &(*pdst)->cpuid;
     src = &(*psrc)->cpuid;
     len = libxl_cpuid_policy_list_length(psrc);
@@ -647,6 +759,22 @@ void libxl_cpuid_policy_list_copy(libxl_ctx *ctx,
                 (*dst)[i].policy[j] = NULL;
     }
 
+copy_msr:
+    if ((*psrc)->msr) {
+        const struct xc_msr *msr = (*psrc)->msr;
+
+        for (i = 0; msr[i].index != XC_MSR_INPUT_UNUSED; i++)
+            ;
+        len = i;
+        (*pdst)->msr = libxl__calloc(NOGC, len + 1, sizeof(struct xc_msr));
+        (*pdst)->msr[len].index = XC_MSR_INPUT_UNUSED;
+
+        for (i = 0; i < len; i++) {
+            (*pdst)->msr[i].index = msr[i].index;
+            strcpy((*pdst)->msr[i].policy, msr[i].policy);
+        }
+    }
+
 out:
     GC_FREE;
 }
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 5c8c19bc00..e9bd138df9 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -4840,6 +4840,7 @@ int libxl__is_domid_recent(libxl__gc *gc, uint32_t domid, bool *recent);
 
 struct libxl__cpu_policy {
     struct xc_xend_cpuid *cpuid;
+    struct xc_msr *msr;
 };
 
 #endif
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 9d3f05f399..5b7553920c 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -19,7 +19,7 @@ libxl_mac = Builtin("mac", json_parse_type="JSON_STRING", passby=PASS_BY_REFEREN
 libxl_bitmap = Builtin("bitmap", json_parse_type="JSON_ARRAY", dispose_fn="libxl_bitmap_dispose", passby=PASS_BY_REFERENCE,
                        check_default_fn="libxl_bitmap_is_empty", copy_fn="libxl_bitmap_copy_alloc")
 libxl_cpuid_policy_list = Builtin("cpuid_policy_list", dispose_fn="libxl_cpuid_dispose", passby=PASS_BY_REFERENCE,
-                                  json_parse_type="JSON_ARRAY", check_default_fn="libxl__cpuid_policy_is_empty",
+                                  json_parse_type="JSON_ANY", check_default_fn="libxl__cpuid_policy_is_empty",
                                   copy_fn="libxl_cpuid_policy_list_copy")
 
 libxl_string_list = Builtin("string_list", dispose_fn="libxl_string_list_dispose", passby=PASS_BY_REFERENCE,
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:06:09 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:06:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680940.1059323 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGpt-000088-DR; Wed, 14 Feb 2024 15:06:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680940.1059323; Wed, 14 Feb 2024 15:06:09 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGpt-000080-Au; Wed, 14 Feb 2024 15:06:09 +0000
Received: by outflank-mailman (input) for mailman id 680940;
 Wed, 14 Feb 2024 15:06:08 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGps-00007k-P0
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:08 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGps-0005tz-O9
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:08 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGps-0000vp-NX
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:08 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=YhunNRbonrTIXazlrSxAEeY91X/+fJgk7yE1vXkOrPU=; b=M1gRCtsmiJ+9ud1MVWg49TleMH
	wPrDlFGqaLrMG1Ml7dxPPrmyKsB78xZKi7B8TJPn2M21vtkh4472lCBnORZeYuLmcLFRJJj39auUY
	U27JGm9TgJsGRKkZeO+/zChAoTF2duwsThbkhmrWhDFT6DkoPdV5pQ6PY16X5pfH3u/M=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] libxl: split logic to parse user provided CPUID features
Message-Id: <E1raGps-0000vp-NX@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:06:08 +0000

commit 548ac090515986570d1ab4fab469c45ebcca0fc7
Author:     Roger Pau Monne <roger.pau@citrix.com>
AuthorDate: Tue Jul 25 15:05:56 2023 +0200
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    libxl: split logic to parse user provided CPUID features
    
    Move the CPUID value parsers out of libxl_cpuid_parse_config() into a
    newly created cpuid_add() local helper.  This is in preparation for
    also adding MSR feature parsing support.
    
    No functional change intended.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    (cherry picked from commit e2b1da9b8fda0ed7d3dca7bd15829cfea496973a)
---
 tools/libxl/libxl_cpuid.c | 120 ++++++++++++++++++++++++----------------------
 1 file changed, 63 insertions(+), 57 deletions(-)

diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c
index b4c3a12565..afbebd36a8 100644
--- a/tools/libxl/libxl_cpuid.c
+++ b/tools/libxl/libxl_cpuid.c
@@ -96,6 +96,66 @@ static struct xc_xend_cpuid *cpuid_find_match(libxl_cpuid_policy_list *pl,
     return *list + i;
 }
 
+static int cpuid_add(libxl_cpuid_policy_list *policy,
+                     const struct cpuid_flags *flag, const char *val)
+{
+    struct xc_xend_cpuid *entry = cpuid_find_match(policy, flag->leaf,
+                                                   flag->subleaf);
+    unsigned long num;
+    char flags[33], *resstr, *endptr;
+    unsigned int i;
+
+    resstr = entry->policy[flag->reg - 1];
+    num = strtoul(val, &endptr, 0);
+    flags[flag->length] = 0;
+    if (endptr != val) {
+        /* if this was a valid number, write the binary form into the string */
+        for (i = 0; i < flag->length; i++) {
+            flags[flag->length - 1 - i] = "01"[(num >> i) & 1];
+        }
+    } else {
+        switch(val[0]) {
+        case 'x': case 'k': case 's':
+            memset(flags, val[0], flag->length);
+            break;
+        default:
+            return 3;
+        }
+    }
+
+    if (resstr == NULL) {
+        resstr = strdup("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
+    }
+
+    /* the family and model entry is potentially split up across
+     * two fields in Fn0000_0001_EAX, so handle them here separately.
+     */
+    if (!strcmp(flag->name, "family")) {
+        if (num < 16) {
+            memcpy(resstr + (32 - 4) - flag->bit, flags + 4, 4);
+            memcpy(resstr + (32 - 8) - 20, "00000000", 8);
+        } else {
+            num -= 15;
+            memcpy(resstr + (32 - 4) - flag->bit, "1111", 4);
+            for (i = 0; i < 7; i++) {
+                flags[7 - i] = "01"[num & 1];
+                num >>= 1;
+            }
+            memcpy(resstr + (32 - 8) - 20, flags, 8);
+        }
+    } else if (!strcmp(flag->name, "model")) {
+        memcpy(resstr + (32 - 4) - 16, flags, 4);
+        memcpy(resstr + (32 - 4) - flag->bit, flags + 4, 4);
+    } else {
+        memcpy(resstr + (32 - flag->length) - flag->bit, flags,
+               flag->length);
+    }
+    entry->policy[flag->reg - 1] = resstr;
+
+    return 0;
+
+}
+
 /* parse a single key=value pair and translate it into the libxc
  * used interface using 32-characters strings for each register.
  * Will overwrite earlier entries and thus can be called multiple
@@ -316,12 +376,8 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *policy, const char* str)
         {NULL, 0, NA, CPUID_REG_INV, 0, 0}
     };
 #undef NA
-    char *sep, *val, *endptr;
-    int i;
+    const char *sep, *val;
     const struct cpuid_flags *flag;
-    struct xc_xend_cpuid *entry;
-    unsigned long num;
-    char flags[33], *resstr;
 
     sep = strchr(str, '=');
     if (sep == NULL) {
@@ -331,60 +387,10 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *policy, const char* str)
     }
     for (flag = cpuid_flags; flag->name != NULL; flag++) {
         if(!strncmp(str, flag->name, sep - str) && flag->name[sep - str] == 0)
-            break;
-    }
-    if (flag->name == NULL) {
-        return 2;
-    }
-    entry = cpuid_find_match(policy, flag->leaf, flag->subleaf);
-    resstr = entry->policy[flag->reg - 1];
-    num = strtoull(val, &endptr, 0);
-    flags[flag->length] = 0;
-    if (endptr != val) {
-        /* if this was a valid number, write the binary form into the string */
-        for (i = 0; i < flag->length; i++) {
-            flags[flag->length - 1 - i] = "01"[!!(num & (1 << i))];
-        }
-    } else {
-        switch(val[0]) {
-        case 'x': case 'k': case 's':
-            memset(flags, val[0], flag->length);
-            break;
-        default:
-            return 3;
-        }
-    }
-
-    if (resstr == NULL) {
-        resstr = strdup("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
+            return cpuid_add(policy, flag, val);
     }
 
-    /* the family and model entry is potentially split up across
-     * two fields in Fn0000_0001_EAX, so handle them here separately.
-     */
-    if (!strncmp(str, "family", sep - str)) {
-        if (num < 16) {
-            memcpy(resstr + (32 - 4) - flag->bit, flags + 4, 4);
-            memcpy(resstr + (32 - 8) - 20, "00000000", 8);
-        } else {
-            num -= 15;
-            memcpy(resstr + (32 - 4) - flag->bit, "1111", 4);
-            for (i = 0; i < 7; i++) {
-                flags[7 - i] = "01"[num & 1];
-                num >>= 1;
-            }
-            memcpy(resstr + (32 - 8) - 20, flags, 8);
-        }
-    } else if (!strncmp(str, "model", sep - str)) {
-        memcpy(resstr + (32 - 4) - 16, flags, 4);
-        memcpy(resstr + (32 - 4) - flag->bit, flags + 4, 4);
-    } else {
-        memcpy(resstr + (32 - flag->length) - flag->bit, flags,
-               flag->length);
-    }
-    entry->policy[flag->reg - 1] = resstr;
-
-    return 0;
+    return 2;
 }
 
 /* parse a single list item from the legacy Python xend syntax, where
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:06:19 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:06:19 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680941.1059327 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGq3-0000Az-F2; Wed, 14 Feb 2024 15:06:19 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680941.1059327; Wed, 14 Feb 2024 15:06:19 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGq3-0000Ar-CM; Wed, 14 Feb 2024 15:06:19 +0000
Received: by outflank-mailman (input) for mailman id 680941;
 Wed, 14 Feb 2024 15:06:18 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGq2-0000Aj-Rx
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:18 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGq2-0005uG-RB
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:18 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGq2-0000wo-QZ
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:18 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=n01v3SaHoWAMjwBCbxTJYCNZ8WPYoJUAWD7yevJJiI4=; b=kxdQ5j3CuUjnMJqs2nyjWWz6eQ
	4RDMLYFyrP0Gt25mTpfQq0XeD7SuSsfXuSnPI3fLV+0sejR/53sCfWR1WkRjLfstFX09Cxb5CcxFS
	rpMuctJZaa2Gltg3bgkwxs5bCuaz3Nd0S3Wljsya9lmjt/MAvsQotrK0PHW+9iwmyBJI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] libxl: use the cpuid feature names from cpufeatureset.h
Message-Id: <E1raGq2-0000wo-QZ@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:06:18 +0000

commit 1299ea8d766d15edd130248e3a76770f1ca2a7f2
Author:     Roger Pau Monne <roger.pau@citrix.com>
AuthorDate: Tue Jul 25 15:05:57 2023 +0200
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    libxl: use the cpuid feature names from cpufeatureset.h
    
    The current implementation in libxl_cpuid_parse_config() requires
    keeping a list of cpuid feature bits that should be mostly in sync
    with the contents of cpufeatureset.h.
    
    Avoid such duplication by using the automatically generated list of
    cpuid features in INIT_FEATURE_NAMES in order to map feature names to
    featureset bits, and then translate from featureset bits into cpuid
    leaf, subleaf, register tuple.
    
    Note that the full contents of the previous cpuid translation table
    can't be removed.  That's because some feature names allowed by libxl
    are not described in the featuresets, or because naming has diverged
    and the previous nomenclature is preserved for compatibility reasons.
    
    Should result in no functional change observed by callers, albeit some
    new cpuid features will be available as a result of the change.
    
    While there constify cpuid_flags name field.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    (cherry picked from commit d638fe233cb3a45105319df75df0edfed2fde5a5)
---
 docs/man/xl.cfg.5.pod.in  |  24 ++---
 tools/libxl/libxl_cpuid.c | 243 ++++++++++++++++++----------------------------
 tools/xl/xl_parse.c       |   3 +
 3 files changed, 107 insertions(+), 163 deletions(-)

diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
index 2224080b30..be454ede2a 100644
--- a/docs/man/xl.cfg.5.pod.in
+++ b/docs/man/xl.cfg.5.pod.in
@@ -2014,24 +2014,16 @@ proccount procpkg stepping
 
 =back
 
-List of keys taking a character:
+List of keys taking a character can be found in the public header file
+L<arch-x86/cpufeatureset.h|https://xenbits.xen.org/docs/unstable/hypercall/x86_64/include,public,arch-x86,cpufeatureset.h.html>
 
-=over 4
-
-3dnow 3dnowext 3dnowprefetch abm acpi adx aes altmovcr8 apic arat avx avx2
-avx512-4fmaps avx512-4vnniw avx512bw avx512cd avx512dq avx512er avx512f
-avx512ifma avx512pf avx512vbmi avx512vl bmi1 bmi2 clflushopt clfsh clwb cmov
-cmplegacy cmpxchg16 cmpxchg8 cmt cntxid dca de ds dscpl dtes64 erms est extapic
-f16c ffxsr fma fma4 fpu fsgsbase fxsr hle htt hypervisor ia64 ibs invpcid
-invtsc lahfsahf lm lwp mca mce misalignsse mmx mmxext monitor movbe mpx msr
-mtrr nodeid nx ospke osvw osxsave pae page1gb pat pbe pcid pclmulqdq pdcm
-perfctr_core perfctr_nb pge pku popcnt pse pse36 psn rdrand rdseed rdtscp rtm
-sha skinit smap smep smx ss sse sse2 sse3 sse4.1 sse4.2 sse4_1 sse4_2 sse4a
-ssse3 svm svm_decode svm_lbrv svm_npt svm_nrips svm_pausefilt svm_tscrate
-svm_vmcbclean syscall sysenter tbm tm tm2 topoext tsc tsc-deadline tsc_adjust
-umip vme vmx wdt x2apic xop xsave xtpr
+The feature names described in C<cpufeatureset.h> should be specified in all
+lowercase letters, and with underscores converted to hyphens.  For example in
+order to reference feature C<LAHF_LM> the string C<lahf-lm> should be used.
 
-=back
+Note that C<clflush> is described as an option that takes a value, and that
+takes precedence over the C<clflush> flag in C<cpufeatureset.h>.  The feature
+flag must be referenced as C<clfsh>.
 
 =back
 
diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c
index afbebd36a8..5d0fc34bd4 100644
--- a/tools/libxl/libxl_cpuid.c
+++ b/tools/libxl/libxl_cpuid.c
@@ -14,6 +14,8 @@
 
 #include "libxl_internal.h"
 
+#include <xen/lib/x86/cpu-policy.h>
+
 int libxl__cpuid_policy_is_empty(libxl_cpuid_policy_list *pl)
 {
     return !*pl || (!libxl_cpuid_policy_list_length(pl) && !(*pl)->msr);
@@ -60,7 +62,7 @@ void libxl_cpuid_dispose(libxl_cpuid_policy_list *pl)
  * Used for the static structure describing all features.
  */
 struct cpuid_flags {
-    char* name;
+    const char *name;
     uint32_t leaf;
     uint32_t subleaf;
     int reg;
@@ -153,7 +155,19 @@ static int cpuid_add(libxl_cpuid_policy_list *policy,
     entry->policy[flag->reg - 1] = resstr;
 
     return 0;
+}
+
+struct feature_name {
+    const char *name;
+    unsigned int bit;
+};
+
+static int search_feature(const void *a, const void *b)
+{
+    const char *key = a;
+    const char *feat = ((const struct feature_name *)b)->name;
 
+    return strcmp(key, feat);
 }
 
 /* parse a single key=value pair and translate it into the libxc
@@ -176,187 +190,42 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *policy, const char* str)
         {"proccount",    0x00000001, NA, CPUID_REG_EBX, 16,  8},
         {"localapicid",  0x00000001, NA, CPUID_REG_EBX, 24,  8},
 
-        {"sse3",         0x00000001, NA, CPUID_REG_ECX,  0,  1},
-        {"pclmulqdq",    0x00000001, NA, CPUID_REG_ECX,  1,  1},
-        {"dtes64",       0x00000001, NA, CPUID_REG_ECX,  2,  1},
-        {"monitor",      0x00000001, NA, CPUID_REG_ECX,  3,  1},
-        {"dscpl",        0x00000001, NA, CPUID_REG_ECX,  4,  1},
-        {"vmx",          0x00000001, NA, CPUID_REG_ECX,  5,  1},
-        {"smx",          0x00000001, NA, CPUID_REG_ECX,  6,  1},
         {"est",          0x00000001, NA, CPUID_REG_ECX,  7,  1},
-        {"tm2",          0x00000001, NA, CPUID_REG_ECX,  8,  1},
-        {"ssse3",        0x00000001, NA, CPUID_REG_ECX,  9,  1},
         {"cntxid",       0x00000001, NA, CPUID_REG_ECX, 10,  1},
-        {"fma",          0x00000001, NA, CPUID_REG_ECX, 12,  1},
         {"cmpxchg16",    0x00000001, NA, CPUID_REG_ECX, 13,  1},
-        {"xtpr",         0x00000001, NA, CPUID_REG_ECX, 14,  1},
-        {"pdcm",         0x00000001, NA, CPUID_REG_ECX, 15,  1},
-        {"pcid",         0x00000001, NA, CPUID_REG_ECX, 17,  1},
-        {"dca",          0x00000001, NA, CPUID_REG_ECX, 18,  1},
         /* Linux uses sse4_{1,2}.  Keep sse4.{1,2} for compatibility */
         {"sse4_1",       0x00000001, NA, CPUID_REG_ECX, 19,  1},
         {"sse4.1",       0x00000001, NA, CPUID_REG_ECX, 19,  1},
         {"sse4_2",       0x00000001, NA, CPUID_REG_ECX, 20,  1},
         {"sse4.2",       0x00000001, NA, CPUID_REG_ECX, 20,  1},
-        {"x2apic",       0x00000001, NA, CPUID_REG_ECX, 21,  1},
-        {"movbe",        0x00000001, NA, CPUID_REG_ECX, 22,  1},
-        {"popcnt",       0x00000001, NA, CPUID_REG_ECX, 23,  1},
-        {"tsc-deadline", 0x00000001, NA, CPUID_REG_ECX, 24,  1},
         {"aes",          0x00000001, NA, CPUID_REG_ECX, 25,  1},
-        {"xsave",        0x00000001, NA, CPUID_REG_ECX, 26,  1},
-        {"osxsave",      0x00000001, NA, CPUID_REG_ECX, 27,  1},
-        {"avx",          0x00000001, NA, CPUID_REG_ECX, 28,  1},
-        {"f16c",         0x00000001, NA, CPUID_REG_ECX, 29,  1},
-        {"rdrand",       0x00000001, NA, CPUID_REG_ECX, 30,  1},
-        {"hypervisor",   0x00000001, NA, CPUID_REG_ECX, 31,  1},
-
-        {"fpu",          0x00000001, NA, CPUID_REG_EDX,  0,  1},
-        {"vme",          0x00000001, NA, CPUID_REG_EDX,  1,  1},
-        {"de",           0x00000001, NA, CPUID_REG_EDX,  2,  1},
-        {"pse",          0x00000001, NA, CPUID_REG_EDX,  3,  1},
-        {"tsc",          0x00000001, NA, CPUID_REG_EDX,  4,  1},
-        {"msr",          0x00000001, NA, CPUID_REG_EDX,  5,  1},
-        {"pae",          0x00000001, NA, CPUID_REG_EDX,  6,  1},
-        {"mce",          0x00000001, NA, CPUID_REG_EDX,  7,  1},
+
         {"cmpxchg8",     0x00000001, NA, CPUID_REG_EDX,  8,  1},
-        {"apic",         0x00000001, NA, CPUID_REG_EDX,  9,  1},
         {"sysenter",     0x00000001, NA, CPUID_REG_EDX, 11,  1},
-        {"mtrr",         0x00000001, NA, CPUID_REG_EDX, 12,  1},
-        {"pge",          0x00000001, NA, CPUID_REG_EDX, 13,  1},
-        {"mca",          0x00000001, NA, CPUID_REG_EDX, 14,  1},
-        {"cmov",         0x00000001, NA, CPUID_REG_EDX, 15,  1},
-        {"pat",          0x00000001, NA, CPUID_REG_EDX, 16,  1},
-        {"pse36",        0x00000001, NA, CPUID_REG_EDX, 17,  1},
         {"psn",          0x00000001, NA, CPUID_REG_EDX, 18,  1},
         {"clfsh",        0x00000001, NA, CPUID_REG_EDX, 19,  1},
-        {"ds",           0x00000001, NA, CPUID_REG_EDX, 21,  1},
-        {"acpi",         0x00000001, NA, CPUID_REG_EDX, 22,  1},
-        {"mmx",          0x00000001, NA, CPUID_REG_EDX, 23,  1},
-        {"fxsr",         0x00000001, NA, CPUID_REG_EDX, 24,  1},
-        {"sse",          0x00000001, NA, CPUID_REG_EDX, 25,  1},
-        {"sse2",         0x00000001, NA, CPUID_REG_EDX, 26,  1},
-        {"ss",           0x00000001, NA, CPUID_REG_EDX, 27,  1},
-        {"htt",          0x00000001, NA, CPUID_REG_EDX, 28,  1},
         {"tm",           0x00000001, NA, CPUID_REG_EDX, 29,  1},
         {"ia64",         0x00000001, NA, CPUID_REG_EDX, 30,  1},
         {"pbe",          0x00000001, NA, CPUID_REG_EDX, 31,  1},
 
         {"arat",         0x00000006, NA, CPUID_REG_EAX,  2,  1},
 
-        {"fsgsbase",     0x00000007,  0, CPUID_REG_EBX,  0,  1},
         {"tsc_adjust",   0x00000007,  0, CPUID_REG_EBX,  1,  1},
-        {"bmi1",         0x00000007,  0, CPUID_REG_EBX,  3,  1},
-        {"hle",          0x00000007,  0, CPUID_REG_EBX,  4,  1},
-        {"avx2",         0x00000007,  0, CPUID_REG_EBX,  5,  1},
-        {"smep",         0x00000007,  0, CPUID_REG_EBX,  7,  1},
-        {"bmi2",         0x00000007,  0, CPUID_REG_EBX,  8,  1},
-        {"erms",         0x00000007,  0, CPUID_REG_EBX,  9,  1},
-        {"invpcid",      0x00000007,  0, CPUID_REG_EBX, 10,  1},
-        {"rtm",          0x00000007,  0, CPUID_REG_EBX, 11,  1},
         {"cmt",          0x00000007,  0, CPUID_REG_EBX, 12,  1},
-        {"mpx",          0x00000007,  0, CPUID_REG_EBX, 14,  1},
-        {"avx512f",      0x00000007,  0, CPUID_REG_EBX, 16,  1},
-        {"avx512dq",     0x00000007,  0, CPUID_REG_EBX, 17,  1},
-        {"rdseed",       0x00000007,  0, CPUID_REG_EBX, 18,  1},
-        {"adx",          0x00000007,  0, CPUID_REG_EBX, 19,  1},
-        {"smap",         0x00000007,  0, CPUID_REG_EBX, 20,  1},
-        {"avx512-ifma",  0x00000007,  0, CPUID_REG_EBX, 21,  1},
-        {"clflushopt",   0x00000007,  0, CPUID_REG_EBX, 23,  1},
-        {"clwb",         0x00000007,  0, CPUID_REG_EBX, 24,  1},
-        {"avx512pf",     0x00000007,  0, CPUID_REG_EBX, 26,  1},
-        {"avx512er",     0x00000007,  0, CPUID_REG_EBX, 27,  1},
-        {"avx512cd",     0x00000007,  0, CPUID_REG_EBX, 28,  1},
-        {"sha",          0x00000007,  0, CPUID_REG_EBX, 29,  1},
-        {"avx512bw",     0x00000007,  0, CPUID_REG_EBX, 30,  1},
-        {"avx512vl",     0x00000007,  0, CPUID_REG_EBX, 31,  1},
-
-        {"prefetchwt1",  0x00000007,  0, CPUID_REG_ECX,  0,  1},
-        {"avx512-vbmi",  0x00000007,  0, CPUID_REG_ECX,  1,  1},
-        {"umip",         0x00000007,  0, CPUID_REG_ECX,  2,  1},
-        {"pku",          0x00000007,  0, CPUID_REG_ECX,  3,  1},
-        {"ospke",        0x00000007,  0, CPUID_REG_ECX,  4,  1},
-        {"avx512-vbmi2", 0x00000007,  0, CPUID_REG_ECX,  6,  1},
-        {"cet-ss",       0x00000007,  0, CPUID_REG_ECX,  7,  1},
-        {"gfni",         0x00000007,  0, CPUID_REG_ECX,  8,  1},
-        {"vaes",         0x00000007,  0, CPUID_REG_ECX,  9,  1},
-        {"vpclmulqdq",   0x00000007,  0, CPUID_REG_ECX, 10,  1},
-        {"avx512-vnni",  0x00000007,  0, CPUID_REG_ECX, 11,  1},
-        {"avx512-bitalg",0x00000007,  0, CPUID_REG_ECX, 12,  1},
-        {"avx512-vpopcntdq",0x00000007,0,CPUID_REG_ECX, 14,  1},
-        {"rdpid",        0x00000007,  0, CPUID_REG_ECX, 22,  1},
-        {"cldemote",     0x00000007,  0, CPUID_REG_ECX, 25,  1},
-
-        {"avx512-4vnniw",0x00000007,  0, CPUID_REG_EDX,  2,  1},
-        {"avx512-4fmaps",0x00000007,  0, CPUID_REG_EDX,  3,  1},
-        {"srbds-ctrl",   0x00000007,  0, CPUID_REG_EDX,  9,  1},
-        {"md-clear",     0x00000007,  0, CPUID_REG_EDX, 10,  1},
-        {"serialize",    0x00000007,  0, CPUID_REG_EDX, 14,  1},
-        {"tsxldtrk",     0x00000007,  0, CPUID_REG_EDX, 16,  1},
-        {"cet-ibt",      0x00000007,  0, CPUID_REG_EDX, 20,  1},
-        {"ibrsb",        0x00000007,  0, CPUID_REG_EDX, 26,  1},
-        {"stibp",        0x00000007,  0, CPUID_REG_EDX, 27,  1},
-        {"l1d-flush",    0x00000007,  0, CPUID_REG_EDX, 28,  1},
-        {"arch-caps",    0x00000007,  0, CPUID_REG_EDX, 29,  1},
-        {"core-caps",    0x00000007,  0, CPUID_REG_EDX, 30,  1},
-        {"ssbd",         0x00000007,  0, CPUID_REG_EDX, 31,  1},
-
-        {"avx512-bf16",  0x00000007,  1, CPUID_REG_EAX,  5,  1},
-
-        {"intel-psfd",   0x00000007,  2, CPUID_REG_EDX,  0,  1},
 
         {"lahfsahf",     0x80000001, NA, CPUID_REG_ECX,  0,  1},
         {"cmplegacy",    0x80000001, NA, CPUID_REG_ECX,  1,  1},
-        {"svm",          0x80000001, NA, CPUID_REG_ECX,  2,  1},
-        {"extapic",      0x80000001, NA, CPUID_REG_ECX,  3,  1},
         {"altmovcr8",    0x80000001, NA, CPUID_REG_ECX,  4,  1},
-        {"abm",          0x80000001, NA, CPUID_REG_ECX,  5,  1},
-        {"sse4a",        0x80000001, NA, CPUID_REG_ECX,  6,  1},
-        {"misalignsse",  0x80000001, NA, CPUID_REG_ECX,  7,  1},
-        {"3dnowprefetch",0x80000001, NA, CPUID_REG_ECX,  8,  1},
-        {"osvw",         0x80000001, NA, CPUID_REG_ECX,  9,  1},
-        {"ibs",          0x80000001, NA, CPUID_REG_ECX, 10,  1},
-        {"xop",          0x80000001, NA, CPUID_REG_ECX, 11,  1},
-        {"skinit",       0x80000001, NA, CPUID_REG_ECX, 12,  1},
-        {"wdt",          0x80000001, NA, CPUID_REG_ECX, 13,  1},
-        {"lwp",          0x80000001, NA, CPUID_REG_ECX, 15,  1},
-        {"fma4",         0x80000001, NA, CPUID_REG_ECX, 16,  1},
         {"nodeid",       0x80000001, NA, CPUID_REG_ECX, 19,  1},
-        {"tbm",          0x80000001, NA, CPUID_REG_ECX, 21,  1},
-        {"topoext",      0x80000001, NA, CPUID_REG_ECX, 22,  1},
         {"perfctr_core", 0x80000001, NA, CPUID_REG_ECX, 23,  1},
         {"perfctr_nb",   0x80000001, NA, CPUID_REG_ECX, 24,  1},
 
-        {"syscall",      0x80000001, NA, CPUID_REG_EDX, 11,  1},
-        {"nx",           0x80000001, NA, CPUID_REG_EDX, 20,  1},
-        {"mmxext",       0x80000001, NA, CPUID_REG_EDX, 22,  1},
-        {"ffxsr",        0x80000001, NA, CPUID_REG_EDX, 25,  1},
-        {"page1gb",      0x80000001, NA, CPUID_REG_EDX, 26,  1},
-        {"rdtscp",       0x80000001, NA, CPUID_REG_EDX, 27,  1},
-        {"lm",           0x80000001, NA, CPUID_REG_EDX, 29,  1},
-        {"3dnowext",     0x80000001, NA, CPUID_REG_EDX, 30,  1},
-        {"3dnow",        0x80000001, NA, CPUID_REG_EDX, 31,  1},
-
         {"procpkg",      0x00000004,  0, CPUID_REG_EAX, 26,  6},
 
         {"invtsc",       0x80000007, NA, CPUID_REG_EDX,  8,  1},
 
-        {"clzero",       0x80000008, NA, CPUID_REG_EBX,  0,  1},
-        {"rstr-fp-err-ptrs", 0x80000008, NA, CPUID_REG_EBX, 2, 1},
-        {"wbnoinvd",     0x80000008, NA, CPUID_REG_EBX,  9,  1},
-        {"ibpb",         0x80000008, NA, CPUID_REG_EBX, 12,  1},
-        {"ibrs",         0x80000008, NA, CPUID_REG_EBX, 14,  1},
-        {"amd-stibp",    0x80000008, NA, CPUID_REG_EBX, 15,  1},
-        {"ibrs-always",  0x80000008, NA, CPUID_REG_EBX, 16,  1},
-        {"stibp-always", 0x80000008, NA, CPUID_REG_EBX, 17,  1},
-        {"ibrs-fast",    0x80000008, NA, CPUID_REG_EBX, 18,  1},
-        {"ibrs-same-mode", 0x80000008, NA, CPUID_REG_EBX, 19,  1},
         {"ppin",         0x80000008, NA, CPUID_REG_EBX, 23,  1},
-        {"amd-ssbd",     0x80000008, NA, CPUID_REG_EBX, 24,  1},
-        {"virt-ssbd",    0x80000008, NA, CPUID_REG_EBX, 25,  1},
-        {"ssb-no",       0x80000008, NA, CPUID_REG_EBX, 26,  1},
-        {"psfd",         0x80000008, NA, CPUID_REG_EBX, 28,  1},
         {"btc-no",       0x80000008, NA, CPUID_REG_EBX, 29,  1},
-        {"ibpb-ret",     0x80000008, NA, CPUID_REG_EBX, 30,  1},
 
         {"nc",           0x80000008, NA, CPUID_REG_ECX,  0,  8},
         {"apicidsize",   0x80000008, NA, CPUID_REG_ECX, 12,  4},
@@ -375,9 +244,58 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *policy, const char* str)
 
         {NULL, 0, NA, CPUID_REG_INV, 0, 0}
     };
+    static const struct feature_name features[] = INIT_FEATURE_NAMES;
+    /*
+     * NB: if we switch to using a cpu_policy derived object instead of a
+     * libxl_cpuid_policy_list we could get rid of the featureset -> cpuid leaf
+     * conversion table and use a featureset directly as we have conversions
+     * to/from featureset and cpu_policy.
+     */
+    static const struct {
+        enum { FEAT_CPUID, FEAT_MSR } type;
+        union {
+            struct {
+                uint32_t leaf, subleaf;
+                unsigned int reg;
+            } cpuid;
+            struct {
+                uint32_t index;
+                unsigned int reg;
+            } msr;
+        };
+    } feature_to_policy[] = {
+#define CPUID_ENTRY(l, s, r) \
+    { .type = FEAT_CPUID, .cpuid.leaf = l, .cpuid.subleaf = s, .cpuid.reg = r }
+#define MSR_ENTRY(i, r) \
+    { .type = FEAT_MSR, .msr.index = i, .msr.reg = r }
+        CPUID_ENTRY(0x00000001, NA, CPUID_REG_EDX),
+        CPUID_ENTRY(0x00000001, NA, CPUID_REG_ECX),
+        CPUID_ENTRY(0x80000001, NA, CPUID_REG_EDX),
+        CPUID_ENTRY(0x80000001, NA, CPUID_REG_ECX),
+        CPUID_ENTRY(0x0000000D,  1, CPUID_REG_EAX),
+        CPUID_ENTRY(0x00000007,  0, CPUID_REG_EBX),
+        CPUID_ENTRY(0x00000007,  0, CPUID_REG_ECX),
+        CPUID_ENTRY(0x80000007, NA, CPUID_REG_EDX),
+        CPUID_ENTRY(0x80000008, NA, CPUID_REG_EBX),
+        CPUID_ENTRY(0x00000007,  0, CPUID_REG_EDX),
+        CPUID_ENTRY(0x00000007,  1, CPUID_REG_EAX),
+        CPUID_ENTRY(0x80000021, NA, CPUID_REG_EAX),
+        CPUID_ENTRY(0x00000007,  1, CPUID_REG_EBX),
+        CPUID_ENTRY(0x00000007,  2, CPUID_REG_EDX),
+        CPUID_ENTRY(0x00000007,  1, CPUID_REG_ECX),
+        CPUID_ENTRY(0x00000007,  1, CPUID_REG_EDX),
+        MSR_ENTRY(0x10a, CPUID_REG_EAX),
+        MSR_ENTRY(0x10a, CPUID_REG_EDX),
+#undef MSR_ENTRY
+#undef CPUID_ENTRY
+    };
 #undef NA
     const char *sep, *val;
+    char *name;
     const struct cpuid_flags *flag;
+    const struct feature_name *feat;
+
+    BUILD_BUG_ON(ARRAY_SIZE(feature_to_policy) != FEATURESET_NR_ENTRIES);
 
     sep = strchr(str, '=');
     if (sep == NULL) {
@@ -390,6 +308,37 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *policy, const char* str)
             return cpuid_add(policy, flag, val);
     }
 
+    /* Provide a NUL terminated feature name to the search helper. */
+    name = strndup(str, sep - str);
+    if (name == NULL)
+        return ERROR_NOMEM;
+
+    feat = bsearch(name, features, ARRAY_SIZE(features), sizeof(features[0]),
+                   search_feature);
+    free(name);
+
+    if (feat == NULL)
+        return 2;
+
+    switch (feature_to_policy[feat->bit / 32].type) {
+    case FEAT_CPUID:
+    {
+        struct cpuid_flags f;
+
+        f.name = feat->name;
+        f.leaf = feature_to_policy[feat->bit / 32].cpuid.leaf;
+        f.subleaf = feature_to_policy[feat->bit / 32].cpuid.subleaf;
+        f.reg = feature_to_policy[feat->bit / 32].cpuid.reg;
+        f.bit = feat->bit % 32;
+        f.length = 1;
+
+        return cpuid_add(policy, &f, val);
+    }
+
+    case FEAT_MSR:
+        return 2;
+    }
+
     return 2;
 }
 
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 34ac20773d..ca7e2576fc 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -2465,6 +2465,9 @@ skip_usbdev:
                 case 3:
                     errstr = "illegal CPUID value (must be: [0|1|x|k|s])";
                     break;
+                case ERROR_NOMEM:
+                    errstr = "out of memory";
+                    break;
                 default:
                     errstr = "unknown error";
                     break;
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:06:29 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:06:29 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680942.1059330 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGqD-0000Dz-GV; Wed, 14 Feb 2024 15:06:29 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680942.1059330; Wed, 14 Feb 2024 15:06:29 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGqD-0000Ds-Dr; Wed, 14 Feb 2024 15:06:29 +0000
Received: by outflank-mailman (input) for mailman id 680942;
 Wed, 14 Feb 2024 15:06:29 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGqC-0000Dl-Uu
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:28 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGqC-0005uO-U6
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:28 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGqC-0000y2-TT
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:28 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=WFwLJBWEj2E3I/u9rLlRoJ6oDpX3gBru0ADcPwcTzd4=; b=0HkgC+pWTxKinWpdx6o8nka94+
	O32ct0k3t60dpd0+/pQZoZCAebfditfADJhq1MDcyhjmVs/ABa6TCjeTpMFkTdPWt5qzj37cnVYGO
	E8ztW87k7sO/Am2XgogyzPDpW3Wh7jGioJy1pGI1Aa1MWC0uMpVZnySCEMLeLNvZp70A=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] libxl: add support for parsing MSR features
Message-Id: <E1raGqC-0000y2-TT@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:06:28 +0000

commit f1652ccc9093d50c20a74ac5765feecc9724d9a9
Author:     Roger Pau Monne <roger.pau@citrix.com>
AuthorDate: Tue Jul 25 15:05:58 2023 +0200
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    libxl: add support for parsing MSR features
    
    Introduce support for handling MSR features in
    libxl_cpuid_parse_config().  The MSR policies are added to the
    libxl_cpuid_policy like the CPUID one, which gets passed to
    xc_cpuid_apply_policy().
    
    This allows existing users of libxl to provide MSR related features as
    key=value pairs to libxl_cpuid_parse_config() without requiring the
    usage of a different API.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    (cherry picked from commit 6d21cedbaa34b3a3856f964189e911112c732b21)
---
 tools/libxl/libxl_cpuid.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 63 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c
index 5d0fc34bd4..0a1ff02031 100644
--- a/tools/libxl/libxl_cpuid.c
+++ b/tools/libxl/libxl_cpuid.c
@@ -157,6 +157,60 @@ static int cpuid_add(libxl_cpuid_policy_list *policy,
     return 0;
 }
 
+static struct xc_msr *msr_find_match(libxl_cpuid_policy_list *pl, uint32_t index)
+{
+    unsigned int i = 0;
+    libxl_cpuid_policy_list policy = *pl;
+
+    if (policy == NULL)
+        policy = *pl = calloc(1, sizeof(*policy));
+
+    if (policy->msr != NULL) {
+        for (i = 0; policy->msr[i].index != XC_MSR_INPUT_UNUSED; i++) {
+            if (policy->msr[i].index == index) {
+                return &policy->msr[i];
+            }
+        }
+    }
+
+    policy->msr = realloc(policy->msr, sizeof(struct xc_msr) * (i + 2));
+    policy->msr[i].index = index;
+    memset(policy->msr[i].policy, 'x', ARRAY_SIZE(policy->msr[0].policy) - 1);
+    policy->msr[i].policy[ARRAY_SIZE(policy->msr[0].policy) - 1] = '\0';
+    policy->msr[i + 1].index = XC_MSR_INPUT_UNUSED;
+
+    return &policy->msr[i];
+}
+
+static int msr_add(libxl_cpuid_policy_list *policy, uint32_t index, unsigned int bit,
+                   const char *val)
+{
+    struct xc_msr *entry = msr_find_match(policy, index);
+
+    /* Only allow options taking a character for MSRs, no values allowed. */
+    if (strlen(val) != 1)
+        return 3;
+
+    switch (val[0]) {
+    case '0':
+    case '1':
+    case 'x':
+    case 'k':
+        entry->policy[63 - bit] = val[0];
+        break;
+
+    case 's':
+        /* Translate s -> k as xc_msr doesn't support the deprecated 's'. */
+        entry->policy[63 - bit] = 'k';
+        break;
+
+    default:
+        return 3;
+    }
+
+    return 0;
+}
+
 struct feature_name {
     const char *name;
     unsigned int bit;
@@ -336,7 +390,15 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *policy, const char* str)
     }
 
     case FEAT_MSR:
-        return 2;
+    {
+        unsigned int bit = feat->bit % 32;
+
+        if (feature_to_policy[feat->bit / 32].msr.reg == CPUID_REG_EDX)
+            bit += 32;
+
+        return msr_add(policy, feature_to_policy[feat->bit / 32].msr.index,
+                       bit, val);
+    }
     }
 
     return 2;
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:06:40 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:06:40 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680943.1059335 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGqO-0000Hu-JV; Wed, 14 Feb 2024 15:06:40 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680943.1059335; Wed, 14 Feb 2024 15:06:40 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGqO-0000Hi-Gm; Wed, 14 Feb 2024 15:06:40 +0000
Received: by outflank-mailman (input) for mailman id 680943;
 Wed, 14 Feb 2024 15:06:39 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGqN-0000HW-1V
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:39 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGqN-0005uV-0m
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:39 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGqN-0000yX-03
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:39 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=wEC7W+5ue8g6/dQoSgAq9Z8AdOb4P+v9Mohpvg2EMqo=; b=OfvgHRA8bj9ow7FlWMu2m9lwi8
	SPpWzYB24Fcw1OI22tyU0nJjIBA+x0/5eS5/VKzFndF/w6Aey4Vtd/ahIkdPtK+nOX7JZ4p0DRVqm
	eQLW5xm/KncpaIBsXlixRWaCmyp/l4WEvb09z3z73qAYsUfu6eD2Q8zQJdT5+xDZ3+68=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] libxl: avoid shadowing of index()
Message-Id: <E1raGqN-0000yX-03@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:06:39 +0000

commit 26a5e35fd81ac97ff9b49bfaf932f67aa2a26e76
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Aug 3 17:35:26 2023 +0200
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    libxl: avoid shadowing of index()
    
    Because of -Wshadow the build otherwise fails with old enough glibc.
    
    While there also obey line length limits for msr_add().
    
    Fixes: 6d21cedbaa34 ("libxl: add support for parsing MSR features")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    (cherry picked from commit 4f6afde88be3e8960eb311d16ac41d44ab71ed10)
---
 tools/libxl/libxl_cpuid.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c
index 0a1ff02031..80d83f3213 100644
--- a/tools/libxl/libxl_cpuid.c
+++ b/tools/libxl/libxl_cpuid.c
@@ -157,7 +157,7 @@ static int cpuid_add(libxl_cpuid_policy_list *policy,
     return 0;
 }
 
-static struct xc_msr *msr_find_match(libxl_cpuid_policy_list *pl, uint32_t index)
+static struct xc_msr *msr_find_match(libxl_cpuid_policy_list *pl, uint32_t idx)
 {
     unsigned int i = 0;
     libxl_cpuid_policy_list policy = *pl;
@@ -167,14 +167,14 @@ static struct xc_msr *msr_find_match(libxl_cpuid_policy_list *pl, uint32_t index
 
     if (policy->msr != NULL) {
         for (i = 0; policy->msr[i].index != XC_MSR_INPUT_UNUSED; i++) {
-            if (policy->msr[i].index == index) {
+            if (policy->msr[i].index == idx) {
                 return &policy->msr[i];
             }
         }
     }
 
     policy->msr = realloc(policy->msr, sizeof(struct xc_msr) * (i + 2));
-    policy->msr[i].index = index;
+    policy->msr[i].index = idx;
     memset(policy->msr[i].policy, 'x', ARRAY_SIZE(policy->msr[0].policy) - 1);
     policy->msr[i].policy[ARRAY_SIZE(policy->msr[0].policy) - 1] = '\0';
     policy->msr[i + 1].index = XC_MSR_INPUT_UNUSED;
@@ -182,10 +182,10 @@ static struct xc_msr *msr_find_match(libxl_cpuid_policy_list *pl, uint32_t index
     return &policy->msr[i];
 }
 
-static int msr_add(libxl_cpuid_policy_list *policy, uint32_t index, unsigned int bit,
-                   const char *val)
+static int msr_add(libxl_cpuid_policy_list *policy, uint32_t idx,
+                   unsigned int bit, const char *val)
 {
-    struct xc_msr *entry = msr_find_match(policy, index);
+    struct xc_msr *entry = msr_find_match(policy, idx);
 
     /* Only allow options taking a character for MSRs, no values allowed. */
     if (strlen(val) != 1)
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:06:50 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:06:50 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680944.1059338 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGqY-0000Kj-Ko; Wed, 14 Feb 2024 15:06:50 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680944.1059338; Wed, 14 Feb 2024 15:06:50 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGqY-0000Kc-IM; Wed, 14 Feb 2024 15:06:50 +0000
Received: by outflank-mailman (input) for mailman id 680944;
 Wed, 14 Feb 2024 15:06:49 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGqX-0000KK-4m
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:49 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGqX-0005uw-48
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:49 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGqX-0000zO-3K
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:49 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=H0tfwfLtPXnq0gVhNfJtMcgdiW+GfCsF2FqvByCDoxo=; b=dsqfsTsI4yxwn3UFwdfPUTd8cz
	nZx64TmeqUc7mAHW+Gu8lNH10pcHdgnN483rMyyXJ5l/zV6XxPoCg9f4/0ARC9QPNIJF8nUvozj5k
	kbWREUOAIgipf8DkP+iJJuY8n82v1C50/P5tXvNc8JTVOMos/gdf0ShrB/0Cz599WOrQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] libxl: allow building with old gcc again
Message-Id: <E1raGqX-0000zO-3K@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:06:49 +0000

commit 7e10b39d9dfcde404edef9b16b8b0b2c887975fd
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Aug 3 17:35:39 2023 +0200
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    libxl: allow building with old gcc again
    
    We can't use initializers of unnamed struct/union members just yet.
    
    Fixes: d638fe233cb3 ("libxl: use the cpuid feature names from cpufeatureset.h")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    (cherry picked from commit 1aa5acbbec3f37bf38d78fa96d210053f8e8efd5)
---
 tools/libxl/libxl_cpuid.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c
index 80d83f3213..50592b544a 100644
--- a/tools/libxl/libxl_cpuid.c
+++ b/tools/libxl/libxl_cpuid.c
@@ -316,12 +316,16 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *policy, const char* str)
                 uint32_t index;
                 unsigned int reg;
             } msr;
-        };
+        } u;
     } feature_to_policy[] = {
 #define CPUID_ENTRY(l, s, r) \
-    { .type = FEAT_CPUID, .cpuid.leaf = l, .cpuid.subleaf = s, .cpuid.reg = r }
+    { .type = FEAT_CPUID, \
+      .u = { .cpuid.leaf = l, .cpuid.subleaf = s, .cpuid.reg = r } \
+    }
 #define MSR_ENTRY(i, r) \
-    { .type = FEAT_MSR, .msr.index = i, .msr.reg = r }
+    { .type = FEAT_MSR, \
+      .u = { .msr.index = i, .msr.reg = r } \
+    }
         CPUID_ENTRY(0x00000001, NA, CPUID_REG_EDX),
         CPUID_ENTRY(0x00000001, NA, CPUID_REG_ECX),
         CPUID_ENTRY(0x80000001, NA, CPUID_REG_EDX),
@@ -380,9 +384,9 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *policy, const char* str)
         struct cpuid_flags f;
 
         f.name = feat->name;
-        f.leaf = feature_to_policy[feat->bit / 32].cpuid.leaf;
-        f.subleaf = feature_to_policy[feat->bit / 32].cpuid.subleaf;
-        f.reg = feature_to_policy[feat->bit / 32].cpuid.reg;
+        f.leaf = feature_to_policy[feat->bit / 32].u.cpuid.leaf;
+        f.subleaf = feature_to_policy[feat->bit / 32].u.cpuid.subleaf;
+        f.reg = feature_to_policy[feat->bit / 32].u.cpuid.reg;
         f.bit = feat->bit % 32;
         f.length = 1;
 
@@ -393,10 +397,10 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *policy, const char* str)
     {
         unsigned int bit = feat->bit % 32;
 
-        if (feature_to_policy[feat->bit / 32].msr.reg == CPUID_REG_EDX)
+        if (feature_to_policy[feat->bit / 32].u.msr.reg == CPUID_REG_EDX)
             bit += 32;
 
-        return msr_add(policy, feature_to_policy[feat->bit / 32].msr.index,
+        return msr_add(policy, feature_to_policy[feat->bit / 32].u.msr.index,
                        bit, val);
     }
     }
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:07:00 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:07:00 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680945.1059342 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGqi-0000NJ-Md; Wed, 14 Feb 2024 15:07:00 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680945.1059342; Wed, 14 Feb 2024 15:07:00 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGqi-0000NE-Jv; Wed, 14 Feb 2024 15:07:00 +0000
Received: by outflank-mailman (input) for mailman id 680945;
 Wed, 14 Feb 2024 15:06:59 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGqh-0000Mx-7r
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:59 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGqh-0005v8-77
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:59 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGqh-000109-6N
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:06:59 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=sPdABiWaVOtLv7dlT/+23Fl9upwW3qEEs1mgqJ/gwMI=; b=GzVqsNxfydYkGCNwXWiHqfLhoU
	83/Bhx53cYygyLE+jAJFx2tVbDNmbbv6fmNupJ4drg8aT1bg8kFBf2EwrvGIKlGnGvS3iCNVSCIgk
	UtY5GZxShBwArDN813zn/gNnHjeXD2aEfBcPTHnGyN+ZBY5bhC1N1M1u/M/2ospM3ygY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/cpu-policy: Advertise MSR_ARCH_CAPS to guests by default
Message-Id: <E1raGqh-000109-6N@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:06:59 +0000

commit 49fbb552c4f5c6663dc83ea923cabe8056ae4710
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed May 17 10:13:36 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/cpu-policy: Advertise MSR_ARCH_CAPS to guests by default
    
    With xl/libxl now able to control the policy bits for MSR_ARCH_CAPS, it is
    safe to advertise to guests by default.  In turn, we don't need the special
    case to expose details to dom0.
    
    This advertises MSR_ARCH_CAPS to guests on *all* Intel hardware, even if the
    register content ends up being empty.
    
      - Advertising ARCH_CAPS and not RSBA signals "retpoline is safe here and
        everywhere you might migrate to".  This is important because it avoids the
        guest kernel needing to rely on model checks.
    
      - Alternatively, levelling for safety across the Broadwell/Skylake divide
        requires advertising ARCH_CAPS and RSBA, meaning "retpoline not safe on
        some hardware you might migrate to".
    
    On Cascade Lake and later hardware, guests can now see RDCL_NO (not vulnerable
    to Meltdown) amongst others.  This causes substantial performance
    improvements, as guests are no longer applying software mitigations in cases
    where they don't need to.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 4b2cdbfe766e5666e6754198946df2dc16f6a642)
---
 xen/arch/x86/cpu-policy.c                   | 11 -----------
 xen/include/public/arch-x86/cpufeatureset.h |  2 +-
 2 files changed, 1 insertion(+), 12 deletions(-)

diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
index 9d70e41306..99914b0bff 100644
--- a/xen/arch/x86/cpu-policy.c
+++ b/xen/arch/x86/cpu-policy.c
@@ -853,17 +853,6 @@ void __init init_dom0_cpuid_policy(struct domain *d)
     if ( cpu_has_itsc )
         p->extd.itsc = true;
 
-    /*
-     * Expose the "hardware speculation behaviour" bits of ARCH_CAPS to dom0,
-     * so dom0 can turn off workarounds as appropriate.  Temporary, until the
-     * domain policy logic gains a better understanding of MSRs.
-     */
-    if ( is_hardware_domain(d) && cpu_has_arch_caps )
-    {
-        p->feat.arch_caps = true;
-        p->arch_caps.raw = host_cpu_policy.arch_caps.raw;
-    }
-
     /* Apply dom0-cpuid= command line settings, if provided. */
     if ( dom0_cpuid_cmdline )
     {
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index 357a86521e..be85e7b38a 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -280,7 +280,7 @@ XEN_CPUFEATURE(CET_IBT,       9*32+20) /*   CET - Indirect Branch Tracking */
 XEN_CPUFEATURE(IBRSB,         9*32+26) /*A  IBRS and IBPB support (used by Intel) */
 XEN_CPUFEATURE(STIBP,         9*32+27) /*A  STIBP */
 XEN_CPUFEATURE(L1D_FLUSH,     9*32+28) /*S  MSR_FLUSH_CMD and L1D flush. */
-XEN_CPUFEATURE(ARCH_CAPS,     9*32+29) /*!a IA32_ARCH_CAPABILITIES MSR */
+XEN_CPUFEATURE(ARCH_CAPS,     9*32+29) /*!A IA32_ARCH_CAPABILITIES MSR */
 XEN_CPUFEATURE(CORE_CAPS,     9*32+30) /*   IA32_CORE_CAPABILITIES MSR */
 XEN_CPUFEATURE(SSBD,          9*32+31) /*A  MSR_SPEC_CTRL.SSBD available */
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:07:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:07:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680946.1059347 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGqs-0000QK-OR; Wed, 14 Feb 2024 15:07:10 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680946.1059347; Wed, 14 Feb 2024 15:07:10 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGqs-0000QC-LT; Wed, 14 Feb 2024 15:07:10 +0000
Received: by outflank-mailman (input) for mailman id 680946;
 Wed, 14 Feb 2024 15:07:09 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGqr-0000Q0-Al
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:09 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGqr-0005vU-A3
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:09 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGqr-00011A-9M
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:09 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=2A+L/ShUfVdjBpUsGjju6xJu0CnJ7DmYziuhVhw1Gd0=; b=PODX8Uy784iNSiSND6t8GusPf2
	TVAWgo1uPqbRXCfC5aDxjvxI8XtZDcXeWascne4JjEZ/EMK4e9tXSxvFw5T7a8wOWMAzwjxJbG5nD
	MgkPkYdb5GasT457m0BL4KBtMb3CGfHeo1WRNRlVdhNmIClRVJ74su84Zea38Zhjh11M=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/spec-ctrl: Rework ibpb_calculations()
Message-Id: <E1raGqr-00011A-9M@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:07:09 +0000

commit 0ac679428a034b54da52da5bc4c43788e679613a
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Thu Jul 27 20:03:28 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/spec-ctrl: Rework ibpb_calculations()
    
    ... in order to make the SRSO mitigations easier to integrate.
    
     * Check for AMD/Hygon CPUs directly, rather than assuming based on IBPB.
       In particular, Xen supports synthesising the IBPB bit to guests on Intel to
       allow IBPB while dissuading the use of (legacy) IBRS.
     * Collect def_ibpb_entry rather than opencoding the BTC_NO calculation for
       both opt_ibpb_entry_{pv,hvm}.
    
    No functional change.
    
    This is part of XSA-434 / CVE-2023-20569
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    (cherry picked from commit 292f68fb77196a35ac92b296792770d0f3190d75)
---
 xen/arch/x86/spec_ctrl.c | 40 +++++++++++++++++++++-------------------
 1 file changed, 21 insertions(+), 19 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 9a8d6987ca..55d727e8db 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -869,6 +869,8 @@ static bool __init should_use_eager_fpu(void)
 
 static void __init ibpb_calculations(void)
 {
+    bool def_ibpb_entry = false;
+
     /* Check we have hardware IBPB support before using it... */
     if ( !boot_cpu_has(X86_FEATURE_IBRSB) && !boot_cpu_has(X86_FEATURE_IBPB) )
     {
@@ -877,28 +879,28 @@ static void __init ibpb_calculations(void)
         return;
     }
 
-    /*
-     * AMD/Hygon CPUs to date (June 2022) don't flush the the RAS.  Future
-     * CPUs are expected to enumerate IBPB_RET when this has been fixed.
-     * Until then, cover the difference with the software sequence.
-     */
-    if ( boot_cpu_has(X86_FEATURE_IBPB) && !boot_cpu_has(X86_FEATURE_IBPB_RET) )
-        setup_force_cpu_cap(X86_BUG_IBPB_NO_RET);
+    if ( boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON) )
+    {
+        /*
+         * AMD/Hygon CPUs to date (June 2022) don't flush the RAS.  Future
+         * CPUs are expected to enumerate IBPB_RET when this has been fixed.
+         * Until then, cover the difference with the software sequence.
+         */
+        if ( !boot_cpu_has(X86_FEATURE_IBPB_RET) )
+            setup_force_cpu_cap(X86_BUG_IBPB_NO_RET);
+
+        /*
+         * AMD/Hygon CPUs up to and including Zen2 suffer from Branch Type
+         * Confusion.  Mitigate with IBPB-on-entry.
+         */
+        if ( !boot_cpu_has(X86_FEATURE_BTC_NO) )
+            def_ibpb_entry = true;
+    }
 
-    /*
-     * IBPB-on-entry mitigations for Branch Type Confusion.
-     *
-     * IBPB && !BTC_NO selects all AMD/Hygon hardware, not known to be safe,
-     * that we can provide some form of mitigation on.
-     */
     if ( opt_ibpb_entry_pv == -1 )
-        opt_ibpb_entry_pv = (IS_ENABLED(CONFIG_PV) &&
-                             boot_cpu_has(X86_FEATURE_IBPB) &&
-                             !boot_cpu_has(X86_FEATURE_BTC_NO));
+        opt_ibpb_entry_pv = IS_ENABLED(CONFIG_PV) && def_ibpb_entry;
     if ( opt_ibpb_entry_hvm == -1 )
-        opt_ibpb_entry_hvm = (IS_ENABLED(CONFIG_HVM) &&
-                              boot_cpu_has(X86_FEATURE_IBPB) &&
-                              !boot_cpu_has(X86_FEATURE_BTC_NO));
+        opt_ibpb_entry_hvm = IS_ENABLED(CONFIG_HVM) && def_ibpb_entry;
 
     if ( opt_ibpb_entry_pv )
     {
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:07:20 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:07:20 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680947.1059350 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGr2-0000TI-Pf; Wed, 14 Feb 2024 15:07:20 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680947.1059350; Wed, 14 Feb 2024 15:07:20 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGr2-0000TA-N0; Wed, 14 Feb 2024 15:07:20 +0000
Received: by outflank-mailman (input) for mailman id 680947;
 Wed, 14 Feb 2024 15:07:19 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGr1-0000T0-Du
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:19 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGr1-0005vg-DB
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:19 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGr1-00013c-CO
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:19 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=vcmj+juX1O1zIUTQmzeaeeJN0tewR5ny0sZFALuiaMo=; b=B4Y/xkVmY3Lx77qadOZuHrjIUL
	49cmpVCwdDDX4+ZapYa2V8sOaM4k4EzuWLhDmD0/a8sL9Y5ZiDV4XIkW494kvopVghCOy9NeDRPf9
	gufU/dnCQcZUnl2gKPffZzUY0rVLeeku99gwwc1LW4jfXZK4hnjV2fpsPd1f4Gf9s2aA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/spec-ctrl: Enumerations for Speculative Return Stack Overflow
Message-Id: <E1raGr1-00013c-CO@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:07:19 +0000

commit 6a2df62a986739561df37912ac2b6474b5162da3
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Jun 14 09:13:28 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/spec-ctrl: Enumerations for Speculative Return Stack Overflow
    
    AMD have specified new CPUID bits relating to SRSO.
    
     * SRSO_NO indicates that hardware is no longer vulnerable to SRSO.
     * IBPB_BRTYPE indicates that IBPB flushes branch type information too.
     * SBPB indicates support for a relaxed form of IBPB that does not flush
       branch type information.
    
    Current CPUs (Zen4 and older) are not expected to enumerate these bits.
    Native software is expected to synthesise them for guests using model and
    microcode revision checks.
    
    Two are just status bits, and SBPB is trivial to support for guests by
    tweaking the reserved bit calculation in guest_wrmsr() and feature
    dependencies.  Expose all by default to guests, so they start showing up when
    Xen synthesises them.
    
    While adding feature dependenies for IBPB, fix up an overlooked issue from
    XSA-422.  It's inappropriate to advertise that IBPB flushes RET predictions if
    IBPB is unavailable itself.
    
    This is part of XSA-434 / CVE-2023-20569
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    (cherry picked from commit 2280b0ee2aed6e0fd4af3fa31bf99bc04d038bfe)
---
 tools/misc/xen-cpuid.c                      |  3 +++
 xen/arch/x86/msr.c                          |  5 ++++-
 xen/arch/x86/spec_ctrl.c                    | 15 ++++++++++-----
 xen/include/asm-x86/msr-index.h             |  1 +
 xen/include/public/arch-x86/cpufeatureset.h |  3 +++
 xen/tools/gen-cpuid.py                      |  1 +
 6 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
index ceb8a29c75..37010b7623 100644
--- a/tools/misc/xen-cpuid.c
+++ b/tools/misc/xen-cpuid.c
@@ -187,6 +187,9 @@ static const char *const str_7a1[32] =
 static const char *const str_e21a[32] =
 {
     [ 2] = "lfence+",
+
+    /* 26 */                [27] = "sbpb",
+    [28] = "ibpb-brtype",   [29] = "srso-no",
 };
 
 static const char *const str_7b1[32] =
diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index ded8897a14..c11274cbb6 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -352,7 +352,10 @@ int guest_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)
         if ( !cp->feat.ibrsb && !cp->extd.ibpb )
             goto gp_fault; /* MSR available? */
 
-        if ( val & ~PRED_CMD_IBPB )
+        rsvd = ~(PRED_CMD_IBPB |
+                 (cp->extd.sbpb ? PRED_CMD_SBPB : 0));
+
+        if ( val & rsvd )
             goto gp_fault; /* Rsvd bit set? */
 
         if ( v == curr )
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 55d727e8db..3659e6800e 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -401,7 +401,7 @@ custom_param("pv-l1tf", parse_pv_l1tf);
 
 static void __init print_details(enum ind_thunk thunk)
 {
-    unsigned int _7d0 = 0, _7d2 = 0, e8b = 0, max = 0, tmp;
+    unsigned int _7d0 = 0, _7d2 = 0, e8b = 0, e21a = 0, max = 0, tmp;
     uint64_t caps = 0;
 
     /* Collect diagnostics about available mitigations. */
@@ -411,6 +411,8 @@ static void __init print_details(enum ind_thunk thunk)
         cpuid_count(7, 2, &tmp, &tmp, &tmp, &_7d2);
     if ( boot_cpu_data.extended_cpuid_level >= 0x80000008 )
         cpuid(0x80000008, &tmp, &e8b, &tmp, &tmp);
+    if ( boot_cpu_data.extended_cpuid_level >= 0x80000021 )
+        cpuid(0x80000021, &e21a, &tmp, &tmp, &tmp);
     if ( cpu_has_arch_caps )
         rdmsrl(MSR_ARCH_CAPABILITIES, caps);
 
@@ -420,7 +422,7 @@ static void __init print_details(enum ind_thunk thunk)
      * Hardware read-only information, stating immunity to certain issues, or
      * suggestions of which mitigation to use.
      */
-    printk("  Hardware hints:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+    printk("  Hardware hints:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
            (caps & ARCH_CAPS_RDCL_NO)                        ? " RDCL_NO"        : "",
            (caps & ARCH_CAPS_EIBRS)                          ? " EIBRS"          : "",
            (caps & ARCH_CAPS_RSBA)                           ? " RSBA"           : "",
@@ -440,10 +442,12 @@ static void __init print_details(enum ind_thunk thunk)
            (e8b  & cpufeat_mask(X86_FEATURE_IBRS_FAST))      ? " IBRS_FAST"      : "",
            (e8b  & cpufeat_mask(X86_FEATURE_IBRS_SAME_MODE)) ? " IBRS_SAME_MODE" : "",
            (e8b  & cpufeat_mask(X86_FEATURE_BTC_NO))         ? " BTC_NO"         : "",
-           (e8b  & cpufeat_mask(X86_FEATURE_IBPB_RET))       ? " IBPB_RET"       : "");
+           (e8b  & cpufeat_mask(X86_FEATURE_IBPB_RET))       ? " IBPB_RET"       : "",
+           (e21a & cpufeat_mask(X86_FEATURE_IBPB_BRTYPE))    ? " IBPB_BRTYPE"    : "",
+           (e21a & cpufeat_mask(X86_FEATURE_SRSO_NO))        ? " SRSO_NO"        : "");
 
     /* Hardware features which need driving to mitigate issues. */
-    printk("  Hardware features:%s%s%s%s%s%s%s%s%s%s%s\n",
+    printk("  Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s\n",
            (e8b  & cpufeat_mask(X86_FEATURE_IBPB)) ||
            (_7d0 & cpufeat_mask(X86_FEATURE_IBRSB))          ? " IBPB"           : "",
            (e8b  & cpufeat_mask(X86_FEATURE_IBRS)) ||
@@ -459,7 +463,8 @@ static void __init print_details(enum ind_thunk thunk)
            (_7d0 & cpufeat_mask(X86_FEATURE_SRBDS_CTRL))     ? " SRBDS_CTRL"     : "",
            (e8b  & cpufeat_mask(X86_FEATURE_VIRT_SSBD))      ? " VIRT_SSBD"      : "",
            (caps & ARCH_CAPS_TSX_CTRL)                       ? " TSX_CTRL"       : "",
-           (caps & ARCH_CAPS_FB_CLEAR_CTRL)                  ? " FB_CLEAR_CTRL"  : "");
+           (caps & ARCH_CAPS_FB_CLEAR_CTRL)                  ? " FB_CLEAR_CTRL"  : "",
+           (e21a & cpufeat_mask(X86_FEATURE_SBPB))           ? " SBPB"           : "");
 
     /* Compiled-in support which pertains to mitigations. */
     if ( IS_ENABLED(CONFIG_INDIRECT_THUNK) || IS_ENABLED(CONFIG_SHADOW_PAGING) )
diff --git a/xen/include/asm-x86/msr-index.h b/xen/include/asm-x86/msr-index.h
index 7befa60abd..8e89ad4e28 100644
--- a/xen/include/asm-x86/msr-index.h
+++ b/xen/include/asm-x86/msr-index.h
@@ -37,6 +37,7 @@
 
 #define MSR_PRED_CMD                        0x00000049
 #define  PRED_CMD_IBPB                      (_AC(1, ULL) <<  0)
+#define  PRED_CMD_SBPB                      (_AC(1, ULL) <<  7)
 
 #define MSR_PPIN_CTL                        0x0000004e
 #define  PPIN_LOCKOUT                       (_AC(1, ULL) <<  0)
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index be85e7b38a..db7478a3e0 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -289,6 +289,9 @@ XEN_CPUFEATURE(AVX512_BF16,  10*32+ 5) /*A  AVX512 BFloat16 Instructions */
 
 /* AMD-defined CPU features, CPUID level 0x80000021.eax, word 11 */
 XEN_CPUFEATURE(LFENCE_DISPATCH,    11*32+ 2) /*A  LFENCE always serializing */
+XEN_CPUFEATURE(SBPB,               11*32+27) /*A  Selective Branch Predictor Barrier */
+XEN_CPUFEATURE(IBPB_BRTYPE,        11*32+28) /*A  IBPB flushes Branch Type predictions too */
+XEN_CPUFEATURE(SRSO_NO,            11*32+29) /*A  Hardware not vulenrable to Speculative Return Stack Overflow */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:1.ebx, word 12 */
 
diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py
index 1be3ddbb85..3980e1b67e 100755
--- a/xen/tools/gen-cpuid.py
+++ b/xen/tools/gen-cpuid.py
@@ -318,6 +318,7 @@ def crunch_numbers(state):
         IBRSB: [STIBP, SSBD, INTEL_PSFD, EIBRS],
         IBRS: [AMD_STIBP, AMD_SSBD, PSFD,
                IBRS_ALWAYS, IBRS_FAST, IBRS_SAME_MODE],
+        IBPB: [IBPB_RET, SBPB, IBPB_BRTYPE],
         AMD_STIBP: [STIBP_ALWAYS],
 
         # In principle the TSXLDTRK insns could also be considered independent.
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:07:30 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:07:30 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680948.1059355 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGrC-0000WU-Se; Wed, 14 Feb 2024 15:07:30 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680948.1059355; Wed, 14 Feb 2024 15:07:30 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGrC-0000WM-Po; Wed, 14 Feb 2024 15:07:30 +0000
Received: by outflank-mailman (input) for mailman id 680948;
 Wed, 14 Feb 2024 15:07:29 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGrB-0000WA-HB
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:29 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGrB-0005w2-GM
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:29 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGrB-00014V-Fa
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:29 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=aHq+NywjLoG0cgMZs6stCn9EAPiiq9uhcKLxbn/cAMI=; b=btdJDE0Axn+7Va2JU+j/h9kHYX
	wJp08iipv/q+pPzTMDnTi+Fs/LzWgDueZ1ZkXRYtyK/mfRv+GnrMy4D6iSyOl09cwL8SQ5FsJOJMe
	TSVcuqtpXJNgsIIQD9A58zCTgjtUlfyYpSKiIUBDBhUo+WctVpgs8wg7HUSwLT4AV8M8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/spec-ctrl: Mitigate Speculative Return Stack Overflow
Message-Id: <E1raGrB-00014V-Fa@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:07:29 +0000

commit e8db771a17c96f3a393ad7929c1c35e17e39972a
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Thu Jun 15 13:46:29 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/spec-ctrl: Mitigate Speculative Return Stack Overflow
    
    On native, synthesise the SRSO bits by probing various hardware properties as
    given by AMD.
    
    Extend the IBPB-on-entry mitigations to Zen3/4 CPUs.  There is a microcode
    prerequisite to make this an effective mitigation.
    
    This is part of XSA-434 / CVE-2023-20569
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    (cherry picked from commit 220c06e6fefe2378f40e2a7391f5e265a2aa50f7)
---
 docs/misc/xen-command-line.pandoc |  7 ++--
 xen/arch/x86/spec_ctrl.c          | 68 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 72 insertions(+), 3 deletions(-)

diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
index 2fd6a9a552..88f880177f 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -2170,9 +2170,10 @@ guests to use.
   preference to here.*
 * `ibpb-entry=` offers control over whether IBPB (Indirect Branch Prediction
   Barrier) is used on entry to Xen.  This is used by default on hardware
-  vulnerable to Branch Type Confusion, but for performance reasons, dom0 is
-  unprotected by default.  If it necessary to protect dom0 too, boot with
-  `spec-ctrl=ibpb-entry`.
+  vulnerable to Branch Type Confusion, and hardware vulnerable to Speculative
+  Return Stack Overflow if appropriate microcode has been loaded, but for
+  performance reasons dom0 is unprotected by default.  If it is necessary to
+  protect dom0 too, boot with `spec-ctrl=ibpb-entry`.
 
 If Xen was compiled with INDIRECT_THUNK support, `bti-thunk=` can be used to
 select which of the thunks gets patched into the `__x86_indirect_thunk_%reg`
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 3659e6800e..2dad423255 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -872,6 +872,63 @@ static bool __init should_use_eager_fpu(void)
     }
 }
 
+static void __init srso_calculations(bool hw_smt_enabled)
+{
+    if ( !(boot_cpu_data.x86_vendor &
+           (X86_VENDOR_AMD | X86_VENDOR_HYGON)) )
+        return;
+
+    /*
+     * If virtualised, none of these heuristics are safe.  Trust the
+     * hypervisor completely.
+     */
+    if ( cpu_has_hypervisor )
+        return;
+
+    if ( boot_cpu_data.x86 == 0x19 )
+    {
+        /*
+         * We could have a table of models/microcode revisions.  ...or we
+         * could just look for the new feature added.
+         */
+        if ( wrmsr_safe(MSR_PRED_CMD, PRED_CMD_SBPB) == 0 )
+        {
+            setup_force_cpu_cap(X86_FEATURE_IBPB_BRTYPE);
+            setup_force_cpu_cap(X86_FEATURE_SBPB);
+        }
+        else
+            printk(XENLOG_WARNING
+                   "Vulnerable to SRSO, without suitable microcode to mitigate\n");
+    }
+    else if ( boot_cpu_data.x86 < 0x19 )
+    {
+        /*
+         * Zen1/2 (which have the IBPB microcode) have IBPB_BRTYPE behaviour
+         * already.
+         *
+         * Older CPUs are unknown, but their IBPB likely does flush branch
+         * types too.  As we're synthesising for the benefit of guests, go
+         * with the likely option - this avoids VMs running on e.g. a Zen3
+         * thinking there's no SRSO mitigation available because it may
+         * migrate to e.g. a Bulldozer.
+         */
+        if ( boot_cpu_has(X86_FEATURE_IBPB) )
+            setup_force_cpu_cap(X86_FEATURE_IBPB_BRTYPE);
+    }
+
+    /*
+     * In single-thread mode on Zen1/2, microarchitectural limits prevent SRSO
+     * attacks from being effective.  Synthesise SRSO_NO if SMT is disabled in
+     * hardware.
+     *
+     * Booting with smt=0, or using xen-hptool should be effective too, but
+     * they can be altered at runtime so it's not safe to presume SRSO_NO.
+     */
+    if ( !hw_smt_enabled &&
+         (boot_cpu_data.x86 == 0x17 || boot_cpu_data.x86 == 0x18) )
+        setup_force_cpu_cap(X86_FEATURE_SRSO_NO);
+}
+
 static void __init ibpb_calculations(void)
 {
     bool def_ibpb_entry = false;
@@ -900,6 +957,15 @@ static void __init ibpb_calculations(void)
          */
         if ( !boot_cpu_has(X86_FEATURE_BTC_NO) )
             def_ibpb_entry = true;
+
+        /*
+         * Further to BTC, Zen3/4 CPUs suffer from Speculative Return Stack
+         * Overflow in most configurations.  Mitigate with IBPB-on-entry if we
+         * have the microcode that makes this an effective option.
+         */
+        if ( !boot_cpu_has(X86_FEATURE_SRSO_NO) &&
+             boot_cpu_has(X86_FEATURE_IBPB_BRTYPE) )
+            def_ibpb_entry = true;
     }
 
     if ( opt_ibpb_entry_pv == -1 )
@@ -1402,6 +1468,8 @@ void __init init_speculation_mitigations(void)
     if ( opt_rsb_hvm )
         setup_force_cpu_cap(X86_FEATURE_SC_RSB_HVM);
 
+    srso_calculations(hw_smt_enabled);
+
     ibpb_calculations();
 
     /* Check whether Eager FPU should be enabled by default. */
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:07:40 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:07:40 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680950.1059358 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGrM-0000Zd-Tr; Wed, 14 Feb 2024 15:07:40 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680950.1059358; Wed, 14 Feb 2024 15:07:40 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGrM-0000ZT-RL; Wed, 14 Feb 2024 15:07:40 +0000
Received: by outflank-mailman (input) for mailman id 680950;
 Wed, 14 Feb 2024 15:07:39 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGrL-0000ZJ-MC
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:39 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGrL-0005wB-LL
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:39 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGrL-00015T-Iq
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:39 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=nBrvKh96X/dUzE78tXEF3obztPXrC7yqAPcqesEgYgo=; b=Ay1Jz8xo0DsvP2jaQYloEcrzf+
	/g51SLsT1duXLtZOLFcDeSS+0O1siH9u6h+4k19nxQqZ9Fts93Nx39pWX7cIwHkCZtILuva2zBT0Z
	/71JCpbACbKdkppfSjvyqHUI/skhEHi2vGX/4dNMgjpDFCXCo6/MOftgBdnRcdDB13F0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/cpu-policy: Hide CLWB by default on SKX/CLX/CPX
Message-Id: <E1raGrL-00015T-Iq@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:07:39 +0000

commit 5792b92fd9b6a65214e9980d0280eaef95e59b4a
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon Feb 27 15:36:49 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/cpu-policy: Hide CLWB by default on SKX/CLX/CPX
    
    The August 2023 microcode for GDS has an impact on the CLWB instruction.  See
    code comments for full details.
    
    This is part of XSA-435 / CVE-2022-40982
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 2dd06b4ea10891750af38e4a0e1efaeb0a9b3518)
---
 xen/arch/x86/cpu-policy.c                   | 25 +++++++++++++++++++++++++
 xen/arch/x86/cpu/intel.c                    | 12 ++++++++++++
 xen/include/public/arch-x86/cpufeatureset.h |  2 +-
 3 files changed, 38 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/cpu-policy.c b/xen/arch/x86/cpu-policy.c
index 99914b0bff..fe85f1f960 100644
--- a/xen/arch/x86/cpu-policy.c
+++ b/xen/arch/x86/cpu-policy.c
@@ -433,6 +433,18 @@ static void __init guest_common_max_feature_adjustments(uint32_t *fs)
         __set_bit(X86_FEATURE_ARCH_CAPS, fs);
         __set_bit(X86_FEATURE_RSBA, fs);
         __set_bit(X86_FEATURE_RRSBA, fs);
+
+        /*
+         * The Gather Data Sampling microcode mitigation (August 2023) has an
+         * adverse performance impact on the CLWB instruction on SKX/CLX/CPX.
+         *
+         * We hid CLWB in the host policy to stop Xen using it, but VMs which
+         * have previously seen the CLWB feature can safely run on this CPU.
+         */
+        if ( boot_cpu_data.x86 == 6 &&
+             boot_cpu_data.x86_model == 0x55 /* INTEL_FAM6_SKYLAKE_X */ &&
+             raw_cpu_policy.feat.clwb )
+            __set_bit(X86_FEATURE_CLWB, fs);
     }
 }
 
@@ -455,6 +467,19 @@ static void __init guest_common_default_feature_adjustments(uint32_t *fs)
              boot_cpu_data.x86_model == 0x3a /* INTEL_FAM6_IVYBRIDGE */ &&
              cpu_has_rdrand && !is_forced_cpu_cap(X86_FEATURE_RDRAND) )
             __clear_bit(X86_FEATURE_RDRAND, fs);
+
+        /*
+         * The Gather Data Sampling microcode mitigation (August 2023) has an
+         * adverse performance impact on the CLWB instruction on SKX/CLX/CPX.
+         *
+         * We hid CLWB in the host policy to stop Xen using it, but re-added
+         * it to the max policy to let VMs migrate in.  Re-hide it in the
+         * default policy to disuade VMs from using it in the common case.
+         */
+        if ( boot_cpu_data.x86 == 6 &&
+             boot_cpu_data.x86_model == 0x55 /* INTEL_FAM6_SKYLAKE_X */ &&
+             raw_cpu_policy.feat.clwb )
+            __clear_bit(X86_FEATURE_CLWB, fs);
     }
 
     /*
diff --git a/xen/arch/x86/cpu/intel.c b/xen/arch/x86/cpu/intel.c
index 21419e08c3..2bda64c93a 100644
--- a/xen/arch/x86/cpu/intel.c
+++ b/xen/arch/x86/cpu/intel.c
@@ -518,6 +518,18 @@ static void init_intel(struct cpuinfo_x86 *c)
 	if ((opt_cpu_info && !(c->apicid & (c->x86_num_siblings - 1))) ||
 	    c == &boot_cpu_data )
 		intel_log_freq(c);
+
+	/*
+	 * The Gather Data Sampling microcode mitigation (August 2023) has an
+	 * adverse performance impact on the CLWB instruction on SKX/CLX/CPX.
+	 *
+	 * On this model, CLWB has equivalent behaviour to CLFLUSHOPT but the
+	 * latter is not impacted.  Hide CLWB to cause Xen to fall back to
+	 * using CLFLUSHOPT instead.
+	 */
+	if (c == &boot_cpu_data &&
+	    c->x86 == 6 && c->x86_model == 0x55 /* INTEL_FAM6_SKYLAKE_X */)
+		setup_clear_cpu_cap(X86_FEATURE_CLWB);
 }
 
 const struct cpu_dev intel_cpu_dev = {
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index db7478a3e0..3274ac3e9a 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -216,7 +216,7 @@ XEN_CPUFEATURE(ADX,           5*32+19) /*A  ADCX, ADOX instructions */
 XEN_CPUFEATURE(SMAP,          5*32+20) /*S  Supervisor Mode Access Prevention */
 XEN_CPUFEATURE(AVX512_IFMA,   5*32+21) /*A  AVX-512 Integer Fused Multiply Add */
 XEN_CPUFEATURE(CLFLUSHOPT,    5*32+23) /*A  CLFLUSHOPT instruction */
-XEN_CPUFEATURE(CLWB,          5*32+24) /*A  CLWB instruction */
+XEN_CPUFEATURE(CLWB,          5*32+24) /*!A CLWB instruction */
 XEN_CPUFEATURE(AVX512PF,      5*32+26) /*A  AVX-512 Prefetch Instructions */
 XEN_CPUFEATURE(AVX512ER,      5*32+27) /*A  AVX-512 Exponent & Reciprocal Instrs */
 XEN_CPUFEATURE(AVX512CD,      5*32+28) /*A  AVX-512 Conflict Detection Instrs */
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:07:50 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:07:50 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680951.1059362 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGrW-0000cT-VH; Wed, 14 Feb 2024 15:07:50 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680951.1059362; Wed, 14 Feb 2024 15:07:50 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGrW-0000cM-Ss; Wed, 14 Feb 2024 15:07:50 +0000
Received: by outflank-mailman (input) for mailman id 680951;
 Wed, 14 Feb 2024 15:07:49 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGrV-0000cA-P5
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:49 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGrV-0005wb-OM
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:49 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGrV-00016J-Ni
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:49 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=+dxLYFyL1h+FhvJrtXi8ehE1QiHQIVj/0NxxS6cnMW8=; b=GKbV35DqpfDpNmfWq8X8ttwLUX
	/FEsNE1b6nJgPEhPOlv/AdZdELMsOLQbqniaTGRl4dseojFosibqkTgtc4m4XzUzGhssPr9QrmVtV
	+gwK9KxikUfQGTnFtEYMe8Qe9XmtoxaXF7kJlg8dGmC5uC2g2box3w68D33KAW5bbpf4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/spec-ctrl: Enumerations for Gather Data Sampling
Message-Id: <E1raGrV-00016J-Ni@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:07:49 +0000

commit e138318362ac40572929327e2a3512a20ebb4488
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Jan 4 17:32:44 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/spec-ctrl: Enumerations for Gather Data Sampling
    
    GDS_CTRL is introduced by the August 2023 microcode.  GDS_NO is for current
    and future processors not susceptible to GDS.
    
    This is part of XSA-435 / CVE-2022-40982
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 9f585f59d90c8d3a1b21369a852b7d7eee8a29b9)
---
 tools/misc/xen-cpuid.c                      | 3 ++-
 xen/arch/x86/spec_ctrl.c                    | 6 ++++--
 xen/include/asm-x86/cpufeature.h            | 2 ++
 xen/include/asm-x86/msr-index.h             | 4 ++++
 xen/include/public/arch-x86/cpufeatureset.h | 2 ++
 5 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
index 37010b7623..ff46046bff 100644
--- a/tools/misc/xen-cpuid.c
+++ b/tools/misc/xen-cpuid.c
@@ -223,7 +223,8 @@ static const char *const str_m10Al[32] =
     [18] = "fb-clear-ctrl",       [19] = "rrsba",
     [20] = "bhi-no",              [21] = "xapic-status",
     /* 22 */                      [23] = "ovrclk-status",
-    [24] = "pbrsb-no",
+    [24] = "pbrsb-no",            [25] = "gds-ctrl",
+    [26] = "gds-no",
 };
 
 static const char *const str_m10Ah[32] =
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 2dad423255..c9d4daad9d 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -422,7 +422,7 @@ static void __init print_details(enum ind_thunk thunk)
      * Hardware read-only information, stating immunity to certain issues, or
      * suggestions of which mitigation to use.
      */
-    printk("  Hardware hints:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+    printk("  Hardware hints:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
            (caps & ARCH_CAPS_RDCL_NO)                        ? " RDCL_NO"        : "",
            (caps & ARCH_CAPS_EIBRS)                          ? " EIBRS"          : "",
            (caps & ARCH_CAPS_RSBA)                           ? " RSBA"           : "",
@@ -437,6 +437,7 @@ static void __init print_details(enum ind_thunk thunk)
            (caps & ARCH_CAPS_PSDP_NO)                        ? " PSDP_NO"        : "",
            (caps & ARCH_CAPS_FB_CLEAR)                       ? " FB_CLEAR"       : "",
            (caps & ARCH_CAPS_PBRSB_NO)                       ? " PBRSB_NO"       : "",
+           (caps & ARCH_CAPS_GDS_NO)                         ? " GDS_NO"         : "",
            (e8b  & cpufeat_mask(X86_FEATURE_IBRS_ALWAYS))    ? " IBRS_ALWAYS"    : "",
            (e8b  & cpufeat_mask(X86_FEATURE_STIBP_ALWAYS))   ? " STIBP_ALWAYS"   : "",
            (e8b  & cpufeat_mask(X86_FEATURE_IBRS_FAST))      ? " IBRS_FAST"      : "",
@@ -447,7 +448,7 @@ static void __init print_details(enum ind_thunk thunk)
            (e21a & cpufeat_mask(X86_FEATURE_SRSO_NO))        ? " SRSO_NO"        : "");
 
     /* Hardware features which need driving to mitigate issues. */
-    printk("  Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s\n",
+    printk("  Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
            (e8b  & cpufeat_mask(X86_FEATURE_IBPB)) ||
            (_7d0 & cpufeat_mask(X86_FEATURE_IBRSB))          ? " IBPB"           : "",
            (e8b  & cpufeat_mask(X86_FEATURE_IBRS)) ||
@@ -464,6 +465,7 @@ static void __init print_details(enum ind_thunk thunk)
            (e8b  & cpufeat_mask(X86_FEATURE_VIRT_SSBD))      ? " VIRT_SSBD"      : "",
            (caps & ARCH_CAPS_TSX_CTRL)                       ? " TSX_CTRL"       : "",
            (caps & ARCH_CAPS_FB_CLEAR_CTRL)                  ? " FB_CLEAR_CTRL"  : "",
+           (caps & ARCH_CAPS_GDS_CTRL)                       ? " GDS_CTRL"       : "",
            (e21a & cpufeat_mask(X86_FEATURE_SBPB))           ? " SBPB"           : "");
 
     /* Compiled-in support which pertains to mitigations. */
diff --git a/xen/include/asm-x86/cpufeature.h b/xen/include/asm-x86/cpufeature.h
index 90684fac95..86480b1081 100644
--- a/xen/include/asm-x86/cpufeature.h
+++ b/xen/include/asm-x86/cpufeature.h
@@ -153,6 +153,8 @@
 #define cpu_has_taa_no          boot_cpu_has(X86_FEATURE_TAA_NO)
 #define cpu_has_fb_clear        boot_cpu_has(X86_FEATURE_FB_CLEAR)
 #define cpu_has_rrsba           boot_cpu_has(X86_FEATURE_RRSBA)
+#define cpu_has_gds_ctrl        boot_cpu_has(X86_FEATURE_GDS_CTRL)
+#define cpu_has_gds_no          boot_cpu_has(X86_FEATURE_GDS_NO)
 
 /* Synthesized. */
 #define cpu_has_arch_perfmon    boot_cpu_has(X86_FEATURE_ARCH_PERFMON)
diff --git a/xen/include/asm-x86/msr-index.h b/xen/include/asm-x86/msr-index.h
index 8e89ad4e28..b50d4b4eb3 100644
--- a/xen/include/asm-x86/msr-index.h
+++ b/xen/include/asm-x86/msr-index.h
@@ -65,6 +65,8 @@
 #define  ARCH_CAPS_RRSBA                    (_AC(1, ULL) << 19)
 #define  ARCH_CAPS_BHI_NO                   (_AC(1, ULL) << 20)
 #define  ARCH_CAPS_PBRSB_NO                 (_AC(1, ULL) << 24)
+#define  ARCH_CAPS_GDS_CTRL                 (_AC(1, ULL) << 25)
+#define  ARCH_CAPS_GDS_NO                   (_AC(1, ULL) << 26)
 
 #define MSR_FLUSH_CMD                       0x0000010b
 #define  FLUSH_CMD_L1D                      (_AC(1, ULL) <<  0)
@@ -83,6 +85,8 @@
 #define  MCU_OPT_CTRL_RTM_ALLOW             (_AC(1, ULL) <<  1)
 #define  MCU_OPT_CTRL_RTM_LOCKED            (_AC(1, ULL) <<  2)
 #define  MCU_OPT_CTRL_FB_CLEAR_DIS          (_AC(1, ULL) <<  3)
+#define  MCU_OPT_CTRL_GDS_MIT_DIS           (_AC(1, ULL) <<  4)
+#define  MCU_OPT_CTRL_GDS_MIT_LOCK          (_AC(1, ULL) <<  5)
 
 #define MSR_RTIT_OUTPUT_BASE                0x00000560
 #define MSR_RTIT_OUTPUT_MASK                0x00000561
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index 3274ac3e9a..60173be97d 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -326,6 +326,8 @@ XEN_CPUFEATURE(BHI_NO,             16*32+20) /*A  No Branch History Injection  *
 XEN_CPUFEATURE(XAPIC_STATUS,       16*32+21) /*   MSR_XAPIC_DISABLE_STATUS */
 XEN_CPUFEATURE(OVRCLK_STATUS,      16*32+23) /*   MSR_OVERCLOCKING_STATUS */
 XEN_CPUFEATURE(PBRSB_NO,           16*32+24) /*A  No Post-Barrier RSB predictions */
+XEN_CPUFEATURE(GDS_CTRL,           16*32+25) /*   MCU_OPT_CTRL.GDS_MIT_{DIS,LOCK} */
+XEN_CPUFEATURE(GDS_NO,             16*32+26) /*A  No Gather Data Sampling */
 
 /* Intel-defined CPU features, MSR_ARCH_CAPS 0x10a.edx, word 17 */
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:08:01 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:08:01 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680952.1059368 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGrh-0000fH-1d; Wed, 14 Feb 2024 15:08:01 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680952.1059368; Wed, 14 Feb 2024 15:08:01 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGrg-0000f7-UO; Wed, 14 Feb 2024 15:08:00 +0000
Received: by outflank-mailman (input) for mailman id 680952;
 Wed, 14 Feb 2024 15:07:59 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGrf-0000et-SP
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:59 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGrf-0005wi-Re
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:59 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGrf-000176-Qn
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:07:59 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=6w8lNzigjrz24pOyORR2tH5IhAz9nDkbj1Jo9LLj6BI=; b=uYNFMIFpGiEHC1CirPRwedlqSM
	ghw5WN+UT1sVHN3F5PTZ7SqyNdQEWeqnfbO/uTqGYUoJcDKok0SlazG0AZ9yS5FMVXdNDElWtLDHu
	oxhia/A8ywayLZrwDJxMP0iLufB+UFUPWvbwuBefBoWpfvO/0VYc0O8fQaSNjmdLFMVY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] x86/spec-ctrl: Mitigate Gather Data Sampling
Message-Id: <E1raGrf-000176-Qn@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:07:59 +0000

commit 050abf9e978c153e599d0aaeef4c2da71b6e0993
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Jan 4 16:32:44 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Aug 3 19:14:19 2023 +0100

    x86/spec-ctrl: Mitigate Gather Data Sampling
    
    This is part of XSA-435 / CVE-2022-40982
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 56d690efd3ca3c68e1d222f259fb3d216206e8e5)
---
 docs/misc/xen-command-line.pandoc |  10 ++-
 xen/arch/x86/spec_ctrl.c          | 158 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 167 insertions(+), 1 deletion(-)

diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
index 88f880177f..452d07eba1 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -2124,7 +2124,7 @@ By default SSBD will be mitigated at runtime (i.e `ssbd=runtime`).
 >              {msr-sc,rsb,md-clear,ibpb-entry}=<bool>|{pv,hvm}=<bool>,
 >              bti-thunk=retpoline|lfence|jmp, {ibrs,ibpb,ssbd,psfd,
 >              eager-fpu,l1d-flush,branch-harden,srb-lock,
->              unpriv-mmio}=<bool> ]`
+>              unpriv-mmio,gds-mit}=<bool> ]`
 
 Controls for speculative execution sidechannel mitigations.  By default, Xen
 will pick the most appropriate mitigations based on compiled in support,
@@ -2236,6 +2236,14 @@ and/or `SRBDS_CTRL` functionality available in the Intel May 2022 microcode
 release to mitigate cross-domain leakage of data via the MMIO Stale Data
 vulnerabilities.
 
+On all hardware, the `gds-mit=` option can be used to force or prevent Xen
+from mitigating the GDS (Gather Data Sampling) vulnerability.  By default, Xen
+will mitigate GDS on hardware believed to be vulnerable.  On hardware
+supporting GDS_CTRL (requires the August 2023 microcode), and where firmware
+has elected not to lock the configuration, Xen will use GDS_CTRL to mitigate
+GDS with.  Otherwise, Xen will mitigate by disabling AVX, which blocks the use
+of the AVX2 Gather instructions.
+
 ### sync_console
 > `= <boolean>`
 
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index c9d4daad9d..27bb121b09 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -77,6 +77,7 @@ static bool __initdata cpu_has_bug_mds; /* Any other M{LP,SB,FB}DS combination.
 static int8_t __initdata opt_srb_lock = -1;
 static bool __initdata opt_unpriv_mmio;
 static bool __read_mostly opt_fb_clear_mmio;
+static int8_t __initdata opt_gds_mit = -1;
 
 static int __init parse_spec_ctrl(const char *s)
 {
@@ -130,6 +131,7 @@ static int __init parse_spec_ctrl(const char *s)
             opt_branch_harden = false;
             opt_srb_lock = 0;
             opt_unpriv_mmio = false;
+            opt_gds_mit = 0;
         }
         else if ( val > 0 )
             rc = -EINVAL;
@@ -280,6 +282,8 @@ static int __init parse_spec_ctrl(const char *s)
             opt_srb_lock = val;
         else if ( (val = parse_boolean("unpriv-mmio", s, ss)) >= 0 )
             opt_unpriv_mmio = val;
+        else if ( (val = parse_boolean("gds-mit", s, ss)) >= 0 )
+            opt_gds_mit = val;
         else
             rc = -EINVAL;
 
@@ -1247,6 +1251,158 @@ static __init void mds_calculations(void)
     }
 }
 
+static bool __init cpu_has_gds(void)
+{
+    /*
+     * Any part advertising GDS_NO should be not vulnerable to GDS.  This
+     * includes cases where the hypervisor is mitigating behind our backs, or
+     * has synthesized GDS_NO on older parts for levelling purposes.
+     */
+    if ( cpu_has_gds_no )
+        return false;
+
+    /*
+     * On real hardware the GDS_CTRL control only exists on parts vulnerable
+     * to GDS and with up-to-date microcode.  It might also be virtualised by
+     * an aware hypervisor, meaning "somewhere you might migrate to is
+     * vulnerable".
+     */
+    if ( cpu_has_gds_ctrl )
+        return true;
+
+    /*
+     * An attacker requires the use of the AVX2 GATHER instructions to leak
+     * data with GDS.  However, the only way to block those instructions is to
+     * prevent XCR0[2] from being set, which is original AVX.  A hypervisor
+     * might do this as a stopgap mitigation.
+     */
+    if ( !cpu_has_avx )
+        return false;
+
+    /*
+     * GDS affects the Core line from Skylake up to but not including Golden
+     * Cove (Alder Lake, Sapphire Rapids).  Broadwell and older, and the Atom
+     * line, and all hybrid parts are unaffected.
+     */
+    switch ( boot_cpu_data.x86_model )
+    {
+    case 0x55: /* Skylake/Cascade Lake/Cooper Lake SP */
+    case 0x6a: /* Ice Lake SP */
+    case 0x6c: /* Ice Lake D */
+    case 0x7e: /* Ice Lake U/Y */
+    case 0x8c: /* Tiger Lake U */
+    case 0x8d: /* Tiger Lake H */
+    case 0x8e: /* Amber/Kaby/Coffee/Whiskey/Comet lake U/Y */
+    case 0x9e: /* Kaby/Coffee lake H/S/Xeon */
+    case 0xa5: /* Comet Lake H/S */
+    case 0xa6: /* Comet Lake U */
+    case 0xa7: /* Rocket Lake */
+        return true;
+
+    default:
+        /*
+         * If we've got here and are virtualised, we're most likely under a
+         * hypervisor unaware of GDS at which point we've lost.  Err on the
+         * safe side.
+         */
+        return cpu_has_hypervisor;
+    }
+}
+
+static void __init gds_calculations(void)
+{
+    bool cpu_has_bug_gds, mitigated = false;
+
+    /* GDS is only known to affect Intel Family 6 processors at this time. */
+    if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ||
+         boot_cpu_data.x86 != 6 )
+        return;
+
+    cpu_has_bug_gds = cpu_has_gds();
+
+    /*
+     * If we've got GDS_CTRL, we're either native with up-to-date microcode on
+     * a GDS-vulnerable part, or virtualised under a GDS-aware hypervisor.
+     */
+    if ( cpu_has_gds_ctrl )
+    {
+        bool locked;
+        uint64_t opt_ctrl;
+
+        if ( cpu_has_gds_no )
+        {
+            /*
+             * We don't expect to ever see GDS_CTL and GDS_NO set together.
+             * Complain loudly, and forgo playing with other features.
+             */
+            printk(XENLOG_ERR
+                   "FIRMWARE BUG: CPU %02x-%02x-%02x, ucode 0x%08x: GDS_CTRL && GDS_NO\n",
+                   boot_cpu_data.x86, boot_cpu_data.x86_model,
+                   boot_cpu_data.x86_mask, this_cpu(cpu_sig).rev);
+            return add_taint(TAINT_CPU_OUT_OF_SPEC);
+        }
+
+        rdmsrl(MSR_MCU_OPT_CTRL, opt_ctrl);
+
+        mitigated = !(opt_ctrl & MCU_OPT_CTRL_GDS_MIT_DIS);
+        locked    =   opt_ctrl & MCU_OPT_CTRL_GDS_MIT_LOCK;
+
+        /*
+         * Firmware will lock the GDS mitigation if e.g. SGX is active.
+         * Alternatively, a hypervisor might virtualise GDS_CTRL as locked.
+         * Warn if the mitigiation is locked and the user requested the
+         * opposite configuration.
+         */
+        if ( locked )
+        {
+            if ( opt_gds_mit >= 0 && opt_gds_mit != mitigated )
+                printk(XENLOG_WARNING
+                       "GDS_MIT locked by firwmare - ignoring spec-ctrl=gds-mit setting\n");
+            opt_gds_mit = mitigated;
+        }
+        else if ( opt_gds_mit == -1 )
+            opt_gds_mit = cpu_has_bug_gds; /* Mitigate GDS by default */
+
+        /*
+         * Latch our choice of GDS_MIT for all CPUs to pick up.  If LOCK is
+         * set, we latch the same value as it currently holds.
+         */
+        set_in_mcu_opt_ctrl(MCU_OPT_CTRL_GDS_MIT_DIS,
+                            opt_gds_mit ? 0 : MCU_OPT_CTRL_GDS_MIT_DIS);
+        mitigated = opt_gds_mit;
+    }
+    else if ( opt_gds_mit == -1 )
+        opt_gds_mit = cpu_has_bug_gds; /* Mitigate GDS by default */
+
+    /*
+     * If we think we're not on vulnerable hardware, or we've mitigated GDS,
+     * synthesize GDS_NO.  This is mostly for the benefit of guests, to inform
+     * them not to panic.
+     */
+    if ( !cpu_has_bug_gds || mitigated )
+        return setup_force_cpu_cap(X86_FEATURE_GDS_NO);
+
+    /*
+     * If all else has failed, mitigate by disabling AVX.  This prevents
+     * guests from enabling %xcr0.ymm, thereby blocking the use of VGATHER
+     * instructions.
+     *
+     * There's at least one affected CPU not expected to recieve a microcode
+     * update, and this is the only remaining mitigation.
+     *
+     * If we're virtualised, this prevents our guests attacking each other,
+     * but it doesn't stop the outer hypervisor's guests attacking us.  Leave
+     * a note to this effect.
+     */
+    if ( cpu_has_avx && opt_gds_mit )
+    {
+        setup_clear_cpu_cap(X86_FEATURE_AVX);
+        printk(XENLOG_WARNING "Mitigating GDS by disabling AVX%s\n",
+               cpu_has_hypervisor ?
+               " while virtualised - protections are best-effort" : "");
+    }
+}
+
 void spec_ctrl_init_domain(struct domain *d)
 {
     bool pv = is_pv_domain(d);
@@ -1661,6 +1817,8 @@ void __init init_speculation_mitigations(void)
                             opt_srb_lock ? 0 : MCU_OPT_CTRL_RNGDS_MITG_DIS);
     }
 
+    gds_calculations();
+
     print_details(thunk);
 
     /*
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:08:11 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:08:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680953.1059372 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGrr-0000iU-5W; Wed, 14 Feb 2024 15:08:11 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680953.1059372; Wed, 14 Feb 2024 15:08:11 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGrr-0000iL-1f; Wed, 14 Feb 2024 15:08:11 +0000
Received: by outflank-mailman (input) for mailman id 680953;
 Wed, 14 Feb 2024 15:08:10 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGrp-0000iB-VC
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:08:09 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGrp-0005x7-UV
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:08:09 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGrp-00018k-Tp
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:08:09 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=G4jXBXY/zOXhMaDOndXjkIxCMRLRIZIfHh2WBA2vOa0=; b=ebSYMKpooT5Ov6KavYcn4Af4BA
	/LrP4XiKPCmsi/3+JmbahUuf0zh6Ev/PeG6IdlCFRCcz/+aQODe5BpIaFzr4AGWjrwxcE8WcNS6MX
	AQwq7dHRELGN81GFyqqmpzI4ToINIE68/sssgG2zGL/B047gmHOJtazXzQcj1CwkLsnU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.14] Update Xen to version 4.14.6
Message-Id: <E1raGrp-00018k-Tp@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:08:09 +0000

commit 297fce96e1329107f48c08f539bc3000652610cd
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon Aug 7 13:11:10 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Aug 7 13:11:14 2023 +0100

    Update Xen to version 4.14.6
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/Makefile b/xen/Makefile
index 46c8177d74..4dc707e72f 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -2,7 +2,7 @@
 # All other places this is stored (eg. compile.h) should be autogenerated.
 export XEN_VERSION       = 4
 export XEN_SUBVERSION    = 14
-export XEN_EXTRAVERSION ?= .5$(XEN_VENDORVERSION)
+export XEN_EXTRAVERSION ?= .6$(XEN_VENDORVERSION)
 export XEN_FULLVERSION   = $(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION)
 -include xen-version
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.14


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:08:22 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:08:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680955.1059385 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGs2-00011L-CC; Wed, 14 Feb 2024 15:08:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680955.1059385; Wed, 14 Feb 2024 15:08:22 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGs2-00011D-9V; Wed, 14 Feb 2024 15:08:22 +0000
Received: by outflank-mailman (input) for mailman id 680955;
 Wed, 14 Feb 2024 15:08:20 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGs0-00010Q-BN
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:08:20 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGs0-0005xM-Ad
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:08:20 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGs0-0001AP-9r
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:08:20 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=m/dT/h9rpbo5uTtSH3ynabJ2toxG+czSbD09fmsi3A8=; b=kxyjR/ETQBRHUE0RXh8kWGTKvj
	jnub4Mv6zcrMTiYFVqckfgfPPKVGXHOq/6j8USX7MXzDATCik2jMsooopS1BapZ8aL5RySLGRkTE6
	hdLuDSG7pVonedDKKYhhRQGbJ60OfBeEpX7U0nu3U9ldA/wal10a+jPTuUsbsSaaVIjc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.13] x86/spec-ctrl: Enumeration for IBPB_RET
Message-Id: <E1raGs0-0001AP-9r@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:08:20 +0000

commit c0de5d3b482d5ac84998ee44201796bc49be61ac
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Jun 14 16:18:36 2022 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Nov 4 13:24:37 2022 +0000

    x86/spec-ctrl: Enumeration for IBPB_RET
    
    The IBPB_RET bit indicates that the CPU's implementation of MSR_PRED_CMD.IBPB
    does flush the RSB/RAS too.
    
    This is part of XSA-422 / CVE-2022-23824.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 24496558e650535bdbd22cc04731e82276cd1b3f)
---
 tools/libxl/libxl_cpuid.c                   | 1 +
 tools/misc/xen-cpuid.c                      | 1 +
 xen/arch/x86/spec_ctrl.c                    | 5 +++--
 xen/include/public/arch-x86/cpufeatureset.h | 1 +
 4 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl_cpuid.c b/tools/libxl/libxl_cpuid.c
index 11b43807e9..694e554c96 100644
--- a/tools/libxl/libxl_cpuid.c
+++ b/tools/libxl/libxl_cpuid.c
@@ -275,6 +275,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str)
         {"ssb-no",       0x80000008, NA, CPUID_REG_EBX, 26,  1},
         {"psfd",         0x80000008, NA, CPUID_REG_EBX, 28,  1},
         {"btc-no",       0x80000008, NA, CPUID_REG_EBX, 29,  1},
+        {"ibpb-ret",     0x80000008, NA, CPUID_REG_EBX, 30,  1},
 
         {"nc",           0x80000008, NA, CPUID_REG_ECX,  0,  8},
         {"apicidsize",   0x80000008, NA, CPUID_REG_ECX, 12,  4},
diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
index 52f5059d8f..d2add75f43 100644
--- a/tools/misc/xen-cpuid.c
+++ b/tools/misc/xen-cpuid.c
@@ -157,6 +157,7 @@ static const char *const str_e8b[32] =
     [24] = "amd-ssbd",         [25] = "virt-ssbd",
     [26] = "ssb-no",
     [28] = "psfd",             [29] = "btc-no",
+    [30] = "ibpb-ret",
 };
 
 static const char *const str_7d0[32] =
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index bfa5d27e00..23bc870d3c 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -418,7 +418,7 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)
      * Hardware read-only information, stating immunity to certain issues, or
      * suggestions of which mitigation to use.
      */
-    printk("  Hardware hints:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
+    printk("  Hardware hints:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
            (caps & ARCH_CAPS_RDCL_NO)                        ? " RDCL_NO"        : "",
            (caps & ARCH_CAPS_IBRS_ALL)                       ? " IBRS_ALL"       : "",
            (caps & ARCH_CAPS_RSBA)                           ? " RSBA"           : "",
@@ -434,7 +434,8 @@ static void __init print_details(enum ind_thunk thunk, uint64_t caps)
            (e8b  & cpufeat_mask(X86_FEATURE_STIBP_ALWAYS))   ? " STIBP_ALWAYS"   : "",
            (e8b  & cpufeat_mask(X86_FEATURE_IBRS_FAST))      ? " IBRS_FAST"      : "",
            (e8b  & cpufeat_mask(X86_FEATURE_IBRS_SAME_MODE)) ? " IBRS_SAME_MODE" : "",
-           (e8b  & cpufeat_mask(X86_FEATURE_BTC_NO))         ? " BTC_NO"         : "");
+           (e8b  & cpufeat_mask(X86_FEATURE_BTC_NO))         ? " BTC_NO"         : "",
+           (e8b  & cpufeat_mask(X86_FEATURE_IBPB_RET))       ? " IBPB_RET"       : "");
 
     /* Hardware features which need driving to mitigate issues. */
     printk("  Hardware features:%s%s%s%s%s%s%s%s%s%s%s%s\n",
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index 44b3ba331f..ddcfa5e807 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -259,6 +259,7 @@ XEN_CPUFEATURE(VIRT_SSBD,     8*32+25) /*   MSR_VIRT_SPEC_CTRL.SSBD */
 XEN_CPUFEATURE(SSB_NO,        8*32+26) /*   Hardware not vulnerable to SSB */
 XEN_CPUFEATURE(PSFD,          8*32+28) /*   MSR_SPEC_CTRL.PSFD */
 XEN_CPUFEATURE(BTC_NO,        8*32+29) /*A  Hardware not vulnerable to Branch Type Confusion */
+XEN_CPUFEATURE(IBPB_RET,      8*32+30) /*A  IBPB clears RSB/RAS too. */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:0.edx, word 9 */
 XEN_CPUFEATURE(AVX512_4VNNIW, 9*32+ 2) /*A  AVX512 Neural Network Instructions */
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.13


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:08:32 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:08:32 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680956.1059388 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGsC-00017g-Dd; Wed, 14 Feb 2024 15:08:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680956.1059388; Wed, 14 Feb 2024 15:08:32 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGsC-00017X-B0; Wed, 14 Feb 2024 15:08:32 +0000
Received: by outflank-mailman (input) for mailman id 680956;
 Wed, 14 Feb 2024 15:08:30 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGsA-00016m-EI
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:08:30 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGsA-0005xX-Dc
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:08:30 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGsA-0001BS-Ct
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:08:30 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=lRb7dZVpMklMnLq2bk9N9re8ufdY5SzFRiTCKP4s0j4=; b=q19lGbbJby86Fwa6WqSe79Gf+5
	vpFmUzqOeVx9DQzRCdc8gaHPMdx58hwctikia3GNmjJ195QxCueDerpO+hUNMtoHb+7WvE9Y3Emmr
	4DFkMFkU3ccM2SIkPicx4dQmErHSDRfhmM4HNZ792JlukE2HV1/PJSwWL+FajwDbMje8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.13] x86/spec-ctrl: Mitigate IBPB not flushing the RSB/RAS
Message-Id: <E1raGsA-0001BS-Ct@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:08:30 +0000

commit 1151d260d7a0186978b80b708fcb712eb1470f49
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Jun 14 16:18:36 2022 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Nov 4 13:24:37 2022 +0000

    x86/spec-ctrl: Mitigate IBPB not flushing the RSB/RAS
    
    Introduce spec_ctrl_new_guest_context() to encapsulate all logic pertaining to
    using MSR_PRED_CMD for a new guest context, even if it only has one user
    presently.
    
    Introduce X86_BUG_IBPB_NO_RET, and use it extend spec_ctrl_new_guest_context()
    with a manual fixup for hardware which mis-implements IBPB.
    
    This is part of XSA-422 / CVE-2022-23824.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    (cherry picked from commit 2b27967fb89d7904a1571a2fb963b1c9cac548db)
---
 xen/arch/x86/asm-macros.c         |  1 +
 xen/arch/x86/domain.c             |  2 +-
 xen/arch/x86/spec_ctrl.c          |  8 ++++++++
 xen/include/asm-x86/cpufeatures.h |  1 +
 xen/include/asm-x86/spec_ctrl.h   | 22 ++++++++++++++++++++++
 5 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/asm-macros.c b/xen/arch/x86/asm-macros.c
index b963d56a56..8c585697b9 100644
--- a/xen/arch/x86/asm-macros.c
+++ b/xen/arch/x86/asm-macros.c
@@ -1 +1,2 @@
 #include <asm/alternative-asm.h>
+#include <asm/spec_ctrl_asm.h>
diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 6996c6b06a..c14cc724fa 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -1814,7 +1814,7 @@ void context_switch(struct vcpu *prev, struct vcpu *next)
              */
             if ( *last_id != next_id )
             {
-                wrmsrl(MSR_PRED_CMD, PRED_CMD_IBPB);
+                spec_ctrl_new_guest_context();
                 *last_id = next_id;
             }
         }
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 23bc870d3c..0dbb7d5f87 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -773,6 +773,14 @@ static void __init ibpb_calculations(void)
         return;
     }
 
+    /*
+     * AMD/Hygon CPUs to date (June 2022) don't flush the the RAS.  Future
+     * CPUs are expected to enumerate IBPB_RET when this has been fixed.
+     * Until then, cover the difference with the software sequence.
+     */
+    if ( boot_cpu_has(X86_FEATURE_IBPB) && !boot_cpu_has(X86_FEATURE_IBPB_RET) )
+        setup_force_cpu_cap(X86_BUG_IBPB_NO_RET);
+
     /*
      * IBPB-on-entry mitigations for Branch Type Confusion.
      *
diff --git a/xen/include/asm-x86/cpufeatures.h b/xen/include/asm-x86/cpufeatures.h
index c6136ca4a0..730eac4b2f 100644
--- a/xen/include/asm-x86/cpufeatures.h
+++ b/xen/include/asm-x86/cpufeatures.h
@@ -46,6 +46,7 @@ XEN_CPUFEATURE(IBPB_ENTRY_HVM,    X86_SYNTH(27)) /* MSR_PRED_CMD used by Xen for
 
 #define X86_BUG_FPU_PTRS          X86_BUG( 0) /* (F)X{SAVE,RSTOR} doesn't save/restore FOP/FIP/FDP. */
 #define X86_BUG_CLFLUSH_MFENCE    X86_BUG( 2) /* MFENCE needed to serialise CLFLUSH */
+#define X86_BUG_IBPB_NO_RET       X86_BUG( 3) /* IBPB doesn't flush the RSB/RAS */
 
 /* Total number of capability words, inc synth and bug words. */
 #define NCAPINTS (FSCAPINTS + X86_NR_SYNTH + X86_NR_BUG) /* N 32-bit words worth of info */
diff --git a/xen/include/asm-x86/spec_ctrl.h b/xen/include/asm-x86/spec_ctrl.h
index 2f15ae9814..fcaef49629 100644
--- a/xen/include/asm-x86/spec_ctrl.h
+++ b/xen/include/asm-x86/spec_ctrl.h
@@ -65,6 +65,28 @@
 void init_speculation_mitigations(void);
 void spec_ctrl_init_domain(struct domain *d);
 
+/*
+ * Switch to a new guest prediction context.
+ *
+ * This flushes all indirect branch predictors (BTB, RSB/RAS), so guest code
+ * which has previously run on this CPU can't attack subsequent guest code.
+ *
+ * As this flushes the RSB/RAS, it destroys the predictions of the calling
+ * context.  For best performace, arrange for this to be used when we're going
+ * to jump out of the current context, e.g. with reset_stack_and_jump().
+ *
+ * For hardware which mis-implements IBPB, fix up by flushing the RSB/RAS
+ * manually.
+ */
+static always_inline void spec_ctrl_new_guest_context(void)
+{
+    wrmsrl(MSR_PRED_CMD, PRED_CMD_IBPB);
+
+    /* (ab)use alternative_input() to specify clobbers. */
+    alternative_input("", "DO_OVERWRITE_RSB", X86_BUG_IBPB_NO_RET,
+                      : "rax", "rcx");
+}
+
 extern int8_t opt_ibpb_ctxt_switch;
 extern bool opt_ssbd;
 extern int8_t opt_eager_fpu;
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.13


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:08:42 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:08:42 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680958.1059393 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGsM-0001CH-FD; Wed, 14 Feb 2024 15:08:42 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680958.1059393; Wed, 14 Feb 2024 15:08:42 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGsM-0001C9-CT; Wed, 14 Feb 2024 15:08:42 +0000
Received: by outflank-mailman (input) for mailman id 680958;
 Wed, 14 Feb 2024 15:08:40 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGsK-0001Bk-HB
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:08:40 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGsK-0005xe-GN
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:08:40 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGsK-0001CN-Fg
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:08:40 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=SSXlbgmgkdWAxQdKU9GfiZfUO3BflxXt2bKlM8Im95c=; b=xQUJH7OlFBWgAT7DcIEeSDxg3P
	0mCBM2R7GUV57DwxDofFmYRSrt2UagrPabK/hwE4mTKJ8wIfCshMMgrE3IKx2KXZAiwZsQF77F65A
	a68BpZvWO8oyX1YtDi40EIusqrzpWi7lc/U12zWlKe98H768QhLKtR7PNTkRytlZX3Cw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.13] update Xen version to 4.13.5
Message-Id: <E1raGsK-0001CN-Fg@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:08:40 +0000

commit 708e83f0e7d1e32295fee58c71c1e972d4e61f56
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Dec 19 09:10:08 2022 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Dec 19 09:10:08 2022 +0100

    update Xen version to 4.13.5
---
 Config.mk    | 6 +++---
 xen/Makefile | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/Config.mk b/Config.mk
index da96fe34cd..0ee845e5d2 100644
--- a/Config.mk
+++ b/Config.mk
@@ -288,15 +288,15 @@ SEABIOS_UPSTREAM_URL ?= git://xenbits.xen.org/seabios.git
 MINIOS_UPSTREAM_URL ?= git://xenbits.xen.org/mini-os.git
 endif
 OVMF_UPSTREAM_REVISION ?= 20d2e5a125e34fc8501026613a71549b2a1a3e54
-QEMU_UPSTREAM_REVISION ?= qemu-xen-4.13.4
-MINIOS_UPSTREAM_REVISION ?= xen-RELEASE-4.13.4
+QEMU_UPSTREAM_REVISION ?= qemu-xen-4.13.5
+MINIOS_UPSTREAM_REVISION ?= xen-RELEASE-4.13.5
 
 SEABIOS_UPSTREAM_REVISION ?= rel-1.12.1
 
 ETHERBOOT_NICS ?= rtl8139 8086100e
 
 
-QEMU_TRADITIONAL_REVISION ?= xen-4.13.4
+QEMU_TRADITIONAL_REVISION ?= xen-4.13.5
 # Wed Oct 10 18:52:54 2018 +0000
 # xen/pt: allow QEMU to request MSI unmasking at bind time
 
diff --git a/xen/Makefile b/xen/Makefile
index f88e068559..7cd3abee6d 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -2,7 +2,7 @@
 # All other places this is stored (eg. compile.h) should be autogenerated.
 export XEN_VERSION       = 4
 export XEN_SUBVERSION    = 13
-export XEN_EXTRAVERSION ?= .4$(XEN_VENDORVERSION)
+export XEN_EXTRAVERSION ?= .5$(XEN_VENDORVERSION)
 export XEN_FULLVERSION   = $(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION)
 -include xen-version
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.13


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:10:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:10:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680960.1059397 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGuH-0002NL-Lx; Wed, 14 Feb 2024 15:10:41 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680960.1059397; Wed, 14 Feb 2024 15:10:41 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGuH-0002NE-I2; Wed, 14 Feb 2024 15:10:41 +0000
Received: by outflank-mailman (input) for mailman id 680960;
 Wed, 14 Feb 2024 15:10:39 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGuF-0002N4-RM
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:10:39 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGuF-0005zT-Np
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:10:39 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGuF-0004pq-MV
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:10:39 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=omu7hQfCZFvlZsiJ1BgbRKctKuG7qCAk5A9Vt6kNjKA=; b=V0hHrO718arLtKYEj1IjOWMCjW
	JA8g46nfGQOYrxhNmSJRm8Gru3c0v5BId61V4z0M3wyAfBgIWa/4aCY1orgDF7j/yWOoaVSpv1KjQ
	ul/27mETYCfA6vjRR8TsPFR1F+SAK+gzIuxa+Ue7kat1qHdtLTRxqCOsiUyWpSsWAAkc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging] Merge tag 'v7.2.0' into 'staging'
Message-Id: <E1raGuF-0004pq-MV@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:10:39 +0000

=== This changeset includes merge from high-traffic branch ===
Commits on that branch are not reported individually.

commit efb74542d6fbb814408c80f97048c7809aad759a
Merge: b67b00e6b4c7831a3f5bc684bc0df7a9bfd1bd56 b746458e1ce1bec85e58b458386f8b7a0bedfaa6
Author:     Anthony PERARD <anthony.perard@gmail.com>
AuthorDate: Thu Dec 15 15:12:57 2022 +0000
Commit:     Anthony PERARD <anthony.perard@gmail.com>
CommitDate: Thu Dec 15 15:12:57 2022 +0000

    Merge tag 'v7.2.0' into 'staging'
 .cirrus.yml                                        |     4 +-
 .github/workflows/lockdown.yml                     |     6 +-
 .gitignore                                         |     4 +
 .gitlab-ci.d/base.yml                              |    72 +
 .gitlab-ci.d/buildtest-template.yml                |    30 +-
 .gitlab-ci.d/buildtest.yml                         |    81 +-
 .gitlab-ci.d/cirrus.yml                            |    30 +-
 .gitlab-ci.d/cirrus/build.yml                      |     3 +-
 .gitlab-ci.d/cirrus/freebsd-12.vars                |     2 +-
 .gitlab-ci.d/cirrus/freebsd-13.vars                |     2 +-
 .gitlab-ci.d/cirrus/macos-11.vars                  |    16 -
 .gitlab-ci.d/cirrus/macos-12.vars                  |    16 +
 .gitlab-ci.d/container-core.yml                    |     5 -
 .gitlab-ci.d/container-cross.yml                   |    58 +-
 .gitlab-ci.d/container-template.yml                |     1 +
 .gitlab-ci.d/containers.yml                        |    13 +-
 .gitlab-ci.d/crossbuild-template.yml               |     8 +-
 .gitlab-ci.d/crossbuilds.yml                       |    16 +-
 .gitlab-ci.d/custom-runners.yml                    |     4 +-
 .../custom-runners/centos-stream-8-x86_64.yml      |     2 +
 .../custom-runners/ubuntu-20.04-aarch32.yml        |    23 -
 .../custom-runners/ubuntu-20.04-aarch64.yml        |   118 -
 .gitlab-ci.d/custom-runners/ubuntu-20.04-s390x.yml |    25 +-
 .../custom-runners/ubuntu-22.04-aarch32.yml        |    25 +
 .../custom-runners/ubuntu-22.04-aarch64.yml        |   130 +
 .gitlab-ci.d/edk2.yml                              |   133 +-
 .gitlab-ci.d/opensbi.yml                           |   134 +-
 .gitlab-ci.d/qemu-project.yml                      |     1 +
 .gitlab-ci.d/stages.yml                            |     1 -
 .gitlab-ci.d/static_checks.yml                     |    33 +-
 .gitlab-ci.d/windows.yml                           |    25 +-
 .gitmodules                                        |     9 +-
 .mailmap                                           |     8 +-
 .travis.yml                                        |     8 +-
 Kconfig.host                                       |     7 +-
 MAINTAINERS                                        |   320 +-
 Makefile                                           |    36 +-
 README.rst                                         |     4 +-
 VERSION                                            |     2 +-
 accel/accel-common.c                               |    18 +
 accel/accel-softmmu.c                              |     8 +-
 accel/dummy-cpus.c                                 |    14 +-
 accel/hvf/hvf-accel-ops.c                          |     6 +-
 accel/hvf/hvf-all.c                                |     1 -
 accel/kvm/kvm-accel-ops.c                          |     9 +
 accel/kvm/kvm-all.c                                |   639 +-
 accel/kvm/kvm-cpus.h                               |     4 +
 accel/meson.build                                  |     2 +-
 accel/qtest/meson.build                            |     3 +-
 accel/stubs/kvm-stub.c                             |    26 +-
 accel/stubs/tcg-stub.c                             |    15 +-
 accel/tcg/atomic_template.h                        |     4 +-
 accel/tcg/cpu-exec-common.c                        |     2 +-
 accel/tcg/cpu-exec.c                               |   252 +-
 accel/tcg/cputlb.c                                 |   399 +-
 accel/tcg/hmp.c                                    |     1 -
 accel/tcg/internal.h                               |   104 +-
 accel/tcg/meson.build                              |     1 +
 accel/tcg/plugin-gen.c                             |    22 +-
 accel/tcg/tb-hash.h                                |     1 +
 accel/tcg/tb-jmp-cache.h                           |    65 +
 accel/tcg/tb-maint.c                               |   704 +
 accel/tcg/tcg-accel-ops-icount.c                   |    13 +-
 accel/tcg/tcg-accel-ops-icount.h                   |     6 +-
 accel/tcg/tcg-accel-ops-mttcg.c                    |     1 -
 accel/tcg/tcg-accel-ops-mttcg.h                    |     6 +-
 accel/tcg/tcg-accel-ops-rr.c                       |     3 +-
 accel/tcg/tcg-accel-ops-rr.h                       |     6 +-
 accel/tcg/tcg-accel-ops.c                          |   114 +-
 accel/tcg/tcg-accel-ops.h                          |     6 +-
 accel/tcg/tcg-all.c                                |    18 +-
 accel/tcg/translate-all.c                          |  1352 +-
 accel/tcg/translator.c                             |   150 +-
 accel/tcg/user-exec.c                              |    66 +-
 audio/alsaaudio.c                                  |    38 +-
 audio/audio.c                                      |   195 +-
 audio/audio.h                                      |     6 +-
 audio/audio_int.h                                  |     4 +-
 audio/audio_template.h                             |    33 +-
 audio/audio_win_int.c                              |     1 -
 audio/dbusaudio.c                                  |     6 +-
 audio/meson.build                                  |     3 +-
 audio/noaudio.c                                    |     4 +-
 audio/rate_template.h                              |    11 +-
 audio/sndioaudio.c                                 |   565 +
 audio/spiceaudio.c                                 |    19 +-
 audio/wavaudio.c                                   |     2 +-
 backends/cryptodev-builtin.c                       |   313 +-
 backends/cryptodev-lkcf.c                          |   645 +
 backends/cryptodev-vhost-user.c                    |    71 +-
 backends/cryptodev-vhost.c                         |     4 +-
 backends/cryptodev.c                               |    68 +-
 backends/dbus-vmstate.c                            |    13 +-
 backends/hostmem-epc.c                             |     1 -
 backends/hostmem.c                                 |    29 +-
 backends/meson.build                               |    13 +-
 backends/rng-egd.c                                 |     2 +-
 backends/rng-random.c                              |     2 +-
 backends/rng.c                                     |    18 +-
 backends/tpm/tpm_emulator.c                        |    70 +-
 backends/tpm/tpm_ioctl.h                           |   100 +-
 backends/tpm/tpm_passthrough.c                     |     1 -
 backends/tpm/trace-events                          |     2 +
 backends/vhost-user.c                              |     6 +-
 block.c                                            |   931 +-
 block/accounting.c                                 |    26 +-
 block/backup.c                                     |     8 +-
 block/blkdebug.c                                   |    11 +-
 block/blkio.c                                      |  1046 +
 block/blklogwrites.c                               |    17 +-
 block/blkreplay.c                                  |     7 +-
 block/blkverify.c                                  |    15 +-
 block/block-backend.c                              |   276 +-
 block/block-copy.c                                 |    33 +-
 block/block-ram-registrar.c                        |    58 +
 block/bochs.c                                      |    17 +-
 block/cloop.c                                      |    19 +-
 block/commit.c                                     |     7 +-
 block/copy-before-write.c                          |   126 +-
 block/copy-on-read.c                               |     9 +-
 block/copy-on-read.h                               |     6 +-
 block/coroutines.h                                 |    55 +-
 block/crypto.c                                     |    73 +-
 block/curl.c                                       |     2 +-
 block/dirty-bitmap.c                               |    26 +-
 block/dmg.c                                        |    74 +-
 block/export/export.c                              |     8 +-
 block/export/fuse.c                                |     4 +-
 block/export/meson.build                           |     7 +-
 block/export/vduse-blk.c                           |   374 +
 block/export/vduse-blk.h                           |    20 +
 block/export/vhost-user-blk-server.c               |   263 +-
 block/export/virtio-blk-handler.c                  |   240 +
 block/export/virtio-blk-handler.h                  |    37 +
 block/file-posix.c                                 |    58 +-
 block/filter-compress.c                            |     8 +-
 block/gluster.c                                    |     7 +-
 block/io.c                                         |   255 +-
 block/io_uring.c                                   |    13 +-
 block/iscsi.c                                      |     7 +-
 block/linux-aio.c                                  |    12 +-
 block/meson.build                                  |     3 +
 block/mirror.c                                     |   106 +-
 block/monitor/bitmap-qmp-cmds.c                    |    46 +-
 block/monitor/block-hmp-cmds.c                     |    12 +-
 block/nbd.c                                        |   306 +-
 block/nfs.c                                        |    10 +-
 block/nvme.c                                       |    96 +-
 block/parallels-ext.c                              |     6 +-
 block/parallels.c                                  |    55 +-
 block/preallocate.c                                |     9 +-
 block/qapi-sysemu.c                                |     3 +-
 block/qcow.c                                       |    91 +-
 block/qcow2-bitmap.c                               |    28 +-
 block/qcow2-cache.c                                |    11 +-
 block/qcow2-cluster.c                              |    69 +-
 block/qcow2-refcount.c                             |   425 +-
 block/qcow2-snapshot.c                             |    55 +-
 block/qcow2.c                                      |   233 +-
 block/qcow2.h                                      |    51 +-
 block/qed-table.c                                  |     2 +-
 block/qed.c                                        |    53 +-
 block/quorum.c                                     |    38 +-
 block/raw-format.c                                 |    13 +-
 block/rbd.c                                        |    24 +
 block/replication.c                                |    12 +-
 block/snapshot-access.c                            |     6 +-
 block/snapshot.c                                   |    59 +-
 block/ssh.c                                        |     7 +-
 block/throttle.c                                   |    10 +-
 block/trace-events                                 |     2 +
 block/vdi.c                                        |    32 +-
 block/vhdx-log.c                                   |    23 +-
 block/vhdx.c                                       |    68 +-
 block/vmdk.c                                       |   227 +-
 block/vpc.c                                        |    42 +-
 block/vvfat.c                                      |    55 +-
 blockdev-nbd.c                                     |    21 +-
 blockdev.c                                         |   178 +-
 blockjob.c                                         |   181 +-
 bsd-user/arm/target.h                              |     2 +-
 bsd-user/arm/target_arch.h                         |     6 +-
 bsd-user/arm/target_arch_cpu.h                     |     6 +-
 bsd-user/arm/target_arch_elf.h                     |     7 +-
 bsd-user/arm/target_arch_reg.h                     |     6 +-
 bsd-user/arm/target_arch_signal.h                  |     7 +-
 bsd-user/arm/target_arch_sigtramp.h                |     6 +-
 bsd-user/arm/target_arch_sysarch.h                 |     6 +-
 bsd-user/arm/target_arch_thread.h                  |     7 +-
 bsd-user/arm/target_arch_vmparam.h                 |     7 +-
 bsd-user/arm/target_syscall.h                      |     6 +-
 bsd-user/bsd-file.h                                |   918 +-
 bsd-user/bsd-proc.h                                |    42 +
 bsd-user/elfload.c                                 |     2 +-
 bsd-user/errno_defs.h                              |     6 +-
 bsd-user/freebsd/host-os.h                         |     6 +-
 bsd-user/freebsd/os-syscall.c                      |   452 +-
 bsd-user/freebsd/target_os_elf.h                   |     7 +-
 bsd-user/freebsd/target_os_siginfo.h               |     7 +-
 bsd-user/freebsd/target_os_signal.h                |     6 +-
 bsd-user/freebsd/target_os_stack.h                 |     6 +-
 bsd-user/freebsd/target_os_thread.h                |     6 +-
 bsd-user/freebsd/target_os_user.h                  |     6 +-
 bsd-user/freebsd/target_os_vmparam.h               |     7 +-
 bsd-user/host/i386/host-signal.h                   |     1 +
 bsd-user/host/x86_64/host-signal.h                 |     1 +
 bsd-user/i386/target.h                             |     7 +-
 bsd-user/i386/target_arch.h                        |     6 +-
 bsd-user/i386/target_arch_cpu.h                    |     6 +-
 bsd-user/i386/target_arch_elf.h                    |     7 +-
 bsd-user/i386/target_arch_reg.h                    |     6 +-
 bsd-user/i386/target_arch_sigtramp.h               |     6 +-
 bsd-user/i386/target_arch_sysarch.h                |     6 +-
 bsd-user/i386/target_arch_thread.h                 |     7 +-
 bsd-user/i386/target_arch_vmparam.h                |     7 +-
 bsd-user/main.c                                    |    59 +-
 bsd-user/mmap.c                                    |     5 +-
 bsd-user/netbsd/host-os.h                          |     6 +-
 bsd-user/netbsd/target_os_elf.h                    |     7 +-
 bsd-user/netbsd/target_os_siginfo.h                |     6 +-
 bsd-user/netbsd/target_os_signal.h                 |     6 +-
 bsd-user/netbsd/target_os_stack.h                  |     6 +-
 bsd-user/netbsd/target_os_thread.h                 |     6 +-
 bsd-user/openbsd/host-os.h                         |     6 +-
 bsd-user/openbsd/target_os_elf.h                   |     7 +-
 bsd-user/openbsd/target_os_siginfo.h               |     6 +-
 bsd-user/openbsd/target_os_signal.h                |     6 +-
 bsd-user/openbsd/target_os_stack.h                 |     6 +-
 bsd-user/openbsd/target_os_thread.h                |     6 +-
 bsd-user/qemu.h                                    |     2 +-
 bsd-user/signal.c                                  |     3 +-
 bsd-user/syscall_defs.h                            |    10 +-
 bsd-user/x86_64/target.h                           |     2 +-
 bsd-user/x86_64/target_arch.h                      |     6 +-
 bsd-user/x86_64/target_arch_cpu.h                  |     6 +-
 bsd-user/x86_64/target_arch_elf.h                  |     7 +-
 bsd-user/x86_64/target_arch_reg.h                  |     6 +-
 bsd-user/x86_64/target_arch_signal.h               |     7 +-
 bsd-user/x86_64/target_arch_sigtramp.h             |     6 +-
 bsd-user/x86_64/target_arch_sysarch.h              |     6 +-
 bsd-user/x86_64/target_arch_thread.h               |     7 +-
 bsd-user/x86_64/target_arch_vmparam.h              |     7 +-
 capstone                                           |     1 -
 chardev/baum.c                                     |    22 +-
 chardev/char-fd.c                                  |     5 +-
 chardev/char-io.c                                  |     2 +-
 chardev/char-pipe.c                                |     1 -
 chardev/char-pty.c                                 |   117 +-
 chardev/char-serial.c                              |     5 +-
 chardev/char-socket.c                              |     6 +-
 chardev/char-stdio.c                               |     5 +-
 chardev/char-win-stdio.c                           |     8 +-
 chardev/char.c                                     |     4 +-
 chardev/chardev-internal.h                         |     3 +-
 chardev/meson.build                                |     4 +-
 chardev/msmouse.c                                  |   152 +-
 chardev/wctablet.c                                 |     4 +-
 common-user/meson.build                            |     4 +
 configs/devices/hppa-softmmu/default.mak           |     2 +-
 configs/devices/loongarch64-softmmu/default.mak    |     3 +
 configs/devices/mips-softmmu/common.mak            |     1 -
 configs/devices/mips64el-softmmu/default.mak       |     1 -
 configs/devices/or1k-softmmu/default.mak           |     1 +
 configs/devices/ppc-softmmu/default.mak            |     3 +-
 configs/targets/aarch64-linux-user.mak             |     1 +
 configs/targets/aarch64_be-linux-user.mak          |     3 +-
 configs/targets/arm-linux-user.mak                 |     1 +
 configs/targets/armeb-linux-user.mak               |     3 +-
 configs/targets/hppa-linux-user.mak                |     2 +-
 configs/targets/hppa-softmmu.mak                   |     2 +-
 configs/targets/loongarch64-linux-user.mak         |     3 +
 configs/targets/loongarch64-softmmu.mak            |     5 +
 configs/targets/m68k-linux-user.mak                |     2 +-
 configs/targets/m68k-softmmu.mak                   |     2 +-
 configs/targets/microblaze-linux-user.mak          |     2 +-
 configs/targets/microblaze-softmmu.mak             |     2 +-
 configs/targets/mips-linux-user.mak                |     2 +-
 configs/targets/mips-softmmu.mak                   |     2 +-
 configs/targets/mips64-linux-user.mak              |     2 +-
 configs/targets/mips64-softmmu.mak                 |     2 +-
 configs/targets/mipsn32-linux-user.mak             |     2 +-
 configs/targets/nios2-softmmu.mak                  |     1 +
 configs/targets/or1k-linux-user.mak                |     2 +-
 configs/targets/or1k-softmmu.mak                   |     3 +-
 configs/targets/ppc-linux-user.mak                 |     2 +-
 configs/targets/ppc-softmmu.mak                    |     2 +-
 configs/targets/ppc64-linux-user.mak               |     2 +-
 configs/targets/ppc64-softmmu.mak                  |     2 +-
 configs/targets/riscv32-linux-user.mak             |     1 +
 configs/targets/riscv64-linux-user.mak             |     1 +
 configs/targets/s390x-linux-user.mak               |     2 +-
 configs/targets/s390x-softmmu.mak                  |     2 +-
 configs/targets/sh4eb-linux-user.mak               |     2 +-
 configs/targets/sh4eb-softmmu.mak                  |     2 +-
 configs/targets/sparc-linux-user.mak               |     2 +-
 configs/targets/sparc-softmmu.mak                  |     2 +-
 configs/targets/sparc32plus-linux-user.mak         |     2 +-
 configs/targets/sparc64-linux-user.mak             |     2 +-
 configs/targets/sparc64-softmmu.mak                |     2 +-
 configs/targets/xtensaeb-linux-user.mak            |     2 +-
 configs/targets/xtensaeb-softmmu.mak               |     2 +-
 configure                                          |  2044 +-
 contrib/elf2dmp/main.c                             |     7 +-
 contrib/elf2dmp/qemu_elf.c                         |    53 +
 contrib/gitdm/domain-map                           |     2 +
 contrib/gitdm/group-map-academics                  |     6 +
 contrib/gitdm/group-map-individuals                |     3 +
 contrib/ivshmem-server/ivshmem-server.c            |     2 +-
 contrib/plugins/Makefile                           |     1 +
 contrib/plugins/cache.c                            |     2 +-
 contrib/plugins/execlog.c                          |   137 +-
 contrib/rdmacm-mux/meson.build                     |     4 +-
 contrib/vhost-user-blk/meson.build                 |     3 +-
 contrib/vhost-user-blk/vhost-user-blk.c            |    18 +-
 contrib/vhost-user-gpu/vugbm.c                     |     2 +-
 contrib/vhost-user-scsi/vhost-user-scsi.c          |    82 +-
 cpu.c                                              |    44 +-
 cpus-common.c                                      |     8 +
 crypto/akcipher-gcrypt.c.inc                       |   595 +
 crypto/akcipher-nettle.c.inc                       |   451 +
 crypto/akcipher.c                                  |   126 +
 crypto/akcipherpriv.h                              |    55 +
 crypto/block-luks-priv.h                           |   143 +
 crypto/block-luks.c                                |   236 +-
 crypto/block.c                                     |     6 +-
 crypto/cipher-afalg.c                              |     1 -
 crypto/der.c                                       |   452 +
 crypto/der.h                                       |   286 +
 crypto/hash-afalg.c                                |     1 -
 crypto/ivgen-plain.h                               |     6 +-
 crypto/meson.build                                 |    11 +-
 crypto/pbkdf.c                                     |    23 +
 crypto/rsakey-builtin.c.inc                        |   200 +
 crypto/rsakey-nettle.c.inc                         |   158 +
 crypto/rsakey.c                                    |    86 +
 crypto/rsakey.h                                    |   101 +
 crypto/secret_common.c                             |    88 +-
 crypto/sm4.c                                       |    49 +
 crypto/tlscredsanon.c                              |    20 +-
 crypto/tlscredspsk.c                               |    36 +-
 crypto/tlscredsx509.c                              |    20 +-
 disas.c                                            |    56 +-
 disas/arm-a64.cc                                   |   101 -
 disas/arm.c                                        |  4012 ----
 disas/capstone.c                                   |    73 +-
 disas/i386.c                                       |  6771 ------
 disas/libvixl/LICENCE                              |    30 -
 disas/libvixl/README                               |    11 -
 disas/libvixl/meson.build                          |     7 -
 disas/libvixl/vixl/a64/assembler-a64.h             |  4624 ----
 disas/libvixl/vixl/a64/constants-a64.h             |  2116 --
 disas/libvixl/vixl/a64/cpu-a64.h                   |    83 -
 disas/libvixl/vixl/a64/decoder-a64.cc              |   877 -
 disas/libvixl/vixl/a64/decoder-a64.h               |   275 -
 disas/libvixl/vixl/a64/disasm-a64.cc               |  3495 ---
 disas/libvixl/vixl/a64/disasm-a64.h                |   177 -
 disas/libvixl/vixl/a64/instructions-a64.cc         |   622 -
 disas/libvixl/vixl/a64/instructions-a64.h          |   757 -
 disas/libvixl/vixl/code-buffer.h                   |   113 -
 disas/libvixl/vixl/compiler-intrinsics.cc          |   144 -
 disas/libvixl/vixl/compiler-intrinsics.h           |   155 -
 disas/libvixl/vixl/globals.h                       |   155 -
 disas/libvixl/vixl/invalset.h                      |   775 -
 disas/libvixl/vixl/platform.h                      |    39 -
 disas/libvixl/vixl/utils.cc                        |   142 -
 disas/libvixl/vixl/utils.h                         |   286 -
 disas/meson.build                                  |    11 +-
 disas/mips.c                                       |    12 +-
 disas/nanomips.c                                   | 21990 ++++++++++++++++++
 disas/nanomips.cpp                                 | 22398 -------------------
 disas/nanomips.h                                   |  1076 -
 disas/ppc.c                                        |  5435 -----
 disas/riscv.c                                      |  1632 +-
 disas/s390.c                                       |  1892 --
 docs/about/build-platforms.rst                     |    37 +-
 docs/about/deprecated.rst                          |   168 +-
 docs/about/removed-features.rst                    |    87 +-
 docs/ccid.txt                                      |   182 -
 docs/conf.py                                       |     2 +-
 docs/devel/acpi-bits.rst                           |   141 +
 docs/devel/build-system.rst                        |     5 -
 docs/devel/ci-jobs.rst.inc                         |   116 +-
 docs/devel/ci.rst                                  |    11 +-
 docs/devel/code-of-conduct.rst                     |     2 +
 docs/devel/fuzzing.rst                             |     4 +-
 docs/devel/index-api.rst                           |     1 -
 docs/devel/index-build.rst                         |     4 +-
 docs/devel/index-internals.rst                     |     2 +-
 docs/devel/index-process.rst                       |     2 +-
 docs/devel/index-tcg.rst                           |     2 +-
 docs/devel/index.rst                               |     2 -
 docs/devel/loads-stores.rst                        |     2 +-
 docs/devel/maintainers.rst                         |   107 +
 docs/devel/multiple-iothreads.txt                  |     4 +-
 docs/devel/qapi-code-gen.rst                       |    13 +-
 docs/devel/qom.rst                                 |     7 +-
 docs/devel/qtest.rst                               |     3 +-
 docs/devel/replay.rst                              |   306 +
 docs/devel/replay.txt                              |    46 -
 docs/devel/reset.rst                               |     8 +-
 docs/devel/style.rst                               |     2 +-
 docs/devel/submitting-a-patch.rst                  |   139 +-
 docs/devel/submitting-a-pull-request.rst           |    12 +-
 docs/devel/tcg-plugins.rst                         |   175 +-
 docs/devel/testing.rst                             |    74 +-
 docs/devel/tracing.rst                             |     2 +-
 docs/devel/virtio-backends.rst                     |   214 +
 docs/devel/writing-monitor-commands.rst            |    13 +-
 docs/hyperv.txt                                    |   255 -
 docs/interop/firmware.json                         |    21 +-
 docs/interop/live-block-operations.rst             |     4 +-
 docs/interop/nbd.txt                               |     1 +
 docs/interop/qemu-ga.rst                           |     8 +-
 docs/interop/vhost-user-gpu.rst                    |    10 +-
 docs/interop/vhost-user.rst                        |   572 +-
 docs/meson.build                                   |     2 +-
 docs/pcie_sriov.txt                                |     6 +-
 docs/replay.txt                                    |   410 -
 docs/specs/acpi_erst.rst                           |     4 +-
 docs/specs/fw_cfg.rst                              |   290 +
 docs/specs/fw_cfg.txt                              |   265 -
 docs/specs/index.rst                               |     1 +
 docs/specs/pci-ids.txt                             |    18 +-
 docs/specs/tpm.rst                                 |    44 +-
 docs/specs/vmgenid.txt                             |     4 +-
 docs/system/arm/aspeed.rst                         |   122 +-
 docs/system/arm/cpu-features.rst                   |    58 +-
 docs/system/arm/emulation.rst                      |    26 +
 docs/system/arm/nuvoton.rst                        |     4 +-
 docs/system/arm/virt.rst                           |    29 +-
 docs/system/device-emulation.rst                   |     3 +
 docs/system/devices/can.rst                        |     5 +-
 docs/system/devices/canokey.rst                    |   158 +
 docs/system/devices/ccid.rst                       |   171 +
 docs/system/devices/cxl.rst                        |   386 +
 docs/system/devices/nvme.rst                       |    86 +-
 docs/system/devices/usb.rst                        |    61 +-
 docs/system/i386/hyperv.rst                        |   288 +
 docs/system/index.rst                              |     1 +
 docs/system/loongarch/loongson3.rst                |   129 +
 docs/system/openrisc/cpu-features.rst              |    15 +
 docs/system/openrisc/emulation.rst                 |    17 +
 docs/system/openrisc/or1k-sim.rst                  |    43 +
 docs/system/openrisc/virt.rst                      |    50 +
 docs/system/ppc/embedded.rst                       |     1 -
 docs/system/ppc/ppce500.rst                        |    28 +-
 docs/system/ppc/pseries.rst                        |    29 +
 docs/system/replay.rst                             |   237 +
 docs/system/riscv/virt.rst                         |    25 +
 docs/system/s390x/bootdevices.rst                  |    28 +-
 docs/system/target-i386.rst                        |     1 +
 docs/system/target-openrisc.rst                    |    71 +
 docs/system/targets.rst                            |     1 +
 docs/system/tls.rst                                |     2 +-
 docs/tools/qemu-img.rst                            |     6 +-
 docs/tools/qemu-nbd.rst                            |     5 +-
 docs/tools/qemu-pr-helper.rst                      |     4 +-
 docs/tools/qemu-storage-daemon.rst                 |    22 +
 docs/tools/virtiofsd.rst                           |     9 +-
 dump/dump.c                                        |   908 +-
 dump/win_dump.c                                    |   313 +-
 ebpf/ebpf_rss.c                                    |     2 +-
 event-loop-base.c                                  |   140 +
 fpu/softfloat-parts.c.inc                          |    33 +-
 fpu/softfloat-specialize.c.inc                     |    26 +-
 fpu/softfloat.c                                    |   205 +-
 fsdev/virtfs-proxy-helper.c                        |     4 +-
 gdb-xml/i386-32bit.xml                             |     2 +-
 gdb-xml/loongarch-base64.xml                       |    45 +
 gdb-xml/loongarch-fpu.xml                          |    50 +
 gdb-xml/riscv-32bit-cpu.xml                        |     6 +-
 gdb-xml/riscv-32bit-fpu.xml                        |    10 +-
 gdb-xml/riscv-64bit-cpu.xml                        |     6 +-
 gdb-xml/riscv-64bit-fpu.xml                        |    10 +-
 gdbstub.c                                          |  3594 ---
 gdbstub/gdbstub.c                                  |  3517 +++
 gdbstub/internals.h                                |    17 +
 gdbstub/meson.build                                |     9 +
 gdbstub/softmmu.c                                  |    51 +
 gdbstub/trace-events                               |    29 +
 gdbstub/trace.h                                    |     1 +
 gdbstub/user.c                                     |    68 +
 hmp-commands-info.hx                               |   107 +-
 hmp-commands.hx                                    |   119 +-
 hw/9pfs/9p-posix-acl.c                             |    12 +-
 hw/9pfs/9p-proxy.c                                 |     1 -
 hw/9pfs/9p-synth.c                                 |     4 +-
 hw/9pfs/9p-util-darwin.c                           |    54 +-
 hw/9pfs/9p-util.h                                  |    69 +
 hw/9pfs/9p-xattr-user.c                            |     8 +-
 hw/9pfs/9p.c                                       |   263 +-
 hw/9pfs/9p.h                                       |    11 +-
 hw/9pfs/virtio-9p-device.c                         |     2 +-
 hw/Kconfig                                         |     2 +
 hw/acpi/Kconfig                                    |     5 +
 hw/acpi/acpi_interface.c                           |     8 +
 hw/acpi/aml-build-stub.c                           |    10 +
 hw/acpi/aml-build.c                                |   124 +-
 hw/acpi/cxl-stub.c                                 |    12 +
 hw/acpi/cxl.c                                      |   256 +
 hw/acpi/erst.c                                     |     9 +-
 hw/acpi/generic_event_device.c                     |     8 +
 hw/acpi/ghes.c                                     |     2 +-
 hw/acpi/ipmi-stub.c                                |     2 +-
 hw/acpi/ipmi.c                                     |    53 +-
 hw/acpi/meson.build                                |     6 +-
 hw/acpi/nvdimm.c                                   |   143 +-
 hw/acpi/pcihp.c                                    |     6 +-
 hw/acpi/piix4.c                                    |    77 +-
 hw/acpi/trace-events                               |    13 +
 hw/acpi/viot.c                                     |   107 +-
 hw/adc/aspeed_adc.c                                |    16 +
 hw/adc/npcm7xx_adc.c                               |     4 +-
 hw/adc/zynq-xadc.c                                 |     4 +-
 hw/alpha/dp264.c                                   |     3 -
 hw/arm/Kconfig                                     |     4 +
 hw/arm/allwinner-a10.c                             |     4 +-
 hw/arm/allwinner-h3.c                              |     2 +-
 hw/arm/armv7m.c                                    |    16 +-
 hw/arm/aspeed.c                                    |   349 +-
 hw/arm/aspeed_ast10x0.c                            |   377 +
 hw/arm/aspeed_ast2600.c                            |   149 +-
 hw/arm/aspeed_soc.c                                |   212 +-
 hw/arm/bcm2835_peripherals.c                       |    26 +-
 hw/arm/boot.c                                      |    70 +-
 hw/arm/digic.c                                     |     5 +-
 hw/arm/exynos4210.c                                |   430 +-
 hw/arm/fby35.c                                     |   192 +
 hw/arm/meson.build                                 |     8 +-
 hw/arm/microbit.c                                  |     2 +-
 hw/arm/mps2-tz.c                                   |     6 +-
 hw/arm/mps2.c                                      |     2 +-
 hw/arm/msf2-som.c                                  |     2 +-
 hw/arm/musca.c                                     |     3 +-
 hw/arm/musicpal.c                                  |     2 +-
 hw/arm/netduino2.c                                 |     2 +-
 hw/arm/netduinoplus2.c                             |     2 +-
 hw/arm/npcm7xx_boards.c                            |    24 +-
 hw/arm/nseries.c                                   |     6 +-
 hw/arm/omap2.c                                     |     2 +-
 hw/arm/pxa2xx.c                                    |     4 +-
 hw/arm/pxa2xx_pic.c                                |     2 +-
 hw/arm/realview.c                                  |    33 +-
 hw/arm/sbsa-ref.c                                  |    16 +
 hw/arm/smmuv3-internal.h                           |     2 +-
 hw/arm/smmuv3.c                                    |    19 +-
 hw/arm/stellaris.c                                 |    17 +-
 hw/arm/stm32vldiscovery.c                          |     2 +-
 hw/arm/sysbus-fdt.c                                |   571 -
 hw/arm/virt-acpi-build.c                           |    42 +-
 hw/arm/virt.c                                      |   220 +-
 hw/arm/xlnx-versal-virt.c                          |     7 +-
 hw/arm/xlnx-versal.c                               |    99 +-
 hw/arm/xlnx-zynqmp.c                               |    62 +-
 hw/audio/ac97.c                                    |   758 +-
 hw/audio/cs4231a.c                                 |     8 +-
 hw/audio/intel-hda.c                               |    11 +-
 hw/audio/pcspk.c                                   |    10 -
 hw/audio/soundhw.c                                 |   151 +-
 hw/avr/boot.c                                      |     1 -
 hw/block/block.c                                   |     4 +-
 hw/block/dataplane/virtio-blk.c                    |     5 +
 hw/block/fdc-isa.c                                 |    16 +-
 hw/block/fdc-sysbus.c                              |    16 +-
 hw/block/fdc.c                                     |    28 +-
 hw/block/hd-geometry.c                             |     9 +-
 hw/block/m25p80.c                                  |   237 +-
 hw/block/m25p80_sfdp.c                             |   332 +
 hw/block/m25p80_sfdp.h                             |    29 +
 hw/block/meson.build                               |     5 +-
 hw/block/nand.c                                    |    47 +-
 hw/block/onenand.c                                 |    32 +-
 hw/block/pflash_cfi01.c                            |     4 +-
 hw/block/pflash_cfi02.c                            |     4 +-
 hw/block/trace-events                              |     1 +
 hw/block/vhost-user-blk.c                          |   107 +-
 hw/block/virtio-blk-common.c                       |    39 +
 hw/block/virtio-blk.c                              |    76 +-
 hw/block/xen-block.c                               |     1 -
 hw/char/escc.c                                     |     2 +-
 hw/char/exynos4210_uart.c                          |     2 +-
 hw/char/parallel.c                                 |    14 +-
 hw/char/pl011.c                                    |     2 +-
 hw/char/serial-isa.c                               |    14 +-
 hw/char/serial.c                                   |     3 +
 hw/char/virtio-serial-bus.c                        |     3 +-
 hw/core/clock.c                                    |     2 +-
 hw/core/cpu-common.c                               |     3 +-
 hw/core/cpu-sysemu.c                               |     5 +-
 hw/core/generic-loader.c                           |     2 +-
 hw/core/irq.c                                      |    15 -
 hw/core/loader.c                                   |   101 +-
 hw/core/machine-hmp-cmds.c                         |     4 +
 hw/core/machine.c                                  |   272 +-
 hw/core/meson.build                                |     1 +
 hw/core/numa.c                                     |    28 +-
 hw/core/qdev-properties.c                          |    19 +
 hw/core/qdev.c                                     |    41 +-
 hw/core/reset.c                                    |    17 +-
 hw/core/resettable.c                               |     3 +-
 hw/core/sysbus-fdt.c                               |   572 +
 hw/core/uboot_image.h                              |   213 +-
 hw/cxl/Kconfig                                     |     3 +
 hw/cxl/cxl-cdat.c                                  |   224 +
 hw/cxl/cxl-component-utils.c                       |   405 +
 hw/cxl/cxl-device-utils.c                          |   271 +
 hw/cxl/cxl-host-stubs.c                            |    15 +
 hw/cxl/cxl-host.c                                  |   340 +
 hw/cxl/cxl-mailbox-utils.c                         |   478 +
 hw/cxl/meson.build                                 |    13 +
 hw/display/acpi-vga-stub.c                         |     7 +
 hw/display/acpi-vga.c                              |    26 +
 hw/display/artist.c                                |   204 +-
 hw/display/ati_2d.c                                |     7 +-
 hw/display/bcm2835_fb.c                            |     3 +-
 hw/display/blizzard.c                              |   354 +-
 hw/display/cg3.c                                   |     1 -
 hw/display/cirrus_vga.c                            |  1609 +-
 hw/display/cirrus_vga_isa.c                        |     1 +
 hw/display/meson.build                             |    17 +
 hw/display/next-fb.c                               |     2 +-
 hw/display/omap_dss.c                              |   598 +-
 hw/display/pl110_template.h                        |     6 +-
 hw/display/pxa2xx_lcd.c                            |   198 +-
 hw/display/qxl-logger.c                            |    22 +-
 hw/display/qxl-render.c                            |    20 +-
 hw/display/qxl.c                                   |    45 +-
 hw/display/qxl.h                                   |    23 +-
 hw/display/sii9022.c                               |     2 +
 hw/display/ssd0303.c                               |     2 +
 hw/display/tcx.c                                   |     1 -
 hw/display/trace-events                            |     1 +
 hw/display/vga-isa.c                               |     1 +
 hw/display/vga-mmio.c                              |     1 +
 hw/display/vga-pci.c                               |     5 +
 hw/display/vga.c                                   |    18 +-
 hw/display/vga_int.h                               |     3 +-
 hw/display/vga_regs.h                              |     6 +-
 hw/display/vhost-user-gpu-pci.c                    |     1 +
 hw/display/vhost-user-gpu.c                        |    11 +-
 hw/display/vhost-user-vga.c                        |     1 +
 hw/display/virtio-gpu-base.c                       |    10 +-
 hw/display/virtio-gpu-gl.c                         |     3 +-
 hw/display/virtio-gpu-pci-gl.c                     |     1 +
 hw/display/virtio-gpu-pci.c                        |     1 +
 hw/display/virtio-gpu-udmabuf.c                    |     1 -
 hw/display/virtio-gpu.c                            |     6 +
 hw/display/virtio-vga-gl.c                         |     1 +
 hw/display/virtio-vga.c                            |     6 +-
 hw/display/vmware_vga.c                            |    42 +-
 hw/display/xenfb.c                                 |   274 +-
 hw/display/xlnx_dp.c                               |    53 +-
 hw/dma/pl330.c                                     |     3 +-
 hw/dma/xilinx_axidma.c                             |     2 +-
 hw/dma/xlnx_csu_dma.c                              |     2 +-
 hw/dma/xlnx_dpdma.c                                |     2 +-
 hw/gpio/Kconfig                                    |     3 +
 hw/gpio/aspeed_gpio.c                              |   270 +-
 hw/gpio/meson.build                                |     2 +-
 hw/gpio/trace-events                               |     4 +
 hw/hppa/Kconfig                                    |     5 +-
 hw/hppa/dino.c                                     |   608 -
 hw/hppa/hppa_hardware.h                            |     5 +-
 hw/hppa/hppa_sys.h                                 |    24 -
 hw/hppa/lasi.c                                     |   367 -
 hw/hppa/machine.c                                  |   152 +-
 hw/hppa/meson.build                                |     2 +-
 hw/hppa/pci.c                                      |    88 -
 hw/hppa/trace-events                               |    14 -
 hw/hyperv/Kconfig                                  |     5 +
 hw/hyperv/hyperv.c                                 |   354 +-
 hw/hyperv/meson.build                              |     1 +
 hw/hyperv/syndbg.c                                 |   401 +
 hw/hyperv/vmbus.c                                  |    99 -
 hw/i2c/aspeed_i2c.c                                |  1012 +-
 hw/i2c/core.c                                      |    70 +-
 hw/i2c/pmbus_device.c                              |    15 +-
 hw/i2c/smbus_ich9.c                                |    15 +
 hw/i2c/smbus_slave.c                               |     4 +
 hw/i2c/trace-events                                |     4 +-
 hw/i386/acpi-build.c                               |   628 +-
 hw/i386/amd_iommu.c                                |    24 +-
 hw/i386/e820_memory_layout.c                       |    20 +-
 hw/i386/e820_memory_layout.h                       |    12 +-
 hw/i386/fw_cfg.c                                   |     3 -
 hw/i386/fw_cfg.h                                   |     1 -
 hw/i386/intel_iommu.c                              |   786 +-
 hw/i386/intel_iommu_internal.h                     |    25 +-
 hw/i386/microvm-dt.c                               |     9 +-
 hw/i386/microvm.c                                  |    77 +-
 hw/i386/multiboot.c                                |     5 +-
 hw/i386/pc.c                                       |   304 +-
 hw/i386/pc_piix.c                                  |   199 +-
 hw/i386/pc_q35.c                                   |    47 +-
 hw/i386/pc_sysfw.c                                 |    37 +-
 hw/i386/sgx.c                                      |     2 +-
 hw/i386/trace-events                               |     2 +
 hw/i386/x86.c                                      |   194 +-
 hw/i386/xen/xen-hvm.c                              |    17 +-
 hw/i386/xen/xen_platform.c                         |    48 +-
 hw/ide/atapi.c                                     |     8 +-
 hw/ide/core.c                                      |    42 +-
 hw/ide/macio.c                                     |     5 +-
 hw/ide/microdrive.c                                |     8 +-
 hw/ide/piix.c                                      |    64 +-
 hw/ide/via.c                                       |     2 +-
 hw/input/lasips2.c                                 |   335 +-
 hw/input/pckbd.c                                   |   382 +-
 hw/input/pl050.c                                   |   160 +-
 hw/input/ps2.c                                     |   487 +-
 hw/input/trace-events                              |     2 -
 hw/input/vhost-user-input.c                        |     8 +-
 hw/input/virtio-input-host.c                       |     5 +-
 hw/input/virtio-input.c                            |     3 +-
 hw/intc/Kconfig                                    |    18 +
 hw/intc/arm_gic.c                                  |    28 +-
 hw/intc/arm_gicv3_common.c                         |    59 +-
 hw/intc/arm_gicv3_cpuif.c                          |   429 +-
 hw/intc/arm_gicv3_dist.c                           |     9 +-
 hw/intc/arm_gicv3_its.c                            |   776 +-
 hw/intc/arm_gicv3_its_kvm.c                        |     2 +
 hw/intc/arm_gicv3_kvm.c                            |    24 +-
 hw/intc/arm_gicv3_redist.c                         |   484 +-
 hw/intc/armv7m_nvic.c                              |     9 +-
 hw/intc/exynos4210_combiner.c                      |   108 +-
 hw/intc/exynos4210_gic.c                           |   353 +-
 hw/intc/gicv3_internal.h                           |   213 +-
 hw/intc/heathrow_pic.c                             |     1 -
 hw/intc/loongarch_extioi.c                         |   317 +
 hw/intc/loongarch_ipi.c                            |   273 +
 hw/intc/loongarch_pch_msi.c                        |    91 +
 hw/intc/loongarch_pch_pic.c                        |   431 +
 hw/intc/meson.build                                |     5 +
 hw/intc/nios2_vic.c                                |   313 +
 hw/intc/openpic.c                                  |     3 +-
 hw/intc/pnv_xive.c                                 |    20 -
 hw/intc/pnv_xive2.c                                |    41 +-
 hw/intc/ppc-uic.c                                  |    26 +-
 hw/intc/riscv_aclint.c                             |   189 +-
 hw/intc/riscv_aplic.c                              |     2 +-
 hw/intc/riscv_imsic.c                              |     4 +-
 hw/intc/s390_flic_kvm.c                            |     2 +-
 hw/intc/sifive_plic.c                              |    44 +-
 hw/intc/trace-events                               |    39 +-
 hw/intc/xics.c                                     |    12 +-
 hw/intc/xics_kvm.c                                 |     1 -
 hw/intc/xive.c                                     |    29 +-
 hw/intc/xive2.c                                    |    18 +-
 hw/ipmi/isa_ipmi_bt.c                              |     4 +
 hw/ipmi/isa_ipmi_kcs.c                             |     4 +
 hw/ipmi/smbus_ipmi.c                               |     8 +-
 hw/isa/Kconfig                                     |     9 +
 hw/isa/isa-bus.c                                   |    10 +-
 hw/isa/lpc_ich9.c                                  |    37 +
 hw/isa/piix3.c                                     |   165 +-
 hw/isa/piix4.c                                     |   122 +-
 hw/isa/vt82c686.c                                  |   120 +-
 hw/loongarch/Kconfig                               |    22 +
 hw/loongarch/acpi-build.c                          |   549 +
 hw/loongarch/fw_cfg.c                              |    34 +
 hw/loongarch/fw_cfg.h                              |    15 +
 hw/loongarch/meson.build                           |     8 +
 hw/loongarch/virt.c                                |   985 +
 hw/m68k/bootinfo.h                                 |    56 +-
 hw/m68k/mcf5206.c                                  |     2 +-
 hw/m68k/mcf5208.c                                  |     3 +-
 hw/m68k/q800.c                                     |    82 +-
 hw/m68k/virt.c                                     |    76 +-
 hw/mem/Kconfig                                     |     5 +
 hw/mem/cxl_type3.c                                 |   647 +
 hw/mem/meson.build                                 |     1 +
 hw/mem/nvdimm.c                                    |     2 +-
 hw/meson.build                                     |     2 +
 hw/microblaze/boot.c                               |     8 +-
 hw/mips/bootloader.c                               |    28 +-
 hw/mips/boston.c                                   |    25 +-
 hw/mips/fuloong2e.c                                |    50 +-
 hw/mips/gt64xxx_pci.c                              |     6 +-
 hw/mips/jazz.c                                     |    23 +-
 hw/mips/loongson3_virt.c                           |     1 -
 hw/mips/malta.c                                    |   195 +-
 hw/mips/mipssim.c                                  |     3 +-
 hw/misc/Kconfig                                    |     3 +
 hw/misc/applesmc.c                                 |    29 +
 hw/misc/aspeed_hace.c                              |   167 +-
 hw/misc/aspeed_peci.c                              |   152 +
 hw/misc/aspeed_sbc.c                               |    45 +-
 hw/misc/aspeed_scu.c                               |   110 +-
 hw/misc/bcm2835_property.c                         |     4 +
 hw/misc/cbus.c                                     |     6 +-
 hw/misc/grlib_ahb_apb_pnp.c                        |    10 +-
 hw/misc/iotkit-secctl.c                            |     2 +-
 hw/misc/iotkit-sysctl.c                            |     4 +-
 hw/misc/ivshmem.c                                  |     2 +-
 hw/misc/lasi.c                                     |   274 +
 hw/misc/mac_via.c                                  |     8 +-
 hw/misc/macio/cuda.c                               |     1 -
 hw/misc/macio/gpio.c                               |     1 -
 hw/misc/macio/macio.c                              |     8 +-
 hw/misc/macio/pmu.c                                |     1 -
 hw/misc/meson.build                                |     7 +-
 hw/misc/mips_itu.c                                 |     3 +-
 hw/misc/mos6522.c                                  |     2 +-
 hw/misc/pvpanic-isa.c                              |    42 +
 hw/misc/sbsa_ec.c                                  |     1 -
 hw/misc/sifive_u_otp.c                             |    14 +-
 hw/misc/trace-events                               |    15 +-
 hw/misc/xlnx-versal-crl.c                          |   421 +
 hw/net/can/can_sja1000.c                           |    31 +-
 hw/net/can/ctu_can_fd_frame.h                      |   184 +-
 hw/net/can/ctu_can_fd_regs.h                       |  1264 +-
 hw/net/can/ctucan_core.h                           |     2 +-
 hw/net/can/xlnx-zynqmp-can.c                       |    34 +-
 hw/net/e1000.c                                     |     5 +-
 hw/net/e1000_regs.h                                |    31 +-
 hw/net/e1000e.c                                    |    15 +-
 hw/net/e1000e_core.c                               |    62 +-
 hw/net/fsl_etsec/etsec.c                           |    26 +-
 hw/net/fsl_etsec/etsec.h                           |     7 -
 hw/net/fsl_etsec/rings.c                           |     1 -
 hw/net/imx_fec.c                                   |     2 +-
 hw/net/lan9118.c                                   |    10 +-
 hw/net/mcf_fec.c                                   |     8 +-
 hw/net/meson.build                                 |     8 +-
 hw/net/msf2-emac.c                                 |     1 -
 hw/net/ne2000.c                                    |   138 +-
 hw/net/npcm7xx_emc.c                               |     1 -
 hw/net/pcnet.c                                     |   136 +-
 hw/net/pcnet.h                                     |     4 +-
 hw/net/rocker/rocker.c                             |    27 +-
 hw/net/rtl8139.c                                   |    49 +-
 hw/net/tulip.c                                     |    12 +-
 hw/net/vhost_net-stub.c                            |    12 +
 hw/net/vhost_net.c                                 |   120 +-
 hw/net/virtio-net.c                                |   278 +-
 hw/net/vmxnet3.c                                   |    27 +-
 hw/net/vmxnet3.h                                   |     4 +-
 hw/net/xen_nic.c                                   |     5 +-
 hw/nios2/10m50_devboard.c                          |   115 +-
 hw/nios2/Kconfig                                   |     1 +
 hw/nios2/boot.c                                    |    16 +-
 hw/nios2/generic_nommu.c                           |     1 -
 hw/nios2/meson.build                               |     2 +-
 hw/nvme/ctrl.c                                     |  1208 +-
 hw/nvme/dif.c                                      |     5 +
 hw/nvme/ns.c                                       |    13 +-
 hw/nvme/nvme.h                                     |    79 +-
 hw/nvme/subsys.c                                   |    78 +-
 hw/nvme/trace-events                               |    11 +
 hw/nvram/eeprom93xx.c                              |     2 +-
 hw/nvram/eeprom_at24c.c                            |    10 +-
 hw/nvram/fw_cfg.c                                  |    78 +-
 hw/nvram/mac_nvram.c                               |     2 +-
 hw/nvram/spapr_nvram.c                             |    16 +-
 hw/nvram/xlnx-bbram.c                              |     4 +-
 hw/nvram/xlnx-efuse.c                              |     4 +-
 hw/openrisc/Kconfig                                |    12 +
 hw/openrisc/boot.c                                 |   119 +
 hw/openrisc/cputimer.c                             |    22 +-
 hw/openrisc/meson.build                            |     2 +
 hw/openrisc/openrisc_sim.c                         |   132 +-
 hw/openrisc/virt.c                                 |   571 +
 hw/pci-bridge/Kconfig                              |     5 +
 hw/pci-bridge/cxl_downstream.c                     |   249 +
 hw/pci-bridge/cxl_root_port.c                      |   236 +
 hw/pci-bridge/cxl_upstream.c                       |   409 +
 hw/pci-bridge/meson.build                          |     6 +-
 hw/pci-bridge/pci_expander_bridge.c                |   176 +-
 hw/pci-bridge/pci_expander_bridge_stubs.c          |    14 +
 hw/pci-bridge/pcie_root_port.c                     |     6 +-
 hw/pci-host/Kconfig                                |     4 +
 hw/pci-host/dino.c                                 |   521 +
 hw/pci-host/gpex-acpi.c                            |    20 +-
 hw/pci-host/grackle.c                              |    15 +-
 hw/pci-host/i440fx.c                               |     9 +-
 hw/pci-host/meson.build                            |     6 +-
 hw/pci-host/mv64361.c                              |     1 -
 hw/pci-host/pnv_phb.c                              |   345 +
 hw/pci-host/pnv_phb.h                              |    55 +
 hw/pci-host/pnv_phb3.c                             |   177 +-
 hw/pci-host/pnv_phb3_msi.c                         |     1 -
 hw/pci-host/pnv_phb3_pbcq.c                        |     1 -
 hw/pci-host/pnv_phb4.c                             |   230 +-
 hw/pci-host/pnv_phb4_pec.c                         |    25 +-
 hw/pci-host/q35.c                                  |     3 +-
 hw/pci-host/raven.c                                |     1 -
 hw/pci-host/remote.c                               |     1 -
 hw/pci-host/trace-events                           |     5 +
 hw/pci-host/uninorth.c                             |     1 -
 hw/pci/meson.build                                 |     1 +
 hw/pci/msi.c                                       |    49 +-
 hw/pci/msix.c                                      |    45 +-
 hw/pci/pci.c                                       |    52 +-
 hw/pci/pcie.c                                      |     5 +-
 hw/pci/pcie_aer.c                                  |     4 +-
 hw/pci/pcie_doe.c                                  |   367 +
 hw/pci/pcie_port.c                                 |    25 +
 hw/pci/shpc.c                                      |     5 +-
 hw/ppc/Kconfig                                     |    14 +-
 hw/ppc/e500.c                                      |   120 +-
 hw/ppc/e500.h                                      |     1 -
 hw/ppc/e500plat.c                                  |     1 -
 hw/ppc/mac.h                                       |   105 -
 hw/ppc/mac_newworld.c                              |   229 +-
 hw/ppc/mac_oldworld.c                              |   116 +-
 hw/ppc/meson.build                                 |    10 +-
 hw/ppc/mpc8544ds.c                                 |     9 +-
 hw/ppc/pegasos2.c                                  |    38 +-
 hw/ppc/pnv.c                                       |   295 +-
 hw/ppc/pnv_bmc.c                                   |     1 -
 hw/ppc/pnv_core.c                                  |     1 +
 hw/ppc/pnv_lpc.c                                   |    19 +-
 hw/ppc/pnv_occ.c                                   |    16 +-
 hw/ppc/pnv_pnor.c                                  |     6 +-
 hw/ppc/pnv_psi.c                                   |    36 +-
 hw/ppc/pnv_sbe.c                                   |   414 +
 hw/ppc/pnv_xscom.c                                 |     3 +
 hw/ppc/ppc.c                                       |    47 +-
 hw/ppc/ppc405.h                                    |   194 +-
 hw/ppc/ppc405_boards.c                             |   564 +-
 hw/ppc/ppc405_uc.c                                 |  1153 +-
 hw/ppc/ppc440.h                                    |     4 -
 hw/ppc/ppc440_bamboo.c                             |    95 +-
 hw/ppc/ppc440_uc.c                                 |   283 +-
 hw/ppc/ppc4xx_devs.c                               |   913 +-
 hw/ppc/ppc4xx_pci.c                                |    31 +-
 hw/ppc/ppc4xx_sdram.c                              |   757 +
 hw/ppc/prep.c                                      |     6 +-
 hw/ppc/prep_systemio.c                             |     2 +-
 hw/ppc/sam460ex.c                                  |   108 +-
 hw/ppc/spapr.c                                     |    90 +-
 hw/ppc/spapr_caps.c                                |     2 +-
 hw/ppc/spapr_hcall.c                               |    97 +-
 hw/ppc/spapr_iommu.c                               |     3 +-
 hw/ppc/spapr_numa.c                                |     1 -
 hw/ppc/spapr_nvdimm.c                              |    18 +-
 hw/ppc/spapr_pci.c                                 |    11 +-
 hw/ppc/spapr_pci_nvlink2.c                         |     3 +-
 hw/ppc/spapr_rtas.c                                |    20 +-
 hw/ppc/spapr_rtas_ddw.c                            |    35 +-
 hw/ppc/spapr_tpm_proxy.c                           |     1 -
 hw/ppc/spapr_vof.c                                 |     1 -
 hw/ppc/trace-events                                |    17 +-
 hw/ppc/virtex_ml507.c                              |    43 +-
 hw/ppc/vof.c                                       |     3 +-
 hw/rdma/vmw/pvrdma_main.c                          |    18 +-
 hw/remote/Kconfig                                  |     4 +
 hw/remote/iohub.c                                  |     1 -
 hw/remote/iommu.c                                  |   131 +
 hw/remote/machine.c                                |    89 +-
 hw/remote/memory.c                                 |     1 -
 hw/remote/meson.build                              |     4 +
 hw/remote/message.c                                |     1 -
 hw/remote/mpqemu-link.c                            |     3 +-
 hw/remote/proxy-memory-listener.c                  |     1 -
 hw/remote/proxy.c                                  |     1 -
 hw/remote/remote-obj.c                             |     1 -
 hw/remote/trace-events                             |    11 +
 hw/remote/vfio-user-obj.c                          |   951 +
 hw/riscv/Kconfig                                   |     2 +
 hw/riscv/boot.c                                    |    60 +-
 hw/riscv/microchip_pfsoc.c                         |    71 +-
 hw/riscv/opentitan.c                               |    56 +-
 hw/riscv/shakti_c.c                                |     3 +-
 hw/riscv/sifive_e.c                                |     2 +-
 hw/riscv/sifive_u.c                                |    33 +-
 hw/riscv/spike.c                                   |    17 +-
 hw/riscv/virt.c                                    |   411 +-
 hw/rtc/Kconfig                                     |     3 +
 hw/rtc/exynos4210_rtc.c                            |     4 +-
 hw/rtc/goldfish_rtc.c                              |    37 +-
 hw/rtc/ls7a_rtc.c                                  |   488 +
 hw/rtc/m41t80.c                                    |     6 +-
 hw/rtc/mc146818rtc.c                               |    23 +-
 hw/rtc/meson.build                                 |     1 +
 hw/rx/rx-gdbsim.c                                  |    10 +-
 hw/s390x/css.c                                     |    51 +-
 hw/s390x/event-facility.c                          |     2 +-
 hw/s390x/ipl.c                                     |    44 +-
 hw/s390x/ipl.h                                     |     2 +-
 hw/s390x/meson.build                               |     2 +
 hw/s390x/pv.c                                      |   114 +-
 hw/s390x/s390-ccw.c                                |     2 +-
 hw/s390x/s390-pci-bus.c                            |   111 +-
 hw/s390x/s390-pci-inst.c                           |    85 +-
 hw/s390x/s390-pci-kvm.c                            |    52 +
 hw/s390x/s390-pci-vfio.c                           |   129 +-
 hw/s390x/s390-virtio-ccw.c                         |   185 +-
 hw/s390x/tod-kvm.c                                 |     9 +
 hw/s390x/vhost-scsi-ccw.c                          |    73 +
 hw/s390x/vhost-vsock-ccw.c                         |     9 +
 hw/s390x/virtio-ccw-9p.c                           |     9 +
 hw/s390x/virtio-ccw-balloon.c                      |     9 +
 hw/s390x/virtio-ccw-blk.c                          |     9 +
 hw/s390x/virtio-ccw-crypto.c                       |     9 +
 hw/s390x/virtio-ccw-gpu.c                          |    10 +
 hw/s390x/virtio-ccw-input.c                        |    20 +
 hw/s390x/virtio-ccw-net.c                          |     9 +
 hw/s390x/virtio-ccw-rng.c                          |     9 +
 hw/s390x/virtio-ccw-scsi.c                         |    56 +-
 hw/s390x/virtio-ccw-serial.c                       |     9 +
 hw/s390x/virtio-ccw.c                              |    14 +-
 hw/s390x/virtio-ccw.h                              |   149 -
 hw/scsi/Kconfig                                    |     5 +
 hw/scsi/esp.c                                      |    14 +-
 hw/scsi/lsi53c895a.c                               |    10 +-
 hw/scsi/megasas.c                                  |    12 +-
 hw/scsi/mfi.h                                      |     2 +-
 hw/scsi/mptsas.c                                   |    11 +-
 hw/scsi/scsi-bus.c                                 |    47 +-
 hw/scsi/scsi-disk.c                                |   130 +-
 hw/scsi/scsi-generic.c                             |    27 +-
 hw/scsi/spapr_vscsi.c                              |     7 +-
 hw/scsi/trace-events                               |     3 +
 hw/scsi/vhost-scsi-common.c                        |     4 +-
 hw/scsi/vhost-scsi.c                               |    13 +-
 hw/scsi/vhost-user-scsi.c                          |     3 +-
 hw/scsi/virtio-scsi-dataplane.c                    |    13 +-
 hw/scsi/virtio-scsi.c                              |   117 +-
 hw/scsi/vmw_pvscsi.c                               |     8 +-
 hw/sd/allwinner-sdhost.c                           |    74 +-
 hw/sd/sd.c                                         |     5 +-
 hw/sd/sdhci-internal.h                             |    20 -
 hw/sd/sdhci.c                                      |    63 +-
 hw/sensor/Kconfig                                  |     4 +
 hw/sensor/isl_pmbus_vr.c                           |    40 +
 hw/sensor/lsm303dlhc_mag.c                         |     2 +
 hw/sensor/max31785.c                               |   573 +
 hw/sensor/meson.build                              |     1 +
 hw/smbios/smbios.c                                 |    96 +-
 hw/smbios/smbios_build.h                           |     9 +-
 hw/sparc/leon3.c                                   |     1 -
 hw/sparc/sun4m.c                                   |    12 +-
 hw/sparc64/sun4u.c                                 |     9 +-
 hw/sparc64/sun4u_iommu.c                           |     2 +-
 hw/ssi/aspeed_smc.c                                |   170 +-
 hw/ssi/ibex_spi_host.c                             |   646 +
 hw/ssi/meson.build                                 |     1 +
 hw/ssi/ssi.c                                       |    18 +-
 hw/ssi/trace-events                                |     7 +
 hw/timer/allwinner-a10-pit.c                       |     2 +-
 hw/timer/altera_timer.c                            |     2 +-
 hw/timer/arm_timer.c                               |     2 +-
 hw/timer/aspeed_timer.c                            |    17 +
 hw/timer/cadence_ttc.c                             |    32 +-
 hw/timer/digic-timer.c                             |     2 +-
 hw/timer/etraxfs_timer.c                           |     6 +-
 hw/timer/exynos4210_mct.c                          |     6 +-
 hw/timer/exynos4210_pwm.c                          |     2 +-
 hw/timer/grlib_gptimer.c                           |     2 +-
 hw/timer/ibex_timer.c                              |    18 +-
 hw/timer/imx_epit.c                                |    13 +-
 hw/timer/imx_gpt.c                                 |     2 +-
 hw/timer/mss-timer.c                               |     2 +-
 hw/timer/renesas_cmt.c                             |     2 +-
 hw/timer/renesas_tmr.c                             |     8 +-
 hw/timer/sh_timer.c                                |     2 +-
 hw/timer/slavio_timer.c                            |     2 +-
 hw/timer/sse-timer.c                               |     2 +-
 hw/timer/xilinx_timer.c                            |     2 +-
 hw/tpm/tpm_crb.c                                   |     8 +-
 hw/tpm/tpm_ppi.c                                   |     2 +-
 hw/tpm/tpm_tis_common.c                            |     7 +-
 hw/tpm/tpm_tis_isa.c                               |    32 +
 hw/usb/Kconfig                                     |     5 +
 hw/usb/canokey.c                                   |   334 +
 hw/usb/canokey.h                                   |    69 +
 hw/usb/ccid-card-emulated.c                        |     3 +-
 hw/usb/ccid-card-passthru.c                        |     3 +-
 hw/usb/dev-hub.c                                   |    82 +-
 hw/usb/dev-mtp.c                                   |     5 +-
 hw/usb/dev-network.c                               |   320 +-
 hw/usb/dev-smartcard-reader.c                      |     2 +-
 hw/usb/dev-storage.c                               |    58 +-
 hw/usb/dev-uas.c                                   |     5 +-
 hw/usb/dev-wacom.c                                 |     4 +-
 hw/usb/hcd-dwc2.h                                  |     4 +-
 hw/usb/hcd-ehci.c                                  |     5 +-
 hw/usb/hcd-musb.c                                  |   328 +-
 hw/usb/hcd-ohci.c                                  |    17 +-
 hw/usb/hcd-xhci-pci.c                              |     2 +-
 hw/usb/hcd-xhci-sysbus.c                           |     2 +-
 hw/usb/hcd-xhci.c                                  |    94 +-
 hw/usb/host-libusb.c                               |    16 +-
 hw/usb/meson.build                                 |     5 +
 hw/usb/quirks-pl2303-ids.h                         |   180 +-
 hw/usb/redirect.c                                  |     3 +-
 hw/usb/trace-events                                |    17 +
 hw/usb/u2f.h                                       |     2 +-
 hw/usb/vt82c686-uhci-pci.c                         |     4 +-
 hw/vfio/common.c                                   |   192 +-
 hw/vfio/display.c                                  |     8 +-
 hw/vfio/migration.c                                |    29 +-
 hw/vfio/pci-quirks.c                               |    34 +-
 hw/vfio/pci.c                                      |   244 +-
 hw/vfio/pci.h                                      |     2 +
 hw/vfio/spapr.c                                    |     8 +-
 hw/vfio/trace-events                               |     1 +
 hw/virtio/Kconfig                                  |    23 +-
 hw/virtio/meson.build                              |    38 +-
 hw/virtio/trace-events                             |    22 +-
 hw/virtio/vhost-backend.c                          |    11 +-
 hw/virtio/vhost-iova-tree.c                        |     6 +-
 hw/virtio/vhost-iova-tree.h                        |     2 +-
 hw/virtio/vhost-scsi-pci.c                         |     2 +-
 hw/virtio/vhost-shadow-virtqueue.c                 |   281 +-
 hw/virtio/vhost-shadow-virtqueue.h                 |    58 +-
 hw/virtio/vhost-user-blk-pci.c                     |     2 +-
 hw/virtio/vhost-user-fs-pci.c                      |     2 +-
 hw/virtio/vhost-user-fs.c                          |    24 +-
 hw/virtio/vhost-user-gpio-pci.c                    |    69 +
 hw/virtio/vhost-user-gpio.c                        |   418 +
 hw/virtio/vhost-user-i2c-pci.c                     |     2 +-
 hw/virtio/vhost-user-i2c.c                         |    22 +-
 hw/virtio/vhost-user-input-pci.c                   |     2 +-
 hw/virtio/vhost-user-rng-pci.c                     |     2 +-
 hw/virtio/vhost-user-rng.c                         |    34 +-
 hw/virtio/vhost-user-scsi-pci.c                    |     2 +-
 hw/virtio/vhost-user-vsock-pci.c                   |     2 +-
 hw/virtio/vhost-user-vsock.c                       |    10 +-
 hw/virtio/vhost-user.c                             |   313 +-
 hw/virtio/vhost-vdpa.c                             |   147 +-
 hw/virtio/vhost-vsock-common.c                     |    20 +-
 hw/virtio/vhost-vsock-pci.c                        |     2 +-
 hw/virtio/vhost-vsock.c                            |    21 +-
 hw/virtio/vhost.c                                  |   120 +-
 hw/virtio/virtio-9p-pci.c                          |     2 +-
 hw/virtio/virtio-balloon-pci.c                     |     2 +-
 hw/virtio/virtio-balloon.c                         |    12 +-
 hw/virtio/virtio-blk-pci.c                         |     2 +-
 hw/virtio/virtio-bus.c                             |    23 +-
 hw/virtio/virtio-crypto.c                          |   592 +-
 hw/virtio/virtio-input-host-pci.c                  |     2 +-
 hw/virtio/virtio-input-pci.c                       |     2 +-
 hw/virtio/virtio-iommu-pci.c                       |    18 +-
 hw/virtio/virtio-iommu.c                           |   202 +-
 hw/virtio/virtio-mem-pci.c                         |     2 -
 hw/virtio/virtio-mem.c                             |    16 +-
 hw/virtio/virtio-mmio.c                            |    18 +-
 hw/virtio/virtio-net-pci.c                         |     2 +-
 hw/virtio/virtio-pci.c                             |   112 +-
 hw/virtio/virtio-pci.h                             |   255 -
 hw/virtio/virtio-pmem-pci.c                        |     2 -
 hw/virtio/virtio-pmem.c                            |     4 +-
 hw/virtio/virtio-rng-pci.c                         |    16 +-
 hw/virtio/virtio-rng.c                             |     2 +-
 hw/virtio/virtio-scsi-pci.c                        |     2 +-
 hw/virtio/virtio-serial-pci.c                      |     2 +-
 hw/virtio/virtio-stub.c                            |    42 +
 hw/virtio/virtio.c                                 |  1187 +-
 hw/watchdog/meson.build                            |     1 +
 hw/watchdog/sbsa_gwdt.c                            |     6 -
 hw/watchdog/spapr_watchdog.c                       |   274 +
 hw/watchdog/trace-events                           |     7 +
 hw/watchdog/watchdog.c                             |    43 -
 hw/watchdog/wdt_aspeed.c                           |    40 +-
 hw/watchdog/wdt_diag288.c                          |     6 -
 hw/watchdog/wdt_i6300esb.c                         |     6 -
 hw/watchdog/wdt_ib700.c                            |     6 -
 hw/watchdog/wdt_imx2.c                             |     6 -
 hw/xen/meson.build                                 |    20 +-
 hw/xen/xen_pt.c                                    |    12 -
 hw/xen/xen_pt.h                                    |     2 +
 hw/xen/xen_pt_config_init.c                        |    29 +-
 hw/xen/xen_pt_graphics.c                           |   122 +
 hw/xen/xen_pvdev.c                                 |    45 +-
 hw/xenpv/xen_machine_pv.c                          |     1 +
 hw/xtensa/mx_pic.c                                 |     2 +-
 hw/xtensa/sim.c                                    |     2 +-
 hw/xtensa/xtfpga.c                                 |     4 +-
 include/block/accounting.h                         |     6 +-
 include/block/aio-wait.h                           |    19 +-
 include/block/aio.h                                |    10 +
 include/block/block-common.h                       |    48 +
 include/block/block-copy.h                         |     4 +-
 include/block/block-global-state.h                 |    30 +-
 include/block/block-hmp-cmds.h                     |     6 +-
 include/block/block-io.h                           |    32 +-
 include/block/block_int-common.h                   |    68 +-
 include/block/block_int-global-state.h             |     5 +-
 include/block/block_int-io.h                       |     8 +-
 include/block/blockjob.h                           |    59 +-
 include/block/nbd.h                                |     7 +-
 include/block/nvme.h                               |   111 +-
 include/block/qdict.h                              |     3 +
 include/block/thread-pool.h                        |     3 +
 include/chardev/char-socket.h                      |     7 +-
 include/chardev/char.h                             |     4 +-
 include/crypto/akcipher.h                          |   179 +
 include/crypto/block.h                             |    32 +-
 include/crypto/sm4.h                               |     6 +
 include/crypto/tls-cipher-suites.h                 |     6 +-
 include/disas/dis-asm.h                            |     6 +-
 include/elf.h                                      |     3 +
 include/exec/cpu-all.h                             |    40 +-
 include/exec/cpu-common.h                          |    11 +-
 include/exec/cpu-defs.h                            |    48 +-
 include/exec/cpu_ldst.h                            |     2 +-
 include/exec/exec-all.h                            |   233 +-
 include/exec/gdbstub.h                             |    66 +-
 include/exec/helper-head.h                         |     2 +-
 include/exec/log.h                                 |    52 +-
 include/exec/memop.h                               |     4 +-
 include/exec/memopidx.h                            |     2 +-
 include/exec/memory.h                              |    22 +-
 include/exec/page-vary.h                           |    18 +
 include/exec/plugin-gen.h                          |     7 +-
 include/exec/poison.h                              |     6 +-
 include/exec/ram_addr.h                            |    15 +-
 include/exec/ramblock.h                            |     3 +
 include/exec/softmmu-semi.h                        |   101 -
 include/exec/translate-all.h                       |     2 +-
 include/exec/translator.h                          |   117 +-
 include/fpu/softfloat-helpers.h                    |     2 +-
 include/fpu/softfloat-types.h                      |     6 +-
 include/fpu/softfloat.h                            |     7 +
 include/glib-compat.h                              |     4 +
 include/hw/acpi/acpi_aml_interface.h               |    49 +
 include/hw/acpi/cxl.h                              |    29 +
 include/hw/acpi/generic_event_device.h             |     4 +-
 include/hw/acpi/ipmi.h                             |     9 +-
 include/hw/acpi/piix4.h                            |    75 +
 include/hw/adc/aspeed_adc.h                        |     1 +
 include/hw/adc/zynq-xadc.h                         |     3 +-
 include/hw/arm/aspeed_soc.h                        |    40 +-
 include/hw/arm/bcm2835_peripherals.h               |     2 +
 include/hw/arm/boot.h                              |     5 +-
 include/hw/arm/exynos4210.h                        |    50 +-
 include/hw/arm/smmu-common.h                       |     1 +
 include/hw/arm/sysbus-fdt.h                        |    37 -
 include/hw/arm/virt.h                              |    21 +-
 include/hw/arm/xlnx-versal.h                       |    16 +
 include/hw/arm/xlnx-zynqmp.h                       |     7 +
 include/hw/audio/soundhw.h                         |     8 +-
 include/hw/block/block.h                           |     7 +-
 include/hw/block/fdc.h                             |     3 +-
 include/hw/boards.h                                |    15 +-
 include/hw/core/cpu.h                              |    43 +-
 include/hw/core/sysbus-fdt.h                       |    37 +
 include/hw/core/sysemu-cpu-ops.h                   |     8 +-
 include/hw/core/tcg-cpu-ops.h                      |    18 +-
 include/hw/cxl/cxl.h                               |    61 +
 include/hw/cxl/cxl_cdat.h                          |   166 +
 include/hw/cxl/cxl_component.h                     |   230 +
 include/hw/cxl/cxl_device.h                        |   272 +
 include/hw/cxl/cxl_host.h                          |    23 +
 include/hw/cxl/cxl_pci.h                           |   168 +
 include/hw/display/xlnx_dp.h                       |    12 +-
 include/hw/elf_ops.h                               |     2 +-
 include/hw/firmware/smbios.h                       |    22 +
 include/hw/gpio/aspeed_gpio.h                      |    18 +-
 include/hw/hw.h                                    |     2 +-
 include/hw/hyperv/hyperv-proto.h                   |    52 +
 include/hw/hyperv/hyperv.h                         |    58 +
 include/hw/hyperv/vmbus.h                          |     3 -
 include/hw/i2c/arm_sbcon_i2c.h                     |     7 +-
 include/hw/i2c/aspeed_i2c.h                        |   301 +-
 include/hw/i2c/i2c.h                               |    30 +
 include/hw/i2c/i2c_mux_pca954x.h                   |     4 +-
 include/hw/i2c/pmbus_device.h                      |     7 +
 include/hw/i386/intel_iommu.h                      |    25 +-
 include/hw/i386/microvm.h                          |     4 -
 include/hw/i386/pc.h                               |    33 +-
 include/hw/i386/x86-iommu.h                        |     4 +-
 include/hw/i386/x86.h                              |    13 +-
 include/hw/ide.h                                   |     3 -
 include/hw/ide/internal.h                          |     3 +
 include/hw/ide/piix.h                              |     7 +
 include/hw/input/i8042.h                           |    74 +-
 include/hw/input/lasips2.h                         |    68 +-
 include/hw/input/lm832x.h                          |     4 +-
 include/hw/input/pl050.h                           |    59 +
 include/hw/input/ps2.h                             |    77 +-
 include/hw/intc/arm_gicv3_common.h                 |    21 +-
 include/hw/intc/arm_gicv3_its_common.h             |    19 +
 include/hw/intc/exynos4210_combiner.h              |    57 +
 include/hw/intc/exynos4210_gic.h                   |    43 +
 include/hw/intc/loongarch_extioi.h                 |    62 +
 include/hw/intc/loongarch_ipi.h                    |    53 +
 include/hw/intc/loongarch_pch_msi.h                |    22 +
 include/hw/intc/loongarch_pch_pic.h                |    69 +
 include/hw/intc/nios2_vic.h                        |    64 +
 include/hw/intc/ppc-uic.h                          |     6 +-
 include/hw/intc/riscv_aclint.h                     |     3 +
 include/hw/intc/rx_icu.h                           |     2 +-
 include/hw/irq.h                                   |     5 -
 include/hw/isa/isa.h                               |    17 -
 include/hw/isa/vt82c686.h                          |     4 +-
 include/hw/loader.h                                |    55 +-
 include/hw/loongarch/virt.h                        |    57 +
 include/hw/mem/nvdimm.h                            |     8 -
 include/hw/mips/bios.h                             |     2 +-
 include/hw/mips/bootloader.h                       |     8 +-
 include/hw/misc/aspeed_hace.h                      |     9 +-
 include/hw/misc/aspeed_lpc.h                       |     2 +-
 include/hw/misc/aspeed_peci.h                      |    29 +
 include/hw/misc/aspeed_sbc.h                       |    15 +-
 include/hw/misc/aspeed_scu.h                       |    45 +
 include/hw/misc/bcm2835_cprman.h                   |     4 +-
 include/hw/misc/bcm2835_cprman_internals.h         |     4 +-
 include/hw/misc/lasi.h                             |    78 +
 include/hw/misc/macio/macio.h                      |    23 +-
 include/hw/misc/npcm7xx_gcr.h                      |    30 +
 include/hw/misc/pvpanic.h                          |     9 -
 include/hw/misc/stm32f4xx_exti.h                   |     4 +-
 include/hw/misc/stm32f4xx_syscfg.h                 |     4 +-
 include/hw/misc/xlnx-versal-crl.h                  |   235 +
 include/hw/misc/xlnx-versal-pmc-iou-slcr.h         |     6 +-
 include/hw/net/allwinner-sun8i-emac.h              |     2 +-
 include/hw/net/mv88w8618_eth.h                     |     5 +-
 include/hw/nubus/mac-nubus-bridge.h                |     4 +-
 include/hw/nvram/fw_cfg.h                          |    43 +
 include/hw/nvram/mac_nvram.h                       |    51 +
 include/hw/openrisc/boot.h                         |    34 +
 include/hw/pci-bridge/pci_expander_bridge.h        |    12 +
 include/hw/pci-host/dino.h                         |   146 +
 include/hw/pci-host/grackle.h                      |    44 +
 include/hw/pci-host/i440fx.h                       |     4 +-
 include/hw/pci-host/ls7a.h                         |    51 +
 include/hw/pci-host/pnv_phb3.h                     |    19 +-
 include/hw/pci-host/pnv_phb3_regs.h                |    16 -
 include/hw/pci-host/pnv_phb4.h                     |    22 +-
 include/hw/pci-host/remote.h                       |     4 +-
 include/hw/pci/msi.h                               |     1 +
 include/hw/pci/msix.h                              |     3 +-
 include/hw/pci/pci.h                               |    88 +-
 include/hw/pci/pci_bridge.h                        |    20 +
 include/hw/pci/pci_bus.h                           |     9 +
 include/hw/pci/pci_ids.h                           |     5 +
 include/hw/pci/pcie.h                              |     1 +
 include/hw/pci/pcie_doe.h                          |   123 +
 include/hw/pci/pcie_host.h                         |     6 +-
 include/hw/pci/pcie_port.h                         |     2 +
 include/hw/pci/pcie_regs.h                         |     4 +
 include/hw/ppc/pnv.h                               |    12 +-
 include/hw/ppc/pnv_lpc.h                           |     8 +-
 include/hw/ppc/pnv_occ.h                           |     7 +-
 include/hw/ppc/pnv_pnor.h                          |     8 +-
 include/hw/ppc/pnv_psi.h                           |     7 +-
 include/hw/ppc/pnv_sbe.h                           |    55 +
 include/hw/ppc/pnv_xscom.h                         |    12 +
 include/hw/ppc/ppc.h                               |    10 +-
 include/hw/ppc/ppc4xx.h                            |   135 +-
 include/hw/ppc/spapr.h                             |    34 +-
 include/hw/ppc/xive.h                              |     1 +
 include/hw/ptimer.h                                |    16 +-
 include/hw/qdev-core.h                             |    31 +-
 include/hw/qdev-properties.h                       |    12 +
 include/hw/registerfields.h                        |    70 +
 include/hw/remote/iommu.h                          |    40 +
 include/hw/remote/machine.h                        |     4 +
 include/hw/remote/vfio-user-obj.h                  |     6 +
 include/hw/riscv/boot.h                            |     5 +-
 include/hw/riscv/boot_opensbi.h                    |     5 +-
 include/hw/riscv/microchip_pfsoc.h                 |    14 +-
 include/hw/riscv/opentitan.h                       |    33 +-
 include/hw/riscv/shakti_c.h                        |     4 +-
 include/hw/riscv/sifive_e.h                        |     3 +-
 include/hw/riscv/virt.h                            |     9 +-
 include/hw/rtc/goldfish_rtc.h                      |     2 +
 include/hw/rtc/m48t59.h                            |     2 +-
 include/hw/rtc/mc146818rtc.h                       |     4 +-
 include/hw/rtc/sun4v-rtc.h                         |     4 +-
 include/hw/rtc/xlnx-zynqmp-rtc.h                   |     4 +-
 include/hw/rx/rx62n.h                              |     4 +-
 include/hw/s390x/pv.h                              |    19 +
 include/hw/s390x/s390-pci-bus.h                    |     8 +-
 include/hw/s390x/s390-pci-clp.h                    |     4 +-
 include/hw/s390x/s390-pci-kvm.h                    |    38 +
 include/hw/s390x/s390-pci-vfio.h                   |     5 +
 include/hw/s390x/s390-virtio-ccw.h                 |     1 +
 include/hw/scsi/scsi.h                             |    19 +-
 include/hw/sd/allwinner-sdhost.h                   |     1 +
 include/hw/sensor/emc141x_regs.h                   |     4 +-
 include/hw/sensor/isl_pmbus_vr.h                   |     5 +
 include/hw/southbridge/piix.h                      |    12 +-
 include/hw/ssi/aspeed_smc.h                        |     2 +
 include/hw/ssi/ibex_spi_host.h                     |    94 +
 include/hw/ssi/ssi.h                               |     3 +
 include/hw/ssi/xlnx-versal-ospi.h                  |     6 +-
 include/hw/timer/aspeed_timer.h                    |     1 +
 include/hw/timer/bcm2835_systmr.h                  |     4 +-
 include/hw/timer/cadence_ttc.h                     |    54 +
 include/hw/timer/ibex_timer.h                      |     2 +
 include/hw/tricore/tc27x_soc.h                     |     4 +-
 include/hw/tricore/tricore_testdevice.h            |     5 +-
 include/hw/usb.h                                   |   100 +-
 include/hw/usb/dwc2-regs.h                         |  1618 +-
 include/hw/usb/hcd-musb.h                          |     4 +-
 include/hw/usb/msd.h                               |     1 +
 include/hw/usb/xlnx-usb-subsystem.h                |     4 +-
 include/hw/usb/xlnx-versal-usb2-ctrl-regs.h        |     4 +-
 include/hw/vfio/vfio-common.h                      |     2 +-
 include/hw/virtio/vhost-backend.h                  |     3 +
 include/hw/virtio/vhost-user-blk.h                 |     1 -
 include/hw/virtio/vhost-user-fs.h                  |     6 +-
 include/hw/virtio/vhost-user-gpio.h                |    45 +
 include/hw/virtio/vhost-user-i2c.h                 |     6 +-
 include/hw/virtio/vhost-user-rng.h                 |     6 +-
 include/hw/virtio/vhost-user-vsock.h               |     6 +-
 include/hw/virtio/vhost-user.h                     |    61 +-
 include/hw/virtio/vhost-vdpa.h                     |     7 +
 include/hw/virtio/vhost-vsock-common.h             |     8 +-
 include/hw/virtio/vhost.h                          |   179 +-
 include/hw/virtio/virtio-access.h                  |     8 +-
 include/hw/virtio/virtio-blk-common.h              |    20 +
 include/hw/virtio/virtio-blk.h                     |     2 +
 include/hw/virtio/virtio-crypto.h                  |     5 +-
 include/hw/virtio/virtio-gpu-bswap.h               |     2 +-
 include/hw/virtio/virtio-gpu.h                     |     4 +-
 include/hw/virtio/virtio-iommu.h                   |     4 +-
 include/hw/virtio/virtio-net.h                     |     7 +
 include/hw/virtio/virtio-pci.h                     |   260 +
 include/hw/virtio/virtio-scsi.h                    |    45 -
 include/hw/virtio/virtio.h                         |    77 +-
 include/hw/watchdog/wdt_aspeed.h                   |     3 +
 include/hw/watchdog/wdt_imx2.h                     |     6 +-
 include/hw/xen/xen.h                               |     2 +-
 include/hw/xen/xen_common.h                        |     6 -
 include/io/channel-command.h                       |    30 +-
 include/io/channel-null.h                          |    55 +
 include/io/channel-socket.h                        |     2 +
 include/io/channel.h                               |    38 +-
 include/libdecnumber/dconfig.h                     |     2 +-
 include/monitor/hmp.h                              |    12 +-
 include/monitor/monitor.h                          |     4 +
 include/monitor/stats.h                            |    45 +
 include/net/eth.h                                  |     2 +-
 include/net/net.h                                  |    14 +-
 include/net/vhost_net.h                            |     4 +
 include/qapi/qmp/qbool.h                           |     4 +
 include/qapi/qmp/qdict.h                           |     7 +-
 include/qapi/qmp/qerror.h                          |     3 -
 include/qapi/qmp/qlist.h                           |     4 +
 include/qapi/qmp/qnull.h                           |     4 +
 include/qapi/qmp/qnum.h                            |     4 +
 include/qapi/qmp/qstring.h                         |     4 +
 include/qemu-common.h                              |   117 -
 include/qemu-main.h                                |    11 +
 include/qemu/accel.h                               |    13 +
 include/qemu/async-teardown.h                      |    22 +
 include/qemu/atomic.h                              |    24 +-
 include/qemu/bitmap.h                              |     1 +
 include/qemu/bswap.h                               |    64 +-
 include/qemu/compiler.h                            |    26 +-
 include/qemu/config-file.h                         |     1 -
 include/qemu/coroutine.h                           |   100 +-
 include/qemu/cpu-float.h                           |    64 +
 include/qemu/crc-ccitt.h                           |     6 +-
 include/qemu/cutils.h                              |    66 +-
 include/qemu/error-report.h                        |     2 -
 include/qemu/hbitmap.h                             |    15 +-
 include/qemu/help-texts.h                          |    13 +
 include/qemu/host-utils.h                          |    73 +-
 include/qemu/int128.h                              |    61 +-
 include/qemu/iova-tree.h                           |     4 +-
 include/qemu/job.h                                 |   306 +-
 include/qemu/keyval.h                              |    15 +
 include/qemu/log-for-trace.h                       |     2 +-
 include/qemu/log.h                                 |    93 +-
 include/qemu/main-loop.h                           |    42 +-
 include/qemu/mmap-alloc.h                          |     2 -
 include/qemu/module.h                              |    47 +-
 include/qemu/option.h                              |     6 -
 include/qemu/osdep.h                               |   115 +-
 include/qemu/plugin-memory.h                       |     2 +-
 include/qemu/plugin.h                              |    24 +
 include/qemu/qemu-plugin.h                         |     7 +-
 include/qemu/qemu-progress.h                       |     8 +
 include/qemu/selfmap.h                             |     2 +-
 include/qemu/sockets.h                             |    41 +-
 include/qemu/thread-context.h                      |    57 +
 include/qemu/thread-posix.h                        |     9 +-
 include/qemu/thread.h                              |    14 +-
 include/qemu/typedefs.h                            |     5 +
 include/qemu/win_dump_defs.h                       |   115 +-
 include/qom/object.h                               |     1 -
 include/scsi/constants.h                           |     2 +
 include/semihosting/common-semi.h                  |    39 +
 include/semihosting/console.h                      |    66 +-
 include/semihosting/guestfd.h                      |    91 +
 include/semihosting/semihost.h                     |    24 +-
 include/semihosting/softmmu-uaccess.h              |    59 +
 include/semihosting/syscalls.h                     |    75 +
 include/standard-headers/asm-m68k/bootinfo-virt.h  |     3 +
 include/standard-headers/asm-m68k/bootinfo.h       |     8 +-
 include/standard-headers/asm-x86/bootparam.h       |     8 +-
 include/standard-headers/drm/drm_fourcc.h          |    73 +-
 include/standard-headers/linux/ethtool.h           |    29 +-
 include/standard-headers/linux/input-event-codes.h |    25 +-
 include/standard-headers/linux/input.h             |    12 +-
 include/standard-headers/linux/pci_regs.h          |    30 +-
 include/standard-headers/linux/vhost_types.h       |    17 +-
 include/standard-headers/linux/virtio_9p.h         |     2 +-
 include/standard-headers/linux/virtio_config.h     |    13 +-
 include/standard-headers/linux/virtio_crypto.h     |    82 +-
 include/standard-headers/linux/virtio_ids.h        |    14 +-
 include/standard-headers/linux/virtio_net.h        |    34 +-
 include/standard-headers/linux/virtio_pci.h        |     2 +
 include/standard-headers/linux/virtio_ring.h       |    16 +-
 include/sysemu/accel-ops.h                         |     8 +
 include/sysemu/arch_init.h                         |     1 +
 include/sysemu/block-backend-global-state.h        |    10 +-
 include/sysemu/block-backend-io.h                  |    98 +-
 include/sysemu/block-ram-registrar.h               |    37 +
 include/sysemu/cpu-timers.h                        |     1 +
 include/sysemu/cpus.h                              |     3 +
 include/sysemu/cryptodev.h                         |   136 +-
 include/sysemu/device_tree.h                       |    10 +
 include/sysemu/dirtylimit.h                        |    37 +
 include/sysemu/dirtyrate.h                         |    28 +
 include/sysemu/dump-arch.h                         |     3 +
 include/sysemu/dump.h                              |    38 +-
 include/sysemu/event-loop-base.h                   |    41 +
 include/sysemu/hostmem.h                           |     2 +
 include/sysemu/iothread.h                          |     6 +-
 include/sysemu/kvm.h                               |    40 +-
 include/sysemu/kvm_int.h                           |    76 +
 include/sysemu/os-posix.h                          |     5 +-
 include/sysemu/os-win32.h                          |    43 +-
 include/sysemu/replay.h                            |    11 +-
 include/sysemu/reset.h                             |     5 +-
 include/sysemu/runstate.h                          |     9 +-
 include/sysemu/sysemu.h                            |    11 +-
 include/sysemu/tpm.h                               |     6 +
 include/sysemu/watchdog.h                          |    12 -
 include/tcg/tcg-ldst.h                             |     6 +-
 include/tcg/tcg-op.h                               |    11 +
 include/tcg/tcg.h                                  |     8 +-
 include/ui/console.h                               |     7 +-
 include/ui/dbus-display.h                          |     6 +-
 include/ui/dbus-module.h                           |     6 +-
 include/ui/gtk.h                                   |     2 +-
 include/ui/qemu-pixman.h                           |     2 +-
 include/user/safe-syscall.h                        |     2 +-
 include/user/syscall-trace.h                       |     2 +-
 io/channel-buffer.c                                |     1 +
 io/channel-command.c                               |   214 +-
 io/channel-file.c                                  |    14 +-
 io/channel-null.c                                  |   237 +
 io/channel-socket.c                                |   140 +-
 io/channel-tls.c                                   |     1 +
 io/channel-watch.c                                 |    12 +-
 io/channel-websock.c                               |     3 +-
 io/channel.c                                       |    49 +-
 io/meson.build                                     |     1 +
 io/trace-events                                    |     3 +
 iothread.c                                         |    68 +-
 job-qmp.c                                          |    92 +-
 job.c                                              |   674 +-
 libdecnumber/dpd/decimal64.c                       |     3 +-
 linux-headers/asm-arm64/kvm.h                      |    49 +-
 linux-headers/asm-generic/mman-common.h            |     2 +
 linux-headers/asm-generic/unistd.h                 |     4 +-
 linux-headers/asm-mips/mman.h                      |     2 +
 linux-headers/asm-riscv/kvm.h                      |    22 +
 linux-headers/asm-riscv/unistd.h                   |     3 +-
 linux-headers/asm-s390/kvm.h                       |     1 +
 linux-headers/asm-x86/kvm.h                        |    33 +-
 linux-headers/asm-x86/mman.h                       |    14 -
 linux-headers/linux/kvm.h                          |   198 +-
 linux-headers/linux/psci.h                         |     4 +
 linux-headers/linux/userfaultfd.h                  |    16 +-
 linux-headers/linux/vduse.h                        |   353 +
 linux-headers/linux/vfio.h                         |   410 +-
 linux-headers/linux/vfio_zdev.h                    |     7 +
 linux-headers/linux/vhost.h                        |    40 +-
 linux-user/aarch64/cpu_loop.c                      |    14 +-
 linux-user/aarch64/signal.c                        |   245 +-
 linux-user/aarch64/target_cpu.h                    |     5 +-
 linux-user/aarch64/target_mman.h                   |     1 +
 linux-user/aarch64/target_prctl.h                  |    80 +-
 linux-user/aarch64/target_syscall.h                |     2 +-
 linux-user/alpha/cpu_loop.c                        |     1 -
 linux-user/alpha/target_mman.h                     |     8 +
 linux-user/arm/cpu_loop.c                          |     7 +-
 linux-user/arm/nwfpe/double_cpdo.c                 |     4 +-
 linux-user/arm/nwfpe/fpa11_cpdt.c                  |     4 +-
 linux-user/arm/target_cpu.h                        |     4 +-
 linux-user/arm/target_mman.h                       |     1 +
 linux-user/arm/target_syscall.h                    |     2 +-
 linux-user/cpu_loop-common.h                       |    13 +-
 linux-user/cris/cpu_loop.c                         |     1 -
 linux-user/cris/target_mman.h                      |     1 +
 linux-user/elfload.c                               |   321 +-
 linux-user/flatload.c                              |     2 +-
 linux-user/generic/target_mman.h                   |    92 +
 linux-user/hexagon/cpu_loop.c                      |     1 -
 linux-user/hexagon/target_mman.h                   |     1 +
 linux-user/hexagon/target_signal.h                 |     2 +-
 linux-user/hppa/cpu_loop.c                         |    22 +-
 linux-user/hppa/signal.c                           |    57 +-
 linux-user/hppa/target_mman.h                      |    15 +
 linux-user/hppa/target_signal.h                    |    14 +-
 linux-user/hppa/target_syscall.h                   |     2 +
 linux-user/i386/cpu_loop.c                         |     9 +-
 linux-user/i386/signal.c                           |   231 +-
 linux-user/i386/target_elf.h                       |     2 +-
 linux-user/i386/target_mman.h                      |     1 +
 linux-user/include/host/s390/host-signal.h         |    32 +
 linux-user/ioctls.h                                |    24 -
 linux-user/linuxload.c                             |    12 +-
 linux-user/loongarch64/cpu_loop.c                  |    96 +
 linux-user/loongarch64/signal.c                    |   315 +
 linux-user/loongarch64/sockbits.h                  |    11 +
 linux-user/loongarch64/syscall_nr.h                |   312 +
 linux-user/loongarch64/target_cpu.h                |    34 +
 linux-user/loongarch64/target_elf.h                |    12 +
 linux-user/loongarch64/target_errno_defs.h         |    12 +
 linux-user/loongarch64/target_fcntl.h              |    11 +
 linux-user/loongarch64/target_mman.h               |     1 +
 linux-user/loongarch64/target_prctl.h              |     1 +
 linux-user/loongarch64/target_resource.h           |    11 +
 linux-user/loongarch64/target_signal.h             |    13 +
 linux-user/loongarch64/target_structs.h            |    11 +
 linux-user/loongarch64/target_syscall.h            |    48 +
 linux-user/loongarch64/termbits.h                  |    11 +
 linux-user/m68k/cpu_loop.c                         |    19 +-
 linux-user/m68k/target_mman.h                      |     1 +
 linux-user/main.c                                  |    80 +-
 linux-user/microblaze/cpu_loop.c                   |     1 -
 linux-user/microblaze/target_mman.h                |     1 +
 linux-user/mips/cpu_loop.c                         |     1 -
 linux-user/mips/target_mman.h                      |     1 +
 linux-user/mips64/target_mman.h                    |     1 +
 linux-user/mmap.c                                  |   112 +-
 linux-user/nios2/cpu_loop.c                        |    96 +-
 linux-user/nios2/signal.c                          |    25 +-
 linux-user/nios2/target_cpu.h                      |     1 +
 linux-user/nios2/target_mman.h                     |     1 +
 linux-user/openrisc/cpu_loop.c                     |     1 -
 linux-user/openrisc/target_mman.h                  |     1 +
 linux-user/ppc/cpu_loop.c                          |     1 -
 linux-user/ppc/signal.c                            |     5 +-
 linux-user/ppc/target_mman.h                       |     1 +
 linux-user/ppc/target_syscall.h                    |     2 +-
 linux-user/qemu.h                                  |    15 +-
 linux-user/riscv/cpu_loop.c                        |     3 +-
 linux-user/riscv/signal.c                          |     4 +-
 linux-user/riscv/target_mman.h                     |     1 +
 linux-user/s390x/cpu_loop.c                        |     1 -
 linux-user/s390x/signal.c                          |     7 +
 linux-user/s390x/target_mman.h                     |     1 +
 linux-user/semihost.c                              |    48 +-
 linux-user/sh4/cpu_loop.c                          |     1 -
 linux-user/sh4/signal.c                            |     6 +-
 linux-user/sh4/target_mman.h                       |     1 +
 linux-user/signal-common.h                         |    46 +
 linux-user/signal.c                                |    40 +-
 linux-user/sparc/cpu_loop.c                        |     1 -
 linux-user/sparc/target_mman.h                     |     1 +
 linux-user/strace.c                                |   524 +-
 linux-user/strace.h                                |     4 +-
 linux-user/strace.list                             |    40 +-
 linux-user/syscall.c                               |   502 +-
 linux-user/syscall_defs.h                          |    14 +-
 linux-user/uname.c                                 |     7 +-
 linux-user/uname.h                                 |     2 +-
 linux-user/user-internals.h                        |    23 +-
 linux-user/user-mmap.h                             |     1 +
 linux-user/x86_64/target_elf.h                     |     2 +-
 linux-user/x86_64/target_mman.h                    |     1 +
 linux-user/xtensa/signal.c                         |     2 +-
 linux-user/xtensa/target_mman.h                    |     1 +
 linux-user/xtensa/target_structs.h                 |     2 +-
 meson                                              |     2 +-
 meson.build                                        |  1103 +-
 meson_options.txt                                  |    79 +-
 migration/block.c                                  |    24 +-
 migration/channel-block.c                          |   197 +
 migration/channel-block.h                          |    59 +
 migration/channel.c                                |    15 +-
 migration/colo.c                                   |     5 +-
 migration/dirtyrate.c                              |   227 +-
 migration/dirtyrate.h                              |     7 +-
 migration/meson.build                              |     4 +-
 migration/migration.c                              |   296 +-
 migration/migration.h                              |    54 +-
 migration/multifd-zlib.c                           |    38 +-
 migration/multifd.c                                |   119 +-
 migration/multifd.h                                |    70 +-
 migration/postcopy-ram.c                           |   190 +-
 migration/postcopy-ram.h                           |    11 +
 migration/qemu-file-channel.c                      |   194 -
 migration/qemu-file-channel.h                      |    32 -
 migration/qemu-file.c                              |   247 +-
 migration/qemu-file.h                              |   126 +-
 migration/ram.c                                    |   434 +-
 migration/ram.h                                    |     5 +
 migration/rdma.c                                   |   186 +-
 migration/savevm.c                                 |   106 +-
 migration/socket.c                                 |    34 +-
 migration/socket.h                                 |     1 +
 migration/tls.c                                    |    13 +-
 migration/tls.h                                    |     4 +
 migration/trace-events                             |    18 +-
 migration/vmstate-types.c                          |     1 +
 migration/vmstate.c                                |     5 +-
 monitor/hmp-cmds.c                                 |   590 +-
 monitor/hmp.c                                      |    15 +-
 monitor/misc.c                                     |    26 +-
 monitor/monitor-internal.h                         |     1 -
 monitor/monitor.c                                  |    10 +
 monitor/qmp-cmds.c                                 |   182 +-
 nbd/client-connection.c                            |     2 +
 nbd/server.c                                       |    81 +-
 nbd/trace-events                                   |     3 +
 net/announce.c                                     |     2 +-
 net/can/can_socketcan.c                            |    26 +-
 net/clients.h                                      |    17 +
 net/colo-compare.c                                 |     3 +-
 net/colo.c                                         |    26 +-
 net/colo.h                                         |     1 +
 net/dgram.c                                        |   623 +
 net/filter-rewriter.c                              |     2 +-
 net/hub.c                                          |     2 +
 net/l2tpv3.c                                       |     5 +-
 net/meson.build                                    |    22 +-
 net/net.c                                          |   219 +-
 net/slirp.c                                        |    90 +-
 net/socket.c                                       |    47 +-
 net/stream.c                                       |   386 +
 net/tap-bsd.c                                      |     5 +-
 net/tap-linux.c                                    |     3 +-
 net/tap-linux.h                                    |    10 +-
 net/tap-solaris.c                                  |     3 +-
 net/tap-win32.c                                    |     4 +-
 net/tap.c                                          |    63 +-
 net/trace-events                                   |     1 +
 net/util.h                                         |     2 +-
 net/vde.c                                          |     4 +-
 net/vhost-user.c                                   |     3 +-
 net/vhost-vdpa-stub.c                              |    21 +
 net/vhost-vdpa.c                                   |   460 +-
 net/vmnet-bridged.m                                |   152 +
 net/vmnet-common.m                                 |   378 +
 net/vmnet-host.c                                   |   128 +
 net/vmnet-shared.c                                 |   114 +
 net/vmnet_int.h                                    |    63 +
 os-posix.c                                         |    14 +-
 os-win32.c                                         |    10 -
 page-vary-common.c                                 |     1 -
 page-vary.c                                        |     2 +-
 pc-bios/README                                     |     2 +-
 pc-bios/bios-256k.bin                              |   Bin 262144 -> 262144 bytes
 pc-bios/bios-microvm.bin                           |   Bin 131072 -> 131072 bytes
 pc-bios/bios.bin                                   |   Bin 131072 -> 131072 bytes
 pc-bios/hppa-firmware.img                          |   Bin 701964 -> 719368 bytes
 pc-bios/keymaps/meson.build                        |    22 +-
 pc-bios/meson.build                                |     4 +-
 pc-bios/opensbi-riscv32-generic-fw_dynamic.bin     |   Bin 108504 -> 117704 bytes
 pc-bios/opensbi-riscv64-generic-fw_dynamic.bin     |   Bin 105296 -> 115344 bytes
 pc-bios/optionrom/Makefile                         |    70 +-
 pc-bios/optionrom/code16gcc.h                      |     3 -
 pc-bios/qboot.rom                                  |   Bin 65536 -> 65536 bytes
 pc-bios/s390-ccw.img                               |   Bin 50936 -> 42608 bytes
 pc-bios/s390-ccw/Makefile                          |    63 +-
 pc-bios/s390-ccw/bootmap.c                         |    27 +-
 pc-bios/s390-ccw/cio.h                             |     2 +-
 pc-bios/s390-ccw/iplb.h                            |     2 +-
 pc-bios/s390-ccw/main.c                            |    27 +-
 pc-bios/s390-ccw/netboot.mak                       |    28 +-
 pc-bios/s390-ccw/s390-ccw.h                        |     1 +
 pc-bios/s390-ccw/start.S                           |     2 +-
 pc-bios/s390-ccw/virtio-blkdev.c                   |    93 +-
 pc-bios/s390-ccw/virtio-scsi.c                     |    21 +-
 pc-bios/s390-ccw/virtio-scsi.h                     |     2 +-
 pc-bios/s390-ccw/virtio.c                          |    28 +-
 pc-bios/s390-ccw/virtio.h                          |    16 +-
 pc-bios/s390-netboot.img                           |   Bin 79688 -> 67232 bytes
 pc-bios/skiboot.lid                                |   Bin 2528128 -> 2527240 bytes
 pc-bios/slof.bin                                   |   Bin 992384 -> 995176 bytes
 pc-bios/vgabios-ati.bin                            |   Bin 39936 -> 39936 bytes
 pc-bios/vgabios-bochs-display.bin                  |   Bin 28672 -> 28672 bytes
 pc-bios/vgabios-cirrus.bin                         |   Bin 39424 -> 39424 bytes
 pc-bios/vgabios-qxl.bin                            |   Bin 39424 -> 39936 bytes
 pc-bios/vgabios-ramfb.bin                          |   Bin 28672 -> 29184 bytes
 pc-bios/vgabios-stdvga.bin                         |   Bin 39424 -> 39936 bytes
 pc-bios/vgabios-virtio.bin                         |   Bin 39424 -> 39936 bytes
 pc-bios/vgabios-vmware.bin                         |   Bin 39424 -> 39936 bytes
 pc-bios/vgabios.bin                                |   Bin 38912 -> 39424 bytes
 pc-bios/vof/Makefile                               |    28 +-
 plugins/api.c                                      |     2 +
 plugins/core.c                                     |    22 +-
 plugins/meson.build                                |     2 +-
 plugins/plugin.h                                   |     6 +-
 po/LINGUAS                                         |     1 +
 po/uk.po                                           |    75 +
 python/Makefile                                    |     2 +-
 python/README.rst                                  |     2 +-
 python/qemu/aqmp/__init__.py                       |    59 -
 python/qemu/aqmp/aqmp_tui.py                       |   653 -
 python/qemu/aqmp/error.py                          |    50 -
 python/qemu/aqmp/events.py                         |   717 -
 python/qemu/aqmp/legacy.py                         |   177 -
 python/qemu/aqmp/message.py                        |   209 -
 python/qemu/aqmp/models.py                         |   146 -
 python/qemu/aqmp/protocol.py                       |  1048 -
 python/qemu/aqmp/py.typed                          |     0
 python/qemu/aqmp/qmp_client.py                     |   655 -
 python/qemu/aqmp/qmp_shell.py                      |   609 -
 python/qemu/aqmp/util.py                           |   217 -
 python/qemu/machine/machine.py                     |    20 +-
 python/qemu/machine/qtest.py                       |     2 +-
 python/qemu/qmp/README.rst                         |     9 -
 python/qemu/qmp/__init__.py                        |   447 +-
 python/qemu/qmp/error.py                           |    50 +
 python/qemu/qmp/events.py                          |   717 +
 python/qemu/qmp/legacy.py                          |   315 +
 python/qemu/qmp/message.py                         |   209 +
 python/qemu/qmp/models.py                          |   146 +
 python/qemu/qmp/protocol.py                        |  1048 +
 python/qemu/qmp/qmp_client.py                      |   655 +
 python/qemu/qmp/qmp_shell.py                       |   610 +
 python/qemu/qmp/qmp_tui.py                         |   652 +
 python/qemu/qmp/util.py                            |   219 +
 python/qemu/utils/__init__.py                      |     2 +-
 python/qemu/utils/qemu_ga_client.py                |     4 +-
 python/qemu/utils/qom.py                           |     2 +-
 python/qemu/utils/qom_common.py                    |     4 +-
 python/qemu/utils/qom_fuse.py                      |     2 +-
 python/setup.cfg                                   |    12 +-
 python/tests/protocol.py                           |    14 +-
 qapi/audio.json                                    |    26 +-
 qapi/block-core.json                               |   348 +-
 qapi/block-export.json                             |    65 +-
 qapi/block.json                                    |    25 +-
 qapi/char.json                                     |    10 +-
 qapi/common.json                                   |     2 -
 qapi/control.json                                  |    13 +-
 qapi/crypto.json                                   |   128 +-
 qapi/dump.json                                     |     6 +-
 qapi/job.json                                      |     1 -
 qapi/machine-target.json                           |     7 +-
 qapi/machine.json                                  |   130 +-
 qapi/meson.build                                   |    19 +-
 qapi/migration.json                                |   151 +-
 qapi/misc-target.json                              |    17 +-
 qapi/misc.json                                     |    39 +-
 qapi/net.json                                      |   261 +-
 qapi/pragma.json                                   |     3 +-
 qapi/qapi-schema.json                              |     2 +
 qapi/qdev.json                                     |     3 +-
 qapi/qmp-event.c                                   |     9 +-
 qapi/qobject-input-visitor.c                       |     2 +-
 qapi/qom.json                                      |    95 +-
 qapi/replay.json                                   |     1 -
 qapi/run-state.json                                |    38 +-
 qapi/sockets.json                                  |     8 +-
 qapi/stats.json                                    |   251 +
 qapi/ui.json                                       |   191 +-
 qapi/virtio.json                                   |   954 +
 qemu-edid.c                                        |     4 +
 qemu-img.c                                         |   105 +-
 qemu-io-cmds.c                                     |    20 +-
 qemu-io.c                                          |     5 +-
 qemu-nbd.c                                         |    22 +-
 qemu-options.hx                                    |   432 +-
 qga/channel-posix.c                                |    76 +-
 qga/commands-bsd.c                                 |   200 +
 qga/commands-common.h                              |    62 +
 qga/commands-linux.c                               |   286 +
 qga/commands-posix.c                               |  1646 +-
 qga/commands-win32.c                               |    78 +-
 qga/commands.c                                     |    19 +-
 qga/cutils.c                                       |    33 +
 qga/cutils.h                                       |     8 +
 qga/guest-agent-core.h                             |     2 +-
 qga/installer/qemu-ga.wxs                          |    83 +-
 qga/main.c                                         |   117 +-
 qga/meson.build                                    |    26 +-
 qga/qapi-schema.json                               |   231 +-
 qga/vss-win32/meson.build                          |     6 +-
 qga/vss-win32/requester.cpp                        |     4 +-
 qobject/qbool.c                                    |     5 +
 qobject/qdict.c                                    |     5 +
 qobject/qlist.c                                    |     5 +
 qobject/qnull.c                                    |     5 +
 qobject/qnum.c                                     |     5 +
 qobject/qstring.c                                  |     5 +
 qom/object.c                                       |    24 +-
 qom/object_interfaces.c                            |     1 +
 replay/replay-char.c                               |     2 +-
 replay/replay-events.c                             |    56 +-
 replay/replay-internal.h                           |    39 +-
 replay/replay-snapshot.c                           |     2 -
 replay/replay.c                                    |    84 +-
 roms/SLOF                                          |     2 +-
 roms/opensbi                                       |     2 +-
 roms/qboot                                         |     2 +-
 roms/seabios                                       |     2 +-
 roms/seabios-hppa                                  |     2 +-
 roms/skiboot                                       |     2 +-
 scripts/analyze-inclusions                         |     4 -
 scripts/archive-source.sh                          |     2 +-
 scripts/checkpatch.pl                              |    17 +-
 scripts/ci/org.centos/stream/8/x86_64/configure    |     7 +-
 scripts/ci/setup/build-environment.yml             |    29 +-
 scripts/clean-header-guards.pl                     |     4 +-
 scripts/clean-includes                             |     2 +-
 scripts/cocci-macro-file.h                         |     2 +-
 scripts/coverity-scan/COMPONENTS.md                |    15 +-
 scripts/coverity-scan/run-coverity-scan            |     2 +-
 scripts/cpu-x86-uarch-abi.py                       |     2 +-
 scripts/device-crash-test                          |    19 +-
 scripts/feature_to_c.sh                            |     1 +
 scripts/gensyscalls.sh                             |     2 +
 scripts/git-submodule.sh                           |    12 +-
 scripts/hxtool-conv.pl                             |   137 -
 scripts/kvm/vmxcap                                 |    17 +
 scripts/main.c                                     |     1 +
 scripts/meson-buildoptions.py                      |    89 +-
 scripts/meson-buildoptions.sh                      |   134 +-
 scripts/modinfo-generate.py                        |    49 +-
 scripts/mtest2make.py                              |     8 +-
 scripts/nsis.py                                    |    60 +-
 scripts/oss-fuzz/build.sh                          |    16 +-
 scripts/oss-fuzz/output_reproducer.py              |     2 +-
 scripts/qapi/common.py                             |     2 +-
 scripts/qapi/expr.py                               |     4 +-
 scripts/qapi/schema.py                             |     4 +
 scripts/qemu-binfmt-conf.sh                        |     9 +-
 scripts/qemu-stamp.py                              |    24 +
 scripts/qmp/qmp-shell                              |     2 +-
 scripts/qmp/qmp-shell-wrap                         |     2 +-
 scripts/render_block_graph.py                      |     4 +-
 scripts/simplebench/bench_block_job.py             |     5 +-
 scripts/symlink-install-tree.py                    |    33 +
 scripts/update-linux-headers.sh                    |     2 +-
 scripts/vmstate-static-checker.py                  |     3 +-
 scripts/xen-detect.c                               |   203 +
 scsi/pr-manager-helper.c                           |     2 +-
 scsi/qemu-pr-helper.c                              |    10 +-
 semihosting/arm-compat-semi.c                      |  1023 +-
 semihosting/common-semi.h                          |    39 -
 semihosting/config.c                               |    28 +-
 semihosting/console.c                              |   139 +-
 semihosting/guestfd.c                              |   160 +
 semihosting/meson.build                            |     6 +
 semihosting/syscalls.c                             |   978 +
 semihosting/uaccess.c                              |    91 +
 slirp                                              |     1 -
 softmmu/bootdevice.c                               |     3 +-
 softmmu/cpu-throttle.c                             |     1 -
 softmmu/cpu-timers.c                               |     1 -
 softmmu/cpus.c                                     |    31 +-
 softmmu/datadir.c                                  |    31 +-
 softmmu/device_tree.c                              |    58 +
 softmmu/dirtylimit.c                               |   601 +
 softmmu/globals.c                                  |     5 +-
 softmmu/icount.c                                   |    13 +-
 softmmu/main.c                                     |    33 +-
 softmmu/memory.c                                   |    74 +-
 softmmu/meson.build                                |     1 +
 softmmu/physmem.c                                  |    57 +-
 softmmu/qdev-monitor.c                             |     7 +-
 softmmu/qemu-seccomp.c                             |    13 +
 softmmu/qtest.c                                    |    53 +-
 softmmu/runstate.c                                 |    30 +-
 softmmu/trace-events                               |     7 +
 softmmu/vl.c                                       |   573 +-
 storage-daemon/qemu-storage-daemon.c               |    32 +-
 stubs/error-printf.c                               |     1 +
 stubs/get-vm-name.c                                |     2 +-
 stubs/icount.c                                     |     4 +
 stubs/meson.build                                  |     4 +-
 stubs/monitor-core.c                               |     1 -
 stubs/physmem.c                                    |    13 +
 stubs/replay-tools.c                               |     9 +-
 stubs/semihost.c                                   |     8 +-
 stubs/vfio-user-obj.c                              |     6 +
 stubs/xen-hw-stub.c                                |     3 +-
 subprojects/libvduse/include/atomic.h              |     1 +
 subprojects/libvduse/include/compiler.h            |     1 +
 subprojects/libvduse/libvduse.c                    |  1376 ++
 subprojects/libvduse/libvduse.h                    |   247 +
 subprojects/libvduse/linux-headers/linux           |     1 +
 subprojects/libvduse/meson.build                   |    10 +
 subprojects/libvduse/standard-headers/linux        |     1 +
 subprojects/libvfio-user                           |     1 +
 subprojects/libvhost-user/include/compiler.h       |     1 +
 subprojects/libvhost-user/libvhost-user.c          |    58 +-
 subprojects/libvhost-user/libvhost-user.h          |     9 +
 target/Kconfig                                     |     1 +
 target/alpha/cpu-param.h                           |     2 +-
 target/alpha/cpu.c                                 |    18 +
 target/alpha/cpu.h                                 |    11 +-
 target/alpha/helper.c                              |    12 +-
 target/alpha/mem_helper.c                          |     2 +-
 target/alpha/translate.c                           |    20 +-
 target/arm/a32.decode                              |    16 +-
 target/arm/arch_dump.c                             |     8 +-
 target/arm/common-semi-target.h                    |    62 +
 target/arm/cpregs.h                                |   496 +
 target/arm/cpu-param.h                             |    19 +-
 target/arm/cpu.c                                   |   307 +-
 target/arm/cpu.h                                   |  1228 +-
 target/arm/cpu64.c                                 |  1090 +-
 target/arm/cpu_tcg.c                               |   253 +-
 target/arm/crypto_helper.c                         |    38 +-
 target/arm/debug_helper.c                          |   810 +-
 target/arm/gdbstub.c                               |     7 +-
 target/arm/gdbstub64.c                             |     2 +-
 target/arm/helper-a64.c                            |     4 +-
 target/arm/helper-sme.h                            |   147 +
 target/arm/helper-sve.h                            |     4 +
 target/arm/helper.c                                |  5586 ++---
 target/arm/helper.h                                |    28 +-
 target/arm/hvf/hvf.c                               |    10 +-
 target/arm/internals.h                             |   392 +-
 target/arm/kvm-stub.c                              |     4 +-
 target/arm/kvm.c                                   |    15 +-
 target/arm/kvm64.c                                 |   119 +-
 target/arm/kvm_arm.h                               |     7 +-
 target/arm/m_helper.c                              |    91 +-
 target/arm/machine.c                               |    38 +-
 target/arm/meson.build                             |     5 +
 target/arm/mte_helper.c                            |    69 +-
 target/arm/mve_helper.c                            |     6 +-
 target/arm/neon_helper.c                           |     2 +-
 target/arm/op_helper.c                             |   170 +-
 target/arm/pauth_helper.c                          |     4 +-
 target/arm/ptw.c                                   |  2895 +++
 target/arm/sme-fa64.decode                         |    60 +
 target/arm/sme.decode                              |    88 +
 target/arm/sme_helper.c                            |  1201 +
 target/arm/sve.decode                              |    98 +-
 target/arm/sve_helper.c                            |   325 +-
 target/arm/sve_ldst_internal.h                     |   222 +
 target/arm/syndrome.h                              |    26 +-
 target/arm/t32.decode                              |    18 +-
 target/arm/tlb_helper.c                            |    80 +-
 target/arm/translate-a32.h                         |    19 +-
 target/arm/translate-a64.c                         |   818 +-
 target/arm/translate-a64.h                         |    96 +-
 target/arm/translate-m-nocp.c                      |    29 +-
 target/arm/translate-mve.c                         |     3 +-
 target/arm/translate-neon.c                        |    29 +-
 target/arm/translate-sme.c                         |   373 +
 target/arm/translate-sve.c                         |  6006 ++---
 target/arm/translate-vfp.c                         |   110 +-
 target/arm/translate.c                             |   768 +-
 target/arm/translate.h                             |   151 +-
 target/arm/vec_helper.c                            |    52 +-
 target/arm/vec_internal.h                          |    36 +-
 target/avr/cpu-qom.h                               |     6 +-
 target/avr/cpu.c                                   |    22 +-
 target/avr/cpu.h                                   |     4 +-
 target/avr/helper.c                                |    75 +-
 target/avr/translate.c                             |    44 +-
 target/cris/cpu-param.h                            |     2 +-
 target/cris/cpu.c                                  |    19 +
 target/cris/helper.c                               |     2 +-
 target/cris/translate.c                            |    18 +-
 target/hexagon/attribs.h                           |     2 +-
 target/hexagon/attribs_def.h.inc                   |    38 +-
 target/hexagon/cpu.c                               |    19 +-
 target/hexagon/decode.c                            |    13 +-
 target/hexagon/gdbstub.c                           |     1 -
 target/hexagon/gen_tcg.h                           |    10 +-
 target/hexagon/gen_tcg_funcs.py                    |    11 +-
 target/hexagon/genptr.c                            |    43 +-
 target/hexagon/helper.h                            |     1 +
 target/hexagon/hex_arch_types.h                    |     4 +-
 target/hexagon/hex_common.py                       |     3 +-
 target/hexagon/hex_regs.h                          |     4 +-
 target/hexagon/imported/encode_pp.def              |    23 -
 target/hexagon/imported/ldst.idef                  |   122 +-
 target/hexagon/imported/subinsns.idef              |    72 +-
 target/hexagon/macros.h                            |    45 +-
 target/hexagon/op_helper.c                         |    32 +-
 target/hexagon/translate.c                         |    54 +-
 target/hppa/cpu-param.h                            |     2 +-
 target/hppa/cpu.c                                  |    39 +-
 target/hppa/cpu.h                                  |     3 +-
 target/hppa/helper.c                               |     6 +-
 target/hppa/op_helper.c                            |     6 +-
 target/hppa/translate.c                            |    35 +-
 target/i386/arch_dump.c                            |    30 +-
 target/i386/cpu-param.h                            |     8 +-
 target/i386/cpu-sysemu.c                           |     2 +-
 target/i386/cpu.c                                  |   455 +-
 target/i386/cpu.h                                  |   165 +-
 target/i386/gdbstub.c                              |     4 +-
 target/i386/hax/hax-accel-ops.h                    |     6 +-
 target/i386/hax/hax-all.c                          |     1 -
 target/i386/hax/hax-mem.c                          |    10 +-
 target/i386/helper.c                               |    39 +-
 target/i386/helper.h                               |    10 +-
 target/i386/hvf/hvf.c                              |    27 +-
 target/i386/hvf/vmcs.h                             |     5 +-
 target/i386/hvf/vmx.h                              |     2 +-
 target/i386/hvf/x86.c                              |     1 -
 target/i386/hvf/x86_cpuid.c                        |     8 +-
 target/i386/hvf/x86_decode.c                       |     1 -
 target/i386/hvf/x86_descr.c                        |     1 -
 target/i386/hvf/x86_emu.c                          |     1 -
 target/i386/hvf/x86_flags.c                        |     1 -
 target/i386/hvf/x86_mmu.c                          |     1 -
 target/i386/hvf/x86_task.c                         |     1 -
 target/i386/hvf/x86hvf.c                           |     1 -
 target/i386/kvm/hyperv-proto.h                     |    46 +-
 target/i386/kvm/hyperv-stub.c                      |     6 +
 target/i386/kvm/hyperv.c                           |    56 +-
 target/i386/kvm/kvm-cpu.c                          |     2 +-
 target/i386/kvm/kvm-stub.c                         |     5 +
 target/i386/kvm/kvm.c                              |   601 +-
 target/i386/kvm/kvm_i386.h                         |    14 +
 target/i386/kvm/sev-stub.c                         |     1 -
 target/i386/machine.c                              |    58 +
 target/i386/nvmm/nvmm-accel-ops.h                  |     6 +-
 target/i386/nvmm/nvmm-all.c                        |     9 +-
 target/i386/ops_sse.h                              |  2444 +-
 target/i386/ops_sse_header.h                       |   410 +-
 target/i386/sev.c                                  |    42 +-
 target/i386/sev.h                                  |     4 +-
 target/i386/tcg/bpt_helper.c                       |     2 +-
 target/i386/tcg/cc_helper.c                        |    41 -
 target/i386/tcg/decode-new.c.inc                   |  1844 ++
 target/i386/tcg/decode-new.h                       |   252 +
 target/i386/tcg/emit.c.inc                         |  2300 ++
 target/i386/tcg/excp_helper.c                      |    44 +-
 target/i386/tcg/fpu_helper.c                       |   216 +-
 target/i386/tcg/helper-tcg.h                       |    52 +-
 target/i386/tcg/misc_helper.c                      |     6 +-
 target/i386/tcg/seg_helper.c                       |     6 +-
 target/i386/tcg/sysemu/excp_helper.c               |   720 +-
 target/i386/tcg/sysemu/misc_helper.c               |    12 +-
 target/i386/tcg/sysemu/svm_helper.c                |   236 +-
 target/i386/tcg/tcg-cpu.c                          |    25 +-
 target/i386/tcg/translate.c                        |  3087 +--
 target/i386/tcg/user/excp_helper.c                 |     7 +
 target/i386/whpx/whpx-accel-ops.c                  |     1 +
 target/i386/whpx/whpx-accel-ops.h                  |     7 +-
 target/i386/whpx/whpx-all.c                        |   876 +-
 target/i386/whpx/whpx-apic.c                       |     1 -
 target/i386/whpx/whpx-internal.h                   |    39 +-
 target/loongarch/Kconfig                           |     2 +
 target/loongarch/README                            |    52 +
 target/loongarch/constant_timer.c                  |    64 +
 target/loongarch/cpu-csr.h                         |   208 +
 target/loongarch/cpu-param.h                       |    18 +
 target/loongarch/cpu.c                             |   774 +
 target/loongarch/cpu.h                             |   423 +
 target/loongarch/csr_helper.c                      |    89 +
 target/loongarch/disas.c                           |   757 +
 target/loongarch/fpu_helper.c                      |   879 +
 target/loongarch/gdbstub.c                         |   104 +
 target/loongarch/helper.h                          |   132 +
 target/loongarch/insn_trans/trans_arith.c.inc      |   304 +
 target/loongarch/insn_trans/trans_atomic.c.inc     |   113 +
 target/loongarch/insn_trans/trans_bit.c.inc        |   220 +
 target/loongarch/insn_trans/trans_branch.c.inc     |    83 +
 target/loongarch/insn_trans/trans_extra.c.inc      |   101 +
 target/loongarch/insn_trans/trans_farith.c.inc     |   135 +
 target/loongarch/insn_trans/trans_fcmp.c.inc       |    63 +
 target/loongarch/insn_trans/trans_fcnv.c.inc       |    33 +
 target/loongarch/insn_trans/trans_fmemory.c.inc    |   175 +
 target/loongarch/insn_trans/trans_fmov.c.inc       |   181 +
 target/loongarch/insn_trans/trans_memory.c.inc     |   229 +
 target/loongarch/insn_trans/trans_privileged.c.inc |   502 +
 target/loongarch/insn_trans/trans_shift.c.inc      |   106 +
 target/loongarch/insns.decode                      |   486 +
 target/loongarch/internals.h                       |    61 +
 target/loongarch/iocsr_helper.c                    |    70 +
 target/loongarch/machine.c                         |   102 +
 target/loongarch/meson.build                       |    30 +
 target/loongarch/op_helper.c                       |   139 +
 target/loongarch/tlb_helper.c                      |   764 +
 target/loongarch/translate.c                       |   279 +
 target/loongarch/translate.h                       |    46 +
 target/m68k/cpu-param.h                            |     2 +-
 target/m68k/cpu.c                                  |    40 +-
 target/m68k/cpu.h                                  |    22 +-
 target/m68k/helper.c                               |     2 +-
 target/m68k/helper.h                               |    14 +-
 target/m68k/m68k-semi.c                            |   407 +-
 target/m68k/meson.build                            |     6 +-
 target/m68k/op_helper.c                            |   180 +-
 target/m68k/qregs.def                              |    10 -
 target/m68k/qregs.h.inc                            |    10 +
 target/m68k/translate.c                            |   410 +-
 target/meson.build                                 |     1 +
 target/microblaze/cpu-param.h                      |     2 +-
 target/microblaze/cpu.c                            |    21 +-
 target/microblaze/cpu.h                            |     8 +-
 target/microblaze/helper.c                         |     2 +-
 target/microblaze/translate.c                      |    19 +-
 target/mips/TODO                                   |    51 -
 target/mips/cpu-defs.c.inc                         |    28 +
 target/mips/cpu-param.h                            |     2 +-
 target/mips/cpu.c                                  |    21 +-
 target/mips/cpu.h                                  |     8 +-
 target/mips/kvm.c                                  |     5 +-
 target/mips/mips-defs.h                            |     1 +
 target/mips/tcg/exception.c                        |     3 +-
 target/mips/tcg/lmmi_helper.c                      |     2 +-
 target/mips/tcg/meson.build                        |     2 +
 target/mips/tcg/micromips_translate.c.inc          |    12 +-
 target/mips/tcg/mips16e_translate.c.inc            |     4 +-
 target/mips/tcg/msa_helper.c                       |    66 +-
 target/mips/tcg/msa_translate.c                    |    29 +-
 target/mips/tcg/nanomips_translate.c.inc           |    41 +-
 target/mips/tcg/octeon.decode                      |    41 +
 target/mips/tcg/octeon_translate.c                 |   201 +
 target/mips/tcg/sysemu/cp0_helper.c                |     3 +-
 target/mips/tcg/sysemu/mips-semi.c                 |   457 +-
 target/mips/tcg/sysemu/special_helper.c            |     2 +-
 target/mips/tcg/sysemu/tlb_helper.c                |     5 +
 target/mips/tcg/sysemu_helper.h.inc                |     2 -
 target/mips/tcg/tcg-internal.h                     |    22 +-
 target/mips/tcg/translate.c                        |    71 +-
 target/mips/tcg/translate.h                        |     5 +
 target/nios2/cpu-param.h                           |     2 +-
 target/nios2/cpu.c                                 |   234 +-
 target/nios2/cpu.h                                 |   258 +-
 target/nios2/helper.c                              |   363 +-
 target/nios2/helper.h                              |     5 +
 target/nios2/meson.build                           |     9 +-
 target/nios2/mmu.c                                 |    78 +-
 target/nios2/nios2-semi.c                          |   397 +-
 target/nios2/op_helper.c                           |    88 +
 target/nios2/translate.c                           |   770 +-
 target/openrisc/cpu-param.h                        |     2 +-
 target/openrisc/cpu.c                              |    33 +-
 target/openrisc/cpu.h                              |     3 +
 target/openrisc/exception.c                        |     2 +-
 target/openrisc/exception.h                        |     2 +-
 target/openrisc/exception_helper.c                 |     3 +-
 target/openrisc/interrupt.c                        |     4 +-
 target/openrisc/mmu.c                              |     8 +-
 target/openrisc/sys_helper.c                       |    31 +-
 target/openrisc/translate.c                        |    23 +-
 target/ppc/arch_dump.c                             |    20 +-
 target/ppc/cpu-models.c                            |    17 +-
 target/ppc/cpu-models.h                            |    14 +-
 target/ppc/cpu-param.h                             |     2 +-
 target/ppc/cpu-qom.h                               |     6 +-
 target/ppc/cpu.c                                   |     8 +-
 target/ppc/cpu.h                                   |   409 +-
 target/ppc/cpu_init.c                              |   382 +-
 target/ppc/dfp_helper.c                            |    96 +-
 target/ppc/excp_helper.c                           |  1011 +-
 target/ppc/fpu_helper.c                            |   839 +-
 target/ppc/gdbstub.c                               |     6 +-
 target/ppc/helper.h                                |   310 +-
 target/ppc/helper_regs.c                           |    25 +-
 target/ppc/insn32.decode                           |   291 +-
 target/ppc/insn64.decode                           |    79 +
 target/ppc/int_helper.c                            |   624 +-
 target/ppc/internal.h                              |    27 +-
 target/ppc/kvm.c                                   |    35 +-
 target/ppc/machine.c                               |     7 +-
 target/ppc/mem_helper.c                            |    27 +-
 target/ppc/misc_helper.c                           |    13 +-
 target/ppc/mmu-book3s-v3.c                         |     5 +
 target/ppc/mmu-book3s-v3.h                         |    15 +
 target/ppc/mmu-hash64.c                            |    41 +-
 target/ppc/mmu-radix64.c                           |   120 +-
 target/ppc/mmu_common.c                            |    40 +-
 target/ppc/mmu_helper.c                            |   160 +-
 target/ppc/monitor.c                               |     9 +
 target/ppc/power8-pmu-regs.c.inc                   |    10 +-
 target/ppc/power8-pmu.c                            |    74 +-
 target/ppc/power8-pmu.h                            |     7 +-
 target/ppc/timebase_helper.c                       |     6 +-
 target/ppc/trace-events                            |     2 +-
 target/ppc/translate.c                             |   775 +-
 target/ppc/translate/fixedpoint-impl.c.inc         |    92 +-
 target/ppc/translate/fp-impl.c.inc                 |   279 +-
 target/ppc/translate/fp-ops.c.inc                  |    12 -
 target/ppc/translate/processor-ctrl-impl.c.inc     |   105 +
 target/ppc/translate/storage-ctrl-impl.c.inc       |   250 +
 target/ppc/translate/vmx-impl.c.inc                |   585 +-
 target/ppc/translate/vmx-ops.c.inc                 |    28 +-
 target/ppc/translate/vsx-impl.c.inc                |   637 +-
 target/ppc/translate/vsx-ops.c.inc                 |    25 -
 target/riscv/arch_dump.c                           |     6 +-
 target/riscv/bitmanip_helper.c                     |    80 +
 target/riscv/common-semi-target.h                  |    50 +
 target/riscv/cpu-param.h                           |     2 +-
 target/riscv/cpu.c                                 |   444 +-
 target/riscv/cpu.h                                 |   164 +-
 target/riscv/cpu_bits.h                            |   145 +-
 target/riscv/cpu_helper.c                          |   454 +-
 target/riscv/crypto_helper.c                       |   302 +
 target/riscv/csr.c                                 |  1840 +-
 target/riscv/debug.c                               |   731 +
 target/riscv/debug.h                               |   137 +
 target/riscv/gdbstub.c                             |    36 +-
 target/riscv/helper.h                              |    42 +-
 target/riscv/insn16.decode                         |     7 +-
 target/riscv/insn32.decode                         |   110 +-
 target/riscv/insn_trans/trans_privileged.c.inc     |     7 +-
 target/riscv/insn_trans/trans_rvb.c.inc            |   116 +-
 target/riscv/insn_trans/trans_rvh.c.inc            |     2 +
 target/riscv/insn_trans/trans_rvi.c.inc            |    26 +-
 target/riscv/insn_trans/trans_rvk.c.inc            |   391 +
 target/riscv/insn_trans/trans_rvm.c.inc            |    18 +-
 target/riscv/insn_trans/trans_rvv.c.inc            |   227 +-
 target/riscv/instmap.h                             |    45 +
 target/riscv/internals.h                           |     7 +-
 target/riscv/kvm.c                                 |     5 +-
 target/riscv/machine.c                             |    80 +-
 target/riscv/meson.build                           |    10 +-
 target/riscv/monitor.c                             |    11 +-
 target/riscv/op_helper.c                           |    13 +-
 target/riscv/pmp.c                                 |    29 +-
 target/riscv/pmp.h                                 |     8 +-
 target/riscv/pmu.c                                 |   453 +
 target/riscv/pmu.h                                 |    36 +
 target/riscv/sbi_ecall_interface.h                 |     4 +-
 target/riscv/time_helper.c                         |   114 +
 target/riscv/time_helper.h                         |    30 +
 target/riscv/translate.c                           |   105 +-
 target/riscv/vector_helper.c                       |  1822 +-
 target/rx/cpu.c                                    |    21 +-
 target/rx/cpu.h                                    |     2 +
 target/rx/gdbstub.c                                |     1 -
 target/rx/op_helper.c                              |    27 +-
 target/rx/translate.c                              |    87 +-
 target/s390x/arch_dump.c                           |   270 +-
 target/s390x/cpu-param.h                           |     2 +-
 target/s390x/cpu.c                                 |    10 +-
 target/s390x/cpu.h                                 |     1 +
 target/s390x/cpu_features_def.h.inc                |     3 +-
 target/s390x/cpu_models.c                          |    49 +-
 target/s390x/cpu_models.h                          |     4 +-
 target/s390x/cpu_models_sysemu.c                   |     1 -
 target/s390x/gen-features.c                        |    28 +-
 target/s390x/helper.c                              |     1 -
 target/s390x/helper.h                              |    13 +
 target/s390x/ioinst.c                              |     4 +-
 target/s390x/kvm/kvm.c                             |    30 +-
 target/s390x/kvm/kvm_s390x.h                       |     2 +
 target/s390x/kvm/meson.build                       |     2 +
 target/s390x/kvm/stubs.c                           |    12 +
 target/s390x/s390x-internal.h                      |    12 +-
 target/s390x/tcg/cc_helper.c                       |     7 +
 target/s390x/tcg/crypto_helper.c                   |   259 +
 target/s390x/tcg/excp_helper.c                     |    26 +-
 target/s390x/tcg/fpu_helper.c                      |     2 +-
 target/s390x/tcg/insn-data.def                     |  1422 --
 target/s390x/tcg/insn-data.h.inc                   |  1448 ++
 target/s390x/tcg/insn-format.def                   |    81 -
 target/s390x/tcg/insn-format.h.inc                 |    81 +
 target/s390x/tcg/mem_helper.c                      |     4 -
 target/s390x/tcg/misc_helper.c                     |     9 +-
 target/s390x/tcg/tcg_s390x.h                       |    12 +-
 target/s390x/tcg/translate.c                       |   115 +-
 target/s390x/tcg/translate_vx.c.inc                |   471 +-
 target/s390x/tcg/vec.h                             |     2 +-
 target/s390x/tcg/vec_fpu_helper.c                  |    36 +-
 target/s390x/tcg/vec_helper.c                      |     2 -
 target/s390x/tcg/vec_int_helper.c                  |    56 +-
 target/s390x/tcg/vec_string_helper.c               |   100 +-
 target/sh4/cpu-param.h                             |     2 +-
 target/sh4/cpu.c                                   |    34 +-
 target/sh4/cpu.h                                   |    65 +-
 target/sh4/helper.c                                |     6 +-
 target/sh4/op_helper.c                             |     5 +-
 target/sh4/translate.c                             |   112 +-
 target/sparc/cpu-param.h                           |     2 +-
 target/sparc/cpu.c                                 |    11 +-
 target/sparc/cpu.h                                 |    14 +-
 target/sparc/mmu_helper.c                          |     8 +-
 target/sparc/translate.c                           |    19 +-
 target/sparc/vis_helper.c                          |     4 +-
 target/tricore/cpu-param.h                         |     2 +-
 target/tricore/cpu.c                               |    22 +-
 target/tricore/cpu.h                               |     1 +
 target/tricore/csfr.def                            |   125 -
 target/tricore/csfr.h.inc                          |   125 +
 target/tricore/gdbstub.c                           |     1 -
 target/tricore/op_helper.c                         |     8 +-
 target/tricore/translate.c                         |    23 +-
 target/xtensa/core-de233_fpu.c                     |     1 -
 target/xtensa/core-de233_fpu/core-isa.h            |     7 +-
 target/xtensa/core-de233_fpu/core-matmap.h         |     4 +-
 target/xtensa/core-dsp3400.c                       |     1 -
 target/xtensa/core-dsp3400/core-isa.h              |     8 +-
 target/xtensa/core-dsp3400/core-matmap.h           |     4 +-
 target/xtensa/core-lx106.c                         |    51 +
 target/xtensa/core-lx106/core-isa.h                |   470 +
 target/xtensa/core-lx106/gdb-config.c.inc          |    83 +
 target/xtensa/core-lx106/xtensa-modules.c.inc      |  7668 +++++++
 target/xtensa/core-test_mmuhifi_c3.c               |     1 -
 target/xtensa/cores.list                           |     1 +
 target/xtensa/cpu-param.h                          |     2 +-
 target/xtensa/cpu.c                                |    33 +
 target/xtensa/cpu.h                                |    16 +-
 target/xtensa/helper.c                             |     6 +-
 target/xtensa/import_core.sh                       |     1 -
 target/xtensa/op_helper.c                          |     7 +-
 target/xtensa/overlay_tool.h                       |     2 +-
 target/xtensa/translate.c                          |   243 +-
 tcg/aarch64/tcg-target.c.inc                       |    37 +-
 tcg/arm/tcg-target.c.inc                           |     4 +-
 tcg/i386/tcg-target.c.inc                          |     4 +-
 tcg/loongarch64/tcg-target.c.inc                   |    48 +-
 tcg/loongarch64/tcg-target.h                       |     9 +-
 tcg/mips/tcg-target.c.inc                          |     2 +-
 tcg/ppc/tcg-target.c.inc                           |   161 +-
 tcg/ppc/tcg-target.h                               |     4 +-
 tcg/region.c                                       |    10 +-
 tcg/riscv/tcg-target.c.inc                         |     4 +-
 tcg/sparc/tcg-target-con-set.h                     |    32 -
 tcg/sparc/tcg-target-con-str.h                     |    23 -
 tcg/sparc/tcg-target.c.inc                         |  2069 --
 tcg/sparc/tcg-target.h                             |   172 -
 tcg/sparc64/tcg-target-con-set.h                   |    22 +
 tcg/sparc64/tcg-target-con-str.h                   |    20 +
 tcg/sparc64/tcg-target.c.inc                       |  1938 ++
 tcg/sparc64/tcg-target.h                           |   161 +
 tcg/tcg-internal.h                                 |     2 +-
 tcg/tcg-op.c                                       |    34 +-
 tcg/tcg.c                                          |   341 +-
 tcg/tci.c                                          |     1 -
 tcg/tci/tcg-target.c.inc                           |     7 -
 tcg/tci/tcg-target.h                               |     5 -
 tests/Makefile.include                             |   117 +-
 tests/avocado/acpi-bits.py                         |   398 +
 tests/avocado/acpi-bits/bits-config/bits-cfg.txt   |    18 +
 tests/avocado/acpi-bits/bits-tests/smbios.py2      |  2430 ++
 tests/avocado/acpi-bits/bits-tests/testacpi.py2    |   283 +
 tests/avocado/acpi-bits/bits-tests/testcpuid.py2   |    83 +
 tests/avocado/avocado_qemu/__init__.py             |    48 +-
 tests/avocado/boot_linux.py                        |    15 +-
 tests/avocado/boot_linux_console.py                |    93 +-
 tests/avocado/info_usernet.py                      |     4 +
 tests/avocado/machine_aarch64_virt.py              |    95 +
 tests/avocado/machine_arm_canona1100.py            |     4 +-
 tests/avocado/machine_aspeed.py                    |   272 +
 tests/avocado/machine_microblaze.py                |     4 +-
 tests/avocado/machine_s390_ccw_virtio.py           |     1 +
 tests/avocado/machine_sparc64_sun4u.py             |     4 +-
 tests/avocado/migration.py                         |     4 +-
 tests/avocado/ppc_bamboo.py                        |     1 +
 tests/avocado/ppc_mpc8544ds.py                     |     6 +-
 tests/avocado/ppc_virtex_ml507.py                  |     6 +-
 tests/avocado/replay_kernel.py                     |    40 +-
 tests/avocado/replay_linux.py                      |    87 +-
 tests/avocado/virtio_check_params.py               |     1 -
 tests/avocado/virtio_version.py                    |     1 -
 tests/avocado/vnc.py                               |    64 +
 tests/bench/benchmark-crypto-akcipher.c            |   137 +
 tests/bench/meson.build                            |     1 +
 tests/bench/test_akcipher_keys.inc                 |   537 +
 tests/check-block.sh                               |    26 -
 tests/data/acpi/pc/DSDT                            |   Bin 6002 -> 6458 bytes
 tests/data/acpi/pc/DSDT.acpierst                   |   Bin 5969 -> 6418 bytes
 tests/data/acpi/pc/DSDT.acpihmat                   |   Bin 7327 -> 7783 bytes
 tests/data/acpi/pc/DSDT.bridge                     |   Bin 8668 -> 9532 bytes
 tests/data/acpi/pc/DSDT.cphp                       |   Bin 6466 -> 6922 bytes
 tests/data/acpi/pc/DSDT.dimmpxm                    |   Bin 7656 -> 8112 bytes
 tests/data/acpi/pc/DSDT.hpbridge                   |   Bin 5969 -> 6418 bytes
 tests/data/acpi/pc/DSDT.hpbrroot                   |   Bin 3084 -> 3064 bytes
 tests/data/acpi/pc/DSDT.ipmikcs                    |   Bin 6074 -> 6530 bytes
 tests/data/acpi/pc/DSDT.memhp                      |   Bin 7361 -> 7817 bytes
 tests/data/acpi/pc/DSDT.nohpet                     |   Bin 5860 -> 6316 bytes
 tests/data/acpi/pc/DSDT.numamem                    |   Bin 6008 -> 6464 bytes
 tests/data/acpi/pc/DSDT.roothp                     |   Bin 6210 -> 6656 bytes
 tests/data/acpi/pc/SSDT.dimmpxm                    |   Bin 734 -> 1815 bytes
 tests/data/acpi/q35/APIC.acpihmat-noinitiator      |   Bin 0 -> 144 bytes
 tests/data/acpi/q35/APIC.core-count2               |   Bin 0 -> 2478 bytes
 tests/data/acpi/q35/CEDT.cxl                       |   Bin 0 -> 184 bytes
 tests/data/acpi/q35/DSDT                           |   Bin 8289 -> 8310 bytes
 tests/data/acpi/q35/DSDT.acpierst                  |   Bin 8306 -> 8327 bytes
 tests/data/acpi/q35/DSDT.acpihmat                  |   Bin 9614 -> 9635 bytes
 tests/data/acpi/q35/DSDT.acpihmat-noinitiator      |   Bin 0 -> 8589 bytes
 tests/data/acpi/q35/DSDT.applesmc                  |   Bin 0 -> 8356 bytes
 tests/data/acpi/q35/DSDT.bridge                    |   Bin 11003 -> 11439 bytes
 tests/data/acpi/q35/DSDT.core-count2               |   Bin 0 -> 32450 bytes
 tests/data/acpi/q35/DSDT.cphp                      |   Bin 8753 -> 8774 bytes
 tests/data/acpi/q35/DSDT.cxl                       |   Bin 0 -> 9636 bytes
 tests/data/acpi/q35/DSDT.dimmpxm                   |   Bin 9943 -> 9964 bytes
 tests/data/acpi/q35/DSDT.ipmibt                    |   Bin 8364 -> 8385 bytes
 tests/data/acpi/q35/DSDT.ipmismbus                 |   Bin 0 -> 8398 bytes
 tests/data/acpi/q35/DSDT.ivrs                      |   Bin 8306 -> 8327 bytes
 tests/data/acpi/q35/DSDT.memhp                     |   Bin 9648 -> 9669 bytes
 tests/data/acpi/q35/DSDT.mmio64                    |   Bin 9419 -> 9440 bytes
 tests/data/acpi/q35/DSDT.multi-bridge              |   Bin 8583 -> 8630 bytes
 tests/data/acpi/q35/DSDT.nohpet                    |   Bin 8147 -> 8168 bytes
 tests/data/acpi/q35/DSDT.numamem                   |   Bin 8295 -> 8316 bytes
 tests/data/acpi/q35/DSDT.pvpanic-isa               |   Bin 0 -> 8411 bytes
 tests/data/acpi/q35/DSDT.tis.tpm12                 |   Bin 8900 -> 8916 bytes
 tests/data/acpi/q35/DSDT.tis.tpm2                  |   Bin 8921 -> 8942 bytes
 tests/data/acpi/q35/DSDT.viot                      |   Bin 9398 -> 9419 bytes
 tests/data/acpi/q35/DSDT.xapic                     |   Bin 35652 -> 35673 bytes
 tests/data/acpi/q35/FACP.core-count2               |   Bin 0 -> 244 bytes
 tests/data/acpi/q35/HMAT.acpihmat-noinitiator      |   Bin 0 -> 288 bytes
 tests/data/acpi/q35/SRAT.acpihmat-noinitiator      |   Bin 0 -> 312 bytes
 tests/data/acpi/q35/SSDT.dimmpxm                   |   Bin 734 -> 1815 bytes
 tests/data/acpi/q35/VIOT.viot                      |   Bin 112 -> 112 bytes
 tests/data/acpi/virt/APIC                          |   Bin 168 -> 172 bytes
 tests/data/acpi/virt/APIC.acpihmatvirt             |   Bin 0 -> 412 bytes
 tests/data/acpi/virt/APIC.memhp                    |   Bin 168 -> 172 bytes
 tests/data/acpi/virt/APIC.numamem                  |   Bin 168 -> 172 bytes
 tests/data/acpi/virt/DSDT.acpihmatvirt             |   Bin 0 -> 5282 bytes
 tests/data/acpi/virt/FACP                          |   Bin 268 -> 276 bytes
 tests/data/acpi/virt/FACP.memhp                    |   Bin 268 -> 276 bytes
 tests/data/acpi/virt/FACP.numamem                  |   Bin 268 -> 276 bytes
 tests/data/acpi/virt/GTDT                          |   Bin 96 -> 96 bytes
 tests/data/acpi/virt/GTDT.memhp                    |   Bin 96 -> 96 bytes
 tests/data/acpi/virt/GTDT.numamem                  |   Bin 96 -> 96 bytes
 tests/data/acpi/virt/HMAT.acpihmatvirt             |   Bin 0 -> 288 bytes
 tests/data/acpi/virt/PPTT.acpihmatvirt             |   Bin 0 -> 196 bytes
 tests/data/acpi/virt/SRAT.acpihmatvirt             |   Bin 0 -> 240 bytes
 tests/data/acpi/virt/SSDT.memhp                    |   Bin 736 -> 1817 bytes
 tests/data/test-qga-config                         |     2 +-
 tests/docker/Makefile.include                      |   150 +-
 tests/docker/common.rc                             |     6 +-
 tests/docker/docker.py                             |    95 +-
 tests/docker/dockerfiles/alpine.docker             |    14 +-
 tests/docker/dockerfiles/centos8.docker            |    11 +-
 .../dockerfiles/debian-all-test-cross.docker       |    20 +-
 tests/docker/dockerfiles/debian-alpha-cross.docker |    12 +-
 tests/docker/dockerfiles/debian-amd64-cross.docker |   182 +-
 tests/docker/dockerfiles/debian-amd64.docker       |   199 +-
 tests/docker/dockerfiles/debian-arm64-cross.docker |   229 +-
 tests/docker/dockerfiles/debian-armel-cross.docker |   184 +-
 tests/docker/dockerfiles/debian-armhf-cross.docker |   190 +-
 .../debian-hexagon-cross.d/build-toolchain.sh      |   141 +
 .../docker/dockerfiles/debian-hexagon-cross.docker |    21 +-
 .../build-toolchain.sh                             |   141 -
 tests/docker/dockerfiles/debian-hppa-cross.docker  |    12 +-
 .../dockerfiles/debian-loongarch-cross.docker      |    27 +
 tests/docker/dockerfiles/debian-m68k-cross.docker  |    12 +-
 tests/docker/dockerfiles/debian-mips-cross.docker  |    38 +-
 .../docker/dockerfiles/debian-mips64-cross.docker  |    12 +-
 .../dockerfiles/debian-mips64el-cross.docker       |   183 +-
 .../docker/dockerfiles/debian-mipsel-cross.docker  |   185 +-
 tests/docker/dockerfiles/debian-native.docker      |     2 +-
 .../dockerfiles/debian-powerpc-test-cross.docker   |    12 +-
 .../docker/dockerfiles/debian-ppc64el-cross.docker |   184 +-
 .../docker/dockerfiles/debian-riscv64-cross.docker |     3 +
 .../dockerfiles/debian-riscv64-test-cross.docker   |    10 +-
 tests/docker/dockerfiles/debian-s390x-cross.docker |   225 +-
 tests/docker/dockerfiles/debian-sh4-cross.docker   |    12 +-
 .../docker/dockerfiles/debian-sparc64-cross.docker |    12 +-
 tests/docker/dockerfiles/debian-toolchain.docker   |     5 +-
 .../docker/dockerfiles/debian-tricore-cross.docker |     1 -
 tests/docker/dockerfiles/debian10.docker           |    37 -
 tests/docker/dockerfiles/debian11.docker           |    18 -
 tests/docker/dockerfiles/empty.docker              |     8 -
 tests/docker/dockerfiles/fedora-i386-cross.docker  |     3 +-
 tests/docker/dockerfiles/fedora-win32-cross.docker |   139 +-
 tests/docker/dockerfiles/fedora-win64-cross.docker |   138 +-
 tests/docker/dockerfiles/fedora.docker             |   228 +-
 tests/docker/dockerfiles/opensuse-leap.docker      |    16 +-
 tests/docker/dockerfiles/ubuntu1804.docker         |   145 -
 tests/docker/dockerfiles/ubuntu2004.docker         |   234 +-
 tests/docker/run                                   |     2 +-
 tests/docker/test-mingw                            |    16 +-
 tests/fp/fp-bench.c                                |     3 +-
 tests/fp/fp-test.c                                 |     3 +-
 tests/fp/meson.build                               |     5 +-
 tests/fp/platform.h                                |     4 +-
 tests/guest-debug/run-test.py                      |    11 +-
 tests/lcitool/libvirt-ci                           |     2 +-
 tests/lcitool/projects/qemu.yml                    |    11 +-
 tests/lcitool/refresh                              |   204 +-
 tests/meson.build                                  |     4 +-
 tests/migration/aarch64/a-b-kernel.S               |     3 +-
 tests/migration/aarch64/a-b-kernel.h               |    10 +-
 tests/migration/guestperf/engine.py                |     1 -
 tests/migration/i386/a-b-bootblock.S               |     1 +
 tests/migration/i386/a-b-bootblock.h               |    12 +-
 tests/migration/stress.c                           |     2 +-
 tests/qapi-schema/alternate-array.err              |     2 -
 tests/qapi-schema/alternate-array.json             |     2 -
 tests/qapi-schema/alternate-array.out              |    18 +
 tests/qapi-schema/alternate-conflict-lists.err     |     2 +
 tests/qapi-schema/alternate-conflict-lists.json    |     6 +
 tests/qapi-schema/alternate-conflict-lists.out     |     0
 tests/qapi-schema/meson.build                      |    25 +-
 tests/qapi-schema/qapi-schema-test.json            |     1 +
 tests/qapi-schema/qapi-schema-test.out             |     4 +
 tests/qemu-iotests/030                             |    85 +-
 tests/qemu-iotests/040                             |    53 +-
 tests/qemu-iotests/051                             |     3 +-
 tests/qemu-iotests/051.out                         |     2 +-
 tests/qemu-iotests/051.pc.out                      |     2 +-
 tests/qemu-iotests/056                             |     2 +-
 tests/qemu-iotests/065                             |    24 +-
 tests/qemu-iotests/108                             |   264 +-
 tests/qemu-iotests/108.out                         |    81 +
 tests/qemu-iotests/131                             |    35 +-
 tests/qemu-iotests/131.out                         |    13 +
 tests/qemu-iotests/149                             |     6 +-
 tests/qemu-iotests/151                             |   227 +-
 tests/qemu-iotests/151.out                         |     4 +-
 tests/qemu-iotests/163                             |     5 +-
 tests/qemu-iotests/172.out                         |    76 +
 tests/qemu-iotests/205                             |     4 +-
 tests/qemu-iotests/216                             |    12 +-
 tests/qemu-iotests/218                             |     5 +-
 tests/qemu-iotests/223                             |    16 +
 tests/qemu-iotests/223.out                         |    51 +-
 tests/qemu-iotests/224                             |     4 +-
 tests/qemu-iotests/227.out                         |     4 +-
 tests/qemu-iotests/242                             |     6 +-
 tests/qemu-iotests/245                             |    17 +-
 tests/qemu-iotests/255                             |     4 +-
 tests/qemu-iotests/258                             |    11 +-
 tests/qemu-iotests/264                             |     2 +-
 tests/qemu-iotests/298                             |    17 +-
 tests/qemu-iotests/303                             |     6 +-
 tests/qemu-iotests/307.out                         |     4 +-
 tests/qemu-iotests/310                             |    22 +-
 tests/qemu-iotests/common.config                   |    41 -
 tests/qemu-iotests/common.rc                       |    35 +-
 tests/qemu-iotests/iotests.py                      |    92 +-
 tests/qemu-iotests/meson.build                     |    73 +-
 tests/qemu-iotests/mypy.ini                        |     2 +-
 tests/qemu-iotests/pylintrc                        |     5 +
 tests/qemu-iotests/testrunner.py                   |     4 +
 tests/qemu-iotests/tests/backing-file-invalidation |   152 +
 .../tests/backing-file-invalidation.out            |     5 +
 tests/qemu-iotests/tests/copy-before-write         |   222 +
 tests/qemu-iotests/tests/copy-before-write.out     |     5 +
 tests/qemu-iotests/tests/export-incoming-iothread  |    81 +
 .../tests/export-incoming-iothread.out             |     5 +
 tests/qemu-iotests/tests/image-fleecing            |    30 +-
 tests/qemu-iotests/tests/migration-permissions     |    28 +-
 tests/qemu-iotests/tests/mirror-ready-cancel-error |     2 +-
 tests/qemu-iotests/tests/mirror-top-perms          |    11 +-
 tests/qemu-iotests/tests/nbd-multiconn             |   145 +
 tests/qemu-iotests/tests/nbd-multiconn.out         |     5 +
 tests/qemu-iotests/tests/nbd-qemu-allocation.out   |     2 +-
 tests/qemu-iotests/tests/nbd-reconnect-on-open     |     2 +-
 tests/qemu-iotests/tests/reopen-file               |    89 +
 tests/qemu-iotests/tests/reopen-file.out           |     5 +
 tests/qemu-iotests/tests/stream-error-on-reset     |     4 +-
 tests/qemu-iotests/tests/stream-under-throttle     |   121 +
 tests/qemu-iotests/tests/stream-under-throttle.out |     5 +
 tests/qtest/ac97-test.c                            |     4 +-
 tests/qtest/acpi-utils.c                           |     1 -
 tests/qtest/acpi-utils.h                           |     2 +-
 tests/qtest/ahci-test.c                            |    39 +-
 tests/qtest/am53c974-test.c                        |     2 +-
 tests/qtest/arm-cpu-features.c                     |     2 +-
 tests/qtest/aspeed_gpio-test.c                     |    90 +
 tests/qtest/aspeed_hace-test.c                     |   150 +-
 tests/qtest/aspeed_smc-test.c                      |   293 +-
 tests/qtest/bcm2835-dma-test.c                     |   118 +
 tests/qtest/bios-tables-test.c                     |   521 +-
 tests/qtest/boot-order-test.c                      |     2 +-
 tests/qtest/boot-sector.c                          |     3 +-
 tests/qtest/boot-sector.h                          |     2 +-
 tests/qtest/boot-serial-test.c                     |    13 +-
 tests/qtest/cdrom-test.c                           |     4 +-
 tests/qtest/cpu-plug-test.c                        |     1 -
 tests/qtest/cxl-test.c                             |   155 +
 tests/qtest/dbus-display-test.c                    |     5 +-
 tests/qtest/dbus-vmstate-test.c                    |     5 +-
 tests/qtest/device-introspect-test.c               |     3 +-
 tests/qtest/device-plug-test.c                     |   100 +-
 tests/qtest/drive_del-test.c                       |   127 +-
 tests/qtest/ds1338-test.c                          |     2 +-
 tests/qtest/e1000-test.c                           |     4 +-
 tests/qtest/e1000e-test.c                          |    76 +-
 tests/qtest/eepro100-test.c                        |     2 +-
 tests/qtest/endianness-test.c                      |     3 +-
 tests/qtest/erst-test.c                            |     3 +-
 tests/qtest/es1370-test.c                          |     4 +-
 tests/qtest/fdc-test.c                             |    29 +-
 tests/qtest/fuzz-e1000e-test.c                     |     2 +-
 tests/qtest/fuzz-lsi53c895a-test.c                 |    86 +-
 tests/qtest/fuzz-megasas-test.c                    |    16 +-
 tests/qtest/fuzz-sb16-test.c                       |    18 +-
 tests/qtest/fuzz-sdcard-test.c                     |    20 +-
 tests/qtest/fuzz-virtio-scsi-test.c                |    12 +-
 tests/qtest/fuzz-xlnx-dp-test.c                    |     4 +-
 tests/qtest/fuzz/fuzz.c                            |    23 +-
 tests/qtest/fuzz/fuzz.h                            |     7 +-
 tests/qtest/fuzz/generic_fuzz.c                    |    21 +-
 tests/qtest/fuzz/generic_fuzz_configs.h            |     4 +-
 tests/qtest/fuzz/i440fx_fuzz.c                     |     2 +-
 tests/qtest/fuzz/qos_fuzz.c                        |     5 +-
 tests/qtest/fuzz/virtio_blk_fuzz.c                 |     6 +-
 tests/qtest/fuzz/virtio_net_fuzz.c                 |     4 +-
 tests/qtest/fuzz/virtio_scsi_fuzz.c                |     2 +-
 tests/qtest/fw_cfg-test.c                          |     2 +-
 tests/qtest/hd-geo-test.c                          |   298 +-
 tests/qtest/hexloader-test.c                       |     2 +-
 tests/qtest/i440fx-test.c                          |    48 +-
 tests/qtest/ide-test.c                             |    93 +-
 tests/qtest/intel-hda-test.c                       |    13 +-
 tests/qtest/ipmi-bt-test.c                         |     1 -
 tests/qtest/ipoctal232-test.c                      |     2 +-
 tests/qtest/ivshmem-test.c                         |    30 +-
 tests/qtest/libqmp.c                               |   258 +
 tests/qtest/libqmp.h                               |    53 +
 tests/qtest/libqos/aarch64-xlnx-zcu102-machine.c   |     4 +-
 tests/qtest/libqos/ahci.c                          |     3 +-
 tests/qtest/libqos/arm-imx25-pdk-machine.c         |     4 +-
 tests/qtest/libqos/arm-n800-machine.c              |     4 +-
 tests/qtest/libqos/arm-raspi2-machine.c            |     4 +-
 tests/qtest/libqos/arm-sabrelite-machine.c         |     4 +-
 tests/qtest/libqos/arm-smdkc210-machine.c          |     4 +-
 tests/qtest/libqos/arm-virt-machine.c              |    23 +-
 tests/qtest/libqos/arm-xilinx-zynq-a9-machine.c    |     4 +-
 tests/qtest/libqos/e1000e.c                        |   128 +-
 tests/qtest/libqos/fw_cfg.c                        |     2 +-
 tests/qtest/libqos/fw_cfg.h                        |     2 +-
 tests/qtest/libqos/generic-pcihost.c               |   231 +
 tests/qtest/libqos/generic-pcihost.h               |    54 +
 tests/qtest/libqos/i2c-imx.c                       |     2 +-
 tests/qtest/libqos/i2c-omap.c                      |     2 +-
 tests/qtest/libqos/i2c.c                           |     2 +-
 tests/qtest/libqos/i2c.h                           |     2 +-
 tests/qtest/libqos/libqos-malloc.c                 |   346 +
 tests/qtest/libqos/libqos-malloc.h                 |    50 +
 tests/qtest/libqos/libqos.c                        |     4 +-
 tests/qtest/libqos/libqos.h                        |     4 +-
 tests/qtest/libqos/libqtest.h                      |   813 -
 tests/qtest/libqos/malloc-pc.c                     |     2 -
 tests/qtest/libqos/malloc-pc.h                     |     2 +-
 tests/qtest/libqos/malloc-spapr.c                  |     2 -
 tests/qtest/libqos/malloc-spapr.h                  |     2 +-
 tests/qtest/libqos/malloc.c                        |   347 -
 tests/qtest/libqos/malloc.h                        |    50 -
 tests/qtest/libqos/meson.build                     |    14 +-
 tests/qtest/libqos/pci-pc.c                        |    11 +-
 tests/qtest/libqos/pci-pc.h                        |     2 +-
 tests/qtest/libqos/pci-spapr.c                     |     3 +-
 tests/qtest/libqos/pci-spapr.h                     |     2 +-
 tests/qtest/libqos/pci.c                           |    78 +-
 tests/qtest/libqos/pci.h                           |     8 +-
 tests/qtest/libqos/ppc64_pseries-machine.c         |     2 +-
 tests/qtest/libqos/qgraph.c                        |     2 +-
 tests/qtest/libqos/qgraph.h                        |     6 +-
 tests/qtest/libqos/qos_external.c                  |     4 +-
 tests/qtest/libqos/qos_external.h                  |     2 +-
 tests/qtest/libqos/rtas.c                          |     2 +-
 tests/qtest/libqos/rtas.h                          |     2 +-
 tests/qtest/libqos/sdhci-cmd.c                     |     2 +-
 tests/qtest/libqos/sdhci-cmd.h                     |     2 +-
 tests/qtest/libqos/sdhci.c                         |     2 +-
 tests/qtest/libqos/tpci200.c                       |     2 +-
 tests/qtest/libqos/usb.c                           |     2 +-
 tests/qtest/libqos/vhost-user-blk.c                |     2 +-
 tests/qtest/libqos/virtio-9p-client.c              |  1049 +
 tests/qtest/libqos/virtio-9p-client.h              |   494 +
 tests/qtest/libqos/virtio-9p.c                     |     8 +-
 tests/qtest/libqos/virtio-balloon.c                |     2 +-
 tests/qtest/libqos/virtio-blk.c                    |     2 +-
 tests/qtest/libqos/virtio-gpio.c                   |   172 +
 tests/qtest/libqos/virtio-gpio.h                   |    35 +
 tests/qtest/libqos/virtio-iommu.c                  |     2 +-
 tests/qtest/libqos/virtio-mmio.c                   |     4 +-
 tests/qtest/libqos/virtio-net.c                    |     2 +-
 tests/qtest/libqos/virtio-pci.c                    |     4 +-
 tests/qtest/libqos/virtio-rng.c                    |     2 +-
 tests/qtest/libqos/virtio-scsi.c                   |     2 +-
 tests/qtest/libqos/virtio-serial.c                 |     2 +-
 tests/qtest/libqos/virtio.c                        |     8 +-
 tests/qtest/libqos/virtio.h                        |     2 +-
 tests/qtest/libqos/x86_64_pc-machine.c             |     2 +-
 tests/qtest/libqtest-single.h                      |     6 +-
 tests/qtest/libqtest.c                             |   477 +-
 tests/qtest/libqtest.h                             |   835 +
 tests/qtest/lpc-ich9-test.c                        |     2 +-
 tests/qtest/m48t59-test.c                          |     4 +-
 tests/qtest/machine-none-test.c                    |     6 +-
 tests/qtest/megasas-test.c                         |     2 +-
 tests/qtest/meson.build                            |   110 +-
 tests/qtest/microbit-test.c                        |    18 +-
 tests/qtest/migration-helpers.c                    |    51 +
 tests/qtest/migration-helpers.h                    |    14 +-
 tests/qtest/migration-test.c                       |  1727 +-
 tests/qtest/modules-test.c                         |     5 +-
 tests/qtest/ne2000-test.c                          |     2 +-
 tests/qtest/npcm7xx_adc-test.c                     |     4 +-
 tests/qtest/npcm7xx_emc-test.c                     |    12 +-
 tests/qtest/npcm7xx_pwm-test.c                     |     5 +-
 tests/qtest/npcm7xx_rng-test.c                     |     2 +-
 tests/qtest/npcm7xx_sdhci-test.c                   |     4 +-
 tests/qtest/npcm7xx_smbus-test.c                   |     2 +-
 tests/qtest/npcm7xx_watchdog_timer-test.c          |     2 +-
 tests/qtest/numa-test.c                            |    21 +-
 tests/qtest/nvme-test.c                            |     2 +-
 tests/qtest/pca9552-test.c                         |     2 +-
 tests/qtest/pci-test.c                             |     2 +-
 tests/qtest/pcnet-test.c                           |     2 +-
 tests/qtest/pflash-cfi02-test.c                    |    17 +-
 tests/qtest/pnv-xscom-test.c                       |     2 +-
 tests/qtest/prom-env-test.c                        |     6 +-
 tests/qtest/pvpanic-pci-test.c                     |     2 +-
 tests/qtest/pvpanic-test.c                         |     2 +-
 tests/qtest/pxe-test.c                             |     3 +-
 tests/qtest/q35-test.c                             |     2 +-
 tests/qtest/qmp-cmd-test.c                         |     5 +-
 tests/qtest/qmp-test.c                             |    19 +-
 tests/qtest/qom-test.c                             |    25 +-
 tests/qtest/qos-test.c                             |    11 +-
 tests/qtest/readconfig-test.c                      |   195 +
 tests/qtest/rtas-test.c                            |     2 +-
 tests/qtest/rtc-test.c                             |     2 +-
 tests/qtest/rtl8139-test.c                         |     1 -
 tests/qtest/sdhci-test.c                           |     2 +-
 tests/qtest/spapr-phb-test.c                       |     2 +-
 tests/qtest/tco-test.c                             |     2 +-
 tests/qtest/test-filter-mirror.c                   |     3 +-
 tests/qtest/test-filter-redirector.c               |     3 +-
 tests/qtest/test-hmp.c                             |     2 +-
 tests/qtest/test-x86-cpuid-compat.c                |     1 -
 tests/qtest/tpm-crb-swtpm-test.c                   |     7 +-
 tests/qtest/tpm-emu.h                              |     2 +-
 tests/qtest/tpm-tis-device-swtpm-test.c            |     7 +-
 tests/qtest/tpm-tis-swtpm-test.c                   |     7 +-
 tests/qtest/tpm-util.c                             |    21 +-
 tests/qtest/tpm-util.h                             |     1 +
 tests/qtest/tulip-test.c                           |     2 +-
 tests/qtest/vhost-user-blk-test.c                  |    15 +-
 tests/qtest/vhost-user-test.c                      |   196 +-
 tests/qtest/virtio-9p-test.c                       |  1222 +-
 tests/qtest/virtio-blk-test.c                      |    11 +-
 tests/qtest/virtio-net-failover.c                  |    11 +-
 tests/qtest/virtio-net-test.c                      |    19 +-
 tests/qtest/virtio-rng-test.c                      |     7 +-
 tests/qtest/virtio-scsi-test.c                     |     4 +-
 tests/qtest/virtio-test.c                          |     2 +-
 tests/qtest/vmgenid-test.c                         |     2 +-
 tests/qtest/vmxnet3-test.c                         |     2 +-
 tests/qtest/vnc-display-test.c                     |   103 +
 tests/qtest/wdt_ib700-test.c                       |     2 +-
 tests/qtest/xlnx-can-test.c                        |     2 +-
 tests/requirements.txt                             |     1 +
 tests/tcg/Makefile.prereqs                         |    18 -
 tests/tcg/Makefile.qemu                            |   121 -
 tests/tcg/Makefile.target                          |    49 +-
 tests/tcg/aarch64/Makefile.softmmu-target          |    13 +-
 tests/tcg/aarch64/Makefile.target                  |    31 +-
 tests/tcg/aarch64/bti-3.c                          |    42 +
 tests/tcg/aarch64/float_convd.ref                  |   988 +
 tests/tcg/aarch64/system/pauth-3.c                 |     2 +-
 tests/tcg/aarch64/system/semiconsole.c             |     2 +-
 tests/tcg/aarch64/system/semiheap.c                |     2 +-
 tests/tcg/arm/Makefile.softmmu-target              |     2 +-
 tests/tcg/arm/Makefile.target                      |     9 +-
 tests/tcg/arm/float_convd.ref                      |   988 +
 tests/tcg/configure.sh                             |   354 -
 tests/tcg/cris/Makefile.target                     |     2 +-
 tests/tcg/hexagon/Makefile.target                  |     1 +
 tests/tcg/hexagon/float_convd.ref                  |   988 +
 tests/tcg/hexagon/hvx_misc.c                       |    45 +
 tests/tcg/hexagon/load_unpack.c                    |    14 +-
 tests/tcg/hexagon/mem_noshuf.c                     |   122 +-
 tests/tcg/hexagon/mem_noshuf_exception.c           |   146 +
 tests/tcg/hexagon/usr.c                            |    10 +
 tests/tcg/i386/Makefile.softmmu-target             |     3 +-
 tests/tcg/i386/Makefile.target                     |    43 +-
 tests/tcg/i386/README                              |     9 +
 tests/tcg/i386/float_convd.conf                    |   988 +
 tests/tcg/i386/float_convs.ref                     |   748 +
 tests/tcg/i386/test-3dnow.c                        |     3 +
 tests/tcg/i386/test-avx.c                          |   364 +
 tests/tcg/i386/test-avx.py                         |   375 +
 tests/tcg/i386/test-i386-bmi2.c                    |   169 +-
 tests/tcg/i386/test-i386-fp-exceptions.c           |    24 +-
 tests/tcg/i386/test-i386.c                         |   577 +-
 tests/tcg/i386/test-mmx.c                          |   315 +
 tests/tcg/i386/test-mmx.py                         |   244 +
 tests/tcg/i386/x86.csv                             |  4658 ++++
 tests/tcg/loongarch64/Makefile.softmmu-target      |    33 +
 tests/tcg/loongarch64/Makefile.target              |    20 +
 tests/tcg/loongarch64/float_convd.ref              |   988 +
 tests/tcg/loongarch64/float_convs.ref              |   748 +
 tests/tcg/loongarch64/float_madds.ref              |   768 +
 tests/tcg/loongarch64/system/boot.S                |    56 +
 tests/tcg/loongarch64/system/kernel.ld             |    30 +
 tests/tcg/loongarch64/system/regdef.h              |    86 +
 tests/tcg/loongarch64/test_bit.c                   |    88 +
 tests/tcg/loongarch64/test_div.c                   |    54 +
 tests/tcg/loongarch64/test_fclass.c                |   130 +
 tests/tcg/loongarch64/test_fcsr.c                  |    15 +
 tests/tcg/loongarch64/test_fpcom.c                 |    37 +
 tests/tcg/loongarch64/test_pcadd.c                 |    38 +
 tests/tcg/m68k/Makefile.target                     |     3 +
 tests/tcg/m68k/trap.c                              |   129 +
 tests/tcg/multiarch/Makefile.target                |    23 +-
 tests/tcg/multiarch/float_convd.c                  |   106 +
 tests/tcg/multiarch/linux/linux-madvise.c          |    70 +
 tests/tcg/multiarch/linux/linux-test.c             |     2 +-
 tests/tcg/multiarch/munmap-pthread.c               |    79 +
 tests/tcg/multiarch/noexec.c.inc                   |   139 +
 tests/tcg/multiarch/overflow.c                     |    58 +
 tests/tcg/multiarch/system/Makefile.softmmu-target |     2 +-
 tests/tcg/multiarch/system/memory.c                |     2 +-
 tests/tcg/nios2/10m50-ghrd.ld                      |    70 +
 tests/tcg/nios2/Makefile.softmmu-target            |    32 +
 tests/tcg/nios2/Makefile.target                    |    11 -
 tests/tcg/nios2/boot.S                             |   218 +
 tests/tcg/nios2/intr.S                             |    31 +
 tests/tcg/nios2/semicall.h                         |    28 +
 tests/tcg/nios2/test-shadow-1.S                    |    40 +
 tests/tcg/ppc64/Makefile.target                    |    13 +-
 tests/tcg/ppc64/bcdsub.c                           |   134 +
 tests/tcg/ppc64/byte_reverse.c                     |    21 +
 tests/tcg/ppc64/mffsce.c                           |    37 +
 tests/tcg/ppc64/mtfsf.c                            |    60 +
 tests/tcg/ppc64/non_signalling_xscv.c              |    37 +
 tests/tcg/ppc64/signal_save_restore_xer.c          |    42 +
 tests/tcg/ppc64/xxspltw.c                          |    46 +
 tests/tcg/ppc64le/Makefile.target                  |    25 +-
 tests/tcg/ppc64le/bcdsub.c                         |   134 -
 tests/tcg/ppc64le/byte_reverse.c                   |    21 -
 tests/tcg/ppc64le/mtfsf.c                          |    60 -
 tests/tcg/ppc64le/non_signalling_xscv.c            |    37 -
 tests/tcg/ppc64le/signal_save_restore_xer.c        |    42 -
 tests/tcg/ppc64le/xxspltw.c                        |    46 -
 tests/tcg/riscv64/Makefile.softmmu-target          |    21 +
 tests/tcg/riscv64/Makefile.target                  |     1 +
 tests/tcg/riscv64/issue1060.S                      |    53 +
 tests/tcg/riscv64/noexec.c                         |    79 +
 tests/tcg/riscv64/semihost.ld                      |    21 +
 tests/tcg/s390x/Makefile.softmmu-target            |     9 +
 tests/tcg/s390x/Makefile.target                    |    29 +-
 tests/tcg/s390x/branch-relative-long.c             |     4 +-
 tests/tcg/s390x/noexec.c                           |   106 +
 tests/tcg/s390x/signals-s390x.c                    |    69 +-
 tests/tcg/s390x/unaligned-lowcore.S                |    19 +
 tests/tcg/s390x/vfminmax.c                         |   411 +
 tests/tcg/s390x/vistr.c                            |    45 +
 tests/tcg/s390x/vx.h                               |    19 +
 tests/tcg/s390x/vxeh2_vcvt.c                       |    88 +
 tests/tcg/s390x/vxeh2_vlstr.c                      |   139 +
 tests/tcg/s390x/vxeh2_vs.c                         |    93 +
 tests/tcg/sh4/Makefile.target                      |    12 -
 tests/tcg/x86_64/Makefile.softmmu-target           |     3 +-
 tests/tcg/x86_64/Makefile.target                   |    17 +-
 tests/tcg/x86_64/cmpxchg.c                         |    42 +
 tests/tcg/x86_64/float_convd.ref                   |   988 +
 tests/tcg/x86_64/float_convs.ref                   |   748 +
 tests/tcg/x86_64/noexec.c                          |    75 +
 tests/tcg/x86_64/system/boot.S                     |     2 +-
 tests/tcg/xtensa/Makefile.softmmu-target           |     2 +-
 tests/tcg/xtensa/crt.S                             |     2 +
 tests/tcg/xtensa/test_break.S                      |    86 +-
 tests/tcg/xtensa/test_mmu.S                        |   182 +-
 tests/tcg/xtensa/test_phys_mem.S                   |    10 +-
 tests/tcg/xtensa/test_sr.S                         |     2 +
 tests/tcg/xtensa/test_timer.S                      |    68 +-
 tests/unit/check-block-qdict.c                     |     2 +-
 tests/unit/check-qjson.c                           |     1 -
 tests/unit/check-qnull.c                           |     1 -
 tests/unit/check-qnum.c                            |     1 -
 tests/unit/check-qobject.c                         |   133 +-
 tests/unit/check-qom-proplist.c                    |     1 +
 tests/unit/check-qstring.c                         |     1 -
 tests/unit/crypto-tls-psk-helpers.c                |    27 +-
 tests/unit/crypto-tls-psk-helpers.h                |     1 +
 tests/unit/crypto-tls-x509-helpers.c               |    16 +-
 tests/unit/crypto-tls-x509-helpers.h               |    53 +
 tests/unit/io-channel-helpers.c                    |     9 +-
 tests/unit/meson.build                             |     9 +-
 tests/unit/ptimer-test.c                           |    28 +-
 tests/unit/socket-helpers.c                        |    19 +-
 tests/unit/socket-helpers.h                        |     9 +
 tests/unit/test-bdrv-drain.c                       |    97 +-
 tests/unit/test-bdrv-graph-mod.c                   |   104 +-
 tests/unit/test-block-iothread.c                   |   171 +-
 tests/unit/test-blockjob-txn.c                     |    24 +-
 tests/unit/test-blockjob.c                         |   136 +-
 tests/unit/test-clone-visitor.c                    |     1 -
 tests/unit/test-coroutine.c                        |     2 +-
 tests/unit/test-crypto-akcipher.c                  |   990 +
 tests/unit/test-crypto-block.c                     |   340 +-
 tests/unit/test-crypto-der.c                       |   372 +
 tests/unit/test-crypto-tlscredsx509.c              |     4 +-
 tests/unit/test-crypto-tlssession.c                |    25 +-
 tests/unit/test-cutils.c                           |    78 +
 tests/unit/test-forward-visitor.c                  |     3 +-
 tests/unit/test-image-locking.c                    |    10 +-
 tests/unit/test-int128.c                           |    50 +
 tests/unit/test-io-channel-command.c               |    59 +-
 tests/unit/test-io-channel-file.c                  |     2 +-
 tests/unit/test-io-channel-null.c                  |    95 +
 tests/unit/test-io-channel-socket.c                |    38 +-
 tests/unit/test-io-channel-tls.c                   |     6 +-
 tests/unit/test-iov.c                              |    31 +-
 tests/unit/test-keyval.c                           |     2 +-


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:12:22 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:12:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680961.1059401 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGvt-0002UT-Uv; Wed, 14 Feb 2024 15:12:21 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680961.1059401; Wed, 14 Feb 2024 15:12:21 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGvt-0002UM-RZ; Wed, 14 Feb 2024 15:12:21 +0000
Received: by outflank-mailman (input) for mailman id 680961;
 Wed, 14 Feb 2024 15:12:21 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGvt-0002UG-He
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:12:21 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGvt-000645-Gg
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:12:21 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGvt-0008Ma-Fd
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:12:21 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=omu7hQfCZFvlZsiJ1BgbRKctKuG7qCAk5A9Vt6kNjKA=; b=ZlxeFBsOlxP3fbsyEJlUJ1twYC
	KXbaIyxNKG0WpzsX+IPc8CtXT4d7+7uu89hiDPuZf/loM3jO9vrKLbIMraY/337IeyfBRza/hkTub
	SfZMeaXGpuZ0uEzUdqhlzqnwjunGANM+vdsM+sOg61Szrixz0jeHlRNK3U1tI98dfANI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.18] Merge tag 'v7.2.0' into 'staging'
Message-Id: <E1raGvt-0008Ma-Fd@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:12:21 +0000

=== This changeset includes merge from high-traffic branch ===
Commits on that branch are not reported individually.

commit efb74542d6fbb814408c80f97048c7809aad759a
Merge: b67b00e6b4c7831a3f5bc684bc0df7a9bfd1bd56 b746458e1ce1bec85e58b458386f8b7a0bedfaa6
Author:     Anthony PERARD <anthony.perard@gmail.com>
AuthorDate: Thu Dec 15 15:12:57 2022 +0000
Commit:     Anthony PERARD <anthony.perard@gmail.com>
CommitDate: Thu Dec 15 15:12:57 2022 +0000

    Merge tag 'v7.2.0' into 'staging'
 .cirrus.yml                                        |     4 +-
 .github/workflows/lockdown.yml                     |     6 +-
 .gitignore                                         |     4 +
 .gitlab-ci.d/base.yml                              |    72 +
 .gitlab-ci.d/buildtest-template.yml                |    30 +-
 .gitlab-ci.d/buildtest.yml                         |    81 +-
 .gitlab-ci.d/cirrus.yml                            |    30 +-
 .gitlab-ci.d/cirrus/build.yml                      |     3 +-
 .gitlab-ci.d/cirrus/freebsd-12.vars                |     2 +-
 .gitlab-ci.d/cirrus/freebsd-13.vars                |     2 +-
 .gitlab-ci.d/cirrus/macos-11.vars                  |    16 -
 .gitlab-ci.d/cirrus/macos-12.vars                  |    16 +
 .gitlab-ci.d/container-core.yml                    |     5 -
 .gitlab-ci.d/container-cross.yml                   |    58 +-
 .gitlab-ci.d/container-template.yml                |     1 +
 .gitlab-ci.d/containers.yml                        |    13 +-
 .gitlab-ci.d/crossbuild-template.yml               |     8 +-
 .gitlab-ci.d/crossbuilds.yml                       |    16 +-
 .gitlab-ci.d/custom-runners.yml                    |     4 +-
 .../custom-runners/centos-stream-8-x86_64.yml      |     2 +
 .../custom-runners/ubuntu-20.04-aarch32.yml        |    23 -
 .../custom-runners/ubuntu-20.04-aarch64.yml        |   118 -
 .gitlab-ci.d/custom-runners/ubuntu-20.04-s390x.yml |    25 +-
 .../custom-runners/ubuntu-22.04-aarch32.yml        |    25 +
 .../custom-runners/ubuntu-22.04-aarch64.yml        |   130 +
 .gitlab-ci.d/edk2.yml                              |   133 +-
 .gitlab-ci.d/opensbi.yml                           |   134 +-
 .gitlab-ci.d/qemu-project.yml                      |     1 +
 .gitlab-ci.d/stages.yml                            |     1 -
 .gitlab-ci.d/static_checks.yml                     |    33 +-
 .gitlab-ci.d/windows.yml                           |    25 +-
 .gitmodules                                        |     9 +-
 .mailmap                                           |     8 +-
 .travis.yml                                        |     8 +-
 Kconfig.host                                       |     7 +-
 MAINTAINERS                                        |   320 +-
 Makefile                                           |    36 +-
 README.rst                                         |     4 +-
 VERSION                                            |     2 +-
 accel/accel-common.c                               |    18 +
 accel/accel-softmmu.c                              |     8 +-
 accel/dummy-cpus.c                                 |    14 +-
 accel/hvf/hvf-accel-ops.c                          |     6 +-
 accel/hvf/hvf-all.c                                |     1 -
 accel/kvm/kvm-accel-ops.c                          |     9 +
 accel/kvm/kvm-all.c                                |   639 +-
 accel/kvm/kvm-cpus.h                               |     4 +
 accel/meson.build                                  |     2 +-
 accel/qtest/meson.build                            |     3 +-
 accel/stubs/kvm-stub.c                             |    26 +-
 accel/stubs/tcg-stub.c                             |    15 +-
 accel/tcg/atomic_template.h                        |     4 +-
 accel/tcg/cpu-exec-common.c                        |     2 +-
 accel/tcg/cpu-exec.c                               |   252 +-
 accel/tcg/cputlb.c                                 |   399 +-
 accel/tcg/hmp.c                                    |     1 -
 accel/tcg/internal.h                               |   104 +-
 accel/tcg/meson.build                              |     1 +
 accel/tcg/plugin-gen.c                             |    22 +-
 accel/tcg/tb-hash.h                                |     1 +
 accel/tcg/tb-jmp-cache.h                           |    65 +
 accel/tcg/tb-maint.c                               |   704 +
 accel/tcg/tcg-accel-ops-icount.c                   |    13 +-
 accel/tcg/tcg-accel-ops-icount.h                   |     6 +-
 accel/tcg/tcg-accel-ops-mttcg.c                    |     1 -
 accel/tcg/tcg-accel-ops-mttcg.h                    |     6 +-
 accel/tcg/tcg-accel-ops-rr.c                       |     3 +-
 accel/tcg/tcg-accel-ops-rr.h                       |     6 +-
 accel/tcg/tcg-accel-ops.c                          |   114 +-
 accel/tcg/tcg-accel-ops.h                          |     6 +-
 accel/tcg/tcg-all.c                                |    18 +-
 accel/tcg/translate-all.c                          |  1352 +-
 accel/tcg/translator.c                             |   150 +-
 accel/tcg/user-exec.c                              |    66 +-
 audio/alsaaudio.c                                  |    38 +-
 audio/audio.c                                      |   195 +-
 audio/audio.h                                      |     6 +-
 audio/audio_int.h                                  |     4 +-
 audio/audio_template.h                             |    33 +-
 audio/audio_win_int.c                              |     1 -
 audio/dbusaudio.c                                  |     6 +-
 audio/meson.build                                  |     3 +-
 audio/noaudio.c                                    |     4 +-
 audio/rate_template.h                              |    11 +-
 audio/sndioaudio.c                                 |   565 +
 audio/spiceaudio.c                                 |    19 +-
 audio/wavaudio.c                                   |     2 +-
 backends/cryptodev-builtin.c                       |   313 +-
 backends/cryptodev-lkcf.c                          |   645 +
 backends/cryptodev-vhost-user.c                    |    71 +-
 backends/cryptodev-vhost.c                         |     4 +-
 backends/cryptodev.c                               |    68 +-
 backends/dbus-vmstate.c                            |    13 +-
 backends/hostmem-epc.c                             |     1 -
 backends/hostmem.c                                 |    29 +-
 backends/meson.build                               |    13 +-
 backends/rng-egd.c                                 |     2 +-
 backends/rng-random.c                              |     2 +-
 backends/rng.c                                     |    18 +-
 backends/tpm/tpm_emulator.c                        |    70 +-
 backends/tpm/tpm_ioctl.h                           |   100 +-
 backends/tpm/tpm_passthrough.c                     |     1 -
 backends/tpm/trace-events                          |     2 +
 backends/vhost-user.c                              |     6 +-
 block.c                                            |   931 +-
 block/accounting.c                                 |    26 +-
 block/backup.c                                     |     8 +-
 block/blkdebug.c                                   |    11 +-
 block/blkio.c                                      |  1046 +
 block/blklogwrites.c                               |    17 +-
 block/blkreplay.c                                  |     7 +-
 block/blkverify.c                                  |    15 +-
 block/block-backend.c                              |   276 +-
 block/block-copy.c                                 |    33 +-
 block/block-ram-registrar.c                        |    58 +
 block/bochs.c                                      |    17 +-
 block/cloop.c                                      |    19 +-
 block/commit.c                                     |     7 +-
 block/copy-before-write.c                          |   126 +-
 block/copy-on-read.c                               |     9 +-
 block/copy-on-read.h                               |     6 +-
 block/coroutines.h                                 |    55 +-
 block/crypto.c                                     |    73 +-
 block/curl.c                                       |     2 +-
 block/dirty-bitmap.c                               |    26 +-
 block/dmg.c                                        |    74 +-
 block/export/export.c                              |     8 +-
 block/export/fuse.c                                |     4 +-
 block/export/meson.build                           |     7 +-
 block/export/vduse-blk.c                           |   374 +
 block/export/vduse-blk.h                           |    20 +
 block/export/vhost-user-blk-server.c               |   263 +-
 block/export/virtio-blk-handler.c                  |   240 +
 block/export/virtio-blk-handler.h                  |    37 +
 block/file-posix.c                                 |    58 +-
 block/filter-compress.c                            |     8 +-
 block/gluster.c                                    |     7 +-
 block/io.c                                         |   255 +-
 block/io_uring.c                                   |    13 +-
 block/iscsi.c                                      |     7 +-
 block/linux-aio.c                                  |    12 +-
 block/meson.build                                  |     3 +
 block/mirror.c                                     |   106 +-
 block/monitor/bitmap-qmp-cmds.c                    |    46 +-
 block/monitor/block-hmp-cmds.c                     |    12 +-
 block/nbd.c                                        |   306 +-
 block/nfs.c                                        |    10 +-
 block/nvme.c                                       |    96 +-
 block/parallels-ext.c                              |     6 +-
 block/parallels.c                                  |    55 +-
 block/preallocate.c                                |     9 +-
 block/qapi-sysemu.c                                |     3 +-
 block/qcow.c                                       |    91 +-
 block/qcow2-bitmap.c                               |    28 +-
 block/qcow2-cache.c                                |    11 +-
 block/qcow2-cluster.c                              |    69 +-
 block/qcow2-refcount.c                             |   425 +-
 block/qcow2-snapshot.c                             |    55 +-
 block/qcow2.c                                      |   233 +-
 block/qcow2.h                                      |    51 +-
 block/qed-table.c                                  |     2 +-
 block/qed.c                                        |    53 +-
 block/quorum.c                                     |    38 +-
 block/raw-format.c                                 |    13 +-
 block/rbd.c                                        |    24 +
 block/replication.c                                |    12 +-
 block/snapshot-access.c                            |     6 +-
 block/snapshot.c                                   |    59 +-
 block/ssh.c                                        |     7 +-
 block/throttle.c                                   |    10 +-
 block/trace-events                                 |     2 +
 block/vdi.c                                        |    32 +-
 block/vhdx-log.c                                   |    23 +-
 block/vhdx.c                                       |    68 +-
 block/vmdk.c                                       |   227 +-
 block/vpc.c                                        |    42 +-
 block/vvfat.c                                      |    55 +-
 blockdev-nbd.c                                     |    21 +-
 blockdev.c                                         |   178 +-
 blockjob.c                                         |   181 +-
 bsd-user/arm/target.h                              |     2 +-
 bsd-user/arm/target_arch.h                         |     6 +-
 bsd-user/arm/target_arch_cpu.h                     |     6 +-
 bsd-user/arm/target_arch_elf.h                     |     7 +-
 bsd-user/arm/target_arch_reg.h                     |     6 +-
 bsd-user/arm/target_arch_signal.h                  |     7 +-
 bsd-user/arm/target_arch_sigtramp.h                |     6 +-
 bsd-user/arm/target_arch_sysarch.h                 |     6 +-
 bsd-user/arm/target_arch_thread.h                  |     7 +-
 bsd-user/arm/target_arch_vmparam.h                 |     7 +-
 bsd-user/arm/target_syscall.h                      |     6 +-
 bsd-user/bsd-file.h                                |   918 +-
 bsd-user/bsd-proc.h                                |    42 +
 bsd-user/elfload.c                                 |     2 +-
 bsd-user/errno_defs.h                              |     6 +-
 bsd-user/freebsd/host-os.h                         |     6 +-
 bsd-user/freebsd/os-syscall.c                      |   452 +-
 bsd-user/freebsd/target_os_elf.h                   |     7 +-
 bsd-user/freebsd/target_os_siginfo.h               |     7 +-
 bsd-user/freebsd/target_os_signal.h                |     6 +-
 bsd-user/freebsd/target_os_stack.h                 |     6 +-
 bsd-user/freebsd/target_os_thread.h                |     6 +-
 bsd-user/freebsd/target_os_user.h                  |     6 +-
 bsd-user/freebsd/target_os_vmparam.h               |     7 +-
 bsd-user/host/i386/host-signal.h                   |     1 +
 bsd-user/host/x86_64/host-signal.h                 |     1 +
 bsd-user/i386/target.h                             |     7 +-
 bsd-user/i386/target_arch.h                        |     6 +-
 bsd-user/i386/target_arch_cpu.h                    |     6 +-
 bsd-user/i386/target_arch_elf.h                    |     7 +-
 bsd-user/i386/target_arch_reg.h                    |     6 +-
 bsd-user/i386/target_arch_sigtramp.h               |     6 +-
 bsd-user/i386/target_arch_sysarch.h                |     6 +-
 bsd-user/i386/target_arch_thread.h                 |     7 +-
 bsd-user/i386/target_arch_vmparam.h                |     7 +-
 bsd-user/main.c                                    |    59 +-
 bsd-user/mmap.c                                    |     5 +-
 bsd-user/netbsd/host-os.h                          |     6 +-
 bsd-user/netbsd/target_os_elf.h                    |     7 +-
 bsd-user/netbsd/target_os_siginfo.h                |     6 +-
 bsd-user/netbsd/target_os_signal.h                 |     6 +-
 bsd-user/netbsd/target_os_stack.h                  |     6 +-
 bsd-user/netbsd/target_os_thread.h                 |     6 +-
 bsd-user/openbsd/host-os.h                         |     6 +-
 bsd-user/openbsd/target_os_elf.h                   |     7 +-
 bsd-user/openbsd/target_os_siginfo.h               |     6 +-
 bsd-user/openbsd/target_os_signal.h                |     6 +-
 bsd-user/openbsd/target_os_stack.h                 |     6 +-
 bsd-user/openbsd/target_os_thread.h                |     6 +-
 bsd-user/qemu.h                                    |     2 +-
 bsd-user/signal.c                                  |     3 +-
 bsd-user/syscall_defs.h                            |    10 +-
 bsd-user/x86_64/target.h                           |     2 +-
 bsd-user/x86_64/target_arch.h                      |     6 +-
 bsd-user/x86_64/target_arch_cpu.h                  |     6 +-
 bsd-user/x86_64/target_arch_elf.h                  |     7 +-
 bsd-user/x86_64/target_arch_reg.h                  |     6 +-
 bsd-user/x86_64/target_arch_signal.h               |     7 +-
 bsd-user/x86_64/target_arch_sigtramp.h             |     6 +-
 bsd-user/x86_64/target_arch_sysarch.h              |     6 +-
 bsd-user/x86_64/target_arch_thread.h               |     7 +-
 bsd-user/x86_64/target_arch_vmparam.h              |     7 +-
 capstone                                           |     1 -
 chardev/baum.c                                     |    22 +-
 chardev/char-fd.c                                  |     5 +-
 chardev/char-io.c                                  |     2 +-
 chardev/char-pipe.c                                |     1 -
 chardev/char-pty.c                                 |   117 +-
 chardev/char-serial.c                              |     5 +-
 chardev/char-socket.c                              |     6 +-
 chardev/char-stdio.c                               |     5 +-
 chardev/char-win-stdio.c                           |     8 +-
 chardev/char.c                                     |     4 +-
 chardev/chardev-internal.h                         |     3 +-
 chardev/meson.build                                |     4 +-
 chardev/msmouse.c                                  |   152 +-
 chardev/wctablet.c                                 |     4 +-
 common-user/meson.build                            |     4 +
 configs/devices/hppa-softmmu/default.mak           |     2 +-
 configs/devices/loongarch64-softmmu/default.mak    |     3 +
 configs/devices/mips-softmmu/common.mak            |     1 -
 configs/devices/mips64el-softmmu/default.mak       |     1 -
 configs/devices/or1k-softmmu/default.mak           |     1 +
 configs/devices/ppc-softmmu/default.mak            |     3 +-
 configs/targets/aarch64-linux-user.mak             |     1 +
 configs/targets/aarch64_be-linux-user.mak          |     3 +-
 configs/targets/arm-linux-user.mak                 |     1 +
 configs/targets/armeb-linux-user.mak               |     3 +-
 configs/targets/hppa-linux-user.mak                |     2 +-
 configs/targets/hppa-softmmu.mak                   |     2 +-
 configs/targets/loongarch64-linux-user.mak         |     3 +
 configs/targets/loongarch64-softmmu.mak            |     5 +
 configs/targets/m68k-linux-user.mak                |     2 +-
 configs/targets/m68k-softmmu.mak                   |     2 +-
 configs/targets/microblaze-linux-user.mak          |     2 +-
 configs/targets/microblaze-softmmu.mak             |     2 +-
 configs/targets/mips-linux-user.mak                |     2 +-
 configs/targets/mips-softmmu.mak                   |     2 +-
 configs/targets/mips64-linux-user.mak              |     2 +-
 configs/targets/mips64-softmmu.mak                 |     2 +-
 configs/targets/mipsn32-linux-user.mak             |     2 +-
 configs/targets/nios2-softmmu.mak                  |     1 +
 configs/targets/or1k-linux-user.mak                |     2 +-
 configs/targets/or1k-softmmu.mak                   |     3 +-
 configs/targets/ppc-linux-user.mak                 |     2 +-
 configs/targets/ppc-softmmu.mak                    |     2 +-
 configs/targets/ppc64-linux-user.mak               |     2 +-
 configs/targets/ppc64-softmmu.mak                  |     2 +-
 configs/targets/riscv32-linux-user.mak             |     1 +
 configs/targets/riscv64-linux-user.mak             |     1 +
 configs/targets/s390x-linux-user.mak               |     2 +-
 configs/targets/s390x-softmmu.mak                  |     2 +-
 configs/targets/sh4eb-linux-user.mak               |     2 +-
 configs/targets/sh4eb-softmmu.mak                  |     2 +-
 configs/targets/sparc-linux-user.mak               |     2 +-
 configs/targets/sparc-softmmu.mak                  |     2 +-
 configs/targets/sparc32plus-linux-user.mak         |     2 +-
 configs/targets/sparc64-linux-user.mak             |     2 +-
 configs/targets/sparc64-softmmu.mak                |     2 +-
 configs/targets/xtensaeb-linux-user.mak            |     2 +-
 configs/targets/xtensaeb-softmmu.mak               |     2 +-
 configure                                          |  2044 +-
 contrib/elf2dmp/main.c                             |     7 +-
 contrib/elf2dmp/qemu_elf.c                         |    53 +
 contrib/gitdm/domain-map                           |     2 +
 contrib/gitdm/group-map-academics                  |     6 +
 contrib/gitdm/group-map-individuals                |     3 +
 contrib/ivshmem-server/ivshmem-server.c            |     2 +-
 contrib/plugins/Makefile                           |     1 +
 contrib/plugins/cache.c                            |     2 +-
 contrib/plugins/execlog.c                          |   137 +-
 contrib/rdmacm-mux/meson.build                     |     4 +-
 contrib/vhost-user-blk/meson.build                 |     3 +-
 contrib/vhost-user-blk/vhost-user-blk.c            |    18 +-
 contrib/vhost-user-gpu/vugbm.c                     |     2 +-
 contrib/vhost-user-scsi/vhost-user-scsi.c          |    82 +-
 cpu.c                                              |    44 +-
 cpus-common.c                                      |     8 +
 crypto/akcipher-gcrypt.c.inc                       |   595 +
 crypto/akcipher-nettle.c.inc                       |   451 +
 crypto/akcipher.c                                  |   126 +
 crypto/akcipherpriv.h                              |    55 +
 crypto/block-luks-priv.h                           |   143 +
 crypto/block-luks.c                                |   236 +-
 crypto/block.c                                     |     6 +-
 crypto/cipher-afalg.c                              |     1 -
 crypto/der.c                                       |   452 +
 crypto/der.h                                       |   286 +
 crypto/hash-afalg.c                                |     1 -
 crypto/ivgen-plain.h                               |     6 +-
 crypto/meson.build                                 |    11 +-
 crypto/pbkdf.c                                     |    23 +
 crypto/rsakey-builtin.c.inc                        |   200 +
 crypto/rsakey-nettle.c.inc                         |   158 +
 crypto/rsakey.c                                    |    86 +
 crypto/rsakey.h                                    |   101 +
 crypto/secret_common.c                             |    88 +-
 crypto/sm4.c                                       |    49 +
 crypto/tlscredsanon.c                              |    20 +-
 crypto/tlscredspsk.c                               |    36 +-
 crypto/tlscredsx509.c                              |    20 +-
 disas.c                                            |    56 +-
 disas/arm-a64.cc                                   |   101 -
 disas/arm.c                                        |  4012 ----
 disas/capstone.c                                   |    73 +-
 disas/i386.c                                       |  6771 ------
 disas/libvixl/LICENCE                              |    30 -
 disas/libvixl/README                               |    11 -
 disas/libvixl/meson.build                          |     7 -
 disas/libvixl/vixl/a64/assembler-a64.h             |  4624 ----
 disas/libvixl/vixl/a64/constants-a64.h             |  2116 --
 disas/libvixl/vixl/a64/cpu-a64.h                   |    83 -
 disas/libvixl/vixl/a64/decoder-a64.cc              |   877 -
 disas/libvixl/vixl/a64/decoder-a64.h               |   275 -
 disas/libvixl/vixl/a64/disasm-a64.cc               |  3495 ---
 disas/libvixl/vixl/a64/disasm-a64.h                |   177 -
 disas/libvixl/vixl/a64/instructions-a64.cc         |   622 -
 disas/libvixl/vixl/a64/instructions-a64.h          |   757 -
 disas/libvixl/vixl/code-buffer.h                   |   113 -
 disas/libvixl/vixl/compiler-intrinsics.cc          |   144 -
 disas/libvixl/vixl/compiler-intrinsics.h           |   155 -
 disas/libvixl/vixl/globals.h                       |   155 -
 disas/libvixl/vixl/invalset.h                      |   775 -
 disas/libvixl/vixl/platform.h                      |    39 -
 disas/libvixl/vixl/utils.cc                        |   142 -
 disas/libvixl/vixl/utils.h                         |   286 -
 disas/meson.build                                  |    11 +-
 disas/mips.c                                       |    12 +-
 disas/nanomips.c                                   | 21990 ++++++++++++++++++
 disas/nanomips.cpp                                 | 22398 -------------------
 disas/nanomips.h                                   |  1076 -
 disas/ppc.c                                        |  5435 -----
 disas/riscv.c                                      |  1632 +-
 disas/s390.c                                       |  1892 --
 docs/about/build-platforms.rst                     |    37 +-
 docs/about/deprecated.rst                          |   168 +-
 docs/about/removed-features.rst                    |    87 +-
 docs/ccid.txt                                      |   182 -
 docs/conf.py                                       |     2 +-
 docs/devel/acpi-bits.rst                           |   141 +
 docs/devel/build-system.rst                        |     5 -
 docs/devel/ci-jobs.rst.inc                         |   116 +-
 docs/devel/ci.rst                                  |    11 +-
 docs/devel/code-of-conduct.rst                     |     2 +
 docs/devel/fuzzing.rst                             |     4 +-
 docs/devel/index-api.rst                           |     1 -
 docs/devel/index-build.rst                         |     4 +-
 docs/devel/index-internals.rst                     |     2 +-
 docs/devel/index-process.rst                       |     2 +-
 docs/devel/index-tcg.rst                           |     2 +-
 docs/devel/index.rst                               |     2 -
 docs/devel/loads-stores.rst                        |     2 +-
 docs/devel/maintainers.rst                         |   107 +
 docs/devel/multiple-iothreads.txt                  |     4 +-
 docs/devel/qapi-code-gen.rst                       |    13 +-
 docs/devel/qom.rst                                 |     7 +-
 docs/devel/qtest.rst                               |     3 +-
 docs/devel/replay.rst                              |   306 +
 docs/devel/replay.txt                              |    46 -
 docs/devel/reset.rst                               |     8 +-
 docs/devel/style.rst                               |     2 +-
 docs/devel/submitting-a-patch.rst                  |   139 +-
 docs/devel/submitting-a-pull-request.rst           |    12 +-
 docs/devel/tcg-plugins.rst                         |   175 +-
 docs/devel/testing.rst                             |    74 +-
 docs/devel/tracing.rst                             |     2 +-
 docs/devel/virtio-backends.rst                     |   214 +
 docs/devel/writing-monitor-commands.rst            |    13 +-
 docs/hyperv.txt                                    |   255 -
 docs/interop/firmware.json                         |    21 +-
 docs/interop/live-block-operations.rst             |     4 +-
 docs/interop/nbd.txt                               |     1 +
 docs/interop/qemu-ga.rst                           |     8 +-
 docs/interop/vhost-user-gpu.rst                    |    10 +-
 docs/interop/vhost-user.rst                        |   572 +-
 docs/meson.build                                   |     2 +-
 docs/pcie_sriov.txt                                |     6 +-
 docs/replay.txt                                    |   410 -
 docs/specs/acpi_erst.rst                           |     4 +-
 docs/specs/fw_cfg.rst                              |   290 +
 docs/specs/fw_cfg.txt                              |   265 -
 docs/specs/index.rst                               |     1 +
 docs/specs/pci-ids.txt                             |    18 +-
 docs/specs/tpm.rst                                 |    44 +-
 docs/specs/vmgenid.txt                             |     4 +-
 docs/system/arm/aspeed.rst                         |   122 +-
 docs/system/arm/cpu-features.rst                   |    58 +-
 docs/system/arm/emulation.rst                      |    26 +
 docs/system/arm/nuvoton.rst                        |     4 +-
 docs/system/arm/virt.rst                           |    29 +-
 docs/system/device-emulation.rst                   |     3 +
 docs/system/devices/can.rst                        |     5 +-
 docs/system/devices/canokey.rst                    |   158 +
 docs/system/devices/ccid.rst                       |   171 +
 docs/system/devices/cxl.rst                        |   386 +
 docs/system/devices/nvme.rst                       |    86 +-
 docs/system/devices/usb.rst                        |    61 +-
 docs/system/i386/hyperv.rst                        |   288 +
 docs/system/index.rst                              |     1 +
 docs/system/loongarch/loongson3.rst                |   129 +
 docs/system/openrisc/cpu-features.rst              |    15 +
 docs/system/openrisc/emulation.rst                 |    17 +
 docs/system/openrisc/or1k-sim.rst                  |    43 +
 docs/system/openrisc/virt.rst                      |    50 +
 docs/system/ppc/embedded.rst                       |     1 -
 docs/system/ppc/ppce500.rst                        |    28 +-
 docs/system/ppc/pseries.rst                        |    29 +
 docs/system/replay.rst                             |   237 +
 docs/system/riscv/virt.rst                         |    25 +
 docs/system/s390x/bootdevices.rst                  |    28 +-
 docs/system/target-i386.rst                        |     1 +
 docs/system/target-openrisc.rst                    |    71 +
 docs/system/targets.rst                            |     1 +
 docs/system/tls.rst                                |     2 +-
 docs/tools/qemu-img.rst                            |     6 +-
 docs/tools/qemu-nbd.rst                            |     5 +-
 docs/tools/qemu-pr-helper.rst                      |     4 +-
 docs/tools/qemu-storage-daemon.rst                 |    22 +
 docs/tools/virtiofsd.rst                           |     9 +-
 dump/dump.c                                        |   908 +-
 dump/win_dump.c                                    |   313 +-
 ebpf/ebpf_rss.c                                    |     2 +-
 event-loop-base.c                                  |   140 +
 fpu/softfloat-parts.c.inc                          |    33 +-
 fpu/softfloat-specialize.c.inc                     |    26 +-
 fpu/softfloat.c                                    |   205 +-
 fsdev/virtfs-proxy-helper.c                        |     4 +-
 gdb-xml/i386-32bit.xml                             |     2 +-
 gdb-xml/loongarch-base64.xml                       |    45 +
 gdb-xml/loongarch-fpu.xml                          |    50 +
 gdb-xml/riscv-32bit-cpu.xml                        |     6 +-
 gdb-xml/riscv-32bit-fpu.xml                        |    10 +-
 gdb-xml/riscv-64bit-cpu.xml                        |     6 +-
 gdb-xml/riscv-64bit-fpu.xml                        |    10 +-
 gdbstub.c                                          |  3594 ---
 gdbstub/gdbstub.c                                  |  3517 +++
 gdbstub/internals.h                                |    17 +
 gdbstub/meson.build                                |     9 +
 gdbstub/softmmu.c                                  |    51 +
 gdbstub/trace-events                               |    29 +
 gdbstub/trace.h                                    |     1 +
 gdbstub/user.c                                     |    68 +
 hmp-commands-info.hx                               |   107 +-
 hmp-commands.hx                                    |   119 +-
 hw/9pfs/9p-posix-acl.c                             |    12 +-
 hw/9pfs/9p-proxy.c                                 |     1 -
 hw/9pfs/9p-synth.c                                 |     4 +-
 hw/9pfs/9p-util-darwin.c                           |    54 +-
 hw/9pfs/9p-util.h                                  |    69 +
 hw/9pfs/9p-xattr-user.c                            |     8 +-
 hw/9pfs/9p.c                                       |   263 +-
 hw/9pfs/9p.h                                       |    11 +-
 hw/9pfs/virtio-9p-device.c                         |     2 +-
 hw/Kconfig                                         |     2 +
 hw/acpi/Kconfig                                    |     5 +
 hw/acpi/acpi_interface.c                           |     8 +
 hw/acpi/aml-build-stub.c                           |    10 +
 hw/acpi/aml-build.c                                |   124 +-
 hw/acpi/cxl-stub.c                                 |    12 +
 hw/acpi/cxl.c                                      |   256 +
 hw/acpi/erst.c                                     |     9 +-
 hw/acpi/generic_event_device.c                     |     8 +
 hw/acpi/ghes.c                                     |     2 +-
 hw/acpi/ipmi-stub.c                                |     2 +-
 hw/acpi/ipmi.c                                     |    53 +-
 hw/acpi/meson.build                                |     6 +-
 hw/acpi/nvdimm.c                                   |   143 +-
 hw/acpi/pcihp.c                                    |     6 +-
 hw/acpi/piix4.c                                    |    77 +-
 hw/acpi/trace-events                               |    13 +
 hw/acpi/viot.c                                     |   107 +-
 hw/adc/aspeed_adc.c                                |    16 +
 hw/adc/npcm7xx_adc.c                               |     4 +-
 hw/adc/zynq-xadc.c                                 |     4 +-
 hw/alpha/dp264.c                                   |     3 -
 hw/arm/Kconfig                                     |     4 +
 hw/arm/allwinner-a10.c                             |     4 +-
 hw/arm/allwinner-h3.c                              |     2 +-
 hw/arm/armv7m.c                                    |    16 +-
 hw/arm/aspeed.c                                    |   349 +-
 hw/arm/aspeed_ast10x0.c                            |   377 +
 hw/arm/aspeed_ast2600.c                            |   149 +-
 hw/arm/aspeed_soc.c                                |   212 +-
 hw/arm/bcm2835_peripherals.c                       |    26 +-
 hw/arm/boot.c                                      |    70 +-
 hw/arm/digic.c                                     |     5 +-
 hw/arm/exynos4210.c                                |   430 +-
 hw/arm/fby35.c                                     |   192 +
 hw/arm/meson.build                                 |     8 +-
 hw/arm/microbit.c                                  |     2 +-
 hw/arm/mps2-tz.c                                   |     6 +-
 hw/arm/mps2.c                                      |     2 +-
 hw/arm/msf2-som.c                                  |     2 +-
 hw/arm/musca.c                                     |     3 +-
 hw/arm/musicpal.c                                  |     2 +-
 hw/arm/netduino2.c                                 |     2 +-
 hw/arm/netduinoplus2.c                             |     2 +-
 hw/arm/npcm7xx_boards.c                            |    24 +-
 hw/arm/nseries.c                                   |     6 +-
 hw/arm/omap2.c                                     |     2 +-
 hw/arm/pxa2xx.c                                    |     4 +-
 hw/arm/pxa2xx_pic.c                                |     2 +-
 hw/arm/realview.c                                  |    33 +-
 hw/arm/sbsa-ref.c                                  |    16 +
 hw/arm/smmuv3-internal.h                           |     2 +-
 hw/arm/smmuv3.c                                    |    19 +-
 hw/arm/stellaris.c                                 |    17 +-
 hw/arm/stm32vldiscovery.c                          |     2 +-
 hw/arm/sysbus-fdt.c                                |   571 -
 hw/arm/virt-acpi-build.c                           |    42 +-
 hw/arm/virt.c                                      |   220 +-
 hw/arm/xlnx-versal-virt.c                          |     7 +-
 hw/arm/xlnx-versal.c                               |    99 +-
 hw/arm/xlnx-zynqmp.c                               |    62 +-
 hw/audio/ac97.c                                    |   758 +-
 hw/audio/cs4231a.c                                 |     8 +-
 hw/audio/intel-hda.c                               |    11 +-
 hw/audio/pcspk.c                                   |    10 -
 hw/audio/soundhw.c                                 |   151 +-
 hw/avr/boot.c                                      |     1 -
 hw/block/block.c                                   |     4 +-
 hw/block/dataplane/virtio-blk.c                    |     5 +
 hw/block/fdc-isa.c                                 |    16 +-
 hw/block/fdc-sysbus.c                              |    16 +-
 hw/block/fdc.c                                     |    28 +-
 hw/block/hd-geometry.c                             |     9 +-
 hw/block/m25p80.c                                  |   237 +-
 hw/block/m25p80_sfdp.c                             |   332 +
 hw/block/m25p80_sfdp.h                             |    29 +
 hw/block/meson.build                               |     5 +-
 hw/block/nand.c                                    |    47 +-
 hw/block/onenand.c                                 |    32 +-
 hw/block/pflash_cfi01.c                            |     4 +-
 hw/block/pflash_cfi02.c                            |     4 +-
 hw/block/trace-events                              |     1 +
 hw/block/vhost-user-blk.c                          |   107 +-
 hw/block/virtio-blk-common.c                       |    39 +
 hw/block/virtio-blk.c                              |    76 +-
 hw/block/xen-block.c                               |     1 -
 hw/char/escc.c                                     |     2 +-
 hw/char/exynos4210_uart.c                          |     2 +-
 hw/char/parallel.c                                 |    14 +-
 hw/char/pl011.c                                    |     2 +-
 hw/char/serial-isa.c                               |    14 +-
 hw/char/serial.c                                   |     3 +
 hw/char/virtio-serial-bus.c                        |     3 +-
 hw/core/clock.c                                    |     2 +-
 hw/core/cpu-common.c                               |     3 +-
 hw/core/cpu-sysemu.c                               |     5 +-
 hw/core/generic-loader.c                           |     2 +-
 hw/core/irq.c                                      |    15 -
 hw/core/loader.c                                   |   101 +-
 hw/core/machine-hmp-cmds.c                         |     4 +
 hw/core/machine.c                                  |   272 +-
 hw/core/meson.build                                |     1 +
 hw/core/numa.c                                     |    28 +-
 hw/core/qdev-properties.c                          |    19 +
 hw/core/qdev.c                                     |    41 +-
 hw/core/reset.c                                    |    17 +-
 hw/core/resettable.c                               |     3 +-
 hw/core/sysbus-fdt.c                               |   572 +
 hw/core/uboot_image.h                              |   213 +-
 hw/cxl/Kconfig                                     |     3 +
 hw/cxl/cxl-cdat.c                                  |   224 +
 hw/cxl/cxl-component-utils.c                       |   405 +
 hw/cxl/cxl-device-utils.c                          |   271 +
 hw/cxl/cxl-host-stubs.c                            |    15 +
 hw/cxl/cxl-host.c                                  |   340 +
 hw/cxl/cxl-mailbox-utils.c                         |   478 +
 hw/cxl/meson.build                                 |    13 +
 hw/display/acpi-vga-stub.c                         |     7 +
 hw/display/acpi-vga.c                              |    26 +
 hw/display/artist.c                                |   204 +-
 hw/display/ati_2d.c                                |     7 +-
 hw/display/bcm2835_fb.c                            |     3 +-
 hw/display/blizzard.c                              |   354 +-
 hw/display/cg3.c                                   |     1 -
 hw/display/cirrus_vga.c                            |  1609 +-
 hw/display/cirrus_vga_isa.c                        |     1 +
 hw/display/meson.build                             |    17 +
 hw/display/next-fb.c                               |     2 +-
 hw/display/omap_dss.c                              |   598 +-
 hw/display/pl110_template.h                        |     6 +-
 hw/display/pxa2xx_lcd.c                            |   198 +-
 hw/display/qxl-logger.c                            |    22 +-
 hw/display/qxl-render.c                            |    20 +-
 hw/display/qxl.c                                   |    45 +-
 hw/display/qxl.h                                   |    23 +-
 hw/display/sii9022.c                               |     2 +
 hw/display/ssd0303.c                               |     2 +
 hw/display/tcx.c                                   |     1 -
 hw/display/trace-events                            |     1 +
 hw/display/vga-isa.c                               |     1 +
 hw/display/vga-mmio.c                              |     1 +
 hw/display/vga-pci.c                               |     5 +
 hw/display/vga.c                                   |    18 +-
 hw/display/vga_int.h                               |     3 +-
 hw/display/vga_regs.h                              |     6 +-
 hw/display/vhost-user-gpu-pci.c                    |     1 +
 hw/display/vhost-user-gpu.c                        |    11 +-
 hw/display/vhost-user-vga.c                        |     1 +
 hw/display/virtio-gpu-base.c                       |    10 +-
 hw/display/virtio-gpu-gl.c                         |     3 +-
 hw/display/virtio-gpu-pci-gl.c                     |     1 +
 hw/display/virtio-gpu-pci.c                        |     1 +
 hw/display/virtio-gpu-udmabuf.c                    |     1 -
 hw/display/virtio-gpu.c                            |     6 +
 hw/display/virtio-vga-gl.c                         |     1 +
 hw/display/virtio-vga.c                            |     6 +-
 hw/display/vmware_vga.c                            |    42 +-
 hw/display/xenfb.c                                 |   274 +-
 hw/display/xlnx_dp.c                               |    53 +-
 hw/dma/pl330.c                                     |     3 +-
 hw/dma/xilinx_axidma.c                             |     2 +-
 hw/dma/xlnx_csu_dma.c                              |     2 +-
 hw/dma/xlnx_dpdma.c                                |     2 +-
 hw/gpio/Kconfig                                    |     3 +
 hw/gpio/aspeed_gpio.c                              |   270 +-
 hw/gpio/meson.build                                |     2 +-
 hw/gpio/trace-events                               |     4 +
 hw/hppa/Kconfig                                    |     5 +-
 hw/hppa/dino.c                                     |   608 -
 hw/hppa/hppa_hardware.h                            |     5 +-
 hw/hppa/hppa_sys.h                                 |    24 -
 hw/hppa/lasi.c                                     |   367 -
 hw/hppa/machine.c                                  |   152 +-
 hw/hppa/meson.build                                |     2 +-
 hw/hppa/pci.c                                      |    88 -
 hw/hppa/trace-events                               |    14 -
 hw/hyperv/Kconfig                                  |     5 +
 hw/hyperv/hyperv.c                                 |   354 +-
 hw/hyperv/meson.build                              |     1 +
 hw/hyperv/syndbg.c                                 |   401 +
 hw/hyperv/vmbus.c                                  |    99 -
 hw/i2c/aspeed_i2c.c                                |  1012 +-
 hw/i2c/core.c                                      |    70 +-
 hw/i2c/pmbus_device.c                              |    15 +-
 hw/i2c/smbus_ich9.c                                |    15 +
 hw/i2c/smbus_slave.c                               |     4 +
 hw/i2c/trace-events                                |     4 +-
 hw/i386/acpi-build.c                               |   628 +-
 hw/i386/amd_iommu.c                                |    24 +-
 hw/i386/e820_memory_layout.c                       |    20 +-
 hw/i386/e820_memory_layout.h                       |    12 +-
 hw/i386/fw_cfg.c                                   |     3 -
 hw/i386/fw_cfg.h                                   |     1 -
 hw/i386/intel_iommu.c                              |   786 +-
 hw/i386/intel_iommu_internal.h                     |    25 +-
 hw/i386/microvm-dt.c                               |     9 +-
 hw/i386/microvm.c                                  |    77 +-
 hw/i386/multiboot.c                                |     5 +-
 hw/i386/pc.c                                       |   304 +-
 hw/i386/pc_piix.c                                  |   199 +-
 hw/i386/pc_q35.c                                   |    47 +-
 hw/i386/pc_sysfw.c                                 |    37 +-
 hw/i386/sgx.c                                      |     2 +-
 hw/i386/trace-events                               |     2 +
 hw/i386/x86.c                                      |   194 +-
 hw/i386/xen/xen-hvm.c                              |    17 +-
 hw/i386/xen/xen_platform.c                         |    48 +-
 hw/ide/atapi.c                                     |     8 +-
 hw/ide/core.c                                      |    42 +-
 hw/ide/macio.c                                     |     5 +-
 hw/ide/microdrive.c                                |     8 +-
 hw/ide/piix.c                                      |    64 +-
 hw/ide/via.c                                       |     2 +-
 hw/input/lasips2.c                                 |   335 +-
 hw/input/pckbd.c                                   |   382 +-
 hw/input/pl050.c                                   |   160 +-
 hw/input/ps2.c                                     |   487 +-
 hw/input/trace-events                              |     2 -
 hw/input/vhost-user-input.c                        |     8 +-
 hw/input/virtio-input-host.c                       |     5 +-
 hw/input/virtio-input.c                            |     3 +-
 hw/intc/Kconfig                                    |    18 +
 hw/intc/arm_gic.c                                  |    28 +-
 hw/intc/arm_gicv3_common.c                         |    59 +-
 hw/intc/arm_gicv3_cpuif.c                          |   429 +-
 hw/intc/arm_gicv3_dist.c                           |     9 +-
 hw/intc/arm_gicv3_its.c                            |   776 +-
 hw/intc/arm_gicv3_its_kvm.c                        |     2 +
 hw/intc/arm_gicv3_kvm.c                            |    24 +-
 hw/intc/arm_gicv3_redist.c                         |   484 +-
 hw/intc/armv7m_nvic.c                              |     9 +-
 hw/intc/exynos4210_combiner.c                      |   108 +-
 hw/intc/exynos4210_gic.c                           |   353 +-
 hw/intc/gicv3_internal.h                           |   213 +-
 hw/intc/heathrow_pic.c                             |     1 -
 hw/intc/loongarch_extioi.c                         |   317 +
 hw/intc/loongarch_ipi.c                            |   273 +
 hw/intc/loongarch_pch_msi.c                        |    91 +
 hw/intc/loongarch_pch_pic.c                        |   431 +
 hw/intc/meson.build                                |     5 +
 hw/intc/nios2_vic.c                                |   313 +
 hw/intc/openpic.c                                  |     3 +-
 hw/intc/pnv_xive.c                                 |    20 -
 hw/intc/pnv_xive2.c                                |    41 +-
 hw/intc/ppc-uic.c                                  |    26 +-
 hw/intc/riscv_aclint.c                             |   189 +-
 hw/intc/riscv_aplic.c                              |     2 +-
 hw/intc/riscv_imsic.c                              |     4 +-
 hw/intc/s390_flic_kvm.c                            |     2 +-
 hw/intc/sifive_plic.c                              |    44 +-
 hw/intc/trace-events                               |    39 +-
 hw/intc/xics.c                                     |    12 +-
 hw/intc/xics_kvm.c                                 |     1 -
 hw/intc/xive.c                                     |    29 +-
 hw/intc/xive2.c                                    |    18 +-
 hw/ipmi/isa_ipmi_bt.c                              |     4 +
 hw/ipmi/isa_ipmi_kcs.c                             |     4 +
 hw/ipmi/smbus_ipmi.c                               |     8 +-
 hw/isa/Kconfig                                     |     9 +
 hw/isa/isa-bus.c                                   |    10 +-
 hw/isa/lpc_ich9.c                                  |    37 +
 hw/isa/piix3.c                                     |   165 +-
 hw/isa/piix4.c                                     |   122 +-
 hw/isa/vt82c686.c                                  |   120 +-
 hw/loongarch/Kconfig                               |    22 +
 hw/loongarch/acpi-build.c                          |   549 +
 hw/loongarch/fw_cfg.c                              |    34 +
 hw/loongarch/fw_cfg.h                              |    15 +
 hw/loongarch/meson.build                           |     8 +
 hw/loongarch/virt.c                                |   985 +
 hw/m68k/bootinfo.h                                 |    56 +-
 hw/m68k/mcf5206.c                                  |     2 +-
 hw/m68k/mcf5208.c                                  |     3 +-
 hw/m68k/q800.c                                     |    82 +-
 hw/m68k/virt.c                                     |    76 +-
 hw/mem/Kconfig                                     |     5 +
 hw/mem/cxl_type3.c                                 |   647 +
 hw/mem/meson.build                                 |     1 +
 hw/mem/nvdimm.c                                    |     2 +-
 hw/meson.build                                     |     2 +
 hw/microblaze/boot.c                               |     8 +-
 hw/mips/bootloader.c                               |    28 +-
 hw/mips/boston.c                                   |    25 +-
 hw/mips/fuloong2e.c                                |    50 +-
 hw/mips/gt64xxx_pci.c                              |     6 +-
 hw/mips/jazz.c                                     |    23 +-
 hw/mips/loongson3_virt.c                           |     1 -
 hw/mips/malta.c                                    |   195 +-
 hw/mips/mipssim.c                                  |     3 +-
 hw/misc/Kconfig                                    |     3 +
 hw/misc/applesmc.c                                 |    29 +
 hw/misc/aspeed_hace.c                              |   167 +-
 hw/misc/aspeed_peci.c                              |   152 +
 hw/misc/aspeed_sbc.c                               |    45 +-
 hw/misc/aspeed_scu.c                               |   110 +-
 hw/misc/bcm2835_property.c                         |     4 +
 hw/misc/cbus.c                                     |     6 +-
 hw/misc/grlib_ahb_apb_pnp.c                        |    10 +-
 hw/misc/iotkit-secctl.c                            |     2 +-
 hw/misc/iotkit-sysctl.c                            |     4 +-
 hw/misc/ivshmem.c                                  |     2 +-
 hw/misc/lasi.c                                     |   274 +
 hw/misc/mac_via.c                                  |     8 +-
 hw/misc/macio/cuda.c                               |     1 -
 hw/misc/macio/gpio.c                               |     1 -
 hw/misc/macio/macio.c                              |     8 +-
 hw/misc/macio/pmu.c                                |     1 -
 hw/misc/meson.build                                |     7 +-
 hw/misc/mips_itu.c                                 |     3 +-
 hw/misc/mos6522.c                                  |     2 +-
 hw/misc/pvpanic-isa.c                              |    42 +
 hw/misc/sbsa_ec.c                                  |     1 -
 hw/misc/sifive_u_otp.c                             |    14 +-
 hw/misc/trace-events                               |    15 +-
 hw/misc/xlnx-versal-crl.c                          |   421 +
 hw/net/can/can_sja1000.c                           |    31 +-
 hw/net/can/ctu_can_fd_frame.h                      |   184 +-
 hw/net/can/ctu_can_fd_regs.h                       |  1264 +-
 hw/net/can/ctucan_core.h                           |     2 +-
 hw/net/can/xlnx-zynqmp-can.c                       |    34 +-
 hw/net/e1000.c                                     |     5 +-
 hw/net/e1000_regs.h                                |    31 +-
 hw/net/e1000e.c                                    |    15 +-
 hw/net/e1000e_core.c                               |    62 +-
 hw/net/fsl_etsec/etsec.c                           |    26 +-
 hw/net/fsl_etsec/etsec.h                           |     7 -
 hw/net/fsl_etsec/rings.c                           |     1 -
 hw/net/imx_fec.c                                   |     2 +-
 hw/net/lan9118.c                                   |    10 +-
 hw/net/mcf_fec.c                                   |     8 +-
 hw/net/meson.build                                 |     8 +-
 hw/net/msf2-emac.c                                 |     1 -
 hw/net/ne2000.c                                    |   138 +-
 hw/net/npcm7xx_emc.c                               |     1 -
 hw/net/pcnet.c                                     |   136 +-
 hw/net/pcnet.h                                     |     4 +-
 hw/net/rocker/rocker.c                             |    27 +-
 hw/net/rtl8139.c                                   |    49 +-
 hw/net/tulip.c                                     |    12 +-
 hw/net/vhost_net-stub.c                            |    12 +
 hw/net/vhost_net.c                                 |   120 +-
 hw/net/virtio-net.c                                |   278 +-
 hw/net/vmxnet3.c                                   |    27 +-
 hw/net/vmxnet3.h                                   |     4 +-
 hw/net/xen_nic.c                                   |     5 +-
 hw/nios2/10m50_devboard.c                          |   115 +-
 hw/nios2/Kconfig                                   |     1 +
 hw/nios2/boot.c                                    |    16 +-
 hw/nios2/generic_nommu.c                           |     1 -
 hw/nios2/meson.build                               |     2 +-
 hw/nvme/ctrl.c                                     |  1208 +-
 hw/nvme/dif.c                                      |     5 +
 hw/nvme/ns.c                                       |    13 +-
 hw/nvme/nvme.h                                     |    79 +-
 hw/nvme/subsys.c                                   |    78 +-
 hw/nvme/trace-events                               |    11 +
 hw/nvram/eeprom93xx.c                              |     2 +-
 hw/nvram/eeprom_at24c.c                            |    10 +-
 hw/nvram/fw_cfg.c                                  |    78 +-
 hw/nvram/mac_nvram.c                               |     2 +-
 hw/nvram/spapr_nvram.c                             |    16 +-
 hw/nvram/xlnx-bbram.c                              |     4 +-
 hw/nvram/xlnx-efuse.c                              |     4 +-
 hw/openrisc/Kconfig                                |    12 +
 hw/openrisc/boot.c                                 |   119 +
 hw/openrisc/cputimer.c                             |    22 +-
 hw/openrisc/meson.build                            |     2 +
 hw/openrisc/openrisc_sim.c                         |   132 +-
 hw/openrisc/virt.c                                 |   571 +
 hw/pci-bridge/Kconfig                              |     5 +
 hw/pci-bridge/cxl_downstream.c                     |   249 +
 hw/pci-bridge/cxl_root_port.c                      |   236 +
 hw/pci-bridge/cxl_upstream.c                       |   409 +
 hw/pci-bridge/meson.build                          |     6 +-
 hw/pci-bridge/pci_expander_bridge.c                |   176 +-
 hw/pci-bridge/pci_expander_bridge_stubs.c          |    14 +
 hw/pci-bridge/pcie_root_port.c                     |     6 +-
 hw/pci-host/Kconfig                                |     4 +
 hw/pci-host/dino.c                                 |   521 +
 hw/pci-host/gpex-acpi.c                            |    20 +-
 hw/pci-host/grackle.c                              |    15 +-
 hw/pci-host/i440fx.c                               |     9 +-
 hw/pci-host/meson.build                            |     6 +-
 hw/pci-host/mv64361.c                              |     1 -
 hw/pci-host/pnv_phb.c                              |   345 +
 hw/pci-host/pnv_phb.h                              |    55 +
 hw/pci-host/pnv_phb3.c                             |   177 +-
 hw/pci-host/pnv_phb3_msi.c                         |     1 -
 hw/pci-host/pnv_phb3_pbcq.c                        |     1 -
 hw/pci-host/pnv_phb4.c                             |   230 +-
 hw/pci-host/pnv_phb4_pec.c                         |    25 +-
 hw/pci-host/q35.c                                  |     3 +-
 hw/pci-host/raven.c                                |     1 -
 hw/pci-host/remote.c                               |     1 -
 hw/pci-host/trace-events                           |     5 +
 hw/pci-host/uninorth.c                             |     1 -
 hw/pci/meson.build                                 |     1 +
 hw/pci/msi.c                                       |    49 +-
 hw/pci/msix.c                                      |    45 +-
 hw/pci/pci.c                                       |    52 +-
 hw/pci/pcie.c                                      |     5 +-
 hw/pci/pcie_aer.c                                  |     4 +-
 hw/pci/pcie_doe.c                                  |   367 +
 hw/pci/pcie_port.c                                 |    25 +
 hw/pci/shpc.c                                      |     5 +-
 hw/ppc/Kconfig                                     |    14 +-
 hw/ppc/e500.c                                      |   120 +-
 hw/ppc/e500.h                                      |     1 -
 hw/ppc/e500plat.c                                  |     1 -
 hw/ppc/mac.h                                       |   105 -
 hw/ppc/mac_newworld.c                              |   229 +-
 hw/ppc/mac_oldworld.c                              |   116 +-
 hw/ppc/meson.build                                 |    10 +-
 hw/ppc/mpc8544ds.c                                 |     9 +-
 hw/ppc/pegasos2.c                                  |    38 +-
 hw/ppc/pnv.c                                       |   295 +-
 hw/ppc/pnv_bmc.c                                   |     1 -
 hw/ppc/pnv_core.c                                  |     1 +
 hw/ppc/pnv_lpc.c                                   |    19 +-
 hw/ppc/pnv_occ.c                                   |    16 +-
 hw/ppc/pnv_pnor.c                                  |     6 +-
 hw/ppc/pnv_psi.c                                   |    36 +-
 hw/ppc/pnv_sbe.c                                   |   414 +
 hw/ppc/pnv_xscom.c                                 |     3 +
 hw/ppc/ppc.c                                       |    47 +-
 hw/ppc/ppc405.h                                    |   194 +-
 hw/ppc/ppc405_boards.c                             |   564 +-
 hw/ppc/ppc405_uc.c                                 |  1153 +-
 hw/ppc/ppc440.h                                    |     4 -
 hw/ppc/ppc440_bamboo.c                             |    95 +-
 hw/ppc/ppc440_uc.c                                 |   283 +-
 hw/ppc/ppc4xx_devs.c                               |   913 +-
 hw/ppc/ppc4xx_pci.c                                |    31 +-
 hw/ppc/ppc4xx_sdram.c                              |   757 +
 hw/ppc/prep.c                                      |     6 +-
 hw/ppc/prep_systemio.c                             |     2 +-
 hw/ppc/sam460ex.c                                  |   108 +-
 hw/ppc/spapr.c                                     |    90 +-
 hw/ppc/spapr_caps.c                                |     2 +-
 hw/ppc/spapr_hcall.c                               |    97 +-
 hw/ppc/spapr_iommu.c                               |     3 +-
 hw/ppc/spapr_numa.c                                |     1 -
 hw/ppc/spapr_nvdimm.c                              |    18 +-
 hw/ppc/spapr_pci.c                                 |    11 +-
 hw/ppc/spapr_pci_nvlink2.c                         |     3 +-
 hw/ppc/spapr_rtas.c                                |    20 +-
 hw/ppc/spapr_rtas_ddw.c                            |    35 +-
 hw/ppc/spapr_tpm_proxy.c                           |     1 -
 hw/ppc/spapr_vof.c                                 |     1 -
 hw/ppc/trace-events                                |    17 +-
 hw/ppc/virtex_ml507.c                              |    43 +-
 hw/ppc/vof.c                                       |     3 +-
 hw/rdma/vmw/pvrdma_main.c                          |    18 +-
 hw/remote/Kconfig                                  |     4 +
 hw/remote/iohub.c                                  |     1 -
 hw/remote/iommu.c                                  |   131 +
 hw/remote/machine.c                                |    89 +-
 hw/remote/memory.c                                 |     1 -
 hw/remote/meson.build                              |     4 +
 hw/remote/message.c                                |     1 -
 hw/remote/mpqemu-link.c                            |     3 +-
 hw/remote/proxy-memory-listener.c                  |     1 -
 hw/remote/proxy.c                                  |     1 -
 hw/remote/remote-obj.c                             |     1 -
 hw/remote/trace-events                             |    11 +
 hw/remote/vfio-user-obj.c                          |   951 +
 hw/riscv/Kconfig                                   |     2 +
 hw/riscv/boot.c                                    |    60 +-
 hw/riscv/microchip_pfsoc.c                         |    71 +-
 hw/riscv/opentitan.c                               |    56 +-
 hw/riscv/shakti_c.c                                |     3 +-
 hw/riscv/sifive_e.c                                |     2 +-
 hw/riscv/sifive_u.c                                |    33 +-
 hw/riscv/spike.c                                   |    17 +-
 hw/riscv/virt.c                                    |   411 +-
 hw/rtc/Kconfig                                     |     3 +
 hw/rtc/exynos4210_rtc.c                            |     4 +-
 hw/rtc/goldfish_rtc.c                              |    37 +-
 hw/rtc/ls7a_rtc.c                                  |   488 +
 hw/rtc/m41t80.c                                    |     6 +-
 hw/rtc/mc146818rtc.c                               |    23 +-
 hw/rtc/meson.build                                 |     1 +
 hw/rx/rx-gdbsim.c                                  |    10 +-
 hw/s390x/css.c                                     |    51 +-
 hw/s390x/event-facility.c                          |     2 +-
 hw/s390x/ipl.c                                     |    44 +-
 hw/s390x/ipl.h                                     |     2 +-
 hw/s390x/meson.build                               |     2 +
 hw/s390x/pv.c                                      |   114 +-
 hw/s390x/s390-ccw.c                                |     2 +-
 hw/s390x/s390-pci-bus.c                            |   111 +-
 hw/s390x/s390-pci-inst.c                           |    85 +-
 hw/s390x/s390-pci-kvm.c                            |    52 +
 hw/s390x/s390-pci-vfio.c                           |   129 +-
 hw/s390x/s390-virtio-ccw.c                         |   185 +-
 hw/s390x/tod-kvm.c                                 |     9 +
 hw/s390x/vhost-scsi-ccw.c                          |    73 +
 hw/s390x/vhost-vsock-ccw.c                         |     9 +
 hw/s390x/virtio-ccw-9p.c                           |     9 +
 hw/s390x/virtio-ccw-balloon.c                      |     9 +
 hw/s390x/virtio-ccw-blk.c                          |     9 +
 hw/s390x/virtio-ccw-crypto.c                       |     9 +
 hw/s390x/virtio-ccw-gpu.c                          |    10 +
 hw/s390x/virtio-ccw-input.c                        |    20 +
 hw/s390x/virtio-ccw-net.c                          |     9 +
 hw/s390x/virtio-ccw-rng.c                          |     9 +
 hw/s390x/virtio-ccw-scsi.c                         |    56 +-
 hw/s390x/virtio-ccw-serial.c                       |     9 +
 hw/s390x/virtio-ccw.c                              |    14 +-
 hw/s390x/virtio-ccw.h                              |   149 -
 hw/scsi/Kconfig                                    |     5 +
 hw/scsi/esp.c                                      |    14 +-
 hw/scsi/lsi53c895a.c                               |    10 +-
 hw/scsi/megasas.c                                  |    12 +-
 hw/scsi/mfi.h                                      |     2 +-
 hw/scsi/mptsas.c                                   |    11 +-
 hw/scsi/scsi-bus.c                                 |    47 +-
 hw/scsi/scsi-disk.c                                |   130 +-
 hw/scsi/scsi-generic.c                             |    27 +-
 hw/scsi/spapr_vscsi.c                              |     7 +-
 hw/scsi/trace-events                               |     3 +
 hw/scsi/vhost-scsi-common.c                        |     4 +-
 hw/scsi/vhost-scsi.c                               |    13 +-
 hw/scsi/vhost-user-scsi.c                          |     3 +-
 hw/scsi/virtio-scsi-dataplane.c                    |    13 +-
 hw/scsi/virtio-scsi.c                              |   117 +-
 hw/scsi/vmw_pvscsi.c                               |     8 +-
 hw/sd/allwinner-sdhost.c                           |    74 +-
 hw/sd/sd.c                                         |     5 +-
 hw/sd/sdhci-internal.h                             |    20 -
 hw/sd/sdhci.c                                      |    63 +-
 hw/sensor/Kconfig                                  |     4 +
 hw/sensor/isl_pmbus_vr.c                           |    40 +
 hw/sensor/lsm303dlhc_mag.c                         |     2 +
 hw/sensor/max31785.c                               |   573 +
 hw/sensor/meson.build                              |     1 +
 hw/smbios/smbios.c                                 |    96 +-
 hw/smbios/smbios_build.h                           |     9 +-
 hw/sparc/leon3.c                                   |     1 -
 hw/sparc/sun4m.c                                   |    12 +-
 hw/sparc64/sun4u.c                                 |     9 +-
 hw/sparc64/sun4u_iommu.c                           |     2 +-
 hw/ssi/aspeed_smc.c                                |   170 +-
 hw/ssi/ibex_spi_host.c                             |   646 +
 hw/ssi/meson.build                                 |     1 +
 hw/ssi/ssi.c                                       |    18 +-
 hw/ssi/trace-events                                |     7 +
 hw/timer/allwinner-a10-pit.c                       |     2 +-
 hw/timer/altera_timer.c                            |     2 +-
 hw/timer/arm_timer.c                               |     2 +-
 hw/timer/aspeed_timer.c                            |    17 +
 hw/timer/cadence_ttc.c                             |    32 +-
 hw/timer/digic-timer.c                             |     2 +-
 hw/timer/etraxfs_timer.c                           |     6 +-
 hw/timer/exynos4210_mct.c                          |     6 +-
 hw/timer/exynos4210_pwm.c                          |     2 +-
 hw/timer/grlib_gptimer.c                           |     2 +-
 hw/timer/ibex_timer.c                              |    18 +-
 hw/timer/imx_epit.c                                |    13 +-
 hw/timer/imx_gpt.c                                 |     2 +-
 hw/timer/mss-timer.c                               |     2 +-
 hw/timer/renesas_cmt.c                             |     2 +-
 hw/timer/renesas_tmr.c                             |     8 +-
 hw/timer/sh_timer.c                                |     2 +-
 hw/timer/slavio_timer.c                            |     2 +-
 hw/timer/sse-timer.c                               |     2 +-
 hw/timer/xilinx_timer.c                            |     2 +-
 hw/tpm/tpm_crb.c                                   |     8 +-
 hw/tpm/tpm_ppi.c                                   |     2 +-
 hw/tpm/tpm_tis_common.c                            |     7 +-
 hw/tpm/tpm_tis_isa.c                               |    32 +
 hw/usb/Kconfig                                     |     5 +
 hw/usb/canokey.c                                   |   334 +
 hw/usb/canokey.h                                   |    69 +
 hw/usb/ccid-card-emulated.c                        |     3 +-
 hw/usb/ccid-card-passthru.c                        |     3 +-
 hw/usb/dev-hub.c                                   |    82 +-
 hw/usb/dev-mtp.c                                   |     5 +-
 hw/usb/dev-network.c                               |   320 +-
 hw/usb/dev-smartcard-reader.c                      |     2 +-
 hw/usb/dev-storage.c                               |    58 +-
 hw/usb/dev-uas.c                                   |     5 +-
 hw/usb/dev-wacom.c                                 |     4 +-
 hw/usb/hcd-dwc2.h                                  |     4 +-
 hw/usb/hcd-ehci.c                                  |     5 +-
 hw/usb/hcd-musb.c                                  |   328 +-
 hw/usb/hcd-ohci.c                                  |    17 +-
 hw/usb/hcd-xhci-pci.c                              |     2 +-
 hw/usb/hcd-xhci-sysbus.c                           |     2 +-
 hw/usb/hcd-xhci.c                                  |    94 +-
 hw/usb/host-libusb.c                               |    16 +-
 hw/usb/meson.build                                 |     5 +
 hw/usb/quirks-pl2303-ids.h                         |   180 +-
 hw/usb/redirect.c                                  |     3 +-
 hw/usb/trace-events                                |    17 +
 hw/usb/u2f.h                                       |     2 +-
 hw/usb/vt82c686-uhci-pci.c                         |     4 +-
 hw/vfio/common.c                                   |   192 +-
 hw/vfio/display.c                                  |     8 +-
 hw/vfio/migration.c                                |    29 +-
 hw/vfio/pci-quirks.c                               |    34 +-
 hw/vfio/pci.c                                      |   244 +-
 hw/vfio/pci.h                                      |     2 +
 hw/vfio/spapr.c                                    |     8 +-
 hw/vfio/trace-events                               |     1 +
 hw/virtio/Kconfig                                  |    23 +-
 hw/virtio/meson.build                              |    38 +-
 hw/virtio/trace-events                             |    22 +-
 hw/virtio/vhost-backend.c                          |    11 +-
 hw/virtio/vhost-iova-tree.c                        |     6 +-
 hw/virtio/vhost-iova-tree.h                        |     2 +-
 hw/virtio/vhost-scsi-pci.c                         |     2 +-
 hw/virtio/vhost-shadow-virtqueue.c                 |   281 +-
 hw/virtio/vhost-shadow-virtqueue.h                 |    58 +-
 hw/virtio/vhost-user-blk-pci.c                     |     2 +-
 hw/virtio/vhost-user-fs-pci.c                      |     2 +-
 hw/virtio/vhost-user-fs.c                          |    24 +-
 hw/virtio/vhost-user-gpio-pci.c                    |    69 +
 hw/virtio/vhost-user-gpio.c                        |   418 +
 hw/virtio/vhost-user-i2c-pci.c                     |     2 +-
 hw/virtio/vhost-user-i2c.c                         |    22 +-
 hw/virtio/vhost-user-input-pci.c                   |     2 +-
 hw/virtio/vhost-user-rng-pci.c                     |     2 +-
 hw/virtio/vhost-user-rng.c                         |    34 +-
 hw/virtio/vhost-user-scsi-pci.c                    |     2 +-
 hw/virtio/vhost-user-vsock-pci.c                   |     2 +-
 hw/virtio/vhost-user-vsock.c                       |    10 +-
 hw/virtio/vhost-user.c                             |   313 +-
 hw/virtio/vhost-vdpa.c                             |   147 +-
 hw/virtio/vhost-vsock-common.c                     |    20 +-
 hw/virtio/vhost-vsock-pci.c                        |     2 +-
 hw/virtio/vhost-vsock.c                            |    21 +-
 hw/virtio/vhost.c                                  |   120 +-
 hw/virtio/virtio-9p-pci.c                          |     2 +-
 hw/virtio/virtio-balloon-pci.c                     |     2 +-
 hw/virtio/virtio-balloon.c                         |    12 +-
 hw/virtio/virtio-blk-pci.c                         |     2 +-
 hw/virtio/virtio-bus.c                             |    23 +-
 hw/virtio/virtio-crypto.c                          |   592 +-
 hw/virtio/virtio-input-host-pci.c                  |     2 +-
 hw/virtio/virtio-input-pci.c                       |     2 +-
 hw/virtio/virtio-iommu-pci.c                       |    18 +-
 hw/virtio/virtio-iommu.c                           |   202 +-
 hw/virtio/virtio-mem-pci.c                         |     2 -
 hw/virtio/virtio-mem.c                             |    16 +-
 hw/virtio/virtio-mmio.c                            |    18 +-
 hw/virtio/virtio-net-pci.c                         |     2 +-
 hw/virtio/virtio-pci.c                             |   112 +-
 hw/virtio/virtio-pci.h                             |   255 -
 hw/virtio/virtio-pmem-pci.c                        |     2 -
 hw/virtio/virtio-pmem.c                            |     4 +-
 hw/virtio/virtio-rng-pci.c                         |    16 +-
 hw/virtio/virtio-rng.c                             |     2 +-
 hw/virtio/virtio-scsi-pci.c                        |     2 +-
 hw/virtio/virtio-serial-pci.c                      |     2 +-
 hw/virtio/virtio-stub.c                            |    42 +
 hw/virtio/virtio.c                                 |  1187 +-
 hw/watchdog/meson.build                            |     1 +
 hw/watchdog/sbsa_gwdt.c                            |     6 -
 hw/watchdog/spapr_watchdog.c                       |   274 +
 hw/watchdog/trace-events                           |     7 +
 hw/watchdog/watchdog.c                             |    43 -
 hw/watchdog/wdt_aspeed.c                           |    40 +-
 hw/watchdog/wdt_diag288.c                          |     6 -
 hw/watchdog/wdt_i6300esb.c                         |     6 -
 hw/watchdog/wdt_ib700.c                            |     6 -
 hw/watchdog/wdt_imx2.c                             |     6 -
 hw/xen/meson.build                                 |    20 +-
 hw/xen/xen_pt.c                                    |    12 -
 hw/xen/xen_pt.h                                    |     2 +
 hw/xen/xen_pt_config_init.c                        |    29 +-
 hw/xen/xen_pt_graphics.c                           |   122 +
 hw/xen/xen_pvdev.c                                 |    45 +-
 hw/xenpv/xen_machine_pv.c                          |     1 +
 hw/xtensa/mx_pic.c                                 |     2 +-
 hw/xtensa/sim.c                                    |     2 +-
 hw/xtensa/xtfpga.c                                 |     4 +-
 include/block/accounting.h                         |     6 +-
 include/block/aio-wait.h                           |    19 +-
 include/block/aio.h                                |    10 +
 include/block/block-common.h                       |    48 +
 include/block/block-copy.h                         |     4 +-
 include/block/block-global-state.h                 |    30 +-
 include/block/block-hmp-cmds.h                     |     6 +-
 include/block/block-io.h                           |    32 +-
 include/block/block_int-common.h                   |    68 +-
 include/block/block_int-global-state.h             |     5 +-
 include/block/block_int-io.h                       |     8 +-
 include/block/blockjob.h                           |    59 +-
 include/block/nbd.h                                |     7 +-
 include/block/nvme.h                               |   111 +-
 include/block/qdict.h                              |     3 +
 include/block/thread-pool.h                        |     3 +
 include/chardev/char-socket.h                      |     7 +-
 include/chardev/char.h                             |     4 +-
 include/crypto/akcipher.h                          |   179 +
 include/crypto/block.h                             |    32 +-
 include/crypto/sm4.h                               |     6 +
 include/crypto/tls-cipher-suites.h                 |     6 +-
 include/disas/dis-asm.h                            |     6 +-
 include/elf.h                                      |     3 +
 include/exec/cpu-all.h                             |    40 +-
 include/exec/cpu-common.h                          |    11 +-
 include/exec/cpu-defs.h                            |    48 +-
 include/exec/cpu_ldst.h                            |     2 +-
 include/exec/exec-all.h                            |   233 +-
 include/exec/gdbstub.h                             |    66 +-
 include/exec/helper-head.h                         |     2 +-
 include/exec/log.h                                 |    52 +-
 include/exec/memop.h                               |     4 +-
 include/exec/memopidx.h                            |     2 +-
 include/exec/memory.h                              |    22 +-
 include/exec/page-vary.h                           |    18 +
 include/exec/plugin-gen.h                          |     7 +-
 include/exec/poison.h                              |     6 +-
 include/exec/ram_addr.h                            |    15 +-
 include/exec/ramblock.h                            |     3 +
 include/exec/softmmu-semi.h                        |   101 -
 include/exec/translate-all.h                       |     2 +-
 include/exec/translator.h                          |   117 +-
 include/fpu/softfloat-helpers.h                    |     2 +-
 include/fpu/softfloat-types.h                      |     6 +-
 include/fpu/softfloat.h                            |     7 +
 include/glib-compat.h                              |     4 +
 include/hw/acpi/acpi_aml_interface.h               |    49 +
 include/hw/acpi/cxl.h                              |    29 +
 include/hw/acpi/generic_event_device.h             |     4 +-
 include/hw/acpi/ipmi.h                             |     9 +-
 include/hw/acpi/piix4.h                            |    75 +
 include/hw/adc/aspeed_adc.h                        |     1 +
 include/hw/adc/zynq-xadc.h                         |     3 +-
 include/hw/arm/aspeed_soc.h                        |    40 +-
 include/hw/arm/bcm2835_peripherals.h               |     2 +
 include/hw/arm/boot.h                              |     5 +-
 include/hw/arm/exynos4210.h                        |    50 +-
 include/hw/arm/smmu-common.h                       |     1 +
 include/hw/arm/sysbus-fdt.h                        |    37 -
 include/hw/arm/virt.h                              |    21 +-
 include/hw/arm/xlnx-versal.h                       |    16 +
 include/hw/arm/xlnx-zynqmp.h                       |     7 +
 include/hw/audio/soundhw.h                         |     8 +-
 include/hw/block/block.h                           |     7 +-
 include/hw/block/fdc.h                             |     3 +-
 include/hw/boards.h                                |    15 +-
 include/hw/core/cpu.h                              |    43 +-
 include/hw/core/sysbus-fdt.h                       |    37 +
 include/hw/core/sysemu-cpu-ops.h                   |     8 +-
 include/hw/core/tcg-cpu-ops.h                      |    18 +-
 include/hw/cxl/cxl.h                               |    61 +
 include/hw/cxl/cxl_cdat.h                          |   166 +
 include/hw/cxl/cxl_component.h                     |   230 +
 include/hw/cxl/cxl_device.h                        |   272 +
 include/hw/cxl/cxl_host.h                          |    23 +
 include/hw/cxl/cxl_pci.h                           |   168 +
 include/hw/display/xlnx_dp.h                       |    12 +-
 include/hw/elf_ops.h                               |     2 +-
 include/hw/firmware/smbios.h                       |    22 +
 include/hw/gpio/aspeed_gpio.h                      |    18 +-
 include/hw/hw.h                                    |     2 +-
 include/hw/hyperv/hyperv-proto.h                   |    52 +
 include/hw/hyperv/hyperv.h                         |    58 +
 include/hw/hyperv/vmbus.h                          |     3 -
 include/hw/i2c/arm_sbcon_i2c.h                     |     7 +-
 include/hw/i2c/aspeed_i2c.h                        |   301 +-
 include/hw/i2c/i2c.h                               |    30 +
 include/hw/i2c/i2c_mux_pca954x.h                   |     4 +-
 include/hw/i2c/pmbus_device.h                      |     7 +
 include/hw/i386/intel_iommu.h                      |    25 +-
 include/hw/i386/microvm.h                          |     4 -
 include/hw/i386/pc.h                               |    33 +-
 include/hw/i386/x86-iommu.h                        |     4 +-
 include/hw/i386/x86.h                              |    13 +-
 include/hw/ide.h                                   |     3 -
 include/hw/ide/internal.h                          |     3 +
 include/hw/ide/piix.h                              |     7 +
 include/hw/input/i8042.h                           |    74 +-
 include/hw/input/lasips2.h                         |    68 +-
 include/hw/input/lm832x.h                          |     4 +-
 include/hw/input/pl050.h                           |    59 +
 include/hw/input/ps2.h                             |    77 +-
 include/hw/intc/arm_gicv3_common.h                 |    21 +-
 include/hw/intc/arm_gicv3_its_common.h             |    19 +
 include/hw/intc/exynos4210_combiner.h              |    57 +
 include/hw/intc/exynos4210_gic.h                   |    43 +
 include/hw/intc/loongarch_extioi.h                 |    62 +
 include/hw/intc/loongarch_ipi.h                    |    53 +
 include/hw/intc/loongarch_pch_msi.h                |    22 +
 include/hw/intc/loongarch_pch_pic.h                |    69 +
 include/hw/intc/nios2_vic.h                        |    64 +
 include/hw/intc/ppc-uic.h                          |     6 +-
 include/hw/intc/riscv_aclint.h                     |     3 +
 include/hw/intc/rx_icu.h                           |     2 +-
 include/hw/irq.h                                   |     5 -
 include/hw/isa/isa.h                               |    17 -
 include/hw/isa/vt82c686.h                          |     4 +-
 include/hw/loader.h                                |    55 +-
 include/hw/loongarch/virt.h                        |    57 +
 include/hw/mem/nvdimm.h                            |     8 -
 include/hw/mips/bios.h                             |     2 +-
 include/hw/mips/bootloader.h                       |     8 +-
 include/hw/misc/aspeed_hace.h                      |     9 +-
 include/hw/misc/aspeed_lpc.h                       |     2 +-
 include/hw/misc/aspeed_peci.h                      |    29 +
 include/hw/misc/aspeed_sbc.h                       |    15 +-
 include/hw/misc/aspeed_scu.h                       |    45 +
 include/hw/misc/bcm2835_cprman.h                   |     4 +-
 include/hw/misc/bcm2835_cprman_internals.h         |     4 +-
 include/hw/misc/lasi.h                             |    78 +
 include/hw/misc/macio/macio.h                      |    23 +-
 include/hw/misc/npcm7xx_gcr.h                      |    30 +
 include/hw/misc/pvpanic.h                          |     9 -
 include/hw/misc/stm32f4xx_exti.h                   |     4 +-
 include/hw/misc/stm32f4xx_syscfg.h                 |     4 +-
 include/hw/misc/xlnx-versal-crl.h                  |   235 +
 include/hw/misc/xlnx-versal-pmc-iou-slcr.h         |     6 +-
 include/hw/net/allwinner-sun8i-emac.h              |     2 +-
 include/hw/net/mv88w8618_eth.h                     |     5 +-
 include/hw/nubus/mac-nubus-bridge.h                |     4 +-
 include/hw/nvram/fw_cfg.h                          |    43 +
 include/hw/nvram/mac_nvram.h                       |    51 +
 include/hw/openrisc/boot.h                         |    34 +
 include/hw/pci-bridge/pci_expander_bridge.h        |    12 +
 include/hw/pci-host/dino.h                         |   146 +
 include/hw/pci-host/grackle.h                      |    44 +
 include/hw/pci-host/i440fx.h                       |     4 +-
 include/hw/pci-host/ls7a.h                         |    51 +
 include/hw/pci-host/pnv_phb3.h                     |    19 +-
 include/hw/pci-host/pnv_phb3_regs.h                |    16 -
 include/hw/pci-host/pnv_phb4.h                     |    22 +-
 include/hw/pci-host/remote.h                       |     4 +-
 include/hw/pci/msi.h                               |     1 +
 include/hw/pci/msix.h                              |     3 +-
 include/hw/pci/pci.h                               |    88 +-
 include/hw/pci/pci_bridge.h                        |    20 +
 include/hw/pci/pci_bus.h                           |     9 +
 include/hw/pci/pci_ids.h                           |     5 +
 include/hw/pci/pcie.h                              |     1 +
 include/hw/pci/pcie_doe.h                          |   123 +
 include/hw/pci/pcie_host.h                         |     6 +-
 include/hw/pci/pcie_port.h                         |     2 +
 include/hw/pci/pcie_regs.h                         |     4 +
 include/hw/ppc/pnv.h                               |    12 +-
 include/hw/ppc/pnv_lpc.h                           |     8 +-
 include/hw/ppc/pnv_occ.h                           |     7 +-
 include/hw/ppc/pnv_pnor.h                          |     8 +-
 include/hw/ppc/pnv_psi.h                           |     7 +-
 include/hw/ppc/pnv_sbe.h                           |    55 +
 include/hw/ppc/pnv_xscom.h                         |    12 +
 include/hw/ppc/ppc.h                               |    10 +-
 include/hw/ppc/ppc4xx.h                            |   135 +-
 include/hw/ppc/spapr.h                             |    34 +-
 include/hw/ppc/xive.h                              |     1 +
 include/hw/ptimer.h                                |    16 +-
 include/hw/qdev-core.h                             |    31 +-
 include/hw/qdev-properties.h                       |    12 +
 include/hw/registerfields.h                        |    70 +
 include/hw/remote/iommu.h                          |    40 +
 include/hw/remote/machine.h                        |     4 +
 include/hw/remote/vfio-user-obj.h                  |     6 +
 include/hw/riscv/boot.h                            |     5 +-
 include/hw/riscv/boot_opensbi.h                    |     5 +-
 include/hw/riscv/microchip_pfsoc.h                 |    14 +-
 include/hw/riscv/opentitan.h                       |    33 +-
 include/hw/riscv/shakti_c.h                        |     4 +-
 include/hw/riscv/sifive_e.h                        |     3 +-
 include/hw/riscv/virt.h                            |     9 +-
 include/hw/rtc/goldfish_rtc.h                      |     2 +
 include/hw/rtc/m48t59.h                            |     2 +-
 include/hw/rtc/mc146818rtc.h                       |     4 +-
 include/hw/rtc/sun4v-rtc.h                         |     4 +-
 include/hw/rtc/xlnx-zynqmp-rtc.h                   |     4 +-
 include/hw/rx/rx62n.h                              |     4 +-
 include/hw/s390x/pv.h                              |    19 +
 include/hw/s390x/s390-pci-bus.h                    |     8 +-
 include/hw/s390x/s390-pci-clp.h                    |     4 +-
 include/hw/s390x/s390-pci-kvm.h                    |    38 +
 include/hw/s390x/s390-pci-vfio.h                   |     5 +
 include/hw/s390x/s390-virtio-ccw.h                 |     1 +
 include/hw/scsi/scsi.h                             |    19 +-
 include/hw/sd/allwinner-sdhost.h                   |     1 +
 include/hw/sensor/emc141x_regs.h                   |     4 +-
 include/hw/sensor/isl_pmbus_vr.h                   |     5 +
 include/hw/southbridge/piix.h                      |    12 +-
 include/hw/ssi/aspeed_smc.h                        |     2 +
 include/hw/ssi/ibex_spi_host.h                     |    94 +
 include/hw/ssi/ssi.h                               |     3 +
 include/hw/ssi/xlnx-versal-ospi.h                  |     6 +-
 include/hw/timer/aspeed_timer.h                    |     1 +
 include/hw/timer/bcm2835_systmr.h                  |     4 +-
 include/hw/timer/cadence_ttc.h                     |    54 +
 include/hw/timer/ibex_timer.h                      |     2 +
 include/hw/tricore/tc27x_soc.h                     |     4 +-
 include/hw/tricore/tricore_testdevice.h            |     5 +-
 include/hw/usb.h                                   |   100 +-
 include/hw/usb/dwc2-regs.h                         |  1618 +-
 include/hw/usb/hcd-musb.h                          |     4 +-
 include/hw/usb/msd.h                               |     1 +
 include/hw/usb/xlnx-usb-subsystem.h                |     4 +-
 include/hw/usb/xlnx-versal-usb2-ctrl-regs.h        |     4 +-
 include/hw/vfio/vfio-common.h                      |     2 +-
 include/hw/virtio/vhost-backend.h                  |     3 +
 include/hw/virtio/vhost-user-blk.h                 |     1 -
 include/hw/virtio/vhost-user-fs.h                  |     6 +-
 include/hw/virtio/vhost-user-gpio.h                |    45 +
 include/hw/virtio/vhost-user-i2c.h                 |     6 +-
 include/hw/virtio/vhost-user-rng.h                 |     6 +-
 include/hw/virtio/vhost-user-vsock.h               |     6 +-
 include/hw/virtio/vhost-user.h                     |    61 +-
 include/hw/virtio/vhost-vdpa.h                     |     7 +
 include/hw/virtio/vhost-vsock-common.h             |     8 +-
 include/hw/virtio/vhost.h                          |   179 +-
 include/hw/virtio/virtio-access.h                  |     8 +-
 include/hw/virtio/virtio-blk-common.h              |    20 +
 include/hw/virtio/virtio-blk.h                     |     2 +
 include/hw/virtio/virtio-crypto.h                  |     5 +-
 include/hw/virtio/virtio-gpu-bswap.h               |     2 +-
 include/hw/virtio/virtio-gpu.h                     |     4 +-
 include/hw/virtio/virtio-iommu.h                   |     4 +-
 include/hw/virtio/virtio-net.h                     |     7 +
 include/hw/virtio/virtio-pci.h                     |   260 +
 include/hw/virtio/virtio-scsi.h                    |    45 -
 include/hw/virtio/virtio.h                         |    77 +-
 include/hw/watchdog/wdt_aspeed.h                   |     3 +
 include/hw/watchdog/wdt_imx2.h                     |     6 +-
 include/hw/xen/xen.h                               |     2 +-
 include/hw/xen/xen_common.h                        |     6 -
 include/io/channel-command.h                       |    30 +-
 include/io/channel-null.h                          |    55 +
 include/io/channel-socket.h                        |     2 +
 include/io/channel.h                               |    38 +-
 include/libdecnumber/dconfig.h                     |     2 +-
 include/monitor/hmp.h                              |    12 +-
 include/monitor/monitor.h                          |     4 +
 include/monitor/stats.h                            |    45 +
 include/net/eth.h                                  |     2 +-
 include/net/net.h                                  |    14 +-
 include/net/vhost_net.h                            |     4 +
 include/qapi/qmp/qbool.h                           |     4 +
 include/qapi/qmp/qdict.h                           |     7 +-
 include/qapi/qmp/qerror.h                          |     3 -
 include/qapi/qmp/qlist.h                           |     4 +
 include/qapi/qmp/qnull.h                           |     4 +
 include/qapi/qmp/qnum.h                            |     4 +
 include/qapi/qmp/qstring.h                         |     4 +
 include/qemu-common.h                              |   117 -
 include/qemu-main.h                                |    11 +
 include/qemu/accel.h                               |    13 +
 include/qemu/async-teardown.h                      |    22 +
 include/qemu/atomic.h                              |    24 +-
 include/qemu/bitmap.h                              |     1 +
 include/qemu/bswap.h                               |    64 +-
 include/qemu/compiler.h                            |    26 +-
 include/qemu/config-file.h                         |     1 -
 include/qemu/coroutine.h                           |   100 +-
 include/qemu/cpu-float.h                           |    64 +
 include/qemu/crc-ccitt.h                           |     6 +-
 include/qemu/cutils.h                              |    66 +-
 include/qemu/error-report.h                        |     2 -
 include/qemu/hbitmap.h                             |    15 +-
 include/qemu/help-texts.h                          |    13 +
 include/qemu/host-utils.h                          |    73 +-
 include/qemu/int128.h                              |    61 +-
 include/qemu/iova-tree.h                           |     4 +-
 include/qemu/job.h                                 |   306 +-
 include/qemu/keyval.h                              |    15 +
 include/qemu/log-for-trace.h                       |     2 +-
 include/qemu/log.h                                 |    93 +-
 include/qemu/main-loop.h                           |    42 +-
 include/qemu/mmap-alloc.h                          |     2 -
 include/qemu/module.h                              |    47 +-
 include/qemu/option.h                              |     6 -
 include/qemu/osdep.h                               |   115 +-
 include/qemu/plugin-memory.h                       |     2 +-
 include/qemu/plugin.h                              |    24 +
 include/qemu/qemu-plugin.h                         |     7 +-
 include/qemu/qemu-progress.h                       |     8 +
 include/qemu/selfmap.h                             |     2 +-
 include/qemu/sockets.h                             |    41 +-
 include/qemu/thread-context.h                      |    57 +
 include/qemu/thread-posix.h                        |     9 +-
 include/qemu/thread.h                              |    14 +-
 include/qemu/typedefs.h                            |     5 +
 include/qemu/win_dump_defs.h                       |   115 +-
 include/qom/object.h                               |     1 -
 include/scsi/constants.h                           |     2 +
 include/semihosting/common-semi.h                  |    39 +
 include/semihosting/console.h                      |    66 +-
 include/semihosting/guestfd.h                      |    91 +
 include/semihosting/semihost.h                     |    24 +-
 include/semihosting/softmmu-uaccess.h              |    59 +
 include/semihosting/syscalls.h                     |    75 +
 include/standard-headers/asm-m68k/bootinfo-virt.h  |     3 +
 include/standard-headers/asm-m68k/bootinfo.h       |     8 +-
 include/standard-headers/asm-x86/bootparam.h       |     8 +-
 include/standard-headers/drm/drm_fourcc.h          |    73 +-
 include/standard-headers/linux/ethtool.h           |    29 +-
 include/standard-headers/linux/input-event-codes.h |    25 +-
 include/standard-headers/linux/input.h             |    12 +-
 include/standard-headers/linux/pci_regs.h          |    30 +-
 include/standard-headers/linux/vhost_types.h       |    17 +-
 include/standard-headers/linux/virtio_9p.h         |     2 +-
 include/standard-headers/linux/virtio_config.h     |    13 +-
 include/standard-headers/linux/virtio_crypto.h     |    82 +-
 include/standard-headers/linux/virtio_ids.h        |    14 +-
 include/standard-headers/linux/virtio_net.h        |    34 +-
 include/standard-headers/linux/virtio_pci.h        |     2 +
 include/standard-headers/linux/virtio_ring.h       |    16 +-
 include/sysemu/accel-ops.h                         |     8 +
 include/sysemu/arch_init.h                         |     1 +
 include/sysemu/block-backend-global-state.h        |    10 +-
 include/sysemu/block-backend-io.h                  |    98 +-
 include/sysemu/block-ram-registrar.h               |    37 +
 include/sysemu/cpu-timers.h                        |     1 +
 include/sysemu/cpus.h                              |     3 +
 include/sysemu/cryptodev.h                         |   136 +-
 include/sysemu/device_tree.h                       |    10 +
 include/sysemu/dirtylimit.h                        |    37 +
 include/sysemu/dirtyrate.h                         |    28 +
 include/sysemu/dump-arch.h                         |     3 +
 include/sysemu/dump.h                              |    38 +-
 include/sysemu/event-loop-base.h                   |    41 +
 include/sysemu/hostmem.h                           |     2 +
 include/sysemu/iothread.h                          |     6 +-
 include/sysemu/kvm.h                               |    40 +-
 include/sysemu/kvm_int.h                           |    76 +
 include/sysemu/os-posix.h                          |     5 +-
 include/sysemu/os-win32.h                          |    43 +-
 include/sysemu/replay.h                            |    11 +-
 include/sysemu/reset.h                             |     5 +-
 include/sysemu/runstate.h                          |     9 +-
 include/sysemu/sysemu.h                            |    11 +-
 include/sysemu/tpm.h                               |     6 +
 include/sysemu/watchdog.h                          |    12 -
 include/tcg/tcg-ldst.h                             |     6 +-
 include/tcg/tcg-op.h                               |    11 +
 include/tcg/tcg.h                                  |     8 +-
 include/ui/console.h                               |     7 +-
 include/ui/dbus-display.h                          |     6 +-
 include/ui/dbus-module.h                           |     6 +-
 include/ui/gtk.h                                   |     2 +-
 include/ui/qemu-pixman.h                           |     2 +-
 include/user/safe-syscall.h                        |     2 +-
 include/user/syscall-trace.h                       |     2 +-
 io/channel-buffer.c                                |     1 +
 io/channel-command.c                               |   214 +-
 io/channel-file.c                                  |    14 +-
 io/channel-null.c                                  |   237 +
 io/channel-socket.c                                |   140 +-
 io/channel-tls.c                                   |     1 +
 io/channel-watch.c                                 |    12 +-
 io/channel-websock.c                               |     3 +-
 io/channel.c                                       |    49 +-
 io/meson.build                                     |     1 +
 io/trace-events                                    |     3 +
 iothread.c                                         |    68 +-
 job-qmp.c                                          |    92 +-
 job.c                                              |   674 +-
 libdecnumber/dpd/decimal64.c                       |     3 +-
 linux-headers/asm-arm64/kvm.h                      |    49 +-
 linux-headers/asm-generic/mman-common.h            |     2 +
 linux-headers/asm-generic/unistd.h                 |     4 +-
 linux-headers/asm-mips/mman.h                      |     2 +
 linux-headers/asm-riscv/kvm.h                      |    22 +
 linux-headers/asm-riscv/unistd.h                   |     3 +-
 linux-headers/asm-s390/kvm.h                       |     1 +
 linux-headers/asm-x86/kvm.h                        |    33 +-
 linux-headers/asm-x86/mman.h                       |    14 -
 linux-headers/linux/kvm.h                          |   198 +-
 linux-headers/linux/psci.h                         |     4 +
 linux-headers/linux/userfaultfd.h                  |    16 +-
 linux-headers/linux/vduse.h                        |   353 +
 linux-headers/linux/vfio.h                         |   410 +-
 linux-headers/linux/vfio_zdev.h                    |     7 +
 linux-headers/linux/vhost.h                        |    40 +-
 linux-user/aarch64/cpu_loop.c                      |    14 +-
 linux-user/aarch64/signal.c                        |   245 +-
 linux-user/aarch64/target_cpu.h                    |     5 +-
 linux-user/aarch64/target_mman.h                   |     1 +
 linux-user/aarch64/target_prctl.h                  |    80 +-
 linux-user/aarch64/target_syscall.h                |     2 +-
 linux-user/alpha/cpu_loop.c                        |     1 -
 linux-user/alpha/target_mman.h                     |     8 +
 linux-user/arm/cpu_loop.c                          |     7 +-
 linux-user/arm/nwfpe/double_cpdo.c                 |     4 +-
 linux-user/arm/nwfpe/fpa11_cpdt.c                  |     4 +-
 linux-user/arm/target_cpu.h                        |     4 +-
 linux-user/arm/target_mman.h                       |     1 +
 linux-user/arm/target_syscall.h                    |     2 +-
 linux-user/cpu_loop-common.h                       |    13 +-
 linux-user/cris/cpu_loop.c                         |     1 -
 linux-user/cris/target_mman.h                      |     1 +
 linux-user/elfload.c                               |   321 +-
 linux-user/flatload.c                              |     2 +-
 linux-user/generic/target_mman.h                   |    92 +
 linux-user/hexagon/cpu_loop.c                      |     1 -
 linux-user/hexagon/target_mman.h                   |     1 +
 linux-user/hexagon/target_signal.h                 |     2 +-
 linux-user/hppa/cpu_loop.c                         |    22 +-
 linux-user/hppa/signal.c                           |    57 +-
 linux-user/hppa/target_mman.h                      |    15 +
 linux-user/hppa/target_signal.h                    |    14 +-
 linux-user/hppa/target_syscall.h                   |     2 +
 linux-user/i386/cpu_loop.c                         |     9 +-
 linux-user/i386/signal.c                           |   231 +-
 linux-user/i386/target_elf.h                       |     2 +-
 linux-user/i386/target_mman.h                      |     1 +
 linux-user/include/host/s390/host-signal.h         |    32 +
 linux-user/ioctls.h                                |    24 -
 linux-user/linuxload.c                             |    12 +-
 linux-user/loongarch64/cpu_loop.c                  |    96 +
 linux-user/loongarch64/signal.c                    |   315 +
 linux-user/loongarch64/sockbits.h                  |    11 +
 linux-user/loongarch64/syscall_nr.h                |   312 +
 linux-user/loongarch64/target_cpu.h                |    34 +
 linux-user/loongarch64/target_elf.h                |    12 +
 linux-user/loongarch64/target_errno_defs.h         |    12 +
 linux-user/loongarch64/target_fcntl.h              |    11 +
 linux-user/loongarch64/target_mman.h               |     1 +
 linux-user/loongarch64/target_prctl.h              |     1 +
 linux-user/loongarch64/target_resource.h           |    11 +
 linux-user/loongarch64/target_signal.h             |    13 +
 linux-user/loongarch64/target_structs.h            |    11 +
 linux-user/loongarch64/target_syscall.h            |    48 +
 linux-user/loongarch64/termbits.h                  |    11 +
 linux-user/m68k/cpu_loop.c                         |    19 +-
 linux-user/m68k/target_mman.h                      |     1 +
 linux-user/main.c                                  |    80 +-
 linux-user/microblaze/cpu_loop.c                   |     1 -
 linux-user/microblaze/target_mman.h                |     1 +
 linux-user/mips/cpu_loop.c                         |     1 -
 linux-user/mips/target_mman.h                      |     1 +
 linux-user/mips64/target_mman.h                    |     1 +
 linux-user/mmap.c                                  |   112 +-
 linux-user/nios2/cpu_loop.c                        |    96 +-
 linux-user/nios2/signal.c                          |    25 +-
 linux-user/nios2/target_cpu.h                      |     1 +
 linux-user/nios2/target_mman.h                     |     1 +
 linux-user/openrisc/cpu_loop.c                     |     1 -
 linux-user/openrisc/target_mman.h                  |     1 +
 linux-user/ppc/cpu_loop.c                          |     1 -
 linux-user/ppc/signal.c                            |     5 +-
 linux-user/ppc/target_mman.h                       |     1 +
 linux-user/ppc/target_syscall.h                    |     2 +-
 linux-user/qemu.h                                  |    15 +-
 linux-user/riscv/cpu_loop.c                        |     3 +-
 linux-user/riscv/signal.c                          |     4 +-
 linux-user/riscv/target_mman.h                     |     1 +
 linux-user/s390x/cpu_loop.c                        |     1 -
 linux-user/s390x/signal.c                          |     7 +
 linux-user/s390x/target_mman.h                     |     1 +
 linux-user/semihost.c                              |    48 +-
 linux-user/sh4/cpu_loop.c                          |     1 -
 linux-user/sh4/signal.c                            |     6 +-
 linux-user/sh4/target_mman.h                       |     1 +
 linux-user/signal-common.h                         |    46 +
 linux-user/signal.c                                |    40 +-
 linux-user/sparc/cpu_loop.c                        |     1 -
 linux-user/sparc/target_mman.h                     |     1 +
 linux-user/strace.c                                |   524 +-
 linux-user/strace.h                                |     4 +-
 linux-user/strace.list                             |    40 +-
 linux-user/syscall.c                               |   502 +-
 linux-user/syscall_defs.h                          |    14 +-
 linux-user/uname.c                                 |     7 +-
 linux-user/uname.h                                 |     2 +-
 linux-user/user-internals.h                        |    23 +-
 linux-user/user-mmap.h                             |     1 +
 linux-user/x86_64/target_elf.h                     |     2 +-
 linux-user/x86_64/target_mman.h                    |     1 +
 linux-user/xtensa/signal.c                         |     2 +-
 linux-user/xtensa/target_mman.h                    |     1 +
 linux-user/xtensa/target_structs.h                 |     2 +-
 meson                                              |     2 +-
 meson.build                                        |  1103 +-
 meson_options.txt                                  |    79 +-
 migration/block.c                                  |    24 +-
 migration/channel-block.c                          |   197 +
 migration/channel-block.h                          |    59 +
 migration/channel.c                                |    15 +-
 migration/colo.c                                   |     5 +-
 migration/dirtyrate.c                              |   227 +-
 migration/dirtyrate.h                              |     7 +-
 migration/meson.build                              |     4 +-
 migration/migration.c                              |   296 +-
 migration/migration.h                              |    54 +-
 migration/multifd-zlib.c                           |    38 +-
 migration/multifd.c                                |   119 +-
 migration/multifd.h                                |    70 +-
 migration/postcopy-ram.c                           |   190 +-
 migration/postcopy-ram.h                           |    11 +
 migration/qemu-file-channel.c                      |   194 -
 migration/qemu-file-channel.h                      |    32 -
 migration/qemu-file.c                              |   247 +-
 migration/qemu-file.h                              |   126 +-
 migration/ram.c                                    |   434 +-
 migration/ram.h                                    |     5 +
 migration/rdma.c                                   |   186 +-
 migration/savevm.c                                 |   106 +-
 migration/socket.c                                 |    34 +-
 migration/socket.h                                 |     1 +
 migration/tls.c                                    |    13 +-
 migration/tls.h                                    |     4 +
 migration/trace-events                             |    18 +-
 migration/vmstate-types.c                          |     1 +
 migration/vmstate.c                                |     5 +-
 monitor/hmp-cmds.c                                 |   590 +-
 monitor/hmp.c                                      |    15 +-
 monitor/misc.c                                     |    26 +-
 monitor/monitor-internal.h                         |     1 -
 monitor/monitor.c                                  |    10 +
 monitor/qmp-cmds.c                                 |   182 +-
 nbd/client-connection.c                            |     2 +
 nbd/server.c                                       |    81 +-
 nbd/trace-events                                   |     3 +
 net/announce.c                                     |     2 +-
 net/can/can_socketcan.c                            |    26 +-
 net/clients.h                                      |    17 +
 net/colo-compare.c                                 |     3 +-
 net/colo.c                                         |    26 +-
 net/colo.h                                         |     1 +
 net/dgram.c                                        |   623 +
 net/filter-rewriter.c                              |     2 +-
 net/hub.c                                          |     2 +
 net/l2tpv3.c                                       |     5 +-
 net/meson.build                                    |    22 +-
 net/net.c                                          |   219 +-
 net/slirp.c                                        |    90 +-
 net/socket.c                                       |    47 +-
 net/stream.c                                       |   386 +
 net/tap-bsd.c                                      |     5 +-
 net/tap-linux.c                                    |     3 +-
 net/tap-linux.h                                    |    10 +-
 net/tap-solaris.c                                  |     3 +-
 net/tap-win32.c                                    |     4 +-
 net/tap.c                                          |    63 +-
 net/trace-events                                   |     1 +
 net/util.h                                         |     2 +-
 net/vde.c                                          |     4 +-
 net/vhost-user.c                                   |     3 +-
 net/vhost-vdpa-stub.c                              |    21 +
 net/vhost-vdpa.c                                   |   460 +-
 net/vmnet-bridged.m                                |   152 +
 net/vmnet-common.m                                 |   378 +
 net/vmnet-host.c                                   |   128 +
 net/vmnet-shared.c                                 |   114 +
 net/vmnet_int.h                                    |    63 +
 os-posix.c                                         |    14 +-
 os-win32.c                                         |    10 -
 page-vary-common.c                                 |     1 -
 page-vary.c                                        |     2 +-
 pc-bios/README                                     |     2 +-
 pc-bios/bios-256k.bin                              |   Bin 262144 -> 262144 bytes
 pc-bios/bios-microvm.bin                           |   Bin 131072 -> 131072 bytes
 pc-bios/bios.bin                                   |   Bin 131072 -> 131072 bytes
 pc-bios/hppa-firmware.img                          |   Bin 701964 -> 719368 bytes
 pc-bios/keymaps/meson.build                        |    22 +-
 pc-bios/meson.build                                |     4 +-
 pc-bios/opensbi-riscv32-generic-fw_dynamic.bin     |   Bin 108504 -> 117704 bytes
 pc-bios/opensbi-riscv64-generic-fw_dynamic.bin     |   Bin 105296 -> 115344 bytes
 pc-bios/optionrom/Makefile                         |    70 +-
 pc-bios/optionrom/code16gcc.h                      |     3 -
 pc-bios/qboot.rom                                  |   Bin 65536 -> 65536 bytes
 pc-bios/s390-ccw.img                               |   Bin 50936 -> 42608 bytes
 pc-bios/s390-ccw/Makefile                          |    63 +-
 pc-bios/s390-ccw/bootmap.c                         |    27 +-
 pc-bios/s390-ccw/cio.h                             |     2 +-
 pc-bios/s390-ccw/iplb.h                            |     2 +-
 pc-bios/s390-ccw/main.c                            |    27 +-
 pc-bios/s390-ccw/netboot.mak                       |    28 +-
 pc-bios/s390-ccw/s390-ccw.h                        |     1 +
 pc-bios/s390-ccw/start.S                           |     2 +-
 pc-bios/s390-ccw/virtio-blkdev.c                   |    93 +-
 pc-bios/s390-ccw/virtio-scsi.c                     |    21 +-
 pc-bios/s390-ccw/virtio-scsi.h                     |     2 +-
 pc-bios/s390-ccw/virtio.c                          |    28 +-
 pc-bios/s390-ccw/virtio.h                          |    16 +-
 pc-bios/s390-netboot.img                           |   Bin 79688 -> 67232 bytes
 pc-bios/skiboot.lid                                |   Bin 2528128 -> 2527240 bytes
 pc-bios/slof.bin                                   |   Bin 992384 -> 995176 bytes
 pc-bios/vgabios-ati.bin                            |   Bin 39936 -> 39936 bytes
 pc-bios/vgabios-bochs-display.bin                  |   Bin 28672 -> 28672 bytes
 pc-bios/vgabios-cirrus.bin                         |   Bin 39424 -> 39424 bytes
 pc-bios/vgabios-qxl.bin                            |   Bin 39424 -> 39936 bytes
 pc-bios/vgabios-ramfb.bin                          |   Bin 28672 -> 29184 bytes
 pc-bios/vgabios-stdvga.bin                         |   Bin 39424 -> 39936 bytes
 pc-bios/vgabios-virtio.bin                         |   Bin 39424 -> 39936 bytes
 pc-bios/vgabios-vmware.bin                         |   Bin 39424 -> 39936 bytes
 pc-bios/vgabios.bin                                |   Bin 38912 -> 39424 bytes
 pc-bios/vof/Makefile                               |    28 +-
 plugins/api.c                                      |     2 +
 plugins/core.c                                     |    22 +-
 plugins/meson.build                                |     2 +-
 plugins/plugin.h                                   |     6 +-
 po/LINGUAS                                         |     1 +
 po/uk.po                                           |    75 +
 python/Makefile                                    |     2 +-
 python/README.rst                                  |     2 +-
 python/qemu/aqmp/__init__.py                       |    59 -
 python/qemu/aqmp/aqmp_tui.py                       |   653 -
 python/qemu/aqmp/error.py                          |    50 -
 python/qemu/aqmp/events.py                         |   717 -
 python/qemu/aqmp/legacy.py                         |   177 -
 python/qemu/aqmp/message.py                        |   209 -
 python/qemu/aqmp/models.py                         |   146 -
 python/qemu/aqmp/protocol.py                       |  1048 -
 python/qemu/aqmp/py.typed                          |     0
 python/qemu/aqmp/qmp_client.py                     |   655 -
 python/qemu/aqmp/qmp_shell.py                      |   609 -
 python/qemu/aqmp/util.py                           |   217 -
 python/qemu/machine/machine.py                     |    20 +-
 python/qemu/machine/qtest.py                       |     2 +-
 python/qemu/qmp/README.rst                         |     9 -
 python/qemu/qmp/__init__.py                        |   447 +-
 python/qemu/qmp/error.py                           |    50 +
 python/qemu/qmp/events.py                          |   717 +
 python/qemu/qmp/legacy.py                          |   315 +
 python/qemu/qmp/message.py                         |   209 +
 python/qemu/qmp/models.py                          |   146 +
 python/qemu/qmp/protocol.py                        |  1048 +
 python/qemu/qmp/qmp_client.py                      |   655 +
 python/qemu/qmp/qmp_shell.py                       |   610 +
 python/qemu/qmp/qmp_tui.py                         |   652 +
 python/qemu/qmp/util.py                            |   219 +
 python/qemu/utils/__init__.py                      |     2 +-
 python/qemu/utils/qemu_ga_client.py                |     4 +-
 python/qemu/utils/qom.py                           |     2 +-
 python/qemu/utils/qom_common.py                    |     4 +-
 python/qemu/utils/qom_fuse.py                      |     2 +-
 python/setup.cfg                                   |    12 +-
 python/tests/protocol.py                           |    14 +-
 qapi/audio.json                                    |    26 +-
 qapi/block-core.json                               |   348 +-
 qapi/block-export.json                             |    65 +-
 qapi/block.json                                    |    25 +-
 qapi/char.json                                     |    10 +-
 qapi/common.json                                   |     2 -
 qapi/control.json                                  |    13 +-
 qapi/crypto.json                                   |   128 +-
 qapi/dump.json                                     |     6 +-
 qapi/job.json                                      |     1 -
 qapi/machine-target.json                           |     7 +-
 qapi/machine.json                                  |   130 +-
 qapi/meson.build                                   |    19 +-
 qapi/migration.json                                |   151 +-
 qapi/misc-target.json                              |    17 +-
 qapi/misc.json                                     |    39 +-
 qapi/net.json                                      |   261 +-
 qapi/pragma.json                                   |     3 +-
 qapi/qapi-schema.json                              |     2 +
 qapi/qdev.json                                     |     3 +-
 qapi/qmp-event.c                                   |     9 +-
 qapi/qobject-input-visitor.c                       |     2 +-
 qapi/qom.json                                      |    95 +-
 qapi/replay.json                                   |     1 -
 qapi/run-state.json                                |    38 +-
 qapi/sockets.json                                  |     8 +-
 qapi/stats.json                                    |   251 +
 qapi/ui.json                                       |   191 +-
 qapi/virtio.json                                   |   954 +
 qemu-edid.c                                        |     4 +
 qemu-img.c                                         |   105 +-
 qemu-io-cmds.c                                     |    20 +-
 qemu-io.c                                          |     5 +-
 qemu-nbd.c                                         |    22 +-
 qemu-options.hx                                    |   432 +-
 qga/channel-posix.c                                |    76 +-
 qga/commands-bsd.c                                 |   200 +
 qga/commands-common.h                              |    62 +
 qga/commands-linux.c                               |   286 +
 qga/commands-posix.c                               |  1646 +-
 qga/commands-win32.c                               |    78 +-
 qga/commands.c                                     |    19 +-
 qga/cutils.c                                       |    33 +
 qga/cutils.h                                       |     8 +
 qga/guest-agent-core.h                             |     2 +-
 qga/installer/qemu-ga.wxs                          |    83 +-
 qga/main.c                                         |   117 +-
 qga/meson.build                                    |    26 +-
 qga/qapi-schema.json                               |   231 +-
 qga/vss-win32/meson.build                          |     6 +-
 qga/vss-win32/requester.cpp                        |     4 +-
 qobject/qbool.c                                    |     5 +
 qobject/qdict.c                                    |     5 +
 qobject/qlist.c                                    |     5 +
 qobject/qnull.c                                    |     5 +
 qobject/qnum.c                                     |     5 +
 qobject/qstring.c                                  |     5 +
 qom/object.c                                       |    24 +-
 qom/object_interfaces.c                            |     1 +
 replay/replay-char.c                               |     2 +-
 replay/replay-events.c                             |    56 +-
 replay/replay-internal.h                           |    39 +-
 replay/replay-snapshot.c                           |     2 -
 replay/replay.c                                    |    84 +-
 roms/SLOF                                          |     2 +-
 roms/opensbi                                       |     2 +-
 roms/qboot                                         |     2 +-
 roms/seabios                                       |     2 +-
 roms/seabios-hppa                                  |     2 +-
 roms/skiboot                                       |     2 +-
 scripts/analyze-inclusions                         |     4 -
 scripts/archive-source.sh                          |     2 +-
 scripts/checkpatch.pl                              |    17 +-
 scripts/ci/org.centos/stream/8/x86_64/configure    |     7 +-
 scripts/ci/setup/build-environment.yml             |    29 +-
 scripts/clean-header-guards.pl                     |     4 +-
 scripts/clean-includes                             |     2 +-
 scripts/cocci-macro-file.h                         |     2 +-
 scripts/coverity-scan/COMPONENTS.md                |    15 +-
 scripts/coverity-scan/run-coverity-scan            |     2 +-
 scripts/cpu-x86-uarch-abi.py                       |     2 +-
 scripts/device-crash-test                          |    19 +-
 scripts/feature_to_c.sh                            |     1 +
 scripts/gensyscalls.sh                             |     2 +
 scripts/git-submodule.sh                           |    12 +-
 scripts/hxtool-conv.pl                             |   137 -
 scripts/kvm/vmxcap                                 |    17 +
 scripts/main.c                                     |     1 +
 scripts/meson-buildoptions.py                      |    89 +-
 scripts/meson-buildoptions.sh                      |   134 +-
 scripts/modinfo-generate.py                        |    49 +-
 scripts/mtest2make.py                              |     8 +-
 scripts/nsis.py                                    |    60 +-
 scripts/oss-fuzz/build.sh                          |    16 +-
 scripts/oss-fuzz/output_reproducer.py              |     2 +-
 scripts/qapi/common.py                             |     2 +-
 scripts/qapi/expr.py                               |     4 +-
 scripts/qapi/schema.py                             |     4 +
 scripts/qemu-binfmt-conf.sh                        |     9 +-
 scripts/qemu-stamp.py                              |    24 +
 scripts/qmp/qmp-shell                              |     2 +-
 scripts/qmp/qmp-shell-wrap                         |     2 +-
 scripts/render_block_graph.py                      |     4 +-
 scripts/simplebench/bench_block_job.py             |     5 +-
 scripts/symlink-install-tree.py                    |    33 +
 scripts/update-linux-headers.sh                    |     2 +-
 scripts/vmstate-static-checker.py                  |     3 +-
 scripts/xen-detect.c                               |   203 +
 scsi/pr-manager-helper.c                           |     2 +-
 scsi/qemu-pr-helper.c                              |    10 +-
 semihosting/arm-compat-semi.c                      |  1023 +-
 semihosting/common-semi.h                          |    39 -
 semihosting/config.c                               |    28 +-
 semihosting/console.c                              |   139 +-
 semihosting/guestfd.c                              |   160 +
 semihosting/meson.build                            |     6 +
 semihosting/syscalls.c                             |   978 +
 semihosting/uaccess.c                              |    91 +
 slirp                                              |     1 -
 softmmu/bootdevice.c                               |     3 +-
 softmmu/cpu-throttle.c                             |     1 -
 softmmu/cpu-timers.c                               |     1 -
 softmmu/cpus.c                                     |    31 +-
 softmmu/datadir.c                                  |    31 +-
 softmmu/device_tree.c                              |    58 +
 softmmu/dirtylimit.c                               |   601 +
 softmmu/globals.c                                  |     5 +-
 softmmu/icount.c                                   |    13 +-
 softmmu/main.c                                     |    33 +-
 softmmu/memory.c                                   |    74 +-
 softmmu/meson.build                                |     1 +
 softmmu/physmem.c                                  |    57 +-
 softmmu/qdev-monitor.c                             |     7 +-
 softmmu/qemu-seccomp.c                             |    13 +
 softmmu/qtest.c                                    |    53 +-
 softmmu/runstate.c                                 |    30 +-
 softmmu/trace-events                               |     7 +
 softmmu/vl.c                                       |   573 +-
 storage-daemon/qemu-storage-daemon.c               |    32 +-
 stubs/error-printf.c                               |     1 +
 stubs/get-vm-name.c                                |     2 +-
 stubs/icount.c                                     |     4 +
 stubs/meson.build                                  |     4 +-
 stubs/monitor-core.c                               |     1 -
 stubs/physmem.c                                    |    13 +
 stubs/replay-tools.c                               |     9 +-
 stubs/semihost.c                                   |     8 +-
 stubs/vfio-user-obj.c                              |     6 +
 stubs/xen-hw-stub.c                                |     3 +-
 subprojects/libvduse/include/atomic.h              |     1 +
 subprojects/libvduse/include/compiler.h            |     1 +
 subprojects/libvduse/libvduse.c                    |  1376 ++
 subprojects/libvduse/libvduse.h                    |   247 +
 subprojects/libvduse/linux-headers/linux           |     1 +
 subprojects/libvduse/meson.build                   |    10 +
 subprojects/libvduse/standard-headers/linux        |     1 +
 subprojects/libvfio-user                           |     1 +
 subprojects/libvhost-user/include/compiler.h       |     1 +
 subprojects/libvhost-user/libvhost-user.c          |    58 +-
 subprojects/libvhost-user/libvhost-user.h          |     9 +
 target/Kconfig                                     |     1 +
 target/alpha/cpu-param.h                           |     2 +-
 target/alpha/cpu.c                                 |    18 +
 target/alpha/cpu.h                                 |    11 +-
 target/alpha/helper.c                              |    12 +-
 target/alpha/mem_helper.c                          |     2 +-
 target/alpha/translate.c                           |    20 +-
 target/arm/a32.decode                              |    16 +-
 target/arm/arch_dump.c                             |     8 +-
 target/arm/common-semi-target.h                    |    62 +
 target/arm/cpregs.h                                |   496 +
 target/arm/cpu-param.h                             |    19 +-
 target/arm/cpu.c                                   |   307 +-
 target/arm/cpu.h                                   |  1228 +-
 target/arm/cpu64.c                                 |  1090 +-
 target/arm/cpu_tcg.c                               |   253 +-
 target/arm/crypto_helper.c                         |    38 +-
 target/arm/debug_helper.c                          |   810 +-
 target/arm/gdbstub.c                               |     7 +-
 target/arm/gdbstub64.c                             |     2 +-
 target/arm/helper-a64.c                            |     4 +-
 target/arm/helper-sme.h                            |   147 +
 target/arm/helper-sve.h                            |     4 +
 target/arm/helper.c                                |  5586 ++---
 target/arm/helper.h                                |    28 +-
 target/arm/hvf/hvf.c                               |    10 +-
 target/arm/internals.h                             |   392 +-
 target/arm/kvm-stub.c                              |     4 +-
 target/arm/kvm.c                                   |    15 +-
 target/arm/kvm64.c                                 |   119 +-
 target/arm/kvm_arm.h                               |     7 +-
 target/arm/m_helper.c                              |    91 +-
 target/arm/machine.c                               |    38 +-
 target/arm/meson.build                             |     5 +
 target/arm/mte_helper.c                            |    69 +-
 target/arm/mve_helper.c                            |     6 +-
 target/arm/neon_helper.c                           |     2 +-
 target/arm/op_helper.c                             |   170 +-
 target/arm/pauth_helper.c                          |     4 +-
 target/arm/ptw.c                                   |  2895 +++
 target/arm/sme-fa64.decode                         |    60 +
 target/arm/sme.decode                              |    88 +
 target/arm/sme_helper.c                            |  1201 +
 target/arm/sve.decode                              |    98 +-
 target/arm/sve_helper.c                            |   325 +-
 target/arm/sve_ldst_internal.h                     |   222 +
 target/arm/syndrome.h                              |    26 +-
 target/arm/t32.decode                              |    18 +-
 target/arm/tlb_helper.c                            |    80 +-
 target/arm/translate-a32.h                         |    19 +-
 target/arm/translate-a64.c                         |   818 +-
 target/arm/translate-a64.h                         |    96 +-
 target/arm/translate-m-nocp.c                      |    29 +-
 target/arm/translate-mve.c                         |     3 +-
 target/arm/translate-neon.c                        |    29 +-
 target/arm/translate-sme.c                         |   373 +
 target/arm/translate-sve.c                         |  6006 ++---
 target/arm/translate-vfp.c                         |   110 +-
 target/arm/translate.c                             |   768 +-
 target/arm/translate.h                             |   151 +-
 target/arm/vec_helper.c                            |    52 +-
 target/arm/vec_internal.h                          |    36 +-
 target/avr/cpu-qom.h                               |     6 +-
 target/avr/cpu.c                                   |    22 +-
 target/avr/cpu.h                                   |     4 +-
 target/avr/helper.c                                |    75 +-
 target/avr/translate.c                             |    44 +-
 target/cris/cpu-param.h                            |     2 +-
 target/cris/cpu.c                                  |    19 +
 target/cris/helper.c                               |     2 +-
 target/cris/translate.c                            |    18 +-
 target/hexagon/attribs.h                           |     2 +-
 target/hexagon/attribs_def.h.inc                   |    38 +-
 target/hexagon/cpu.c                               |    19 +-
 target/hexagon/decode.c                            |    13 +-
 target/hexagon/gdbstub.c                           |     1 -
 target/hexagon/gen_tcg.h                           |    10 +-
 target/hexagon/gen_tcg_funcs.py                    |    11 +-
 target/hexagon/genptr.c                            |    43 +-
 target/hexagon/helper.h                            |     1 +
 target/hexagon/hex_arch_types.h                    |     4 +-
 target/hexagon/hex_common.py                       |     3 +-
 target/hexagon/hex_regs.h                          |     4 +-
 target/hexagon/imported/encode_pp.def              |    23 -
 target/hexagon/imported/ldst.idef                  |   122 +-
 target/hexagon/imported/subinsns.idef              |    72 +-
 target/hexagon/macros.h                            |    45 +-
 target/hexagon/op_helper.c                         |    32 +-
 target/hexagon/translate.c                         |    54 +-
 target/hppa/cpu-param.h                            |     2 +-
 target/hppa/cpu.c                                  |    39 +-
 target/hppa/cpu.h                                  |     3 +-
 target/hppa/helper.c                               |     6 +-
 target/hppa/op_helper.c                            |     6 +-
 target/hppa/translate.c                            |    35 +-
 target/i386/arch_dump.c                            |    30 +-
 target/i386/cpu-param.h                            |     8 +-
 target/i386/cpu-sysemu.c                           |     2 +-
 target/i386/cpu.c                                  |   455 +-
 target/i386/cpu.h                                  |   165 +-
 target/i386/gdbstub.c                              |     4 +-
 target/i386/hax/hax-accel-ops.h                    |     6 +-
 target/i386/hax/hax-all.c                          |     1 -
 target/i386/hax/hax-mem.c                          |    10 +-
 target/i386/helper.c                               |    39 +-
 target/i386/helper.h                               |    10 +-
 target/i386/hvf/hvf.c                              |    27 +-
 target/i386/hvf/vmcs.h                             |     5 +-
 target/i386/hvf/vmx.h                              |     2 +-
 target/i386/hvf/x86.c                              |     1 -
 target/i386/hvf/x86_cpuid.c                        |     8 +-
 target/i386/hvf/x86_decode.c                       |     1 -
 target/i386/hvf/x86_descr.c                        |     1 -
 target/i386/hvf/x86_emu.c                          |     1 -
 target/i386/hvf/x86_flags.c                        |     1 -
 target/i386/hvf/x86_mmu.c                          |     1 -
 target/i386/hvf/x86_task.c                         |     1 -
 target/i386/hvf/x86hvf.c                           |     1 -
 target/i386/kvm/hyperv-proto.h                     |    46 +-
 target/i386/kvm/hyperv-stub.c                      |     6 +
 target/i386/kvm/hyperv.c                           |    56 +-
 target/i386/kvm/kvm-cpu.c                          |     2 +-
 target/i386/kvm/kvm-stub.c                         |     5 +
 target/i386/kvm/kvm.c                              |   601 +-
 target/i386/kvm/kvm_i386.h                         |    14 +
 target/i386/kvm/sev-stub.c                         |     1 -
 target/i386/machine.c                              |    58 +
 target/i386/nvmm/nvmm-accel-ops.h                  |     6 +-
 target/i386/nvmm/nvmm-all.c                        |     9 +-
 target/i386/ops_sse.h                              |  2444 +-
 target/i386/ops_sse_header.h                       |   410 +-
 target/i386/sev.c                                  |    42 +-
 target/i386/sev.h                                  |     4 +-
 target/i386/tcg/bpt_helper.c                       |     2 +-
 target/i386/tcg/cc_helper.c                        |    41 -
 target/i386/tcg/decode-new.c.inc                   |  1844 ++
 target/i386/tcg/decode-new.h                       |   252 +
 target/i386/tcg/emit.c.inc                         |  2300 ++
 target/i386/tcg/excp_helper.c                      |    44 +-
 target/i386/tcg/fpu_helper.c                       |   216 +-
 target/i386/tcg/helper-tcg.h                       |    52 +-
 target/i386/tcg/misc_helper.c                      |     6 +-
 target/i386/tcg/seg_helper.c                       |     6 +-
 target/i386/tcg/sysemu/excp_helper.c               |   720 +-
 target/i386/tcg/sysemu/misc_helper.c               |    12 +-
 target/i386/tcg/sysemu/svm_helper.c                |   236 +-
 target/i386/tcg/tcg-cpu.c                          |    25 +-
 target/i386/tcg/translate.c                        |  3087 +--
 target/i386/tcg/user/excp_helper.c                 |     7 +
 target/i386/whpx/whpx-accel-ops.c                  |     1 +
 target/i386/whpx/whpx-accel-ops.h                  |     7 +-
 target/i386/whpx/whpx-all.c                        |   876 +-
 target/i386/whpx/whpx-apic.c                       |     1 -
 target/i386/whpx/whpx-internal.h                   |    39 +-
 target/loongarch/Kconfig                           |     2 +
 target/loongarch/README                            |    52 +
 target/loongarch/constant_timer.c                  |    64 +
 target/loongarch/cpu-csr.h                         |   208 +
 target/loongarch/cpu-param.h                       |    18 +
 target/loongarch/cpu.c                             |   774 +
 target/loongarch/cpu.h                             |   423 +
 target/loongarch/csr_helper.c                      |    89 +
 target/loongarch/disas.c                           |   757 +
 target/loongarch/fpu_helper.c                      |   879 +
 target/loongarch/gdbstub.c                         |   104 +
 target/loongarch/helper.h                          |   132 +
 target/loongarch/insn_trans/trans_arith.c.inc      |   304 +
 target/loongarch/insn_trans/trans_atomic.c.inc     |   113 +
 target/loongarch/insn_trans/trans_bit.c.inc        |   220 +
 target/loongarch/insn_trans/trans_branch.c.inc     |    83 +
 target/loongarch/insn_trans/trans_extra.c.inc      |   101 +
 target/loongarch/insn_trans/trans_farith.c.inc     |   135 +
 target/loongarch/insn_trans/trans_fcmp.c.inc       |    63 +
 target/loongarch/insn_trans/trans_fcnv.c.inc       |    33 +
 target/loongarch/insn_trans/trans_fmemory.c.inc    |   175 +
 target/loongarch/insn_trans/trans_fmov.c.inc       |   181 +
 target/loongarch/insn_trans/trans_memory.c.inc     |   229 +
 target/loongarch/insn_trans/trans_privileged.c.inc |   502 +
 target/loongarch/insn_trans/trans_shift.c.inc      |   106 +
 target/loongarch/insns.decode                      |   486 +
 target/loongarch/internals.h                       |    61 +
 target/loongarch/iocsr_helper.c                    |    70 +
 target/loongarch/machine.c                         |   102 +
 target/loongarch/meson.build                       |    30 +
 target/loongarch/op_helper.c                       |   139 +
 target/loongarch/tlb_helper.c                      |   764 +
 target/loongarch/translate.c                       |   279 +
 target/loongarch/translate.h                       |    46 +
 target/m68k/cpu-param.h                            |     2 +-
 target/m68k/cpu.c                                  |    40 +-
 target/m68k/cpu.h                                  |    22 +-
 target/m68k/helper.c                               |     2 +-
 target/m68k/helper.h                               |    14 +-
 target/m68k/m68k-semi.c                            |   407 +-
 target/m68k/meson.build                            |     6 +-
 target/m68k/op_helper.c                            |   180 +-
 target/m68k/qregs.def                              |    10 -
 target/m68k/qregs.h.inc                            |    10 +
 target/m68k/translate.c                            |   410 +-
 target/meson.build                                 |     1 +
 target/microblaze/cpu-param.h                      |     2 +-
 target/microblaze/cpu.c                            |    21 +-
 target/microblaze/cpu.h                            |     8 +-
 target/microblaze/helper.c                         |     2 +-
 target/microblaze/translate.c                      |    19 +-
 target/mips/TODO                                   |    51 -
 target/mips/cpu-defs.c.inc                         |    28 +
 target/mips/cpu-param.h                            |     2 +-
 target/mips/cpu.c                                  |    21 +-
 target/mips/cpu.h                                  |     8 +-
 target/mips/kvm.c                                  |     5 +-
 target/mips/mips-defs.h                            |     1 +
 target/mips/tcg/exception.c                        |     3 +-
 target/mips/tcg/lmmi_helper.c                      |     2 +-
 target/mips/tcg/meson.build                        |     2 +
 target/mips/tcg/micromips_translate.c.inc          |    12 +-
 target/mips/tcg/mips16e_translate.c.inc            |     4 +-
 target/mips/tcg/msa_helper.c                       |    66 +-
 target/mips/tcg/msa_translate.c                    |    29 +-
 target/mips/tcg/nanomips_translate.c.inc           |    41 +-
 target/mips/tcg/octeon.decode                      |    41 +
 target/mips/tcg/octeon_translate.c                 |   201 +
 target/mips/tcg/sysemu/cp0_helper.c                |     3 +-
 target/mips/tcg/sysemu/mips-semi.c                 |   457 +-
 target/mips/tcg/sysemu/special_helper.c            |     2 +-
 target/mips/tcg/sysemu/tlb_helper.c                |     5 +
 target/mips/tcg/sysemu_helper.h.inc                |     2 -
 target/mips/tcg/tcg-internal.h                     |    22 +-
 target/mips/tcg/translate.c                        |    71 +-
 target/mips/tcg/translate.h                        |     5 +
 target/nios2/cpu-param.h                           |     2 +-
 target/nios2/cpu.c                                 |   234 +-
 target/nios2/cpu.h                                 |   258 +-
 target/nios2/helper.c                              |   363 +-
 target/nios2/helper.h                              |     5 +
 target/nios2/meson.build                           |     9 +-
 target/nios2/mmu.c                                 |    78 +-
 target/nios2/nios2-semi.c                          |   397 +-
 target/nios2/op_helper.c                           |    88 +
 target/nios2/translate.c                           |   770 +-
 target/openrisc/cpu-param.h                        |     2 +-
 target/openrisc/cpu.c                              |    33 +-
 target/openrisc/cpu.h                              |     3 +
 target/openrisc/exception.c                        |     2 +-
 target/openrisc/exception.h                        |     2 +-
 target/openrisc/exception_helper.c                 |     3 +-
 target/openrisc/interrupt.c                        |     4 +-
 target/openrisc/mmu.c                              |     8 +-
 target/openrisc/sys_helper.c                       |    31 +-
 target/openrisc/translate.c                        |    23 +-
 target/ppc/arch_dump.c                             |    20 +-
 target/ppc/cpu-models.c                            |    17 +-
 target/ppc/cpu-models.h                            |    14 +-
 target/ppc/cpu-param.h                             |     2 +-
 target/ppc/cpu-qom.h                               |     6 +-
 target/ppc/cpu.c                                   |     8 +-
 target/ppc/cpu.h                                   |   409 +-
 target/ppc/cpu_init.c                              |   382 +-
 target/ppc/dfp_helper.c                            |    96 +-
 target/ppc/excp_helper.c                           |  1011 +-
 target/ppc/fpu_helper.c                            |   839 +-
 target/ppc/gdbstub.c                               |     6 +-
 target/ppc/helper.h                                |   310 +-
 target/ppc/helper_regs.c                           |    25 +-
 target/ppc/insn32.decode                           |   291 +-
 target/ppc/insn64.decode                           |    79 +
 target/ppc/int_helper.c                            |   624 +-
 target/ppc/internal.h                              |    27 +-
 target/ppc/kvm.c                                   |    35 +-
 target/ppc/machine.c                               |     7 +-
 target/ppc/mem_helper.c                            |    27 +-
 target/ppc/misc_helper.c                           |    13 +-
 target/ppc/mmu-book3s-v3.c                         |     5 +
 target/ppc/mmu-book3s-v3.h                         |    15 +
 target/ppc/mmu-hash64.c                            |    41 +-
 target/ppc/mmu-radix64.c                           |   120 +-
 target/ppc/mmu_common.c                            |    40 +-
 target/ppc/mmu_helper.c                            |   160 +-
 target/ppc/monitor.c                               |     9 +
 target/ppc/power8-pmu-regs.c.inc                   |    10 +-
 target/ppc/power8-pmu.c                            |    74 +-
 target/ppc/power8-pmu.h                            |     7 +-
 target/ppc/timebase_helper.c                       |     6 +-
 target/ppc/trace-events                            |     2 +-
 target/ppc/translate.c                             |   775 +-
 target/ppc/translate/fixedpoint-impl.c.inc         |    92 +-
 target/ppc/translate/fp-impl.c.inc                 |   279 +-
 target/ppc/translate/fp-ops.c.inc                  |    12 -
 target/ppc/translate/processor-ctrl-impl.c.inc     |   105 +
 target/ppc/translate/storage-ctrl-impl.c.inc       |   250 +
 target/ppc/translate/vmx-impl.c.inc                |   585 +-
 target/ppc/translate/vmx-ops.c.inc                 |    28 +-
 target/ppc/translate/vsx-impl.c.inc                |   637 +-
 target/ppc/translate/vsx-ops.c.inc                 |    25 -
 target/riscv/arch_dump.c                           |     6 +-
 target/riscv/bitmanip_helper.c                     |    80 +
 target/riscv/common-semi-target.h                  |    50 +
 target/riscv/cpu-param.h                           |     2 +-
 target/riscv/cpu.c                                 |   444 +-
 target/riscv/cpu.h                                 |   164 +-
 target/riscv/cpu_bits.h                            |   145 +-
 target/riscv/cpu_helper.c                          |   454 +-
 target/riscv/crypto_helper.c                       |   302 +
 target/riscv/csr.c                                 |  1840 +-
 target/riscv/debug.c                               |   731 +
 target/riscv/debug.h                               |   137 +
 target/riscv/gdbstub.c                             |    36 +-
 target/riscv/helper.h                              |    42 +-
 target/riscv/insn16.decode                         |     7 +-
 target/riscv/insn32.decode                         |   110 +-
 target/riscv/insn_trans/trans_privileged.c.inc     |     7 +-
 target/riscv/insn_trans/trans_rvb.c.inc            |   116 +-
 target/riscv/insn_trans/trans_rvh.c.inc            |     2 +
 target/riscv/insn_trans/trans_rvi.c.inc            |    26 +-
 target/riscv/insn_trans/trans_rvk.c.inc            |   391 +
 target/riscv/insn_trans/trans_rvm.c.inc            |    18 +-
 target/riscv/insn_trans/trans_rvv.c.inc            |   227 +-
 target/riscv/instmap.h                             |    45 +
 target/riscv/internals.h                           |     7 +-
 target/riscv/kvm.c                                 |     5 +-
 target/riscv/machine.c                             |    80 +-
 target/riscv/meson.build                           |    10 +-
 target/riscv/monitor.c                             |    11 +-
 target/riscv/op_helper.c                           |    13 +-
 target/riscv/pmp.c                                 |    29 +-
 target/riscv/pmp.h                                 |     8 +-
 target/riscv/pmu.c                                 |   453 +
 target/riscv/pmu.h                                 |    36 +
 target/riscv/sbi_ecall_interface.h                 |     4 +-
 target/riscv/time_helper.c                         |   114 +
 target/riscv/time_helper.h                         |    30 +
 target/riscv/translate.c                           |   105 +-
 target/riscv/vector_helper.c                       |  1822 +-
 target/rx/cpu.c                                    |    21 +-
 target/rx/cpu.h                                    |     2 +
 target/rx/gdbstub.c                                |     1 -
 target/rx/op_helper.c                              |    27 +-
 target/rx/translate.c                              |    87 +-
 target/s390x/arch_dump.c                           |   270 +-
 target/s390x/cpu-param.h                           |     2 +-
 target/s390x/cpu.c                                 |    10 +-
 target/s390x/cpu.h                                 |     1 +
 target/s390x/cpu_features_def.h.inc                |     3 +-
 target/s390x/cpu_models.c                          |    49 +-
 target/s390x/cpu_models.h                          |     4 +-
 target/s390x/cpu_models_sysemu.c                   |     1 -
 target/s390x/gen-features.c                        |    28 +-
 target/s390x/helper.c                              |     1 -
 target/s390x/helper.h                              |    13 +
 target/s390x/ioinst.c                              |     4 +-
 target/s390x/kvm/kvm.c                             |    30 +-
 target/s390x/kvm/kvm_s390x.h                       |     2 +
 target/s390x/kvm/meson.build                       |     2 +
 target/s390x/kvm/stubs.c                           |    12 +
 target/s390x/s390x-internal.h                      |    12 +-
 target/s390x/tcg/cc_helper.c                       |     7 +
 target/s390x/tcg/crypto_helper.c                   |   259 +
 target/s390x/tcg/excp_helper.c                     |    26 +-
 target/s390x/tcg/fpu_helper.c                      |     2 +-
 target/s390x/tcg/insn-data.def                     |  1422 --
 target/s390x/tcg/insn-data.h.inc                   |  1448 ++
 target/s390x/tcg/insn-format.def                   |    81 -
 target/s390x/tcg/insn-format.h.inc                 |    81 +
 target/s390x/tcg/mem_helper.c                      |     4 -
 target/s390x/tcg/misc_helper.c                     |     9 +-
 target/s390x/tcg/tcg_s390x.h                       |    12 +-
 target/s390x/tcg/translate.c                       |   115 +-
 target/s390x/tcg/translate_vx.c.inc                |   471 +-
 target/s390x/tcg/vec.h                             |     2 +-
 target/s390x/tcg/vec_fpu_helper.c                  |    36 +-
 target/s390x/tcg/vec_helper.c                      |     2 -
 target/s390x/tcg/vec_int_helper.c                  |    56 +-
 target/s390x/tcg/vec_string_helper.c               |   100 +-
 target/sh4/cpu-param.h                             |     2 +-
 target/sh4/cpu.c                                   |    34 +-
 target/sh4/cpu.h                                   |    65 +-
 target/sh4/helper.c                                |     6 +-
 target/sh4/op_helper.c                             |     5 +-
 target/sh4/translate.c                             |   112 +-
 target/sparc/cpu-param.h                           |     2 +-
 target/sparc/cpu.c                                 |    11 +-
 target/sparc/cpu.h                                 |    14 +-
 target/sparc/mmu_helper.c                          |     8 +-
 target/sparc/translate.c                           |    19 +-
 target/sparc/vis_helper.c                          |     4 +-
 target/tricore/cpu-param.h                         |     2 +-
 target/tricore/cpu.c                               |    22 +-
 target/tricore/cpu.h                               |     1 +
 target/tricore/csfr.def                            |   125 -
 target/tricore/csfr.h.inc                          |   125 +
 target/tricore/gdbstub.c                           |     1 -
 target/tricore/op_helper.c                         |     8 +-
 target/tricore/translate.c                         |    23 +-
 target/xtensa/core-de233_fpu.c                     |     1 -
 target/xtensa/core-de233_fpu/core-isa.h            |     7 +-
 target/xtensa/core-de233_fpu/core-matmap.h         |     4 +-
 target/xtensa/core-dsp3400.c                       |     1 -
 target/xtensa/core-dsp3400/core-isa.h              |     8 +-
 target/xtensa/core-dsp3400/core-matmap.h           |     4 +-
 target/xtensa/core-lx106.c                         |    51 +
 target/xtensa/core-lx106/core-isa.h                |   470 +
 target/xtensa/core-lx106/gdb-config.c.inc          |    83 +
 target/xtensa/core-lx106/xtensa-modules.c.inc      |  7668 +++++++
 target/xtensa/core-test_mmuhifi_c3.c               |     1 -
 target/xtensa/cores.list                           |     1 +
 target/xtensa/cpu-param.h                          |     2 +-
 target/xtensa/cpu.c                                |    33 +
 target/xtensa/cpu.h                                |    16 +-
 target/xtensa/helper.c                             |     6 +-
 target/xtensa/import_core.sh                       |     1 -
 target/xtensa/op_helper.c                          |     7 +-
 target/xtensa/overlay_tool.h                       |     2 +-
 target/xtensa/translate.c                          |   243 +-
 tcg/aarch64/tcg-target.c.inc                       |    37 +-
 tcg/arm/tcg-target.c.inc                           |     4 +-
 tcg/i386/tcg-target.c.inc                          |     4 +-
 tcg/loongarch64/tcg-target.c.inc                   |    48 +-
 tcg/loongarch64/tcg-target.h                       |     9 +-
 tcg/mips/tcg-target.c.inc                          |     2 +-
 tcg/ppc/tcg-target.c.inc                           |   161 +-
 tcg/ppc/tcg-target.h                               |     4 +-
 tcg/region.c                                       |    10 +-
 tcg/riscv/tcg-target.c.inc                         |     4 +-
 tcg/sparc/tcg-target-con-set.h                     |    32 -
 tcg/sparc/tcg-target-con-str.h                     |    23 -
 tcg/sparc/tcg-target.c.inc                         |  2069 --
 tcg/sparc/tcg-target.h                             |   172 -
 tcg/sparc64/tcg-target-con-set.h                   |    22 +
 tcg/sparc64/tcg-target-con-str.h                   |    20 +
 tcg/sparc64/tcg-target.c.inc                       |  1938 ++
 tcg/sparc64/tcg-target.h                           |   161 +
 tcg/tcg-internal.h                                 |     2 +-
 tcg/tcg-op.c                                       |    34 +-
 tcg/tcg.c                                          |   341 +-
 tcg/tci.c                                          |     1 -
 tcg/tci/tcg-target.c.inc                           |     7 -
 tcg/tci/tcg-target.h                               |     5 -
 tests/Makefile.include                             |   117 +-
 tests/avocado/acpi-bits.py                         |   398 +
 tests/avocado/acpi-bits/bits-config/bits-cfg.txt   |    18 +
 tests/avocado/acpi-bits/bits-tests/smbios.py2      |  2430 ++
 tests/avocado/acpi-bits/bits-tests/testacpi.py2    |   283 +
 tests/avocado/acpi-bits/bits-tests/testcpuid.py2   |    83 +
 tests/avocado/avocado_qemu/__init__.py             |    48 +-
 tests/avocado/boot_linux.py                        |    15 +-
 tests/avocado/boot_linux_console.py                |    93 +-
 tests/avocado/info_usernet.py                      |     4 +
 tests/avocado/machine_aarch64_virt.py              |    95 +
 tests/avocado/machine_arm_canona1100.py            |     4 +-
 tests/avocado/machine_aspeed.py                    |   272 +
 tests/avocado/machine_microblaze.py                |     4 +-
 tests/avocado/machine_s390_ccw_virtio.py           |     1 +
 tests/avocado/machine_sparc64_sun4u.py             |     4 +-
 tests/avocado/migration.py                         |     4 +-
 tests/avocado/ppc_bamboo.py                        |     1 +
 tests/avocado/ppc_mpc8544ds.py                     |     6 +-
 tests/avocado/ppc_virtex_ml507.py                  |     6 +-
 tests/avocado/replay_kernel.py                     |    40 +-
 tests/avocado/replay_linux.py                      |    87 +-
 tests/avocado/virtio_check_params.py               |     1 -
 tests/avocado/virtio_version.py                    |     1 -
 tests/avocado/vnc.py                               |    64 +
 tests/bench/benchmark-crypto-akcipher.c            |   137 +
 tests/bench/meson.build                            |     1 +
 tests/bench/test_akcipher_keys.inc                 |   537 +
 tests/check-block.sh                               |    26 -
 tests/data/acpi/pc/DSDT                            |   Bin 6002 -> 6458 bytes
 tests/data/acpi/pc/DSDT.acpierst                   |   Bin 5969 -> 6418 bytes
 tests/data/acpi/pc/DSDT.acpihmat                   |   Bin 7327 -> 7783 bytes
 tests/data/acpi/pc/DSDT.bridge                     |   Bin 8668 -> 9532 bytes
 tests/data/acpi/pc/DSDT.cphp                       |   Bin 6466 -> 6922 bytes
 tests/data/acpi/pc/DSDT.dimmpxm                    |   Bin 7656 -> 8112 bytes
 tests/data/acpi/pc/DSDT.hpbridge                   |   Bin 5969 -> 6418 bytes
 tests/data/acpi/pc/DSDT.hpbrroot                   |   Bin 3084 -> 3064 bytes
 tests/data/acpi/pc/DSDT.ipmikcs                    |   Bin 6074 -> 6530 bytes
 tests/data/acpi/pc/DSDT.memhp                      |   Bin 7361 -> 7817 bytes
 tests/data/acpi/pc/DSDT.nohpet                     |   Bin 5860 -> 6316 bytes
 tests/data/acpi/pc/DSDT.numamem                    |   Bin 6008 -> 6464 bytes
 tests/data/acpi/pc/DSDT.roothp                     |   Bin 6210 -> 6656 bytes
 tests/data/acpi/pc/SSDT.dimmpxm                    |   Bin 734 -> 1815 bytes
 tests/data/acpi/q35/APIC.acpihmat-noinitiator      |   Bin 0 -> 144 bytes
 tests/data/acpi/q35/APIC.core-count2               |   Bin 0 -> 2478 bytes
 tests/data/acpi/q35/CEDT.cxl                       |   Bin 0 -> 184 bytes
 tests/data/acpi/q35/DSDT                           |   Bin 8289 -> 8310 bytes
 tests/data/acpi/q35/DSDT.acpierst                  |   Bin 8306 -> 8327 bytes
 tests/data/acpi/q35/DSDT.acpihmat                  |   Bin 9614 -> 9635 bytes
 tests/data/acpi/q35/DSDT.acpihmat-noinitiator      |   Bin 0 -> 8589 bytes
 tests/data/acpi/q35/DSDT.applesmc                  |   Bin 0 -> 8356 bytes
 tests/data/acpi/q35/DSDT.bridge                    |   Bin 11003 -> 11439 bytes
 tests/data/acpi/q35/DSDT.core-count2               |   Bin 0 -> 32450 bytes
 tests/data/acpi/q35/DSDT.cphp                      |   Bin 8753 -> 8774 bytes
 tests/data/acpi/q35/DSDT.cxl                       |   Bin 0 -> 9636 bytes
 tests/data/acpi/q35/DSDT.dimmpxm                   |   Bin 9943 -> 9964 bytes
 tests/data/acpi/q35/DSDT.ipmibt                    |   Bin 8364 -> 8385 bytes
 tests/data/acpi/q35/DSDT.ipmismbus                 |   Bin 0 -> 8398 bytes
 tests/data/acpi/q35/DSDT.ivrs                      |   Bin 8306 -> 8327 bytes
 tests/data/acpi/q35/DSDT.memhp                     |   Bin 9648 -> 9669 bytes
 tests/data/acpi/q35/DSDT.mmio64                    |   Bin 9419 -> 9440 bytes
 tests/data/acpi/q35/DSDT.multi-bridge              |   Bin 8583 -> 8630 bytes
 tests/data/acpi/q35/DSDT.nohpet                    |   Bin 8147 -> 8168 bytes
 tests/data/acpi/q35/DSDT.numamem                   |   Bin 8295 -> 8316 bytes
 tests/data/acpi/q35/DSDT.pvpanic-isa               |   Bin 0 -> 8411 bytes
 tests/data/acpi/q35/DSDT.tis.tpm12                 |   Bin 8900 -> 8916 bytes
 tests/data/acpi/q35/DSDT.tis.tpm2                  |   Bin 8921 -> 8942 bytes
 tests/data/acpi/q35/DSDT.viot                      |   Bin 9398 -> 9419 bytes
 tests/data/acpi/q35/DSDT.xapic                     |   Bin 35652 -> 35673 bytes
 tests/data/acpi/q35/FACP.core-count2               |   Bin 0 -> 244 bytes
 tests/data/acpi/q35/HMAT.acpihmat-noinitiator      |   Bin 0 -> 288 bytes
 tests/data/acpi/q35/SRAT.acpihmat-noinitiator      |   Bin 0 -> 312 bytes
 tests/data/acpi/q35/SSDT.dimmpxm                   |   Bin 734 -> 1815 bytes
 tests/data/acpi/q35/VIOT.viot                      |   Bin 112 -> 112 bytes
 tests/data/acpi/virt/APIC                          |   Bin 168 -> 172 bytes
 tests/data/acpi/virt/APIC.acpihmatvirt             |   Bin 0 -> 412 bytes
 tests/data/acpi/virt/APIC.memhp                    |   Bin 168 -> 172 bytes
 tests/data/acpi/virt/APIC.numamem                  |   Bin 168 -> 172 bytes
 tests/data/acpi/virt/DSDT.acpihmatvirt             |   Bin 0 -> 5282 bytes
 tests/data/acpi/virt/FACP                          |   Bin 268 -> 276 bytes
 tests/data/acpi/virt/FACP.memhp                    |   Bin 268 -> 276 bytes
 tests/data/acpi/virt/FACP.numamem                  |   Bin 268 -> 276 bytes
 tests/data/acpi/virt/GTDT                          |   Bin 96 -> 96 bytes
 tests/data/acpi/virt/GTDT.memhp                    |   Bin 96 -> 96 bytes
 tests/data/acpi/virt/GTDT.numamem                  |   Bin 96 -> 96 bytes
 tests/data/acpi/virt/HMAT.acpihmatvirt             |   Bin 0 -> 288 bytes
 tests/data/acpi/virt/PPTT.acpihmatvirt             |   Bin 0 -> 196 bytes
 tests/data/acpi/virt/SRAT.acpihmatvirt             |   Bin 0 -> 240 bytes
 tests/data/acpi/virt/SSDT.memhp                    |   Bin 736 -> 1817 bytes
 tests/data/test-qga-config                         |     2 +-
 tests/docker/Makefile.include                      |   150 +-
 tests/docker/common.rc                             |     6 +-
 tests/docker/docker.py                             |    95 +-
 tests/docker/dockerfiles/alpine.docker             |    14 +-
 tests/docker/dockerfiles/centos8.docker            |    11 +-
 .../dockerfiles/debian-all-test-cross.docker       |    20 +-
 tests/docker/dockerfiles/debian-alpha-cross.docker |    12 +-
 tests/docker/dockerfiles/debian-amd64-cross.docker |   182 +-
 tests/docker/dockerfiles/debian-amd64.docker       |   199 +-
 tests/docker/dockerfiles/debian-arm64-cross.docker |   229 +-
 tests/docker/dockerfiles/debian-armel-cross.docker |   184 +-
 tests/docker/dockerfiles/debian-armhf-cross.docker |   190 +-
 .../debian-hexagon-cross.d/build-toolchain.sh      |   141 +
 .../docker/dockerfiles/debian-hexagon-cross.docker |    21 +-
 .../build-toolchain.sh                             |   141 -
 tests/docker/dockerfiles/debian-hppa-cross.docker  |    12 +-
 .../dockerfiles/debian-loongarch-cross.docker      |    27 +
 tests/docker/dockerfiles/debian-m68k-cross.docker  |    12 +-
 tests/docker/dockerfiles/debian-mips-cross.docker  |    38 +-
 .../docker/dockerfiles/debian-mips64-cross.docker  |    12 +-
 .../dockerfiles/debian-mips64el-cross.docker       |   183 +-
 .../docker/dockerfiles/debian-mipsel-cross.docker  |   185 +-
 tests/docker/dockerfiles/debian-native.docker      |     2 +-
 .../dockerfiles/debian-powerpc-test-cross.docker   |    12 +-
 .../docker/dockerfiles/debian-ppc64el-cross.docker |   184 +-
 .../docker/dockerfiles/debian-riscv64-cross.docker |     3 +
 .../dockerfiles/debian-riscv64-test-cross.docker   |    10 +-
 tests/docker/dockerfiles/debian-s390x-cross.docker |   225 +-
 tests/docker/dockerfiles/debian-sh4-cross.docker   |    12 +-
 .../docker/dockerfiles/debian-sparc64-cross.docker |    12 +-
 tests/docker/dockerfiles/debian-toolchain.docker   |     5 +-
 .../docker/dockerfiles/debian-tricore-cross.docker |     1 -
 tests/docker/dockerfiles/debian10.docker           |    37 -
 tests/docker/dockerfiles/debian11.docker           |    18 -
 tests/docker/dockerfiles/empty.docker              |     8 -
 tests/docker/dockerfiles/fedora-i386-cross.docker  |     3 +-
 tests/docker/dockerfiles/fedora-win32-cross.docker |   139 +-
 tests/docker/dockerfiles/fedora-win64-cross.docker |   138 +-
 tests/docker/dockerfiles/fedora.docker             |   228 +-
 tests/docker/dockerfiles/opensuse-leap.docker      |    16 +-
 tests/docker/dockerfiles/ubuntu1804.docker         |   145 -
 tests/docker/dockerfiles/ubuntu2004.docker         |   234 +-
 tests/docker/run                                   |     2 +-
 tests/docker/test-mingw                            |    16 +-
 tests/fp/fp-bench.c                                |     3 +-
 tests/fp/fp-test.c                                 |     3 +-
 tests/fp/meson.build                               |     5 +-
 tests/fp/platform.h                                |     4 +-
 tests/guest-debug/run-test.py                      |    11 +-
 tests/lcitool/libvirt-ci                           |     2 +-
 tests/lcitool/projects/qemu.yml                    |    11 +-
 tests/lcitool/refresh                              |   204 +-
 tests/meson.build                                  |     4 +-
 tests/migration/aarch64/a-b-kernel.S               |     3 +-
 tests/migration/aarch64/a-b-kernel.h               |    10 +-
 tests/migration/guestperf/engine.py                |     1 -
 tests/migration/i386/a-b-bootblock.S               |     1 +
 tests/migration/i386/a-b-bootblock.h               |    12 +-
 tests/migration/stress.c                           |     2 +-
 tests/qapi-schema/alternate-array.err              |     2 -
 tests/qapi-schema/alternate-array.json             |     2 -
 tests/qapi-schema/alternate-array.out              |    18 +
 tests/qapi-schema/alternate-conflict-lists.err     |     2 +
 tests/qapi-schema/alternate-conflict-lists.json    |     6 +
 tests/qapi-schema/alternate-conflict-lists.out     |     0
 tests/qapi-schema/meson.build                      |    25 +-
 tests/qapi-schema/qapi-schema-test.json            |     1 +
 tests/qapi-schema/qapi-schema-test.out             |     4 +
 tests/qemu-iotests/030                             |    85 +-
 tests/qemu-iotests/040                             |    53 +-
 tests/qemu-iotests/051                             |     3 +-
 tests/qemu-iotests/051.out                         |     2 +-
 tests/qemu-iotests/051.pc.out                      |     2 +-
 tests/qemu-iotests/056                             |     2 +-
 tests/qemu-iotests/065                             |    24 +-
 tests/qemu-iotests/108                             |   264 +-
 tests/qemu-iotests/108.out                         |    81 +
 tests/qemu-iotests/131                             |    35 +-
 tests/qemu-iotests/131.out                         |    13 +
 tests/qemu-iotests/149                             |     6 +-
 tests/qemu-iotests/151                             |   227 +-
 tests/qemu-iotests/151.out                         |     4 +-
 tests/qemu-iotests/163                             |     5 +-
 tests/qemu-iotests/172.out                         |    76 +
 tests/qemu-iotests/205                             |     4 +-
 tests/qemu-iotests/216                             |    12 +-
 tests/qemu-iotests/218                             |     5 +-
 tests/qemu-iotests/223                             |    16 +
 tests/qemu-iotests/223.out                         |    51 +-
 tests/qemu-iotests/224                             |     4 +-
 tests/qemu-iotests/227.out                         |     4 +-
 tests/qemu-iotests/242                             |     6 +-
 tests/qemu-iotests/245                             |    17 +-
 tests/qemu-iotests/255                             |     4 +-
 tests/qemu-iotests/258                             |    11 +-
 tests/qemu-iotests/264                             |     2 +-
 tests/qemu-iotests/298                             |    17 +-
 tests/qemu-iotests/303                             |     6 +-
 tests/qemu-iotests/307.out                         |     4 +-
 tests/qemu-iotests/310                             |    22 +-
 tests/qemu-iotests/common.config                   |    41 -
 tests/qemu-iotests/common.rc                       |    35 +-
 tests/qemu-iotests/iotests.py                      |    92 +-
 tests/qemu-iotests/meson.build                     |    73 +-
 tests/qemu-iotests/mypy.ini                        |     2 +-
 tests/qemu-iotests/pylintrc                        |     5 +
 tests/qemu-iotests/testrunner.py                   |     4 +
 tests/qemu-iotests/tests/backing-file-invalidation |   152 +
 .../tests/backing-file-invalidation.out            |     5 +
 tests/qemu-iotests/tests/copy-before-write         |   222 +
 tests/qemu-iotests/tests/copy-before-write.out     |     5 +
 tests/qemu-iotests/tests/export-incoming-iothread  |    81 +
 .../tests/export-incoming-iothread.out             |     5 +
 tests/qemu-iotests/tests/image-fleecing            |    30 +-
 tests/qemu-iotests/tests/migration-permissions     |    28 +-
 tests/qemu-iotests/tests/mirror-ready-cancel-error |     2 +-
 tests/qemu-iotests/tests/mirror-top-perms          |    11 +-
 tests/qemu-iotests/tests/nbd-multiconn             |   145 +
 tests/qemu-iotests/tests/nbd-multiconn.out         |     5 +
 tests/qemu-iotests/tests/nbd-qemu-allocation.out   |     2 +-
 tests/qemu-iotests/tests/nbd-reconnect-on-open     |     2 +-
 tests/qemu-iotests/tests/reopen-file               |    89 +
 tests/qemu-iotests/tests/reopen-file.out           |     5 +
 tests/qemu-iotests/tests/stream-error-on-reset     |     4 +-
 tests/qemu-iotests/tests/stream-under-throttle     |   121 +
 tests/qemu-iotests/tests/stream-under-throttle.out |     5 +
 tests/qtest/ac97-test.c                            |     4 +-
 tests/qtest/acpi-utils.c                           |     1 -
 tests/qtest/acpi-utils.h                           |     2 +-
 tests/qtest/ahci-test.c                            |    39 +-
 tests/qtest/am53c974-test.c                        |     2 +-
 tests/qtest/arm-cpu-features.c                     |     2 +-
 tests/qtest/aspeed_gpio-test.c                     |    90 +
 tests/qtest/aspeed_hace-test.c                     |   150 +-
 tests/qtest/aspeed_smc-test.c                      |   293 +-
 tests/qtest/bcm2835-dma-test.c                     |   118 +
 tests/qtest/bios-tables-test.c                     |   521 +-
 tests/qtest/boot-order-test.c                      |     2 +-
 tests/qtest/boot-sector.c                          |     3 +-
 tests/qtest/boot-sector.h                          |     2 +-
 tests/qtest/boot-serial-test.c                     |    13 +-
 tests/qtest/cdrom-test.c                           |     4 +-
 tests/qtest/cpu-plug-test.c                        |     1 -
 tests/qtest/cxl-test.c                             |   155 +
 tests/qtest/dbus-display-test.c                    |     5 +-
 tests/qtest/dbus-vmstate-test.c                    |     5 +-
 tests/qtest/device-introspect-test.c               |     3 +-
 tests/qtest/device-plug-test.c                     |   100 +-
 tests/qtest/drive_del-test.c                       |   127 +-
 tests/qtest/ds1338-test.c                          |     2 +-
 tests/qtest/e1000-test.c                           |     4 +-
 tests/qtest/e1000e-test.c                          |    76 +-
 tests/qtest/eepro100-test.c                        |     2 +-
 tests/qtest/endianness-test.c                      |     3 +-
 tests/qtest/erst-test.c                            |     3 +-
 tests/qtest/es1370-test.c                          |     4 +-
 tests/qtest/fdc-test.c                             |    29 +-
 tests/qtest/fuzz-e1000e-test.c                     |     2 +-
 tests/qtest/fuzz-lsi53c895a-test.c                 |    86 +-
 tests/qtest/fuzz-megasas-test.c                    |    16 +-
 tests/qtest/fuzz-sb16-test.c                       |    18 +-
 tests/qtest/fuzz-sdcard-test.c                     |    20 +-
 tests/qtest/fuzz-virtio-scsi-test.c                |    12 +-
 tests/qtest/fuzz-xlnx-dp-test.c                    |     4 +-
 tests/qtest/fuzz/fuzz.c                            |    23 +-
 tests/qtest/fuzz/fuzz.h                            |     7 +-
 tests/qtest/fuzz/generic_fuzz.c                    |    21 +-
 tests/qtest/fuzz/generic_fuzz_configs.h            |     4 +-
 tests/qtest/fuzz/i440fx_fuzz.c                     |     2 +-
 tests/qtest/fuzz/qos_fuzz.c                        |     5 +-
 tests/qtest/fuzz/virtio_blk_fuzz.c                 |     6 +-
 tests/qtest/fuzz/virtio_net_fuzz.c                 |     4 +-
 tests/qtest/fuzz/virtio_scsi_fuzz.c                |     2 +-
 tests/qtest/fw_cfg-test.c                          |     2 +-
 tests/qtest/hd-geo-test.c                          |   298 +-
 tests/qtest/hexloader-test.c                       |     2 +-
 tests/qtest/i440fx-test.c                          |    48 +-
 tests/qtest/ide-test.c                             |    93 +-
 tests/qtest/intel-hda-test.c                       |    13 +-
 tests/qtest/ipmi-bt-test.c                         |     1 -
 tests/qtest/ipoctal232-test.c                      |     2 +-
 tests/qtest/ivshmem-test.c                         |    30 +-
 tests/qtest/libqmp.c                               |   258 +
 tests/qtest/libqmp.h                               |    53 +
 tests/qtest/libqos/aarch64-xlnx-zcu102-machine.c   |     4 +-
 tests/qtest/libqos/ahci.c                          |     3 +-
 tests/qtest/libqos/arm-imx25-pdk-machine.c         |     4 +-
 tests/qtest/libqos/arm-n800-machine.c              |     4 +-
 tests/qtest/libqos/arm-raspi2-machine.c            |     4 +-
 tests/qtest/libqos/arm-sabrelite-machine.c         |     4 +-
 tests/qtest/libqos/arm-smdkc210-machine.c          |     4 +-
 tests/qtest/libqos/arm-virt-machine.c              |    23 +-
 tests/qtest/libqos/arm-xilinx-zynq-a9-machine.c    |     4 +-
 tests/qtest/libqos/e1000e.c                        |   128 +-
 tests/qtest/libqos/fw_cfg.c                        |     2 +-
 tests/qtest/libqos/fw_cfg.h                        |     2 +-
 tests/qtest/libqos/generic-pcihost.c               |   231 +
 tests/qtest/libqos/generic-pcihost.h               |    54 +
 tests/qtest/libqos/i2c-imx.c                       |     2 +-
 tests/qtest/libqos/i2c-omap.c                      |     2 +-
 tests/qtest/libqos/i2c.c                           |     2 +-
 tests/qtest/libqos/i2c.h                           |     2 +-
 tests/qtest/libqos/libqos-malloc.c                 |   346 +
 tests/qtest/libqos/libqos-malloc.h                 |    50 +
 tests/qtest/libqos/libqos.c                        |     4 +-
 tests/qtest/libqos/libqos.h                        |     4 +-
 tests/qtest/libqos/libqtest.h                      |   813 -
 tests/qtest/libqos/malloc-pc.c                     |     2 -
 tests/qtest/libqos/malloc-pc.h                     |     2 +-
 tests/qtest/libqos/malloc-spapr.c                  |     2 -
 tests/qtest/libqos/malloc-spapr.h                  |     2 +-
 tests/qtest/libqos/malloc.c                        |   347 -
 tests/qtest/libqos/malloc.h                        |    50 -
 tests/qtest/libqos/meson.build                     |    14 +-
 tests/qtest/libqos/pci-pc.c                        |    11 +-
 tests/qtest/libqos/pci-pc.h                        |     2 +-
 tests/qtest/libqos/pci-spapr.c                     |     3 +-
 tests/qtest/libqos/pci-spapr.h                     |     2 +-
 tests/qtest/libqos/pci.c                           |    78 +-
 tests/qtest/libqos/pci.h                           |     8 +-
 tests/qtest/libqos/ppc64_pseries-machine.c         |     2 +-
 tests/qtest/libqos/qgraph.c                        |     2 +-
 tests/qtest/libqos/qgraph.h                        |     6 +-
 tests/qtest/libqos/qos_external.c                  |     4 +-
 tests/qtest/libqos/qos_external.h                  |     2 +-
 tests/qtest/libqos/rtas.c                          |     2 +-
 tests/qtest/libqos/rtas.h                          |     2 +-
 tests/qtest/libqos/sdhci-cmd.c                     |     2 +-
 tests/qtest/libqos/sdhci-cmd.h                     |     2 +-
 tests/qtest/libqos/sdhci.c                         |     2 +-
 tests/qtest/libqos/tpci200.c                       |     2 +-
 tests/qtest/libqos/usb.c                           |     2 +-
 tests/qtest/libqos/vhost-user-blk.c                |     2 +-
 tests/qtest/libqos/virtio-9p-client.c              |  1049 +
 tests/qtest/libqos/virtio-9p-client.h              |   494 +
 tests/qtest/libqos/virtio-9p.c                     |     8 +-
 tests/qtest/libqos/virtio-balloon.c                |     2 +-
 tests/qtest/libqos/virtio-blk.c                    |     2 +-
 tests/qtest/libqos/virtio-gpio.c                   |   172 +
 tests/qtest/libqos/virtio-gpio.h                   |    35 +
 tests/qtest/libqos/virtio-iommu.c                  |     2 +-
 tests/qtest/libqos/virtio-mmio.c                   |     4 +-
 tests/qtest/libqos/virtio-net.c                    |     2 +-
 tests/qtest/libqos/virtio-pci.c                    |     4 +-
 tests/qtest/libqos/virtio-rng.c                    |     2 +-
 tests/qtest/libqos/virtio-scsi.c                   |     2 +-
 tests/qtest/libqos/virtio-serial.c                 |     2 +-
 tests/qtest/libqos/virtio.c                        |     8 +-
 tests/qtest/libqos/virtio.h                        |     2 +-
 tests/qtest/libqos/x86_64_pc-machine.c             |     2 +-
 tests/qtest/libqtest-single.h                      |     6 +-
 tests/qtest/libqtest.c                             |   477 +-
 tests/qtest/libqtest.h                             |   835 +
 tests/qtest/lpc-ich9-test.c                        |     2 +-
 tests/qtest/m48t59-test.c                          |     4 +-
 tests/qtest/machine-none-test.c                    |     6 +-
 tests/qtest/megasas-test.c                         |     2 +-
 tests/qtest/meson.build                            |   110 +-
 tests/qtest/microbit-test.c                        |    18 +-
 tests/qtest/migration-helpers.c                    |    51 +
 tests/qtest/migration-helpers.h                    |    14 +-
 tests/qtest/migration-test.c                       |  1727 +-
 tests/qtest/modules-test.c                         |     5 +-
 tests/qtest/ne2000-test.c                          |     2 +-
 tests/qtest/npcm7xx_adc-test.c                     |     4 +-
 tests/qtest/npcm7xx_emc-test.c                     |    12 +-
 tests/qtest/npcm7xx_pwm-test.c                     |     5 +-
 tests/qtest/npcm7xx_rng-test.c                     |     2 +-
 tests/qtest/npcm7xx_sdhci-test.c                   |     4 +-
 tests/qtest/npcm7xx_smbus-test.c                   |     2 +-
 tests/qtest/npcm7xx_watchdog_timer-test.c          |     2 +-
 tests/qtest/numa-test.c                            |    21 +-
 tests/qtest/nvme-test.c                            |     2 +-
 tests/qtest/pca9552-test.c                         |     2 +-
 tests/qtest/pci-test.c                             |     2 +-
 tests/qtest/pcnet-test.c                           |     2 +-
 tests/qtest/pflash-cfi02-test.c                    |    17 +-
 tests/qtest/pnv-xscom-test.c                       |     2 +-
 tests/qtest/prom-env-test.c                        |     6 +-
 tests/qtest/pvpanic-pci-test.c                     |     2 +-
 tests/qtest/pvpanic-test.c                         |     2 +-
 tests/qtest/pxe-test.c                             |     3 +-
 tests/qtest/q35-test.c                             |     2 +-
 tests/qtest/qmp-cmd-test.c                         |     5 +-
 tests/qtest/qmp-test.c                             |    19 +-
 tests/qtest/qom-test.c                             |    25 +-
 tests/qtest/qos-test.c                             |    11 +-
 tests/qtest/readconfig-test.c                      |   195 +
 tests/qtest/rtas-test.c                            |     2 +-
 tests/qtest/rtc-test.c                             |     2 +-
 tests/qtest/rtl8139-test.c                         |     1 -
 tests/qtest/sdhci-test.c                           |     2 +-
 tests/qtest/spapr-phb-test.c                       |     2 +-
 tests/qtest/tco-test.c                             |     2 +-
 tests/qtest/test-filter-mirror.c                   |     3 +-
 tests/qtest/test-filter-redirector.c               |     3 +-
 tests/qtest/test-hmp.c                             |     2 +-
 tests/qtest/test-x86-cpuid-compat.c                |     1 -
 tests/qtest/tpm-crb-swtpm-test.c                   |     7 +-
 tests/qtest/tpm-emu.h                              |     2 +-
 tests/qtest/tpm-tis-device-swtpm-test.c            |     7 +-
 tests/qtest/tpm-tis-swtpm-test.c                   |     7 +-
 tests/qtest/tpm-util.c                             |    21 +-
 tests/qtest/tpm-util.h                             |     1 +
 tests/qtest/tulip-test.c                           |     2 +-
 tests/qtest/vhost-user-blk-test.c                  |    15 +-
 tests/qtest/vhost-user-test.c                      |   196 +-
 tests/qtest/virtio-9p-test.c                       |  1222 +-
 tests/qtest/virtio-blk-test.c                      |    11 +-
 tests/qtest/virtio-net-failover.c                  |    11 +-
 tests/qtest/virtio-net-test.c                      |    19 +-
 tests/qtest/virtio-rng-test.c                      |     7 +-
 tests/qtest/virtio-scsi-test.c                     |     4 +-
 tests/qtest/virtio-test.c                          |     2 +-
 tests/qtest/vmgenid-test.c                         |     2 +-
 tests/qtest/vmxnet3-test.c                         |     2 +-
 tests/qtest/vnc-display-test.c                     |   103 +
 tests/qtest/wdt_ib700-test.c                       |     2 +-
 tests/qtest/xlnx-can-test.c                        |     2 +-
 tests/requirements.txt                             |     1 +
 tests/tcg/Makefile.prereqs                         |    18 -
 tests/tcg/Makefile.qemu                            |   121 -
 tests/tcg/Makefile.target                          |    49 +-
 tests/tcg/aarch64/Makefile.softmmu-target          |    13 +-
 tests/tcg/aarch64/Makefile.target                  |    31 +-
 tests/tcg/aarch64/bti-3.c                          |    42 +
 tests/tcg/aarch64/float_convd.ref                  |   988 +
 tests/tcg/aarch64/system/pauth-3.c                 |     2 +-
 tests/tcg/aarch64/system/semiconsole.c             |     2 +-
 tests/tcg/aarch64/system/semiheap.c                |     2 +-
 tests/tcg/arm/Makefile.softmmu-target              |     2 +-
 tests/tcg/arm/Makefile.target                      |     9 +-
 tests/tcg/arm/float_convd.ref                      |   988 +
 tests/tcg/configure.sh                             |   354 -
 tests/tcg/cris/Makefile.target                     |     2 +-
 tests/tcg/hexagon/Makefile.target                  |     1 +
 tests/tcg/hexagon/float_convd.ref                  |   988 +
 tests/tcg/hexagon/hvx_misc.c                       |    45 +
 tests/tcg/hexagon/load_unpack.c                    |    14 +-
 tests/tcg/hexagon/mem_noshuf.c                     |   122 +-
 tests/tcg/hexagon/mem_noshuf_exception.c           |   146 +
 tests/tcg/hexagon/usr.c                            |    10 +
 tests/tcg/i386/Makefile.softmmu-target             |     3 +-
 tests/tcg/i386/Makefile.target                     |    43 +-
 tests/tcg/i386/README                              |     9 +
 tests/tcg/i386/float_convd.conf                    |   988 +
 tests/tcg/i386/float_convs.ref                     |   748 +
 tests/tcg/i386/test-3dnow.c                        |     3 +
 tests/tcg/i386/test-avx.c                          |   364 +
 tests/tcg/i386/test-avx.py                         |   375 +
 tests/tcg/i386/test-i386-bmi2.c                    |   169 +-
 tests/tcg/i386/test-i386-fp-exceptions.c           |    24 +-
 tests/tcg/i386/test-i386.c                         |   577 +-
 tests/tcg/i386/test-mmx.c                          |   315 +
 tests/tcg/i386/test-mmx.py                         |   244 +
 tests/tcg/i386/x86.csv                             |  4658 ++++
 tests/tcg/loongarch64/Makefile.softmmu-target      |    33 +
 tests/tcg/loongarch64/Makefile.target              |    20 +
 tests/tcg/loongarch64/float_convd.ref              |   988 +
 tests/tcg/loongarch64/float_convs.ref              |   748 +
 tests/tcg/loongarch64/float_madds.ref              |   768 +
 tests/tcg/loongarch64/system/boot.S                |    56 +
 tests/tcg/loongarch64/system/kernel.ld             |    30 +
 tests/tcg/loongarch64/system/regdef.h              |    86 +
 tests/tcg/loongarch64/test_bit.c                   |    88 +
 tests/tcg/loongarch64/test_div.c                   |    54 +
 tests/tcg/loongarch64/test_fclass.c                |   130 +
 tests/tcg/loongarch64/test_fcsr.c                  |    15 +
 tests/tcg/loongarch64/test_fpcom.c                 |    37 +
 tests/tcg/loongarch64/test_pcadd.c                 |    38 +
 tests/tcg/m68k/Makefile.target                     |     3 +
 tests/tcg/m68k/trap.c                              |   129 +
 tests/tcg/multiarch/Makefile.target                |    23 +-
 tests/tcg/multiarch/float_convd.c                  |   106 +
 tests/tcg/multiarch/linux/linux-madvise.c          |    70 +
 tests/tcg/multiarch/linux/linux-test.c             |     2 +-
 tests/tcg/multiarch/munmap-pthread.c               |    79 +
 tests/tcg/multiarch/noexec.c.inc                   |   139 +
 tests/tcg/multiarch/overflow.c                     |    58 +
 tests/tcg/multiarch/system/Makefile.softmmu-target |     2 +-
 tests/tcg/multiarch/system/memory.c                |     2 +-
 tests/tcg/nios2/10m50-ghrd.ld                      |    70 +
 tests/tcg/nios2/Makefile.softmmu-target            |    32 +
 tests/tcg/nios2/Makefile.target                    |    11 -
 tests/tcg/nios2/boot.S                             |   218 +
 tests/tcg/nios2/intr.S                             |    31 +
 tests/tcg/nios2/semicall.h                         |    28 +
 tests/tcg/nios2/test-shadow-1.S                    |    40 +
 tests/tcg/ppc64/Makefile.target                    |    13 +-
 tests/tcg/ppc64/bcdsub.c                           |   134 +
 tests/tcg/ppc64/byte_reverse.c                     |    21 +
 tests/tcg/ppc64/mffsce.c                           |    37 +
 tests/tcg/ppc64/mtfsf.c                            |    60 +
 tests/tcg/ppc64/non_signalling_xscv.c              |    37 +
 tests/tcg/ppc64/signal_save_restore_xer.c          |    42 +
 tests/tcg/ppc64/xxspltw.c                          |    46 +
 tests/tcg/ppc64le/Makefile.target                  |    25 +-
 tests/tcg/ppc64le/bcdsub.c                         |   134 -
 tests/tcg/ppc64le/byte_reverse.c                   |    21 -
 tests/tcg/ppc64le/mtfsf.c                          |    60 -
 tests/tcg/ppc64le/non_signalling_xscv.c            |    37 -
 tests/tcg/ppc64le/signal_save_restore_xer.c        |    42 -
 tests/tcg/ppc64le/xxspltw.c                        |    46 -
 tests/tcg/riscv64/Makefile.softmmu-target          |    21 +
 tests/tcg/riscv64/Makefile.target                  |     1 +
 tests/tcg/riscv64/issue1060.S                      |    53 +
 tests/tcg/riscv64/noexec.c                         |    79 +
 tests/tcg/riscv64/semihost.ld                      |    21 +
 tests/tcg/s390x/Makefile.softmmu-target            |     9 +
 tests/tcg/s390x/Makefile.target                    |    29 +-
 tests/tcg/s390x/branch-relative-long.c             |     4 +-
 tests/tcg/s390x/noexec.c                           |   106 +
 tests/tcg/s390x/signals-s390x.c                    |    69 +-
 tests/tcg/s390x/unaligned-lowcore.S                |    19 +
 tests/tcg/s390x/vfminmax.c                         |   411 +
 tests/tcg/s390x/vistr.c                            |    45 +
 tests/tcg/s390x/vx.h                               |    19 +
 tests/tcg/s390x/vxeh2_vcvt.c                       |    88 +
 tests/tcg/s390x/vxeh2_vlstr.c                      |   139 +
 tests/tcg/s390x/vxeh2_vs.c                         |    93 +
 tests/tcg/sh4/Makefile.target                      |    12 -
 tests/tcg/x86_64/Makefile.softmmu-target           |     3 +-
 tests/tcg/x86_64/Makefile.target                   |    17 +-
 tests/tcg/x86_64/cmpxchg.c                         |    42 +
 tests/tcg/x86_64/float_convd.ref                   |   988 +
 tests/tcg/x86_64/float_convs.ref                   |   748 +
 tests/tcg/x86_64/noexec.c                          |    75 +
 tests/tcg/x86_64/system/boot.S                     |     2 +-
 tests/tcg/xtensa/Makefile.softmmu-target           |     2 +-
 tests/tcg/xtensa/crt.S                             |     2 +
 tests/tcg/xtensa/test_break.S                      |    86 +-
 tests/tcg/xtensa/test_mmu.S                        |   182 +-
 tests/tcg/xtensa/test_phys_mem.S                   |    10 +-
 tests/tcg/xtensa/test_sr.S                         |     2 +
 tests/tcg/xtensa/test_timer.S                      |    68 +-
 tests/unit/check-block-qdict.c                     |     2 +-
 tests/unit/check-qjson.c                           |     1 -
 tests/unit/check-qnull.c                           |     1 -
 tests/unit/check-qnum.c                            |     1 -
 tests/unit/check-qobject.c                         |   133 +-
 tests/unit/check-qom-proplist.c                    |     1 +
 tests/unit/check-qstring.c                         |     1 -
 tests/unit/crypto-tls-psk-helpers.c                |    27 +-
 tests/unit/crypto-tls-psk-helpers.h                |     1 +
 tests/unit/crypto-tls-x509-helpers.c               |    16 +-
 tests/unit/crypto-tls-x509-helpers.h               |    53 +
 tests/unit/io-channel-helpers.c                    |     9 +-
 tests/unit/meson.build                             |     9 +-
 tests/unit/ptimer-test.c                           |    28 +-
 tests/unit/socket-helpers.c                        |    19 +-
 tests/unit/socket-helpers.h                        |     9 +
 tests/unit/test-bdrv-drain.c                       |    97 +-
 tests/unit/test-bdrv-graph-mod.c                   |   104 +-
 tests/unit/test-block-iothread.c                   |   171 +-
 tests/unit/test-blockjob-txn.c                     |    24 +-
 tests/unit/test-blockjob.c                         |   136 +-
 tests/unit/test-clone-visitor.c                    |     1 -
 tests/unit/test-coroutine.c                        |     2 +-
 tests/unit/test-crypto-akcipher.c                  |   990 +
 tests/unit/test-crypto-block.c                     |   340 +-
 tests/unit/test-crypto-der.c                       |   372 +
 tests/unit/test-crypto-tlscredsx509.c              |     4 +-
 tests/unit/test-crypto-tlssession.c                |    25 +-
 tests/unit/test-cutils.c                           |    78 +
 tests/unit/test-forward-visitor.c                  |     3 +-
 tests/unit/test-image-locking.c                    |    10 +-
 tests/unit/test-int128.c                           |    50 +
 tests/unit/test-io-channel-command.c               |    59 +-
 tests/unit/test-io-channel-file.c                  |     2 +-
 tests/unit/test-io-channel-null.c                  |    95 +
 tests/unit/test-io-channel-socket.c                |    38 +-
 tests/unit/test-io-channel-tls.c                   |     6 +-
 tests/unit/test-iov.c                              |    31 +-
 tests/unit/test-keyval.c                           |     2 +-


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:12:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:12:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680962.1059404 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGvv-0002W2-3N; Wed, 14 Feb 2024 15:12:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680962.1059404; Wed, 14 Feb 2024 15:12:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGvv-0002Vv-0u; Wed, 14 Feb 2024 15:12:23 +0000
Received: by outflank-mailman (input) for mailman id 680962;
 Wed, 14 Feb 2024 15:12:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGvu-0002Ve-4c
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:12:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGvu-000649-2A
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:12:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGvt-0008O7-Tx
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:12:21 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=88hS0iMFIiFLWZd/lhNl9EQ777/Z/W5w4kvMEsU2lzI=; b=nmGQOJi/76Wz0DyHGsrj2DzsHm
	Scz79GOaIQf1OVCvh5yOAx7Ms2mAkigl6W3DFywWpja3DX9P+rVQoKuV8ZYIRSR9dc2B4Tfnh5RjM
	m2V5xWUHkOhfoKuUzgUjRozRztXVffd3Ok3ITmPrQ9T8OpfvqFYVzXzHsDbl6tt+pDJY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.17] ebpf: replace deprecated bpf_program__set_socket_filter
Message-Id: <E1raGvt-0008O7-Tx@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:12:21 +0000

commit 27ca28d169038bf7fe70341c4cbb8fddd3791e8b
Author:     Haochen Tong <i@hexchain.org>
AuthorDate: Sat May 28 03:06:58 2022 +0800
Commit:     Anthony PERARD <anthony.perard@gmail.com>
CommitDate: Thu Oct 20 14:36:16 2022 +0100

    ebpf: replace deprecated bpf_program__set_socket_filter
    
    bpf_program__set_<TYPE> functions have been deprecated since libbpf 0.8.
    Replace with the equivalent bpf_program__set_type call to avoid a
    deprecation warning.
    
    Signed-off-by: Haochen Tong <i@hexchain.org>
    Reviewed-by: Zhang Chen <chen.zhang@intel.com>
    Signed-off-by: Jason Wang <jasowang@redhat.com>
    (cherry picked from commit a495eba03c31c96d6a0817b13598ce2219326691)
---
 ebpf/ebpf_rss.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ebpf/ebpf_rss.c b/ebpf/ebpf_rss.c
index 118c68da83..cee658c158 100644
--- a/ebpf/ebpf_rss.c
+++ b/ebpf/ebpf_rss.c
@@ -49,7 +49,7 @@ bool ebpf_rss_load(struct EBPFRSSContext *ctx)
         goto error;
     }
 
-    bpf_program__set_socket_filter(rss_bpf_ctx->progs.tun_rss_steering_prog);
+    bpf_program__set_type(rss_bpf_ctx->progs.tun_rss_steering_prog, BPF_PROG_TYPE_SOCKET_FILTER);
 
     if (rss_bpf__load(rss_bpf_ctx)) {
         trace_ebpf_error("eBPF RSS", "can not load RSS program");
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:12:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:12:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680963.1059409 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGw5-0002Zb-55; Wed, 14 Feb 2024 15:12:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680963.1059409; Wed, 14 Feb 2024 15:12:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGw5-0002ZU-2V; Wed, 14 Feb 2024 15:12:33 +0000
Received: by outflank-mailman (input) for mailman id 680963;
 Wed, 14 Feb 2024 15:12:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGw4-0002ZL-66
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:12:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGw4-00064V-5H
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:12:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGw4-0008PW-4P
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:12:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=hHHrTH2mqxSa7kLG/E7Rsx7aUgxztDbcbcYTEKW4/18=; b=D2t/wE3+UuQf95RG7CYxj6AWyu
	hSRPX/lH0CogPaS3qfWfkXqBOtMpms0oSRKvR2bQxmnDSSMFEyXPrVav0z/o2nEeEwWFIulznxCxx
	/K2L5UpxGoIly1Qei0EpkYWiwKlqAa3AqOYhb2Sk7CECZxPO6iLoTmCo0kTdn5Som9rE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.17] rtl8139: Remove unused variable
Message-Id: <E1raGw4-0008PW-4P@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:12:32 +0000

commit 7385a130d841aeaf39e8773af869eb54cc7d6a7f
Author:     Miroslav Rezanina <mrezanin@redhat.com>
AuthorDate: Wed Nov 9 10:57:11 2022 -0500
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Mon Jul 17 11:06:47 2023 +0100

    rtl8139: Remove unused variable
    
    Variable send_count used in rtl8139_cplus_transmit_one function is only
    incremented but never read. This causes 'Unused but set variable' warning
    on Clang 15.0.1 compiler.
    
    Removing the variable to prevent the warning.
    
    Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Message-Id: <15a32dd06c492216cbf27cd3ddcbe1e9afb8d8f5.1668009030.git.mrezanin@redhat.com>
    Signed-off-by: Thomas Huth <thuth@redhat.com>
    (cherry picked from commit 7d7238c72b983cff5064734349d2d45be9c6282c)
---
 hw/net/rtl8139.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 6b65823b4b..e6643e3c9d 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -2156,7 +2156,6 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
                     ip_data_len, saved_size - ETH_HLEN, large_send_mss);
 
                 int tcp_send_offset = 0;
-                int send_count = 0;
 
                 /* maximum IP header length is 60 bytes */
                 uint8_t saved_ip_header[60];
@@ -2261,7 +2260,6 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
                     /* add transferred count to TCP sequence number */
                     stl_be_p(&p_tcp_hdr->th_seq,
                              chunk_size + ldl_be_p(&p_tcp_hdr->th_seq));
-                    ++send_count;
                 }
 
                 /* Stop sending this frame */
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:12:43 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:12:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680964.1059412 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGwF-0002cc-6L; Wed, 14 Feb 2024 15:12:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680964.1059412; Wed, 14 Feb 2024 15:12:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGwF-0002cV-3x; Wed, 14 Feb 2024 15:12:43 +0000
Received: by outflank-mailman (input) for mailman id 680964;
 Wed, 14 Feb 2024 15:12:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGwE-0002cH-95
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:12:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGwE-00064c-8H
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:12:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGwE-0008Q8-7U
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:12:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=kLu+Ik1CtLR+q0ZTKARNiJHpuoz4tLfP0ikLXVKS9Ws=; b=m681RB39rxVTftwPEfTFsyu3En
	GiE9m3OD2/gYiqWN1AdThGm9sIffJCu/i9I4WlTkapr9nz/qJfwPhd6BaepAo9AC9af+aK9ivEOzS
	zyOtLUODiPgkcO+f2frXPNALWS/l2yIlXLp4c8WDIIHKD0csTjS44m7lJWDBy6dVVMrc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.17] tulip: Remove unused variable
Message-Id: <E1raGwE-0008Q8-7U@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:12:42 +0000

commit 83b8b039db0efefd851dc62160728a69b36e09aa
Author:     Miroslav Rezanina <mrezanin@redhat.com>
AuthorDate: Wed Nov 9 10:57:12 2022 -0500
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Mon Jul 17 11:34:45 2023 +0100

    tulip: Remove unused variable
    
    Variable n used in tulip_idblock_crc function is only incremented but never read.
    This causes 'Unused but set variable' warning on Clang 15.0.1 compiler.
    
    Removing the variable to prevent the warning.
    
    Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Message-Id: <02e1560d115c208df32236df8916fed98429fda1.1668009030.git.mrezanin@redhat.com>
    Signed-off-by: Thomas Huth <thuth@redhat.com>
    (cherry picked from commit 6083dcad80743718620a3f8a72fb76ea8b7c28ca)
---
 hw/net/tulip.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/hw/net/tulip.c b/hw/net/tulip.c
index d5b6cc5ee6..9b5a5d33bd 100644
--- a/hw/net/tulip.c
+++ b/hw/net/tulip.c
@@ -870,11 +870,10 @@ static const MemoryRegionOps tulip_ops = {
 
 static void tulip_idblock_crc(TULIPState *s, uint16_t *srom)
 {
-    int word, n;
+    int word;
     int bit;
     unsigned char bitval, crc;
     const int len = 9;
-    n = 0;
     crc = -1;
 
     for (word = 0; word < len; word++) {
@@ -887,7 +886,6 @@ static void tulip_idblock_crc(TULIPState *s, uint16_t *srom)
                 srom[len - 1] = (srom[len - 1] & 0xff00) | (unsigned short)crc;
                 break;
             }
-            n++;
             bitval = ((srom[word] >> bit) & 1) ^ ((crc >> 7) & 1);
             crc = crc << 1;
             if (bitval == 1) {
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:12:53 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:12:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680965.1059416 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGwP-0002gP-7t; Wed, 14 Feb 2024 15:12:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680965.1059416; Wed, 14 Feb 2024 15:12:53 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGwP-0002gI-5L; Wed, 14 Feb 2024 15:12:53 +0000
Received: by outflank-mailman (input) for mailman id 680965;
 Wed, 14 Feb 2024 15:12:52 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGwO-0002g9-Dq
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:12:52 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGwO-000652-BL
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:12:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGwO-0008Qa-Aa
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:12:52 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=uU3TIMZfW2drflUTGgwLpAgk8Jmb3mnef3yTmbRrfKs=; b=NnBdJpx4IAJlWmQX8wqjw/0yim
	MB+nwvhoJJoICPvEGGYcGfUV/u+6e1ocOvc5ejS0xXNInBD63aiPJDYN/Z2Q982dJ+UzWrYdNgLXf
	KBVfQ10+UttpDtu9T2GHlHdgLQE2thGgaVRqGk2OaoJugaQmt7JgFxW7H7ANNpt+JLEo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.17] qemu-img: remove unused variable
Message-Id: <E1raGwO-0008Qa-Aa@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:12:52 +0000

commit eeaede60ffb1760c06850cae562d104e4f98c859
Author:     Miroslav Rezanina <mrezanin@redhat.com>
AuthorDate: Wed Nov 9 10:57:13 2022 -0500
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Mon Jul 17 11:39:50 2023 +0100

    qemu-img: remove unused variable
    
    Variable block_count used in img_dd function is only incremented but never read.
    This causes 'Unused but set variable' warning on Clang 15.0.1 compiler.
    
    Removing the variable to prevent the warning.
    
    Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Message-Id: <e86d5b57f9d13bde995c616a533b876f1fb8a527.1668009030.git.mrezanin@redhat.com>
    Signed-off-by: Thomas Huth <thuth@redhat.com>
    (cherry picked from commit 0f48c47c679bc29fceb3a67283ee3b78175524bf)
---
 qemu-img.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index 1caddfb23a..0240177af7 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -4914,7 +4914,7 @@ static int img_dd(int argc, char **argv)
     const char *out_fmt = "raw";
     const char *fmt = NULL;
     int64_t size = 0;
-    int64_t block_count = 0, out_pos, in_pos;
+    int64_t out_pos, in_pos;
     bool force_share = false;
     struct DdInfo dd = {
         .flags = 0,
@@ -5114,7 +5114,7 @@ static int img_dd(int argc, char **argv)
 
     in.buf = g_new(uint8_t, in.bsz);
 
-    for (out_pos = 0; in_pos < size; block_count++) {
+    for (out_pos = 0; in_pos < size; ) {
         int in_ret, out_ret;
 
         if (in_pos + in.bsz > size) {
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:13:03 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:13:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680967.1059431 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGwZ-0002xO-GD; Wed, 14 Feb 2024 15:13:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680967.1059431; Wed, 14 Feb 2024 15:13:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGwZ-0002xH-D3; Wed, 14 Feb 2024 15:13:03 +0000
Received: by outflank-mailman (input) for mailman id 680967;
 Wed, 14 Feb 2024 15:13:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGwY-0002lu-F1
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGwY-00065S-EK
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGwY-0008RA-DZ
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ThXhjhze7r1jOuCAZkcCieUnhu/9vzJDfDbQ8uv9kec=; b=Xa6VTGApBXQUzC8uUU0qK9EZMu
	zqCtiipJHZtDkj4/5l7EDpJYubHBWik4rzIB6X3U2mg27Jtinr14pJpsVQZBjHrm5gIfnkFtFMbgX
	mPJlM2XqJGlhOZbbp20qIdtu1KcrNYsnePVKnv6fhBuhjS8H6mgcg+g5WDVyl9C24PNk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.17] stubs: update replay-tools to match replay.h types
Message-Id: <E1raGwY-0008RA-DZ@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:13:02 +0000

commit df4fece4be5a8acf4fa9588b58497c6544bd326e
Author:     Claudio Fontana <cfontana@suse.de>
AuthorDate: Mon Jul 4 09:58:32 2022 +0200
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Fri Jul 21 11:02:04 2023 +0100

    stubs: update replay-tools to match replay.h types
    
    detected with GCC 13 [-Werror=enum-int-mismatch]
    
    Solves Issue #1096.
    
    Signed-off-by: Claudio Fontana <cfontana@suse.de>
    Cc: Pavel Dovgalyuk <pavel.dovgalyuk@ispras.ru>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Message-Id: <20220704075832.31537-1-cfontana@suse.de>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    (cherry picked from commit bb7e03cb5677b570c5966c7dd946f9ed7acd11bc)
---
 stubs/replay-tools.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/stubs/replay-tools.c b/stubs/replay-tools.c
index 43296b3d4e..f2e72bb225 100644
--- a/stubs/replay-tools.c
+++ b/stubs/replay-tools.c
@@ -7,13 +7,14 @@ bool replay_events_enabled(void)
     return false;
 }
 
-int64_t replay_save_clock(unsigned int kind, int64_t clock, int64_t raw_icount)
+int64_t replay_save_clock(ReplayClockKind kind,
+                          int64_t clock, int64_t raw_icount)
 {
     abort();
     return 0;
 }
 
-int64_t replay_read_clock(unsigned int kind, int64_t raw_icount)
+int64_t replay_read_clock(ReplayClockKind kind, int64_t raw_icount)
 {
     abort();
     return 0;
@@ -48,11 +49,11 @@ void replay_mutex_unlock(void)
 {
 }
 
-void replay_register_char_driver(Chardev *chr)
+void replay_register_char_driver(struct Chardev *chr)
 {
 }
 
-void replay_chr_be_write(Chardev *s, uint8_t *buf, int len)
+void replay_chr_be_write(struct Chardev *s, uint8_t *buf, int len)
 {
     abort();
 }
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:13:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:13:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680969.1059435 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGwj-00035D-HV; Wed, 14 Feb 2024 15:13:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680969.1059435; Wed, 14 Feb 2024 15:13:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGwj-000356-Ea; Wed, 14 Feb 2024 15:13:13 +0000
Received: by outflank-mailman (input) for mailman id 680969;
 Wed, 14 Feb 2024 15:13:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGwi-00034k-Hx
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGwi-00065h-H9
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGwi-0008S1-GS
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=TWwDU1uroiDRSiduflHrc/vDEW+PaC48Fs5w3OKXaeQ=; b=QKjgXwykSPOTPpzHAq5rW1HNlr
	N0O03ujodAjB60W28Xpwngc6dIAAs8RgFvYAEo5MiQbgLRInIKF1pnV03sj39uSGvNQJ6rcbIa2xk
	YcJAiVsJ6S/WJ2mXVCOqN0NiJCta3ayzJTDHPIwFkDGUhseUfgw8OS/SILIvcwPVpSuY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.17] replay: Fix declaration of replay_read_next_clock
Message-Id: <E1raGwi-0008S1-GS@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:13:12 +0000

commit 97e8df50760afab883f7d58a0c8dcde30aa28e0f
Author:     Richard Henderson <richard.henderson@linaro.org>
AuthorDate: Mon Nov 28 17:05:47 2022 -0800
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Fri Jul 21 11:08:48 2023 +0100

    replay: Fix declaration of replay_read_next_clock
    
    Fixes the build with gcc 13:
    
    replay/replay-time.c:34:6: error: conflicting types for  \
      'replay_read_next_clock' due to enum/integer mismatch; \
      have 'void(ReplayClockKind)' [-Werror=enum-int-mismatch]
       34 | void replay_read_next_clock(ReplayClockKind kind)
          |      ^~~~~~~~~~~~~~~~~~~~~~
    In file included from ../qemu/replay/replay-time.c:14:
    replay/replay-internal.h:139:6: note: previous declaration of \
      'replay_read_next_clock' with type 'void(unsigned int)'
      139 | void replay_read_next_clock(unsigned int kind);
          |      ^~~~~~~~~~~~~~~~~~~~~~
    
    Fixes: 8eda206e090 ("replay: recording and replaying clock ticks")
    Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Reviewed-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
    Reviewed-by: Pavel Dovgalyuk <Pavel.Dovgalyuk@ispras.ru>
    Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20221129010547.284051-1-richard.henderson@linaro.org>
    (cherry picked from commit fb72e779ebe3a51f55b16a49738380ee3e54c7d5)
---
 replay/replay-internal.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/replay/replay-internal.h b/replay/replay-internal.h
index 97649ed8d7..b4238226f4 100644
--- a/replay/replay-internal.h
+++ b/replay/replay-internal.h
@@ -141,7 +141,7 @@ bool replay_next_event_is(int event);
 /*! Reads next clock value from the file.
     If clock kind read from the file is different from the parameter,
     the value is not used. */
-void replay_read_next_clock(unsigned int kind);
+void replay_read_next_clock(ReplayClockKind kind);
 
 /* Asynchronous events queue */
 
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:13:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:13:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680971.1059439 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGwt-0003Bh-JR; Wed, 14 Feb 2024 15:13:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680971.1059439; Wed, 14 Feb 2024 15:13:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGwt-0003BW-GQ; Wed, 14 Feb 2024 15:13:23 +0000
Received: by outflank-mailman (input) for mailman id 680971;
 Wed, 14 Feb 2024 15:13:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGws-0003BF-L0
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGws-00065o-KG
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGws-0008Sc-JT
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Ir6ln6WLPow//uoLWIHzB8+TB5sul9uuYiik70li9OQ=; b=et+w91Sxi4R+dHbTiO55BiOndV
	JbM6We00ih4E4u7yJCZznI+hWL22NNCSOMKlXqqsKAvQCF05KjJsUNCkn+li/uFcmqmEoGniXXfnm
	xnOZzbBXRV2wIgF0FeWO9DRpytUsIHEzBQCPbAf/9GHBOPf6GYSWuaCJeCljYNZ66Exs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.17] softfloat: Fix declaration of partsN_compare
Message-Id: <E1raGws-0008Sc-JT@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:13:22 +0000

commit 69344f6be7bf94607c6ff0de79b81bac836e5f15
Author:     Richard Henderson <richard.henderson@linaro.org>
AuthorDate: Fri Apr 1 07:22:38 2022 -0600
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Fri Jul 21 11:20:26 2023 +0100

    softfloat: Fix declaration of partsN_compare
    
    The declaration used 'int', while the definition used 'FloatRelation'.
    This should have resulted in a compiler error, but mysteriously didn't.
    
    Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
    Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
    Message-Id: <20220401132240.79730-2-richard.henderson@linaro.org>
    (cherry picked from commit b880867f15623b2e82b0fa6b149753d7c18c615c)
---
 fpu/softfloat.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index 7f524d4377..7e62fcf414 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -874,10 +874,10 @@ static FloatParts128 *parts128_minmax(FloatParts128 *a, FloatParts128 *b,
 #define parts_minmax(A, B, S, F) \
     PARTS_GENERIC_64_128(minmax, A)(A, B, S, F)
 
-static int parts64_compare(FloatParts64 *a, FloatParts64 *b,
-                           float_status *s, bool q);
-static int parts128_compare(FloatParts128 *a, FloatParts128 *b,
-                            float_status *s, bool q);
+static FloatRelation parts64_compare(FloatParts64 *a, FloatParts64 *b,
+                                     float_status *s, bool q);
+static FloatRelation parts128_compare(FloatParts128 *a, FloatParts128 *b,
+                                      float_status *s, bool q);
 
 #define parts_compare(A, B, S, Q) \
     PARTS_GENERIC_64_128(compare, A)(A, B, S, Q)
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:13:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:13:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680972.1059443 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGx3-0003JS-Kd; Wed, 14 Feb 2024 15:13:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680972.1059443; Wed, 14 Feb 2024 15:13:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGx3-0003JJ-Hy; Wed, 14 Feb 2024 15:13:33 +0000
Received: by outflank-mailman (input) for mailman id 680972;
 Wed, 14 Feb 2024 15:13:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGx2-0003J6-O8
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGx2-00065v-NR
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGx2-0008T7-MU
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Zdkg/+UpSNb1TuaYjK5yFCT0pJ7xpfGcFX7DsMMEeDE=; b=RtDmqk+aLkh6tHPTD/Fz7PP46V
	Mn3tE3UhD1Pl5Ikvmucx6lDj17rLzgKzN3GmO4PFt1dS5r5Uu9fq7K8iZYelpvwwsHm774igYyg0k
	VTeXNy2tNUO2XIXth1S2PJylqkni7Vi2tlB2YDalmwQtmq0sWMPeL7zyqGdhLYEDTuu8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.17] async: Suppress GCC13 false positive in aio_bh_poll()
Message-Id: <E1raGx2-0008T7-MU@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:13:32 +0000

commit ffb451126550b22b43b62fb8731a0d78e3376c03
Author:     Cédric Le Goater <clg@redhat.com>
AuthorDate: Thu Apr 20 22:29:39 2023 +0200
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Fri Jul 21 11:57:33 2023 +0100

    async: Suppress GCC13 false positive in aio_bh_poll()
    
    GCC13 reports an error :
    
    ../util/async.c: In function ‘aio_bh_poll’:
    include/qemu/queue.h:303:22: error: storing the address of local variable ‘slice’ in ‘*ctx.bh_slice_list.sqh_last’ [-Werror=dangling-pointer=]
      303 |     (head)->sqh_last = &(elm)->field.sqe_next;                          \
          |     ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
    ../util/async.c:169:5: note: in expansion of macro ‘QSIMPLEQ_INSERT_TAIL’
      169 |     QSIMPLEQ_INSERT_TAIL(&ctx->bh_slice_list, &slice, next);
          |     ^~~~~~~~~~~~~~~~~~~~
    ../util/async.c:161:17: note: ‘slice’ declared here
      161 |     BHListSlice slice;
          |                 ^~~~~
    ../util/async.c:161:17: note: ‘ctx’ declared here
    
    But the local variable 'slice' is removed from the global context list
    in following loop of the same routine. Add a pragma to silent GCC.
    
    Cc: Stefan Hajnoczi <stefanha@redhat.com>
    Cc: Paolo Bonzini <pbonzini@redhat.com>
    Cc: Daniel P. Berrangé <berrange@redhat.com>
    Signed-off-by: Cédric Le Goater <clg@redhat.com>
    Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
    Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
    Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Tested-by: Daniel Henrique Barboza <danielhb413@gmail.com>
    Message-Id: <20230420202939.1982044-1-clg@kaod.org>
    Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
    (cherry picked from commit d66ba6dc1cce914673bd8a89fca30a7715ea70d1)
---
 util/async.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/util/async.c b/util/async.c
index 2ea1172f3e..0b3bf38e9d 100644
--- a/util/async.c
+++ b/util/async.c
@@ -150,7 +150,21 @@ int aio_bh_poll(AioContext *ctx)
     int ret = 0;
 
     QSLIST_MOVE_ATOMIC(&slice.bh_list, &ctx->bh_list);
+
+    /*
+     * GCC13 [-Werror=dangling-pointer=] complains that the local variable
+     * 'slice' is being stored in the global 'ctx->bh_slice_list' but the
+     * list is emptied before this function returns.
+     */
+#if !defined(__clang__)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wpragmas"
+#pragma GCC diagnostic ignored "-Wdangling-pointer="
+#endif
     QSIMPLEQ_INSERT_TAIL(&ctx->bh_slice_list, &slice, next);
+#if !defined(__clang__)
+#pragma GCC diagnostic pop
+#endif
 
     while ((s = QSIMPLEQ_FIRST(&ctx->bh_slice_list))) {
         QEMUBH *bh;
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:13:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:13:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680974.1059448 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGxE-0003QP-Nk; Wed, 14 Feb 2024 15:13:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680974.1059448; Wed, 14 Feb 2024 15:13:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGxE-0003QH-Kj; Wed, 14 Feb 2024 15:13:44 +0000
Received: by outflank-mailman (input) for mailman id 680974;
 Wed, 14 Feb 2024 15:13:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGxD-0003Q1-4c
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:43 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGxD-000664-3q
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGxD-0008UY-3E
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=9iLFhVrbHzsN80g5LzlyPIbLmNpQQn284Lsetg66jKg=; b=ah30LGeOr1oqYtmnWFWyC0pHuq
	pgX0s5p0ejusSOgXJyMaLlwKz4QlbBTVEWjcCjzHENNukA+UakSytDQ4+wNdvE4FnezEjTQYqt+pv
	Sm0PsUtiQyB2ifhQvgFIwWSWASkELVhACfEYgPCtl04dmOvTNNbDJoFHoxa0YMgVVWNE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.16] rtl8139: Remove unused variable
Message-Id: <E1raGxD-0008UY-3E@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:13:43 +0000

commit 204c1af1fc6f99ca70a671a013a30f5409e30786
Author:     Miroslav Rezanina <mrezanin@redhat.com>
AuthorDate: Wed Nov 9 10:57:11 2022 -0500
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Mon Jul 17 12:05:00 2023 +0100

    rtl8139: Remove unused variable
    
    Variable send_count used in rtl8139_cplus_transmit_one function is only
    incremented but never read. This causes 'Unused but set variable' warning
    on Clang 15.0.1 compiler.
    
    Removing the variable to prevent the warning.
    
    Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Message-Id: <15a32dd06c492216cbf27cd3ddcbe1e9afb8d8f5.1668009030.git.mrezanin@redhat.com>
    Signed-off-by: Thomas Huth <thuth@redhat.com>
    (cherry picked from commit 7d7238c72b983cff5064734349d2d45be9c6282c)
---
 hw/net/rtl8139.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 90b4fc63ce..e278ae1ed5 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -2156,7 +2156,6 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
                     ip_data_len, saved_size - ETH_HLEN, large_send_mss);
 
                 int tcp_send_offset = 0;
-                int send_count = 0;
 
                 /* maximum IP header length is 60 bytes */
                 uint8_t saved_ip_header[60];
@@ -2261,7 +2260,6 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
                     /* add transferred count to TCP sequence number */
                     stl_be_p(&p_tcp_hdr->th_seq,
                              chunk_size + ldl_be_p(&p_tcp_hdr->th_seq));
-                    ++send_count;
                 }
 
                 /* Stop sending this frame */
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.16


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:13:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:13:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680977.1059450 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGxO-0003Ux-Oh; Wed, 14 Feb 2024 15:13:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680977.1059450; Wed, 14 Feb 2024 15:13:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGxO-0003Up-MB; Wed, 14 Feb 2024 15:13:54 +0000
Received: by outflank-mailman (input) for mailman id 680977;
 Wed, 14 Feb 2024 15:13:53 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGxN-0003UT-9P
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:53 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGxN-00066U-6k
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:53 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGxN-0008VA-5w
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:13:53 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=4015QE1k/yJyGoYuAqvegQ/FNT8ztD9sVGAvIvN/8rI=; b=QaqCXl6j1g5/d5L5HxMlRSXiZU
	GbyRCKl5OtLrQetZZdGm7QgUOSRupdYsxIbCcg73A9oZiWh+3vh3yPKR++2uMm0uHtERWmK3sEBCC
	sVRBZwjno32K+bmb5co6P+x/lwTJJo/bzmvg3uYCB7qtQ9NkVCLCpKIZMIdo7elsVBpc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.16] tulip: Remove unused variable
Message-Id: <E1raGxN-0008VA-5w@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:13:53 +0000

commit 290836b2894d2f6a855b1b153f6a1e9ca82a5820
Author:     Miroslav Rezanina <mrezanin@redhat.com>
AuthorDate: Wed Nov 9 10:57:12 2022 -0500
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Mon Jul 17 12:05:00 2023 +0100

    tulip: Remove unused variable
    
    Variable n used in tulip_idblock_crc function is only incremented but never read.
    This causes 'Unused but set variable' warning on Clang 15.0.1 compiler.
    
    Removing the variable to prevent the warning.
    
    Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Message-Id: <02e1560d115c208df32236df8916fed98429fda1.1668009030.git.mrezanin@redhat.com>
    Signed-off-by: Thomas Huth <thuth@redhat.com>
    (cherry picked from commit 6083dcad80743718620a3f8a72fb76ea8b7c28ca)
---
 hw/net/tulip.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/hw/net/tulip.c b/hw/net/tulip.c
index ca69f7ea5e..42666378de 100644
--- a/hw/net/tulip.c
+++ b/hw/net/tulip.c
@@ -866,11 +866,10 @@ static const MemoryRegionOps tulip_ops = {
 
 static void tulip_idblock_crc(TULIPState *s, uint16_t *srom)
 {
-    int word, n;
+    int word;
     int bit;
     unsigned char bitval, crc;
     const int len = 9;
-    n = 0;
     crc = -1;
 
     for (word = 0; word < len; word++) {
@@ -883,7 +882,6 @@ static void tulip_idblock_crc(TULIPState *s, uint16_t *srom)
                 srom[len - 1] = (srom[len - 1] & 0xff00) | (unsigned short)crc;
                 break;
             }
-            n++;
             bitval = ((srom[word] >> bit) & 1) ^ ((crc >> 7) & 1);
             crc = crc << 1;
             if (bitval == 1) {
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.16


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:14:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:14:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680979.1059454 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGxY-0003Xm-Q2; Wed, 14 Feb 2024 15:14:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680979.1059454; Wed, 14 Feb 2024 15:14:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGxY-0003Xf-NY; Wed, 14 Feb 2024 15:14:04 +0000
Received: by outflank-mailman (input) for mailman id 680979;
 Wed, 14 Feb 2024 15:14:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGxX-0003XV-CM
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:14:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGxX-000670-9l
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:14:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGxX-0008W9-97
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:14:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=10UHm21dleK4MjIZPb53D9qDUkf0MsDlch1nWHj83VY=; b=ddrsz5MYAwGPJpapraF7vqCLJU
	eQroEfrLCwabgUoONM8wCzqSXPSIp152Ae5K1LfxdakGYlKVgy+bLJ1t4u/PuOok2NRSSyWPnysqz
	HGwd3VQ8Pm+hKk/SY0pk9agBCZ9eVGrQIa8RyP7uS6k38V8rv2S7ndDrZJtfwXUPoxfo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.16] qemu-img: remove unused variable
Message-Id: <E1raGxX-0008W9-97@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:14:03 +0000

commit 1b31565af3932ffe4a6e12012a406ae23aa381a1
Author:     Miroslav Rezanina <mrezanin@redhat.com>
AuthorDate: Wed Nov 9 10:57:13 2022 -0500
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Mon Jul 17 12:05:26 2023 +0100

    qemu-img: remove unused variable
    
    Variable block_count used in img_dd function is only incremented but never read.
    This causes 'Unused but set variable' warning on Clang 15.0.1 compiler.
    
    Removing the variable to prevent the warning.
    
    Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
    Reviewed-by: Thomas Huth <thuth@redhat.com>
    Message-Id: <e86d5b57f9d13bde995c616a533b876f1fb8a527.1668009030.git.mrezanin@redhat.com>
    Signed-off-by: Thomas Huth <thuth@redhat.com>
    (cherry picked from commit 0f48c47c679bc29fceb3a67283ee3b78175524bf)
---
 qemu-img.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qemu-img.c b/qemu-img.c
index 908fd0cce5..314ca0534d 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -4886,7 +4886,7 @@ static int img_dd(int argc, char **argv)
     const char *out_fmt = "raw";
     const char *fmt = NULL;
     int64_t size = 0;
-    int64_t block_count = 0, out_pos, in_pos;
+    int64_t out_pos, in_pos;
     bool force_share = false;
     struct DdInfo dd = {
         .flags = 0,
@@ -5086,7 +5086,7 @@ static int img_dd(int argc, char **argv)
 
     in.buf = g_new(uint8_t, in.bsz);
 
-    for (out_pos = 0; in_pos < size; block_count++) {
+    for (out_pos = 0; in_pos < size; ) {
         int in_ret, out_ret;
 
         if (in_pos + in.bsz > size) {
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.16


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:14:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:14:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680980.1059459 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGxi-0003aT-Rf; Wed, 14 Feb 2024 15:14:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680980.1059459; Wed, 14 Feb 2024 15:14:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGxi-0003aL-P0; Wed, 14 Feb 2024 15:14:14 +0000
Received: by outflank-mailman (input) for mailman id 680980;
 Wed, 14 Feb 2024 15:14:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGxh-0003a8-DI
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:14:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGxh-000677-Cb
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:14:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGxh-000051-Bo
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:14:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=rwCZEN/eeP5otqYeDCCzFF254s+uCkDfzhVy0k2ONtM=; b=N+Ug3Vx2OCdjngeCc7MCxPXJxE
	R1Cf5H2Gm+vjqqQ4UxyfDSFX6AU564b0u69qfMMWmXsgCx1hpgQShVVKz6ImbGa3QaYcr6dfcsEfG
	oUWS1/ma3jQ13un2Dy28mo9HAmWJCf6X7BNfNZM1AekkLeiBxBPBJOTWJm+95T4CaL2U=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.16] Update dtc to include build fix
Message-Id: <E1raGxh-000051-Bo@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:14:13 +0000

commit 770026a27872174f66e420f643abce0756a128f1
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Mon Jul 17 12:05:34 2023 +0100
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Mon Jul 17 12:05:34 2023 +0100

    Update dtc to include build fix
    
    Build fix:
        libfdt: Correct condition for reordering blocks
    
    This change also include one extra commit that seems to be a unit test
    only.
    
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 dtc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dtc b/dtc
index 85e5d83984..b6910bec11 160000
--- a/dtc
+++ b/dtc
@@ -1 +1 @@
-Subproject commit 85e5d839847af54efab170f2b1331b2a6421e647
+Subproject commit b6910bec11614980a21e46fbccc35934b671bd81
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.16


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:14:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:14:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680981.1059463 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGxs-0003d6-TW; Wed, 14 Feb 2024 15:14:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680981.1059463; Wed, 14 Feb 2024 15:14:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raGxs-0003cy-Qs; Wed, 14 Feb 2024 15:14:24 +0000
Received: by outflank-mailman (input) for mailman id 680981;
 Wed, 14 Feb 2024 15:14:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGxr-0003cn-GY
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:14:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGxr-00067K-Fq
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:14:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raGxr-00005d-Ex
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:14:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=av6iScbxycNBN/7vkmuBNNhJBlunHDKixg+GciZFLPY=; b=TFBZVezLFwDnC/bXZ1Sbe4r4kY
	s3UArNQDbeqx1uKjxXHdQOYJnlk1AL9eew1QeuZDf3u/7Szqk23z5NUZ8D5OKFx6w42iPklJPpRL2
	3gCHy41XuyYowZtXRglbKNfo/Z1JB6XXKF5hwBhKnm6T1Kb/8CD8EVO5tW+aW0hM+Ygw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.16] migration: Fix operator type
Message-Id: <E1raGxr-00005d-Ex@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:14:23 +0000

commit c02cb236b5e4a76cf74e641cc35a0e3ebd3e52f3
Author:     Dr. David Alan Gilbert <dgilbert@redhat.com>
AuthorDate: Wed Apr 6 11:25:15 2022 +0100
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Mon Jul 17 12:09:08 2023 +0100

    migration: Fix operator type
    
    Clang spotted an & that should have been an &&; fix it.
    
    Reported by: David Binderman / https://gitlab.com/dcb
    Fixes: 65dacaa04fa ("migration: introduce save_normal_page()")
    Resolves: https://gitlab.com/qemu-project/qemu/-/issues/963
    Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
    Message-Id: <20220406102515.96320-1-dgilbert@redhat.com>
    Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
    Reviewed-by: Peter Xu <peterx@redhat.com>
    Signed-off-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
    (cherry picked from commit f912ec5b2d65644116ff496b58d7c9145c19e4c0)
    (cherry picked from commit b746458e1ce1bec85e58b458386f8b7a0bedfaa6)
---
 migration/ram.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/migration/ram.c b/migration/ram.c
index 7a43bfd7af..541f6b6b41 100644
--- a/migration/ram.c
+++ b/migration/ram.c
@@ -1155,7 +1155,7 @@ static int save_normal_page(RAMState *rs, RAMBlock *block, ram_addr_t offset,
                                                  offset | RAM_SAVE_FLAG_PAGE);
     if (async) {
         qemu_put_buffer_async(rs->f, buf, TARGET_PAGE_SIZE,
-                              migrate_release_ram() &
+                              migrate_release_ram() &&
                               migration_in_postcopy());
     } else {
         qemu_put_buffer(rs->f, buf, TARGET_PAGE_SIZE);
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.16


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:22:07 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:22:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680988.1059486 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raH5J-00064I-UI; Wed, 14 Feb 2024 15:22:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680988.1059486; Wed, 14 Feb 2024 15:22:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raH5J-00064D-Rc; Wed, 14 Feb 2024 15:22:05 +0000
Received: by outflank-mailman (input) for mailman id 680988;
 Wed, 14 Feb 2024 15:22:05 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raH5J-00063n-Be
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:22:05 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raH5J-0006Gb-8q
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:22:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raH5J-0000ht-66
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:22:05 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=0//CCzx4Zpj6AlS18QtICc77BvMXyALBx954xYYkiQ4=; b=Otj1JNPOVIqu5QsZJ75X+ojeM5
	RMU/DcYp2+GQfmM0aSH+Mo6F3LRPg9VNBw/FGNgPN7zHkiZBvvBrjheBplCujiSDRYlYry8bzZAZX
	dmRCKD0TqVaTguJdb+mkOUAGD1smu4BMDsnnt8ACyci9WKLDs5e311gTcejEYWHQAVSI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging] main loop: Big hammer to fix logfile disk DoS in Xen setups
Message-Id: <E1raH5J-0000ht-66@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:22:05 +0000

commit 1cf02b05b27c48775a25699e61b93b814b9ae042
Author:     Ian Jackson <ian.jackson@eu.citrix.com>
AuthorDate: Thu May 26 16:21:56 2016 +0100
Commit:     Anthony PERARD <anthony.perard@gmail.com>
CommitDate: Thu Dec 15 15:19:18 2022 +0000

    main loop: Big hammer to fix logfile disk DoS in Xen setups
    
    Each time round the main loop, we now fstat stderr.  If it is too big,
    we dup2 /dev/null onto it.  This is not a very pretty patch but it is
    very simple, easy to see that it's correct, and has a low risk of
    collateral damage.
    
    There is no limit by default but can be adjusted by setting a new
    environment variable.
    
    This fixes CVE-2014-3672.
    
    Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
    Tested-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
    
    Set the default to 0 so that it won't affect non-xen installation. The
    limit will be set by Xen toolstack.
    
    Signed-off-by: Wei Liu <wei.liu2@citrix.com>
    Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    (cherry picked from commit 44a072f0de0d57c95c2212bbce02888832b7b74f)
    (cherry picked from commit 269381bb635692856aa8789a3f322e543e0c648d)
---
 util/main-loop.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/util/main-loop.c b/util/main-loop.c
index 10fa74c6e3..7dfb95e3c5 100644
--- a/util/main-loop.c
+++ b/util/main-loop.c
@@ -186,6 +186,50 @@ int qemu_init_main_loop(Error **errp)
     return 0;
 }
 
+static void check_cve_2014_3672_xen(void)
+{
+    static unsigned long limit = ~0UL;
+    const int fd = 2;
+    struct stat stab;
+
+    if (limit == ~0UL) {
+        const char *s = getenv("XEN_QEMU_CONSOLE_LIMIT");
+        /* XEN_QEMU_CONSOLE_LIMIT=0 means no limit */
+        limit = s ? strtoul(s,0,0) : 0;
+    }
+    if (limit == 0)
+        return;
+
+    int r = fstat(fd, &stab);
+    if (r) {
+        perror("fstat stderr (for CVE-2014-3672 check)");
+        exit(-1);
+    }
+    if (!S_ISREG(stab.st_mode))
+        return;
+    if (stab.st_size <= limit)
+        return;
+
+    /* oh dear */
+    fprintf(stderr,"\r\n"
+            "Closing stderr due to CVE-2014-3672 limit. "
+            " Set XEN_QEMU_CONSOLE_LIMIT to number of bytes to override,"
+            " or 0 for no limit.\n");
+    fflush(stderr);
+
+    int nfd = open("/dev/null", O_WRONLY);
+    if (nfd < 0) {
+        perror("open /dev/null (for CVE-2014-3672 check)");
+        exit(-1);
+    }
+    r = dup2(nfd, fd);
+    if (r != fd) {
+        perror("dup2 /dev/null (for CVE-2014-3672 check)");
+        exit(-1);
+    }
+    close(nfd);
+}
+
 static void main_loop_update_params(EventLoopBase *base, Error **errp)
 {
     ERRP_GUARD();
@@ -307,6 +351,8 @@ static int os_host_main_loop_wait(int64_t timeout)
 
     g_main_context_acquire(context);
 
+    check_cve_2014_3672_xen();
+
     glib_pollfds_fill(&timeout);
 
     qemu_mutex_unlock_iothread();
@@ -489,6 +535,8 @@ static int os_host_main_loop_wait(int64_t timeout)
 
     g_main_context_acquire(context);
 
+    check_cve_2014_3672_xen();
+
     /* XXX: need to suppress polling by better using win32 events */
     ret = 0;
     for (pe = first_polling_entry; pe != NULL; pe = pe->next) {
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:22:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:22:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.680989.1059492 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raH5M-00068X-0H; Wed, 14 Feb 2024 15:22:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 680989.1059492; Wed, 14 Feb 2024 15:22:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raH5L-00068P-Su; Wed, 14 Feb 2024 15:22:07 +0000
Received: by outflank-mailman (input) for mailman id 680989;
 Wed, 14 Feb 2024 15:22:07 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raH5L-00065k-3x
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:22:07 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raH5L-0006Gf-3E
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:22:07 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raH5L-0000uZ-0X
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:22:07 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=CKZmyGK0QmQdS5ezT76zaOBjmHPaHrAxn9+Ax1kQ0Hk=; b=rfYu69kbemZyvDtOQ9LQIHRJLG
	57dNi3YKTkTb42Pr/6F2ulJFdrg0FmCY6B8QqPsZAqlQUbOVD3dFocrDLzP2EwPV2X3qgeccxM8ud
	U2sZt2LKU/xtEufOqPI3IpPtvAN6SsqkHzpiRmzuJyJS18lsa+QiDGnqKpPdnNxyNPuM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.18] main loop: Big hammer to fix logfile disk DoS in Xen setups
Message-Id: <E1raH5L-0000uZ-0X@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:22:07 +0000

commit 1cf02b05b27c48775a25699e61b93b814b9ae042
Author:     Ian Jackson <ian.jackson@eu.citrix.com>
AuthorDate: Thu May 26 16:21:56 2016 +0100
Commit:     Anthony PERARD <anthony.perard@gmail.com>
CommitDate: Thu Dec 15 15:19:18 2022 +0000

    main loop: Big hammer to fix logfile disk DoS in Xen setups
    
    Each time round the main loop, we now fstat stderr.  If it is too big,
    we dup2 /dev/null onto it.  This is not a very pretty patch but it is
    very simple, easy to see that it's correct, and has a low risk of
    collateral damage.
    
    There is no limit by default but can be adjusted by setting a new
    environment variable.
    
    This fixes CVE-2014-3672.
    
    Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
    Tested-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
    
    Set the default to 0 so that it won't affect non-xen installation. The
    limit will be set by Xen toolstack.
    
    Signed-off-by: Wei Liu <wei.liu2@citrix.com>
    Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    (cherry picked from commit 44a072f0de0d57c95c2212bbce02888832b7b74f)
    (cherry picked from commit 269381bb635692856aa8789a3f322e543e0c648d)
---
 util/main-loop.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/util/main-loop.c b/util/main-loop.c
index 10fa74c6e3..7dfb95e3c5 100644
--- a/util/main-loop.c
+++ b/util/main-loop.c
@@ -186,6 +186,50 @@ int qemu_init_main_loop(Error **errp)
     return 0;
 }
 
+static void check_cve_2014_3672_xen(void)
+{
+    static unsigned long limit = ~0UL;
+    const int fd = 2;
+    struct stat stab;
+
+    if (limit == ~0UL) {
+        const char *s = getenv("XEN_QEMU_CONSOLE_LIMIT");
+        /* XEN_QEMU_CONSOLE_LIMIT=0 means no limit */
+        limit = s ? strtoul(s,0,0) : 0;
+    }
+    if (limit == 0)
+        return;
+
+    int r = fstat(fd, &stab);
+    if (r) {
+        perror("fstat stderr (for CVE-2014-3672 check)");
+        exit(-1);
+    }
+    if (!S_ISREG(stab.st_mode))
+        return;
+    if (stab.st_size <= limit)
+        return;
+
+    /* oh dear */
+    fprintf(stderr,"\r\n"
+            "Closing stderr due to CVE-2014-3672 limit. "
+            " Set XEN_QEMU_CONSOLE_LIMIT to number of bytes to override,"
+            " or 0 for no limit.\n");
+    fflush(stderr);
+
+    int nfd = open("/dev/null", O_WRONLY);
+    if (nfd < 0) {
+        perror("open /dev/null (for CVE-2014-3672 check)");
+        exit(-1);
+    }
+    r = dup2(nfd, fd);
+    if (r != fd) {
+        perror("dup2 /dev/null (for CVE-2014-3672 check)");
+        exit(-1);
+    }
+    close(nfd);
+}
+
 static void main_loop_update_params(EventLoopBase *base, Error **errp)
 {
     ERRP_GUARD();
@@ -307,6 +351,8 @@ static int os_host_main_loop_wait(int64_t timeout)
 
     g_main_context_acquire(context);
 
+    check_cve_2014_3672_xen();
+
     glib_pollfds_fill(&timeout);
 
     qemu_mutex_unlock_iothread();
@@ -489,6 +535,8 @@ static int os_host_main_loop_wait(int64_t timeout)
 
     g_main_context_acquire(context);
 
+    check_cve_2014_3672_xen();
+
     /* XXX: need to suppress polling by better using win32 events */
     ret = 0;
     for (pe = first_polling_entry; pe != NULL; pe = pe->next) {
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:33:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:33:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681020.1059539 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHG0-0001pC-UV; Wed, 14 Feb 2024 15:33:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681020.1059539; Wed, 14 Feb 2024 15:33:08 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHG0-0001p4-Rh; Wed, 14 Feb 2024 15:33:08 +0000
Received: by outflank-mailman (input) for mailman id 681020;
 Wed, 14 Feb 2024 15:33:06 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHFy-0001oe-UR
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:33:06 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHFy-0006Sr-Tm
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:33:06 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHFy-0001lt-R9
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:33:06 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=qGnNRBurL7zNztWkyZo2EyI7hgfuRYT3KJbmLBCs1E4=; b=uySNkA0b4g1saeX0MJ8K5nkj0o
	uDsFAo5EPIgkXq457dsqbVpDIDhn7pcRxlm7Kk30+R4hap6TjJFyqd/2UVPbQQj39TLrwf04DCsbA
	qik9kuDhq1s6MDeqM3xDihBMOf+Tsg26CSIQ6rXYfvzULxvRHCiaXFh/c7Hh0mjzaFsg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.18] configure: Expand test which disable -Wmissing-braces
Message-Id: <E1raHFy-0001lt-R9@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:33:06 +0000

commit 625eb5e96dc96aa7fddef59a08edae215527f19c
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Fri Jan 6 15:21:10 2023 +0100
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Tue Jan 17 15:10:57 2023 +0000

    configure: Expand test which disable -Wmissing-braces
    
    With "clang 6.0.0-1ubuntu2" on Ubuntu Bionic, the test with build
    fine, but clang still suggest braces around the zero initializer in a
    few places, where there is a subobject. Expand test to include a sub
    struct which doesn't build on clang 6.0.0-1ubuntu2, and give:
        config-temp/qemu-conf.c:7:8: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
        } x = {0};
               ^
               {}
    
    These are the error reported by clang on QEMU's code (v7.2.0):
    hw/pci-bridge/cxl_downstream.c:101:51: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
        dvsec = (uint8_t *)&(CXLDVSECPortExtensions){ 0 };
    
    hw/pci-bridge/cxl_root_port.c:62:51: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
        dvsec = (uint8_t *)&(CXLDVSECPortExtensions){ 0 };
    
    tests/qtest/virtio-net-test.c:322:34: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
        QOSGraphTestOptions opts = { 0 };
    
    Reported-by: Andrew Cooper <Andrew.Cooper3@citrix.com>
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Message-Id: <20230106142110.672-1-anthony.perard@citrix.com>
---
 configure | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/configure b/configure
index 26c7bc5154..08eac0d42c 100755
--- a/configure
+++ b/configure
@@ -1288,7 +1288,11 @@ fi
 # Disable -Wmissing-braces on older compilers that warn even for
 # the "universal" C zero initializer {0}.
 cat > $TMPC << EOF
+struct s {
+  void *a;
+};
 struct {
+  struct s s;
   int a[2];
 } x = {0};
 EOF
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:33:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:33:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681019.1059535 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHFy-0001nb-Rt; Wed, 14 Feb 2024 15:33:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681019.1059535; Wed, 14 Feb 2024 15:33:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHFy-0001nS-P4; Wed, 14 Feb 2024 15:33:06 +0000
Received: by outflank-mailman (input) for mailman id 681019;
 Wed, 14 Feb 2024 15:33:05 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHFx-0001lw-4L
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:33:05 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHFx-0006Sn-3U
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:33:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHFx-0001ZM-2T
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:33:05 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=CeqGSOUXo7jGzg4OqEiM2C2oi0Vw+73wmnf6PiVrv50=; b=JVAINuIhCXyk3SUSWLPQeKzbA7
	+aWsoPej42eS0Rd5zKHS+gT2ftP+f7jQXm9YLZXTHLxqW+yKVy2RwRVZelUrEoDfZAaL2yPxiqflI
	5oeZP52s40YANgkt0LRDQLUmEko1LSAsx9vlpQM9d0MzKcy/uD7WA7yulWkH4VRv87Ug=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging] configure: Expand test which disable -Wmissing-braces
Message-Id: <E1raHFx-0001ZM-2T@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:33:05 +0000

commit 625eb5e96dc96aa7fddef59a08edae215527f19c
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Fri Jan 6 15:21:10 2023 +0100
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Tue Jan 17 15:10:57 2023 +0000

    configure: Expand test which disable -Wmissing-braces
    
    With "clang 6.0.0-1ubuntu2" on Ubuntu Bionic, the test with build
    fine, but clang still suggest braces around the zero initializer in a
    few places, where there is a subobject. Expand test to include a sub
    struct which doesn't build on clang 6.0.0-1ubuntu2, and give:
        config-temp/qemu-conf.c:7:8: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
        } x = {0};
               ^
               {}
    
    These are the error reported by clang on QEMU's code (v7.2.0):
    hw/pci-bridge/cxl_downstream.c:101:51: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
        dvsec = (uint8_t *)&(CXLDVSECPortExtensions){ 0 };
    
    hw/pci-bridge/cxl_root_port.c:62:51: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
        dvsec = (uint8_t *)&(CXLDVSECPortExtensions){ 0 };
    
    tests/qtest/virtio-net-test.c:322:34: error: suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
        QOSGraphTestOptions opts = { 0 };
    
    Reported-by: Andrew Cooper <Andrew.Cooper3@citrix.com>
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Message-Id: <20230106142110.672-1-anthony.perard@citrix.com>
---
 configure | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/configure b/configure
index 26c7bc5154..08eac0d42c 100755
--- a/configure
+++ b/configure
@@ -1288,7 +1288,11 @@ fi
 # Disable -Wmissing-braces on older compilers that warn even for
 # the "universal" C zero initializer {0}.
 cat > $TMPC << EOF
+struct s {
+  void *a;
+};
 struct {
+  struct s s;
   int a[2];
 } x = {0};
 EOF
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:44:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:44:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681032.1059552 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHQb-00043c-Sh; Wed, 14 Feb 2024 15:44:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681032.1059552; Wed, 14 Feb 2024 15:44:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHQb-00043V-QB; Wed, 14 Feb 2024 15:44:05 +0000
Received: by outflank-mailman (input) for mailman id 681032;
 Wed, 14 Feb 2024 15:44:05 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHQb-00043N-3i
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:44:05 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHQa-0006dV-Vx
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:44:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHQa-0002eZ-V5
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:44:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=3Z55g7rxCEomsGNp+e6JfcRy7+BKJlLryFPlQ1pvo9A=; b=juXQZByZ2AoVpGkw785K+yBHiP
	QonS6NaUbYqqh+Zw8jm0PcoHBf3k6pAojJwz1ra0X5ssRU/2LXJJqHoztgOzR+WtKde7dFXQCT7Ns
	bY1rOCE3Co2s9llK9k1npyc7laxR6ZCgFYhdRQcD3+pLCdRfj5G1oGO3aF/bmmENFYq0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging] hw/xen/xen_pt: fix uninitialized variable
Message-Id: <E1raHQa-0002eZ-V5@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:44:04 +0000

commit 8c51cd970509b97d8378d175646ec32889828158
Author:     Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
AuthorDate: Fri Jan 27 06:08:14 2023 +0100
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Mon Mar 27 14:26:19 2023 +0100

    hw/xen/xen_pt: fix uninitialized variable
    
    xen_pt_config_reg_init() reads only that many bytes as the size of the
    register that is being initialized. It uses
    xen_host_pci_get_{byte,word,long} and casts its last argument to
    expected pointer type. This means for smaller registers higher bits of
    'val' are not initialized. Then, the function fails if any of those
    higher bits are set.
    
    Fix this by initializing 'val' with zero.
    
    Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Message-Id: <20230127050815.4155276-1-marmarek@invisiblethingslab.com>
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    (cherry picked from commit 3856734d80fbf46683e4080117ed961f5ab1300b)
---
 hw/xen/xen_pt_config_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
index cde898b744..8b9b554352 100644
--- a/hw/xen/xen_pt_config_init.c
+++ b/hw/xen/xen_pt_config_init.c
@@ -1924,7 +1924,7 @@ static void xen_pt_config_reg_init(XenPCIPassthroughState *s,
     if (reg->init) {
         uint32_t host_mask, size_mask;
         unsigned int offset;
-        uint32_t val;
+        uint32_t val = 0;
 
         /* initialize emulate register */
         rc = reg->init(s, reg_entry->reg,
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:44:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:44:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681033.1059557 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHQd-000451-U0; Wed, 14 Feb 2024 15:44:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681033.1059557; Wed, 14 Feb 2024 15:44:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHQd-00044t-RL; Wed, 14 Feb 2024 15:44:07 +0000
Received: by outflank-mailman (input) for mailman id 681033;
 Wed, 14 Feb 2024 15:44:06 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHQc-00044c-Ts
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:44:06 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHQc-0006dZ-RK
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:44:06 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHQc-0002qz-Mq
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:44:06 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=l0qpZ25qIUJHTTwCzjncSBzju0cmCyevAGsBWO6nN5c=; b=la45pSIGXLipKrRVI4sVsgiztp
	rZmwFHOI1NZBoLOEZ9PpMLcEN17ITG/R39ChpxoR0cUZ721XtKP3GS4A87HlyZpXz2c+JHlV0ih+1
	1kG6xjnenI1qQXbXkO3v+CFgqwtNcaKwyW2pT8SXxAoZhLhTtmsfhip5+9VwOLxX2MA8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.18] hw/xen/xen_pt: fix uninitialized variable
Message-Id: <E1raHQc-0002qz-Mq@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:44:06 +0000

commit 8c51cd970509b97d8378d175646ec32889828158
Author:     Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
AuthorDate: Fri Jan 27 06:08:14 2023 +0100
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Mon Mar 27 14:26:19 2023 +0100

    hw/xen/xen_pt: fix uninitialized variable
    
    xen_pt_config_reg_init() reads only that many bytes as the size of the
    register that is being initialized. It uses
    xen_host_pci_get_{byte,word,long} and casts its last argument to
    expected pointer type. This means for smaller registers higher bits of
    'val' are not initialized. Then, the function fails if any of those
    higher bits are set.
    
    Fix this by initializing 'val' with zero.
    
    Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Message-Id: <20230127050815.4155276-1-marmarek@invisiblethingslab.com>
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    (cherry picked from commit 3856734d80fbf46683e4080117ed961f5ab1300b)
---
 hw/xen/xen_pt_config_init.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/xen/xen_pt_config_init.c b/hw/xen/xen_pt_config_init.c
index cde898b744..8b9b554352 100644
--- a/hw/xen/xen_pt_config_init.c
+++ b/hw/xen/xen_pt_config_init.c
@@ -1924,7 +1924,7 @@ static void xen_pt_config_reg_init(XenPCIPassthroughState *s,
     if (reg->init) {
         uint32_t host_mask, size_mask;
         unsigned int offset;
-        uint32_t val;
+        uint32_t val = 0;
 
         /* initialize emulate register */
         rc = reg->init(s, reg_entry->reg,
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:55:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:55:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681046.1059584 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHbM-0006gZ-8W; Wed, 14 Feb 2024 15:55:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681046.1059584; Wed, 14 Feb 2024 15:55:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHbM-0006gS-5O; Wed, 14 Feb 2024 15:55:12 +0000
Received: by outflank-mailman (input) for mailman id 681046;
 Wed, 14 Feb 2024 15:55:10 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHbK-0006gB-OS
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:55:10 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHbK-0006on-NW
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:55:10 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHbK-00041H-MQ
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:55:10 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=J/fGcuL17hZKLt75whHJ1Qva/E6XHqwHh9alqBX0aKI=; b=rkR6OUb8Ckq9bF1Ylr8aFu/amv
	ag2SUTizcf+I04CTQ2IfiPLnKCgrGK56p1zkJ8ycc/pGklbegonrgh4eetqs0viPFnDz2qZQHjHjp
	7956HSC0jRCPxsZ0G+DmQVnCxJsJOUCMr8fg9PzZYB2Sfl5O/x6YjBVDNSayY44Bf07M=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.18] Merge tag 'v7.2.4' into staging
Message-Id: <E1raHbK-00041H-MQ@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:55:10 +0000

=== This changeset includes merge from high-traffic branch ===
Commits on that branch are not reported individually.

commit 698407ef8395521a9a5b15ed9cd0b7e1fc258ded
Merge: 8c51cd970509b97d8378d175646ec32889828158 681858ea14242d3b509b77e0179f7f63c99032bb
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Fri Jul 21 14:57:10 2023 +0100
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Fri Jul 21 14:57:10 2023 +0100

    Merge tag 'v7.2.4' into staging
    
    v7.2.4 release
 .gitlab-ci.d/buildtest.yml                         |   6 +-
 VERSION                                            |   2 +-
 accel/tcg/cputlb.c                                 |   2 +-
 block/curl.c                                       |  44 ++++-
 block/io.c                                         |   3 +
 block/iscsi.c                                      |   1 +
 block/monitor/block-hmp-cmds.c                     |  10 +-
 block/qcow2-bitmap.c                               |   5 +-
 block/vhdx-log.c                                   |   2 +-
 blockdev.c                                         |  18 +-
 chardev/char-socket.c                              |   1 +
 configure                                          |   2 +-
 docs/about/deprecated.rst                          |   4 +-
 docs/system/multi-process.rst                      |   2 +-
 fpu/softfloat.c                                    |   2 +-
 fsdev/virtfs-proxy-helper.c                        |  27 ++-
 hw/9pfs/9p-util.h                                  |  38 ++++
 hw/9pfs/trace-events                               |   6 +
 hw/9pfs/xen-9p-backend.c                           |  35 ++--
 hw/acpi/cpu_hotplug.c                              |   3 +
 hw/acpi/pcihp.c                                    |  10 ++
 hw/arm/aspeed.c                                    |  42 ++---
 hw/arm/boot.c                                      |  40 ++---
 hw/arm/raspi.c                                     |  64 +++----
 hw/arm/xlnx-zynqmp.c                               |   2 +-
 hw/core/machine.c                                  |  11 ++
 hw/display/virtio-gpu.c                            |  27 ++-
 hw/dma/xilinx_axidma.c                             |  11 +-
 hw/hppa/machine.c                                  |  15 +-
 hw/i386/intel_iommu.c                              |  15 ++
 hw/i386/microvm.c                                  |   2 +-
 hw/i386/pc.c                                       |   4 +-
 hw/i386/pc_piix.c                                  |   3 +-
 hw/i386/pc_q35.c                                   |   2 -
 hw/i386/x86.c                                      |  88 ++-------
 hw/intc/allwinner-a10-pic.c                        |   7 +-
 hw/misc/aspeed_hace.c                              |   2 +-
 hw/net/allwinner-sun8i-emac.c                      |  22 ++-
 hw/net/e1000.c                                     |   9 +-
 hw/net/e1000e_core.c                               |   5 +-
 hw/net/e1000x_common.c                             |   5 +-
 hw/net/msf2-emac.c                                 |  18 +-
 hw/net/rtl8139.c                                   |   3 +
 hw/net/virtio-net.c                                |   1 -
 hw/net/vmxnet3.c                                   |   2 +-
 hw/nvme/ctrl.c                                     |  35 +++-
 hw/nvram/fw_cfg.c                                  |  12 +-
 hw/ppc/ppc.c                                       |   2 +
 hw/ppc/prep.c                                      |   4 +-
 hw/rdma/vmw/pvrdma_cmd.c                           |   6 +
 hw/remote/trace-events                             |   4 +-
 hw/riscv/numa.c                                    |   6 +
 hw/scsi/lsi53c895a.c                               |  23 ++-
 hw/scsi/scsi-generic.c                             |  14 +-
 hw/sd/allwinner-sdhost.c                           |  31 +++-
 hw/smbios/smbios.c                                 |   8 +-
 hw/timer/hpet.c                                    |  19 +-
 hw/timer/nrf51_timer.c                             |   7 +-
 hw/usb/hcd-ohci.c                                  |   2 +
 hw/vfio/pci.c                                      |   8 +-
 hw/virtio/vhost-shadow-virtqueue.c                 |   7 +-
 hw/virtio/vhost-shadow-virtqueue.h                 |   3 +
 hw/virtio/vhost-user-gpio.c                        |  10 +-
 hw/virtio/vhost-user-i2c.c                         |   5 +-
 hw/virtio/vhost-user-rng.c                         |   5 +-
 hw/virtio/vhost-user.c                             | 104 ++---------
 hw/virtio/vhost-vdpa.c                             |  17 +-
 hw/virtio/vhost.c                                  |  87 ++++++---
 hw/virtio/virtio-crypto.c                          |  20 ++-
 hw/virtio/virtio-mem.c                             |   6 +-
 hw/virtio/virtio.c                                 |  11 +-
 hw/xen/xen_pt.c                                    |  64 +++++--
 hw/xen/xen_pt.h                                    |  20 +++
 hw/xen/xen_pt_stub.c                               |   4 +
 include/hw/arm/boot.h                              |  49 +++++
 include/hw/i386/pc.h                               |   3 -
 include/hw/i386/x86.h                              |   3 +-
 include/hw/nvram/fw_cfg.h                          |  22 ---
 include/hw/virtio/vhost-user-gpio.h                |   2 +-
 include/qemu/compiler.h                            |  13 ++
 include/qemu/host-utils.h                          |   2 +-
 include/qemu/osdep.h                               |   2 +-
 io/channel-tls.c                                   |   3 +
 linux-user/fd-trans.c                              |  10 +-
 linux-user/fd-trans.h                              |   1 +
 linux-user/generic/target_resource.h               |   4 +-
 linux-user/mips/cpu_loop.c                         |   5 +-
 linux-user/s390x/cpu_loop.c                        |   9 +
 linux-user/syscall.c                               | 120 +++++++++----
 meson.build                                        |   6 +-
 migration/migration.c                              |  30 ++--
 migration/ram.c                                    |   9 +-
 net/vhost-vdpa.c                                   |  11 +-
 pc-bios/hppa-firmware.img                          | Bin 719368 -> 720216 bytes
 pc-bios/keymaps/meson.build                        |   2 +-
 qemu-options.hx                                    |  24 ++-
 qga/commands-posix.c                               |  12 +-
 qga/commands.c                                     |   5 +-
 qga/installer/qemu-ga.wxs                          |   1 +
 qga/vss-win32/install.cpp                          |   2 +-
 roms/seabios-hppa                                  |   2 +-
 scripts/device-crash-test                          |   4 +-
 scripts/shaderinclude.pl                           |  16 --
 scripts/shaderinclude.py                           |  26 +++
 scripts/symlink-install-tree.py                    |   1 -
 softmmu/icount.c                                   |   9 +-
 subprojects/libvhost-user/libvhost-user.c          |   7 +
 target/arm/cpu.h                                   |   3 +
 target/arm/helper.c                                |   3 +
 target/arm/kvm.c                                   |   2 +
 target/arm/kvm64.c                                 |  18 +-
 target/arm/kvm_arm.h                               |   8 +
 target/arm/ptw.c                                   |   6 +-
 target/arm/sve_helper.c                            |  20 ++-
 target/arm/tlb_helper.c                            |  13 +-
 target/arm/translate-a32.h                         |   7 +
 target/arm/translate-a64.c                         |  24 ++-
 target/arm/translate.c                             |   6 +-
 target/i386/cpu.c                                  |   4 +-
 target/i386/ops_sse.h                              |   8 +
 target/i386/tcg/decode-new.c.inc                   |  15 +-
 target/i386/tcg/emit.c.inc                         |  61 ++++---
 target/ppc/cpu_init.c                              |   2 +-
 target/ppc/excp_helper.c                           |   9 +-
 target/ppc/helper_regs.c                           |  73 ++++++--
 target/ppc/helper_regs.h                           |   1 +
 target/ppc/machine.c                               |   8 +-
 target/ppc/power8-pmu.c                            |  38 ++--
 target/ppc/power8-pmu.h                            |   4 +-
 target/ppc/translate.c                             |   1 +
 target/ppc/translate/vmx-impl.c.inc                |   2 +-
 target/riscv/insn_trans/trans_privileged.c.inc     |   6 +
 target/riscv/translate.c                           |  12 +-
 target/s390x/arch_dump.c                           |   2 +-
 target/s390x/cpu.h                                 |   1 +
 target/s390x/cpu_models.c                          |   4 +-
 target/s390x/cpu_models.h                          |  10 +-
 target/s390x/s390x-internal.h                      |   3 +-
 target/s390x/tcg/insn-data.h.inc                   |  10 +-
 target/s390x/tcg/mem_helper.c                      |   1 +
 target/s390x/tcg/translate.c                       | 106 ++++++++---
 target/sh4/cpu.c                                   |   2 +-
 .../docker/dockerfiles/debian-xtensa-cross.docker  |   2 +-
 tests/qtest/fuzz-lsi53c895a-test.c                 |  33 ++++
 tests/tcg/Makefile.target                          |   2 +
 tests/tcg/i386/Makefile.target                     |   6 +-
 tests/tcg/i386/test-i386-adcox.c                   |  75 ++++++++
 tests/tcg/i386/test-i386-bmi2.c                    | 197 +++++++++++----------
 tests/tcg/multiarch/linux/linux-test.c             |   6 +-
 tests/tcg/riscv64/Makefile.target                  |   6 +
 tests/tcg/riscv64/test-noc.S                       |  32 ++++
 tests/tcg/s390x/Makefile.target                    |  13 +-
 tests/tcg/s390x/gdbstub/test-svc.py                |  64 +++++++
 tests/tcg/s390x/hello-s390x-asm.S                  |  20 +++
 tests/tcg/s390x/lcbb.c                             |  51 ++++++
 tests/tcg/s390x/locfhr.c                           |  29 +++
 ui/console.c                                       |   4 +-
 ui/gtk-egl.c                                       |   9 +-
 ui/gtk-gl-area.c                                   |   5 +-
 ui/gtk.c                                           |  12 +-
 ui/sdl2-gl.c                                       |   4 +
 ui/sdl2.c                                          |   7 +
 ui/vnc-jobs.c                                      |   3 +-
 ui/vnc.c                                           |   2 +-
 util/async.c                                       |  14 ++
 util/fdmon-epoll.c                                 |  25 ++-
 util/vfio-helpers.c                                |   8 +-
 167 files changed, 1854 insertions(+), 850 deletions(-)

diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml
index d21b4a1fd4..10886bb414 100644
--- a/.gitlab-ci.d/buildtest.yml
+++ b/.gitlab-ci.d/buildtest.yml
@@ -109,8 +109,8 @@ crash-test-debian:
     IMAGE: debian-amd64
   script:
     - cd build
-    - make check-venv
-    - tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-i386
+    - make NINJA=":" check-venv
+    - tests/venv/bin/python3 scripts/device-crash-test -q --tcg-only ./qemu-system-i386
 
 build-system-fedora:
   extends: .native_build_job_template
@@ -155,7 +155,7 @@ crash-test-fedora:
     IMAGE: fedora
   script:
     - cd build
-    - make check-venv
+    - make NINJA=":" check-venv
     - tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-ppc
     - tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-riscv32
 
diff --git a/VERSION b/VERSION
index 0ee843cc60..2bbaead448 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-7.2.0
+7.2.4
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 6f1c00682b..1160aec626 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -1817,7 +1817,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
     } else /* if (prot & PAGE_READ) */ {
         tlb_addr = tlbe->addr_read;
         if (!tlb_hit(tlb_addr, addr)) {
-            if (!VICTIM_TLB_HIT(addr_write, addr)) {
+            if (!VICTIM_TLB_HIT(addr_read, addr)) {
                 tlb_fill(env_cpu(env), addr, size,
                          MMU_DATA_LOAD, mmu_idx, retaddr);
                 index = tlb_index(env, mmu_idx, addr);
diff --git a/block/curl.c b/block/curl.c
index cba4c4cac7..0b125095e3 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -37,8 +37,15 @@
 
 // #define DEBUG_VERBOSE
 
+/* CURL 7.85.0 switches to a string based API for specifying
+ * the desired protocols.
+ */
+#if LIBCURL_VERSION_NUM >= 0x075500
+#define PROTOCOLS "HTTP,HTTPS,FTP,FTPS"
+#else
 #define PROTOCOLS (CURLPROTO_HTTP | CURLPROTO_HTTPS | \
                    CURLPROTO_FTP | CURLPROTO_FTPS)
+#endif
 
 #define CURL_NUM_STATES 8
 #define CURL_NUM_ACB    8
@@ -509,9 +516,18 @@ static int curl_init_state(BDRVCURLState *s, CURLState *state)
          * obscure protocols.  For example, do not allow POP3/SMTP/IMAP see
          * CVE-2013-0249.
          *
-         * Restricting protocols is only supported from 7.19.4 upwards.
+         * Restricting protocols is only supported from 7.19.4 upwards. Note:
+         * version 7.85.0 deprecates CURLOPT_*PROTOCOLS in favour of a string
+         * based CURLOPT_*PROTOCOLS_STR API.
          */
-#if LIBCURL_VERSION_NUM >= 0x071304
+#if LIBCURL_VERSION_NUM >= 0x075500
+        if (curl_easy_setopt(state->curl,
+                             CURLOPT_PROTOCOLS_STR, PROTOCOLS) ||
+            curl_easy_setopt(state->curl,
+                             CURLOPT_REDIR_PROTOCOLS_STR, PROTOCOLS)) {
+            goto err;
+        }
+#elif LIBCURL_VERSION_NUM >= 0x071304
         if (curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS) ||
             curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS)) {
             goto err;
@@ -669,7 +685,12 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
     const char *file;
     const char *cookie;
     const char *cookie_secret;
-    double d;
+    /* CURL >= 7.55.0 uses curl_off_t for content length instead of a double */
+#if LIBCURL_VERSION_NUM >= 0x073700
+    curl_off_t cl;
+#else
+    double cl;
+#endif
     const char *secretid;
     const char *protocol_delimiter;
     int ret;
@@ -796,27 +817,36 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
     }
     if (curl_easy_perform(state->curl))
         goto out;
-    if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d)) {
+    /* CURL 7.55.0 deprecates CURLINFO_CONTENT_LENGTH_DOWNLOAD in favour of
+     * the *_T version which returns a more sensible type for content length.
+     */
+#if LIBCURL_VERSION_NUM >= 0x073700
+    if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &cl)) {
+        goto out;
+    }
+#else
+    if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl)) {
         goto out;
     }
+#endif
     /* Prior CURL 7.19.4 return value of 0 could mean that the file size is not
      * know or the size is zero. From 7.19.4 CURL returns -1 if size is not
      * known and zero if it is really zero-length file. */
 #if LIBCURL_VERSION_NUM >= 0x071304
-    if (d < 0) {
+    if (cl < 0) {
         pstrcpy(state->errmsg, CURL_ERROR_SIZE,
                 "Server didn't report file size.");
         goto out;
     }
 #else
-    if (d <= 0) {
+    if (cl <= 0) {
         pstrcpy(state->errmsg, CURL_ERROR_SIZE,
                 "Unknown file size or zero-length file.");
         goto out;
     }
 #endif
 
-    s->len = d;
+    s->len = cl;
 
     if ((!strncasecmp(s->url, "http://", strlen("http://"))
         || !strncasecmp(s->url, "https://", strlen("https://")))
diff --git a/block/io.c b/block/io.c
index b9424024f9..bbaa0d1b2d 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2087,6 +2087,9 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
         if (bs->detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP) {
             flags |= BDRV_REQ_MAY_UNMAP;
         }
+
+        /* Can't use optimization hint with bufferless zero write */
+        flags &= ~BDRV_REQ_REGISTERED_BUF;
     }
 
     if (ret < 0) {
diff --git a/block/iscsi.c b/block/iscsi.c
index a316d46d96..1bba42a71b 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -268,6 +268,7 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int status,
                 timer_mod(&iTask->retry_timer,
                           qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + retry_time);
                 iTask->do_retry = 1;
+                return;
             } else if (status == SCSI_STATUS_CHECK_CONDITION) {
                 int error = iscsi_translate_sense(&task->sense);
                 if (error == EAGAIN) {
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index b6135e9bfe..cf21b5e40a 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -213,15 +213,17 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
             error_report("Device '%s' not found", device);
             return;
         }
-        if (!blk_is_available(blk)) {
-            error_report("Device '%s' has no medium", device);
-            return;
-        }
 
         bs = bdrv_skip_implicit_filters(blk_bs(blk));
         aio_context = bdrv_get_aio_context(bs);
         aio_context_acquire(aio_context);
 
+        if (!blk_is_available(blk)) {
+            error_report("Device '%s' has no medium", device);
+            aio_context_release(aio_context);
+            return;
+        }
+
         ret = bdrv_commit(bs);
 
         aio_context_release(aio_context);
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index bcad567c0c..3dff99ba06 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -115,7 +115,7 @@ static int update_header_sync(BlockDriverState *bs)
     return bdrv_flush(bs->file->bs);
 }
 
-static inline void bitmap_table_to_be(uint64_t *bitmap_table, size_t size)
+static inline void bitmap_table_bswap_be(uint64_t *bitmap_table, size_t size)
 {
     size_t i;
 
@@ -1401,9 +1401,10 @@ static int store_bitmap(BlockDriverState *bs, Qcow2Bitmap *bm, Error **errp)
         goto fail;
     }
 
-    bitmap_table_to_be(tb, tb_size);
+    bitmap_table_bswap_be(tb, tb_size);
     ret = bdrv_pwrite(bs->file, tb_offset, tb_size * sizeof(tb[0]), tb, 0);
     if (ret < 0) {
+        bitmap_table_bswap_be(tb, tb_size);
         error_setg_errno(errp, -ret, "Failed to write bitmap '%s' to file",
                          bm_name);
         goto fail;
diff --git a/block/vhdx-log.c b/block/vhdx-log.c
index 572582b87b..0866897a85 100644
--- a/block/vhdx-log.c
+++ b/block/vhdx-log.c
@@ -980,7 +980,7 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHDXState *s,
             sector_write = merged_sector;
         } else if (i == sectors - 1 && trailing_length) {
             /* partial sector at the end of the buffer */
-            ret = bdrv_pread(bs->file, file_offset,
+            ret = bdrv_pread(bs->file, file_offset + trailing_length,
                              VHDX_LOG_SECTOR_SIZE - trailing_length,
                              merged_sector + trailing_length, 0);
             if (ret < 0) {
diff --git a/blockdev.c b/blockdev.c
index 3f1dec6242..ae27a41efa 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -152,12 +152,22 @@ void blockdev_mark_auto_del(BlockBackend *blk)
 
     JOB_LOCK_GUARD();
 
-    for (job = block_job_next_locked(NULL); job;
-         job = block_job_next_locked(job)) {
-        if (block_job_has_bdrv(job, blk_bs(blk))) {
+    do {
+        job = block_job_next_locked(NULL);
+        while (job && (job->job.cancelled ||
+                       job->job.deferred_to_main_loop ||
+                       !block_job_has_bdrv(job, blk_bs(blk))))
+        {
+            job = block_job_next_locked(job);
+        }
+        if (job) {
+            /*
+             * This drops the job lock temporarily and polls, so we need to
+             * restart processing the list from the start after this.
+             */
             job_cancel_locked(&job->job, false);
         }
-    }
+    } while (job);
 
     dinfo->auto_del = 1;
 }
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 879564aa8a..b00efb1482 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -1065,6 +1065,7 @@ static void char_socket_finalize(Object *obj)
         qio_net_listener_set_client_func_full(s->listener, NULL, NULL,
                                               NULL, chr->gcontext);
         object_unref(OBJECT(s->listener));
+        s->listener = NULL;
     }
     if (s->tls_creds) {
         object_unref(OBJECT(s->tls_creds));
diff --git a/configure b/configure
index 08eac0d42c..3ecc35c217 100755
--- a/configure
+++ b/configure
@@ -2420,7 +2420,7 @@ echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak
 echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
 echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
 echo "GLIB_BINDIR=$glib_bindir" >> $config_host_mak
-echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
+echo "GLIB_VERSION=$($pkg_config --modversion glib-2.0)" >> $config_host_mak
 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
 echo "EXESUF=$EXESUF" >> $config_host_mak
 
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index 93affe3669..0b26c01da0 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -233,8 +233,8 @@ Use the more generic event ``DEVICE_UNPLUG_GUEST_ERROR`` instead.
 System emulator machines
 ------------------------
 
-Arm ``virt`` machine ``dtb-kaslr-seed`` property
-''''''''''''''''''''''''''''''''''''''''''''''''
+Arm ``virt`` machine ``dtb-kaslr-seed`` property (since 7.1)
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
 The ``dtb-kaslr-seed`` property on the ``virt`` board has been
 deprecated; use the new name ``dtb-randomness`` instead. The new name
diff --git a/docs/system/multi-process.rst b/docs/system/multi-process.rst
index 210531ee17..1b8852c27c 100644
--- a/docs/system/multi-process.rst
+++ b/docs/system/multi-process.rst
@@ -2,7 +2,7 @@ Multi-process QEMU
 ==================
 
 This document describes how to configure and use multi-process qemu.
-For the design document refer to docs/devel/qemu-multiprocess.
+For the design document refer to docs/devel/multi-process.rst.
 
 1) Configuration
 ----------------
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index c7454c3eb1..108f9cb224 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -5135,7 +5135,7 @@ float32 float32_exp2(float32 a, float_status *status)
     float64_unpack_canonical(&rp, float64_one, status);
     for (i = 0 ; i < 15 ; i++) {
         float64_unpack_canonical(&tp, float32_exp2_coefficients[i], status);
-        rp = *parts_muladd(&tp, &xp, &rp, 0, status);
+        rp = *parts_muladd(&tp, &xnp, &rp, 0, status);
         xnp = *parts_mul(&xnp, &xp, status);
     }
 
diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
index 5cafcd7703..d9511f429c 100644
--- a/fsdev/virtfs-proxy-helper.c
+++ b/fsdev/virtfs-proxy-helper.c
@@ -26,6 +26,7 @@
 #include "qemu/xattr.h"
 #include "9p-iov-marshal.h"
 #include "hw/9pfs/9p-proxy.h"
+#include "hw/9pfs/9p-util.h"
 #include "fsdev/9p-iov-marshal.h"
 
 #define PROGNAME "virtfs-proxy-helper"
@@ -338,6 +339,28 @@ static void resetugid(int suid, int sgid)
     }
 }
 
+/*
+ * Open regular file or directory. Attempts to open any special file are
+ * rejected.
+ *
+ * returns file descriptor or -1 on error
+ */
+static int open_regular(const char *pathname, int flags, mode_t mode)
+{
+    int fd;
+
+    fd = open(pathname, flags, mode);
+    if (fd < 0) {
+        return fd;
+    }
+
+    if (close_if_special_file(fd) < 0) {
+        return -1;
+    }
+
+    return fd;
+}
+
 /*
  * send response in two parts
  * 1) ProxyHeader
@@ -682,7 +705,7 @@ static int do_create(struct iovec *iovec)
     if (ret < 0) {
         goto unmarshal_err_out;
     }
-    ret = open(path.data, flags, mode);
+    ret = open_regular(path.data, flags, mode);
     if (ret < 0) {
         ret = -errno;
     }
@@ -707,7 +730,7 @@ static int do_open(struct iovec *iovec)
     if (ret < 0) {
         goto err_out;
     }
-    ret = open(path.data, flags);
+    ret = open_regular(path.data, flags, 0);
     if (ret < 0) {
         ret = -errno;
     }
diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h
index c3526144c9..6b44e5f7a4 100644
--- a/hw/9pfs/9p-util.h
+++ b/hw/9pfs/9p-util.h
@@ -13,6 +13,8 @@
 #ifndef QEMU_9P_UTIL_H
 #define QEMU_9P_UTIL_H
 
+#include "qemu/error-report.h"
+
 #ifdef O_PATH
 #define O_PATH_9P_UTIL O_PATH
 #else
@@ -112,6 +114,38 @@ static inline void close_preserve_errno(int fd)
     errno = serrno;
 }
 
+/**
+ * close_if_special_file() - Close @fd if neither regular file nor directory.
+ *
+ * @fd: file descriptor of open file
+ * Return: 0 on regular file or directory, -1 otherwise
+ *
+ * CVE-2023-2861: Prohibit opening any special file directly on host
+ * (especially device files), as a compromised client could potentially gain
+ * access outside exported tree under certain, unsafe setups. We expect
+ * client to handle I/O on special files exclusively on guest side.
+ */
+static inline int close_if_special_file(int fd)
+{
+    struct stat stbuf;
+
+    if (fstat(fd, &stbuf) < 0) {
+        close_preserve_errno(fd);
+        return -1;
+    }
+    if (!S_ISREG(stbuf.st_mode) && !S_ISDIR(stbuf.st_mode)) {
+        error_report_once(
+            "9p: broken or compromised client detected; attempt to open "
+            "special file (i.e. neither regular file, nor directory)"
+        );
+        close(fd);
+        errno = ENXIO;
+        return -1;
+    }
+
+    return 0;
+}
+
 static inline int openat_dir(int dirfd, const char *name)
 {
     return openat(dirfd, name,
@@ -146,6 +180,10 @@ again:
         return -1;
     }
 
+    if (close_if_special_file(fd) < 0) {
+        return -1;
+    }
+
     serrno = errno;
     /* O_NONBLOCK was only needed to open the file. Let's drop it. We don't
      * do that with O_PATH since fcntl(F_SETFL) isn't supported, and openat()
diff --git a/hw/9pfs/trace-events b/hw/9pfs/trace-events
index 6c77966c0b..a12e55c165 100644
--- a/hw/9pfs/trace-events
+++ b/hw/9pfs/trace-events
@@ -48,3 +48,9 @@ v9fs_readlink(uint16_t tag, uint8_t id, int32_t fid) "tag %d id %d fid %d"
 v9fs_readlink_return(uint16_t tag, uint8_t id, char* target) "tag %d id %d name %s"
 v9fs_setattr(uint16_t tag, uint8_t id, int32_t fid, int32_t valid, int32_t mode, int32_t uid, int32_t gid, int64_t size, int64_t atime_sec, int64_t mtime_sec) "tag %u id %u fid %d iattr={valid %d mode %d uid %d gid %d size %"PRId64" atime=%"PRId64" mtime=%"PRId64" }"
 v9fs_setattr_return(uint16_t tag, uint8_t id) "tag %u id %u"
+
+# xen-9p-backend.c
+xen_9pfs_alloc(char *name) "name %s"
+xen_9pfs_connect(char *name) "name %s"
+xen_9pfs_disconnect(char *name) "name %s"
+xen_9pfs_free(char *name) "name %s"
diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
index 65c4979c3c..ab1df8dd2f 100644
--- a/hw/9pfs/xen-9p-backend.c
+++ b/hw/9pfs/xen-9p-backend.c
@@ -24,6 +24,8 @@
 #include "qemu/option.h"
 #include "fsdev/qemu-fsdev.h"
 
+#include "trace.h"
+
 #define VERSIONS "1"
 #define MAX_RINGS 8
 #define MAX_RING_ORDER 9
@@ -335,6 +337,8 @@ static void xen_9pfs_disconnect(struct XenLegacyDevice *xendev)
     Xen9pfsDev *xen_9pdev = container_of(xendev, Xen9pfsDev, xendev);
     int i;
 
+    trace_xen_9pfs_disconnect(xendev->name);
+
     for (i = 0; i < xen_9pdev->num_rings; i++) {
         if (xen_9pdev->rings[i].evtchndev != NULL) {
             qemu_set_fd_handler(xenevtchn_fd(xen_9pdev->rings[i].evtchndev),
@@ -343,39 +347,40 @@ static void xen_9pfs_disconnect(struct XenLegacyDevice *xendev)
                              xen_9pdev->rings[i].local_port);
             xen_9pdev->rings[i].evtchndev = NULL;
         }
-    }
-}
-
-static int xen_9pfs_free(struct XenLegacyDevice *xendev)
-{
-    Xen9pfsDev *xen_9pdev = container_of(xendev, Xen9pfsDev, xendev);
-    int i;
-
-    if (xen_9pdev->rings[0].evtchndev != NULL) {
-        xen_9pfs_disconnect(xendev);
-    }
-
-    for (i = 0; i < xen_9pdev->num_rings; i++) {
         if (xen_9pdev->rings[i].data != NULL) {
             xen_be_unmap_grant_refs(&xen_9pdev->xendev,
                                     xen_9pdev->rings[i].data,
                                     (1 << xen_9pdev->rings[i].ring_order));
+            xen_9pdev->rings[i].data = NULL;
         }
         if (xen_9pdev->rings[i].intf != NULL) {
             xen_be_unmap_grant_refs(&xen_9pdev->xendev,
                                     xen_9pdev->rings[i].intf,
                                     1);
+            xen_9pdev->rings[i].intf = NULL;
         }
         if (xen_9pdev->rings[i].bh != NULL) {
             qemu_bh_delete(xen_9pdev->rings[i].bh);
+            xen_9pdev->rings[i].bh = NULL;
         }
     }
 
     g_free(xen_9pdev->id);
+    xen_9pdev->id = NULL;
     g_free(xen_9pdev->tag);
+    xen_9pdev->tag = NULL;
     g_free(xen_9pdev->path);
+    xen_9pdev->path = NULL;
     g_free(xen_9pdev->security_model);
+    xen_9pdev->security_model = NULL;
     g_free(xen_9pdev->rings);
+    xen_9pdev->rings = NULL;
+}
+
+static int xen_9pfs_free(struct XenLegacyDevice *xendev)
+{
+    trace_xen_9pfs_free(xendev->name);
+
     return 0;
 }
 
@@ -387,6 +392,8 @@ static int xen_9pfs_connect(struct XenLegacyDevice *xendev)
     V9fsState *s = &xen_9pdev->state;
     QemuOpts *fsdev;
 
+    trace_xen_9pfs_connect(xendev->name);
+
     if (xenstore_read_fe_int(&xen_9pdev->xendev, "num-rings",
                              &xen_9pdev->num_rings) == -1 ||
         xen_9pdev->num_rings > MAX_RINGS || xen_9pdev->num_rings < 1) {
@@ -494,6 +501,8 @@ out:
 
 static void xen_9pfs_alloc(struct XenLegacyDevice *xendev)
 {
+    trace_xen_9pfs_alloc(xendev->name);
+
     xenstore_write_be_str(xendev, "versions", VERSIONS);
     xenstore_write_be_int(xendev, "max-rings", MAX_RINGS);
     xenstore_write_be_int(xendev, "max-ring-page-order", MAX_RING_ORDER);
diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c
index 53654f8638..ff14c3f410 100644
--- a/hw/acpi/cpu_hotplug.c
+++ b/hw/acpi/cpu_hotplug.c
@@ -52,6 +52,9 @@ static const MemoryRegionOps AcpiCpuHotplug_ops = {
     .endianness = DEVICE_LITTLE_ENDIAN,
     .valid = {
         .min_access_size = 1,
+        .max_access_size = 4,
+    },
+    .impl = {
         .max_access_size = 1,
     },
 };
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 84d75e6b84..a2a3738b46 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -429,6 +429,16 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
      * acpi_pcihp_eject_slot() when the operation is completed.
      */
     pdev->qdev.pending_deleted_event = true;
+    /* if unplug was requested before OSPM is initialized,
+     * linux kernel will clear GPE0.sts[] bits during boot, which effectively
+     * hides unplug event. And than followup qmp_device_del() calls remain
+     * blocked by above flag permanently.
+     * Unblock qmp_device_del() by setting expire limit, so user can
+     * repeat unplug request later when OSPM has been booted.
+     */
+    pdev->qdev.pending_deleted_expires_ms =
+        qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); /* 1 msec */
+
     s->acpi_pcihp_pci_status[bsel].down |= (1U << slot);
     acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS);
 }
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 55f114ef72..97fb1916ec 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -188,33 +188,35 @@ struct AspeedMachineState {
 static void aspeed_write_smpboot(ARMCPU *cpu,
                                  const struct arm_boot_info *info)
 {
-    static const uint32_t poll_mailbox_ready[] = {
+    AddressSpace *as = arm_boot_address_space(cpu, info);
+    static const ARMInsnFixup poll_mailbox_ready[] = {
         /*
          * r2 = per-cpu go sign value
          * r1 = AST_SMP_MBOX_FIELD_ENTRY
          * r0 = AST_SMP_MBOX_FIELD_GOSIGN
          */
-        0xee100fb0,  /* mrc     p15, 0, r0, c0, c0, 5 */
-        0xe21000ff,  /* ands    r0, r0, #255          */
-        0xe59f201c,  /* ldr     r2, [pc, #28]         */
-        0xe1822000,  /* orr     r2, r2, r0            */
-
-        0xe59f1018,  /* ldr     r1, [pc, #24]         */
-        0xe59f0018,  /* ldr     r0, [pc, #24]         */
-
-        0xe320f002,  /* wfe                           */
-        0xe5904000,  /* ldr     r4, [r0]              */
-        0xe1520004,  /* cmp     r2, r4                */
-        0x1afffffb,  /* bne     <wfe>                 */
-        0xe591f000,  /* ldr     pc, [r1]              */
-        AST_SMP_MBOX_GOSIGN,
-        AST_SMP_MBOX_FIELD_ENTRY,
-        AST_SMP_MBOX_FIELD_GOSIGN,
+        { 0xee100fb0 },  /* mrc     p15, 0, r0, c0, c0, 5 */
+        { 0xe21000ff },  /* ands    r0, r0, #255          */
+        { 0xe59f201c },  /* ldr     r2, [pc, #28]         */
+        { 0xe1822000 },  /* orr     r2, r2, r0            */
+
+        { 0xe59f1018 },  /* ldr     r1, [pc, #24]         */
+        { 0xe59f0018 },  /* ldr     r0, [pc, #24]         */
+
+        { 0xe320f002 },  /* wfe                           */
+        { 0xe5904000 },  /* ldr     r4, [r0]              */
+        { 0xe1520004 },  /* cmp     r2, r4                */
+        { 0x1afffffb },  /* bne     <wfe>                 */
+        { 0xe591f000 },  /* ldr     pc, [r1]              */
+        { AST_SMP_MBOX_GOSIGN },
+        { AST_SMP_MBOX_FIELD_ENTRY },
+        { AST_SMP_MBOX_FIELD_GOSIGN },
+        { 0, FIXUP_TERMINATOR }
     };
+    static const uint32_t fixupcontext[FIXUP_MAX] = { 0 };
 
-    rom_add_blob_fixed("aspeed.smpboot", poll_mailbox_ready,
-                       sizeof(poll_mailbox_ready),
-                       info->smp_loader_start);
+    arm_write_bootloader("aspeed.smpboot", as, info->smp_loader_start,
+                         poll_mailbox_ready, fixupcontext);
 }
 
 static void aspeed_reset_secondary(ARMCPU *cpu,
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 15c2bf1867..8ff315f431 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -59,26 +59,6 @@ AddressSpace *arm_boot_address_space(ARMCPU *cpu,
     return cpu_get_address_space(cs, asidx);
 }
 
-typedef enum {
-    FIXUP_NONE = 0,     /* do nothing */
-    FIXUP_TERMINATOR,   /* end of insns */
-    FIXUP_BOARDID,      /* overwrite with board ID number */
-    FIXUP_BOARD_SETUP,  /* overwrite with board specific setup code address */
-    FIXUP_ARGPTR_LO,    /* overwrite with pointer to kernel args */
-    FIXUP_ARGPTR_HI,    /* overwrite with pointer to kernel args (high half) */
-    FIXUP_ENTRYPOINT_LO, /* overwrite with kernel entry point */
-    FIXUP_ENTRYPOINT_HI, /* overwrite with kernel entry point (high half) */
-    FIXUP_GIC_CPU_IF,   /* overwrite with GIC CPU interface address */
-    FIXUP_BOOTREG,      /* overwrite with boot register address */
-    FIXUP_DSB,          /* overwrite with correct DSB insn for cpu */
-    FIXUP_MAX,
-} FixupType;
-
-typedef struct ARMInsnFixup {
-    uint32_t insn;
-    FixupType fixup;
-} ARMInsnFixup;
-
 static const ARMInsnFixup bootloader_aarch64[] = {
     { 0x580000c0 }, /* ldr x0, arg ; Load the lower 32-bits of DTB */
     { 0xaa1f03e1 }, /* mov x1, xzr */
@@ -149,9 +129,10 @@ static const ARMInsnFixup smpboot[] = {
     { 0, FIXUP_TERMINATOR }
 };
 
-static void write_bootloader(const char *name, hwaddr addr,
-                             const ARMInsnFixup *insns, uint32_t *fixupcontext,
-                             AddressSpace *as)
+void arm_write_bootloader(const char *name,
+                          AddressSpace *as, hwaddr addr,
+                          const ARMInsnFixup *insns,
+                          const uint32_t *fixupcontext)
 {
     /* Fix up the specified bootloader fragment and write it into
      * guest memory using rom_add_blob_fixed(). fixupcontext is
@@ -213,8 +194,8 @@ static void default_write_secondary(ARMCPU *cpu,
         fixupcontext[FIXUP_DSB] = CP15_DSB_INSN;
     }
 
-    write_bootloader("smpboot", info->smp_loader_start,
-                     smpboot, fixupcontext, as);
+    arm_write_bootloader("smpboot", as, info->smp_loader_start,
+                         smpboot, fixupcontext);
 }
 
 void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,
@@ -686,7 +667,10 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
     qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds,
                                        rom_ptr_for_as(as, addr, size));
 
-    g_free(fdt);
+    if (fdt != ms->fdt) {
+        g_free(ms->fdt);
+        ms->fdt = fdt;
+    }
 
     return size;
 
@@ -1171,8 +1155,8 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
         fixupcontext[FIXUP_ENTRYPOINT_LO] = entry;
         fixupcontext[FIXUP_ENTRYPOINT_HI] = entry >> 32;
 
-        write_bootloader("bootloader", info->loader_start,
-                         primary_loader, fixupcontext, as);
+        arm_write_bootloader("bootloader", as, info->loader_start,
+                             primary_loader, fixupcontext);
 
         if (info->write_board_setup) {
             info->write_board_setup(cpu, info);
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 92d068d1f9..a7d287b1a8 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -16,6 +16,7 @@
 #include "qemu/units.h"
 #include "qemu/cutils.h"
 #include "qapi/error.h"
+#include "hw/arm/boot.h"
 #include "hw/arm/bcm2836.h"
 #include "hw/registerfields.h"
 #include "qemu/error-report.h"
@@ -124,20 +125,22 @@ static const char *board_type(uint32_t board_rev)
 
 static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
 {
-    static const uint32_t smpboot[] = {
-        0xe1a0e00f, /*    mov     lr, pc */
-        0xe3a0fe00 + (BOARDSETUP_ADDR >> 4), /* mov pc, BOARDSETUP_ADDR */
-        0xee100fb0, /*    mrc     p15, 0, r0, c0, c0, 5;get core ID */
-        0xe7e10050, /*    ubfx    r0, r0, #0, #2       ;extract LSB */
-        0xe59f5014, /*    ldr     r5, =0x400000CC      ;load mbox base */
-        0xe320f001, /* 1: yield */
-        0xe7953200, /*    ldr     r3, [r5, r0, lsl #4] ;read mbox for our core*/
-        0xe3530000, /*    cmp     r3, #0               ;spin while zero */
-        0x0afffffb, /*    beq     1b */
-        0xe7853200, /*    str     r3, [r5, r0, lsl #4] ;clear mbox */
-        0xe12fff13, /*    bx      r3                   ;jump to target */
-        0x400000cc, /* (constant: mailbox 3 read/clear base) */
+    static const ARMInsnFixup smpboot[] = {
+        { 0xe1a0e00f }, /*    mov     lr, pc */
+        { 0xe3a0fe00 + (BOARDSETUP_ADDR >> 4) }, /* mov pc, BOARDSETUP_ADDR */
+        { 0xee100fb0 }, /*    mrc     p15, 0, r0, c0, c0, 5;get core ID */
+        { 0xe7e10050 }, /*    ubfx    r0, r0, #0, #2       ;extract LSB */
+        { 0xe59f5014 }, /*    ldr     r5, =0x400000CC      ;load mbox base */
+        { 0xe320f001 }, /* 1: yield */
+        { 0xe7953200 }, /*    ldr     r3, [r5, r0, lsl #4] ;read mbox for our core */
+        { 0xe3530000 }, /*    cmp     r3, #0               ;spin while zero */
+        { 0x0afffffb }, /*    beq     1b */
+        { 0xe7853200 }, /*    str     r3, [r5, r0, lsl #4] ;clear mbox */
+        { 0xe12fff13 }, /*    bx      r3                   ;jump to target */
+        { 0x400000cc }, /* (constant: mailbox 3 read/clear base) */
+        { 0, FIXUP_TERMINATOR }
     };
+    static const uint32_t fixupcontext[FIXUP_MAX] = { 0 };
 
     /* check that we don't overrun board setup vectors */
     QEMU_BUILD_BUG_ON(SMPBOOT_ADDR + sizeof(smpboot) > MVBAR_ADDR);
@@ -145,9 +148,8 @@ static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
     QEMU_BUILD_BUG_ON((BOARDSETUP_ADDR & 0xf) != 0
                       || (BOARDSETUP_ADDR >> 4) >= 0x100);
 
-    rom_add_blob_fixed_as("raspi_smpboot", smpboot, sizeof(smpboot),
-                          info->smp_loader_start,
-                          arm_boot_address_space(cpu, info));
+    arm_write_bootloader("raspi_smpboot", arm_boot_address_space(cpu, info),
+                         info->smp_loader_start, smpboot, fixupcontext);
 }
 
 static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info)
@@ -161,26 +163,28 @@ static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info)
      * the primary CPU goes into the kernel. We put these variables inside
      * a rom blob, so that the reset for ROM contents zeroes them for us.
      */
-    static const uint32_t smpboot[] = {
-        0xd2801b05, /*        mov     x5, 0xd8 */
-        0xd53800a6, /*        mrs     x6, mpidr_el1 */
-        0x924004c6, /*        and     x6, x6, #0x3 */
-        0xd503205f, /* spin:  wfe */
-        0xf86678a4, /*        ldr     x4, [x5,x6,lsl #3] */
-        0xb4ffffc4, /*        cbz     x4, spin */
-        0xd2800000, /*        mov     x0, #0x0 */
-        0xd2800001, /*        mov     x1, #0x0 */
-        0xd2800002, /*        mov     x2, #0x0 */
-        0xd2800003, /*        mov     x3, #0x0 */
-        0xd61f0080, /*        br      x4 */
+    static const ARMInsnFixup smpboot[] = {
+        { 0xd2801b05 }, /*        mov     x5, 0xd8 */
+        { 0xd53800a6 }, /*        mrs     x6, mpidr_el1 */
+        { 0x924004c6 }, /*        and     x6, x6, #0x3 */
+        { 0xd503205f }, /* spin:  wfe */
+        { 0xf86678a4 }, /*        ldr     x4, [x5,x6,lsl #3] */
+        { 0xb4ffffc4 }, /*        cbz     x4, spin */
+        { 0xd2800000 }, /*        mov     x0, #0x0 */
+        { 0xd2800001 }, /*        mov     x1, #0x0 */
+        { 0xd2800002 }, /*        mov     x2, #0x0 */
+        { 0xd2800003 }, /*        mov     x3, #0x0 */
+        { 0xd61f0080 }, /*        br      x4 */
+        { 0, FIXUP_TERMINATOR }
     };
+    static const uint32_t fixupcontext[FIXUP_MAX] = { 0 };
 
     static const uint64_t spintables[] = {
         0, 0, 0, 0
     };
 
-    rom_add_blob_fixed_as("raspi_smpboot", smpboot, sizeof(smpboot),
-                          info->smp_loader_start, as);
+    arm_write_bootloader("raspi_smpboot", as, info->smp_loader_start,
+                         smpboot, fixupcontext);
     rom_add_blob_fixed_as("raspi_spintables", spintables, sizeof(spintables),
                           SPINTABLE_ADDR, as);
 }
diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
index 335cfc417d..5905a33015 100644
--- a/hw/arm/xlnx-zynqmp.c
+++ b/hw/arm/xlnx-zynqmp.c
@@ -213,7 +213,7 @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,
                                    const char *boot_cpu, Error **errp)
 {
     int i;
-    int num_rpus = MIN(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS,
+    int num_rpus = MIN((int)(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS),
                        XLNX_ZYNQMP_NUM_RPU_CPUS);
 
     if (num_rpus <= 0) {
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 8d34caa31d..19f42450f5 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -42,6 +42,9 @@
 
 GlobalProperty hw_compat_7_1[] = {
     { "virtio-device", "queue_reset", "false" },
+    { "virtio-rng-pci", "vectors", "0" },
+    { "virtio-rng-pci-transitional", "vectors", "0" },
+    { "virtio-rng-pci-non-transitional", "vectors", "0" },
 };
 const size_t hw_compat_7_1_len = G_N_ELEMENTS(hw_compat_7_1);
 
@@ -1326,6 +1329,14 @@ void machine_run_board_init(MachineState *machine, const char *mem_path, Error *
         }
     } else if (machine_class->default_ram_id && machine->ram_size &&
                numa_uses_legacy_mem()) {
+        if (object_property_find(object_get_objects_root(),
+                                 machine_class->default_ram_id)) {
+            error_setg(errp, "object name '%s' is reserved for the default"
+                " RAM backend, it can't be used for any other purposes."
+                " Change the object's 'id' to something else",
+                machine_class->default_ram_id);
+            return;
+        }
         if (!create_default_memdev(current_machine, mem_path, errp)) {
             return;
         }
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 5e15c79b94..4e2e0dd53a 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -498,6 +498,8 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,
     struct virtio_gpu_resource_flush rf;
     struct virtio_gpu_scanout *scanout;
     pixman_region16_t flush_region;
+    bool within_bounds = false;
+    bool update_submitted = false;
     int i;
 
     VIRTIO_GPU_FILL_CMD(rf);
@@ -518,13 +520,28 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,
                 rf.r.x < scanout->x + scanout->width &&
                 rf.r.x + rf.r.width >= scanout->x &&
                 rf.r.y < scanout->y + scanout->height &&
-                rf.r.y + rf.r.height >= scanout->y &&
-                console_has_gl(scanout->con)) {
-                dpy_gl_update(scanout->con, 0, 0, scanout->width,
-                              scanout->height);
+                rf.r.y + rf.r.height >= scanout->y) {
+                within_bounds = true;
+
+                if (console_has_gl(scanout->con)) {
+                    dpy_gl_update(scanout->con, 0, 0, scanout->width,
+                                  scanout->height);
+                    update_submitted = true;
+                }
             }
         }
-        return;
+
+        if (update_submitted) {
+            return;
+        }
+        if (!within_bounds) {
+            qemu_log_mask(LOG_GUEST_ERROR, "%s: flush bounds outside scanouts"
+                          " bounds for flush %d: %d %d %d %d\n",
+                          __func__, rf.resource_id, rf.r.x, rf.r.y,
+                          rf.r.width, rf.r.height);
+            cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
+            return;
+        }
     }
 
     if (!res->blob &&
diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
index cbb8f0f169..99e50f65e2 100644
--- a/hw/dma/xilinx_axidma.c
+++ b/hw/dma/xilinx_axidma.c
@@ -168,6 +168,11 @@ static inline int stream_idle(struct Stream *s)
     return !!(s->regs[R_DMASR] & DMASR_IDLE);
 }
 
+static inline int stream_halted(struct Stream *s)
+{
+    return !!(s->regs[R_DMASR] & DMASR_HALTED);
+}
+
 static void stream_reset(struct Stream *s)
 {
     s->regs[R_DMASR] = DMASR_HALTED;  /* starts up halted.  */
@@ -269,7 +274,7 @@ static void stream_process_mem2s(struct Stream *s, StreamSink *tx_data_dev,
     uint64_t addr;
     bool eop;
 
-    if (!stream_running(s) || stream_idle(s)) {
+    if (!stream_running(s) || stream_idle(s) || stream_halted(s)) {
         return;
     }
 
@@ -326,7 +331,7 @@ static size_t stream_process_s2mem(struct Stream *s, unsigned char *buf,
     unsigned int rxlen;
     size_t pos = 0;
 
-    if (!stream_running(s) || stream_idle(s)) {
+    if (!stream_running(s) || stream_idle(s) || stream_halted(s)) {
         return 0;
     }
 
@@ -407,7 +412,7 @@ xilinx_axidma_data_stream_can_push(StreamSink *obj,
     XilinxAXIDMAStreamSink *ds = XILINX_AXI_DMA_DATA_STREAM(obj);
     struct Stream *s = &ds->dma->streams[1];
 
-    if (!stream_running(s) || stream_idle(s)) {
+    if (!stream_running(s) || stream_idle(s) || stream_halted(s)) {
         ds->dma->notify = notify;
         ds->dma->notify_opaque = notify_opaque;
         return false;
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index de1cc7ab71..98a78b84b4 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -123,6 +123,7 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
 {
     FWCfgState *fw_cfg;
     uint64_t val;
+    const char qemu_version[] = QEMU_VERSION;
 
     fw_cfg = fw_cfg_init_mem(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4);
     fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, ms->smp.cpus);
@@ -148,6 +149,10 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
     fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ms->boot_config.order[0]);
     qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
 
+    fw_cfg_add_file(fw_cfg, "/etc/qemu-version",
+                    g_memdup(qemu_version, sizeof(qemu_version)),
+                    sizeof(qemu_version));
+
     return fw_cfg;
 }
 
@@ -418,10 +423,16 @@ static void hppa_machine_reset(MachineState *ms, ShutdownCause reason)
 
     /* Start all CPUs at the firmware entry point.
      *  Monarch CPU will initialize firmware, secondary CPUs
-     *  will enter a small idle look and wait for rendevouz. */
+     *  will enter a small idle loop and wait for rendevouz. */
     for (i = 0; i < smp_cpus; i++) {
-        cpu_set_pc(CPU(cpu[i]), firmware_entry);
+        CPUState *cs = CPU(cpu[i]);
+
+        cpu_set_pc(cs, firmware_entry);
+        cpu[i]->env.psw = PSW_Q;
         cpu[i]->env.gr[5] = CPU_HPA + i * 0x1000;
+
+        cs->exception_index = -1;
+        cs->halted = 0;
     }
 
     /* already initialized by machine_hppa_init()? */
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index a08ee85edf..d025ef2873 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -3179,6 +3179,7 @@ static int vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
 {
     VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
     IntelIOMMUState *s = vtd_as->iommu_state;
+    X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s);
 
     /* TODO: add support for VFIO and vhost users */
     if (s->snoop_control) {
@@ -3186,6 +3187,20 @@ static int vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
                          "Snoop Control with vhost or VFIO is not supported");
         return -ENOTSUP;
     }
+    if (!s->caching_mode && (new & IOMMU_NOTIFIER_MAP)) {
+        error_setg_errno(errp, ENOTSUP,
+                         "device %02x.%02x.%x requires caching mode",
+                         pci_bus_num(vtd_as->bus), PCI_SLOT(vtd_as->devfn),
+                         PCI_FUNC(vtd_as->devfn));
+        return -ENOTSUP;
+    }
+    if (!x86_iommu->dt_supported && (new & IOMMU_NOTIFIER_DEVIOTLB_UNMAP)) {
+        error_setg_errno(errp, ENOTSUP,
+                         "device %02x.%02x.%x requires device IOTLB mode",
+                         pci_bus_num(vtd_as->bus), PCI_SLOT(vtd_as->devfn),
+                         PCI_FUNC(vtd_as->devfn));
+        return -ENOTSUP;
+    }
 
     /* Update per-address-space notifier flags */
     vtd_as->notifier_flags = new;
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index 170a331e3f..b231ceda9a 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -330,7 +330,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)
     rom_set_fw(fw_cfg);
 
     if (machine->kernel_filename != NULL) {
-        x86_load_linux(x86ms, fw_cfg, 0, true, false);
+        x86_load_linux(x86ms, fw_cfg, 0, true);
     }
 
     if (mms->option_roms) {
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 546b703cb4..ec5a10534b 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -799,7 +799,7 @@ void xen_load_linux(PCMachineState *pcms)
     rom_set_fw(fw_cfg);
 
     x86_load_linux(x86ms, fw_cfg, pcmc->acpi_data_size,
-                   pcmc->pvh_enabled, pcmc->legacy_no_rng_seed);
+                   pcmc->pvh_enabled);
     for (i = 0; i < nb_option_roms; i++) {
         assert(!strcmp(option_rom[i].name, "linuxboot.bin") ||
                !strcmp(option_rom[i].name, "linuxboot_dma.bin") ||
@@ -1119,7 +1119,7 @@ void pc_memory_init(PCMachineState *pcms,
 
     if (linux_boot) {
         x86_load_linux(x86ms, fw_cfg, pcmc->acpi_data_size,
-                       pcmc->pvh_enabled, pcmc->legacy_no_rng_seed);
+                       pcmc->pvh_enabled);
     }
 
     for (i = 0; i < nb_option_roms; i++) {
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 0ad0ed1603..04f793cca1 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -405,6 +405,7 @@ static void pc_xen_hvm_init(MachineState *machine)
     }
 
     pc_xen_hvm_init_pci(machine);
+    xen_igd_reserve_slot(pcms->bus);
     pci_create_simple(pcms->bus, -1, "xen-platform");
 }
 #endif
@@ -449,11 +450,9 @@ DEFINE_I440FX_MACHINE(v7_2, "pc-i440fx-7.2", NULL,
 
 static void pc_i440fx_7_1_machine_options(MachineClass *m)
 {
-    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_7_2_machine_options(m);
     m->alias = NULL;
     m->is_default = false;
-    pcmc->legacy_no_rng_seed = true;
     compat_props_add(m->compat_props, hw_compat_7_1, hw_compat_7_1_len);
     compat_props_add(m->compat_props, pc_compat_7_1, pc_compat_7_1_len);
 }
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index a496bd6e74..f522874add 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -383,10 +383,8 @@ DEFINE_Q35_MACHINE(v7_2, "pc-q35-7.2", NULL,
 
 static void pc_q35_7_1_machine_options(MachineClass *m)
 {
-    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_q35_7_2_machine_options(m);
     m->alias = NULL;
-    pcmc->legacy_no_rng_seed = true;
     compat_props_add(m->compat_props, hw_compat_7_1, hw_compat_7_1_len);
     compat_props_add(m->compat_props, pc_compat_7_1, pc_compat_7_1_len);
 }
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 78cc131926..80be3032cc 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -26,7 +26,6 @@
 #include "qemu/cutils.h"
 #include "qemu/units.h"
 #include "qemu/datadir.h"
-#include "qemu/guest-random.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qerror.h"
 #include "qapi/qapi-visit-common.h"
@@ -37,7 +36,6 @@
 #include "sysemu/whpx.h"
 #include "sysemu/numa.h"
 #include "sysemu/replay.h"
-#include "sysemu/reset.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/cpu-timers.h"
 #include "sysemu/xen.h"
@@ -657,12 +655,12 @@ DeviceState *ioapic_init_secondary(GSIState *gsi_state)
     return dev;
 }
 
-typedef struct SetupData {
+struct setup_data {
     uint64_t next;
     uint32_t type;
     uint32_t len;
     uint8_t data[];
-} __attribute__((packed)) SetupData;
+} __attribute__((packed));
 
 
 /*
@@ -769,35 +767,10 @@ static bool load_elfboot(const char *kernel_filename,
     return true;
 }
 
-typedef struct SetupDataFixup {
-    void *pos;
-    hwaddr orig_val, new_val;
-    uint32_t addr;
-} SetupDataFixup;
-
-static void fixup_setup_data(void *opaque)
-{
-    SetupDataFixup *fixup = opaque;
-    stq_p(fixup->pos, fixup->new_val);
-}
-
-static void reset_setup_data(void *opaque)
-{
-    SetupDataFixup *fixup = opaque;
-    stq_p(fixup->pos, fixup->orig_val);
-}
-
-static void reset_rng_seed(void *opaque)
-{
-    SetupData *setup_data = opaque;
-    qemu_guest_getrandom_nofail(setup_data->data, le32_to_cpu(setup_data->len));
-}
-
 void x86_load_linux(X86MachineState *x86ms,
                     FWCfgState *fw_cfg,
                     int acpi_data_size,
-                    bool pvh_enabled,
-                    bool legacy_no_rng_seed)
+                    bool pvh_enabled)
 {
     bool linuxboot_dma_enabled = X86_MACHINE_GET_CLASS(x86ms)->fwcfg_dma_enabled;
     uint16_t protocol;
@@ -805,17 +778,16 @@ void x86_load_linux(X86MachineState *x86ms,
     int dtb_size, setup_data_offset;
     uint32_t initrd_max;
     uint8_t header[8192], *setup, *kernel;
-    hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0, first_setup_data = 0;
+    hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0;
     FILE *f;
     char *vmode;
     MachineState *machine = MACHINE(x86ms);
-    SetupData *setup_data;
+    struct setup_data *setup_data;
     const char *kernel_filename = machine->kernel_filename;
     const char *initrd_filename = machine->initrd_filename;
     const char *dtb_filename = machine->dtb;
     const char *kernel_cmdline = machine->kernel_cmdline;
     SevKernelLoaderContext sev_load_ctx = {};
-    enum { RNG_SEED_LENGTH = 32 };
 
     /* Align to 16 bytes as a paranoia measure */
     cmdline_size = (strlen(kernel_cmdline) + 16) & ~15;
@@ -1092,41 +1064,19 @@ void x86_load_linux(X86MachineState *x86ms,
         }
 
         setup_data_offset = QEMU_ALIGN_UP(kernel_size, 16);
-        kernel_size = setup_data_offset + sizeof(SetupData) + dtb_size;
+        kernel_size = setup_data_offset + sizeof(struct setup_data) + dtb_size;
         kernel = g_realloc(kernel, kernel_size);
 
+        stq_p(header + 0x250, prot_addr + setup_data_offset);
 
-        setup_data = (SetupData *)(kernel + setup_data_offset);
-        setup_data->next = cpu_to_le64(first_setup_data);
-        first_setup_data = prot_addr + setup_data_offset;
+        setup_data = (struct setup_data *)(kernel + setup_data_offset);
+        setup_data->next = 0;
         setup_data->type = cpu_to_le32(SETUP_DTB);
         setup_data->len = cpu_to_le32(dtb_size);
 
         load_image_size(dtb_filename, setup_data->data, dtb_size);
     }
 
-    if (!legacy_no_rng_seed) {
-        setup_data_offset = QEMU_ALIGN_UP(kernel_size, 16);
-        kernel_size = setup_data_offset + sizeof(SetupData) + RNG_SEED_LENGTH;
-        kernel = g_realloc(kernel, kernel_size);
-        setup_data = (SetupData *)(kernel + setup_data_offset);
-        setup_data->next = cpu_to_le64(first_setup_data);
-        first_setup_data = prot_addr + setup_data_offset;
-        setup_data->type = cpu_to_le32(SETUP_RNG_SEED);
-        setup_data->len = cpu_to_le32(RNG_SEED_LENGTH);
-        qemu_guest_getrandom_nofail(setup_data->data, RNG_SEED_LENGTH);
-        qemu_register_reset_nosnapshotload(reset_rng_seed, setup_data);
-        fw_cfg_add_bytes_callback(fw_cfg, FW_CFG_KERNEL_DATA, reset_rng_seed, NULL,
-                                  setup_data, kernel, kernel_size, true);
-    } else {
-        fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
-    }
-
-    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr);
-    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
-    sev_load_ctx.kernel_data = (char *)kernel;
-    sev_load_ctx.kernel_size = kernel_size;
-
     /*
      * If we're starting an encrypted VM, it will be OVMF based, which uses the
      * efi stub for booting and doesn't require any values to be placed in the
@@ -1135,20 +1085,16 @@ void x86_load_linux(X86MachineState *x86ms,
      * file the user passed in.
      */
     if (!sev_enabled()) {
-        SetupDataFixup *fixup = g_malloc(sizeof(*fixup));
-
         memcpy(setup, header, MIN(sizeof(header), setup_size));
-        /* Offset 0x250 is a pointer to the first setup_data link. */
-        fixup->pos = setup + 0x250;
-        fixup->orig_val = ldq_p(fixup->pos);
-        fixup->new_val = first_setup_data;
-        fixup->addr = cpu_to_le32(real_addr);
-        fw_cfg_add_bytes_callback(fw_cfg, FW_CFG_SETUP_ADDR, fixup_setup_data, NULL,
-                                  fixup, &fixup->addr, sizeof(fixup->addr), true);
-        qemu_register_reset(reset_setup_data, fixup);
-    } else {
-        fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr);
     }
+
+    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr);
+    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
+    fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
+    sev_load_ctx.kernel_data = (char *)kernel;
+    sev_load_ctx.kernel_size = kernel_size;
+
+    fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr);
     fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, setup_size);
     fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, setup, setup_size);
     sev_load_ctx.setup_data = (char *)setup;
diff --git a/hw/intc/allwinner-a10-pic.c b/hw/intc/allwinner-a10-pic.c
index 8cca124807..d0bf8d545b 100644
--- a/hw/intc/allwinner-a10-pic.c
+++ b/hw/intc/allwinner-a10-pic.c
@@ -49,12 +49,9 @@ static void aw_a10_pic_update(AwA10PICState *s)
 static void aw_a10_pic_set_irq(void *opaque, int irq, int level)
 {
     AwA10PICState *s = opaque;
+    uint32_t *pending_reg = &s->irq_pending[irq / 32];
 
-    if (level) {
-        set_bit(irq % 32, (void *)&s->irq_pending[irq / 32]);
-    } else {
-        clear_bit(irq % 32, (void *)&s->irq_pending[irq / 32]);
-    }
+    *pending_reg = deposit32(*pending_reg, irq % 32, 1, !!level);
     aw_a10_pic_update(s);
 }
 
diff --git a/hw/misc/aspeed_hace.c b/hw/misc/aspeed_hace.c
index ac21be306c..69175e972d 100644
--- a/hw/misc/aspeed_hace.c
+++ b/hw/misc/aspeed_hace.c
@@ -189,7 +189,7 @@ static void do_hash_operation(AspeedHACEState *s, int algo, bool sg_mode,
                               bool acc_mode)
 {
     struct iovec iov[ASPEED_HACE_MAX_SG];
-    g_autofree uint8_t *digest_buf;
+    g_autofree uint8_t *digest_buf = NULL;
     size_t digest_len = 0;
     int niov = 0;
     int i;
diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
index ecc0245fe8..c3fed5fcbe 100644
--- a/hw/net/allwinner-sun8i-emac.c
+++ b/hw/net/allwinner-sun8i-emac.c
@@ -350,8 +350,13 @@ static void allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s,
                                           FrameDescriptor *desc,
                                           uint32_t phys_addr)
 {
-    dma_memory_read(&s->dma_as, phys_addr, desc, sizeof(*desc),
+    uint32_t desc_words[4];
+    dma_memory_read(&s->dma_as, phys_addr, &desc_words, sizeof(desc_words),
                     MEMTXATTRS_UNSPECIFIED);
+    desc->status = le32_to_cpu(desc_words[0]);
+    desc->status2 = le32_to_cpu(desc_words[1]);
+    desc->addr = le32_to_cpu(desc_words[2]);
+    desc->next = le32_to_cpu(desc_words[3]);
 }
 
 static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s,
@@ -400,10 +405,15 @@ static uint32_t allwinner_sun8i_emac_tx_desc(AwSun8iEmacState *s,
 }
 
 static void allwinner_sun8i_emac_flush_desc(AwSun8iEmacState *s,
-                                            FrameDescriptor *desc,
+                                            const FrameDescriptor *desc,
                                             uint32_t phys_addr)
 {
-    dma_memory_write(&s->dma_as, phys_addr, desc, sizeof(*desc),
+    uint32_t desc_words[4];
+    desc_words[0] = cpu_to_le32(desc->status);
+    desc_words[1] = cpu_to_le32(desc->status2);
+    desc_words[2] = cpu_to_le32(desc->addr);
+    desc_words[3] = cpu_to_le32(desc->next);
+    dma_memory_write(&s->dma_as, phys_addr, &desc_words, sizeof(desc_words),
                      MEMTXATTRS_UNSPECIFIED);
 }
 
@@ -638,8 +648,7 @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset,
         break;
     case REG_TX_CUR_BUF:        /* Transmit Current Buffer */
         if (s->tx_desc_curr != 0) {
-            dma_memory_read(&s->dma_as, s->tx_desc_curr, &desc, sizeof(desc),
-                            MEMTXATTRS_UNSPECIFIED);
+            allwinner_sun8i_emac_get_desc(s, &desc, s->tx_desc_curr);
             value = desc.addr;
         } else {
             value = 0;
@@ -652,8 +661,7 @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset,
         break;
     case REG_RX_CUR_BUF:        /* Receive Current Buffer */
         if (s->rx_desc_curr != 0) {
-            dma_memory_read(&s->dma_as, s->rx_desc_curr, &desc, sizeof(desc),
-                            MEMTXATTRS_UNSPECIFIED);
+            allwinner_sun8i_emac_get_desc(s, &desc, s->rx_desc_curr);
             value = desc.addr;
         } else {
             value = 0;
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index e26e0a64c1..0dfdf47313 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -567,7 +567,7 @@ e1000_send_packet(E1000State *s, const uint8_t *buf, int size)
         qemu_send_packet(nc, buf, size);
     }
     inc_tx_bcast_or_mcast_count(s, buf);
-    e1000x_increase_size_stats(s->mac_reg, PTCregs, size);
+    e1000x_increase_size_stats(s->mac_reg, PTCregs, size + 4);
 }
 
 static void
@@ -631,10 +631,9 @@ xmit_seg(E1000State *s)
     }
 
     e1000x_inc_reg_if_not_full(s->mac_reg, TPT);
-    e1000x_grow_8reg_if_not_full(s->mac_reg, TOTL, s->tx.size);
-    s->mac_reg[GPTC] = s->mac_reg[TPT];
-    s->mac_reg[GOTCL] = s->mac_reg[TOTL];
-    s->mac_reg[GOTCH] = s->mac_reg[TOTH];
+    e1000x_grow_8reg_if_not_full(s->mac_reg, TOTL, s->tx.size + 4);
+    e1000x_inc_reg_if_not_full(s->mac_reg, GPTC);
+    e1000x_grow_8reg_if_not_full(s->mac_reg, GOTCL, s->tx.size + 4);
 }
 
 static void
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
index fc9cdb4528..c71d82ce1d 100644
--- a/hw/net/e1000e_core.c
+++ b/hw/net/e1000e_core.c
@@ -687,9 +687,8 @@ e1000e_on_tx_done_update_stats(E1000ECore *core, struct NetTxPkt *tx_pkt)
         g_assert_not_reached();
     }
 
-    core->mac[GPTC] = core->mac[TPT];
-    core->mac[GOTCL] = core->mac[TOTL];
-    core->mac[GOTCH] = core->mac[TOTH];
+    e1000x_inc_reg_if_not_full(core->mac, GPTC);
+    e1000x_grow_8reg_if_not_full(core->mac, GOTCL, tot_len);
 }
 
 static void
diff --git a/hw/net/e1000x_common.c b/hw/net/e1000x_common.c
index a8d93870b5..3fdc34f753 100644
--- a/hw/net/e1000x_common.c
+++ b/hw/net/e1000x_common.c
@@ -217,15 +217,14 @@ e1000x_update_rx_total_stats(uint32_t *mac,
 
     e1000x_increase_size_stats(mac, PRCregs, data_fcs_size);
     e1000x_inc_reg_if_not_full(mac, TPR);
-    mac[GPRC] = mac[TPR];
+    e1000x_inc_reg_if_not_full(mac, GPRC);
     /* TOR - Total Octets Received:
     * This register includes bytes received in a packet from the <Destination
     * Address> field through the <CRC> field, inclusively.
     * Always include FCS length (4) in size.
     */
     e1000x_grow_8reg_if_not_full(mac, TORL, data_size + 4);
-    mac[GORCL] = mac[TORL];
-    mac[GORCH] = mac[TORH];
+    e1000x_grow_8reg_if_not_full(mac, GORCL, data_size + 4);
 }
 
 void
diff --git a/hw/net/msf2-emac.c b/hw/net/msf2-emac.c
index 7ccd3e5142..db3a04deb1 100644
--- a/hw/net/msf2-emac.c
+++ b/hw/net/msf2-emac.c
@@ -118,14 +118,18 @@ static void emac_load_desc(MSF2EmacState *s, EmacDesc *d, hwaddr desc)
     d->next = le32_to_cpu(d->next);
 }
 
-static void emac_store_desc(MSF2EmacState *s, EmacDesc *d, hwaddr desc)
+static void emac_store_desc(MSF2EmacState *s, const EmacDesc *d, hwaddr desc)
 {
-    /* Convert from host endianness into LE. */
-    d->pktaddr = cpu_to_le32(d->pktaddr);
-    d->pktsize = cpu_to_le32(d->pktsize);
-    d->next = cpu_to_le32(d->next);
-
-    address_space_write(&s->dma_as, desc, MEMTXATTRS_UNSPECIFIED, d, sizeof *d);
+    EmacDesc outd;
+    /*
+     * Convert from host endianness into LE. We use a local struct because
+     * calling code may still want to look at the fields afterwards.
+     */
+    outd.pktaddr = cpu_to_le32(d->pktaddr);
+    outd.pktsize = cpu_to_le32(d->pktsize);
+    outd.next = cpu_to_le32(d->next);
+
+    address_space_write(&s->dma_as, desc, MEMTXATTRS_UNSPECIFIED, &outd, sizeof outd);
 }
 
 static void msf2_dma_tx(MSF2EmacState *s)
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 700b1b66b6..eb679d7c40 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -2154,6 +2154,9 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
 
                 int large_send_mss = (txdw0 >> CP_TC_LGSEN_MSS_SHIFT) &
                                      CP_TC_LGSEN_MSS_MASK;
+                if (large_send_mss == 0) {
+                    goto skip_offload;
+                }
 
                 DPRINTF("+++ C+ mode offloaded task TSO IP data %d "
                     "frame data %d specified MSS=%d\n",
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index aba12759d5..4abd49e298 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -802,7 +802,6 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features,
     }
 
     if (!get_vhost_net(nc->peer)) {
-        virtio_add_feature(&features, VIRTIO_F_RING_RESET);
         return features;
     }
 
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index d2ab527ef4..56559cda24 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -1441,7 +1441,7 @@ static void vmxnet3_activate_device(VMXNET3State *s)
     vmxnet3_setup_rx_filtering(s);
     /* Cache fields from shared memory */
     s->mtu = VMXNET3_READ_DRV_SHARED32(d, s->drv_shmem, devRead.misc.mtu);
-    assert(VMXNET3_MIN_MTU <= s->mtu && s->mtu < VMXNET3_MAX_MTU);
+    assert(VMXNET3_MIN_MTU <= s->mtu && s->mtu <= VMXNET3_MAX_MTU);
     VMW_CFPRN("MTU is %u", s->mtu);
 
     s->max_rx_frags =
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index e54276dc1d..749a6938dd 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -1331,10 +1331,23 @@ static inline void nvme_blk_write(BlockBackend *blk, int64_t offset,
     }
 }
 
+static void nvme_update_cq_eventidx(const NvmeCQueue *cq)
+{
+    uint32_t v = cpu_to_le32(cq->head);
+
+    //not in 7.2: trace_pci_nvme_update_cq_eventidx(cq->cqid, cq->head);
+
+    pci_dma_write(PCI_DEVICE(cq->ctrl), cq->ei_addr, &v, sizeof(v));
+}
+
 static void nvme_update_cq_head(NvmeCQueue *cq)
 {
-    pci_dma_read(&cq->ctrl->parent_obj, cq->db_addr, &cq->head,
-            sizeof(cq->head));
+    uint32_t v;
+
+    pci_dma_read(&cq->ctrl->parent_obj, cq->db_addr, &v, sizeof(v));
+
+    cq->head = le32_to_cpu(v);
+
     trace_pci_nvme_shadow_doorbell_cq(cq->cqid, cq->head);
 }
 
@@ -1351,6 +1364,7 @@ static void nvme_post_cqes(void *opaque)
         hwaddr addr;
 
         if (n->dbbuf_enabled) {
+            nvme_update_cq_eventidx(cq);
             nvme_update_cq_head(cq);
         }
 
@@ -2477,6 +2491,9 @@ static uint16_t nvme_dsm(NvmeCtrl *n, NvmeRequest *req)
         status = nvme_h2c(n, (uint8_t *)iocb->range, sizeof(NvmeDsmRange) * nr,
                           req);
         if (status) {
+            g_free(iocb->range);
+            qemu_aio_unref(iocb);
+
             return status;
         }
 
@@ -6141,15 +6158,21 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeRequest *req)
 
 static void nvme_update_sq_eventidx(const NvmeSQueue *sq)
 {
-    pci_dma_write(&sq->ctrl->parent_obj, sq->ei_addr, &sq->tail,
-                  sizeof(sq->tail));
+    uint32_t v = cpu_to_le32(sq->tail);
+
+    pci_dma_write(&sq->ctrl->parent_obj, sq->ei_addr, &v, sizeof(v));
+
     trace_pci_nvme_eventidx_sq(sq->sqid, sq->tail);
 }
 
 static void nvme_update_sq_tail(NvmeSQueue *sq)
 {
-    pci_dma_read(&sq->ctrl->parent_obj, sq->db_addr, &sq->tail,
-                 sizeof(sq->tail));
+    uint32_t v;
+
+    pci_dma_read(&sq->ctrl->parent_obj, sq->db_addr, &v, sizeof(v));
+
+    sq->tail = le32_to_cpu(v);
+
     trace_pci_nvme_shadow_doorbell_sq(sq->sqid, sq->tail);
 }
 
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 6edf5ea3e9..371a45dfe2 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -693,12 +693,12 @@ static const VMStateDescription vmstate_fw_cfg = {
     }
 };
 
-void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
-                               FWCfgCallback select_cb,
-                               FWCfgWriteCallback write_cb,
-                               void *callback_opaque,
-                               void *data, size_t len,
-                               bool read_only)
+static void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
+                                      FWCfgCallback select_cb,
+                                      FWCfgWriteCallback write_cb,
+                                      void *callback_opaque,
+                                      void *data, size_t len,
+                                      bool read_only)
 {
     int arch = !!(key & FW_CFG_ARCH_LOCAL);
 
diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index dc86c1c7db..fbdc48911e 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -806,6 +806,8 @@ static void __cpu_ppc_store_decr(PowerPCCPU *cpu, uint64_t *nextp,
     int64_t signed_decr;
 
     /* Truncate value to decr_width and sign extend for simplicity */
+    value = extract64(value, 0, nr_bits);
+    decr = extract64(decr, 0, nr_bits);
     signed_value = sextract64(value, 0, nr_bits);
     signed_decr = sextract64(decr, 0, nr_bits);
 
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index fcbe4c5837..ec8d9584fb 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -271,9 +271,11 @@ static void ibm_40p_init(MachineState *machine)
     }
 
     /* PCI -> ISA bridge */
-    i82378_dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(11, 0), "i82378"));
+    i82378_dev = DEVICE(pci_new(PCI_DEVFN(11, 0), "i82378"));
     qdev_connect_gpio_out(i82378_dev, 0,
                           qdev_get_gpio_in(DEVICE(cpu), PPC6xx_INPUT_INT));
+    qdev_realize_and_unref(i82378_dev, BUS(pci_bus), &error_fatal);
+
     sysbus_connect_irq(pcihost, 0, qdev_get_gpio_in(i82378_dev, 15));
     isa_bus = ISA_BUS(qdev_get_child_bus(i82378_dev, "isa.0"));
 
diff --git a/hw/rdma/vmw/pvrdma_cmd.c b/hw/rdma/vmw/pvrdma_cmd.c
index da7ddfa548..89db963c46 100644
--- a/hw/rdma/vmw/pvrdma_cmd.c
+++ b/hw/rdma/vmw/pvrdma_cmd.c
@@ -796,6 +796,12 @@ int pvrdma_exec_cmd(PVRDMADev *dev)
 
     dsr_info = &dev->dsr_info;
 
+    if (!dsr_info->dsr) {
+            /* Buggy or malicious guest driver */
+            rdma_error_report("Exec command without dsr, req or rsp buffers");
+            goto out;
+    }
+
     if (dsr_info->req->hdr.cmd >= sizeof(cmd_handlers) /
                       sizeof(struct cmd_handler)) {
         rdma_error_report("Unsupported command");
diff --git a/hw/remote/trace-events b/hw/remote/trace-events
index c167b3c7a5..0d1b7d56a5 100644
--- a/hw/remote/trace-events
+++ b/hw/remote/trace-events
@@ -5,8 +5,8 @@ mpqemu_recv_io_error(int cmd, int size, int nfds) "failed to receive %d size %d,
 
 # vfio-user-obj.c
 vfu_prop(const char *prop, const char *val) "vfu: setting %s as %s"
-vfu_cfg_read(uint32_t offset, uint32_t val) "vfu: cfg: 0x%u -> 0x%x"
-vfu_cfg_write(uint32_t offset, uint32_t val) "vfu: cfg: 0x%u <- 0x%x"
+vfu_cfg_read(uint32_t offset, uint32_t val) "vfu: cfg: 0x%x -> 0x%x"
+vfu_cfg_write(uint32_t offset, uint32_t val) "vfu: cfg: 0x%x <- 0x%x"
 vfu_dma_register(uint64_t gpa, size_t len) "vfu: registering GPA 0x%"PRIx64", %zu bytes"
 vfu_dma_unregister(uint64_t gpa) "vfu: unregistering GPA 0x%"PRIx64""
 vfu_bar_register(int i, uint64_t addr, uint64_t size) "vfu: BAR %d: addr 0x%"PRIx64" size 0x%"PRIx64""
diff --git a/hw/riscv/numa.c b/hw/riscv/numa.c
index 7fe92d402f..edf6750f54 100644
--- a/hw/riscv/numa.c
+++ b/hw/riscv/numa.c
@@ -207,6 +207,12 @@ int64_t riscv_numa_get_default_cpu_node_id(const MachineState *ms, int idx)
 {
     int64_t nidx = 0;
 
+    if (ms->numa_state->num_nodes > ms->smp.cpus) {
+        error_report("Number of NUMA nodes (%d)"
+                     " cannot exceed the number of available CPUs (%d).",
+                     ms->numa_state->num_nodes, ms->smp.max_cpus);
+        exit(EXIT_FAILURE);
+    }
     if (ms->numa_state->num_nodes) {
         nidx = idx / (ms->smp.cpus / ms->numa_state->num_nodes);
         if (ms->numa_state->num_nodes <= nidx) {
diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index 50979640c3..42532c4744 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -1134,15 +1134,24 @@ static void lsi_execute_script(LSIState *s)
     uint32_t addr, addr_high;
     int opcode;
     int insn_processed = 0;
+    static int reentrancy_level;
+
+    reentrancy_level++;
 
     s->istat1 |= LSI_ISTAT1_SRUN;
 again:
-    if (++insn_processed > LSI_MAX_INSN) {
-        /* Some windows drivers make the device spin waiting for a memory
-           location to change.  If we have been executed a lot of code then
-           assume this is the case and force an unexpected device disconnect.
-           This is apparently sufficient to beat the drivers into submission.
-         */
+    /*
+     * Some windows drivers make the device spin waiting for a memory location
+     * to change. If we have executed more than LSI_MAX_INSN instructions then
+     * assume this is the case and force an unexpected device disconnect. This
+     * is apparently sufficient to beat the drivers into submission.
+     *
+     * Another issue (CVE-2023-0330) can occur if the script is programmed to
+     * trigger itself again and again. Avoid this problem by stopping after
+     * being called multiple times in a reentrant way (8 is an arbitrary value
+     * which should be enough for all valid use cases).
+     */
+    if (++insn_processed > LSI_MAX_INSN || reentrancy_level > 8) {
         if (!(s->sien0 & LSI_SIST0_UDC)) {
             qemu_log_mask(LOG_GUEST_ERROR,
                           "lsi_scsi: inf. loop with UDC masked");
@@ -1596,6 +1605,8 @@ again:
         }
     }
     trace_lsi_execute_script_stop();
+
+    reentrancy_level--;
 }
 
 static uint8_t lsi_reg_readb(LSIState *s, int offset)
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 92cce20a4d..d513870181 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -190,12 +190,16 @@ static int scsi_handle_inquiry_reply(SCSIGenericReq *r, SCSIDevice *s, int len)
     if ((s->type == TYPE_DISK || s->type == TYPE_ZBC) &&
         (r->req.cmd.buf[1] & 0x01)) {
         page = r->req.cmd.buf[2];
-        if (page == 0xb0) {
+        if (page == 0xb0 && r->buflen >= 8) {
+            uint8_t buf[16] = {};
+            uint8_t buf_used = MIN(r->buflen, 16);
             uint64_t max_transfer = calculate_max_transfer(s);
-            stl_be_p(&r->buf[8], max_transfer);
-            /* Also take care of the opt xfer len. */
-            stl_be_p(&r->buf[12],
-                    MIN_NON_ZERO(max_transfer, ldl_be_p(&r->buf[12])));
+
+            memcpy(buf, r->buf, buf_used);
+            stl_be_p(&buf[8], max_transfer);
+            stl_be_p(&buf[12], MIN_NON_ZERO(max_transfer, ldl_be_p(&buf[12])));
+            memcpy(r->buf + 8, buf + 8, buf_used - 8);
+
         } else if (s->needs_vpd_bl_emulation && page == 0x00 && r->buflen >= 4) {
             /*
              * Now we're capable of supplying the VPD Block Limits
diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c
index 51e5e90830..92a0f42708 100644
--- a/hw/sd/allwinner-sdhost.c
+++ b/hw/sd/allwinner-sdhost.c
@@ -302,6 +302,30 @@ static void allwinner_sdhost_auto_stop(AwSdHostState *s)
     }
 }
 
+static void read_descriptor(AwSdHostState *s, hwaddr desc_addr,
+                            TransferDescriptor *desc)
+{
+    uint32_t desc_words[4];
+    dma_memory_read(&s->dma_as, desc_addr, &desc_words, sizeof(desc_words),
+                    MEMTXATTRS_UNSPECIFIED);
+    desc->status = le32_to_cpu(desc_words[0]);
+    desc->size = le32_to_cpu(desc_words[1]);
+    desc->addr = le32_to_cpu(desc_words[2]);
+    desc->next = le32_to_cpu(desc_words[3]);
+}
+
+static void write_descriptor(AwSdHostState *s, hwaddr desc_addr,
+                             const TransferDescriptor *desc)
+{
+    uint32_t desc_words[4];
+    desc_words[0] = cpu_to_le32(desc->status);
+    desc_words[1] = cpu_to_le32(desc->size);
+    desc_words[2] = cpu_to_le32(desc->addr);
+    desc_words[3] = cpu_to_le32(desc->next);
+    dma_memory_write(&s->dma_as, desc_addr, &desc_words, sizeof(desc_words),
+                     MEMTXATTRS_UNSPECIFIED);
+}
+
 static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s,
                                               hwaddr desc_addr,
                                               TransferDescriptor *desc,
@@ -312,9 +336,7 @@ static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s,
     uint32_t num_bytes = max_bytes;
     uint8_t buf[1024];
 
-    /* Read descriptor */
-    dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc),
-                    MEMTXATTRS_UNSPECIFIED);
+    read_descriptor(s, desc_addr, desc);
     if (desc->size == 0) {
         desc->size = klass->max_desc_size;
     } else if (desc->size > klass->max_desc_size) {
@@ -356,8 +378,7 @@ static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s,
 
     /* Clear hold flag and flush descriptor */
     desc->status &= ~DESC_STATUS_HOLD;
-    dma_memory_write(&s->dma_as, desc_addr, desc, sizeof(*desc),
-                     MEMTXATTRS_UNSPECIFIED);
+    write_descriptor(s, desc_addr, desc);
 
     return num_done;
 }
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index b4243de735..66a020999b 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -749,14 +749,16 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
     t->core_count = (ms->smp.cores > 255) ? 0xFF : ms->smp.cores;
     t->core_enabled = t->core_count;
 
-    t->core_count2 = t->core_enabled2 = cpu_to_le16(ms->smp.cores);
-
     t->thread_count = (ms->smp.threads > 255) ? 0xFF : ms->smp.threads;
-    t->thread_count2 = cpu_to_le16(ms->smp.threads);
 
     t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */
     t->processor_family2 = cpu_to_le16(0x01); /* Other */
 
+    if (tbl_len == SMBIOS_TYPE_4_LEN_V30) {
+        t->core_count2 = t->core_enabled2 = cpu_to_le16(ms->smp.cores);
+        t->thread_count2 = cpu_to_le16(ms->smp.threads);
+    }
+
     SMBIOS_BUILD_TABLE_POST;
     smbios_type4_count++;
 }
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index 9520471be2..5f88ffdef8 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -352,6 +352,16 @@ static const VMStateDescription vmstate_hpet = {
     }
 };
 
+static void hpet_arm(HPETTimer *t, uint64_t ticks)
+{
+    if (ticks < ns_to_ticks(INT64_MAX / 2)) {
+        timer_mod(t->qemu_timer,
+                  qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ticks_to_ns(ticks));
+    } else {
+        timer_del(t->qemu_timer);
+    }
+}
+
 /*
  * timer expiration callback
  */
@@ -374,13 +384,11 @@ static void hpet_timer(void *opaque)
             }
         }
         diff = hpet_calculate_diff(t, cur_tick);
-        timer_mod(t->qemu_timer,
-                       qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + (int64_t)ticks_to_ns(diff));
+        hpet_arm(t, diff);
     } else if (t->config & HPET_TN_32BIT && !timer_is_periodic(t)) {
         if (t->wrap_flag) {
             diff = hpet_calculate_diff(t, cur_tick);
-            timer_mod(t->qemu_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
-                           (int64_t)ticks_to_ns(diff));
+            hpet_arm(t, diff);
             t->wrap_flag = 0;
         }
     }
@@ -407,8 +415,7 @@ static void hpet_set_timer(HPETTimer *t)
             t->wrap_flag = 1;
         }
     }
-    timer_mod(t->qemu_timer,
-                   qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + (int64_t)ticks_to_ns(diff));
+    hpet_arm(t, diff);
 }
 
 static void hpet_del_timer(HPETTimer *t)
diff --git a/hw/timer/nrf51_timer.c b/hw/timer/nrf51_timer.c
index 42be79c736..50c6772383 100644
--- a/hw/timer/nrf51_timer.c
+++ b/hw/timer/nrf51_timer.c
@@ -45,7 +45,12 @@ static uint32_t update_counter(NRF51TimerState *s, int64_t now)
     uint32_t ticks = ns_to_ticks(s, now - s->update_counter_ns);
 
     s->counter = (s->counter + ticks) % BIT(bitwidths[s->bitmode]);
-    s->update_counter_ns = now;
+    /*
+     * Only advance the sync time to the timestamp of the last tick,
+     * not all the way to 'now', so we don't lose time if we do
+     * multiple resyncs in a single tick.
+     */
+    s->update_counter_ns += ticks_to_ns(s, ticks);
     return ticks;
 }
 
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 9d68036d23..c3ab762f54 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1210,6 +1210,8 @@ static void ohci_frame_boundary(void *opaque)
     /* Increment frame number and take care of endianness. */
     ohci->frame_number = (ohci->frame_number + 1) & 0xffff;
     hcca.frame = cpu_to_le16(ohci->frame_number);
+    /* When the HC updates frame number, set pad to 0. Ref OHCI Spec 4.4.1*/
+    hcca.pad = 0;
 
     if (ohci->done_count == 0 && !(ohci->intr_status & OHCI_INTR_WD)) {
         if (!ohci->done)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 939dcc3d4a..92a45de4c3 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -663,6 +663,8 @@ static void vfio_msi_enable(VFIOPCIDevice *vdev)
 
     vfio_disable_interrupts(vdev);
 
+    vdev->nr_vectors = msi_nr_vectors_allocated(&vdev->pdev);
+retry:
     /*
      * Setting vector notifiers needs to enable route for each vector.
      * Deferring to commit the KVM routes once rather than per vector
@@ -670,8 +672,6 @@ static void vfio_msi_enable(VFIOPCIDevice *vdev)
      */
     vfio_prepare_kvm_msi_virq_batch(vdev);
 
-    vdev->nr_vectors = msi_nr_vectors_allocated(&vdev->pdev);
-retry:
     vdev->msi_vectors = g_new0(VFIOMSIVector, vdev->nr_vectors);
 
     for (i = 0; i < vdev->nr_vectors; i++) {
@@ -3159,7 +3159,9 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
 
 out_deregister:
     pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
-    kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
+    if (vdev->irqchip_change_notifier.notify) {
+        kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
+    }
 out_teardown:
     vfio_teardown_msi(vdev);
     vfio_bars_exit(vdev);
diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
index 5bd14cad96..d422418f2d 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -68,7 +68,7 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp)
  */
 static uint16_t vhost_svq_available_slots(const VhostShadowVirtqueue *svq)
 {
-    return svq->vring.num - (svq->shadow_avail_idx - svq->shadow_used_idx);
+    return svq->num_free;
 }
 
 /**
@@ -263,6 +263,7 @@ int vhost_svq_add(VhostShadowVirtqueue *svq, const struct iovec *out_sg,
         return -EINVAL;
     }
 
+    svq->num_free -= ndescs;
     svq->desc_state[qemu_head].elem = elem;
     svq->desc_state[qemu_head].ndescs = ndescs;
     vhost_svq_kick(svq);
@@ -449,6 +450,7 @@ static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
     last_used_chain = vhost_svq_last_desc_of_chain(svq, num, used_elem.id);
     svq->desc_next[last_used_chain] = svq->free_head;
     svq->free_head = used_elem.id;
+    svq->num_free += num;
 
     *len = used_elem.len;
     return g_steal_pointer(&svq->desc_state[used_elem.id].elem);
@@ -522,7 +524,7 @@ static void vhost_svq_flush(VhostShadowVirtqueue *svq,
 size_t vhost_svq_poll(VhostShadowVirtqueue *svq)
 {
     int64_t start_us = g_get_monotonic_time();
-    uint32_t len;
+    uint32_t len = 0;
 
     do {
         if (vhost_svq_more_used(svq)) {
@@ -656,6 +658,7 @@ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev,
     svq->vq = vq;
 
     svq->vring.num = virtio_queue_get_num(vdev, virtio_get_queue_index(vq));
+    svq->num_free = svq->vring.num;
     driver_size = vhost_svq_driver_area_size(svq);
     device_size = vhost_svq_device_area_size(svq);
     svq->vring.desc = qemu_memalign(qemu_real_host_page_size(), driver_size);
diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-virtqueue.h
index d04c34a589..328a7fc075 100644
--- a/hw/virtio/vhost-shadow-virtqueue.h
+++ b/hw/virtio/vhost-shadow-virtqueue.h
@@ -107,6 +107,9 @@ typedef struct VhostShadowVirtqueue {
 
     /* Next head to consume from the device */
     uint16_t last_used_idx;
+
+    /* Size of SVQ vring free descriptors */
+    uint16_t num_free;
 } VhostShadowVirtqueue;
 
 bool vhost_svq_valid_features(uint64_t features, Error **errp);
diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c
index b7b82a1099..97145376eb 100644
--- a/hw/virtio/vhost-user-gpio.c
+++ b/hw/virtio/vhost-user-gpio.c
@@ -16,6 +16,7 @@
 #include "trace.h"
 
 #define REALIZE_CONNECTION_RETRIES 3
+#define VHOST_NVQS 2
 
 /* Features required from VirtIO */
 static const int feature_bits[] = {
@@ -198,8 +199,7 @@ static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserGPIO *gpio)
 {
     virtio_delete_queue(gpio->command_vq);
     virtio_delete_queue(gpio->interrupt_vq);
-    g_free(gpio->vhost_dev.vqs);
-    gpio->vhost_dev.vqs = NULL;
+    g_free(gpio->vhost_vqs);
     virtio_cleanup(vdev);
     vhost_user_cleanup(&gpio->vhost_user);
 }
@@ -219,6 +219,9 @@ static int vu_gpio_connect(DeviceState *dev, Error **errp)
     vhost_dev_set_config_notifier(vhost_dev, &gpio_ops);
     gpio->vhost_user.supports_config = true;
 
+    gpio->vhost_dev.nvqs = VHOST_NVQS;
+    gpio->vhost_dev.vqs = gpio->vhost_vqs;
+
     ret = vhost_dev_init(vhost_dev, &gpio->vhost_user,
                          VHOST_BACKEND_TYPE_USER, 0, errp);
     if (ret < 0) {
@@ -337,10 +340,9 @@ static void vu_gpio_device_realize(DeviceState *dev, Error **errp)
 
     virtio_init(vdev, VIRTIO_ID_GPIO, sizeof(gpio->config));
 
-    gpio->vhost_dev.nvqs = 2;
     gpio->command_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output);
     gpio->interrupt_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output);
-    gpio->vhost_dev.vqs = g_new0(struct vhost_virtqueue, gpio->vhost_dev.nvqs);
+    gpio->vhost_vqs = g_new0(struct vhost_virtqueue, VHOST_NVQS);
 
     gpio->connected = false;
 
diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c
index dc5c828ba6..60eaf0d95b 100644
--- a/hw/virtio/vhost-user-i2c.c
+++ b/hw/virtio/vhost-user-i2c.c
@@ -143,8 +143,6 @@ static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserI2C *i2c)
     vhost_user_cleanup(&i2c->vhost_user);
     virtio_delete_queue(i2c->vq);
     virtio_cleanup(vdev);
-    g_free(i2c->vhost_dev.vqs);
-    i2c->vhost_dev.vqs = NULL;
 }
 
 static int vu_i2c_connect(DeviceState *dev)
@@ -228,6 +226,7 @@ static void vu_i2c_device_realize(DeviceState *dev, Error **errp)
     ret = vhost_dev_init(&i2c->vhost_dev, &i2c->vhost_user,
                          VHOST_BACKEND_TYPE_USER, 0, errp);
     if (ret < 0) {
+        g_free(i2c->vhost_dev.vqs);
         do_vhost_user_cleanup(vdev, i2c);
     }
 
@@ -239,10 +238,12 @@ static void vu_i2c_device_unrealize(DeviceState *dev)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VHostUserI2C *i2c = VHOST_USER_I2C(dev);
+    struct vhost_virtqueue *vhost_vqs = i2c->vhost_dev.vqs;
 
     /* This will stop vhost backend if appropriate. */
     vu_i2c_set_status(vdev, 0);
     vhost_dev_cleanup(&i2c->vhost_dev);
+    g_free(vhost_vqs);
     do_vhost_user_cleanup(vdev, i2c);
 }
 
diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c
index 201a39e220..efc54cd3fb 100644
--- a/hw/virtio/vhost-user-rng.c
+++ b/hw/virtio/vhost-user-rng.c
@@ -229,6 +229,7 @@ static void vu_rng_device_realize(DeviceState *dev, Error **errp)
     return;
 
 vhost_dev_init_failed:
+    g_free(rng->vhost_dev.vqs);
     virtio_delete_queue(rng->req_vq);
 virtio_add_queue_failed:
     virtio_cleanup(vdev);
@@ -239,12 +240,12 @@ static void vu_rng_device_unrealize(DeviceState *dev)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VHostUserRNG *rng = VHOST_USER_RNG(dev);
+    struct vhost_virtqueue *vhost_vqs = rng->vhost_dev.vqs;
 
     vu_rng_set_status(vdev, 0);
 
     vhost_dev_cleanup(&rng->vhost_dev);
-    g_free(rng->vhost_dev.vqs);
-    rng->vhost_dev.vqs = NULL;
+    g_free(vhost_vqs);
     virtio_delete_queue(rng->req_vq);
     virtio_cleanup(vdev);
     vhost_user_cleanup(&rng->vhost_user);
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 8f635844af..d92b026e1c 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -305,19 +305,8 @@ static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg)
     return 0;
 }
 
-struct vhost_user_read_cb_data {
-    struct vhost_dev *dev;
-    VhostUserMsg *msg;
-    GMainLoop *loop;
-    int ret;
-};
-
-static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
-                                   gpointer opaque)
+static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
 {
-    struct vhost_user_read_cb_data *data = opaque;
-    struct vhost_dev *dev = data->dev;
-    VhostUserMsg *msg = data->msg;
     struct vhost_user *u = dev->opaque;
     CharBackend *chr = u->user->chr;
     uint8_t *p = (uint8_t *) msg;
@@ -325,8 +314,7 @@ static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
 
     r = vhost_user_read_header(dev, msg);
     if (r < 0) {
-        data->ret = r;
-        goto end;
+        return r;
     }
 
     /* validate message size is sane */
@@ -334,8 +322,7 @@ static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
         error_report("Failed to read msg header."
                 " Size %d exceeds the maximum %zu.", msg->hdr.size,
                 VHOST_USER_PAYLOAD_SIZE);
-        data->ret = -EPROTO;
-        goto end;
+        return -EPROTO;
     }
 
     if (msg->hdr.size) {
@@ -346,84 +333,11 @@ static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
             int saved_errno = errno;
             error_report("Failed to read msg payload."
                          " Read %d instead of %d.", r, msg->hdr.size);
-            data->ret = r < 0 ? -saved_errno : -EIO;
-            goto end;
+            return r < 0 ? -saved_errno : -EIO;
         }
     }
 
-end:
-    g_main_loop_quit(data->loop);
-    return G_SOURCE_REMOVE;
-}
-
-static gboolean slave_read(QIOChannel *ioc, GIOCondition condition,
-                           gpointer opaque);
-
-/*
- * This updates the read handler to use a new event loop context.
- * Event sources are removed from the previous context : this ensures
- * that events detected in the previous context are purged. They will
- * be re-detected and processed in the new context.
- */
-static void slave_update_read_handler(struct vhost_dev *dev,
-                                      GMainContext *ctxt)
-{
-    struct vhost_user *u = dev->opaque;
-
-    if (!u->slave_ioc) {
-        return;
-    }
-
-    if (u->slave_src) {
-        g_source_destroy(u->slave_src);
-        g_source_unref(u->slave_src);
-    }
-
-    u->slave_src = qio_channel_add_watch_source(u->slave_ioc,
-                                                G_IO_IN | G_IO_HUP,
-                                                slave_read, dev, NULL,
-                                                ctxt);
-}
-
-static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
-{
-    struct vhost_user *u = dev->opaque;
-    CharBackend *chr = u->user->chr;
-    GMainContext *prev_ctxt = chr->chr->gcontext;
-    GMainContext *ctxt = g_main_context_new();
-    GMainLoop *loop = g_main_loop_new(ctxt, FALSE);
-    struct vhost_user_read_cb_data data = {
-        .dev = dev,
-        .loop = loop,
-        .msg = msg,
-        .ret = 0
-    };
-
-    /*
-     * We want to be able to monitor the slave channel fd while waiting
-     * for chr I/O. This requires an event loop, but we can't nest the
-     * one to which chr is currently attached : its fd handlers might not
-     * be prepared for re-entrancy. So we create a new one and switch chr
-     * to use it.
-     */
-    slave_update_read_handler(dev, ctxt);
-    qemu_chr_be_update_read_handlers(chr->chr, ctxt);
-    qemu_chr_fe_add_watch(chr, G_IO_IN | G_IO_HUP, vhost_user_read_cb, &data);
-
-    g_main_loop_run(loop);
-
-    /*
-     * Restore the previous event loop context. This also destroys/recreates
-     * event sources : this guarantees that all pending events in the original
-     * context that have been processed by the nested loop are purged.
-     */
-    qemu_chr_be_update_read_handlers(chr->chr, prev_ctxt);
-    slave_update_read_handler(dev, NULL);
-
-    g_main_loop_unref(loop);
-    g_main_context_unref(ctxt);
-
-    return data.ret;
+    return 0;
 }
 
 static int process_message_reply(struct vhost_dev *dev,
@@ -1802,7 +1716,9 @@ static int vhost_setup_slave_channel(struct vhost_dev *dev)
         return -ECONNREFUSED;
     }
     u->slave_ioc = ioc;
-    slave_update_read_handler(dev, NULL);
+    u->slave_src = qio_channel_add_watch_source(u->slave_ioc,
+                                                G_IO_IN | G_IO_HUP,
+                                                slave_read, dev, NULL, NULL);
 
     if (reply_supported) {
         msg.hdr.flags |= VHOST_USER_NEED_REPLY_MASK;
@@ -2108,8 +2024,8 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque,
         } else {
             if (virtio_has_feature(protocol_features,
                                    VHOST_USER_PROTOCOL_F_CONFIG)) {
-                warn_reportf_err(*errp, "vhost-user backend supports "
-                                 "VHOST_USER_PROTOCOL_F_CONFIG but QEMU does not.");
+                warn_report("vhost-user backend supports "
+                            "VHOST_USER_PROTOCOL_F_CONFIG but QEMU does not.");
                 protocol_features &= ~(1ULL << VHOST_USER_PROTOCOL_F_CONFIG);
             }
         }
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 7468e44b87..03c78d25d8 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -707,26 +707,11 @@ static int vhost_vdpa_get_device_id(struct vhost_dev *dev,
     return ret;
 }
 
-static void vhost_vdpa_reset_svq(struct vhost_vdpa *v)
-{
-    if (!v->shadow_vqs_enabled) {
-        return;
-    }
-
-    for (unsigned i = 0; i < v->shadow_vqs->len; ++i) {
-        VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
-        vhost_svq_stop(svq);
-    }
-}
-
 static int vhost_vdpa_reset_device(struct vhost_dev *dev)
 {
-    struct vhost_vdpa *v = dev->opaque;
     int ret;
     uint8_t status = 0;
 
-    vhost_vdpa_reset_svq(v);
-
     ret = vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &status);
     trace_vhost_vdpa_reset_device(dev, status);
     return ret;
@@ -1088,6 +1073,8 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *dev)
 
     for (unsigned i = 0; i < v->shadow_vqs->len; ++i) {
         VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
+
+        vhost_svq_stop(svq);
         vhost_vdpa_svq_unmap_rings(dev, svq);
     }
 }
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 7fb008bc9e..f38997b3f6 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -20,6 +20,7 @@
 #include "qemu/range.h"
 #include "qemu/error-report.h"
 #include "qemu/memfd.h"
+#include "qemu/log.h"
 #include "standard-headers/linux/vhost_types.h"
 #include "hw/virtio/virtio-bus.h"
 #include "hw/virtio/virtio-access.h"
@@ -106,6 +107,24 @@ static void vhost_dev_sync_region(struct vhost_dev *dev,
     }
 }
 
+static bool vhost_dev_has_iommu(struct vhost_dev *dev)
+{
+    VirtIODevice *vdev = dev->vdev;
+
+    /*
+     * For vhost, VIRTIO_F_IOMMU_PLATFORM means the backend support
+     * incremental memory mapping API via IOTLB API. For platform that
+     * does not have IOMMU, there's no need to enable this feature
+     * which may cause unnecessary IOTLB miss/update transactions.
+     */
+    if (vdev) {
+        return virtio_bus_device_iommu_enabled(vdev) &&
+            virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
+    } else {
+        return false;
+    }
+}
+
 static int vhost_sync_dirty_bitmap(struct vhost_dev *dev,
                                    MemoryRegionSection *section,
                                    hwaddr first,
@@ -137,8 +156,51 @@ static int vhost_sync_dirty_bitmap(struct vhost_dev *dev,
             continue;
         }
 
-        vhost_dev_sync_region(dev, section, start_addr, end_addr, vq->used_phys,
-                              range_get_last(vq->used_phys, vq->used_size));
+        if (vhost_dev_has_iommu(dev)) {
+            IOMMUTLBEntry iotlb;
+            hwaddr used_phys = vq->used_phys, used_size = vq->used_size;
+            hwaddr phys, s, offset;
+
+            while (used_size) {
+                rcu_read_lock();
+                iotlb = address_space_get_iotlb_entry(dev->vdev->dma_as,
+                                                      used_phys,
+                                                      true,
+                                                      MEMTXATTRS_UNSPECIFIED);
+                rcu_read_unlock();
+
+                if (!iotlb.target_as) {
+                    qemu_log_mask(LOG_GUEST_ERROR, "translation "
+                                  "failure for used_iova %"PRIx64"\n",
+                                  used_phys);
+                    return -EINVAL;
+                }
+
+                offset = used_phys & iotlb.addr_mask;
+                phys = iotlb.translated_addr + offset;
+
+                /*
+                 * Distance from start of used ring until last byte of
+                 * IOMMU page.
+                 */
+                s = iotlb.addr_mask - offset;
+                /*
+                 * Size of used ring, or of the part of it until end
+                 * of IOMMU page. To avoid zero result, do the adding
+                 * outside of MIN().
+                 */
+                s = MIN(s, used_size - 1) + 1;
+
+                vhost_dev_sync_region(dev, section, start_addr, end_addr, phys,
+                                      range_get_last(phys, s));
+                used_size -= s;
+                used_phys += s;
+            }
+        } else {
+            vhost_dev_sync_region(dev, section, start_addr,
+                                  end_addr, vq->used_phys,
+                                  range_get_last(vq->used_phys, vq->used_size));
+        }
     }
     return 0;
 }
@@ -306,24 +368,6 @@ static inline void vhost_dev_log_resize(struct vhost_dev *dev, uint64_t size)
     dev->log_size = size;
 }
 
-static bool vhost_dev_has_iommu(struct vhost_dev *dev)
-{
-    VirtIODevice *vdev = dev->vdev;
-
-    /*
-     * For vhost, VIRTIO_F_IOMMU_PLATFORM means the backend support
-     * incremental memory mapping API via IOTLB API. For platform that
-     * does not have IOMMU, there's no need to enable this feature
-     * which may cause unnecessary IOTLB miss/update transactions.
-     */
-    if (vdev) {
-        return virtio_bus_device_iommu_enabled(vdev) &&
-            virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
-    } else {
-        return false;
-    }
-}
-
 static void *vhost_memory_map(struct vhost_dev *dev, hwaddr addr,
                               hwaddr *plen, bool is_write)
 {
@@ -1890,6 +1934,9 @@ fail_vq:
     }
 
 fail_mem:
+    if (vhost_dev_has_iommu(hdev)) {
+        memory_listener_unregister(&hdev->iommu_listener);
+    }
 fail_features:
     vdev->vhost_started = false;
     hdev->started = false;
diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
index 97da74e719..a6dbdd32da 100644
--- a/hw/virtio/virtio-crypto.c
+++ b/hw/virtio/virtio-crypto.c
@@ -476,15 +476,17 @@ static void virtio_crypto_free_request(VirtIOCryptoReq *req)
         size_t max_len;
         CryptoDevBackendSymOpInfo *op_info = req->op_info.u.sym_op_info;
 
-        max_len = op_info->iv_len +
-                  op_info->aad_len +
-                  op_info->src_len +
-                  op_info->dst_len +
-                  op_info->digest_result_len;
-
-        /* Zeroize and free request data structure */
-        memset(op_info, 0, sizeof(*op_info) + max_len);
-        g_free(op_info);
+        if (op_info) {
+            max_len = op_info->iv_len +
+                      op_info->aad_len +
+                      op_info->src_len +
+                      op_info->dst_len +
+                      op_info->digest_result_len;
+
+            /* Zeroize and free request data structure */
+            memset(op_info, 0, sizeof(*op_info) + max_len);
+            g_free(op_info);
+        }
     } else if (req->flags == CRYPTODEV_BACKEND_ALG_ASYM) {
         CryptoDevBackendAsymOpInfo *op_info = req->op_info.u.asym_op_info;
         if (op_info) {
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index ed170def48..56db586c89 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -235,7 +235,7 @@ static int virtio_mem_for_each_plugged_section(const VirtIOMEM *vmem,
     uint64_t offset, size;
     int ret = 0;
 
-    first_bit = s->offset_within_region / vmem->bitmap_size;
+    first_bit = s->offset_within_region / vmem->block_size;
     first_bit = find_next_bit(vmem->bitmap, vmem->bitmap_size, first_bit);
     while (first_bit < vmem->bitmap_size) {
         MemoryRegionSection tmp = *s;
@@ -267,7 +267,7 @@ static int virtio_mem_for_each_unplugged_section(const VirtIOMEM *vmem,
     uint64_t offset, size;
     int ret = 0;
 
-    first_bit = s->offset_within_region / vmem->bitmap_size;
+    first_bit = s->offset_within_region / vmem->block_size;
     first_bit = find_next_zero_bit(vmem->bitmap, vmem->bitmap_size, first_bit);
     while (first_bit < vmem->bitmap_size) {
         MemoryRegionSection tmp = *s;
@@ -341,7 +341,7 @@ static int virtio_mem_notify_plug(VirtIOMEM *vmem, uint64_t offset,
     if (ret) {
         /* Notify all already-notified listeners. */
         QLIST_FOREACH(rdl2, &vmem->rdl_list, next) {
-            MemoryRegionSection tmp = *rdl->section;
+            MemoryRegionSection tmp = *rdl2->section;
 
             if (rdl2 == rdl) {
                 break;
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index eb6347ab5d..384c8f0f08 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1478,7 +1478,7 @@ static void virtqueue_split_get_avail_bytes(VirtQueue *vq,
                             VRingMemoryRegionCaches *caches)
 {
     VirtIODevice *vdev = vq->vdev;
-    unsigned int max, idx;
+    unsigned int idx;
     unsigned int total_bufs, in_total, out_total;
     MemoryRegionCache indirect_desc_cache = MEMORY_REGION_CACHE_INVALID;
     int64_t len = 0;
@@ -1487,13 +1487,12 @@ static void virtqueue_split_get_avail_bytes(VirtQueue *vq,
     idx = vq->last_avail_idx;
     total_bufs = in_total = out_total = 0;
 
-    max = vq->vring.num;
-
     while ((rc = virtqueue_num_heads(vq, idx)) > 0) {
         MemoryRegionCache *desc_cache = &caches->desc;
         unsigned int num_bufs;
         VRingDesc desc;
         unsigned int i;
+        unsigned int max = vq->vring.num;
 
         num_bufs = total_bufs;
 
@@ -1615,7 +1614,7 @@ static void virtqueue_packed_get_avail_bytes(VirtQueue *vq,
                                              VRingMemoryRegionCaches *caches)
 {
     VirtIODevice *vdev = vq->vdev;
-    unsigned int max, idx;
+    unsigned int idx;
     unsigned int total_bufs, in_total, out_total;
     MemoryRegionCache *desc_cache;
     MemoryRegionCache indirect_desc_cache = MEMORY_REGION_CACHE_INVALID;
@@ -1627,14 +1626,14 @@ static void virtqueue_packed_get_avail_bytes(VirtQueue *vq,
     wrap_counter = vq->last_avail_wrap_counter;
     total_bufs = in_total = out_total = 0;
 
-    max = vq->vring.num;
-
     for (;;) {
         unsigned int num_bufs = total_bufs;
         unsigned int i = idx;
         int rc;
+        unsigned int max = vq->vring.num;
 
         desc_cache = &caches->desc;
+
         vring_packed_desc_read(vdev, &desc, desc_cache, idx, true);
         if (!is_desc_avail(desc.flags, wrap_counter)) {
             break;
diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
index 0ec7e52183..5dd706efbf 100644
--- a/hw/xen/xen_pt.c
+++ b/hw/xen/xen_pt.c
@@ -57,6 +57,7 @@
 #include <sys/ioctl.h>
 
 #include "hw/pci/pci.h"
+#include "hw/pci/pci_bus.h"
 #include "hw/qdev-properties.h"
 #include "hw/qdev-properties-system.h"
 #include "hw/xen/xen.h"
@@ -780,15 +781,6 @@ static void xen_pt_realize(PCIDevice *d, Error **errp)
                s->hostaddr.bus, s->hostaddr.slot, s->hostaddr.function,
                s->dev.devfn);
 
-    xen_host_pci_device_get(&s->real_device,
-                            s->hostaddr.domain, s->hostaddr.bus,
-                            s->hostaddr.slot, s->hostaddr.function,
-                            errp);
-    if (*errp) {
-        error_append_hint(errp, "Failed to \"open\" the real pci device");
-        return;
-    }
-
     s->is_virtfn = s->real_device.is_virtfn;
     if (s->is_virtfn) {
         XEN_PT_LOG(d, "%04x:%02x:%02x.%d is a SR-IOV Virtual Function\n",
@@ -803,8 +795,10 @@ static void xen_pt_realize(PCIDevice *d, Error **errp)
     s->io_listener = xen_pt_io_listener;
 
     /* Setup VGA bios for passthrough GFX */
-    if ((s->real_device.domain == 0) && (s->real_device.bus == 0) &&
-        (s->real_device.dev == 2) && (s->real_device.func == 0)) {
+    if ((s->real_device.domain == XEN_PCI_IGD_DOMAIN) &&
+        (s->real_device.bus == XEN_PCI_IGD_BUS) &&
+        (s->real_device.dev == XEN_PCI_IGD_DEV) &&
+        (s->real_device.func == XEN_PCI_IGD_FN)) {
         if (!is_igd_vga_passthrough(&s->real_device)) {
             error_setg(errp, "Need to enable igd-passthru if you're trying"
                     " to passthrough IGD GFX");
@@ -950,11 +944,58 @@ static void xen_pci_passthrough_instance_init(Object *obj)
     PCI_DEVICE(obj)->cap_present |= QEMU_PCI_CAP_EXPRESS;
 }
 
+void xen_igd_reserve_slot(PCIBus *pci_bus)
+{
+    if (!xen_igd_gfx_pt_enabled()) {
+        return;
+    }
+
+    XEN_PT_LOG(0, "Reserving PCI slot 2 for IGD\n");
+    pci_bus->slot_reserved_mask |= XEN_PCI_IGD_SLOT_MASK;
+}
+
+static void xen_igd_clear_slot(DeviceState *qdev, Error **errp)
+{
+    ERRP_GUARD();
+    PCIDevice *pci_dev = (PCIDevice *)qdev;
+    XenPCIPassthroughState *s = XEN_PT_DEVICE(pci_dev);
+    XenPTDeviceClass *xpdc = XEN_PT_DEVICE_GET_CLASS(s);
+    PCIBus *pci_bus = pci_get_bus(pci_dev);
+
+    xen_host_pci_device_get(&s->real_device,
+                            s->hostaddr.domain, s->hostaddr.bus,
+                            s->hostaddr.slot, s->hostaddr.function,
+                            errp);
+    if (*errp) {
+        error_append_hint(errp, "Failed to \"open\" the real pci device");
+        return;
+    }
+
+    if (!(pci_bus->slot_reserved_mask & XEN_PCI_IGD_SLOT_MASK)) {
+        xpdc->pci_qdev_realize(qdev, errp);
+        return;
+    }
+
+    if (is_igd_vga_passthrough(&s->real_device) &&
+        s->real_device.domain == XEN_PCI_IGD_DOMAIN &&
+        s->real_device.bus == XEN_PCI_IGD_BUS &&
+        s->real_device.dev == XEN_PCI_IGD_DEV &&
+        s->real_device.func == XEN_PCI_IGD_FN &&
+        s->real_device.vendor_id == PCI_VENDOR_ID_INTEL) {
+        pci_bus->slot_reserved_mask &= ~XEN_PCI_IGD_SLOT_MASK;
+        XEN_PT_LOG(pci_dev, "Intel IGD found, using slot 2\n");
+    }
+    xpdc->pci_qdev_realize(qdev, errp);
+}
+
 static void xen_pci_passthrough_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
+    XenPTDeviceClass *xpdc = XEN_PT_DEVICE_CLASS(klass);
+    xpdc->pci_qdev_realize = dc->realize;
+    dc->realize = xen_igd_clear_slot;
     k->realize = xen_pt_realize;
     k->exit = xen_pt_unregister_device;
     k->config_read = xen_pt_pci_read_config;
@@ -977,6 +1018,7 @@ static const TypeInfo xen_pci_passthrough_info = {
     .instance_size = sizeof(XenPCIPassthroughState),
     .instance_finalize = xen_pci_passthrough_finalize,
     .class_init = xen_pci_passthrough_class_init,
+    .class_size = sizeof(XenPTDeviceClass),
     .instance_init = xen_pci_passthrough_instance_init,
     .interfaces = (InterfaceInfo[]) {
         { INTERFACE_CONVENTIONAL_PCI_DEVICE },
diff --git a/hw/xen/xen_pt.h b/hw/xen/xen_pt.h
index e7c4316a7d..292bdf7499 100644
--- a/hw/xen/xen_pt.h
+++ b/hw/xen/xen_pt.h
@@ -41,7 +41,20 @@ typedef struct XenPTReg XenPTReg;
 #define TYPE_XEN_PT_DEVICE "xen-pci-passthrough"
 OBJECT_DECLARE_SIMPLE_TYPE(XenPCIPassthroughState, XEN_PT_DEVICE)
 
+#define XEN_PT_DEVICE_CLASS(klass) \
+    OBJECT_CLASS_CHECK(XenPTDeviceClass, klass, TYPE_XEN_PT_DEVICE)
+#define XEN_PT_DEVICE_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(XenPTDeviceClass, obj, TYPE_XEN_PT_DEVICE)
+
+typedef void (*XenPTQdevRealize)(DeviceState *qdev, Error **errp);
+
+typedef struct XenPTDeviceClass {
+    PCIDeviceClass parent_class;
+    XenPTQdevRealize pci_qdev_realize;
+} XenPTDeviceClass;
+
 uint32_t igd_read_opregion(XenPCIPassthroughState *s);
+void xen_igd_reserve_slot(PCIBus *pci_bus);
 void igd_write_opregion(XenPCIPassthroughState *s, uint32_t val);
 void xen_igd_passthrough_isa_bridge_create(XenPCIPassthroughState *s,
                                            XenHostPCIDevice *dev);
@@ -76,6 +89,13 @@ typedef int (*xen_pt_conf_byte_read)
 
 #define XEN_PCI_INTEL_OPREGION 0xfc
 
+#define XEN_PCI_IGD_DOMAIN 0
+#define XEN_PCI_IGD_BUS 0
+#define XEN_PCI_IGD_DEV 2
+#define XEN_PCI_IGD_FN 0
+#define XEN_PCI_IGD_SLOT_MASK \
+    (1UL << PCI_SLOT(PCI_DEVFN(XEN_PCI_IGD_DEV, XEN_PCI_IGD_FN)))
+
 typedef enum {
     XEN_PT_GRP_TYPE_HARDWIRED = 0,  /* 0 Hardwired reg group */
     XEN_PT_GRP_TYPE_EMU,            /* emul reg group */
diff --git a/hw/xen/xen_pt_stub.c b/hw/xen/xen_pt_stub.c
index 2d8cac8d54..5c108446a8 100644
--- a/hw/xen/xen_pt_stub.c
+++ b/hw/xen/xen_pt_stub.c
@@ -20,3 +20,7 @@ void xen_igd_gfx_pt_set(bool value, Error **errp)
         error_setg(errp, "Xen PCI passthrough support not built in");
     }
 }
+
+void xen_igd_reserve_slot(PCIBus *pci_bus)
+{
+}
diff --git a/include/hw/arm/boot.h b/include/hw/arm/boot.h
index f18cc3064f..80c492d742 100644
--- a/include/hw/arm/boot.h
+++ b/include/hw/arm/boot.h
@@ -183,4 +183,53 @@ void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,
                                             const struct arm_boot_info *info,
                                             hwaddr mvbar_addr);
 
+typedef enum {
+    FIXUP_NONE = 0,     /* do nothing */
+    FIXUP_TERMINATOR,   /* end of insns */
+    FIXUP_BOARDID,      /* overwrite with board ID number */
+    FIXUP_BOARD_SETUP,  /* overwrite with board specific setup code address */
+    FIXUP_ARGPTR_LO,    /* overwrite with pointer to kernel args */
+    FIXUP_ARGPTR_HI,    /* overwrite with pointer to kernel args (high half) */
+    FIXUP_ENTRYPOINT_LO, /* overwrite with kernel entry point */
+    FIXUP_ENTRYPOINT_HI, /* overwrite with kernel entry point (high half) */
+    FIXUP_GIC_CPU_IF,   /* overwrite with GIC CPU interface address */
+    FIXUP_BOOTREG,      /* overwrite with boot register address */
+    FIXUP_DSB,          /* overwrite with correct DSB insn for cpu */
+    FIXUP_MAX,
+} FixupType;
+
+typedef struct ARMInsnFixup {
+    uint32_t insn;
+    FixupType fixup;
+} ARMInsnFixup;
+
+/**
+ * arm_write_bootloader - write a bootloader to guest memory
+ * @name: name of the bootloader blob
+ * @as: AddressSpace to write the bootloader
+ * @addr: guest address to write it
+ * @insns: the blob to be loaded
+ * @fixupcontext: context to be used for any fixups in @insns
+ *
+ * Write a bootloader to guest memory at address @addr in the address
+ * space @as. @name is the name to use for the resulting ROM blob, so
+ * it should be unique in the system and reasonably identifiable for debugging.
+ *
+ * @insns must be an array of ARMInsnFixup structs, each of which has
+ * one 32-bit value to be written to the guest memory, and a fixup to be
+ * applied to the value. FIXUP_NONE (do nothing) is value 0, so effectively
+ * the fixup is optional when writing a struct initializer.
+ * The final entry in the array must be { 0, FIXUP_TERMINATOR }.
+ *
+ * All other supported fixup types have the semantics "ignore insn
+ * and instead use the value from the array element @fixupcontext[fixup]".
+ * The caller should therefore provide @fixupcontext as an array of
+ * size FIXUP_MAX whose elements have been initialized for at least
+ * the entries that @insns refers to.
+ */
+void arm_write_bootloader(const char *name,
+                          AddressSpace *as, hwaddr addr,
+                          const ARMInsnFixup *insns,
+                          const uint32_t *fixupcontext);
+
 #endif /* HW_ARM_BOOT_H */
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index c95333514e..0c76e82626 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -128,9 +128,6 @@ struct PCMachineClass {
 
     /* create kvmclock device even when KVM PV features are not exposed */
     bool kvmclock_create_always;
-
-    /* skip passing an rng seed for legacy machines */
-    bool legacy_no_rng_seed;
 };
 
 #define TYPE_PC_MACHINE "generic-pc-machine"
diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
index 62fa5774f8..df82c5fd42 100644
--- a/include/hw/i386/x86.h
+++ b/include/hw/i386/x86.h
@@ -126,8 +126,7 @@ void x86_bios_rom_init(MachineState *ms, const char *default_firmware,
 void x86_load_linux(X86MachineState *x86ms,
                     FWCfgState *fw_cfg,
                     int acpi_data_size,
-                    bool pvh_enabled,
-                    bool legacy_no_rng_seed);
+                    bool pvh_enabled);
 
 bool x86_machine_is_smm_enabled(const X86MachineState *x86ms);
 bool x86_machine_is_acpi_enabled(const X86MachineState *x86ms);
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
index 2e503904dc..c1f81a5f13 100644
--- a/include/hw/nvram/fw_cfg.h
+++ b/include/hw/nvram/fw_cfg.h
@@ -117,28 +117,6 @@ struct FWCfgMemState {
  */
 void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len);
 
-/**
- * fw_cfg_add_bytes_callback:
- * @s: fw_cfg device being modified
- * @key: selector key value for new fw_cfg item
- * @select_cb: callback function when selecting
- * @write_cb: callback function after a write
- * @callback_opaque: argument to be passed into callback function
- * @data: pointer to start of item data
- * @len: size of item data
- * @read_only: is file read only
- *
- * Add a new fw_cfg item, available by selecting the given key, as a raw
- * "blob" of the given size. The data referenced by the starting pointer
- * is only linked, NOT copied, into the data structure of the fw_cfg device.
- */
-void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
-                               FWCfgCallback select_cb,


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 15:55:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 15:55:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681045.1059581 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHbJ-0006er-3u; Wed, 14 Feb 2024 15:55:09 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681045.1059581; Wed, 14 Feb 2024 15:55:09 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHbJ-0006ek-0b; Wed, 14 Feb 2024 15:55:09 +0000
Received: by outflank-mailman (input) for mailman id 681045;
 Wed, 14 Feb 2024 15:55:07 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHbH-0006ea-GK
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:55:07 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHbH-0006oj-CD
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:55:07 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHbH-0003dl-BB
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 15:55:07 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=J/fGcuL17hZKLt75whHJ1Qva/E6XHqwHh9alqBX0aKI=; b=bSr9Nzg9cpIKw6jHdLYJS2CgvI
	Gh5NlLtQPMtuqFdjTz+IEgsKetpSvhIoNciIU8AbU6jnazK+aVsGhTtOglD7nQn0wDt1J4TsZftOh
	F0Pr3KoCGLgxIihSpn+QuexPXpP1/ij2Gwuc2Mw0xPjignms8nOE+A83oxk38Ug78dgA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging] Merge tag 'v7.2.4' into staging
Message-Id: <E1raHbH-0003dl-BB@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 15:55:07 +0000

=== This changeset includes merge from high-traffic branch ===
Commits on that branch are not reported individually.

commit 698407ef8395521a9a5b15ed9cd0b7e1fc258ded
Merge: 8c51cd970509b97d8378d175646ec32889828158 681858ea14242d3b509b77e0179f7f63c99032bb
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Fri Jul 21 14:57:10 2023 +0100
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Fri Jul 21 14:57:10 2023 +0100

    Merge tag 'v7.2.4' into staging
    
    v7.2.4 release
 .gitlab-ci.d/buildtest.yml                         |   6 +-
 VERSION                                            |   2 +-
 accel/tcg/cputlb.c                                 |   2 +-
 block/curl.c                                       |  44 ++++-
 block/io.c                                         |   3 +
 block/iscsi.c                                      |   1 +
 block/monitor/block-hmp-cmds.c                     |  10 +-
 block/qcow2-bitmap.c                               |   5 +-
 block/vhdx-log.c                                   |   2 +-
 blockdev.c                                         |  18 +-
 chardev/char-socket.c                              |   1 +
 configure                                          |   2 +-
 docs/about/deprecated.rst                          |   4 +-
 docs/system/multi-process.rst                      |   2 +-
 fpu/softfloat.c                                    |   2 +-
 fsdev/virtfs-proxy-helper.c                        |  27 ++-
 hw/9pfs/9p-util.h                                  |  38 ++++
 hw/9pfs/trace-events                               |   6 +
 hw/9pfs/xen-9p-backend.c                           |  35 ++--
 hw/acpi/cpu_hotplug.c                              |   3 +
 hw/acpi/pcihp.c                                    |  10 ++
 hw/arm/aspeed.c                                    |  42 ++---
 hw/arm/boot.c                                      |  40 ++---
 hw/arm/raspi.c                                     |  64 +++----
 hw/arm/xlnx-zynqmp.c                               |   2 +-
 hw/core/machine.c                                  |  11 ++
 hw/display/virtio-gpu.c                            |  27 ++-
 hw/dma/xilinx_axidma.c                             |  11 +-
 hw/hppa/machine.c                                  |  15 +-
 hw/i386/intel_iommu.c                              |  15 ++
 hw/i386/microvm.c                                  |   2 +-
 hw/i386/pc.c                                       |   4 +-
 hw/i386/pc_piix.c                                  |   3 +-
 hw/i386/pc_q35.c                                   |   2 -
 hw/i386/x86.c                                      |  88 ++-------
 hw/intc/allwinner-a10-pic.c                        |   7 +-
 hw/misc/aspeed_hace.c                              |   2 +-
 hw/net/allwinner-sun8i-emac.c                      |  22 ++-
 hw/net/e1000.c                                     |   9 +-
 hw/net/e1000e_core.c                               |   5 +-
 hw/net/e1000x_common.c                             |   5 +-
 hw/net/msf2-emac.c                                 |  18 +-
 hw/net/rtl8139.c                                   |   3 +
 hw/net/virtio-net.c                                |   1 -
 hw/net/vmxnet3.c                                   |   2 +-
 hw/nvme/ctrl.c                                     |  35 +++-
 hw/nvram/fw_cfg.c                                  |  12 +-
 hw/ppc/ppc.c                                       |   2 +
 hw/ppc/prep.c                                      |   4 +-
 hw/rdma/vmw/pvrdma_cmd.c                           |   6 +
 hw/remote/trace-events                             |   4 +-
 hw/riscv/numa.c                                    |   6 +
 hw/scsi/lsi53c895a.c                               |  23 ++-
 hw/scsi/scsi-generic.c                             |  14 +-
 hw/sd/allwinner-sdhost.c                           |  31 +++-
 hw/smbios/smbios.c                                 |   8 +-
 hw/timer/hpet.c                                    |  19 +-
 hw/timer/nrf51_timer.c                             |   7 +-
 hw/usb/hcd-ohci.c                                  |   2 +
 hw/vfio/pci.c                                      |   8 +-
 hw/virtio/vhost-shadow-virtqueue.c                 |   7 +-
 hw/virtio/vhost-shadow-virtqueue.h                 |   3 +
 hw/virtio/vhost-user-gpio.c                        |  10 +-
 hw/virtio/vhost-user-i2c.c                         |   5 +-
 hw/virtio/vhost-user-rng.c                         |   5 +-
 hw/virtio/vhost-user.c                             | 104 ++---------
 hw/virtio/vhost-vdpa.c                             |  17 +-
 hw/virtio/vhost.c                                  |  87 ++++++---
 hw/virtio/virtio-crypto.c                          |  20 ++-
 hw/virtio/virtio-mem.c                             |   6 +-
 hw/virtio/virtio.c                                 |  11 +-
 hw/xen/xen_pt.c                                    |  64 +++++--
 hw/xen/xen_pt.h                                    |  20 +++
 hw/xen/xen_pt_stub.c                               |   4 +
 include/hw/arm/boot.h                              |  49 +++++
 include/hw/i386/pc.h                               |   3 -
 include/hw/i386/x86.h                              |   3 +-
 include/hw/nvram/fw_cfg.h                          |  22 ---
 include/hw/virtio/vhost-user-gpio.h                |   2 +-
 include/qemu/compiler.h                            |  13 ++
 include/qemu/host-utils.h                          |   2 +-
 include/qemu/osdep.h                               |   2 +-
 io/channel-tls.c                                   |   3 +
 linux-user/fd-trans.c                              |  10 +-
 linux-user/fd-trans.h                              |   1 +
 linux-user/generic/target_resource.h               |   4 +-
 linux-user/mips/cpu_loop.c                         |   5 +-
 linux-user/s390x/cpu_loop.c                        |   9 +
 linux-user/syscall.c                               | 120 +++++++++----
 meson.build                                        |   6 +-
 migration/migration.c                              |  30 ++--
 migration/ram.c                                    |   9 +-
 net/vhost-vdpa.c                                   |  11 +-
 pc-bios/hppa-firmware.img                          | Bin 719368 -> 720216 bytes
 pc-bios/keymaps/meson.build                        |   2 +-
 qemu-options.hx                                    |  24 ++-
 qga/commands-posix.c                               |  12 +-
 qga/commands.c                                     |   5 +-
 qga/installer/qemu-ga.wxs                          |   1 +
 qga/vss-win32/install.cpp                          |   2 +-
 roms/seabios-hppa                                  |   2 +-
 scripts/device-crash-test                          |   4 +-
 scripts/shaderinclude.pl                           |  16 --
 scripts/shaderinclude.py                           |  26 +++
 scripts/symlink-install-tree.py                    |   1 -
 softmmu/icount.c                                   |   9 +-
 subprojects/libvhost-user/libvhost-user.c          |   7 +
 target/arm/cpu.h                                   |   3 +
 target/arm/helper.c                                |   3 +
 target/arm/kvm.c                                   |   2 +
 target/arm/kvm64.c                                 |  18 +-
 target/arm/kvm_arm.h                               |   8 +
 target/arm/ptw.c                                   |   6 +-
 target/arm/sve_helper.c                            |  20 ++-
 target/arm/tlb_helper.c                            |  13 +-
 target/arm/translate-a32.h                         |   7 +
 target/arm/translate-a64.c                         |  24 ++-
 target/arm/translate.c                             |   6 +-
 target/i386/cpu.c                                  |   4 +-
 target/i386/ops_sse.h                              |   8 +
 target/i386/tcg/decode-new.c.inc                   |  15 +-
 target/i386/tcg/emit.c.inc                         |  61 ++++---
 target/ppc/cpu_init.c                              |   2 +-
 target/ppc/excp_helper.c                           |   9 +-
 target/ppc/helper_regs.c                           |  73 ++++++--
 target/ppc/helper_regs.h                           |   1 +
 target/ppc/machine.c                               |   8 +-
 target/ppc/power8-pmu.c                            |  38 ++--
 target/ppc/power8-pmu.h                            |   4 +-
 target/ppc/translate.c                             |   1 +
 target/ppc/translate/vmx-impl.c.inc                |   2 +-
 target/riscv/insn_trans/trans_privileged.c.inc     |   6 +
 target/riscv/translate.c                           |  12 +-
 target/s390x/arch_dump.c                           |   2 +-
 target/s390x/cpu.h                                 |   1 +
 target/s390x/cpu_models.c                          |   4 +-
 target/s390x/cpu_models.h                          |  10 +-
 target/s390x/s390x-internal.h                      |   3 +-
 target/s390x/tcg/insn-data.h.inc                   |  10 +-
 target/s390x/tcg/mem_helper.c                      |   1 +
 target/s390x/tcg/translate.c                       | 106 ++++++++---
 target/sh4/cpu.c                                   |   2 +-
 .../docker/dockerfiles/debian-xtensa-cross.docker  |   2 +-
 tests/qtest/fuzz-lsi53c895a-test.c                 |  33 ++++
 tests/tcg/Makefile.target                          |   2 +
 tests/tcg/i386/Makefile.target                     |   6 +-
 tests/tcg/i386/test-i386-adcox.c                   |  75 ++++++++
 tests/tcg/i386/test-i386-bmi2.c                    | 197 +++++++++++----------
 tests/tcg/multiarch/linux/linux-test.c             |   6 +-
 tests/tcg/riscv64/Makefile.target                  |   6 +
 tests/tcg/riscv64/test-noc.S                       |  32 ++++
 tests/tcg/s390x/Makefile.target                    |  13 +-
 tests/tcg/s390x/gdbstub/test-svc.py                |  64 +++++++
 tests/tcg/s390x/hello-s390x-asm.S                  |  20 +++
 tests/tcg/s390x/lcbb.c                             |  51 ++++++
 tests/tcg/s390x/locfhr.c                           |  29 +++
 ui/console.c                                       |   4 +-
 ui/gtk-egl.c                                       |   9 +-
 ui/gtk-gl-area.c                                   |   5 +-
 ui/gtk.c                                           |  12 +-
 ui/sdl2-gl.c                                       |   4 +
 ui/sdl2.c                                          |   7 +
 ui/vnc-jobs.c                                      |   3 +-
 ui/vnc.c                                           |   2 +-
 util/async.c                                       |  14 ++
 util/fdmon-epoll.c                                 |  25 ++-
 util/vfio-helpers.c                                |   8 +-
 167 files changed, 1854 insertions(+), 850 deletions(-)

diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml
index d21b4a1fd4..10886bb414 100644
--- a/.gitlab-ci.d/buildtest.yml
+++ b/.gitlab-ci.d/buildtest.yml
@@ -109,8 +109,8 @@ crash-test-debian:
     IMAGE: debian-amd64
   script:
     - cd build
-    - make check-venv
-    - tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-i386
+    - make NINJA=":" check-venv
+    - tests/venv/bin/python3 scripts/device-crash-test -q --tcg-only ./qemu-system-i386
 
 build-system-fedora:
   extends: .native_build_job_template
@@ -155,7 +155,7 @@ crash-test-fedora:
     IMAGE: fedora
   script:
     - cd build
-    - make check-venv
+    - make NINJA=":" check-venv
     - tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-ppc
     - tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-riscv32
 
diff --git a/VERSION b/VERSION
index 0ee843cc60..2bbaead448 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-7.2.0
+7.2.4
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index 6f1c00682b..1160aec626 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -1817,7 +1817,7 @@ static void *atomic_mmu_lookup(CPUArchState *env, target_ulong addr,
     } else /* if (prot & PAGE_READ) */ {
         tlb_addr = tlbe->addr_read;
         if (!tlb_hit(tlb_addr, addr)) {
-            if (!VICTIM_TLB_HIT(addr_write, addr)) {
+            if (!VICTIM_TLB_HIT(addr_read, addr)) {
                 tlb_fill(env_cpu(env), addr, size,
                          MMU_DATA_LOAD, mmu_idx, retaddr);
                 index = tlb_index(env, mmu_idx, addr);
diff --git a/block/curl.c b/block/curl.c
index cba4c4cac7..0b125095e3 100644
--- a/block/curl.c
+++ b/block/curl.c
@@ -37,8 +37,15 @@
 
 // #define DEBUG_VERBOSE
 
+/* CURL 7.85.0 switches to a string based API for specifying
+ * the desired protocols.
+ */
+#if LIBCURL_VERSION_NUM >= 0x075500
+#define PROTOCOLS "HTTP,HTTPS,FTP,FTPS"
+#else
 #define PROTOCOLS (CURLPROTO_HTTP | CURLPROTO_HTTPS | \
                    CURLPROTO_FTP | CURLPROTO_FTPS)
+#endif
 
 #define CURL_NUM_STATES 8
 #define CURL_NUM_ACB    8
@@ -509,9 +516,18 @@ static int curl_init_state(BDRVCURLState *s, CURLState *state)
          * obscure protocols.  For example, do not allow POP3/SMTP/IMAP see
          * CVE-2013-0249.
          *
-         * Restricting protocols is only supported from 7.19.4 upwards.
+         * Restricting protocols is only supported from 7.19.4 upwards. Note:
+         * version 7.85.0 deprecates CURLOPT_*PROTOCOLS in favour of a string
+         * based CURLOPT_*PROTOCOLS_STR API.
          */
-#if LIBCURL_VERSION_NUM >= 0x071304
+#if LIBCURL_VERSION_NUM >= 0x075500
+        if (curl_easy_setopt(state->curl,
+                             CURLOPT_PROTOCOLS_STR, PROTOCOLS) ||
+            curl_easy_setopt(state->curl,
+                             CURLOPT_REDIR_PROTOCOLS_STR, PROTOCOLS)) {
+            goto err;
+        }
+#elif LIBCURL_VERSION_NUM >= 0x071304
         if (curl_easy_setopt(state->curl, CURLOPT_PROTOCOLS, PROTOCOLS) ||
             curl_easy_setopt(state->curl, CURLOPT_REDIR_PROTOCOLS, PROTOCOLS)) {
             goto err;
@@ -669,7 +685,12 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
     const char *file;
     const char *cookie;
     const char *cookie_secret;
-    double d;
+    /* CURL >= 7.55.0 uses curl_off_t for content length instead of a double */
+#if LIBCURL_VERSION_NUM >= 0x073700
+    curl_off_t cl;
+#else
+    double cl;
+#endif
     const char *secretid;
     const char *protocol_delimiter;
     int ret;
@@ -796,27 +817,36 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags,
     }
     if (curl_easy_perform(state->curl))
         goto out;
-    if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &d)) {
+    /* CURL 7.55.0 deprecates CURLINFO_CONTENT_LENGTH_DOWNLOAD in favour of
+     * the *_T version which returns a more sensible type for content length.
+     */
+#if LIBCURL_VERSION_NUM >= 0x073700
+    if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD_T, &cl)) {
+        goto out;
+    }
+#else
+    if (curl_easy_getinfo(state->curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD, &cl)) {
         goto out;
     }
+#endif
     /* Prior CURL 7.19.4 return value of 0 could mean that the file size is not
      * know or the size is zero. From 7.19.4 CURL returns -1 if size is not
      * known and zero if it is really zero-length file. */
 #if LIBCURL_VERSION_NUM >= 0x071304
-    if (d < 0) {
+    if (cl < 0) {
         pstrcpy(state->errmsg, CURL_ERROR_SIZE,
                 "Server didn't report file size.");
         goto out;
     }
 #else
-    if (d <= 0) {
+    if (cl <= 0) {
         pstrcpy(state->errmsg, CURL_ERROR_SIZE,
                 "Unknown file size or zero-length file.");
         goto out;
     }
 #endif
 
-    s->len = d;
+    s->len = cl;
 
     if ((!strncasecmp(s->url, "http://", strlen("http://"))
         || !strncasecmp(s->url, "https://", strlen("https://")))
diff --git a/block/io.c b/block/io.c
index b9424024f9..bbaa0d1b2d 100644
--- a/block/io.c
+++ b/block/io.c
@@ -2087,6 +2087,9 @@ static int coroutine_fn bdrv_aligned_pwritev(BdrvChild *child,
         if (bs->detect_zeroes == BLOCKDEV_DETECT_ZEROES_OPTIONS_UNMAP) {
             flags |= BDRV_REQ_MAY_UNMAP;
         }
+
+        /* Can't use optimization hint with bufferless zero write */
+        flags &= ~BDRV_REQ_REGISTERED_BUF;
     }
 
     if (ret < 0) {
diff --git a/block/iscsi.c b/block/iscsi.c
index a316d46d96..1bba42a71b 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -268,6 +268,7 @@ iscsi_co_generic_cb(struct iscsi_context *iscsi, int status,
                 timer_mod(&iTask->retry_timer,
                           qemu_clock_get_ms(QEMU_CLOCK_REALTIME) + retry_time);
                 iTask->do_retry = 1;
+                return;
             } else if (status == SCSI_STATUS_CHECK_CONDITION) {
                 int error = iscsi_translate_sense(&task->sense);
                 if (error == EAGAIN) {
diff --git a/block/monitor/block-hmp-cmds.c b/block/monitor/block-hmp-cmds.c
index b6135e9bfe..cf21b5e40a 100644
--- a/block/monitor/block-hmp-cmds.c
+++ b/block/monitor/block-hmp-cmds.c
@@ -213,15 +213,17 @@ void hmp_commit(Monitor *mon, const QDict *qdict)
             error_report("Device '%s' not found", device);
             return;
         }
-        if (!blk_is_available(blk)) {
-            error_report("Device '%s' has no medium", device);
-            return;
-        }
 
         bs = bdrv_skip_implicit_filters(blk_bs(blk));
         aio_context = bdrv_get_aio_context(bs);
         aio_context_acquire(aio_context);
 
+        if (!blk_is_available(blk)) {
+            error_report("Device '%s' has no medium", device);
+            aio_context_release(aio_context);
+            return;
+        }
+
         ret = bdrv_commit(bs);
 
         aio_context_release(aio_context);
diff --git a/block/qcow2-bitmap.c b/block/qcow2-bitmap.c
index bcad567c0c..3dff99ba06 100644
--- a/block/qcow2-bitmap.c
+++ b/block/qcow2-bitmap.c
@@ -115,7 +115,7 @@ static int update_header_sync(BlockDriverState *bs)
     return bdrv_flush(bs->file->bs);
 }
 
-static inline void bitmap_table_to_be(uint64_t *bitmap_table, size_t size)
+static inline void bitmap_table_bswap_be(uint64_t *bitmap_table, size_t size)
 {
     size_t i;
 
@@ -1401,9 +1401,10 @@ static int store_bitmap(BlockDriverState *bs, Qcow2Bitmap *bm, Error **errp)
         goto fail;
     }
 
-    bitmap_table_to_be(tb, tb_size);
+    bitmap_table_bswap_be(tb, tb_size);
     ret = bdrv_pwrite(bs->file, tb_offset, tb_size * sizeof(tb[0]), tb, 0);
     if (ret < 0) {
+        bitmap_table_bswap_be(tb, tb_size);
         error_setg_errno(errp, -ret, "Failed to write bitmap '%s' to file",
                          bm_name);
         goto fail;
diff --git a/block/vhdx-log.c b/block/vhdx-log.c
index 572582b87b..0866897a85 100644
--- a/block/vhdx-log.c
+++ b/block/vhdx-log.c
@@ -980,7 +980,7 @@ static int vhdx_log_write(BlockDriverState *bs, BDRVVHDXState *s,
             sector_write = merged_sector;
         } else if (i == sectors - 1 && trailing_length) {
             /* partial sector at the end of the buffer */
-            ret = bdrv_pread(bs->file, file_offset,
+            ret = bdrv_pread(bs->file, file_offset + trailing_length,
                              VHDX_LOG_SECTOR_SIZE - trailing_length,
                              merged_sector + trailing_length, 0);
             if (ret < 0) {
diff --git a/blockdev.c b/blockdev.c
index 3f1dec6242..ae27a41efa 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -152,12 +152,22 @@ void blockdev_mark_auto_del(BlockBackend *blk)
 
     JOB_LOCK_GUARD();
 
-    for (job = block_job_next_locked(NULL); job;
-         job = block_job_next_locked(job)) {
-        if (block_job_has_bdrv(job, blk_bs(blk))) {
+    do {
+        job = block_job_next_locked(NULL);
+        while (job && (job->job.cancelled ||
+                       job->job.deferred_to_main_loop ||
+                       !block_job_has_bdrv(job, blk_bs(blk))))
+        {
+            job = block_job_next_locked(job);
+        }
+        if (job) {
+            /*
+             * This drops the job lock temporarily and polls, so we need to
+             * restart processing the list from the start after this.
+             */
             job_cancel_locked(&job->job, false);
         }
-    }
+    } while (job);
 
     dinfo->auto_del = 1;
 }
diff --git a/chardev/char-socket.c b/chardev/char-socket.c
index 879564aa8a..b00efb1482 100644
--- a/chardev/char-socket.c
+++ b/chardev/char-socket.c
@@ -1065,6 +1065,7 @@ static void char_socket_finalize(Object *obj)
         qio_net_listener_set_client_func_full(s->listener, NULL, NULL,
                                               NULL, chr->gcontext);
         object_unref(OBJECT(s->listener));
+        s->listener = NULL;
     }
     if (s->tls_creds) {
         object_unref(OBJECT(s->tls_creds));
diff --git a/configure b/configure
index 08eac0d42c..3ecc35c217 100755
--- a/configure
+++ b/configure
@@ -2420,7 +2420,7 @@ echo "QEMU_OBJCFLAGS=$QEMU_OBJCFLAGS" >> $config_host_mak
 echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
 echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
 echo "GLIB_BINDIR=$glib_bindir" >> $config_host_mak
-echo "GLIB_VERSION=$(pkg-config --modversion glib-2.0)" >> $config_host_mak
+echo "GLIB_VERSION=$($pkg_config --modversion glib-2.0)" >> $config_host_mak
 echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
 echo "EXESUF=$EXESUF" >> $config_host_mak
 
diff --git a/docs/about/deprecated.rst b/docs/about/deprecated.rst
index 93affe3669..0b26c01da0 100644
--- a/docs/about/deprecated.rst
+++ b/docs/about/deprecated.rst
@@ -233,8 +233,8 @@ Use the more generic event ``DEVICE_UNPLUG_GUEST_ERROR`` instead.
 System emulator machines
 ------------------------
 
-Arm ``virt`` machine ``dtb-kaslr-seed`` property
-''''''''''''''''''''''''''''''''''''''''''''''''
+Arm ``virt`` machine ``dtb-kaslr-seed`` property (since 7.1)
+''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
 
 The ``dtb-kaslr-seed`` property on the ``virt`` board has been
 deprecated; use the new name ``dtb-randomness`` instead. The new name
diff --git a/docs/system/multi-process.rst b/docs/system/multi-process.rst
index 210531ee17..1b8852c27c 100644
--- a/docs/system/multi-process.rst
+++ b/docs/system/multi-process.rst
@@ -2,7 +2,7 @@ Multi-process QEMU
 ==================
 
 This document describes how to configure and use multi-process qemu.
-For the design document refer to docs/devel/qemu-multiprocess.
+For the design document refer to docs/devel/multi-process.rst.
 
 1) Configuration
 ----------------
diff --git a/fpu/softfloat.c b/fpu/softfloat.c
index c7454c3eb1..108f9cb224 100644
--- a/fpu/softfloat.c
+++ b/fpu/softfloat.c
@@ -5135,7 +5135,7 @@ float32 float32_exp2(float32 a, float_status *status)
     float64_unpack_canonical(&rp, float64_one, status);
     for (i = 0 ; i < 15 ; i++) {
         float64_unpack_canonical(&tp, float32_exp2_coefficients[i], status);
-        rp = *parts_muladd(&tp, &xp, &rp, 0, status);
+        rp = *parts_muladd(&tp, &xnp, &rp, 0, status);
         xnp = *parts_mul(&xnp, &xp, status);
     }
 
diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
index 5cafcd7703..d9511f429c 100644
--- a/fsdev/virtfs-proxy-helper.c
+++ b/fsdev/virtfs-proxy-helper.c
@@ -26,6 +26,7 @@
 #include "qemu/xattr.h"
 #include "9p-iov-marshal.h"
 #include "hw/9pfs/9p-proxy.h"
+#include "hw/9pfs/9p-util.h"
 #include "fsdev/9p-iov-marshal.h"
 
 #define PROGNAME "virtfs-proxy-helper"
@@ -338,6 +339,28 @@ static void resetugid(int suid, int sgid)
     }
 }
 
+/*
+ * Open regular file or directory. Attempts to open any special file are
+ * rejected.
+ *
+ * returns file descriptor or -1 on error
+ */
+static int open_regular(const char *pathname, int flags, mode_t mode)
+{
+    int fd;
+
+    fd = open(pathname, flags, mode);
+    if (fd < 0) {
+        return fd;
+    }
+
+    if (close_if_special_file(fd) < 0) {
+        return -1;
+    }
+
+    return fd;
+}
+
 /*
  * send response in two parts
  * 1) ProxyHeader
@@ -682,7 +705,7 @@ static int do_create(struct iovec *iovec)
     if (ret < 0) {
         goto unmarshal_err_out;
     }
-    ret = open(path.data, flags, mode);
+    ret = open_regular(path.data, flags, mode);
     if (ret < 0) {
         ret = -errno;
     }
@@ -707,7 +730,7 @@ static int do_open(struct iovec *iovec)
     if (ret < 0) {
         goto err_out;
     }
-    ret = open(path.data, flags);
+    ret = open_regular(path.data, flags, 0);
     if (ret < 0) {
         ret = -errno;
     }
diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h
index c3526144c9..6b44e5f7a4 100644
--- a/hw/9pfs/9p-util.h
+++ b/hw/9pfs/9p-util.h
@@ -13,6 +13,8 @@
 #ifndef QEMU_9P_UTIL_H
 #define QEMU_9P_UTIL_H
 
+#include "qemu/error-report.h"
+
 #ifdef O_PATH
 #define O_PATH_9P_UTIL O_PATH
 #else
@@ -112,6 +114,38 @@ static inline void close_preserve_errno(int fd)
     errno = serrno;
 }
 
+/**
+ * close_if_special_file() - Close @fd if neither regular file nor directory.
+ *
+ * @fd: file descriptor of open file
+ * Return: 0 on regular file or directory, -1 otherwise
+ *
+ * CVE-2023-2861: Prohibit opening any special file directly on host
+ * (especially device files), as a compromised client could potentially gain
+ * access outside exported tree under certain, unsafe setups. We expect
+ * client to handle I/O on special files exclusively on guest side.
+ */
+static inline int close_if_special_file(int fd)
+{
+    struct stat stbuf;
+
+    if (fstat(fd, &stbuf) < 0) {
+        close_preserve_errno(fd);
+        return -1;
+    }
+    if (!S_ISREG(stbuf.st_mode) && !S_ISDIR(stbuf.st_mode)) {
+        error_report_once(
+            "9p: broken or compromised client detected; attempt to open "
+            "special file (i.e. neither regular file, nor directory)"
+        );
+        close(fd);
+        errno = ENXIO;
+        return -1;
+    }
+
+    return 0;
+}
+
 static inline int openat_dir(int dirfd, const char *name)
 {
     return openat(dirfd, name,
@@ -146,6 +180,10 @@ again:
         return -1;
     }
 
+    if (close_if_special_file(fd) < 0) {
+        return -1;
+    }
+
     serrno = errno;
     /* O_NONBLOCK was only needed to open the file. Let's drop it. We don't
      * do that with O_PATH since fcntl(F_SETFL) isn't supported, and openat()
diff --git a/hw/9pfs/trace-events b/hw/9pfs/trace-events
index 6c77966c0b..a12e55c165 100644
--- a/hw/9pfs/trace-events
+++ b/hw/9pfs/trace-events
@@ -48,3 +48,9 @@ v9fs_readlink(uint16_t tag, uint8_t id, int32_t fid) "tag %d id %d fid %d"
 v9fs_readlink_return(uint16_t tag, uint8_t id, char* target) "tag %d id %d name %s"
 v9fs_setattr(uint16_t tag, uint8_t id, int32_t fid, int32_t valid, int32_t mode, int32_t uid, int32_t gid, int64_t size, int64_t atime_sec, int64_t mtime_sec) "tag %u id %u fid %d iattr={valid %d mode %d uid %d gid %d size %"PRId64" atime=%"PRId64" mtime=%"PRId64" }"
 v9fs_setattr_return(uint16_t tag, uint8_t id) "tag %u id %u"
+
+# xen-9p-backend.c
+xen_9pfs_alloc(char *name) "name %s"
+xen_9pfs_connect(char *name) "name %s"
+xen_9pfs_disconnect(char *name) "name %s"
+xen_9pfs_free(char *name) "name %s"
diff --git a/hw/9pfs/xen-9p-backend.c b/hw/9pfs/xen-9p-backend.c
index 65c4979c3c..ab1df8dd2f 100644
--- a/hw/9pfs/xen-9p-backend.c
+++ b/hw/9pfs/xen-9p-backend.c
@@ -24,6 +24,8 @@
 #include "qemu/option.h"
 #include "fsdev/qemu-fsdev.h"
 
+#include "trace.h"
+
 #define VERSIONS "1"
 #define MAX_RINGS 8
 #define MAX_RING_ORDER 9
@@ -335,6 +337,8 @@ static void xen_9pfs_disconnect(struct XenLegacyDevice *xendev)
     Xen9pfsDev *xen_9pdev = container_of(xendev, Xen9pfsDev, xendev);
     int i;
 
+    trace_xen_9pfs_disconnect(xendev->name);
+
     for (i = 0; i < xen_9pdev->num_rings; i++) {
         if (xen_9pdev->rings[i].evtchndev != NULL) {
             qemu_set_fd_handler(xenevtchn_fd(xen_9pdev->rings[i].evtchndev),
@@ -343,39 +347,40 @@ static void xen_9pfs_disconnect(struct XenLegacyDevice *xendev)
                              xen_9pdev->rings[i].local_port);
             xen_9pdev->rings[i].evtchndev = NULL;
         }
-    }
-}
-
-static int xen_9pfs_free(struct XenLegacyDevice *xendev)
-{
-    Xen9pfsDev *xen_9pdev = container_of(xendev, Xen9pfsDev, xendev);
-    int i;
-
-    if (xen_9pdev->rings[0].evtchndev != NULL) {
-        xen_9pfs_disconnect(xendev);
-    }
-
-    for (i = 0; i < xen_9pdev->num_rings; i++) {
         if (xen_9pdev->rings[i].data != NULL) {
             xen_be_unmap_grant_refs(&xen_9pdev->xendev,
                                     xen_9pdev->rings[i].data,
                                     (1 << xen_9pdev->rings[i].ring_order));
+            xen_9pdev->rings[i].data = NULL;
         }
         if (xen_9pdev->rings[i].intf != NULL) {
             xen_be_unmap_grant_refs(&xen_9pdev->xendev,
                                     xen_9pdev->rings[i].intf,
                                     1);
+            xen_9pdev->rings[i].intf = NULL;
         }
         if (xen_9pdev->rings[i].bh != NULL) {
             qemu_bh_delete(xen_9pdev->rings[i].bh);
+            xen_9pdev->rings[i].bh = NULL;
         }
     }
 
     g_free(xen_9pdev->id);
+    xen_9pdev->id = NULL;
     g_free(xen_9pdev->tag);
+    xen_9pdev->tag = NULL;
     g_free(xen_9pdev->path);
+    xen_9pdev->path = NULL;
     g_free(xen_9pdev->security_model);
+    xen_9pdev->security_model = NULL;
     g_free(xen_9pdev->rings);
+    xen_9pdev->rings = NULL;
+}
+
+static int xen_9pfs_free(struct XenLegacyDevice *xendev)
+{
+    trace_xen_9pfs_free(xendev->name);
+
     return 0;
 }
 
@@ -387,6 +392,8 @@ static int xen_9pfs_connect(struct XenLegacyDevice *xendev)
     V9fsState *s = &xen_9pdev->state;
     QemuOpts *fsdev;
 
+    trace_xen_9pfs_connect(xendev->name);
+
     if (xenstore_read_fe_int(&xen_9pdev->xendev, "num-rings",
                              &xen_9pdev->num_rings) == -1 ||
         xen_9pdev->num_rings > MAX_RINGS || xen_9pdev->num_rings < 1) {
@@ -494,6 +501,8 @@ out:
 
 static void xen_9pfs_alloc(struct XenLegacyDevice *xendev)
 {
+    trace_xen_9pfs_alloc(xendev->name);
+
     xenstore_write_be_str(xendev, "versions", VERSIONS);
     xenstore_write_be_int(xendev, "max-rings", MAX_RINGS);
     xenstore_write_be_int(xendev, "max-ring-page-order", MAX_RING_ORDER);
diff --git a/hw/acpi/cpu_hotplug.c b/hw/acpi/cpu_hotplug.c
index 53654f8638..ff14c3f410 100644
--- a/hw/acpi/cpu_hotplug.c
+++ b/hw/acpi/cpu_hotplug.c
@@ -52,6 +52,9 @@ static const MemoryRegionOps AcpiCpuHotplug_ops = {
     .endianness = DEVICE_LITTLE_ENDIAN,
     .valid = {
         .min_access_size = 1,
+        .max_access_size = 4,
+    },
+    .impl = {
         .max_access_size = 1,
     },
 };
diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c
index 84d75e6b84..a2a3738b46 100644
--- a/hw/acpi/pcihp.c
+++ b/hw/acpi/pcihp.c
@@ -429,6 +429,16 @@ void acpi_pcihp_device_unplug_request_cb(HotplugHandler *hotplug_dev,
      * acpi_pcihp_eject_slot() when the operation is completed.
      */
     pdev->qdev.pending_deleted_event = true;
+    /* if unplug was requested before OSPM is initialized,
+     * linux kernel will clear GPE0.sts[] bits during boot, which effectively
+     * hides unplug event. And than followup qmp_device_del() calls remain
+     * blocked by above flag permanently.
+     * Unblock qmp_device_del() by setting expire limit, so user can
+     * repeat unplug request later when OSPM has been booted.
+     */
+    pdev->qdev.pending_deleted_expires_ms =
+        qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL); /* 1 msec */
+
     s->acpi_pcihp_pci_status[bsel].down |= (1U << slot);
     acpi_send_event(DEVICE(hotplug_dev), ACPI_PCI_HOTPLUG_STATUS);
 }
diff --git a/hw/arm/aspeed.c b/hw/arm/aspeed.c
index 55f114ef72..97fb1916ec 100644
--- a/hw/arm/aspeed.c
+++ b/hw/arm/aspeed.c
@@ -188,33 +188,35 @@ struct AspeedMachineState {
 static void aspeed_write_smpboot(ARMCPU *cpu,
                                  const struct arm_boot_info *info)
 {
-    static const uint32_t poll_mailbox_ready[] = {
+    AddressSpace *as = arm_boot_address_space(cpu, info);
+    static const ARMInsnFixup poll_mailbox_ready[] = {
         /*
          * r2 = per-cpu go sign value
          * r1 = AST_SMP_MBOX_FIELD_ENTRY
          * r0 = AST_SMP_MBOX_FIELD_GOSIGN
          */
-        0xee100fb0,  /* mrc     p15, 0, r0, c0, c0, 5 */
-        0xe21000ff,  /* ands    r0, r0, #255          */
-        0xe59f201c,  /* ldr     r2, [pc, #28]         */
-        0xe1822000,  /* orr     r2, r2, r0            */
-
-        0xe59f1018,  /* ldr     r1, [pc, #24]         */
-        0xe59f0018,  /* ldr     r0, [pc, #24]         */
-
-        0xe320f002,  /* wfe                           */
-        0xe5904000,  /* ldr     r4, [r0]              */
-        0xe1520004,  /* cmp     r2, r4                */
-        0x1afffffb,  /* bne     <wfe>                 */
-        0xe591f000,  /* ldr     pc, [r1]              */
-        AST_SMP_MBOX_GOSIGN,
-        AST_SMP_MBOX_FIELD_ENTRY,
-        AST_SMP_MBOX_FIELD_GOSIGN,
+        { 0xee100fb0 },  /* mrc     p15, 0, r0, c0, c0, 5 */
+        { 0xe21000ff },  /* ands    r0, r0, #255          */
+        { 0xe59f201c },  /* ldr     r2, [pc, #28]         */
+        { 0xe1822000 },  /* orr     r2, r2, r0            */
+
+        { 0xe59f1018 },  /* ldr     r1, [pc, #24]         */
+        { 0xe59f0018 },  /* ldr     r0, [pc, #24]         */
+
+        { 0xe320f002 },  /* wfe                           */
+        { 0xe5904000 },  /* ldr     r4, [r0]              */
+        { 0xe1520004 },  /* cmp     r2, r4                */
+        { 0x1afffffb },  /* bne     <wfe>                 */
+        { 0xe591f000 },  /* ldr     pc, [r1]              */
+        { AST_SMP_MBOX_GOSIGN },
+        { AST_SMP_MBOX_FIELD_ENTRY },
+        { AST_SMP_MBOX_FIELD_GOSIGN },
+        { 0, FIXUP_TERMINATOR }
     };
+    static const uint32_t fixupcontext[FIXUP_MAX] = { 0 };
 
-    rom_add_blob_fixed("aspeed.smpboot", poll_mailbox_ready,
-                       sizeof(poll_mailbox_ready),
-                       info->smp_loader_start);
+    arm_write_bootloader("aspeed.smpboot", as, info->smp_loader_start,
+                         poll_mailbox_ready, fixupcontext);
 }
 
 static void aspeed_reset_secondary(ARMCPU *cpu,
diff --git a/hw/arm/boot.c b/hw/arm/boot.c
index 15c2bf1867..8ff315f431 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -59,26 +59,6 @@ AddressSpace *arm_boot_address_space(ARMCPU *cpu,
     return cpu_get_address_space(cs, asidx);
 }
 
-typedef enum {
-    FIXUP_NONE = 0,     /* do nothing */
-    FIXUP_TERMINATOR,   /* end of insns */
-    FIXUP_BOARDID,      /* overwrite with board ID number */
-    FIXUP_BOARD_SETUP,  /* overwrite with board specific setup code address */
-    FIXUP_ARGPTR_LO,    /* overwrite with pointer to kernel args */
-    FIXUP_ARGPTR_HI,    /* overwrite with pointer to kernel args (high half) */
-    FIXUP_ENTRYPOINT_LO, /* overwrite with kernel entry point */
-    FIXUP_ENTRYPOINT_HI, /* overwrite with kernel entry point (high half) */
-    FIXUP_GIC_CPU_IF,   /* overwrite with GIC CPU interface address */
-    FIXUP_BOOTREG,      /* overwrite with boot register address */
-    FIXUP_DSB,          /* overwrite with correct DSB insn for cpu */
-    FIXUP_MAX,
-} FixupType;
-
-typedef struct ARMInsnFixup {
-    uint32_t insn;
-    FixupType fixup;
-} ARMInsnFixup;
-
 static const ARMInsnFixup bootloader_aarch64[] = {
     { 0x580000c0 }, /* ldr x0, arg ; Load the lower 32-bits of DTB */
     { 0xaa1f03e1 }, /* mov x1, xzr */
@@ -149,9 +129,10 @@ static const ARMInsnFixup smpboot[] = {
     { 0, FIXUP_TERMINATOR }
 };
 
-static void write_bootloader(const char *name, hwaddr addr,
-                             const ARMInsnFixup *insns, uint32_t *fixupcontext,
-                             AddressSpace *as)
+void arm_write_bootloader(const char *name,
+                          AddressSpace *as, hwaddr addr,
+                          const ARMInsnFixup *insns,
+                          const uint32_t *fixupcontext)
 {
     /* Fix up the specified bootloader fragment and write it into
      * guest memory using rom_add_blob_fixed(). fixupcontext is
@@ -213,8 +194,8 @@ static void default_write_secondary(ARMCPU *cpu,
         fixupcontext[FIXUP_DSB] = CP15_DSB_INSN;
     }
 
-    write_bootloader("smpboot", info->smp_loader_start,
-                     smpboot, fixupcontext, as);
+    arm_write_bootloader("smpboot", as, info->smp_loader_start,
+                         smpboot, fixupcontext);
 }
 
 void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,
@@ -686,7 +667,10 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo,
     qemu_register_reset_nosnapshotload(qemu_fdt_randomize_seeds,
                                        rom_ptr_for_as(as, addr, size));
 
-    g_free(fdt);
+    if (fdt != ms->fdt) {
+        g_free(ms->fdt);
+        ms->fdt = fdt;
+    }
 
     return size;
 
@@ -1171,8 +1155,8 @@ static void arm_setup_direct_kernel_boot(ARMCPU *cpu,
         fixupcontext[FIXUP_ENTRYPOINT_LO] = entry;
         fixupcontext[FIXUP_ENTRYPOINT_HI] = entry >> 32;
 
-        write_bootloader("bootloader", info->loader_start,
-                         primary_loader, fixupcontext, as);
+        arm_write_bootloader("bootloader", as, info->loader_start,
+                             primary_loader, fixupcontext);
 
         if (info->write_board_setup) {
             info->write_board_setup(cpu, info);
diff --git a/hw/arm/raspi.c b/hw/arm/raspi.c
index 92d068d1f9..a7d287b1a8 100644
--- a/hw/arm/raspi.c
+++ b/hw/arm/raspi.c
@@ -16,6 +16,7 @@
 #include "qemu/units.h"
 #include "qemu/cutils.h"
 #include "qapi/error.h"
+#include "hw/arm/boot.h"
 #include "hw/arm/bcm2836.h"
 #include "hw/registerfields.h"
 #include "qemu/error-report.h"
@@ -124,20 +125,22 @@ static const char *board_type(uint32_t board_rev)
 
 static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
 {
-    static const uint32_t smpboot[] = {
-        0xe1a0e00f, /*    mov     lr, pc */
-        0xe3a0fe00 + (BOARDSETUP_ADDR >> 4), /* mov pc, BOARDSETUP_ADDR */
-        0xee100fb0, /*    mrc     p15, 0, r0, c0, c0, 5;get core ID */
-        0xe7e10050, /*    ubfx    r0, r0, #0, #2       ;extract LSB */
-        0xe59f5014, /*    ldr     r5, =0x400000CC      ;load mbox base */
-        0xe320f001, /* 1: yield */
-        0xe7953200, /*    ldr     r3, [r5, r0, lsl #4] ;read mbox for our core*/
-        0xe3530000, /*    cmp     r3, #0               ;spin while zero */
-        0x0afffffb, /*    beq     1b */
-        0xe7853200, /*    str     r3, [r5, r0, lsl #4] ;clear mbox */
-        0xe12fff13, /*    bx      r3                   ;jump to target */
-        0x400000cc, /* (constant: mailbox 3 read/clear base) */
+    static const ARMInsnFixup smpboot[] = {
+        { 0xe1a0e00f }, /*    mov     lr, pc */
+        { 0xe3a0fe00 + (BOARDSETUP_ADDR >> 4) }, /* mov pc, BOARDSETUP_ADDR */
+        { 0xee100fb0 }, /*    mrc     p15, 0, r0, c0, c0, 5;get core ID */
+        { 0xe7e10050 }, /*    ubfx    r0, r0, #0, #2       ;extract LSB */
+        { 0xe59f5014 }, /*    ldr     r5, =0x400000CC      ;load mbox base */
+        { 0xe320f001 }, /* 1: yield */
+        { 0xe7953200 }, /*    ldr     r3, [r5, r0, lsl #4] ;read mbox for our core */
+        { 0xe3530000 }, /*    cmp     r3, #0               ;spin while zero */
+        { 0x0afffffb }, /*    beq     1b */
+        { 0xe7853200 }, /*    str     r3, [r5, r0, lsl #4] ;clear mbox */
+        { 0xe12fff13 }, /*    bx      r3                   ;jump to target */
+        { 0x400000cc }, /* (constant: mailbox 3 read/clear base) */
+        { 0, FIXUP_TERMINATOR }
     };
+    static const uint32_t fixupcontext[FIXUP_MAX] = { 0 };
 
     /* check that we don't overrun board setup vectors */
     QEMU_BUILD_BUG_ON(SMPBOOT_ADDR + sizeof(smpboot) > MVBAR_ADDR);
@@ -145,9 +148,8 @@ static void write_smpboot(ARMCPU *cpu, const struct arm_boot_info *info)
     QEMU_BUILD_BUG_ON((BOARDSETUP_ADDR & 0xf) != 0
                       || (BOARDSETUP_ADDR >> 4) >= 0x100);
 
-    rom_add_blob_fixed_as("raspi_smpboot", smpboot, sizeof(smpboot),
-                          info->smp_loader_start,
-                          arm_boot_address_space(cpu, info));
+    arm_write_bootloader("raspi_smpboot", arm_boot_address_space(cpu, info),
+                         info->smp_loader_start, smpboot, fixupcontext);
 }
 
 static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info)
@@ -161,26 +163,28 @@ static void write_smpboot64(ARMCPU *cpu, const struct arm_boot_info *info)
      * the primary CPU goes into the kernel. We put these variables inside
      * a rom blob, so that the reset for ROM contents zeroes them for us.
      */
-    static const uint32_t smpboot[] = {
-        0xd2801b05, /*        mov     x5, 0xd8 */
-        0xd53800a6, /*        mrs     x6, mpidr_el1 */
-        0x924004c6, /*        and     x6, x6, #0x3 */
-        0xd503205f, /* spin:  wfe */
-        0xf86678a4, /*        ldr     x4, [x5,x6,lsl #3] */
-        0xb4ffffc4, /*        cbz     x4, spin */
-        0xd2800000, /*        mov     x0, #0x0 */
-        0xd2800001, /*        mov     x1, #0x0 */
-        0xd2800002, /*        mov     x2, #0x0 */
-        0xd2800003, /*        mov     x3, #0x0 */
-        0xd61f0080, /*        br      x4 */
+    static const ARMInsnFixup smpboot[] = {
+        { 0xd2801b05 }, /*        mov     x5, 0xd8 */
+        { 0xd53800a6 }, /*        mrs     x6, mpidr_el1 */
+        { 0x924004c6 }, /*        and     x6, x6, #0x3 */
+        { 0xd503205f }, /* spin:  wfe */
+        { 0xf86678a4 }, /*        ldr     x4, [x5,x6,lsl #3] */
+        { 0xb4ffffc4 }, /*        cbz     x4, spin */
+        { 0xd2800000 }, /*        mov     x0, #0x0 */
+        { 0xd2800001 }, /*        mov     x1, #0x0 */
+        { 0xd2800002 }, /*        mov     x2, #0x0 */
+        { 0xd2800003 }, /*        mov     x3, #0x0 */
+        { 0xd61f0080 }, /*        br      x4 */
+        { 0, FIXUP_TERMINATOR }
     };
+    static const uint32_t fixupcontext[FIXUP_MAX] = { 0 };
 
     static const uint64_t spintables[] = {
         0, 0, 0, 0
     };
 
-    rom_add_blob_fixed_as("raspi_smpboot", smpboot, sizeof(smpboot),
-                          info->smp_loader_start, as);
+    arm_write_bootloader("raspi_smpboot", as, info->smp_loader_start,
+                         smpboot, fixupcontext);
     rom_add_blob_fixed_as("raspi_spintables", spintables, sizeof(spintables),
                           SPINTABLE_ADDR, as);
 }
diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c
index 335cfc417d..5905a33015 100644
--- a/hw/arm/xlnx-zynqmp.c
+++ b/hw/arm/xlnx-zynqmp.c
@@ -213,7 +213,7 @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, XlnxZynqMPState *s,
                                    const char *boot_cpu, Error **errp)
 {
     int i;
-    int num_rpus = MIN(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS,
+    int num_rpus = MIN((int)(ms->smp.cpus - XLNX_ZYNQMP_NUM_APU_CPUS),
                        XLNX_ZYNQMP_NUM_RPU_CPUS);
 
     if (num_rpus <= 0) {
diff --git a/hw/core/machine.c b/hw/core/machine.c
index 8d34caa31d..19f42450f5 100644
--- a/hw/core/machine.c
+++ b/hw/core/machine.c
@@ -42,6 +42,9 @@
 
 GlobalProperty hw_compat_7_1[] = {
     { "virtio-device", "queue_reset", "false" },
+    { "virtio-rng-pci", "vectors", "0" },
+    { "virtio-rng-pci-transitional", "vectors", "0" },
+    { "virtio-rng-pci-non-transitional", "vectors", "0" },
 };
 const size_t hw_compat_7_1_len = G_N_ELEMENTS(hw_compat_7_1);
 
@@ -1326,6 +1329,14 @@ void machine_run_board_init(MachineState *machine, const char *mem_path, Error *
         }
     } else if (machine_class->default_ram_id && machine->ram_size &&
                numa_uses_legacy_mem()) {
+        if (object_property_find(object_get_objects_root(),
+                                 machine_class->default_ram_id)) {
+            error_setg(errp, "object name '%s' is reserved for the default"
+                " RAM backend, it can't be used for any other purposes."
+                " Change the object's 'id' to something else",
+                machine_class->default_ram_id);
+            return;
+        }
         if (!create_default_memdev(current_machine, mem_path, errp)) {
             return;
         }
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 5e15c79b94..4e2e0dd53a 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -498,6 +498,8 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,
     struct virtio_gpu_resource_flush rf;
     struct virtio_gpu_scanout *scanout;
     pixman_region16_t flush_region;
+    bool within_bounds = false;
+    bool update_submitted = false;
     int i;
 
     VIRTIO_GPU_FILL_CMD(rf);
@@ -518,13 +520,28 @@ static void virtio_gpu_resource_flush(VirtIOGPU *g,
                 rf.r.x < scanout->x + scanout->width &&
                 rf.r.x + rf.r.width >= scanout->x &&
                 rf.r.y < scanout->y + scanout->height &&
-                rf.r.y + rf.r.height >= scanout->y &&
-                console_has_gl(scanout->con)) {
-                dpy_gl_update(scanout->con, 0, 0, scanout->width,
-                              scanout->height);
+                rf.r.y + rf.r.height >= scanout->y) {
+                within_bounds = true;
+
+                if (console_has_gl(scanout->con)) {
+                    dpy_gl_update(scanout->con, 0, 0, scanout->width,
+                                  scanout->height);
+                    update_submitted = true;
+                }
             }
         }
-        return;
+
+        if (update_submitted) {
+            return;
+        }
+        if (!within_bounds) {
+            qemu_log_mask(LOG_GUEST_ERROR, "%s: flush bounds outside scanouts"
+                          " bounds for flush %d: %d %d %d %d\n",
+                          __func__, rf.resource_id, rf.r.x, rf.r.y,
+                          rf.r.width, rf.r.height);
+            cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
+            return;
+        }
     }
 
     if (!res->blob &&
diff --git a/hw/dma/xilinx_axidma.c b/hw/dma/xilinx_axidma.c
index cbb8f0f169..99e50f65e2 100644
--- a/hw/dma/xilinx_axidma.c
+++ b/hw/dma/xilinx_axidma.c
@@ -168,6 +168,11 @@ static inline int stream_idle(struct Stream *s)
     return !!(s->regs[R_DMASR] & DMASR_IDLE);
 }
 
+static inline int stream_halted(struct Stream *s)
+{
+    return !!(s->regs[R_DMASR] & DMASR_HALTED);
+}
+
 static void stream_reset(struct Stream *s)
 {
     s->regs[R_DMASR] = DMASR_HALTED;  /* starts up halted.  */
@@ -269,7 +274,7 @@ static void stream_process_mem2s(struct Stream *s, StreamSink *tx_data_dev,
     uint64_t addr;
     bool eop;
 
-    if (!stream_running(s) || stream_idle(s)) {
+    if (!stream_running(s) || stream_idle(s) || stream_halted(s)) {
         return;
     }
 
@@ -326,7 +331,7 @@ static size_t stream_process_s2mem(struct Stream *s, unsigned char *buf,
     unsigned int rxlen;
     size_t pos = 0;
 
-    if (!stream_running(s) || stream_idle(s)) {
+    if (!stream_running(s) || stream_idle(s) || stream_halted(s)) {
         return 0;
     }
 
@@ -407,7 +412,7 @@ xilinx_axidma_data_stream_can_push(StreamSink *obj,
     XilinxAXIDMAStreamSink *ds = XILINX_AXI_DMA_DATA_STREAM(obj);
     struct Stream *s = &ds->dma->streams[1];
 
-    if (!stream_running(s) || stream_idle(s)) {
+    if (!stream_running(s) || stream_idle(s) || stream_halted(s)) {
         ds->dma->notify = notify;
         ds->dma->notify_opaque = notify_opaque;
         return false;
diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c
index de1cc7ab71..98a78b84b4 100644
--- a/hw/hppa/machine.c
+++ b/hw/hppa/machine.c
@@ -123,6 +123,7 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
 {
     FWCfgState *fw_cfg;
     uint64_t val;
+    const char qemu_version[] = QEMU_VERSION;
 
     fw_cfg = fw_cfg_init_mem(FW_CFG_IO_BASE, FW_CFG_IO_BASE + 4);
     fw_cfg_add_i16(fw_cfg, FW_CFG_NB_CPUS, ms->smp.cpus);
@@ -148,6 +149,10 @@ static FWCfgState *create_fw_cfg(MachineState *ms)
     fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, ms->boot_config.order[0]);
     qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
 
+    fw_cfg_add_file(fw_cfg, "/etc/qemu-version",
+                    g_memdup(qemu_version, sizeof(qemu_version)),
+                    sizeof(qemu_version));
+
     return fw_cfg;
 }
 
@@ -418,10 +423,16 @@ static void hppa_machine_reset(MachineState *ms, ShutdownCause reason)
 
     /* Start all CPUs at the firmware entry point.
      *  Monarch CPU will initialize firmware, secondary CPUs
-     *  will enter a small idle look and wait for rendevouz. */
+     *  will enter a small idle loop and wait for rendevouz. */
     for (i = 0; i < smp_cpus; i++) {
-        cpu_set_pc(CPU(cpu[i]), firmware_entry);
+        CPUState *cs = CPU(cpu[i]);
+
+        cpu_set_pc(cs, firmware_entry);
+        cpu[i]->env.psw = PSW_Q;
         cpu[i]->env.gr[5] = CPU_HPA + i * 0x1000;
+
+        cs->exception_index = -1;
+        cs->halted = 0;
     }
 
     /* already initialized by machine_hppa_init()? */
diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c
index a08ee85edf..d025ef2873 100644
--- a/hw/i386/intel_iommu.c
+++ b/hw/i386/intel_iommu.c
@@ -3179,6 +3179,7 @@ static int vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
 {
     VTDAddressSpace *vtd_as = container_of(iommu, VTDAddressSpace, iommu);
     IntelIOMMUState *s = vtd_as->iommu_state;
+    X86IOMMUState *x86_iommu = X86_IOMMU_DEVICE(s);
 
     /* TODO: add support for VFIO and vhost users */
     if (s->snoop_control) {
@@ -3186,6 +3187,20 @@ static int vtd_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu,
                          "Snoop Control with vhost or VFIO is not supported");
         return -ENOTSUP;
     }
+    if (!s->caching_mode && (new & IOMMU_NOTIFIER_MAP)) {
+        error_setg_errno(errp, ENOTSUP,
+                         "device %02x.%02x.%x requires caching mode",
+                         pci_bus_num(vtd_as->bus), PCI_SLOT(vtd_as->devfn),
+                         PCI_FUNC(vtd_as->devfn));
+        return -ENOTSUP;
+    }
+    if (!x86_iommu->dt_supported && (new & IOMMU_NOTIFIER_DEVIOTLB_UNMAP)) {
+        error_setg_errno(errp, ENOTSUP,
+                         "device %02x.%02x.%x requires device IOTLB mode",
+                         pci_bus_num(vtd_as->bus), PCI_SLOT(vtd_as->devfn),
+                         PCI_FUNC(vtd_as->devfn));
+        return -ENOTSUP;
+    }
 
     /* Update per-address-space notifier flags */
     vtd_as->notifier_flags = new;
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index 170a331e3f..b231ceda9a 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -330,7 +330,7 @@ static void microvm_memory_init(MicrovmMachineState *mms)
     rom_set_fw(fw_cfg);
 
     if (machine->kernel_filename != NULL) {
-        x86_load_linux(x86ms, fw_cfg, 0, true, false);
+        x86_load_linux(x86ms, fw_cfg, 0, true);
     }
 
     if (mms->option_roms) {
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 546b703cb4..ec5a10534b 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -799,7 +799,7 @@ void xen_load_linux(PCMachineState *pcms)
     rom_set_fw(fw_cfg);
 
     x86_load_linux(x86ms, fw_cfg, pcmc->acpi_data_size,
-                   pcmc->pvh_enabled, pcmc->legacy_no_rng_seed);
+                   pcmc->pvh_enabled);
     for (i = 0; i < nb_option_roms; i++) {
         assert(!strcmp(option_rom[i].name, "linuxboot.bin") ||
                !strcmp(option_rom[i].name, "linuxboot_dma.bin") ||
@@ -1119,7 +1119,7 @@ void pc_memory_init(PCMachineState *pcms,
 
     if (linux_boot) {
         x86_load_linux(x86ms, fw_cfg, pcmc->acpi_data_size,
-                       pcmc->pvh_enabled, pcmc->legacy_no_rng_seed);
+                       pcmc->pvh_enabled);
     }
 
     for (i = 0; i < nb_option_roms; i++) {
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index 0ad0ed1603..04f793cca1 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -405,6 +405,7 @@ static void pc_xen_hvm_init(MachineState *machine)
     }
 
     pc_xen_hvm_init_pci(machine);
+    xen_igd_reserve_slot(pcms->bus);
     pci_create_simple(pcms->bus, -1, "xen-platform");
 }
 #endif
@@ -449,11 +450,9 @@ DEFINE_I440FX_MACHINE(v7_2, "pc-i440fx-7.2", NULL,
 
 static void pc_i440fx_7_1_machine_options(MachineClass *m)
 {
-    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_i440fx_7_2_machine_options(m);
     m->alias = NULL;
     m->is_default = false;
-    pcmc->legacy_no_rng_seed = true;
     compat_props_add(m->compat_props, hw_compat_7_1, hw_compat_7_1_len);
     compat_props_add(m->compat_props, pc_compat_7_1, pc_compat_7_1_len);
 }
diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c
index a496bd6e74..f522874add 100644
--- a/hw/i386/pc_q35.c
+++ b/hw/i386/pc_q35.c
@@ -383,10 +383,8 @@ DEFINE_Q35_MACHINE(v7_2, "pc-q35-7.2", NULL,
 
 static void pc_q35_7_1_machine_options(MachineClass *m)
 {
-    PCMachineClass *pcmc = PC_MACHINE_CLASS(m);
     pc_q35_7_2_machine_options(m);
     m->alias = NULL;
-    pcmc->legacy_no_rng_seed = true;
     compat_props_add(m->compat_props, hw_compat_7_1, hw_compat_7_1_len);
     compat_props_add(m->compat_props, pc_compat_7_1, pc_compat_7_1_len);
 }
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index 78cc131926..80be3032cc 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -26,7 +26,6 @@
 #include "qemu/cutils.h"
 #include "qemu/units.h"
 #include "qemu/datadir.h"
-#include "qemu/guest-random.h"
 #include "qapi/error.h"
 #include "qapi/qmp/qerror.h"
 #include "qapi/qapi-visit-common.h"
@@ -37,7 +36,6 @@
 #include "sysemu/whpx.h"
 #include "sysemu/numa.h"
 #include "sysemu/replay.h"
-#include "sysemu/reset.h"
 #include "sysemu/sysemu.h"
 #include "sysemu/cpu-timers.h"
 #include "sysemu/xen.h"
@@ -657,12 +655,12 @@ DeviceState *ioapic_init_secondary(GSIState *gsi_state)
     return dev;
 }
 
-typedef struct SetupData {
+struct setup_data {
     uint64_t next;
     uint32_t type;
     uint32_t len;
     uint8_t data[];
-} __attribute__((packed)) SetupData;
+} __attribute__((packed));
 
 
 /*
@@ -769,35 +767,10 @@ static bool load_elfboot(const char *kernel_filename,
     return true;
 }
 
-typedef struct SetupDataFixup {
-    void *pos;
-    hwaddr orig_val, new_val;
-    uint32_t addr;
-} SetupDataFixup;
-
-static void fixup_setup_data(void *opaque)
-{
-    SetupDataFixup *fixup = opaque;
-    stq_p(fixup->pos, fixup->new_val);
-}
-
-static void reset_setup_data(void *opaque)
-{
-    SetupDataFixup *fixup = opaque;
-    stq_p(fixup->pos, fixup->orig_val);
-}
-
-static void reset_rng_seed(void *opaque)
-{
-    SetupData *setup_data = opaque;
-    qemu_guest_getrandom_nofail(setup_data->data, le32_to_cpu(setup_data->len));
-}
-
 void x86_load_linux(X86MachineState *x86ms,
                     FWCfgState *fw_cfg,
                     int acpi_data_size,
-                    bool pvh_enabled,
-                    bool legacy_no_rng_seed)
+                    bool pvh_enabled)
 {
     bool linuxboot_dma_enabled = X86_MACHINE_GET_CLASS(x86ms)->fwcfg_dma_enabled;
     uint16_t protocol;
@@ -805,17 +778,16 @@ void x86_load_linux(X86MachineState *x86ms,
     int dtb_size, setup_data_offset;
     uint32_t initrd_max;
     uint8_t header[8192], *setup, *kernel;
-    hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0, first_setup_data = 0;
+    hwaddr real_addr, prot_addr, cmdline_addr, initrd_addr = 0;
     FILE *f;
     char *vmode;
     MachineState *machine = MACHINE(x86ms);
-    SetupData *setup_data;
+    struct setup_data *setup_data;
     const char *kernel_filename = machine->kernel_filename;
     const char *initrd_filename = machine->initrd_filename;
     const char *dtb_filename = machine->dtb;
     const char *kernel_cmdline = machine->kernel_cmdline;
     SevKernelLoaderContext sev_load_ctx = {};
-    enum { RNG_SEED_LENGTH = 32 };
 
     /* Align to 16 bytes as a paranoia measure */
     cmdline_size = (strlen(kernel_cmdline) + 16) & ~15;
@@ -1092,41 +1064,19 @@ void x86_load_linux(X86MachineState *x86ms,
         }
 
         setup_data_offset = QEMU_ALIGN_UP(kernel_size, 16);
-        kernel_size = setup_data_offset + sizeof(SetupData) + dtb_size;
+        kernel_size = setup_data_offset + sizeof(struct setup_data) + dtb_size;
         kernel = g_realloc(kernel, kernel_size);
 
+        stq_p(header + 0x250, prot_addr + setup_data_offset);
 
-        setup_data = (SetupData *)(kernel + setup_data_offset);
-        setup_data->next = cpu_to_le64(first_setup_data);
-        first_setup_data = prot_addr + setup_data_offset;
+        setup_data = (struct setup_data *)(kernel + setup_data_offset);
+        setup_data->next = 0;
         setup_data->type = cpu_to_le32(SETUP_DTB);
         setup_data->len = cpu_to_le32(dtb_size);
 
         load_image_size(dtb_filename, setup_data->data, dtb_size);
     }
 
-    if (!legacy_no_rng_seed) {
-        setup_data_offset = QEMU_ALIGN_UP(kernel_size, 16);
-        kernel_size = setup_data_offset + sizeof(SetupData) + RNG_SEED_LENGTH;
-        kernel = g_realloc(kernel, kernel_size);
-        setup_data = (SetupData *)(kernel + setup_data_offset);
-        setup_data->next = cpu_to_le64(first_setup_data);
-        first_setup_data = prot_addr + setup_data_offset;
-        setup_data->type = cpu_to_le32(SETUP_RNG_SEED);
-        setup_data->len = cpu_to_le32(RNG_SEED_LENGTH);
-        qemu_guest_getrandom_nofail(setup_data->data, RNG_SEED_LENGTH);
-        qemu_register_reset_nosnapshotload(reset_rng_seed, setup_data);
-        fw_cfg_add_bytes_callback(fw_cfg, FW_CFG_KERNEL_DATA, reset_rng_seed, NULL,
-                                  setup_data, kernel, kernel_size, true);
-    } else {
-        fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
-    }
-
-    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr);
-    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
-    sev_load_ctx.kernel_data = (char *)kernel;
-    sev_load_ctx.kernel_size = kernel_size;
-
     /*
      * If we're starting an encrypted VM, it will be OVMF based, which uses the
      * efi stub for booting and doesn't require any values to be placed in the
@@ -1135,20 +1085,16 @@ void x86_load_linux(X86MachineState *x86ms,
      * file the user passed in.
      */
     if (!sev_enabled()) {
-        SetupDataFixup *fixup = g_malloc(sizeof(*fixup));
-
         memcpy(setup, header, MIN(sizeof(header), setup_size));
-        /* Offset 0x250 is a pointer to the first setup_data link. */
-        fixup->pos = setup + 0x250;
-        fixup->orig_val = ldq_p(fixup->pos);
-        fixup->new_val = first_setup_data;
-        fixup->addr = cpu_to_le32(real_addr);
-        fw_cfg_add_bytes_callback(fw_cfg, FW_CFG_SETUP_ADDR, fixup_setup_data, NULL,
-                                  fixup, &fixup->addr, sizeof(fixup->addr), true);
-        qemu_register_reset(reset_setup_data, fixup);
-    } else {
-        fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr);
     }
+
+    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, prot_addr);
+    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
+    fw_cfg_add_bytes(fw_cfg, FW_CFG_KERNEL_DATA, kernel, kernel_size);
+    sev_load_ctx.kernel_data = (char *)kernel;
+    sev_load_ctx.kernel_size = kernel_size;
+
+    fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_ADDR, real_addr);
     fw_cfg_add_i32(fw_cfg, FW_CFG_SETUP_SIZE, setup_size);
     fw_cfg_add_bytes(fw_cfg, FW_CFG_SETUP_DATA, setup, setup_size);
     sev_load_ctx.setup_data = (char *)setup;
diff --git a/hw/intc/allwinner-a10-pic.c b/hw/intc/allwinner-a10-pic.c
index 8cca124807..d0bf8d545b 100644
--- a/hw/intc/allwinner-a10-pic.c
+++ b/hw/intc/allwinner-a10-pic.c
@@ -49,12 +49,9 @@ static void aw_a10_pic_update(AwA10PICState *s)
 static void aw_a10_pic_set_irq(void *opaque, int irq, int level)
 {
     AwA10PICState *s = opaque;
+    uint32_t *pending_reg = &s->irq_pending[irq / 32];
 
-    if (level) {
-        set_bit(irq % 32, (void *)&s->irq_pending[irq / 32]);
-    } else {
-        clear_bit(irq % 32, (void *)&s->irq_pending[irq / 32]);
-    }
+    *pending_reg = deposit32(*pending_reg, irq % 32, 1, !!level);
     aw_a10_pic_update(s);
 }
 
diff --git a/hw/misc/aspeed_hace.c b/hw/misc/aspeed_hace.c
index ac21be306c..69175e972d 100644
--- a/hw/misc/aspeed_hace.c
+++ b/hw/misc/aspeed_hace.c
@@ -189,7 +189,7 @@ static void do_hash_operation(AspeedHACEState *s, int algo, bool sg_mode,
                               bool acc_mode)
 {
     struct iovec iov[ASPEED_HACE_MAX_SG];
-    g_autofree uint8_t *digest_buf;
+    g_autofree uint8_t *digest_buf = NULL;
     size_t digest_len = 0;
     int niov = 0;
     int i;
diff --git a/hw/net/allwinner-sun8i-emac.c b/hw/net/allwinner-sun8i-emac.c
index ecc0245fe8..c3fed5fcbe 100644
--- a/hw/net/allwinner-sun8i-emac.c
+++ b/hw/net/allwinner-sun8i-emac.c
@@ -350,8 +350,13 @@ static void allwinner_sun8i_emac_get_desc(AwSun8iEmacState *s,
                                           FrameDescriptor *desc,
                                           uint32_t phys_addr)
 {
-    dma_memory_read(&s->dma_as, phys_addr, desc, sizeof(*desc),
+    uint32_t desc_words[4];
+    dma_memory_read(&s->dma_as, phys_addr, &desc_words, sizeof(desc_words),
                     MEMTXATTRS_UNSPECIFIED);
+    desc->status = le32_to_cpu(desc_words[0]);
+    desc->status2 = le32_to_cpu(desc_words[1]);
+    desc->addr = le32_to_cpu(desc_words[2]);
+    desc->next = le32_to_cpu(desc_words[3]);
 }
 
 static uint32_t allwinner_sun8i_emac_next_desc(AwSun8iEmacState *s,
@@ -400,10 +405,15 @@ static uint32_t allwinner_sun8i_emac_tx_desc(AwSun8iEmacState *s,
 }
 
 static void allwinner_sun8i_emac_flush_desc(AwSun8iEmacState *s,
-                                            FrameDescriptor *desc,
+                                            const FrameDescriptor *desc,
                                             uint32_t phys_addr)
 {
-    dma_memory_write(&s->dma_as, phys_addr, desc, sizeof(*desc),
+    uint32_t desc_words[4];
+    desc_words[0] = cpu_to_le32(desc->status);
+    desc_words[1] = cpu_to_le32(desc->status2);
+    desc_words[2] = cpu_to_le32(desc->addr);
+    desc_words[3] = cpu_to_le32(desc->next);
+    dma_memory_write(&s->dma_as, phys_addr, &desc_words, sizeof(desc_words),
                      MEMTXATTRS_UNSPECIFIED);
 }
 
@@ -638,8 +648,7 @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset,
         break;
     case REG_TX_CUR_BUF:        /* Transmit Current Buffer */
         if (s->tx_desc_curr != 0) {
-            dma_memory_read(&s->dma_as, s->tx_desc_curr, &desc, sizeof(desc),
-                            MEMTXATTRS_UNSPECIFIED);
+            allwinner_sun8i_emac_get_desc(s, &desc, s->tx_desc_curr);
             value = desc.addr;
         } else {
             value = 0;
@@ -652,8 +661,7 @@ static uint64_t allwinner_sun8i_emac_read(void *opaque, hwaddr offset,
         break;
     case REG_RX_CUR_BUF:        /* Receive Current Buffer */
         if (s->rx_desc_curr != 0) {
-            dma_memory_read(&s->dma_as, s->rx_desc_curr, &desc, sizeof(desc),
-                            MEMTXATTRS_UNSPECIFIED);
+            allwinner_sun8i_emac_get_desc(s, &desc, s->rx_desc_curr);
             value = desc.addr;
         } else {
             value = 0;
diff --git a/hw/net/e1000.c b/hw/net/e1000.c
index e26e0a64c1..0dfdf47313 100644
--- a/hw/net/e1000.c
+++ b/hw/net/e1000.c
@@ -567,7 +567,7 @@ e1000_send_packet(E1000State *s, const uint8_t *buf, int size)
         qemu_send_packet(nc, buf, size);
     }
     inc_tx_bcast_or_mcast_count(s, buf);
-    e1000x_increase_size_stats(s->mac_reg, PTCregs, size);
+    e1000x_increase_size_stats(s->mac_reg, PTCregs, size + 4);
 }
 
 static void
@@ -631,10 +631,9 @@ xmit_seg(E1000State *s)
     }
 
     e1000x_inc_reg_if_not_full(s->mac_reg, TPT);
-    e1000x_grow_8reg_if_not_full(s->mac_reg, TOTL, s->tx.size);
-    s->mac_reg[GPTC] = s->mac_reg[TPT];
-    s->mac_reg[GOTCL] = s->mac_reg[TOTL];
-    s->mac_reg[GOTCH] = s->mac_reg[TOTH];
+    e1000x_grow_8reg_if_not_full(s->mac_reg, TOTL, s->tx.size + 4);
+    e1000x_inc_reg_if_not_full(s->mac_reg, GPTC);
+    e1000x_grow_8reg_if_not_full(s->mac_reg, GOTCL, s->tx.size + 4);
 }
 
 static void
diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c
index fc9cdb4528..c71d82ce1d 100644
--- a/hw/net/e1000e_core.c
+++ b/hw/net/e1000e_core.c
@@ -687,9 +687,8 @@ e1000e_on_tx_done_update_stats(E1000ECore *core, struct NetTxPkt *tx_pkt)
         g_assert_not_reached();
     }
 
-    core->mac[GPTC] = core->mac[TPT];
-    core->mac[GOTCL] = core->mac[TOTL];
-    core->mac[GOTCH] = core->mac[TOTH];
+    e1000x_inc_reg_if_not_full(core->mac, GPTC);
+    e1000x_grow_8reg_if_not_full(core->mac, GOTCL, tot_len);
 }
 
 static void
diff --git a/hw/net/e1000x_common.c b/hw/net/e1000x_common.c
index a8d93870b5..3fdc34f753 100644
--- a/hw/net/e1000x_common.c
+++ b/hw/net/e1000x_common.c
@@ -217,15 +217,14 @@ e1000x_update_rx_total_stats(uint32_t *mac,
 
     e1000x_increase_size_stats(mac, PRCregs, data_fcs_size);
     e1000x_inc_reg_if_not_full(mac, TPR);
-    mac[GPRC] = mac[TPR];
+    e1000x_inc_reg_if_not_full(mac, GPRC);
     /* TOR - Total Octets Received:
     * This register includes bytes received in a packet from the <Destination
     * Address> field through the <CRC> field, inclusively.
     * Always include FCS length (4) in size.
     */
     e1000x_grow_8reg_if_not_full(mac, TORL, data_size + 4);
-    mac[GORCL] = mac[TORL];
-    mac[GORCH] = mac[TORH];
+    e1000x_grow_8reg_if_not_full(mac, GORCL, data_size + 4);
 }
 
 void
diff --git a/hw/net/msf2-emac.c b/hw/net/msf2-emac.c
index 7ccd3e5142..db3a04deb1 100644
--- a/hw/net/msf2-emac.c
+++ b/hw/net/msf2-emac.c
@@ -118,14 +118,18 @@ static void emac_load_desc(MSF2EmacState *s, EmacDesc *d, hwaddr desc)
     d->next = le32_to_cpu(d->next);
 }
 
-static void emac_store_desc(MSF2EmacState *s, EmacDesc *d, hwaddr desc)
+static void emac_store_desc(MSF2EmacState *s, const EmacDesc *d, hwaddr desc)
 {
-    /* Convert from host endianness into LE. */
-    d->pktaddr = cpu_to_le32(d->pktaddr);
-    d->pktsize = cpu_to_le32(d->pktsize);
-    d->next = cpu_to_le32(d->next);
-
-    address_space_write(&s->dma_as, desc, MEMTXATTRS_UNSPECIFIED, d, sizeof *d);
+    EmacDesc outd;
+    /*
+     * Convert from host endianness into LE. We use a local struct because
+     * calling code may still want to look at the fields afterwards.
+     */
+    outd.pktaddr = cpu_to_le32(d->pktaddr);
+    outd.pktsize = cpu_to_le32(d->pktsize);
+    outd.next = cpu_to_le32(d->next);
+
+    address_space_write(&s->dma_as, desc, MEMTXATTRS_UNSPECIFIED, &outd, sizeof outd);
 }
 
 static void msf2_dma_tx(MSF2EmacState *s)
diff --git a/hw/net/rtl8139.c b/hw/net/rtl8139.c
index 700b1b66b6..eb679d7c40 100644
--- a/hw/net/rtl8139.c
+++ b/hw/net/rtl8139.c
@@ -2154,6 +2154,9 @@ static int rtl8139_cplus_transmit_one(RTL8139State *s)
 
                 int large_send_mss = (txdw0 >> CP_TC_LGSEN_MSS_SHIFT) &
                                      CP_TC_LGSEN_MSS_MASK;
+                if (large_send_mss == 0) {
+                    goto skip_offload;
+                }
 
                 DPRINTF("+++ C+ mode offloaded task TSO IP data %d "
                     "frame data %d specified MSS=%d\n",
diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c
index aba12759d5..4abd49e298 100644
--- a/hw/net/virtio-net.c
+++ b/hw/net/virtio-net.c
@@ -802,7 +802,6 @@ static uint64_t virtio_net_get_features(VirtIODevice *vdev, uint64_t features,
     }
 
     if (!get_vhost_net(nc->peer)) {
-        virtio_add_feature(&features, VIRTIO_F_RING_RESET);
         return features;
     }
 
diff --git a/hw/net/vmxnet3.c b/hw/net/vmxnet3.c
index d2ab527ef4..56559cda24 100644
--- a/hw/net/vmxnet3.c
+++ b/hw/net/vmxnet3.c
@@ -1441,7 +1441,7 @@ static void vmxnet3_activate_device(VMXNET3State *s)
     vmxnet3_setup_rx_filtering(s);
     /* Cache fields from shared memory */
     s->mtu = VMXNET3_READ_DRV_SHARED32(d, s->drv_shmem, devRead.misc.mtu);
-    assert(VMXNET3_MIN_MTU <= s->mtu && s->mtu < VMXNET3_MAX_MTU);
+    assert(VMXNET3_MIN_MTU <= s->mtu && s->mtu <= VMXNET3_MAX_MTU);
     VMW_CFPRN("MTU is %u", s->mtu);
 
     s->max_rx_frags =
diff --git a/hw/nvme/ctrl.c b/hw/nvme/ctrl.c
index e54276dc1d..749a6938dd 100644
--- a/hw/nvme/ctrl.c
+++ b/hw/nvme/ctrl.c
@@ -1331,10 +1331,23 @@ static inline void nvme_blk_write(BlockBackend *blk, int64_t offset,
     }
 }
 
+static void nvme_update_cq_eventidx(const NvmeCQueue *cq)
+{
+    uint32_t v = cpu_to_le32(cq->head);
+
+    //not in 7.2: trace_pci_nvme_update_cq_eventidx(cq->cqid, cq->head);
+
+    pci_dma_write(PCI_DEVICE(cq->ctrl), cq->ei_addr, &v, sizeof(v));
+}
+
 static void nvme_update_cq_head(NvmeCQueue *cq)
 {
-    pci_dma_read(&cq->ctrl->parent_obj, cq->db_addr, &cq->head,
-            sizeof(cq->head));
+    uint32_t v;
+
+    pci_dma_read(&cq->ctrl->parent_obj, cq->db_addr, &v, sizeof(v));
+
+    cq->head = le32_to_cpu(v);
+
     trace_pci_nvme_shadow_doorbell_cq(cq->cqid, cq->head);
 }
 
@@ -1351,6 +1364,7 @@ static void nvme_post_cqes(void *opaque)
         hwaddr addr;
 
         if (n->dbbuf_enabled) {
+            nvme_update_cq_eventidx(cq);
             nvme_update_cq_head(cq);
         }
 
@@ -2477,6 +2491,9 @@ static uint16_t nvme_dsm(NvmeCtrl *n, NvmeRequest *req)
         status = nvme_h2c(n, (uint8_t *)iocb->range, sizeof(NvmeDsmRange) * nr,
                           req);
         if (status) {
+            g_free(iocb->range);
+            qemu_aio_unref(iocb);
+
             return status;
         }
 
@@ -6141,15 +6158,21 @@ static uint16_t nvme_admin_cmd(NvmeCtrl *n, NvmeRequest *req)
 
 static void nvme_update_sq_eventidx(const NvmeSQueue *sq)
 {
-    pci_dma_write(&sq->ctrl->parent_obj, sq->ei_addr, &sq->tail,
-                  sizeof(sq->tail));
+    uint32_t v = cpu_to_le32(sq->tail);
+
+    pci_dma_write(&sq->ctrl->parent_obj, sq->ei_addr, &v, sizeof(v));
+
     trace_pci_nvme_eventidx_sq(sq->sqid, sq->tail);
 }
 
 static void nvme_update_sq_tail(NvmeSQueue *sq)
 {
-    pci_dma_read(&sq->ctrl->parent_obj, sq->db_addr, &sq->tail,
-                 sizeof(sq->tail));
+    uint32_t v;
+
+    pci_dma_read(&sq->ctrl->parent_obj, sq->db_addr, &v, sizeof(v));
+
+    sq->tail = le32_to_cpu(v);
+
     trace_pci_nvme_shadow_doorbell_sq(sq->sqid, sq->tail);
 }
 
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
index 6edf5ea3e9..371a45dfe2 100644
--- a/hw/nvram/fw_cfg.c
+++ b/hw/nvram/fw_cfg.c
@@ -693,12 +693,12 @@ static const VMStateDescription vmstate_fw_cfg = {
     }
 };
 
-void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
-                               FWCfgCallback select_cb,
-                               FWCfgWriteCallback write_cb,
-                               void *callback_opaque,
-                               void *data, size_t len,
-                               bool read_only)
+static void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
+                                      FWCfgCallback select_cb,
+                                      FWCfgWriteCallback write_cb,
+                                      void *callback_opaque,
+                                      void *data, size_t len,
+                                      bool read_only)
 {
     int arch = !!(key & FW_CFG_ARCH_LOCAL);
 
diff --git a/hw/ppc/ppc.c b/hw/ppc/ppc.c
index dc86c1c7db..fbdc48911e 100644
--- a/hw/ppc/ppc.c
+++ b/hw/ppc/ppc.c
@@ -806,6 +806,8 @@ static void __cpu_ppc_store_decr(PowerPCCPU *cpu, uint64_t *nextp,
     int64_t signed_decr;
 
     /* Truncate value to decr_width and sign extend for simplicity */
+    value = extract64(value, 0, nr_bits);
+    decr = extract64(decr, 0, nr_bits);
     signed_value = sextract64(value, 0, nr_bits);
     signed_decr = sextract64(decr, 0, nr_bits);
 
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index fcbe4c5837..ec8d9584fb 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -271,9 +271,11 @@ static void ibm_40p_init(MachineState *machine)
     }
 
     /* PCI -> ISA bridge */
-    i82378_dev = DEVICE(pci_create_simple(pci_bus, PCI_DEVFN(11, 0), "i82378"));
+    i82378_dev = DEVICE(pci_new(PCI_DEVFN(11, 0), "i82378"));
     qdev_connect_gpio_out(i82378_dev, 0,
                           qdev_get_gpio_in(DEVICE(cpu), PPC6xx_INPUT_INT));
+    qdev_realize_and_unref(i82378_dev, BUS(pci_bus), &error_fatal);
+
     sysbus_connect_irq(pcihost, 0, qdev_get_gpio_in(i82378_dev, 15));
     isa_bus = ISA_BUS(qdev_get_child_bus(i82378_dev, "isa.0"));
 
diff --git a/hw/rdma/vmw/pvrdma_cmd.c b/hw/rdma/vmw/pvrdma_cmd.c
index da7ddfa548..89db963c46 100644
--- a/hw/rdma/vmw/pvrdma_cmd.c
+++ b/hw/rdma/vmw/pvrdma_cmd.c
@@ -796,6 +796,12 @@ int pvrdma_exec_cmd(PVRDMADev *dev)
 
     dsr_info = &dev->dsr_info;
 
+    if (!dsr_info->dsr) {
+            /* Buggy or malicious guest driver */
+            rdma_error_report("Exec command without dsr, req or rsp buffers");
+            goto out;
+    }
+
     if (dsr_info->req->hdr.cmd >= sizeof(cmd_handlers) /
                       sizeof(struct cmd_handler)) {
         rdma_error_report("Unsupported command");
diff --git a/hw/remote/trace-events b/hw/remote/trace-events
index c167b3c7a5..0d1b7d56a5 100644
--- a/hw/remote/trace-events
+++ b/hw/remote/trace-events
@@ -5,8 +5,8 @@ mpqemu_recv_io_error(int cmd, int size, int nfds) "failed to receive %d size %d,
 
 # vfio-user-obj.c
 vfu_prop(const char *prop, const char *val) "vfu: setting %s as %s"
-vfu_cfg_read(uint32_t offset, uint32_t val) "vfu: cfg: 0x%u -> 0x%x"
-vfu_cfg_write(uint32_t offset, uint32_t val) "vfu: cfg: 0x%u <- 0x%x"
+vfu_cfg_read(uint32_t offset, uint32_t val) "vfu: cfg: 0x%x -> 0x%x"
+vfu_cfg_write(uint32_t offset, uint32_t val) "vfu: cfg: 0x%x <- 0x%x"
 vfu_dma_register(uint64_t gpa, size_t len) "vfu: registering GPA 0x%"PRIx64", %zu bytes"
 vfu_dma_unregister(uint64_t gpa) "vfu: unregistering GPA 0x%"PRIx64""
 vfu_bar_register(int i, uint64_t addr, uint64_t size) "vfu: BAR %d: addr 0x%"PRIx64" size 0x%"PRIx64""
diff --git a/hw/riscv/numa.c b/hw/riscv/numa.c
index 7fe92d402f..edf6750f54 100644
--- a/hw/riscv/numa.c
+++ b/hw/riscv/numa.c
@@ -207,6 +207,12 @@ int64_t riscv_numa_get_default_cpu_node_id(const MachineState *ms, int idx)
 {
     int64_t nidx = 0;
 
+    if (ms->numa_state->num_nodes > ms->smp.cpus) {
+        error_report("Number of NUMA nodes (%d)"
+                     " cannot exceed the number of available CPUs (%d).",
+                     ms->numa_state->num_nodes, ms->smp.max_cpus);
+        exit(EXIT_FAILURE);
+    }
     if (ms->numa_state->num_nodes) {
         nidx = idx / (ms->smp.cpus / ms->numa_state->num_nodes);
         if (ms->numa_state->num_nodes <= nidx) {
diff --git a/hw/scsi/lsi53c895a.c b/hw/scsi/lsi53c895a.c
index 50979640c3..42532c4744 100644
--- a/hw/scsi/lsi53c895a.c
+++ b/hw/scsi/lsi53c895a.c
@@ -1134,15 +1134,24 @@ static void lsi_execute_script(LSIState *s)
     uint32_t addr, addr_high;
     int opcode;
     int insn_processed = 0;
+    static int reentrancy_level;
+
+    reentrancy_level++;
 
     s->istat1 |= LSI_ISTAT1_SRUN;
 again:
-    if (++insn_processed > LSI_MAX_INSN) {
-        /* Some windows drivers make the device spin waiting for a memory
-           location to change.  If we have been executed a lot of code then
-           assume this is the case and force an unexpected device disconnect.
-           This is apparently sufficient to beat the drivers into submission.
-         */
+    /*
+     * Some windows drivers make the device spin waiting for a memory location
+     * to change. If we have executed more than LSI_MAX_INSN instructions then
+     * assume this is the case and force an unexpected device disconnect. This
+     * is apparently sufficient to beat the drivers into submission.
+     *
+     * Another issue (CVE-2023-0330) can occur if the script is programmed to
+     * trigger itself again and again. Avoid this problem by stopping after
+     * being called multiple times in a reentrant way (8 is an arbitrary value
+     * which should be enough for all valid use cases).
+     */
+    if (++insn_processed > LSI_MAX_INSN || reentrancy_level > 8) {
         if (!(s->sien0 & LSI_SIST0_UDC)) {
             qemu_log_mask(LOG_GUEST_ERROR,
                           "lsi_scsi: inf. loop with UDC masked");
@@ -1596,6 +1605,8 @@ again:
         }
     }
     trace_lsi_execute_script_stop();
+
+    reentrancy_level--;
 }
 
 static uint8_t lsi_reg_readb(LSIState *s, int offset)
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index 92cce20a4d..d513870181 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -190,12 +190,16 @@ static int scsi_handle_inquiry_reply(SCSIGenericReq *r, SCSIDevice *s, int len)
     if ((s->type == TYPE_DISK || s->type == TYPE_ZBC) &&
         (r->req.cmd.buf[1] & 0x01)) {
         page = r->req.cmd.buf[2];
-        if (page == 0xb0) {
+        if (page == 0xb0 && r->buflen >= 8) {
+            uint8_t buf[16] = {};
+            uint8_t buf_used = MIN(r->buflen, 16);
             uint64_t max_transfer = calculate_max_transfer(s);
-            stl_be_p(&r->buf[8], max_transfer);
-            /* Also take care of the opt xfer len. */
-            stl_be_p(&r->buf[12],
-                    MIN_NON_ZERO(max_transfer, ldl_be_p(&r->buf[12])));
+
+            memcpy(buf, r->buf, buf_used);
+            stl_be_p(&buf[8], max_transfer);
+            stl_be_p(&buf[12], MIN_NON_ZERO(max_transfer, ldl_be_p(&buf[12])));
+            memcpy(r->buf + 8, buf + 8, buf_used - 8);
+
         } else if (s->needs_vpd_bl_emulation && page == 0x00 && r->buflen >= 4) {
             /*
              * Now we're capable of supplying the VPD Block Limits
diff --git a/hw/sd/allwinner-sdhost.c b/hw/sd/allwinner-sdhost.c
index 51e5e90830..92a0f42708 100644
--- a/hw/sd/allwinner-sdhost.c
+++ b/hw/sd/allwinner-sdhost.c
@@ -302,6 +302,30 @@ static void allwinner_sdhost_auto_stop(AwSdHostState *s)
     }
 }
 
+static void read_descriptor(AwSdHostState *s, hwaddr desc_addr,
+                            TransferDescriptor *desc)
+{
+    uint32_t desc_words[4];
+    dma_memory_read(&s->dma_as, desc_addr, &desc_words, sizeof(desc_words),
+                    MEMTXATTRS_UNSPECIFIED);
+    desc->status = le32_to_cpu(desc_words[0]);
+    desc->size = le32_to_cpu(desc_words[1]);
+    desc->addr = le32_to_cpu(desc_words[2]);
+    desc->next = le32_to_cpu(desc_words[3]);
+}
+
+static void write_descriptor(AwSdHostState *s, hwaddr desc_addr,
+                             const TransferDescriptor *desc)
+{
+    uint32_t desc_words[4];
+    desc_words[0] = cpu_to_le32(desc->status);
+    desc_words[1] = cpu_to_le32(desc->size);
+    desc_words[2] = cpu_to_le32(desc->addr);
+    desc_words[3] = cpu_to_le32(desc->next);
+    dma_memory_write(&s->dma_as, desc_addr, &desc_words, sizeof(desc_words),
+                     MEMTXATTRS_UNSPECIFIED);
+}
+
 static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s,
                                               hwaddr desc_addr,
                                               TransferDescriptor *desc,
@@ -312,9 +336,7 @@ static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s,
     uint32_t num_bytes = max_bytes;
     uint8_t buf[1024];
 
-    /* Read descriptor */
-    dma_memory_read(&s->dma_as, desc_addr, desc, sizeof(*desc),
-                    MEMTXATTRS_UNSPECIFIED);
+    read_descriptor(s, desc_addr, desc);
     if (desc->size == 0) {
         desc->size = klass->max_desc_size;
     } else if (desc->size > klass->max_desc_size) {
@@ -356,8 +378,7 @@ static uint32_t allwinner_sdhost_process_desc(AwSdHostState *s,
 
     /* Clear hold flag and flush descriptor */
     desc->status &= ~DESC_STATUS_HOLD;
-    dma_memory_write(&s->dma_as, desc_addr, desc, sizeof(*desc),
-                     MEMTXATTRS_UNSPECIFIED);
+    write_descriptor(s, desc_addr, desc);
 
     return num_done;
 }
diff --git a/hw/smbios/smbios.c b/hw/smbios/smbios.c
index b4243de735..66a020999b 100644
--- a/hw/smbios/smbios.c
+++ b/hw/smbios/smbios.c
@@ -749,14 +749,16 @@ static void smbios_build_type_4_table(MachineState *ms, unsigned instance)
     t->core_count = (ms->smp.cores > 255) ? 0xFF : ms->smp.cores;
     t->core_enabled = t->core_count;
 
-    t->core_count2 = t->core_enabled2 = cpu_to_le16(ms->smp.cores);
-
     t->thread_count = (ms->smp.threads > 255) ? 0xFF : ms->smp.threads;
-    t->thread_count2 = cpu_to_le16(ms->smp.threads);
 
     t->processor_characteristics = cpu_to_le16(0x02); /* Unknown */
     t->processor_family2 = cpu_to_le16(0x01); /* Other */
 
+    if (tbl_len == SMBIOS_TYPE_4_LEN_V30) {
+        t->core_count2 = t->core_enabled2 = cpu_to_le16(ms->smp.cores);
+        t->thread_count2 = cpu_to_le16(ms->smp.threads);
+    }
+
     SMBIOS_BUILD_TABLE_POST;
     smbios_type4_count++;
 }
diff --git a/hw/timer/hpet.c b/hw/timer/hpet.c
index 9520471be2..5f88ffdef8 100644
--- a/hw/timer/hpet.c
+++ b/hw/timer/hpet.c
@@ -352,6 +352,16 @@ static const VMStateDescription vmstate_hpet = {
     }
 };
 
+static void hpet_arm(HPETTimer *t, uint64_t ticks)
+{
+    if (ticks < ns_to_ticks(INT64_MAX / 2)) {
+        timer_mod(t->qemu_timer,
+                  qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + ticks_to_ns(ticks));
+    } else {
+        timer_del(t->qemu_timer);
+    }
+}
+
 /*
  * timer expiration callback
  */
@@ -374,13 +384,11 @@ static void hpet_timer(void *opaque)
             }
         }
         diff = hpet_calculate_diff(t, cur_tick);
-        timer_mod(t->qemu_timer,
-                       qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + (int64_t)ticks_to_ns(diff));
+        hpet_arm(t, diff);
     } else if (t->config & HPET_TN_32BIT && !timer_is_periodic(t)) {
         if (t->wrap_flag) {
             diff = hpet_calculate_diff(t, cur_tick);
-            timer_mod(t->qemu_timer, qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) +
-                           (int64_t)ticks_to_ns(diff));
+            hpet_arm(t, diff);
             t->wrap_flag = 0;
         }
     }
@@ -407,8 +415,7 @@ static void hpet_set_timer(HPETTimer *t)
             t->wrap_flag = 1;
         }
     }
-    timer_mod(t->qemu_timer,
-                   qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL) + (int64_t)ticks_to_ns(diff));
+    hpet_arm(t, diff);
 }
 
 static void hpet_del_timer(HPETTimer *t)
diff --git a/hw/timer/nrf51_timer.c b/hw/timer/nrf51_timer.c
index 42be79c736..50c6772383 100644
--- a/hw/timer/nrf51_timer.c
+++ b/hw/timer/nrf51_timer.c
@@ -45,7 +45,12 @@ static uint32_t update_counter(NRF51TimerState *s, int64_t now)
     uint32_t ticks = ns_to_ticks(s, now - s->update_counter_ns);
 
     s->counter = (s->counter + ticks) % BIT(bitwidths[s->bitmode]);
-    s->update_counter_ns = now;
+    /*
+     * Only advance the sync time to the timestamp of the last tick,
+     * not all the way to 'now', so we don't lose time if we do
+     * multiple resyncs in a single tick.
+     */
+    s->update_counter_ns += ticks_to_ns(s, ticks);
     return ticks;
 }
 
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 9d68036d23..c3ab762f54 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -1210,6 +1210,8 @@ static void ohci_frame_boundary(void *opaque)
     /* Increment frame number and take care of endianness. */
     ohci->frame_number = (ohci->frame_number + 1) & 0xffff;
     hcca.frame = cpu_to_le16(ohci->frame_number);
+    /* When the HC updates frame number, set pad to 0. Ref OHCI Spec 4.4.1*/
+    hcca.pad = 0;
 
     if (ohci->done_count == 0 && !(ohci->intr_status & OHCI_INTR_WD)) {
         if (!ohci->done)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 939dcc3d4a..92a45de4c3 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -663,6 +663,8 @@ static void vfio_msi_enable(VFIOPCIDevice *vdev)
 
     vfio_disable_interrupts(vdev);
 
+    vdev->nr_vectors = msi_nr_vectors_allocated(&vdev->pdev);
+retry:
     /*
      * Setting vector notifiers needs to enable route for each vector.
      * Deferring to commit the KVM routes once rather than per vector
@@ -670,8 +672,6 @@ static void vfio_msi_enable(VFIOPCIDevice *vdev)
      */
     vfio_prepare_kvm_msi_virq_batch(vdev);
 
-    vdev->nr_vectors = msi_nr_vectors_allocated(&vdev->pdev);
-retry:
     vdev->msi_vectors = g_new0(VFIOMSIVector, vdev->nr_vectors);
 
     for (i = 0; i < vdev->nr_vectors; i++) {
@@ -3159,7 +3159,9 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
 
 out_deregister:
     pci_device_set_intx_routing_notifier(&vdev->pdev, NULL);
-    kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
+    if (vdev->irqchip_change_notifier.notify) {
+        kvm_irqchip_remove_change_notifier(&vdev->irqchip_change_notifier);
+    }
 out_teardown:
     vfio_teardown_msi(vdev);
     vfio_bars_exit(vdev);
diff --git a/hw/virtio/vhost-shadow-virtqueue.c b/hw/virtio/vhost-shadow-virtqueue.c
index 5bd14cad96..d422418f2d 100644
--- a/hw/virtio/vhost-shadow-virtqueue.c
+++ b/hw/virtio/vhost-shadow-virtqueue.c
@@ -68,7 +68,7 @@ bool vhost_svq_valid_features(uint64_t features, Error **errp)
  */
 static uint16_t vhost_svq_available_slots(const VhostShadowVirtqueue *svq)
 {
-    return svq->vring.num - (svq->shadow_avail_idx - svq->shadow_used_idx);
+    return svq->num_free;
 }
 
 /**
@@ -263,6 +263,7 @@ int vhost_svq_add(VhostShadowVirtqueue *svq, const struct iovec *out_sg,
         return -EINVAL;
     }
 
+    svq->num_free -= ndescs;
     svq->desc_state[qemu_head].elem = elem;
     svq->desc_state[qemu_head].ndescs = ndescs;
     vhost_svq_kick(svq);
@@ -449,6 +450,7 @@ static VirtQueueElement *vhost_svq_get_buf(VhostShadowVirtqueue *svq,
     last_used_chain = vhost_svq_last_desc_of_chain(svq, num, used_elem.id);
     svq->desc_next[last_used_chain] = svq->free_head;
     svq->free_head = used_elem.id;
+    svq->num_free += num;
 
     *len = used_elem.len;
     return g_steal_pointer(&svq->desc_state[used_elem.id].elem);
@@ -522,7 +524,7 @@ static void vhost_svq_flush(VhostShadowVirtqueue *svq,
 size_t vhost_svq_poll(VhostShadowVirtqueue *svq)
 {
     int64_t start_us = g_get_monotonic_time();
-    uint32_t len;
+    uint32_t len = 0;
 
     do {
         if (vhost_svq_more_used(svq)) {
@@ -656,6 +658,7 @@ void vhost_svq_start(VhostShadowVirtqueue *svq, VirtIODevice *vdev,
     svq->vq = vq;
 
     svq->vring.num = virtio_queue_get_num(vdev, virtio_get_queue_index(vq));
+    svq->num_free = svq->vring.num;
     driver_size = vhost_svq_driver_area_size(svq);
     device_size = vhost_svq_device_area_size(svq);
     svq->vring.desc = qemu_memalign(qemu_real_host_page_size(), driver_size);
diff --git a/hw/virtio/vhost-shadow-virtqueue.h b/hw/virtio/vhost-shadow-virtqueue.h
index d04c34a589..328a7fc075 100644
--- a/hw/virtio/vhost-shadow-virtqueue.h
+++ b/hw/virtio/vhost-shadow-virtqueue.h
@@ -107,6 +107,9 @@ typedef struct VhostShadowVirtqueue {
 
     /* Next head to consume from the device */
     uint16_t last_used_idx;
+
+    /* Size of SVQ vring free descriptors */
+    uint16_t num_free;
 } VhostShadowVirtqueue;
 
 bool vhost_svq_valid_features(uint64_t features, Error **errp);
diff --git a/hw/virtio/vhost-user-gpio.c b/hw/virtio/vhost-user-gpio.c
index b7b82a1099..97145376eb 100644
--- a/hw/virtio/vhost-user-gpio.c
+++ b/hw/virtio/vhost-user-gpio.c
@@ -16,6 +16,7 @@
 #include "trace.h"
 
 #define REALIZE_CONNECTION_RETRIES 3
+#define VHOST_NVQS 2
 
 /* Features required from VirtIO */
 static const int feature_bits[] = {
@@ -198,8 +199,7 @@ static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserGPIO *gpio)
 {
     virtio_delete_queue(gpio->command_vq);
     virtio_delete_queue(gpio->interrupt_vq);
-    g_free(gpio->vhost_dev.vqs);
-    gpio->vhost_dev.vqs = NULL;
+    g_free(gpio->vhost_vqs);
     virtio_cleanup(vdev);
     vhost_user_cleanup(&gpio->vhost_user);
 }
@@ -219,6 +219,9 @@ static int vu_gpio_connect(DeviceState *dev, Error **errp)
     vhost_dev_set_config_notifier(vhost_dev, &gpio_ops);
     gpio->vhost_user.supports_config = true;
 
+    gpio->vhost_dev.nvqs = VHOST_NVQS;
+    gpio->vhost_dev.vqs = gpio->vhost_vqs;
+
     ret = vhost_dev_init(vhost_dev, &gpio->vhost_user,
                          VHOST_BACKEND_TYPE_USER, 0, errp);
     if (ret < 0) {
@@ -337,10 +340,9 @@ static void vu_gpio_device_realize(DeviceState *dev, Error **errp)
 
     virtio_init(vdev, VIRTIO_ID_GPIO, sizeof(gpio->config));
 
-    gpio->vhost_dev.nvqs = 2;
     gpio->command_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output);
     gpio->interrupt_vq = virtio_add_queue(vdev, 256, vu_gpio_handle_output);
-    gpio->vhost_dev.vqs = g_new0(struct vhost_virtqueue, gpio->vhost_dev.nvqs);
+    gpio->vhost_vqs = g_new0(struct vhost_virtqueue, VHOST_NVQS);
 
     gpio->connected = false;
 
diff --git a/hw/virtio/vhost-user-i2c.c b/hw/virtio/vhost-user-i2c.c
index dc5c828ba6..60eaf0d95b 100644
--- a/hw/virtio/vhost-user-i2c.c
+++ b/hw/virtio/vhost-user-i2c.c
@@ -143,8 +143,6 @@ static void do_vhost_user_cleanup(VirtIODevice *vdev, VHostUserI2C *i2c)
     vhost_user_cleanup(&i2c->vhost_user);
     virtio_delete_queue(i2c->vq);
     virtio_cleanup(vdev);
-    g_free(i2c->vhost_dev.vqs);
-    i2c->vhost_dev.vqs = NULL;
 }
 
 static int vu_i2c_connect(DeviceState *dev)
@@ -228,6 +226,7 @@ static void vu_i2c_device_realize(DeviceState *dev, Error **errp)
     ret = vhost_dev_init(&i2c->vhost_dev, &i2c->vhost_user,
                          VHOST_BACKEND_TYPE_USER, 0, errp);
     if (ret < 0) {
+        g_free(i2c->vhost_dev.vqs);
         do_vhost_user_cleanup(vdev, i2c);
     }
 
@@ -239,10 +238,12 @@ static void vu_i2c_device_unrealize(DeviceState *dev)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VHostUserI2C *i2c = VHOST_USER_I2C(dev);
+    struct vhost_virtqueue *vhost_vqs = i2c->vhost_dev.vqs;
 
     /* This will stop vhost backend if appropriate. */
     vu_i2c_set_status(vdev, 0);
     vhost_dev_cleanup(&i2c->vhost_dev);
+    g_free(vhost_vqs);
     do_vhost_user_cleanup(vdev, i2c);
 }
 
diff --git a/hw/virtio/vhost-user-rng.c b/hw/virtio/vhost-user-rng.c
index 201a39e220..efc54cd3fb 100644
--- a/hw/virtio/vhost-user-rng.c
+++ b/hw/virtio/vhost-user-rng.c
@@ -229,6 +229,7 @@ static void vu_rng_device_realize(DeviceState *dev, Error **errp)
     return;
 
 vhost_dev_init_failed:
+    g_free(rng->vhost_dev.vqs);
     virtio_delete_queue(rng->req_vq);
 virtio_add_queue_failed:
     virtio_cleanup(vdev);
@@ -239,12 +240,12 @@ static void vu_rng_device_unrealize(DeviceState *dev)
 {
     VirtIODevice *vdev = VIRTIO_DEVICE(dev);
     VHostUserRNG *rng = VHOST_USER_RNG(dev);
+    struct vhost_virtqueue *vhost_vqs = rng->vhost_dev.vqs;
 
     vu_rng_set_status(vdev, 0);
 
     vhost_dev_cleanup(&rng->vhost_dev);
-    g_free(rng->vhost_dev.vqs);
-    rng->vhost_dev.vqs = NULL;
+    g_free(vhost_vqs);
     virtio_delete_queue(rng->req_vq);
     virtio_cleanup(vdev);
     vhost_user_cleanup(&rng->vhost_user);
diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c
index 8f635844af..d92b026e1c 100644
--- a/hw/virtio/vhost-user.c
+++ b/hw/virtio/vhost-user.c
@@ -305,19 +305,8 @@ static int vhost_user_read_header(struct vhost_dev *dev, VhostUserMsg *msg)
     return 0;
 }
 
-struct vhost_user_read_cb_data {
-    struct vhost_dev *dev;
-    VhostUserMsg *msg;
-    GMainLoop *loop;
-    int ret;
-};
-
-static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
-                                   gpointer opaque)
+static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
 {
-    struct vhost_user_read_cb_data *data = opaque;
-    struct vhost_dev *dev = data->dev;
-    VhostUserMsg *msg = data->msg;
     struct vhost_user *u = dev->opaque;
     CharBackend *chr = u->user->chr;
     uint8_t *p = (uint8_t *) msg;
@@ -325,8 +314,7 @@ static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
 
     r = vhost_user_read_header(dev, msg);
     if (r < 0) {
-        data->ret = r;
-        goto end;
+        return r;
     }
 
     /* validate message size is sane */
@@ -334,8 +322,7 @@ static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
         error_report("Failed to read msg header."
                 " Size %d exceeds the maximum %zu.", msg->hdr.size,
                 VHOST_USER_PAYLOAD_SIZE);
-        data->ret = -EPROTO;
-        goto end;
+        return -EPROTO;
     }
 
     if (msg->hdr.size) {
@@ -346,84 +333,11 @@ static gboolean vhost_user_read_cb(void *do_not_use, GIOCondition condition,
             int saved_errno = errno;
             error_report("Failed to read msg payload."
                          " Read %d instead of %d.", r, msg->hdr.size);
-            data->ret = r < 0 ? -saved_errno : -EIO;
-            goto end;
+            return r < 0 ? -saved_errno : -EIO;
         }
     }
 
-end:
-    g_main_loop_quit(data->loop);
-    return G_SOURCE_REMOVE;
-}
-
-static gboolean slave_read(QIOChannel *ioc, GIOCondition condition,
-                           gpointer opaque);
-
-/*
- * This updates the read handler to use a new event loop context.
- * Event sources are removed from the previous context : this ensures
- * that events detected in the previous context are purged. They will
- * be re-detected and processed in the new context.
- */
-static void slave_update_read_handler(struct vhost_dev *dev,
-                                      GMainContext *ctxt)
-{
-    struct vhost_user *u = dev->opaque;
-
-    if (!u->slave_ioc) {
-        return;
-    }
-
-    if (u->slave_src) {
-        g_source_destroy(u->slave_src);
-        g_source_unref(u->slave_src);
-    }
-
-    u->slave_src = qio_channel_add_watch_source(u->slave_ioc,
-                                                G_IO_IN | G_IO_HUP,
-                                                slave_read, dev, NULL,
-                                                ctxt);
-}
-
-static int vhost_user_read(struct vhost_dev *dev, VhostUserMsg *msg)
-{
-    struct vhost_user *u = dev->opaque;
-    CharBackend *chr = u->user->chr;
-    GMainContext *prev_ctxt = chr->chr->gcontext;
-    GMainContext *ctxt = g_main_context_new();
-    GMainLoop *loop = g_main_loop_new(ctxt, FALSE);
-    struct vhost_user_read_cb_data data = {
-        .dev = dev,
-        .loop = loop,
-        .msg = msg,
-        .ret = 0
-    };
-
-    /*
-     * We want to be able to monitor the slave channel fd while waiting
-     * for chr I/O. This requires an event loop, but we can't nest the
-     * one to which chr is currently attached : its fd handlers might not
-     * be prepared for re-entrancy. So we create a new one and switch chr
-     * to use it.
-     */
-    slave_update_read_handler(dev, ctxt);
-    qemu_chr_be_update_read_handlers(chr->chr, ctxt);
-    qemu_chr_fe_add_watch(chr, G_IO_IN | G_IO_HUP, vhost_user_read_cb, &data);
-
-    g_main_loop_run(loop);
-
-    /*
-     * Restore the previous event loop context. This also destroys/recreates
-     * event sources : this guarantees that all pending events in the original
-     * context that have been processed by the nested loop are purged.
-     */
-    qemu_chr_be_update_read_handlers(chr->chr, prev_ctxt);
-    slave_update_read_handler(dev, NULL);
-
-    g_main_loop_unref(loop);
-    g_main_context_unref(ctxt);
-
-    return data.ret;
+    return 0;
 }
 
 static int process_message_reply(struct vhost_dev *dev,
@@ -1802,7 +1716,9 @@ static int vhost_setup_slave_channel(struct vhost_dev *dev)
         return -ECONNREFUSED;
     }
     u->slave_ioc = ioc;
-    slave_update_read_handler(dev, NULL);
+    u->slave_src = qio_channel_add_watch_source(u->slave_ioc,
+                                                G_IO_IN | G_IO_HUP,
+                                                slave_read, dev, NULL, NULL);
 
     if (reply_supported) {
         msg.hdr.flags |= VHOST_USER_NEED_REPLY_MASK;
@@ -2108,8 +2024,8 @@ static int vhost_user_backend_init(struct vhost_dev *dev, void *opaque,
         } else {
             if (virtio_has_feature(protocol_features,
                                    VHOST_USER_PROTOCOL_F_CONFIG)) {
-                warn_reportf_err(*errp, "vhost-user backend supports "
-                                 "VHOST_USER_PROTOCOL_F_CONFIG but QEMU does not.");
+                warn_report("vhost-user backend supports "
+                            "VHOST_USER_PROTOCOL_F_CONFIG but QEMU does not.");
                 protocol_features &= ~(1ULL << VHOST_USER_PROTOCOL_F_CONFIG);
             }
         }
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 7468e44b87..03c78d25d8 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -707,26 +707,11 @@ static int vhost_vdpa_get_device_id(struct vhost_dev *dev,
     return ret;
 }
 
-static void vhost_vdpa_reset_svq(struct vhost_vdpa *v)
-{
-    if (!v->shadow_vqs_enabled) {
-        return;
-    }
-
-    for (unsigned i = 0; i < v->shadow_vqs->len; ++i) {
-        VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
-        vhost_svq_stop(svq);
-    }
-}
-
 static int vhost_vdpa_reset_device(struct vhost_dev *dev)
 {
-    struct vhost_vdpa *v = dev->opaque;
     int ret;
     uint8_t status = 0;
 
-    vhost_vdpa_reset_svq(v);
-
     ret = vhost_vdpa_call(dev, VHOST_VDPA_SET_STATUS, &status);
     trace_vhost_vdpa_reset_device(dev, status);
     return ret;
@@ -1088,6 +1073,8 @@ static void vhost_vdpa_svqs_stop(struct vhost_dev *dev)
 
     for (unsigned i = 0; i < v->shadow_vqs->len; ++i) {
         VhostShadowVirtqueue *svq = g_ptr_array_index(v->shadow_vqs, i);
+
+        vhost_svq_stop(svq);
         vhost_vdpa_svq_unmap_rings(dev, svq);
     }
 }
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 7fb008bc9e..f38997b3f6 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -20,6 +20,7 @@
 #include "qemu/range.h"
 #include "qemu/error-report.h"
 #include "qemu/memfd.h"
+#include "qemu/log.h"
 #include "standard-headers/linux/vhost_types.h"
 #include "hw/virtio/virtio-bus.h"
 #include "hw/virtio/virtio-access.h"
@@ -106,6 +107,24 @@ static void vhost_dev_sync_region(struct vhost_dev *dev,
     }
 }
 
+static bool vhost_dev_has_iommu(struct vhost_dev *dev)
+{
+    VirtIODevice *vdev = dev->vdev;
+
+    /*
+     * For vhost, VIRTIO_F_IOMMU_PLATFORM means the backend support
+     * incremental memory mapping API via IOTLB API. For platform that
+     * does not have IOMMU, there's no need to enable this feature
+     * which may cause unnecessary IOTLB miss/update transactions.
+     */
+    if (vdev) {
+        return virtio_bus_device_iommu_enabled(vdev) &&
+            virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
+    } else {
+        return false;
+    }
+}
+
 static int vhost_sync_dirty_bitmap(struct vhost_dev *dev,
                                    MemoryRegionSection *section,
                                    hwaddr first,
@@ -137,8 +156,51 @@ static int vhost_sync_dirty_bitmap(struct vhost_dev *dev,
             continue;
         }
 
-        vhost_dev_sync_region(dev, section, start_addr, end_addr, vq->used_phys,
-                              range_get_last(vq->used_phys, vq->used_size));
+        if (vhost_dev_has_iommu(dev)) {
+            IOMMUTLBEntry iotlb;
+            hwaddr used_phys = vq->used_phys, used_size = vq->used_size;
+            hwaddr phys, s, offset;
+
+            while (used_size) {
+                rcu_read_lock();
+                iotlb = address_space_get_iotlb_entry(dev->vdev->dma_as,
+                                                      used_phys,
+                                                      true,
+                                                      MEMTXATTRS_UNSPECIFIED);
+                rcu_read_unlock();
+
+                if (!iotlb.target_as) {
+                    qemu_log_mask(LOG_GUEST_ERROR, "translation "
+                                  "failure for used_iova %"PRIx64"\n",
+                                  used_phys);
+                    return -EINVAL;
+                }
+
+                offset = used_phys & iotlb.addr_mask;
+                phys = iotlb.translated_addr + offset;
+
+                /*
+                 * Distance from start of used ring until last byte of
+                 * IOMMU page.
+                 */
+                s = iotlb.addr_mask - offset;
+                /*
+                 * Size of used ring, or of the part of it until end
+                 * of IOMMU page. To avoid zero result, do the adding
+                 * outside of MIN().
+                 */
+                s = MIN(s, used_size - 1) + 1;
+
+                vhost_dev_sync_region(dev, section, start_addr, end_addr, phys,
+                                      range_get_last(phys, s));
+                used_size -= s;
+                used_phys += s;
+            }
+        } else {
+            vhost_dev_sync_region(dev, section, start_addr,
+                                  end_addr, vq->used_phys,
+                                  range_get_last(vq->used_phys, vq->used_size));
+        }
     }
     return 0;
 }
@@ -306,24 +368,6 @@ static inline void vhost_dev_log_resize(struct vhost_dev *dev, uint64_t size)
     dev->log_size = size;
 }
 
-static bool vhost_dev_has_iommu(struct vhost_dev *dev)
-{
-    VirtIODevice *vdev = dev->vdev;
-
-    /*
-     * For vhost, VIRTIO_F_IOMMU_PLATFORM means the backend support
-     * incremental memory mapping API via IOTLB API. For platform that
-     * does not have IOMMU, there's no need to enable this feature
-     * which may cause unnecessary IOTLB miss/update transactions.
-     */
-    if (vdev) {
-        return virtio_bus_device_iommu_enabled(vdev) &&
-            virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM);
-    } else {
-        return false;
-    }
-}
-
 static void *vhost_memory_map(struct vhost_dev *dev, hwaddr addr,
                               hwaddr *plen, bool is_write)
 {
@@ -1890,6 +1934,9 @@ fail_vq:
     }
 
 fail_mem:
+    if (vhost_dev_has_iommu(hdev)) {
+        memory_listener_unregister(&hdev->iommu_listener);
+    }
 fail_features:
     vdev->vhost_started = false;
     hdev->started = false;
diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c
index 97da74e719..a6dbdd32da 100644
--- a/hw/virtio/virtio-crypto.c
+++ b/hw/virtio/virtio-crypto.c
@@ -476,15 +476,17 @@ static void virtio_crypto_free_request(VirtIOCryptoReq *req)
         size_t max_len;
         CryptoDevBackendSymOpInfo *op_info = req->op_info.u.sym_op_info;
 
-        max_len = op_info->iv_len +
-                  op_info->aad_len +
-                  op_info->src_len +
-                  op_info->dst_len +
-                  op_info->digest_result_len;
-
-        /* Zeroize and free request data structure */
-        memset(op_info, 0, sizeof(*op_info) + max_len);
-        g_free(op_info);
+        if (op_info) {
+            max_len = op_info->iv_len +
+                      op_info->aad_len +
+                      op_info->src_len +
+                      op_info->dst_len +
+                      op_info->digest_result_len;
+
+            /* Zeroize and free request data structure */
+            memset(op_info, 0, sizeof(*op_info) + max_len);
+            g_free(op_info);
+        }
     } else if (req->flags == CRYPTODEV_BACKEND_ALG_ASYM) {
         CryptoDevBackendAsymOpInfo *op_info = req->op_info.u.asym_op_info;
         if (op_info) {
diff --git a/hw/virtio/virtio-mem.c b/hw/virtio/virtio-mem.c
index ed170def48..56db586c89 100644
--- a/hw/virtio/virtio-mem.c
+++ b/hw/virtio/virtio-mem.c
@@ -235,7 +235,7 @@ static int virtio_mem_for_each_plugged_section(const VirtIOMEM *vmem,
     uint64_t offset, size;
     int ret = 0;
 
-    first_bit = s->offset_within_region / vmem->bitmap_size;
+    first_bit = s->offset_within_region / vmem->block_size;
     first_bit = find_next_bit(vmem->bitmap, vmem->bitmap_size, first_bit);
     while (first_bit < vmem->bitmap_size) {
         MemoryRegionSection tmp = *s;
@@ -267,7 +267,7 @@ static int virtio_mem_for_each_unplugged_section(const VirtIOMEM *vmem,
     uint64_t offset, size;
     int ret = 0;
 
-    first_bit = s->offset_within_region / vmem->bitmap_size;
+    first_bit = s->offset_within_region / vmem->block_size;
     first_bit = find_next_zero_bit(vmem->bitmap, vmem->bitmap_size, first_bit);
     while (first_bit < vmem->bitmap_size) {
         MemoryRegionSection tmp = *s;
@@ -341,7 +341,7 @@ static int virtio_mem_notify_plug(VirtIOMEM *vmem, uint64_t offset,
     if (ret) {
         /* Notify all already-notified listeners. */
         QLIST_FOREACH(rdl2, &vmem->rdl_list, next) {
-            MemoryRegionSection tmp = *rdl->section;
+            MemoryRegionSection tmp = *rdl2->section;
 
             if (rdl2 == rdl) {
                 break;
diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c
index eb6347ab5d..384c8f0f08 100644
--- a/hw/virtio/virtio.c
+++ b/hw/virtio/virtio.c
@@ -1478,7 +1478,7 @@ static void virtqueue_split_get_avail_bytes(VirtQueue *vq,
                             VRingMemoryRegionCaches *caches)
 {
     VirtIODevice *vdev = vq->vdev;
-    unsigned int max, idx;
+    unsigned int idx;
     unsigned int total_bufs, in_total, out_total;
     MemoryRegionCache indirect_desc_cache = MEMORY_REGION_CACHE_INVALID;
     int64_t len = 0;
@@ -1487,13 +1487,12 @@ static void virtqueue_split_get_avail_bytes(VirtQueue *vq,
     idx = vq->last_avail_idx;
     total_bufs = in_total = out_total = 0;
 
-    max = vq->vring.num;
-
     while ((rc = virtqueue_num_heads(vq, idx)) > 0) {
         MemoryRegionCache *desc_cache = &caches->desc;
         unsigned int num_bufs;
         VRingDesc desc;
         unsigned int i;
+        unsigned int max = vq->vring.num;
 
         num_bufs = total_bufs;
 
@@ -1615,7 +1614,7 @@ static void virtqueue_packed_get_avail_bytes(VirtQueue *vq,
                                              VRingMemoryRegionCaches *caches)
 {
     VirtIODevice *vdev = vq->vdev;
-    unsigned int max, idx;
+    unsigned int idx;
     unsigned int total_bufs, in_total, out_total;
     MemoryRegionCache *desc_cache;
     MemoryRegionCache indirect_desc_cache = MEMORY_REGION_CACHE_INVALID;
@@ -1627,14 +1626,14 @@ static void virtqueue_packed_get_avail_bytes(VirtQueue *vq,
     wrap_counter = vq->last_avail_wrap_counter;
     total_bufs = in_total = out_total = 0;
 
-    max = vq->vring.num;
-
     for (;;) {
         unsigned int num_bufs = total_bufs;
         unsigned int i = idx;
         int rc;
+        unsigned int max = vq->vring.num;
 
         desc_cache = &caches->desc;
+
         vring_packed_desc_read(vdev, &desc, desc_cache, idx, true);
         if (!is_desc_avail(desc.flags, wrap_counter)) {
             break;
diff --git a/hw/xen/xen_pt.c b/hw/xen/xen_pt.c
index 0ec7e52183..5dd706efbf 100644
--- a/hw/xen/xen_pt.c
+++ b/hw/xen/xen_pt.c
@@ -57,6 +57,7 @@
 #include <sys/ioctl.h>
 
 #include "hw/pci/pci.h"
+#include "hw/pci/pci_bus.h"
 #include "hw/qdev-properties.h"
 #include "hw/qdev-properties-system.h"
 #include "hw/xen/xen.h"
@@ -780,15 +781,6 @@ static void xen_pt_realize(PCIDevice *d, Error **errp)
                s->hostaddr.bus, s->hostaddr.slot, s->hostaddr.function,
                s->dev.devfn);
 
-    xen_host_pci_device_get(&s->real_device,
-                            s->hostaddr.domain, s->hostaddr.bus,
-                            s->hostaddr.slot, s->hostaddr.function,
-                            errp);
-    if (*errp) {
-        error_append_hint(errp, "Failed to \"open\" the real pci device");
-        return;
-    }
-
     s->is_virtfn = s->real_device.is_virtfn;
     if (s->is_virtfn) {
         XEN_PT_LOG(d, "%04x:%02x:%02x.%d is a SR-IOV Virtual Function\n",
@@ -803,8 +795,10 @@ static void xen_pt_realize(PCIDevice *d, Error **errp)
     s->io_listener = xen_pt_io_listener;
 
     /* Setup VGA bios for passthrough GFX */
-    if ((s->real_device.domain == 0) && (s->real_device.bus == 0) &&
-        (s->real_device.dev == 2) && (s->real_device.func == 0)) {
+    if ((s->real_device.domain == XEN_PCI_IGD_DOMAIN) &&
+        (s->real_device.bus == XEN_PCI_IGD_BUS) &&
+        (s->real_device.dev == XEN_PCI_IGD_DEV) &&
+        (s->real_device.func == XEN_PCI_IGD_FN)) {
         if (!is_igd_vga_passthrough(&s->real_device)) {
             error_setg(errp, "Need to enable igd-passthru if you're trying"
                     " to passthrough IGD GFX");
@@ -950,11 +944,58 @@ static void xen_pci_passthrough_instance_init(Object *obj)
     PCI_DEVICE(obj)->cap_present |= QEMU_PCI_CAP_EXPRESS;
 }
 
+void xen_igd_reserve_slot(PCIBus *pci_bus)
+{
+    if (!xen_igd_gfx_pt_enabled()) {
+        return;
+    }
+
+    XEN_PT_LOG(0, "Reserving PCI slot 2 for IGD\n");
+    pci_bus->slot_reserved_mask |= XEN_PCI_IGD_SLOT_MASK;
+}
+
+static void xen_igd_clear_slot(DeviceState *qdev, Error **errp)
+{
+    ERRP_GUARD();
+    PCIDevice *pci_dev = (PCIDevice *)qdev;
+    XenPCIPassthroughState *s = XEN_PT_DEVICE(pci_dev);
+    XenPTDeviceClass *xpdc = XEN_PT_DEVICE_GET_CLASS(s);
+    PCIBus *pci_bus = pci_get_bus(pci_dev);
+
+    xen_host_pci_device_get(&s->real_device,
+                            s->hostaddr.domain, s->hostaddr.bus,
+                            s->hostaddr.slot, s->hostaddr.function,
+                            errp);
+    if (*errp) {
+        error_append_hint(errp, "Failed to \"open\" the real pci device");
+        return;
+    }
+
+    if (!(pci_bus->slot_reserved_mask & XEN_PCI_IGD_SLOT_MASK)) {
+        xpdc->pci_qdev_realize(qdev, errp);
+        return;
+    }
+
+    if (is_igd_vga_passthrough(&s->real_device) &&
+        s->real_device.domain == XEN_PCI_IGD_DOMAIN &&
+        s->real_device.bus == XEN_PCI_IGD_BUS &&
+        s->real_device.dev == XEN_PCI_IGD_DEV &&
+        s->real_device.func == XEN_PCI_IGD_FN &&
+        s->real_device.vendor_id == PCI_VENDOR_ID_INTEL) {
+        pci_bus->slot_reserved_mask &= ~XEN_PCI_IGD_SLOT_MASK;
+        XEN_PT_LOG(pci_dev, "Intel IGD found, using slot 2\n");
+    }
+    xpdc->pci_qdev_realize(qdev, errp);
+}
+
 static void xen_pci_passthrough_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
     PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
 
+    XenPTDeviceClass *xpdc = XEN_PT_DEVICE_CLASS(klass);
+    xpdc->pci_qdev_realize = dc->realize;
+    dc->realize = xen_igd_clear_slot;
     k->realize = xen_pt_realize;
     k->exit = xen_pt_unregister_device;
     k->config_read = xen_pt_pci_read_config;
@@ -977,6 +1018,7 @@ static const TypeInfo xen_pci_passthrough_info = {
     .instance_size = sizeof(XenPCIPassthroughState),
     .instance_finalize = xen_pci_passthrough_finalize,
     .class_init = xen_pci_passthrough_class_init,
+    .class_size = sizeof(XenPTDeviceClass),
     .instance_init = xen_pci_passthrough_instance_init,
     .interfaces = (InterfaceInfo[]) {
         { INTERFACE_CONVENTIONAL_PCI_DEVICE },
diff --git a/hw/xen/xen_pt.h b/hw/xen/xen_pt.h
index e7c4316a7d..292bdf7499 100644
--- a/hw/xen/xen_pt.h
+++ b/hw/xen/xen_pt.h
@@ -41,7 +41,20 @@ typedef struct XenPTReg XenPTReg;
 #define TYPE_XEN_PT_DEVICE "xen-pci-passthrough"
 OBJECT_DECLARE_SIMPLE_TYPE(XenPCIPassthroughState, XEN_PT_DEVICE)
 
+#define XEN_PT_DEVICE_CLASS(klass) \
+    OBJECT_CLASS_CHECK(XenPTDeviceClass, klass, TYPE_XEN_PT_DEVICE)
+#define XEN_PT_DEVICE_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(XenPTDeviceClass, obj, TYPE_XEN_PT_DEVICE)
+
+typedef void (*XenPTQdevRealize)(DeviceState *qdev, Error **errp);
+
+typedef struct XenPTDeviceClass {
+    PCIDeviceClass parent_class;
+    XenPTQdevRealize pci_qdev_realize;
+} XenPTDeviceClass;
+
 uint32_t igd_read_opregion(XenPCIPassthroughState *s);
+void xen_igd_reserve_slot(PCIBus *pci_bus);
 void igd_write_opregion(XenPCIPassthroughState *s, uint32_t val);
 void xen_igd_passthrough_isa_bridge_create(XenPCIPassthroughState *s,
                                            XenHostPCIDevice *dev);
@@ -76,6 +89,13 @@ typedef int (*xen_pt_conf_byte_read)
 
 #define XEN_PCI_INTEL_OPREGION 0xfc
 
+#define XEN_PCI_IGD_DOMAIN 0
+#define XEN_PCI_IGD_BUS 0
+#define XEN_PCI_IGD_DEV 2
+#define XEN_PCI_IGD_FN 0
+#define XEN_PCI_IGD_SLOT_MASK \
+    (1UL << PCI_SLOT(PCI_DEVFN(XEN_PCI_IGD_DEV, XEN_PCI_IGD_FN)))
+
 typedef enum {
     XEN_PT_GRP_TYPE_HARDWIRED = 0,  /* 0 Hardwired reg group */
     XEN_PT_GRP_TYPE_EMU,            /* emul reg group */
diff --git a/hw/xen/xen_pt_stub.c b/hw/xen/xen_pt_stub.c
index 2d8cac8d54..5c108446a8 100644
--- a/hw/xen/xen_pt_stub.c
+++ b/hw/xen/xen_pt_stub.c
@@ -20,3 +20,7 @@ void xen_igd_gfx_pt_set(bool value, Error **errp)
         error_setg(errp, "Xen PCI passthrough support not built in");
     }
 }
+
+void xen_igd_reserve_slot(PCIBus *pci_bus)
+{
+}
diff --git a/include/hw/arm/boot.h b/include/hw/arm/boot.h
index f18cc3064f..80c492d742 100644
--- a/include/hw/arm/boot.h
+++ b/include/hw/arm/boot.h
@@ -183,4 +183,53 @@ void arm_write_secure_board_setup_dummy_smc(ARMCPU *cpu,
                                             const struct arm_boot_info *info,
                                             hwaddr mvbar_addr);
 
+typedef enum {
+    FIXUP_NONE = 0,     /* do nothing */
+    FIXUP_TERMINATOR,   /* end of insns */
+    FIXUP_BOARDID,      /* overwrite with board ID number */
+    FIXUP_BOARD_SETUP,  /* overwrite with board specific setup code address */
+    FIXUP_ARGPTR_LO,    /* overwrite with pointer to kernel args */
+    FIXUP_ARGPTR_HI,    /* overwrite with pointer to kernel args (high half) */
+    FIXUP_ENTRYPOINT_LO, /* overwrite with kernel entry point */
+    FIXUP_ENTRYPOINT_HI, /* overwrite with kernel entry point (high half) */
+    FIXUP_GIC_CPU_IF,   /* overwrite with GIC CPU interface address */
+    FIXUP_BOOTREG,      /* overwrite with boot register address */
+    FIXUP_DSB,          /* overwrite with correct DSB insn for cpu */
+    FIXUP_MAX,
+} FixupType;
+
+typedef struct ARMInsnFixup {
+    uint32_t insn;
+    FixupType fixup;
+} ARMInsnFixup;
+
+/**
+ * arm_write_bootloader - write a bootloader to guest memory
+ * @name: name of the bootloader blob
+ * @as: AddressSpace to write the bootloader
+ * @addr: guest address to write it
+ * @insns: the blob to be loaded
+ * @fixupcontext: context to be used for any fixups in @insns
+ *
+ * Write a bootloader to guest memory at address @addr in the address
+ * space @as. @name is the name to use for the resulting ROM blob, so
+ * it should be unique in the system and reasonably identifiable for debugging.
+ *
+ * @insns must be an array of ARMInsnFixup structs, each of which has
+ * one 32-bit value to be written to the guest memory, and a fixup to be
+ * applied to the value. FIXUP_NONE (do nothing) is value 0, so effectively
+ * the fixup is optional when writing a struct initializer.
+ * The final entry in the array must be { 0, FIXUP_TERMINATOR }.
+ *
+ * All other supported fixup types have the semantics "ignore insn
+ * and instead use the value from the array element @fixupcontext[fixup]".
+ * The caller should therefore provide @fixupcontext as an array of
+ * size FIXUP_MAX whose elements have been initialized for at least
+ * the entries that @insns refers to.
+ */
+void arm_write_bootloader(const char *name,
+                          AddressSpace *as, hwaddr addr,
+                          const ARMInsnFixup *insns,
+                          const uint32_t *fixupcontext);
+
 #endif /* HW_ARM_BOOT_H */
diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h
index c95333514e..0c76e82626 100644
--- a/include/hw/i386/pc.h
+++ b/include/hw/i386/pc.h
@@ -128,9 +128,6 @@ struct PCMachineClass {
 
     /* create kvmclock device even when KVM PV features are not exposed */
     bool kvmclock_create_always;
-
-    /* skip passing an rng seed for legacy machines */
-    bool legacy_no_rng_seed;
 };
 
 #define TYPE_PC_MACHINE "generic-pc-machine"
diff --git a/include/hw/i386/x86.h b/include/hw/i386/x86.h
index 62fa5774f8..df82c5fd42 100644
--- a/include/hw/i386/x86.h
+++ b/include/hw/i386/x86.h
@@ -126,8 +126,7 @@ void x86_bios_rom_init(MachineState *ms, const char *default_firmware,
 void x86_load_linux(X86MachineState *x86ms,
                     FWCfgState *fw_cfg,
                     int acpi_data_size,
-                    bool pvh_enabled,
-                    bool legacy_no_rng_seed);
+                    bool pvh_enabled);
 
 bool x86_machine_is_smm_enabled(const X86MachineState *x86ms);
 bool x86_machine_is_acpi_enabled(const X86MachineState *x86ms);
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
index 2e503904dc..c1f81a5f13 100644
--- a/include/hw/nvram/fw_cfg.h
+++ b/include/hw/nvram/fw_cfg.h
@@ -117,28 +117,6 @@ struct FWCfgMemState {
  */
 void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len);
 
-/**
- * fw_cfg_add_bytes_callback:
- * @s: fw_cfg device being modified
- * @key: selector key value for new fw_cfg item
- * @select_cb: callback function when selecting
- * @write_cb: callback function after a write
- * @callback_opaque: argument to be passed into callback function
- * @data: pointer to start of item data
- * @len: size of item data
- * @read_only: is file read only
- *
- * Add a new fw_cfg item, available by selecting the given key, as a raw
- * "blob" of the given size. The data referenced by the starting pointer
- * is only linked, NOT copied, into the data structure of the fw_cfg device.
- */
-void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
-                               FWCfgCallback select_cb,


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 16:00:09 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 16:00:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681050.1059593 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHg8-0008Dn-PJ; Wed, 14 Feb 2024 16:00:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681050.1059593; Wed, 14 Feb 2024 16:00:08 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHg8-0008Df-MM; Wed, 14 Feb 2024 16:00:08 +0000
Received: by outflank-mailman (input) for mailman id 681050;
 Wed, 14 Feb 2024 16:00:07 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHg7-0008DY-Ef
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 16:00:07 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHg7-0007SV-C9
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 16:00:07 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHg7-0004k9-B6
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 16:00:07 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=RQ9bjjvMRkZiSk4sjSgbizbPB3WX7Cwt0dI4RMeiFcg=; b=qCKqpOgu3+z3flLsf5XVdyosbm
	cs2Ht2CqLGlwPTbdIFe77pHtZbo9+g85fSuj4rG5YOaQE3Vn/t6Mzn6juxg+c+VoaM7vOo4EkRiFq
	o3QgCv+xaS4sYfzPJH55G0EGXWDOwnoPuyg9wc4HVwiTOJuvYV+9KqQf8SCtrjfAOtKM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.18] thread-pool: signal "request_cond" while locked
Message-Id: <E1raHg7-0004k9-B6@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 16:00:07 +0000

commit 690346043db881debcace7d22249f3355527c5f9
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Fri Jul 14 16:27:20 2023 +0100
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Tue Aug 1 19:02:38 2023 +0100

    thread-pool: signal "request_cond" while locked
    
    thread_pool_free() might have been called on the `pool`, which would
    be a reason for worker_thread() to quit. In this case,
    `pool->request_cond` is been destroyed.
    
    If worker_thread() didn't managed to signal `request_cond` before it
    been destroyed by thread_pool_free(), we got:
        util/qemu-thread-posix.c:198: qemu_cond_signal: Assertion `cond->initialized' failed.
    
    One backtrace:
        __GI___assert_fail (assertion=0x55555614abcb "cond->initialized", file=0x55555614ab88 "util/qemu-thread-posix.c", line=198,
            function=0x55555614ad80 <__PRETTY_FUNCTION__.17104> "qemu_cond_signal") at assert.c:101
        qemu_cond_signal (cond=0x7fffb800db30) at util/qemu-thread-posix.c:198
        worker_thread (opaque=0x7fffb800dab0) at util/thread-pool.c:129
        qemu_thread_start (args=0x7fffb8000b20) at util/qemu-thread-posix.c:505
        start_thread (arg=<optimized out>) at pthread_create.c:486
    
    Reported here:
        https://lore.kernel.org/all/ZJwoK50FcnTSfFZ8@MacBook-Air-de-Roger.local/T/#u
    
    To avoid issue, keep lock while sending a signal to `request_cond`.
    
    Fixes: 900fa208f506 ("thread-pool: replace semaphore with condition variable")
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20230714152720.5077-1-anthony.perard@citrix.com>
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    (cherry picked from commit f4f71363fcdb1092ff64d2bba6f9af39570c2f2b)
---
 util/thread-pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/thread-pool.c b/util/thread-pool.c
index 31113b5860..39accc9ebe 100644
--- a/util/thread-pool.c
+++ b/util/thread-pool.c
@@ -120,13 +120,13 @@ static void *worker_thread(void *opaque)
 
     pool->cur_threads--;
     qemu_cond_signal(&pool->worker_stopped);
-    qemu_mutex_unlock(&pool->lock);
 
     /*
      * Wake up another thread, in case we got a wakeup but decided
      * to exit due to pool->cur_threads > pool->max_threads.
      */
     qemu_cond_signal(&pool->request_cond);
+    qemu_mutex_unlock(&pool->lock);
     return NULL;
 }
 
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 16:00:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 16:00:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681049.1059589 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHg6-00087z-NQ; Wed, 14 Feb 2024 16:00:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681049.1059589; Wed, 14 Feb 2024 16:00:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHg6-00087W-Kd; Wed, 14 Feb 2024 16:00:06 +0000
Received: by outflank-mailman (input) for mailman id 681049;
 Wed, 14 Feb 2024 16:00:05 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHg5-00084q-J7
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 16:00:05 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHg5-0007NQ-IS
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 16:00:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHg5-0004Xl-Gv
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 16:00:05 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=jXjtbbyqm4ucey8w+XBIBL7cd/58iqMJfGPdc1XAvdM=; b=mZJpYulcbZtO1VB5tPZaXgIdEx
	AS6DBaEakAOUWfMCF8HI8QnOSgr7+lqvDK5+Ufr0zZhHT8d2Ije/gGBVscdMNpUo2AtyTt3ZJrIZ4
	1r/NCmaTMW0hbwb+ihatvk3yu5SHRAZnfDS0du0Lqt72xByJFA1rlt+jdsG0tpR5MsI4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging] thread-pool: signal "request_cond" while locked
Message-Id: <E1raHg5-0004Xl-Gv@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 16:00:05 +0000

commit 690346043db881debcace7d22249f3355527c5f9
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Fri Jul 14 16:27:20 2023 +0100
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Tue Aug 1 19:02:38 2023 +0100

    thread-pool: signal "request_cond" while locked
    
    thread_pool_free() might have been called on the `pool`, which would
    be a reason for worker_thread() to quit. In this case,
    `pool->request_cond` is been destroyed.
    
    If worker_thread() didn't managed to signal `request_cond` before it
    been destroyed by thread_pool_free(), we got:
        util/qemu-thread-posix.c:198: qemu_cond_signal: Assertion `cond->initialized' failed.
    
    One backtrace:
        __GI___assert_fail (assertion=0x55555614abcb "cond->initialized", file=0x55555614ab88 "util/qemu-thread-posix.c", line=198,
            function=0x55555614ad80 <__PRETTY_FUNCTION__.17104> "qemu_cond_signal") at assert.c:101
        qemu_cond_signal (cond=0x7fffb800db30) at util/qemu-thread-posix.c:198
        worker_thread (opaque=0x7fffb800dab0) at util/thread-pool.c:129
        qemu_thread_start (args=0x7fffb8000b20) at util/qemu-thread-posix.c:505
        start_thread (arg=<optimized out>) at pthread_create.c:486
    
    Reported here:
        https://lore.kernel.org/all/ZJwoK50FcnTSfFZ8@MacBook-Air-de-Roger.local/T/#u
    
    To avoid issue, keep lock while sending a signal to `request_cond`.
    
    Fixes: 900fa208f506 ("thread-pool: replace semaphore with condition variable")
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
    Message-Id: <20230714152720.5077-1-anthony.perard@citrix.com>
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    (cherry picked from commit f4f71363fcdb1092ff64d2bba6f9af39570c2f2b)
---
 util/thread-pool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util/thread-pool.c b/util/thread-pool.c
index 31113b5860..39accc9ebe 100644
--- a/util/thread-pool.c
+++ b/util/thread-pool.c
@@ -120,13 +120,13 @@ static void *worker_thread(void *opaque)
 
     pool->cur_threads--;
     qemu_cond_signal(&pool->worker_stopped);
-    qemu_mutex_unlock(&pool->lock);
 
     /*
      * Wake up another thread, in case we got a wakeup but decided
      * to exit due to pool->cur_threads > pool->max_threads.
      */
     qemu_cond_signal(&pool->request_cond);
+    qemu_mutex_unlock(&pool->lock);
     return NULL;
 }
 
--
generated by git-patchbot for /home/xen/git/qemu-xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 16:11:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 16:11:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681073.1059650 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHqr-0004BH-1A; Wed, 14 Feb 2024 16:11:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681073.1059650; Wed, 14 Feb 2024 16:11:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHqq-0004BA-UC; Wed, 14 Feb 2024 16:11:12 +0000
Received: by outflank-mailman (input) for mailman id 681073;
 Wed, 14 Feb 2024 16:11:11 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHqp-0004At-7L
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 16:11:11 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHqp-0007fV-6I
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 16:11:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHqp-00069a-5F
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 16:11:11 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=v/xJNqXtFVjWI+EoHtmMwvOZG+QUlothXfdhPC/uivI=; b=xFECHWRGTDsJxtcb1uPlCMWJ3B
	sXlOasscN9JJNR3Qt+Nx3XrhOd5KIIP9xiPxucGdNIy7SrlKeyVJiOsuO6rghSQAWI09xm1rq0mMj
	98nh4YC/+vKgJC9QS91V6zuoD7+RvxKnB6WMDxHAJso74LXyzhAKPLdUXePfvheLiqtU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging-4.18] Merge tag 'v8.0.4' into 'staging'
Message-Id: <E1raHqp-00069a-5F@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 16:11:11 +0000

=== This changeset includes merge from high-traffic branch ===
Commits on that branch are not reported individually.

commit 0df9387c8983e1b1e72d8c574356f572342c03e6
Merge: 83a9cdbd65ceb4a443630aed011a00ef217ed408 690346043db881debcace7d22249f3355527c5f9
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Wed Aug 16 10:43:53 2023 +0100
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Wed Aug 16 10:43:53 2023 +0100

    Merge tag 'v8.0.4' into 'staging'
 .cirrus.yml                                        |   109 -
 .git-blame-ignore-revs                             |    21 +
 .gitlab-ci.d/base.yml                              |     9 +-
 .gitlab-ci.d/buildtest-template.yml                |    26 +-
 .gitlab-ci.d/buildtest.yml                         |   181 +-
 .gitlab-ci.d/cirrus.yml                            |     6 +-
 .gitlab-ci.d/cirrus/build.yml                      |     7 +-
 .gitlab-ci.d/cirrus/freebsd-12.vars                |     2 +-
 .gitlab-ci.d/cirrus/freebsd-13.vars                |     2 +-
 .gitlab-ci.d/cirrus/macos-12.vars                  |     2 +-
 .gitlab-ci.d/container-cross.yml                   |    22 +-
 .gitlab-ci.d/container-template.yml                |     9 +-
 .gitlab-ci.d/containers.yml                        |     4 +-
 .gitlab-ci.d/crossbuild-template.yml               |    23 +-
 .gitlab-ci.d/crossbuilds.yml                       |    46 +-
 .gitlab-ci.d/custom-runners.yml                    |    12 +
 .../custom-runners/centos-stream-8-x86_64.yml      |    18 +-
 .gitlab-ci.d/custom-runners/ubuntu-20.04-s390x.yml |    23 +-
 .../custom-runners/ubuntu-22.04-aarch32.yml        |     4 +-
 .../custom-runners/ubuntu-22.04-aarch64.yml        |    25 +-
 .gitlab-ci.d/edk2.yml                              |    85 -
 .gitlab-ci.d/edk2/Dockerfile                       |    27 -
 .gitlab-ci.d/opensbi.yml                           |     4 +-
 .gitlab-ci.d/opensbi/Dockerfile                    |     1 +
 .gitlab-ci.d/qemu-project.yml                      |     1 -
 .gitlab-ci.d/static_checks.yml                     |     4 +-
 .gitlab-ci.d/windows.yml                           |    45 +-
 .gitlab/issue_templates/bug.md                     |    16 +-
 .gitmodules                                        |     3 -
 .mailmap                                           |     2 +
 .travis.yml                                        |    59 +-
 MAINTAINERS                                        |   204 +-
 Makefile                                           |     6 +-
 VERSION                                            |     2 +-
 accel/accel-blocker.c                              |   154 +
 accel/accel-softmmu.c                              |     2 +-
 accel/kvm/kvm-accel-ops.c                          |     8 +
 accel/kvm/kvm-all.c                                |   135 +-
 accel/kvm/kvm-cpus.h                               |     4 +-
 accel/meson.build                                  |    11 +-
 accel/stubs/tcg-stub.c                             |     3 +-
 accel/tcg/atomic_common.c.inc                      |    45 +
 accel/tcg/cpu-exec-common.c                        |     3 +
 accel/tcg/cpu-exec.c                               |   301 +-
 accel/tcg/cputlb.c                                 |   217 +-
 accel/tcg/debuginfo.c                              |    96 +
 accel/tcg/debuginfo.h                              |    79 +
 accel/tcg/hmp.c                                    |    14 -
 accel/tcg/internal.h                               |    94 +-
 accel/tcg/meson.build                              |     4 +-
 accel/tcg/monitor.c                                |   106 +
 accel/tcg/perf.c                                   |   375 +
 accel/tcg/perf.h                                   |    49 +
 accel/tcg/plugin-gen.c                             |   113 +-
 accel/tcg/plugin-helpers.h                         |     4 +-
 accel/tcg/tb-jmp-cache.h                           |    43 +-
 accel/tcg/tb-maint.c                               |  1070 +-
 accel/tcg/tcg-accel-ops.c                          |    20 +-
 accel/tcg/tcg-all.c                                |     2 +-
 accel/tcg/tcg-runtime.h                            |    11 +
 accel/tcg/trace-events                             |     4 +
 accel/tcg/translate-all.c                          |   847 +-
 accel/tcg/translator.c                             |    51 +-
 accel/tcg/user-exec-stub.c                         |     2 +-
 accel/tcg/user-exec.c                              |   759 +-
 accel/xen/xen-all.c                                |   100 +-
 audio/alsaaudio.c                                  |    29 +-
 audio/audio-hmp-cmds.c                             |    83 +
 audio/audio.c                                      |   430 +-
 audio/audio_int.h                                  |    22 +-
 audio/audio_legacy.c                               |    58 +-
 audio/audio_template.h                             |   125 +-
 audio/dbusaudio.c                                  |     7 +-
 audio/meson.build                                  |     1 +
 audio/mixeng.c                                     |    87 +-
 audio/mixeng.h                                     |     2 +
 audio/ossaudio.c                                   |     8 +-
 audio/paaudio.c                                    |    12 +-
 audio/rate_template.h                              |    21 +-
 audio/sndioaudio.c                                 |     4 +-
 audio/wavaudio.c                                   |     2 +-
 authz/listfile.c                                   |     1 -
 backends/cryptodev-builtin.c                       |    42 +-
 backends/cryptodev-hmp-cmds.c                      |    54 +
 backends/cryptodev-lkcf.c                          |    19 +-
 backends/cryptodev-vhost-user.c                    |    13 +-
 backends/cryptodev-vhost.c                         |     5 +-
 backends/cryptodev.c                               |   443 +-
 backends/hostmem-epc.c                             |     2 +-
 backends/hostmem.c                                 |    19 +-
 backends/meson.build                               |     1 +
 backends/rng.c                                     |     1 -
 backends/tpm/tpm_emulator.c                        |     9 +-
 backends/tpm/tpm_ioctl.h                           |     2 -
 backends/tpm/tpm_passthrough.c                     |     2 -
 backends/vhost-user.c                              |    12 -
 block.c                                            |   581 +-
 block/amend.c                                      |     1 +
 block/backup.c                                     |     5 +-
 block/blkdebug.c                                   |    33 +-
 block/blkio.c                                      |    17 +-
 block/blklogwrites.c                               |    40 +-
 block/blkreplay.c                                  |    29 +-
 block/blkverify.c                                  |    10 +-
 block/block-backend.c                              |   145 +-
 block/block-copy.c                                 |    45 +-
 block/block-gen.h                                  |    11 +-
 block/bochs.c                                      |     3 +-
 block/cloop.c                                      |     1 +
 block/commit.c                                     |    14 +-
 block/copy-before-write.c                          |    37 +-
 block/copy-on-read.c                               |    58 +-
 block/coroutines.h                                 |    23 +-
 block/create.c                                     |     9 +-
 block/crypto.c                                     |    55 +-
 block/curl.c                                       |    17 +-
 block/dirty-bitmap.c                               |    93 +-
 block/dmg-lzfse.c                                  |     5 +
 block/dmg.c                                        |     1 +
 block/export/export.c                              |     8 +-
 block/export/fuse.c                                |    14 +-
 block/export/vduse-blk.c                           |     6 +-
 block/export/virtio-blk-handler.c                  |     7 +-
 block/file-posix.c                                 |   212 +-
 block/file-win32.c                                 |    26 +-
 block/filter-compress.c                            |    52 +-
 block/gluster.c                                    |    27 +-
 block/graph-lock.c                                 |   302 +
 block/io.c                                         |   565 +-
 block/iscsi.c                                      |    49 +-
 block/meson.build                                  |     4 +
 block/mirror.c                                     |    67 +-
 block/monitor/bitmap-qmp-cmds.c                    |     2 +
 block/monitor/block-hmp-cmds.c                     |    72 +-
 block/nbd.c                                        |     8 +-
 block/nfs.c                                        |    29 +-
 block/null.c                                       |    14 +-
 block/nvme.c                                       |    15 +-
 block/parallels-ext.c                              |     2 +
 block/parallels.c                                  |    51 +-
 block/preallocate.c                                |    54 +-
 block/progress_meter.c                             |     2 +
 block/qapi-sysemu.c                                |    74 +-
 block/qapi.c                                       |   381 +-
 block/qcow.c                                       |    79 +-
 block/qcow2-bitmap.c                               |     2 +
 block/qcow2-cache.c                                |     1 +
 block/qcow2-cluster.c                              |    18 +-
 block/qcow2-refcount.c                             |     3 +-
 block/qcow2-threads.c                              |     1 +
 block/qcow2.c                                      |   225 +-
 block/qcow2.h                                      |    27 +-
 block/qed-check.c                                  |     4 +-
 block/qed-table.c                                  |    11 +-
 block/qed.c                                        |   157 +-
 block/qed.h                                        |    45 +-
 block/quorum.c                                     |    70 +-
 block/raw-format.c                                 |   101 +-
 block/rbd.c                                        |   215 +-
 block/replication.c                                |    29 +-
 block/snapshot-access.c                            |     8 +-
 block/ssh.c                                        |     7 +-
 block/stream.c                                     |    67 +-
 block/throttle.c                                   |    50 +-
 block/vdi.c                                        |    36 +-
 block/vhdx-log.c                                   |     1 +
 block/vhdx.c                                       |    41 +-
 block/vmdk.c                                       |   232 +-
 block/vpc.c                                        |    34 +-
 block/vvfat.c                                      |     4 +-
 block/win32-aio.c                                  |     1 +
 block/write-threshold.c                            |     1 +
 blockdev-nbd.c                                     |     9 +-
 blockdev.c                                         |   215 +-
 blockjob.c                                         |     6 +-
 bsd-user/arm/signal.c                              |     1 +
 bsd-user/arm/target_arch_cpu.c                     |     2 +
 bsd-user/bsd-proc.h                                |     4 -
 bsd-user/elfload.c                                 |     2 +-
 bsd-user/freebsd/os-sys.c                          |   572 +
 bsd-user/freebsd/os-syscall.c                      |    19 +-
 bsd-user/i386/signal.c                             |     1 +
 bsd-user/i386/target_arch_cpu.c                    |     3 +-
 bsd-user/main.c                                    |    15 +-
 bsd-user/mmap.c                                    |    10 +-
 bsd-user/qemu.h                                    |    11 +-
 bsd-user/signal.c                                  |     1 +
 bsd-user/strace.c                                  |     1 -
 bsd-user/x86_64/signal.c                           |     1 +
 bsd-user/x86_64/target_arch_cpu.c                  |     3 +-
 chardev/baum.c                                     |    66 +-
 chardev/char-fd.c                                  |     2 +-
 chardev/char-file.c                                |     4 +-
 chardev/char-hmp-cmds.c                            |   220 +
 chardev/char-parallel.c                            |    15 +-
 chardev/char-pipe.c                                |     8 +-
 chardev/char-pty.c                                 |     4 +-
 chardev/char-socket.c                              |    14 +-
 chardev/char-udp.c                                 |     1 -
 chardev/char.c                                     |    57 +-
 chardev/meson.build                                |    11 +-
 chardev/spice.c                                    |     2 -
 common-user/host/ppc/safe-syscall.inc.S            |   107 +
 configs/devices/arm-softmmu/default.mak            |     1 +
 configs/devices/mips-softmmu/common.mak            |     6 -
 configs/targets/aarch64-linux-user.mak             |     2 +-
 configs/targets/aarch64-softmmu.mak                |     2 +-
 configs/targets/aarch64_be-linux-user.mak          |     2 +-
 configs/targets/microblaze-linux-user.mak          |     1 +
 configs/targets/microblaze-softmmu.mak             |     1 +
 configs/targets/microblazeel-linux-user.mak        |     1 +
 configs/targets/microblazeel-softmmu.mak           |     1 +
 configs/targets/nios2-softmmu.mak                  |     1 +
 configure                                          |   256 +-
 contrib/elf2dmp/addrspace.c                        |     1 +
 contrib/elf2dmp/main.c                             |   108 +-
 contrib/elf2dmp/pe.h                               |   115 +-
 contrib/gitdm/domain-map                           |    11 +-
 contrib/gitdm/filetypes.txt                        |     3 +-
 contrib/gitdm/group-map-alibaba                    |     7 +
 contrib/gitdm/group-map-amd                        |     8 +
 contrib/gitdm/group-map-facebook                   |     5 +
 contrib/gitdm/group-map-ibm                        |     1 +
 contrib/gitdm/group-map-individuals                |     5 +
 contrib/plugins/cache.c                            |     8 +-
 contrib/vhost-user-blk/vhost-user-blk.c            |     6 +-
 cpu.c                                              |    97 +-
 cpus-common.c                                      |    84 +-
 crypto/afalg.c                                     |     6 +-
 crypto/block-luks-priv.h                           |     2 -
 crypto/block-luks.c                                |    17 +-
 crypto/tlssession.c                                |    14 +
 disas.c                                            |     5 +-
 disas/meson.build                                  |     3 +-
 disas/riscv.c                                      |    35 +-
 docs/about/build-platforms.rst                     |    35 +-
 docs/about/deprecated.rst                          |   135 +-
 docs/about/emulation.rst                           |   190 +
 docs/about/index.rst                               |    17 +-
 docs/about/removed-features.rst                    |    87 +-
 docs/conf.py                                       |    17 -
 docs/config/mach-virt-graphical.cfg                |     4 +-
 docs/config/mach-virt-serial.cfg                   |     4 +-
 docs/config/q35-emulated.cfg                       |     2 +
 docs/config/q35-virtio-graphical.cfg               |     2 +
 docs/config/q35-virtio-serial.cfg                  |     2 +
 docs/devel/acpi-bits.rst                           |     3 +
 docs/devel/atomics.rst                             |    44 +-
 docs/devel/block-coroutine-wrapper.rst             |     6 +-
 docs/devel/fuzzing.rst                             |    22 +-
 docs/devel/index-tcg.rst                           |     1 +
 docs/devel/kconfig.rst                             |     2 +-
 docs/devel/migration.rst                           |    20 +-
 docs/devel/qapi-code-gen.rst                       |    45 +-
 docs/devel/style.rst                               |     7 +
 docs/devel/tcg-ops.rst                             |   965 ++
 docs/devel/tcg-plugins.rst                         |     2 +
 docs/devel/tcg.rst                                 |    25 +-
 docs/devel/testing.rst                             |    80 +-
 docs/devel/vfio-migration.rst                      |   112 +-
 docs/devel/writing-monitor-commands.rst            |    14 +-
 docs/interop/index.rst                             |     1 +
 docs/interop/live-block-operations.rst             |     2 +
 docs/interop/qemu-qmp-ref.rst                      |     2 +
 docs/interop/vhost-user.rst                        |    40 +-
 docs/interop/vnc-ledstate-Pseudo-encoding.txt      |    50 -
 docs/interop/vnc-ledstate-pseudo-encoding.rst      |    50 +
 docs/meson.build                                   |    12 +-
 docs/pcie.txt                                      |    16 +-
 docs/qdev-device-use.txt                           |     4 +-
 docs/sphinx/kerneldoc.py                           |     5 +
 docs/system/arm/aspeed.rst                         |     2 +
 docs/system/arm/cpu-features.rst                   |    76 +-
 docs/system/arm/cubieboard.rst                     |     1 +
 docs/system/arm/emulation.rst                      |     4 +
 docs/system/arm/nuvoton.rst                        |     2 +-
 docs/system/arm/orangepi.rst                       |     1 +
 docs/system/arm/stm32.rst                          |     1 +
 docs/system/arm/virt.rst                           |    18 +
 docs/system/device-emulation.rst                   |     1 +
 docs/system/devices/igb.rst                        |    71 +
 docs/system/i386/xen.rst                           |    92 +
 docs/system/index.rst                              |     4 +-
 docs/system/introduction.rst                       |   220 +
 docs/system/loongarch/loongson3.rst                |   129 -
 docs/system/loongarch/virt.rst                     |   108 +
 docs/system/multi-process.rst                      |     2 +
 docs/system/ppc/ppce500.rst                        |    13 +
 docs/system/quickstart.rst                         |    21 -
 docs/system/s390x/pcidevices.rst                   |    41 +
 docs/system/target-i386.rst                        |     1 +
 docs/system/target-mips.rst                        |    14 -
 docs/system/target-s390x.rst                       |     1 +
 docs/tools/index.rst                               |     3 +-
 docs/tools/virtiofsd.rst                           |   403 -
 docs/user/index.rst                                |     2 +
 dump/dump-hmp-cmds.c                               |     2 +-
 dump/dump.c                                        |    48 +-
 dump/meson.build                                   |     6 +-
 dump/win_dump.c                                    |    39 +-
 dump/win_dump.h                                    |     5 +-
 ebpf/rss.bpf.skeleton.h                            |  1171 +-
 fsdev/p9array.h                                    |     2 -
 gdb-xml/aarch64-pauth.xml                          |    15 +
 gdb-xml/microblaze-core.xml                        |    67 +
 gdb-xml/microblaze-stack-protect.xml               |    12 +
 gdbstub/gdbstub.c                                  |  1661 +-
 gdbstub/internals.h                                |   218 +-
 gdbstub/meson.build                                |    36 +-
 gdbstub/softmmu.c                                  |   606 +-
 gdbstub/syscalls.c                                 |   205 +
 gdbstub/trace-events                               |     4 +-
 gdbstub/user-target.c                              |   283 +
 gdbstub/user.c                                     |   426 +-
 gitdm.config                                       |     3 +
 hmp-commands-info.hx                               |    14 +
 hmp-commands.hx                                    |    35 +-
 hw/9pfs/9p-local.c                                 |    40 +-
 hw/9pfs/9p-synth.c                                 |    22 +-
 hw/9pfs/9p-util.h                                  |    29 +-
 hw/9pfs/9p.c                                       |     2 -
 hw/9pfs/codir.c                                    |     1 -
 hw/9pfs/cofile.c                                   |     1 -
 hw/9pfs/cofs.c                                     |     1 -
 hw/9pfs/coth.h                                     |     2 +-
 hw/9pfs/coxattr.c                                  |     1 -
 hw/9pfs/meson.build                                |     2 +-
 hw/9pfs/xen-9p-backend.c                           |    32 +-
 hw/Kconfig                                         |     1 +
 hw/acpi/Kconfig                                    |    13 +-
 hw/acpi/acpi-pci-hotplug-stub.c                    |     9 +-
 hw/acpi/acpi-qmp-cmds.c                            |    30 +
 hw/acpi/acpi-stub.c                                |     4 +-
 hw/acpi/acpi-x86-stub.c                            |     5 +-
 hw/acpi/acpi_interface.c                           |    10 +
 hw/acpi/aml-build.c                                |     2 +-
 hw/acpi/core.c                                     |    14 +-
 hw/acpi/cpu.c                                      |     4 +-
 hw/acpi/erst.c                                     |     2 +-
 hw/acpi/ich9.c                                     |    39 +-
 hw/acpi/ich9_tco.c                                 |   275 +
 hw/acpi/memory_hotplug.c                           |     3 +-
 hw/acpi/meson.build                                |     7 +-
 hw/acpi/pci-bridge-stub.c                          |    20 +
 hw/acpi/pci-bridge.c                               |    37 +
 hw/acpi/pcihp.c                                    |   148 +-
 hw/acpi/piix4.c                                    |    35 +-
 hw/acpi/tco.c                                      |   260 -
 hw/acpi/trace-events                               |     2 +
 hw/acpi/vmgenid.c                                  |    18 -
 hw/alpha/alpha_sys.h                               |     1 -
 hw/alpha/dp264.c                                   |     1 -
 hw/alpha/pci.c                                     |     1 +
 hw/alpha/typhoon.c                                 |     2 +-
 hw/arm/Kconfig                                     |    14 +-
 hw/arm/allwinner-a10.c                             |    41 +
 hw/arm/allwinner-h3.c                              |    38 +-
 hw/arm/armsse.c                                    |     3 +-
 hw/arm/aspeed.c                                    |   276 +-
 hw/arm/aspeed_ast10x0.c                            |    83 +-
 hw/arm/aspeed_ast2600.c                            |    17 +-
 hw/arm/aspeed_eeprom.c                             |   127 +
 hw/arm/aspeed_eeprom.h                             |    25 +
 hw/arm/aspeed_soc.c                                |    18 +-
 hw/arm/bcm2836.c                                   |     9 +-
 hw/arm/boot.c                                      |    22 +-
 hw/arm/collie.c                                    |    27 +-
 hw/arm/cubieboard.c                                |    12 +
 hw/arm/exynos4210.c                                |     4 +-
 hw/arm/fby35.c                                     |     8 +-
 hw/arm/fsl-imx6ul.c                                |     2 +-
 hw/arm/fsl-imx7.c                                  |    41 +-
 hw/arm/gumstix.c                                   |    45 +-
 hw/arm/mainstone.c                                 |    37 +-
 hw/arm/meson.build                                 |    13 +-
 hw/arm/mps2-tz.c                                   |     2 +-
 hw/arm/mps2.c                                      |    41 +-
 hw/arm/msf2-som.c                                  |     5 +-
 hw/arm/musicpal.c                                  |    18 +-
 hw/arm/npcm7xx.c                                   |    25 +-
 hw/arm/npcm7xx_boards.c                            |    22 +-
 hw/arm/nseries.c                                   |    30 +-
 hw/arm/olimex-stm32-h405.c                         |    69 +
 hw/arm/omap1.c                                     |   115 +-
 hw/arm/omap2.c                                     |    40 +-
 hw/arm/omap_sx1.c                                  |    57 +-
 hw/arm/orangepi.c                                  |     1 +
 hw/arm/palm.c                                      |     4 +-
 hw/arm/pxa2xx.c                                    |     8 +-
 hw/arm/realview.c                                  |     2 +-
 hw/arm/sbsa-ref.c                                  |     6 +-
 hw/arm/smmu-common.c                               |    48 +-
 hw/arm/smmuv3-internal.h                           |     7 +
 hw/arm/smmuv3.c                                    |    94 +-
 hw/arm/spitz.c                                     |     6 +-
 hw/arm/stellaris.c                                 |    84 +-
 hw/arm/stm32f405_soc.c                             |     8 +
 hw/arm/strongarm.c                                 |    24 +-
 hw/arm/tosa.c                                      |     2 +-
 hw/arm/versatilepb.c                               |     8 +-
 hw/arm/vexpress.c                                  |    12 +-
 hw/arm/virt.c                                      |   437 +-
 hw/arm/xlnx-versal.c                               |     1 -
 hw/arm/z2.c                                        |    16 +-
 hw/audio/ac97.c                                    |    47 +-
 hw/audio/ac97.h                                    |    65 +
 hw/audio/cs4231a.c                                 |     5 +-
 hw/audio/es1370.c                                  |    12 +-
 hw/audio/gus.c                                     |     5 +-
 hw/audio/hda-codec.c                               |     7 +-
 hw/audio/sb16.c                                    |     7 +-
 hw/audio/trace-events                              |     6 +
 hw/audio/via-ac97.c                                |   455 +-
 hw/block/block.c                                   |    36 +-
 hw/block/dataplane/meson.build                     |     2 +-
 hw/block/dataplane/virtio-blk.c                    |    17 +-
 hw/block/dataplane/xen-block.c                     |    12 +-
 hw/block/fdc-isa.c                                 |     5 +-
 hw/block/fdc.c                                     |     4 +-
 hw/block/m25p80.c                                  |     7 +-
 hw/block/m25p80_sfdp.c                             |    40 +
 hw/block/m25p80_sfdp.h                             |     2 +
 hw/block/meson.build                               |     2 +-
 hw/block/nand.c                                    |   222 +-
 hw/block/onenand.c                                 |   128 +-
 hw/block/pflash_cfi01.c                            |     3 +-
 hw/block/tc58128.c                                 |   136 +-
 hw/block/virtio-blk.c                              |    49 +-
 hw/block/xen-block.c                               |    23 +-
 hw/char/cadence_uart.c                             |     6 +-
 hw/char/digic-uart.c                               |     4 +-
 hw/char/etraxfs_ser.c                              |     4 +-
 hw/char/ibex_uart.c                                |     1 +
 hw/char/meson.build                                |     2 +-
 hw/char/omap_uart.c                                |     7 +-
 hw/char/parallel.c                                 |    24 +-
 hw/char/pl011.c                                    |   110 +-
 hw/char/riscv_htif.c                               |   172 +-
 hw/char/serial-pci-multi.c                         |     2 +-
 hw/char/serial-pci.c                               |     2 +-
 hw/char/serial.c                                   |    68 +-
 hw/char/sifive_uart.c                              |     4 +-
 hw/char/xen_console.c                              |    50 +-
 hw/char/xilinx_uartlite.c                          |     4 +-
 hw/core/cpu-common.c                               |    10 +-
 hw/core/irq.c                                      |     9 +-
 hw/core/loader.c                                   |   147 +-
 hw/core/machine-hmp-cmds.c                         |   210 +-
 hw/core/machine-qmp-cmds.c                         |   175 +-
 hw/core/machine-smp.c                              |     4 +
 hw/core/machine.c                                  |    24 +-
 hw/core/nmi.c                                      |     3 +-
 hw/core/numa.c                                     |     8 +-
 hw/core/or-irq.c                                   |    18 +-
 hw/core/ptimer.c                                   |     2 +-
 hw/core/qdev-clock.c                               |     2 +-
 hw/core/qdev-properties-system.c                   |    34 +-
 hw/core/qdev.c                                     |    70 +-
 hw/core/sysbus.c                                   |     4 +-
 hw/core/trace-events                               |     6 -
 hw/cpu/meson.build                                 |     4 +-
 hw/cxl/cxl-cdat.c                                  |     2 +-
 hw/cxl/cxl-component-utils.c                       |    20 +-
 hw/cxl/cxl-device-utils.c                          |     2 +-
 hw/cxl/cxl-host.c                                  |    33 +-
 hw/cxl/cxl-mailbox-utils.c                         |    28 +-
 hw/display/Kconfig                                 |     2 +-
 hw/display/ati_int.h                               |     2 +-
 hw/display/bochs-display.c                         |     2 +-
 hw/display/cirrus_vga.c                            |     6 +-
 hw/display/g364fb.c                                |     4 +-
 hw/display/meson.build                             |    24 +-
 hw/display/omap_dss.c                              |    15 +-
 hw/display/omap_lcdc.c                             |     9 +-
 hw/display/qxl-render.c                            |     4 +-
 hw/display/qxl.c                                   |    28 +-
 hw/display/qxl.h                                   |     5 +-
 hw/display/sm501.c                                 |   562 +-
 hw/display/trace-events                            |     1 -
 hw/display/vga-pci.c                               |     2 +-
 hw/display/vga.c                                   |     8 +-
 hw/display/vhost-user-gpu.c                        |    19 +
 hw/display/virtio-gpu-udmabuf.c                    |     2 +-
 hw/display/virtio-gpu-virgl.c                      |     1 +
 hw/display/virtio-vga.c                            |    15 +-
 hw/display/virtio-vga.h                            |     2 +-
 hw/display/vmware_vga.c                            |     6 +-
 hw/display/xenfb.c                                 |    32 +-
 hw/dma/etraxfs_dma.c                               |   864 +-
 hw/dma/i82374.c                                    |     2 +-
 hw/dma/omap_dma.c                                  |    15 +-
 hw/dma/pl330.c                                     |    14 +-
 hw/dma/xilinx_axidma.c                             |     4 +-
 hw/dma/xlnx_csu_dma.c                              |     4 +-
 hw/gpio/max7310.c                                  |    27 +-
 hw/gpio/omap_gpio.c                                |    48 +-
 hw/hppa/machine.c                                  |     3 +-
 hw/hyperv/syndbg.c                                 |     6 +-
 hw/hyperv/vmbus.c                                  |    14 +-
 hw/i2c/Kconfig                                     |     6 +-
 hw/i2c/allwinner-i2c.c                             |   479 +
 hw/i2c/arm_sbcon_i2c.c                             |   107 +
 hw/i2c/aspeed_i2c.c                                |     2 +
 hw/i2c/bitbang_i2c.c                               |    82 +-
 hw/i2c/core.c                                      |    37 +-
 hw/i2c/meson.build                                 |     5 +-
 hw/i2c/mpc_i2c.c                                   |     4 +-
 hw/i2c/pmbus_device.c                              |     8 +-
 hw/i2c/smbus_ich9.c                                |    44 +-
 hw/i2c/trace-events                                |    12 +
 hw/i2c/versatile_i2c.c                             |   112 -
 hw/i386/Kconfig                                    |    10 +-
 hw/i386/acpi-build.c                               |   418 +-
 hw/i386/acpi-common.c                              |     7 +-
 hw/i386/acpi-microvm.c                             |     3 +-
 hw/i386/amd_iommu.c                                |     2 +-
 hw/i386/intel_iommu.c                              |    41 +-
 hw/i386/intel_iommu_internal.h                     |     9 +
 hw/i386/kvm/i8259.c                                |     4 +-
 hw/i386/kvm/ioapic.c                               |     7 +-
 hw/i386/kvm/meson.build                            |    14 +
 hw/i386/kvm/trace-events                           |    20 +
 hw/i386/kvm/trace.h                                |     1 +
 hw/i386/kvm/xen-stubs.c                            |    44 +
 hw/i386/kvm/xen_evtchn.c                           |  2357 +++
 hw/i386/kvm/xen_evtchn.h                           |    88 +
 hw/i386/kvm/xen_gnttab.c                           |   547 +
 hw/i386/kvm/xen_gnttab.h                           |    26 +
 hw/i386/kvm/xen_overlay.c                          |   272 +
 hw/i386/kvm/xen_overlay.h                          |    26 +
 hw/i386/kvm/xen_xenstore.c                         |  1728 +++
 hw/i386/kvm/xen_xenstore.h                         |    20 +
 hw/i386/kvm/xenstore_impl.c                        |  1927 +++
 hw/i386/kvm/xenstore_impl.h                        |    63 +
 hw/i386/microvm.c                                  |    30 +-
 hw/i386/multiboot.c                                |     8 +-
 hw/i386/pc.c                                       |   129 +-
 hw/i386/pc_piix.c                                  |    64 +-
 hw/i386/pc_q35.c                                   |    81 +-
 hw/i386/sgx.c                                      |    16 +-
 hw/i386/x86-iommu.c                                |     2 +-
 hw/i386/x86.c                                      |    27 +-
 hw/i386/xen/meson.build                            |     5 +-
 hw/i386/xen/xen-hvm.c                              |    54 +-
 hw/i386/xen/xen-mapcache.c                         |    18 +-
 hw/i386/xen/xen_platform.c                         |    65 +-
 hw/i386/xen/xen_pvdevice.c                         |     2 +-
 hw/ide/ahci.c                                      |    13 +-
 hw/ide/ahci_internal.h                             |     2 +-
 hw/ide/atapi.c                                     |    13 +-
 hw/ide/cmd646.c                                    |    32 +-
 hw/ide/core.c                                      |   207 +-
 hw/ide/ich.c                                       |     1 +
 hw/ide/ioport.c                                    |    10 -
 hw/ide/isa.c                                       |    22 +-
 hw/ide/macio.c                                     |    15 +-
 hw/ide/microdrive.c                                |   369 +-
 hw/ide/mmio.c                                      |    37 +-
 hw/ide/pci.c                                       |    11 +-
 hw/ide/piix.c                                      |    50 +-
 hw/ide/qdev.c                                      |    34 +-
 hw/ide/sii3112.c                                   |     4 +-
 hw/ide/trace-events                                |     3 +-
 hw/ide/via.c                                       |    16 +-
 hw/input/adb.c                                     |     2 +-
 hw/input/ads7846.c                                 |    54 +-
 hw/input/ps2.c                                     |    51 +-
 hw/input/tsc2005.c                                 |     2 +-
 hw/input/tsc210x.c                                 |     4 +-
 hw/intc/Kconfig                                    |     3 +
 hw/intc/apic.c                                     |     6 +-
 hw/intc/apic_common.c                              |    30 +-
 hw/intc/arm_gic_common.c                           |     7 +-
 hw/intc/arm_gic_kvm.c                              |    14 +-
 hw/intc/arm_gicv3_common.c                         |     7 +-
 hw/intc/arm_gicv3_cpuif.c                          |    18 +-
 hw/intc/arm_gicv3_dist.c                           |    12 +-
 hw/intc/arm_gicv3_its.c                            |    28 +-
 hw/intc/arm_gicv3_its_common.c                     |     7 +-
 hw/intc/arm_gicv3_its_kvm.c                        |    14 +-
 hw/intc/arm_gicv3_kvm.c                            |    14 +-
 hw/intc/arm_gicv3_redist.c                         |     8 +-
 hw/intc/armv7m_nvic.c                              |    64 +-
 hw/intc/exynos4210_combiner.c                      |    10 +-
 hw/intc/i8259.c                                    |    25 +-
 hw/intc/i8259_common.c                             |    24 +-
 hw/intc/ioapic.c                                   |     7 +-
 hw/intc/ioapic_common.c                            |     4 +-
 hw/intc/ioapic_internal.h                          |   118 +
 hw/intc/kvm_irqcount.c                             |    49 +
 hw/intc/loongarch_pch_msi.c                        |    29 +-
 hw/intc/loongarch_pch_pic.c                        |    35 +-
 hw/intc/meson.build                                |    18 +-
 hw/intc/mips_gic.c                                 |     4 +-
 hw/intc/omap_intc.c                                |    38 +-
 hw/intc/pnv_xive.c                                 |     1 +
 hw/intc/pnv_xive2.c                                |     1 +
 hw/intc/riscv_aclint.c                             |    16 +-
 hw/intc/riscv_aplic.c                              |     4 +-
 hw/intc/riscv_imsic.c                              |     6 +-
 hw/intc/sifive_plic.c                              |    66 +-
 hw/intc/trace-events                               |     9 +-
 hw/intc/xics.c                                     |    11 +-
 hw/intc/xilinx_intc.c                              |    28 +-
 hw/ipack/tpci200.c                                 |     2 +-
 hw/ipmi/pci_ipmi_bt.c                              |     2 +-
 hw/ipmi/pci_ipmi_kcs.c                             |     2 +-
 hw/isa/Kconfig                                     |     4 +-
 hw/isa/i82378.c                                    |    19 +-
 hw/isa/isa-bus.c                                   |    42 +-
 hw/isa/lpc_ich9.c                                  |    47 +-
 hw/isa/piix3.c                                     |    22 +-
 hw/isa/piix4.c                                     |    41 +-
 hw/isa/trace-events                                |     5 +
 hw/isa/vt82c686.c                                  |    54 +-
 hw/loongarch/Kconfig                               |     1 +
 hw/loongarch/acpi-build.c                          |    23 +-
 hw/loongarch/virt.c                                |   105 +-
 hw/m68k/next-cube.c                                |     1 +
 hw/m68k/q800.c                                     |     1 +
 hw/m68k/virt.c                                     |    10 +-
 hw/mem/cxl_type3.c                                 |   320 +-
 hw/mem/cxl_type3_stubs.c                           |    17 +
 hw/mem/memory-device.c                             |     1 +
 hw/mem/meson.build                                 |     2 +
 hw/mem/pc-dimm.c                                   |     1 -
 hw/mem/sparse-mem.c                                |    14 +-
 hw/microblaze/petalogix_s3adsp1800_mmu.c           |     7 +-
 hw/mips/Kconfig                                    |     2 +
 hw/mips/bootloader.c                               |   139 +-
 hw/mips/boston.c                                   |     8 +-
 hw/mips/cps.c                                      |    35 +-
 hw/mips/fuloong2e.c                                |     2 +-
 hw/mips/gt64xxx_pci.c                              |  1234 --
 hw/mips/jazz.c                                     |     2 +-
 hw/mips/malta.c                                    |   405 +-
 hw/mips/meson.build                                |     2 +-
 hw/mips/mips_int.c                                 |    11 +-
 hw/mips/trace-events                               |     9 +-
 hw/misc/Kconfig                                    |    14 +-
 hw/misc/allwinner-a10-ccm.c                        |   224 +
 hw/misc/allwinner-a10-dramc.c                      |   179 +
 hw/misc/applesmc.c                                 |     1 +
 hw/misc/aspeed_hace.c                              |    21 +-
 hw/misc/aspeed_sdmc.c                              |     1 -
 hw/misc/auxbus.c                                   |     2 +-
 hw/misc/axp209.c                                   |   238 +
 hw/misc/edu.c                                      |     5 +
 hw/misc/i2c-echo.c                                 |   156 +
 hw/misc/imx6_src.c                                 |     2 +-
 hw/misc/imx6ul_ccm.c                               |     6 -
 hw/misc/imx7_ccm.c                                 |    49 +-
 hw/misc/iotkit-sysctl.c                            |     1 -
 hw/misc/ivshmem.c                                  |     6 +-
 hw/misc/mac_via.c                                  |    26 +-
 hw/misc/macio/cuda.c                               |    17 +-
 hw/misc/macio/gpio.c                               |     1 +
 hw/misc/macio/mac_dbdma.c                          |     4 +-
 hw/misc/macio/macio.c                              |   167 +-
 hw/misc/macio/pmu.c                                |    18 +-
 hw/misc/mchp_pfsoc_ioscb.c                         |    78 +-
 hw/misc/mchp_pfsoc_sysreg.c                        |    18 +-
 hw/misc/meson.build                                |    17 +-
 hw/misc/mips_cmgcr.c                               |     2 +-
 hw/misc/mips_itu.c                                 |    30 +-
 hw/misc/mos6522.c                                  |     8 +-
 hw/misc/mst_fpga.c                                 |     4 +-
 hw/misc/omap_gpmc.c                                |    12 +-
 hw/misc/omap_l4.c                                  |     7 +-
 hw/misc/omap_sdrc.c                                |     7 +-
 hw/misc/omap_tap.c                                 |     5 +-
 hw/misc/pci-testdev.c                              |     2 +-
 hw/misc/pvpanic-pci.c                              |     2 +-
 hw/misc/sbsa_ec.c                                  |    12 +-
 hw/misc/sga.c                                      |    71 -
 hw/misc/sifive_u_otp.c                             |     7 -
 hw/misc/trace-events                               |     5 +
 hw/misc/xlnx-zynqmp-apu-ctrl.c                     |     1 -
 hw/net/Kconfig                                     |     7 +-
 hw/net/allwinner-sun8i-emac.c                      |     4 +-
 hw/net/allwinner_emac.c                            |     4 +-
 hw/net/cadence_gem.c                               |     2 +-
 hw/net/can/can_kvaser_pci.c                        |     2 +-
 hw/net/can/can_mioe3680_pci.c                      |     2 +-
 hw/net/can/can_pcm3680_pci.c                       |     2 +-
 hw/net/can/ctucan_pci.c                            |     2 +-
 hw/net/e1000.c                                     |   263 +-
 hw/net/e1000_common.h                              |   102 +
 hw/net/e1000_regs.h                                |   958 +-
 hw/net/e1000e.c                                    |   102 +-
 hw/net/e1000e_core.c                               |   765 +-
 hw/net/e1000e_core.h                               |    70 +-
 hw/net/e1000x_common.c                             |    65 +-
 hw/net/e1000x_common.h                             |   138 +-
 hw/net/e1000x_regs.h                               |   971 ++
 hw/net/eepro100.c                                  |     2 +-
 hw/net/fsl_etsec/etsec.c                           |    15 +-
 hw/net/fsl_etsec/etsec.h                           |    17 -
 hw/net/fsl_etsec/miim.c                            |     5 +-
 hw/net/fsl_etsec/rings.c                           |     4 +-
 hw/net/ftgmac100.c                                 |     4 +-
 hw/net/igb.c                                       |   635 +
 hw/net/igb_common.h                                |   146 +
 hw/net/igb_core.c                                  |  4199 ++++++
 hw/net/igb_core.h                                  |   145 +
 hw/net/igb_regs.h                                  |   659 +
 hw/net/igbvf.c                                     |   327 +
 hw/net/imx_fec.c                                   |     8 +-
 hw/net/lan9118.c                                   |    17 +-
 hw/net/meson.build                                 |     3 +
 hw/net/ne2000-pci.c                                |     2 +-
 hw/net/net_rx_pkt.c                                |   112 +-
 hw/net/net_rx_pkt.h                                |    41 +-
 hw/net/net_tx_pkt.c                                |   360 +-
 hw/net/net_tx_pkt.h                                |    30 +-
 hw/net/pcnet-pci.c                                 |     2 +-
 hw/net/pcnet.c                                     |     4 +-
 hw/net/rocker/qmp-norocker.c                       |    12 +-
 hw/net/rocker/rocker-hmp-cmds.c                    |   316 +
 hw/net/rocker/rocker.c                             |    28 +-
 hw/net/rocker/rocker_desc.c                        |     4 +-
 hw/net/rocker/rocker_of_dpa.c                      |    13 +-
 hw/net/rtl8139.c                                   |     2 +-
 hw/net/sungem.c                                    |     2 +-
 hw/net/sunhme.c                                    |     2 +-
 hw/net/trace-events                                |    52 +-
 hw/net/tulip.c                                     |     2 +-
 hw/net/vhost_net-stub.c                            |    14 +
 hw/net/vhost_net.c                                 |    18 +
 hw/net/virtio-net.c                                |   177 +-
 hw/net/vmxnet3.c                                   |    69 +-
 hw/net/vmxnet3_defs.h                              |     2 +-
 hw/net/xen_nic.c                                   |    25 +-
 hw/net/xilinx_axienet.c                            |     5 +-
 hw/net/xilinx_ethlite.c                            |     6 +-
 hw/nubus/nubus-device.c                            |     1 +
 hw/nvme/ctrl.c                                     |  1012 +-
 hw/nvme/ns.c                                       |   148 +
 hw/nvme/nvme.h                                     |    94 +-
 hw/nvme/subsys.c                                   |    94 +-
 hw/nvme/trace-events                               |     9 +-
 hw/nvram/eeprom_at24c.c                            |    88 +-
 hw/nvram/fw_cfg.c                                  |     2 +-
 hw/nvram/mac_nvram.c                               |    28 +
 hw/openrisc/boot.c                                 |     1 +
 hw/pci-bridge/cxl_downstream.c                     |     3 +-
 hw/pci-bridge/cxl_root_port.c                      |    78 +-
 hw/pci-bridge/cxl_upstream.c                       |     1 -
 hw/pci-bridge/dec.c                                |   164 -
 hw/pci-bridge/dec.h                                |     9 -
 hw/pci-bridge/gen_pcie_root_port.c                 |     7 +-
 hw/pci-bridge/i82801b11.c                          |     5 +-
 hw/pci-bridge/meson.build                          |     2 -
 hw/pci-bridge/pci_bridge_dev.c                     |     2 -
 hw/pci-bridge/pci_expander_bridge.c                |    47 +-
 hw/pci-bridge/pcie_pci_bridge.c                    |     1 -
 hw/pci-bridge/pcie_root_port.c                     |     9 +-
 hw/pci-bridge/simba.c                              |     1 -
 hw/pci-bridge/xio3130_downstream.c                 |     1 -
 hw/pci-bridge/xio3130_upstream.c                   |     1 -
 hw/pci-host/Kconfig                                |     6 +
 hw/pci-host/bonito.c                               |    53 +-
 hw/pci-host/designware.c                           |     1 -
 hw/pci-host/dino.c                                 |     2 +-
 hw/pci-host/grackle.c                              |     4 +-
 hw/pci-host/gt64120.c                              |  1288 ++
 hw/pci-host/i440fx.c                               |     3 +-
 hw/pci-host/meson.build                            |     1 +
 hw/pci-host/mv64361.c                              |    14 +-
 hw/pci-host/pnv_phb.c                              |    29 +-
 hw/pci-host/pnv_phb.h                              |     2 +-
 hw/pci-host/pnv_phb3.c                             |     1 +
 hw/pci-host/pnv_phb3_msi.c                         |    22 +-
 hw/pci-host/pnv_phb4.c                             |     2 +-
 hw/pci-host/pnv_phb4_pec.c                         |    62 +-
 hw/pci-host/ppce500.c                              |     6 +-
 hw/pci-host/q35.c                                  |     3 +-
 hw/pci-host/raven.c                                |    13 +-
 hw/pci-host/sh_pci.c                               |     2 +-
 hw/pci-host/trace-events                           |     7 +
 hw/pci-host/uninorth.c                             |    44 +-
 hw/pci-host/versatile.c                            |     5 +-
 hw/pci-host/xilinx-pcie.c                          |     1 -
 hw/pci/meson.build                                 |     2 +
 hw/pci/msi.c                                       |    12 +-
 hw/pci/msix.c                                      |     9 +
 hw/pci/pci-hmp-cmds.c                              |   239 +
 hw/pci/pci-internal.h                              |    24 +
 hw/pci/pci-qmp-cmds.c                              |   199 +
 hw/pci/pci-stub.c                                  |     9 +-
 hw/pci/pci.c                                       |   381 +-
 hw/pci/pci_bridge.c                                |    16 +-
 hw/pci/pci_host.c                                  |    25 +-
 hw/pci/pcie.c                                      |    36 +-
 hw/pci/pcie_aer.c                                  |   130 +-
 hw/pci/pcie_host.c                                 |     2 +-
 hw/pci/pcie_port.c                                 |    49 +-
 hw/pci/pcie_sriov.c                                |     7 +-
 hw/pci/shpc.c                                      |   114 +-
 hw/pci/slotid_cap.c                                |     2 +-
 hw/pci/trace-events                                |     1 +
 hw/ppc/Kconfig                                     |     4 +-
 hw/ppc/e500.c                                      |    77 +-
 hw/ppc/e500.h                                      |     1 +
 hw/ppc/e500plat.c                                  |    10 +-
 hw/ppc/mac_newworld.c                              |     3 +-
 hw/ppc/mac_oldworld.c                              |    11 +-
 hw/ppc/pegasos2.c                                  |    43 +-
 hw/ppc/pnv.c                                       |    73 +-
 hw/ppc/pnv_core.c                                  |     1 +
 hw/ppc/pnv_homer.c                                 |     1 +
 hw/ppc/pnv_lpc.c                                   |     3 +-
 hw/ppc/pnv_psi.c                                   |     1 +
 hw/ppc/pnv_xscom.c                                 |     1 +
 hw/ppc/ppc.c                                       |    43 +-
 hw/ppc/ppc405_uc.c                                 |     2 -
 hw/ppc/ppc440_bamboo.c                             |     1 -
 hw/ppc/ppc440_pcix.c                               |     2 +-
 hw/ppc/ppc4xx_pci.c                                |     2 +-
 hw/ppc/ppc4xx_sdram.c                              |    18 +-
 hw/ppc/prep.c                                      |    11 +-
 hw/ppc/sam460ex.c                                  |     4 +-
 hw/ppc/spapr.c                                     |    18 +-
 hw/ppc/spapr_drc.c                                 |     4 +-
 hw/ppc/spapr_hcall.c                               |     1 +
 hw/ppc/spapr_pci.c                                 |    15 +-
 hw/ppc/spapr_pci_vfio.c                            |     1 +
 hw/ppc/spapr_softmmu.c                             |     2 +
 hw/ppc/virtex_ml507.c                              |     2 +-
 hw/rdma/rdma_utils.c                               |     1 +
 hw/rdma/rdma_utils.h                               |     1 -
 hw/rdma/vmw/pvrdma.h                               |     2 +-
 hw/rdma/vmw/pvrdma_cmd.c                           |    66 +-
 hw/rdma/vmw/pvrdma_dev_ring.c                      |     1 -
 hw/rdma/vmw/pvrdma_qp_ops.c                        |     6 +-
 hw/remote/machine.c                                |     4 +-
 hw/remote/proxy-memory-listener.c                  |     1 -
 hw/remote/remote-obj.c                             |     1 -
 hw/remote/vfio-user-obj.c                          |     7 +-
 hw/riscv/Kconfig                                   |    23 +-
 hw/riscv/boot.c                                    |   234 +-
 hw/riscv/meson.build                               |     1 +
 hw/riscv/microchip_pfsoc.c                         |   148 +-
 hw/riscv/numa.c                                    |    14 +-
 hw/riscv/opentitan.c                               |    98 +-
 hw/riscv/shakti_c.c                                |     1 +
 hw/riscv/sifive_e.c                                |     5 +-
 hw/riscv/sifive_u.c                                |    80 +-
 hw/riscv/spike.c                                   |   114 +-
 hw/riscv/virt-acpi-build.c                         |   417 +
 hw/riscv/virt.c                                    |   632 +-
 hw/rtc/exynos4210_rtc.c                            |     4 +-
 hw/rtc/m48t59-isa.c                                |     2 +-
 hw/rtc/m48t59.c                                    |   150 +-
 hw/rtc/mc146818rtc.c                               |   149 +-
 hw/rtc/meson.build                                 |     3 +-
 hw/rtc/twl92230.c                                  |   160 +-
 hw/s390x/event-facility.c                          |     3 +-
 hw/s390x/pv.c                                      |    74 +
 hw/s390x/s390-pci-bus.c                            |    28 +
 hw/s390x/s390-pci-inst.c                           |    56 +-
 hw/s390x/s390-pci-vfio.c                           |    13 +
 hw/s390x/s390-stattrib.c                           |    11 +-
 hw/s390x/s390-virtio-ccw.c                         |    21 +-
 hw/s390x/virtio-ccw-serial.c                       |     1 -
 hw/scsi/esp-pci.c                                  |     2 +-
 hw/scsi/lsi53c895a.c                               |     2 +-
 hw/scsi/mptsas.h                                   |     2 +-
 hw/scsi/scsi-bus.c                                 |     4 +-
 hw/scsi/scsi-disk.c                                |    28 +-
 hw/scsi/scsi-generic.c                             |    11 +-
 hw/scsi/vhost-scsi-common.c                        |     1 +
 hw/scsi/viosrp.h                                   |     3 +-
 hw/scsi/virtio-scsi.c                              |   170 +-
 hw/sd/omap_mmc.c                                   |     9 +-
 hw/sd/sd.c                                         |   184 +-
 hw/sd/sdhci-internal.h                             |     1 +
 hw/sd/sdhci.c                                      |    32 +-
 hw/sensor/adm1272.c                                |     1 -
 hw/sensor/dps310.c                                 |     1 -
 hw/sh4/r2d.c                                       |     4 +-
 hw/sh4/sh7750.c                                    |     4 +-
 hw/sh4/sh7750_regs.h                               |     3 +-
 hw/smbios/smbios-stub.c                            |     4 +-
 hw/smbios/smbios.c                                 |     1 +
 hw/sparc64/niagara.c                               |     1 +
 hw/sparc64/sun4u.c                                 |    13 +-
 hw/ssi/aspeed_smc.c                                |     5 +-
 hw/ssi/ibex_spi_host.c                             |     1 +
 hw/ssi/meson.build                                 |     2 +-
 hw/ssi/npcm_pspi.c                                 |   221 +
 hw/ssi/omap_spi.c                                  |     7 +-
 hw/ssi/sifive_spi.c                                |     2 +-
 hw/ssi/trace-events                                |     5 +
 hw/ssi/xilinx_spi.c                                |     5 +-
 hw/ssi/xilinx_spips.c                              |     8 +-
 hw/timer/digic-timer.c                             |     4 +-
 hw/timer/etraxfs_timer.c                           |     3 +-
 hw/timer/exynos4210_mct.c                          |     2 +-
 hw/timer/exynos4210_pwm.c                          |     4 +-
 hw/timer/hpet.c                                    |     1 +
 hw/timer/imx_epit.c                                |   370 +-
 hw/timer/imx_gpt.c                                 |    25 +
 hw/timer/omap_gptimer.c                            |    22 +-
 hw/timer/omap_synctimer.c                          |     4 +-
 hw/timer/xilinx_timer.c                            |    27 +-
 hw/tpm/meson.build                                 |     4 +-
 hw/usb/ccid-card-emulated.c                        |     2 +-
 hw/usb/dev-smartcard-reader.c                      |     7 +-
 hw/usb/dev-storage-bot.c                           |     1 -
 hw/usb/dev-storage-classic.c                       |     1 -
 hw/usb/dev-uas.c                                   |     2 +-
 hw/usb/hcd-ehci.h                                  |     3 +-
 hw/usb/hcd-ohci-pci.c                              |     2 +-
 hw/usb/hcd-ohci.c                                  |   463 +-
 hw/usb/hcd-ohci.h                                  |    11 +-
 hw/usb/hcd-uhci.c                                  |    23 +-
 hw/usb/hcd-uhci.h                                  |     8 +-
 hw/usb/hcd-xhci-nec.c                              |     8 +-
 hw/usb/hcd-xhci-pci.h                              |     1 +
 hw/usb/imx-usb-phy.c                               |    19 +-
 hw/usb/meson.build                                 |     6 +-
 hw/usb/trace-events                                |     4 +
 hw/usb/u2f.h                                       |    16 +-
 hw/usb/vt82c686-uhci-pci.c                         |    12 -
 hw/usb/xen-usb.c                                   |    29 +-
 hw/vfio/ccw.c                                      |    40 +-
 hw/vfio/common.c                                   |   765 +-
 hw/vfio/display.c                                  |     1 +
 hw/vfio/igd.c                                      |     1 +
 hw/vfio/migration.c                                |   768 +-
 hw/vfio/pci.c                                      |    12 +-
 hw/vfio/pci.h                                      |     2 +-
 hw/vfio/trace-events                               |    35 +-
 hw/virtio/Kconfig                                  |     5 +
 hw/virtio/meson.build                              |    45 +-
 hw/virtio/trace-events                             |     6 +-
 hw/virtio/vdpa-dev-pci.c                           |   102 +
 hw/virtio/vdpa-dev.c                               |   386 +
 hw/virtio/vhost-shadow-virtqueue.c                 |    52 +-
 hw/virtio/vhost-shadow-virtqueue.h                 |     5 +-
 hw/virtio/vhost-stub.c                             |     4 +
 hw/virtio/vhost-user-fs.c                          |    22 +-
 hw/virtio/vhost-user-gpio.c                        |    10 +
 hw/virtio/vhost-user.c                             |    45 +-
 hw/virtio/vhost-vdpa.c                             |   298 +-
 hw/virtio/vhost-vsock-common.c                     |    18 +
 hw/virtio/vhost.c                                  |   199 +-
 hw/virtio/virtio-balloon.c                         |    20 +-
 hw/virtio/virtio-config-io.c                       |   204 +
 hw/virtio/virtio-crypto.c                          |    71 +-
 hw/virtio/virtio-hmp-cmds.c                        |   321 +
 hw/virtio/virtio-iommu.c                           |    10 +-
 hw/virtio/virtio-mem-pci.c                         |     4 +-
 hw/virtio/virtio-mem.c                             |   166 +-
 hw/virtio/virtio-mmio.c                            |    31 +-
 hw/virtio/virtio-pci.c                             |   425 +-
 hw/virtio/virtio-pmem-pci.c                        |     1 -
 hw/virtio/virtio-pmem.c                            |     1 +
 hw/virtio/virtio-qmp.c                             |   848 ++
 hw/virtio/virtio-qmp.h                             |    30 +
 hw/virtio/virtio.c                                 |  1024 +-
 hw/watchdog/trace-events                           |     4 +
 hw/watchdog/watchdog.c                             |     4 +
 hw/watchdog/wdt_aspeed.c                           |    24 +-
 hw/watchdog/wdt_i6300esb.c                         |     2 +-
 hw/watchdog/wdt_ib700.c                            |     2 +-
 hw/xen/Kconfig                                     |     3 +
 hw/xen/meson.build                                 |     6 +-
 hw/xen/trace-events                                |     2 +-
 hw/xen/xen-bus-helper.c                            |    62 +-
 hw/xen/xen-bus.c                                   |   412 +-
 hw/xen/xen-legacy-backend.c                        |   308 +-
 hw/xen/xen-operations.c                            |   478 +
 hw/xen/xen_devconfig.c                             |     4 +-
 hw/xen/xen_pt.c                                    |     6 +-
 hw/xen/xen_pt.h                                    |     3 +-
 hw/xen/xen_pt_config_init.c                        |     2 +-
 hw/xen/xen_pt_graphics.c                           |     1 -
 hw/xen/xen_pt_msi.c                                |     4 +-
 hw/xen/xen_pvdev.c                                 |    64 +-
 hw/xenpv/xen_machine_pv.c                          |     8 +-
 include/block/aio-wait.h                           |     2 +-
 include/block/aio.h                                |    26 +-
 include/block/aio_task.h                           |     2 -
 include/block/block-common.h                       |    52 +-
 include/block/block-copy.h                         |     9 +-
 include/block/block-global-state.h                 |    65 +-
 include/block/block-hmp-cmds.h                     |     2 +
 include/block/block-io.h                           |   235 +-
 include/block/block.h                              |     4 +-
 include/block/block_backup.h                       |     2 +-
 include/block/block_int-common.h                   |   256 +-
 include/block/block_int-global-state.h             |    22 +-
 include/block/block_int-io.h                       |    66 +-
 include/block/block_int.h                          |     5 +-
 include/block/blockjob.h                           |     2 +-
 include/block/blockjob_int.h                       |     1 -
 include/block/dirty-bitmap.h                       |    11 +-
 include/block/graph-lock.h                         |   277 +
 include/block/nbd.h                                |     1 +
 include/block/nvme.h                               |   236 +-
 include/block/qapi.h                               |    16 +-
 include/block/raw-aio.h                            |     1 -
 include/block/thread-pool.h                        |     2 +-
 include/block/throttle-groups.h                    |     2 +-
 include/block/write-threshold.h                    |     2 -
 include/crypto/aes.h                               |     8 +-
 include/crypto/desrfb.h                            |    16 +-
 include/crypto/tlssession.h                        |    11 +
 include/disas/dis-asm.h                            |    76 +-
 include/elf.h                                      |  1801 +--
 include/exec/cpu-all.h                             |    17 +-
 include/exec/cpu-defs.h                            |    37 +-
 include/exec/cpu_ldst.h                            |    10 +
 include/exec/exec-all.h                            |    82 +-
 include/exec/gdbstub.h                             |   208 -
 include/exec/gen-icount.h                          |    15 +-
 include/exec/helper-head.h                         |    11 +-
 include/exec/helper-proto.h                        |    32 +-
 include/exec/hwaddr.h                              |     2 +-
 include/exec/memory-internal.h                     |     4 -
 include/exec/memory.h                              |    40 +
 include/exec/plugin-gen.h                          |     1 +
 include/exec/poison.h                              |     1 -
 include/exec/replay-core.h                         |    80 +
 include/exec/target_long.h                         |    42 +
 include/exec/tb-flush.h                            |    26 +
 include/exec/translate-all.h                       |     6 -
 include/exec/translator.h                          |     6 +-
 include/gdbstub/helpers.h                          |   103 +
 include/gdbstub/syscalls.h                         |   113 +
 include/gdbstub/user.h                             |    43 +
 include/hw/acpi/acpi.h                             |     4 +-
 include/hw/acpi/acpi_aml_interface.h               |     3 +
 include/hw/acpi/acpi_dev_interface.h               |     3 +-
 include/hw/acpi/erst.h                             |     3 +
 include/hw/acpi/ich9.h                             |     9 +-
 include/hw/acpi/ich9_tco.h                         |    82 +
 include/hw/acpi/pci.h                              |     4 +
 include/hw/acpi/pcihp.h                            |    11 +-
 include/hw/acpi/piix4.h                            |     4 +-
 include/hw/acpi/tco.h                              |    82 -
 include/hw/adc/npcm7xx_adc.h                       |     7 +-
 include/hw/arm/allwinner-a10.h                     |    29 +-
 include/hw/arm/allwinner-h3.h                      |     9 +
 include/hw/arm/armsse.h                            |     6 +-
 include/hw/arm/aspeed_soc.h                        |    19 +
 include/hw/arm/bcm2835_peripherals.h               |     2 +-
 include/hw/arm/exynos4210.h                        |     4 +-
 include/hw/arm/fsl-imx6ul.h                        |     1 -
 include/hw/arm/fsl-imx7.h                          |    21 +-
 include/hw/arm/npcm7xx.h                           |    20 +-
 include/hw/arm/omap.h                              |    24 +-
 include/hw/arm/pxa.h                               |    11 +-
 include/hw/arm/raspi_platform.h                    |     3 +-
 include/hw/arm/smmu-common.h                       |     5 -
 include/hw/arm/smmuv3.h                            |     4 +-
 include/hw/arm/stm32f205_soc.h                     |     2 +-
 include/hw/arm/stm32f405_soc.h                     |     7 +-
 include/hw/arm/virt.h                              |    17 +-
 include/hw/arm/xlnx-versal.h                       |     6 +-
 include/hw/arm/xlnx-zynqmp.h                       |     2 +-
 include/hw/block/flash.h                           |    20 +-
 include/hw/block/swim.h                            |     1 +
 include/hw/boards.h                                |     7 +-
 include/hw/char/cmsdk-apb-uart.h                   |    33 -
 include/hw/char/goldfish_tty.h                     |     1 +
 include/hw/char/ibex_uart.h                        |     1 -
 include/hw/char/pl011.h                            |    41 +-
 include/hw/char/riscv_htif.h                       |    19 +-
 include/hw/char/xilinx_uartlite.h                  |    21 +-
 include/hw/core/cpu.h                              |    57 +-
 include/hw/core/tcg-cpu-ops.h                      |    43 +
 include/hw/cris/etraxfs.h                          |     1 +
 include/hw/cxl/cxl.h                               |     6 +-
 include/hw/cxl/cxl_cdat.h                          |     1 +
 include/hw/cxl/cxl_component.h                     |    30 +-
 include/hw/cxl/cxl_device.h                        |    15 +-
 include/hw/cxl/cxl_host.h                          |     1 -
 include/hw/cxl/cxl_pci.h                           |     4 -
 include/hw/display/macfb.h                         |     3 +-
 include/hw/dma/sifive_pdma.h                       |     2 +
 include/hw/elf_ops.h                               |    42 +-
 include/hw/hotplug.h                               |     2 +
 include/hw/i2c/allwinner-i2c.h                     |    61 +
 include/hw/i2c/arm_sbcon_i2c.h                     |     6 +-
 include/hw/i2c/bitbang_i2c.h                       |     2 +
 include/hw/i2c/i2c.h                               |     2 +
 include/hw/i2c/npcm7xx_smbus.h                     |     7 +-
 include/hw/i386/apic.h                             |     2 -
 include/hw/i386/apic_internal.h                    |     3 +-
 include/hw/i386/ich9.h                             |   256 -
 include/hw/i386/intel_iommu.h                      |    88 +-
 include/hw/i386/ioapic.h                           |    33 -
 include/hw/i386/ioapic_internal.h                  |   117 -
 include/hw/i386/pc.h                               |    14 +-
 include/hw/i386/sgx-epc.h                          |     1 +
 include/hw/i386/x86-iommu.h                        |    51 +-
 include/hw/i386/x86.h                              |     8 +-
 include/hw/ide.h                                   |    12 -
 include/hw/ide/internal.h                          |   278 +-
 include/hw/ide/isa.h                               |    20 +
 include/hw/ide/mmio.h                              |    26 +
 include/hw/ide/pci.h                               |     9 +-
 include/hw/input/pl050.h                           |     1 -
 include/hw/input/ps2.h                             |     2 +-
 include/hw/input/tsc2xxx.h                         |     4 +-
 include/hw/intc/armv7m_nvic.h                      |   128 +-
 include/hw/intc/goldfish_pic.h                     |     2 +
 include/hw/intc/i8259.h                            |    16 +-
 include/hw/intc/ioapic.h                           |    33 +
 include/hw/intc/kvm_irqcount.h                     |    10 +
 include/hw/intc/loongarch_pch_msi.h                |    11 +-
 include/hw/intc/loongarch_pch_pic.h                |     8 +-
 include/hw/intc/mips_gic.h                         |     4 +-
 include/hw/intc/nios2_vic.h                        |     2 +
 include/hw/intc/sifive_plic.h                      |     1 -
 include/hw/isa/i8259_internal.h                    |     3 +-
 include/hw/isa/isa.h                               |    36 +-
 include/hw/isa/superio.h                           |     2 +-
 include/hw/isa/vt82c686.h                          |    26 +-
 include/hw/loader.h                                |    22 +-
 include/hw/loongarch/virt.h                        |     6 +
 include/hw/mips/bootloader.h                       |    10 +-
 include/hw/misc/allwinner-a10-ccm.h                |    67 +
 include/hw/misc/allwinner-a10-dramc.h              |    68 +
 include/hw/misc/aspeed_lpc.h                       |     2 -
 include/hw/misc/mac_via.h                          |     1 +
 include/hw/misc/macio/cuda.h                       |     1 +
 include/hw/misc/macio/macio.h                      |     2 +-
 include/hw/misc/macio/pmu.h                        |     1 +
 include/hw/misc/mchp_pfsoc_dmc.h                   |     2 +
 include/hw/misc/mchp_pfsoc_ioscb.h                 |     6 +
 include/hw/misc/mchp_pfsoc_sysreg.h                |     3 +
 include/hw/misc/mips_cmgcr.h                       |     2 +-
 include/hw/misc/mips_itu.h                         |     9 +-
 include/hw/misc/mos6522.h                          |     5 +-
 include/hw/misc/npcm7xx_clk.h                      |     2 +-
 include/hw/misc/npcm7xx_gcr.h                      |     6 +-
 include/hw/misc/npcm7xx_mft.h                      |     7 +-
 include/hw/misc/npcm7xx_pwm.h                      |     3 +-
 include/hw/misc/npcm7xx_rng.h                      |     6 +-
 include/hw/misc/pvpanic.h                          |     1 +
 include/hw/misc/sifive_e_prci.h                    |     3 +-
 include/hw/misc/sifive_u_otp.h                     |     3 +-
 include/hw/misc/sifive_u_prci.h                    |     3 +-
 include/hw/misc/virt_ctrl.h                        |     2 +
 include/hw/misc/xlnx-versal-pmc-iou-slcr.h         |     1 +
 include/hw/misc/xlnx-zynqmp-apu-ctrl.h             |     2 +-
 include/hw/net/lasi_82596.h                        |     2 +-
 include/hw/net/mii.h                               |    14 +-
 include/hw/net/npcm7xx_emc.h                       |     5 +-
 include/hw/net/xlnx-zynqmp-can.h                   |     1 +
 include/hw/nvram/eeprom_at24c.h                    |    39 +
 include/hw/nvram/mac_nvram.h                       |     1 +
 include/hw/or-irq.h                                |     5 +-
 include/hw/pci-host/bonito.h                       |    18 +
 include/hw/pci-host/designware.h                   |     3 -
 include/hw/pci-host/gpex.h                         |     2 +-
 include/hw/pci-host/i440fx.h                       |     2 +-
 include/hw/pci-host/ls7a.h                         |    21 +-
 include/hw/pci-host/pnv_phb3.h                     |     3 -
 include/hw/pci-host/pnv_phb4.h                     |    16 +-
 include/hw/pci-host/q35.h                          |     2 +-
 include/hw/pci-host/sabre.h                        |     2 +-
 include/hw/pci-host/xilinx-pcie.h                  |     1 -
 include/hw/pci/msi.h                               |     3 +-
 include/hw/pci/pci.h                               |   359 +-
 include/hw/pci/pci_bridge.h                        |    15 +-
 include/hw/pci/pci_device.h                        |   350 +
 include/hw/pci/pci_ids.h                           |     1 -
 include/hw/pci/pcie.h                              |     9 -
 include/hw/pci/pcie_aer.h                          |     1 +
 include/hw/pci/pcie_doe.h                          |     1 -
 include/hw/pci/pcie_port.h                         |     8 +-
 include/hw/pci/pcie_regs.h                         |    17 +-
 include/hw/pci/pcie_sriov.h                        |     5 +
 include/hw/pci/shpc.h                              |     2 +-
 include/hw/pcmcia.h                                |    32 +-
 include/hw/ppc/pnv.h                               |   148 +-
 include/hw/ppc/pnv_chip.h                          |   147 +
 include/hw/ppc/pnv_core.h                          |     3 +-
 include/hw/ppc/pnv_homer.h                         |     2 +-
 include/hw/ppc/pnv_lpc.h                           |    11 +-
 include/hw/ppc/pnv_occ.h                           |     3 +-
 include/hw/ppc/pnv_pnor.h                          |     2 +-
 include/hw/ppc/pnv_psi.h                           |     2 +-
 include/hw/ppc/pnv_sbe.h                           |     3 +-
 include/hw/ppc/pnv_xive.h                          |     7 +-
 include/hw/ppc/pnv_xscom.h                         |     3 +-
 include/hw/ppc/spapr.h                             |     3 +-
 include/hw/ppc/vof.h                               |     2 +-
 include/hw/ppc/xics.h                              |     2 +-
 include/hw/ppc/xive2.h                             |     2 +
 include/hw/ppc/xive2_regs.h                        |     2 +
 include/hw/qdev-core.h                             |    50 +-
 include/hw/remote/iohub.h                          |     2 +-
 include/hw/remote/proxy.h                          |     2 +-
 include/hw/riscv/boot.h                            |    14 +-
 include/hw/riscv/boot_opensbi.h                    |     2 +
 include/hw/riscv/microchip_pfsoc.h                 |    10 +-
 include/hw/riscv/numa.h                            |    11 +-
 include/hw/riscv/opentitan.h                       |    16 +-
 include/hw/riscv/shakti_c.h                        |     2 +-
 include/hw/riscv/sifive_e.h                        |     9 +-
 include/hw/riscv/sifive_u.h                        |     6 +-
 include/hw/riscv/spike.h                           |     4 +-
 include/hw/riscv/virt.h                            |    16 +-
 include/hw/rtc/mc146818rtc.h                       |    15 +-
 include/hw/s390x/pv.h                              |     4 +-
 include/hw/s390x/s390-pci-bus.h                    |     6 +
 include/hw/scsi/scsi.h                             |     2 +-
 include/hw/sd/npcm7xx_sdhci.h                      |     4 +-
 include/hw/sd/sd.h                                 |     8 +-
 include/hw/sd/sdhci.h                              |     3 +-
 include/hw/southbridge/ich9.h                      |   245 +
 include/hw/southbridge/piix.h                      |     3 +-
 include/hw/ssi/ibex_spi_host.h                     |     2 -
 include/hw/ssi/npcm_pspi.h                         |    53 +
 include/hw/ssi/sifive_spi.h                        |     3 +
 include/hw/timer/cmsdk-apb-timer.h                 |     1 -
 include/hw/timer/i8254.h                           |     3 +-
 include/hw/timer/i8254_internal.h                  |     2 +-
 include/hw/timer/imx_epit.h                        |     8 +-
 include/hw/timer/imx_gpt.h                         |     1 +
 include/hw/timer/sse-timer.h                       |     1 +
 include/hw/tricore/triboard.h                      |     1 -
 include/hw/tricore/tricore_testdevice.h            |     1 -
 include/hw/usb/hcd-dwc3.h                          |     1 +
 include/hw/usb/hcd-musb.h                          |     2 +
 include/hw/usb/xlnx-usb-subsystem.h                |     2 +
 include/hw/usb/xlnx-versal-usb2-ctrl-regs.h        |     3 +
 include/hw/vfio/vfio-common.h                      |    18 +-
 include/hw/virtio/vdpa-dev.h                       |    43 +
 include/hw/virtio/vhost-backend.h                  |     7 +
 include/hw/virtio/vhost-vdpa.h                     |    21 +-
 include/hw/virtio/vhost.h                          |    30 +-
 include/hw/virtio/virtio-blk.h                     |     2 -
 include/hw/virtio/virtio-mem.h                     |     8 +
 include/hw/virtio/virtio-mmio.h                    |     2 +-
 include/hw/virtio/virtio-pci.h                     |     9 +-
 include/hw/virtio/virtio-scsi.h                    |    12 +-
 include/hw/virtio/virtio.h                         |    31 +-
 include/hw/watchdog/wdt_aspeed.h                   |     4 +-
 include/hw/xen/interface/arch-arm.h                |   510 +
 include/hw/xen/interface/arch-x86/cpuid.h          |   118 +
 include/hw/xen/interface/arch-x86/xen-x86_32.h     |   194 +
 include/hw/xen/interface/arch-x86/xen-x86_64.h     |   241 +
 include/hw/xen/interface/arch-x86/xen.h            |   398 +
 include/hw/xen/interface/event_channel.h           |   388 +
 include/hw/xen/interface/features.h                |   143 +
 include/hw/xen/interface/grant_table.h             |   650 +
 include/hw/xen/interface/hvm/hvm_op.h              |   395 +
 include/hw/xen/interface/hvm/params.h              |   318 +
 include/hw/xen/interface/io/blkif.h                |    14 +-
 include/hw/xen/interface/io/console.h              |    10 +
 include/hw/xen/interface/io/fbif.h                 |    20 +
 include/hw/xen/interface/io/kbdif.h                |    10 +
 include/hw/xen/interface/io/netif.h                |    94 +-
 include/hw/xen/interface/io/ring.h                 |    99 +-
 include/hw/xen/interface/io/usbif.h                |   377 +-
 include/hw/xen/interface/io/xenbus.h               |    10 +
 include/hw/xen/interface/io/xs_wire.h              |   153 +
 include/hw/xen/interface/memory.h                  |   754 +
 include/hw/xen/interface/physdev.h                 |   383 +
 include/hw/xen/interface/sched.h                   |   202 +
 include/hw/xen/interface/trace.h                   |   341 +
 include/hw/xen/interface/vcpu.h                    |   248 +
 include/hw/xen/interface/version.h                 |   113 +
 include/hw/xen/interface/xen-compat.h              |    46 +
 include/hw/xen/interface/xen.h                     |  1049 ++
 include/hw/xen/xen-bus-helper.h                    |    32 +-
 include/hw/xen/xen-bus.h                           |    24 +-
 include/hw/xen/xen-legacy-backend.h                |    27 +-
 include/hw/xen/xen.h                               |    29 +-
 include/hw/xen/xen_backend_ops.h                   |   408 +
 include/hw/xen/xen_common.h                        |   690 -
 include/hw/xen/xen_native.h                        |   629 +
 include/hw/xen/xen_pvdev.h                         |     6 +-
 include/io/channel-tls.h                           |     1 +
 include/io/channel.h                               |    20 +-
 include/migration/misc.h                           |     4 +-
 include/migration/register.h                       |    31 +-
 include/migration/vmstate.h                        |    35 +-
 include/monitor/hmp-target.h                       |     6 +
 include/monitor/hmp.h                              |    40 +-
 include/monitor/monitor.h                          |     4 +-
 include/monitor/qmp-helpers.h                      |    29 +
 include/monitor/stats.h                            |    45 -
 include/net/eth.h                                  |    21 +-
 include/net/net.h                                  |    24 +-
 include/net/vhost-user.h                           |     1 +
 include/net/vhost_net.h                            |     4 +
 include/qapi/error.h                               |     6 +
 include/qapi/qmp/qerror.h                          |     6 -
 include/qemu/accel.h                               |     4 +-
 include/qemu/async-teardown.h                      |     2 -
 include/qemu/atomic.h                              |    17 +-
 include/qemu/atomic128.h                           |    29 +-
 include/qemu/bitmap.h                              |    52 +-
 include/qemu/bswap.h                               |   103 +-
 include/qemu/clang-tsa.h                           |   114 +
 include/qemu/compiler.h                            |     4 +-
 include/qemu/config-file.h                         |     2 +-
 include/qemu/coroutine-core.h                      |   154 +
 include/qemu/coroutine.h                           |   113 +-
 include/qemu/cpuid.h                               |     7 +
 include/qemu/dbus.h                                |     1 -
 include/qemu/envlist.h                             |     8 -
 include/qemu/hbitmap.h                             |     2 +-
 include/qemu/host-utils.h                          |     1 -
 include/qemu/int128.h                              |    25 +-
 include/qemu/interval-tree.h                       |    99 +
 include/qemu/lockable.h                            |     2 +-
 include/qemu/main-loop.h                           |    31 +-
 include/qemu/osdep.h                               |    87 +-
 include/qemu/plugin-event.h                        |    26 +
 include/qemu/plugin-memory.h                       |     3 +
 include/qemu/plugin.h                              |    30 +-
 include/qemu/progress_meter.h                      |     2 +-
 include/qemu/qemu-plugin.h                         |    47 +-
 include/qemu/qtree.h                               |   201 +
 include/qemu/rcu.h                                 |     8 -
 include/qemu/rcu_queue.h                           |     8 -
 include/qemu/readline.h                            |     2 +
 include/qemu/sockets.h                             |     2 -
 include/qemu/thread.h                              |    19 +-
 include/qemu/typedefs.h                            |    13 +-
 include/qemu/uri.h                                 |    42 +-
 include/qemu/userfaultfd.h                         |    13 +-
 include/qemu/uuid.h                                |    12 +
 include/qemu/vhost-user-server.h                   |     1 -
 include/qemu/xattr.h                               |     4 +-
 include/scsi/pr-manager.h                          |     1 -
 include/standard-headers/drm/drm_fourcc.h          |    63 +-
 include/standard-headers/linux/ethtool.h           |    81 +-
 include/standard-headers/linux/fuse.h              |    20 +-
 include/standard-headers/linux/input-event-codes.h |     4 +
 include/standard-headers/linux/pci_regs.h          |     2 +
 include/standard-headers/linux/virtio_blk.h        |    19 +
 include/standard-headers/linux/virtio_bt.h         |     8 +
 include/standard-headers/linux/virtio_net.h        |     4 +
 include/sysemu/accel-blocker.h                     |    55 +
 include/sysemu/accel-ops.h                         |     7 +-
 include/sysemu/block-backend-global-state.h        |    26 +-
 include/sysemu/block-backend-io.h                  |   112 +-
 include/sysemu/cpus.h                              |     1 -
 include/sysemu/cryptodev.h                         |   113 +-
 include/sysemu/dirtyrate.h                         |     2 +
 include/sysemu/dump.h                              |     1 +
 include/sysemu/event-loop-base.h                   |     1 -
 include/sysemu/kvm.h                               |     2 -
 include/sysemu/kvm_int.h                           |    12 +
 include/sysemu/kvm_xen.h                           |    43 +
 include/sysemu/os-posix.h                          |     3 -
 include/sysemu/os-win32.h                          |    58 +-
 include/sysemu/replay.h                            |    67 +-
 include/sysemu/stats.h                             |    45 +
 include/sysemu/sysemu.h                            |     3 -
 include/tcg/tcg-op.h                               |    68 +-
 include/tcg/tcg-temp-internal.h                    |    83 +
 include/tcg/tcg.h                                  |   261 +-
 include/ui/console.h                               |     8 +-
 include/ui/egl-helpers.h                           |     4 +
 include/ui/qemu-spice.h                            |     8 +-
 include/ui/spice-display.h                         |     2 -
 include/user/syscall-trace.h                       |     2 +
 io/channel-buffer.c                                |     1 +
 io/channel-command.c                               |     1 +
 io/channel-file.c                                  |     1 +
 io/channel-null.c                                  |     1 +
 io/channel-socket.c                                |    27 +-
 io/channel-tls.c                                   |    86 +-
 io/channel-watch.c                                 |    10 +-
 io/channel-websock.c                               |     1 +
 io/channel.c                                       |    49 +-
 iothread.c                                         |     6 +-
 job-qmp.c                                          |     3 +-
 linux-headers/asm-arm64/kvm.h                      |     1 +
 linux-headers/asm-generic/hugetlb_encode.h         |    26 +-
 linux-headers/asm-generic/mman-common.h            |     2 +
 linux-headers/asm-mips/mman.h                      |     2 +
 linux-headers/asm-riscv/kvm.h                      |     7 +
 linux-headers/asm-x86/kvm.h                        |    11 +-
 linux-headers/linux/kvm.h                          |    35 +-
 linux-headers/linux/psci.h                         |    14 +
 linux-headers/linux/userfaultfd.h                  |     4 +
 linux-headers/linux/vfio.h                         |   278 +-
 linux-user/aarch64/cpu_loop.c                      |    11 +-
 linux-user/aarch64/signal.c                        |    13 +-
 linux-user/aarch64/target_flat.h                   |     1 +
 linux-user/alpha/target_mman.h                     |     4 +
 linux-user/arm/cpu_loop.c                          |    13 +-
 linux-user/arm/target_cpu.h                        |     2 +-
 linux-user/arm/target_flat.h                       |     1 +
 linux-user/elfload.c                               |    78 +-
 linux-user/exit.c                                  |     5 +-
 linux-user/fd-trans.c                              |    64 +-
 linux-user/flatload.c                              |     2 +-
 linux-user/generic/target_flat.h                   |    16 +
 linux-user/generic/target_mman.h                   |    13 +
 linux-user/hexagon/signal.c                        |    17 +-
 linux-user/hppa/target_mman.h                      |     4 +
 linux-user/i386/cpu_loop.c                         |     9 +
 linux-user/include/host/ppc/host-signal.h          |    39 +
 linux-user/m68k/target_flat.h                      |     1 +
 linux-user/main.c                                  |    71 +-
 linux-user/meson.build                             |     1 +
 linux-user/microblaze/cpu_loop.c                   |    10 +-
 linux-user/microblaze/target_flat.h                |     1 +
 linux-user/mips/target_elf.h                       |     3 +
 linux-user/mmap.c                                  |    82 +-
 linux-user/sh4/target_flat.h                       |     1 +
 linux-user/signal.c                                |    10 +-
 linux-user/sparc/cpu_loop.c                        |   190 +-
 linux-user/sparc/signal.c                          |    36 +-
 linux-user/sparc/target_signal.h                   |     2 +-
 linux-user/strace.c                                |   302 +-
 linux-user/strace.list                             |    69 +-
 linux-user/syscall.c                               |   500 +-
 linux-user/syscall_defs.h                          |     7 +-
 linux-user/target_flat.h                           |    16 -
 linux-user/user-internals.h                        |    15 +-
 meson.build                                        |   208 +-
 meson_options.txt                                  |    16 +-
 migration/block-dirty-bitmap.c                     |    20 +-
 migration/block.c                                  |    31 +-
 migration/channel-block.c                          |     1 +
 migration/channel.c                                |    45 +
 migration/channel.h                                |     5 +
 migration/colo-failover.c                          |     3 +-
 migration/colo.c                                   |     2 -
 migration/dirtyrate.c                              |    21 +-
 migration/exec.c                                   |    25 +
 migration/meson.build                              |     2 +
 migration/migration-hmp-cmds.c                     |   806 +
 migration/migration.c                              |   377 +-
 migration/migration.h                              |    67 +-
 migration/multifd-zlib.c                           |    14 +-
 migration/multifd-zstd.c                           |    12 +-
 migration/multifd.c                                |   156 +-
 migration/multifd.h                                |    13 +-
 migration/postcopy-ram.c                           |    76 +-
 migration/postcopy-ram.h                           |     6 +-
 migration/qemu-file.c                              |    34 +
 migration/qemu-file.h                              |     1 +
 migration/ram.c                                    |   965 +-
 migration/ram.h                                    |    23 +
 migration/rdma.c                                   |    27 +-
 migration/savevm.c                                 |   192 +-
 migration/savevm.h                                 |     8 +-
 migration/target.c                                 |     2 +-
 migration/threadinfo.c                             |    51 +
 migration/threadinfo.h                             |    28 +
 migration/tls.c                                    |     6 +-
 migration/trace-events                             |     8 +-
 migration/vmstate.c                                |     2 +
 migration/xbzrle.c                                 |   124 +
 migration/xbzrle.h                                 |     4 +
 monitor/fds.c                                      |   517 +
 monitor/hmp-cmds-target.c                          |   380 +
 monitor/hmp-cmds.c                                 |  2854 +---
 monitor/hmp-target.c                               |   178 +
 monitor/hmp.c                                      |    16 +-
 monitor/meson.build                                |     4 +-
 monitor/misc.c                                     |  1994 ---
 monitor/monitor-internal.h                         |     1 -
 monitor/monitor.c                                  |    41 +-
 monitor/qmp-cmds-control.c                         |     1 -
 monitor/qmp-cmds.c                                 |   518 +-
 nbd/client-connection.c                            |     1 +
 nbd/nbd-internal.h                                 |     1 -
 nbd/server.c                                       |    71 +-
 net/announce.c                                     |     8 +-
 net/colo-compare.c                                 |    13 +-
 net/dgram.c                                        |    14 +-
 net/dump.c                                         |    11 +-
 net/eth.c                                          |   134 +-
 net/hub.c                                          |     2 +-
 net/l2tpv3.c                                       |    21 +-
 net/meson.build                                    |     1 +
 net/net-hmp-cmds.c                                 |   170 +
 net/net.c                                          |   121 +-
 net/slirp.c                                        |    20 +-
 net/socket.c                                       |    56 +-
 net/stream.c                                       |    53 +-
 net/tap-bsd.c                                      |     6 +-
 net/tap-linux.c                                    |     2 +-
 net/tap-solaris.c                                  |     8 +-
 net/tap-win32.c                                    |     2 +-
 net/tap.c                                          |    77 +-
 net/vhost-user.c                                   |    27 +-
 net/vhost-vdpa.c                                   |   395 +-
 net/vmnet-common.m                                 |    48 +-
 net/vmnet-host.c                                   |    20 +-
 net/vmnet-shared.c                                 |    16 +-
 net/vmnet_int.h                                    |     3 +-
 os-posix.c                                         |    16 +-
 pc-bios/README                                     |    10 +-
 pc-bios/bios-256k.bin                              |   Bin 262144 -> 262144 bytes
 pc-bios/bios-microvm.bin                           |   Bin 131072 -> 131072 bytes
 pc-bios/bios.bin                                   |   Bin 131072 -> 131072 bytes
 pc-bios/edk2-aarch64-code.fd.bz2                   |   Bin 1161290 -> 1508184 bytes
 pc-bios/edk2-arm-code.fd.bz2                       |   Bin 1161845 -> 1483149 bytes
 pc-bios/edk2-i386-code.fd.bz2                      |   Bin 1282120 -> 1695318 bytes
 pc-bios/edk2-i386-secure-code.fd.bz2               |   Bin 1473677 -> 1922002 bytes
 pc-bios/edk2-riscv.fd.bz2                          |   Bin 0 -> 1096418 bytes
 pc-bios/edk2-x86_64-code.fd.bz2                    |   Bin 1327522 -> 1796544 bytes
 pc-bios/edk2-x86_64-microvm.fd.bz2                 |   Bin 1309407 -> 1697788 bytes
 pc-bios/edk2-x86_64-secure-code.fd.bz2             |   Bin 1513711 -> 1999841 bytes
 pc-bios/keymaps/meson.build                        |     2 +-
 pc-bios/meson.build                                |     1 -
 pc-bios/openbios-ppc                               |   Bin 677196 -> 677196 bytes
 pc-bios/openbios-sparc32                           |   Bin 382080 -> 382080 bytes
 pc-bios/openbios-sparc64                           |   Bin 1593408 -> 1593408 bytes
 pc-bios/opensbi-riscv32-generic-fw_dynamic.bin     |   Bin 117704 -> 123072 bytes
 pc-bios/opensbi-riscv64-generic-fw_dynamic.bin     |   Bin 115344 -> 121800 bytes
 pc-bios/optionrom/optionrom.h                      |   262 +-
 pc-bios/s390-ccw.img                               |   Bin 42608 -> 42608 bytes
 pc-bios/s390-ccw/bootmap.c                         |   157 +-
 pc-bios/s390-ccw/bootmap.h                         |    30 +-
 pc-bios/sgabios.bin                                |   Bin 4096 -> 0 bytes
 pc-bios/vgabios-ati.bin                            |   Bin 39936 -> 39936 bytes
 pc-bios/vgabios-bochs-display.bin                  |   Bin 28672 -> 28672 bytes
 pc-bios/vgabios-cirrus.bin                         |   Bin 39424 -> 39424 bytes
 pc-bios/vgabios-qxl.bin                            |   Bin 39936 -> 39936 bytes
 pc-bios/vgabios-ramfb.bin                          |   Bin 29184 -> 29184 bytes
 pc-bios/vgabios-stdvga.bin                         |   Bin 39936 -> 39936 bytes
 pc-bios/vgabios-virtio.bin                         |   Bin 39936 -> 39936 bytes
 pc-bios/vgabios-vmware.bin                         |   Bin 39936 -> 39936 bytes
 pc-bios/vgabios.bin                                |   Bin 39424 -> 39424 bytes
 plugins/core.c                                     |    35 +-
 plugins/loader.c                                   |     2 +-
 python/.gitignore                                  |     4 +-
 python/Makefile                                    |    53 +-
 python/Pipfile                                     |    13 -
 python/Pipfile.lock                                |   347 -
 python/README.rst                                  |     3 -
 python/qemu/machine/console_socket.py              |     2 +-
 python/qemu/machine/machine.py                     |    62 +-
 python/qemu/machine/qtest.py                       |     2 +-
 python/qemu/qmp/legacy.py                          |    18 +-
 python/qemu/qmp/protocol.py                        |    29 +-
 python/qemu/qmp/qmp_client.py                      |     4 +-
 python/qemu/qmp/qmp_tui.py                         |     6 +-
 python/qemu/utils/qemu_ga_client.py                |     6 +-
 python/setup.cfg                                   |    10 +-
 python/tests/minreqs.txt                           |    45 +
 qapi/audio.json                                    |    57 +-
 qapi/block-core.json                               |   150 +-
 qapi/cryptodev.json                                |    89 +
 qapi/cxl.json                                      |   128 +
 qapi/machine.json                                  |     4 +-
 qapi/meson.build                                   |     2 +
 qapi/migration.json                                |    29 +
 qapi/misc-target.json                              |   128 +-
 qapi/misc.json                                     |    36 +-
 qapi/net.json                                      |     7 +-
 qapi/qapi-schema.json                              |     2 +
 qapi/qom.json                                      |     8 +-
 qapi/stats.json                                    |    10 +-
 qapi/ui.json                                       |    15 +-
 qemu-img.c                                         |   122 +-
 qemu-io-cmds.c                                     |   275 +-
 qemu-keymap.c                                      |     2 +
 qemu-nbd.c                                         |    37 +-
 qemu-options.hx                                    |   118 +-
 qga/commands-bsd.c                                 |     5 +
 qga/commands-posix.c                               |    46 +-
 qga/commands-win32.c                               |    80 +-
 qga/commands.c                                     |    11 +-
 qga/cutils.c                                       |     3 +-
 qga/cutils.h                                       |     2 -
 qga/installer/qemu-ga.wxs                          |    31 +-
 qga/main.c                                         |    57 +-
 qga/meson.build                                    |    25 +-
 qga/messages-win32.mc                              |     9 +
 qga/vss-win32/install.cpp                          |     9 +
 qga/vss-win32/qga-vss.def                          |     2 +
 qga/vss-win32/requester.cpp                        |    41 +-
 qga/vss-win32/vss-handles.h                        |     3 +
 qom/object_interfaces.c                            |     2 +-
 qom/qom-hmp-cmds.c                                 |    67 +
 qom/qom-qmp-cmds.c                                 |     7 +-
 replay/replay-debugging.c                          |     1 -
 replay/replay-time.c                               |     5 +-
 replay/replay.c                                    |     6 +-
 replay/stubs-system.c                              |     2 +-
 roms/Makefile                                      |    38 +-
 roms/Makefile.edk2                                 |   178 -
 roms/edk2                                          |     2 +-
 roms/edk2-build.config                             |   124 +
 roms/edk2-build.py                                 |   380 +
 roms/edk2-build.sh                                 |    55 -
 roms/edk2-funcs.sh                                 |   273 -
 roms/openbios                                      |     2 +-
 roms/opensbi                                       |     2 +-
 roms/seabios                                       |     2 +-
 roms/sgabios                                       |     1 -
 scripts/block-coroutine-wrapper.py                 |   201 +-
 scripts/checkpatch.pl                              |     3 +
 .../ci/org.centos/stream/8/build-environment.yml   |    39 +-
 scripts/ci/org.centos/stream/8/x86_64/configure    |     5 +-
 scripts/ci/org.centos/stream/8/x86_64/test-avocado |     8 +-
 scripts/ci/setup/build-environment.yml             |    59 +-
 scripts/ci/setup/gitlab-runner.yml                 |    70 +-
 scripts/ci/setup/vars.yml.template                 |     2 -
 scripts/clean-includes                             |    27 +-
 scripts/coccinelle/return_directly.cocci           |     5 +-
 scripts/coverage/compare_gcov_json.py              |   119 +
 scripts/coverity-scan/COMPONENTS.md                |     3 -
 scripts/git.orderfile                              |     2 +
 scripts/make-config-poison.sh                      |     2 +-
 scripts/make-release                               |    16 +-
 scripts/meson-buildoptions.py                      |     7 +-
 scripts/meson-buildoptions.sh                      |    34 +-
 scripts/oss-fuzz/lsan_suppressions.txt             |     2 +
 scripts/probe-gdb-support.py                       |    88 +
 scripts/qapi/.flake8                               |     3 +-
 scripts/qapi/commands.py                           |     9 +-
 scripts/qapi/events.py                             |     3 +-
 scripts/qapi/expr.py                               |   100 +-
 scripts/qapi/gen.py                                |     2 +-
 scripts/qapi/parser.py                             |    41 +-
 scripts/qapi/pylintrc                              |     1 +
 scripts/qapi/schema.py                             |    86 +-
 scripts/qapi/types.py                              |     2 +-
 scripts/qapi/visit.py                              |    17 +-
 scripts/tracetool/__init__.py                      |    23 -
 scripts/tracetool/transform.py                     |   168 -
 scsi/qemu-pr-helper.c                              |     2 +-
 semihosting/arm-compat-semi.c                      |     1 +
 semihosting/console.c                              |     4 +-
 semihosting/guestfd.c                              |     2 +-
 semihosting/syscalls.c                             |    69 +-
 semihosting/uaccess.c                              |     2 +-
 softmmu/cpus.c                                     |     1 +
 softmmu/dirtylimit.c                               |     1 -
 softmmu/dma-helpers.c                              |    12 +-
 softmmu/globals.c                                  |     6 +-
 softmmu/memory.c                                   |    42 +-
 softmmu/memory_mapping.c                           |     4 +-
 softmmu/meson.build                                |     5 +-
 softmmu/physmem.c                                  |   234 +-
 softmmu/qdev-monitor.c                             |    82 +
 softmmu/qtest.c                                    |     1 -
 softmmu/rtc.c                                      |    11 +-
 softmmu/runstate-hmp-cmds.c                        |    82 +
 softmmu/runstate.c                                 |    36 +-
 softmmu/tpm-hmp-cmds.c                             |    65 +
 softmmu/vl.c                                       |    59 +-
 softmmu/watchpoint.c                               |   226 +
 stats/meson.build                                  |     1 +
 stats/stats-hmp-cmds.c                             |   252 +
 stats/stats-qmp-cmds.c                             |   164 +
 storage-daemon/qemu-storage-daemon.c               |     5 +-
 stubs/graph-lock.c                                 |    10 +
 stubs/meson.build                                  |     3 +-
 stubs/qdev.c                                       |     6 +-
 stubs/replay.c                                     |     2 +-
 stubs/semihost-all.c                               |    17 +
 stubs/semihost.c                                   |     5 -
 stubs/vmgenid.c                                    |    10 -
 subprojects/libvduse/libvduse.c                    |     9 +-
 subprojects/libvduse/meson.build                   |     8 +-
 subprojects/libvhost-user/libvhost-user.c          |    56 +-
 subprojects/libvhost-user/libvhost-user.h          |    22 +-
 subprojects/libvhost-user/meson.build              |     8 +-
 target/alpha/STATUS                                |    28 -
 target/alpha/cpu-param.h                           |     2 -
 target/alpha/cpu.h                                 |     2 +-
 target/alpha/gdbstub.c                             |     2 +-
 target/alpha/sys_helper.c                          |     1 +
 target/alpha/translate.c                           |    73 +-
 target/arm/a32-uncond.decode                       |    74 -
 target/arm/a32.decode                              |   557 -
 target/arm/arm-powerctl.c                          |     7 +-
 target/arm/arm-qmp-cmds.c                          |   257 +
 target/arm/cpregs.h                                |   582 +-
 target/arm/cpu-param.h                             |     4 -
 target/arm/cpu-qom.h                               |     4 +-
 target/arm/cpu.c                                   |    84 +-
 target/arm/cpu.h                                   |   303 +-
 target/arm/cpu64.c                                 |   146 +-
 target/arm/cpu_tcg.c                               |    46 +
 target/arm/crypto_helper.c                         |   778 -
 target/arm/debug_helper.c                          |   669 +-
 target/arm/gdbstub.c                               |   283 +-
 target/arm/gdbstub64.c                             |   180 +-
 target/arm/helper-a64.c                            |  1101 --
 target/arm/helper-a64.h                            |     8 -
 target/arm/helper-sme.h                            |     3 +-
 target/arm/helper.c                                |  1717 ++-
 target/arm/helper.h                                |    11 +-
 target/arm/hvf/hvf.c                               |   151 +
 target/arm/hvf/trace-events                        |     2 +
 target/arm/internals.h                             |   126 +-
 target/arm/iwmmxt_helper.c                         |   670 -
 target/arm/kvm-consts.h                            |     8 +-
 target/arm/m-nocp.decode                           |    72 -
 target/arm/m_helper.c                              |  2892 ----
 target/arm/machine.c                               |    58 +-
 target/arm/meson.build                             |    48 +-
 target/arm/monitor.c                               |   230 -
 target/arm/mte_helper.c                            |   908 --
 target/arm/mve.decode                              |   832 -
 target/arm/mve_helper.c                            |  3450 -----
 target/arm/neon-dp.decode                          |   646 -
 target/arm/neon-ls.decode                          |    52 -
 target/arm/neon-shared.decode                      |    99 -
 target/arm/neon_helper.c                           |  1740 ---
 target/arm/op_helper.c                             |  1010 --
 target/arm/pauth_helper.c                          |   515 -
 target/arm/psci.c                                  |   222 -
 target/arm/ptw.c                                   |   412 +-
 target/arm/sme-fa64.decode                         |    60 -
 target/arm/sme.decode                              |    88 -
 target/arm/sme_helper.c                            |  1201 --
 target/arm/sve.decode                              |  1702 ---
 target/arm/sve_helper.c                            |  7489 ---------
 target/arm/syndrome.h                              |    10 +
 target/arm/t16.decode                              |   281 -
 target/arm/t32.decode                              |   753 -
 target/arm/tcg-stubs.c                             |    27 +
 target/arm/tcg/a32-uncond.decode                   |    74 +
 target/arm/tcg/a32.decode                          |   557 +
 target/arm/tcg/crypto_helper.c                     |   778 +
 target/arm/tcg/helper-a64.c                        |   954 ++
 target/arm/tcg/hflags.c                            |   403 +
 target/arm/tcg/iwmmxt_helper.c                     |   670 +
 target/arm/tcg/m-nocp.decode                       |    72 +
 target/arm/tcg/m_helper.c                          |  2901 ++++
 target/arm/tcg/meson.build                         |    50 +
 target/arm/tcg/mte_helper.c                        |   909 ++
 target/arm/tcg/mve.decode                          |   832 +
 target/arm/tcg/mve_helper.c                        |  3450 +++++
 target/arm/tcg/neon-dp.decode                      |   646 +
 target/arm/tcg/neon-ls.decode                      |    52 +
 target/arm/tcg/neon-shared.decode                  |    99 +
 target/arm/tcg/neon_helper.c                       |  1740 +++
 target/arm/tcg/op_helper.c                         |  1069 ++
 target/arm/tcg/pauth_helper.c                      |   517 +
 target/arm/tcg/psci.c                              |   222 +
 target/arm/tcg/sme-fa64.decode                     |    60 +
 target/arm/tcg/sme.decode                          |    88 +
 target/arm/tcg/sme_helper.c                        |  1168 ++
 target/arm/tcg/sve.decode                          |  1702 +++
 target/arm/tcg/sve_helper.c                        |  7490 +++++++++
 target/arm/tcg/t16.decode                          |   281 +
 target/arm/tcg/t32.decode                          |   753 +
 target/arm/tcg/tlb_helper.c                        |   278 +
 target/arm/tcg/translate-a64.c                     | 14554 ++++++++++++++++++
 target/arm/tcg/translate-a64.h                     |   198 +
 target/arm/tcg/translate-m-nocp.c                  |   768 +
 target/arm/tcg/translate-mve.c                     |  2262 +++
 target/arm/tcg/translate-neon.c                    |  3935 +++++
 target/arm/tcg/translate-sme.c                     |   357 +
 target/arm/tcg/translate-sve.c                     |  7369 +++++++++
 target/arm/tcg/translate-vfp.c                     |  3420 +++++
 target/arm/tcg/translate.c                         |  9724 ++++++++++++
 target/arm/tcg/translate.h                         |   654 +
 target/arm/tcg/vec_helper.c                        |  2716 ++++
 target/arm/tcg/vec_internal.h                      |   246 +
 target/arm/tcg/vfp-uncond.decode                   |    82 +
 target/arm/tcg/vfp.decode                          |   247 +
 target/arm/tlb_helper.c                            |   292 -
 target/arm/translate-a64.c                         | 15063 -------------------
 target/arm/translate-a64.h                         |   201 -
 target/arm/translate-m-nocp.c                      |   788 -
 target/arm/translate-mve.c                         |  2310 ---
 target/arm/translate-neon.c                        |  4064 -----
 target/arm/translate-sme.c                         |   373 -
 target/arm/translate-sve.c                         |  7583 ----------
 target/arm/translate-vfp.c                         |  3619 -----
 target/arm/translate.c                             |  9941 ------------
 target/arm/translate.h                             |   631 -
 target/arm/vec_helper.c                            |  2716 ----
 target/arm/vec_internal.h                          |   246 -
 target/arm/vfp-uncond.decode                       |    82 -
 target/arm/vfp.decode                              |   247 -
 target/arm/vfp_helper.c                            |    35 +-
 target/avr/cpu-param.h                             |     1 -
 target/avr/cpu-qom.h                               |     4 +-
 target/avr/cpu.c                                   |    16 +-
 target/avr/cpu.h                                   |     4 +-
 target/avr/gdbstub.c                               |     2 +-
 target/avr/translate.c                             |   301 +-
 target/cris/cpu-param.h                            |     1 -
 target/cris/cpu-qom.h                              |     4 +-
 target/cris/cpu.c                                  |    12 +-
 target/cris/cpu.h                                  |     3 +-
 target/cris/gdbstub.c                              |     2 +-
 target/cris/translate.c                            |   167 +-
 target/cris/translate_v10.c.inc                    |    85 +-
 target/hexagon/README                              |    49 +-
 target/hexagon/attribs_def.h.inc                   |     1 +
 target/hexagon/cpu-param.h                         |     2 -
 target/hexagon/cpu.c                               |    22 +-
 target/hexagon/cpu.h                               |    21 +-
 target/hexagon/decode.c                            |    15 +-
 target/hexagon/gdbstub.c                           |     2 +-
 target/hexagon/gen_analyze_funcs.py                |   252 +
 target/hexagon/gen_helper_funcs.py                 |    47 +-
 target/hexagon/gen_helper_protos.py                |    41 +-
 target/hexagon/gen_idef_parser_funcs.py            |   130 +
 target/hexagon/gen_tcg.h                           |   525 +-
 target/hexagon/gen_tcg_funcs.py                    |   298 +-
 target/hexagon/gen_tcg_hvx.h                       |    36 +-
 target/hexagon/genptr.c                            |   895 +-
 target/hexagon/genptr.h                            |    36 +
 target/hexagon/hex_arch_types.h                    |     1 -
 target/hexagon/hex_common.py                       |    50 +-
 target/hexagon/hex_regs.h                          |     2 +-
 target/hexagon/idef-parser/README.rst              |   714 +
 target/hexagon/idef-parser/idef-parser.h           |   251 +
 target/hexagon/idef-parser/idef-parser.lex         |   448 +
 target/hexagon/idef-parser/idef-parser.y           |   916 ++
 target/hexagon/idef-parser/macros.inc              |   131 +
 target/hexagon/idef-parser/parser-helpers.c        |  2145 +++
 target/hexagon/idef-parser/parser-helpers.h        |   366 +
 target/hexagon/idef-parser/prepare                 |    24 +
 target/hexagon/insn.h                              |     9 +-
 target/hexagon/macros.h                            |    59 +-
 target/hexagon/meson.build                         |   168 +-
 target/hexagon/mmvec/macros.h                      |     5 +-
 target/hexagon/op_helper.c                         |    81 +-
 target/hexagon/op_helper.h                         |    36 +
 target/hexagon/translate.c                         |   464 +-
 target/hexagon/translate.h                         |    92 +-
 target/hppa/cpu-param.h                            |     1 -
 target/hppa/cpu.c                                  |     8 +-
 target/hppa/cpu.h                                  |     7 +-
 target/hppa/fpu_helper.c                           |   450 +
 target/hppa/gdbstub.c                              |     2 +-
 target/hppa/insns.decode                           |     5 +-
 target/hppa/meson.build                            |     2 +
 target/hppa/op_helper.c                            |   504 -
 target/hppa/sys_helper.c                           |   101 +
 target/hppa/translate.c                            |   146 +-
 target/i386/cpu-dump.c                             |     5 +-
 target/i386/cpu-param.h                            |     5 -
 target/i386/cpu-qom.h                              |     4 +-
 target/i386/cpu-sysemu.c                           |    22 +-
 target/i386/cpu.c                                  |   240 +-
 target/i386/cpu.h                                  |    42 +-
 target/i386/gdbstub.c                              |     6 +-
 target/i386/hax/hax-all.c                          |     5 +-
 target/i386/hax/hax-i386.h                         |     2 -
 target/i386/helper.c                               |     2 +-
 target/i386/helper.h                               |     6 -
 target/i386/host-cpu.c                             |     1 +
 target/i386/hvf/hvf-i386.h                         |     4 -
 target/i386/kvm/kvm.c                              |   280 +-
 target/i386/kvm/kvm_i386.h                         |     2 +
 target/i386/kvm/meson.build                        |     2 +
 target/i386/kvm/trace-events                       |     7 +
 target/i386/kvm/xen-compat.h                       |    70 +
 target/i386/kvm/xen-emu.c                          |  1903 +++
 target/i386/kvm/xen-emu.h                          |    33 +
 target/i386/machine.c                              |    25 +
 target/i386/monitor.c                              |     7 +-
 target/i386/ops_sse.h                              |     4 +
 target/i386/sev-sysemu-stub.c                      |     1 -
 target/i386/sev.c                                  |     2 +-
 target/i386/tcg/decode-new.c.inc                   |    36 +-
 target/i386/tcg/emit.c.inc                         |     8 +-
 target/i386/tcg/mem_helper.c                       |   126 -
 target/i386/tcg/seg_helper.c                       |     8 +-
 target/i386/tcg/sysemu/excp_helper.c               |     4 +-
 target/i386/tcg/tcg-cpu.c                          |     8 +-
 target/i386/tcg/translate.c                        |   344 +-
 target/i386/whpx/whpx-all.c                        |     4 +-
 target/i386/whpx/whpx-apic.c                       |     1 +
 target/loongarch/cpu-param.h                       |     1 -
 target/loongarch/cpu.c                             |    51 +-
 target/loongarch/cpu.h                             |     9 +-
 target/loongarch/csr_helper.c                      |     9 +
 target/loongarch/disas.c                           |    39 +-
 target/loongarch/gdbstub.c                         |     1 +
 target/loongarch/helper.h                          |     1 +
 target/loongarch/insn_trans/trans_arith.c.inc      |    12 -
 target/loongarch/insn_trans/trans_atomic.c.inc     |     3 -
 target/loongarch/insn_trans/trans_bit.c.inc        |    12 -
 target/loongarch/insn_trans/trans_branch.c.inc     |     2 +-
 target/loongarch/insn_trans/trans_fcmp.c.inc       |     3 -
 target/loongarch/insn_trans/trans_fmemory.c.inc    |    20 +-
 target/loongarch/insn_trans/trans_fmov.c.inc       |     6 -
 target/loongarch/insn_trans/trans_memory.c.inc     |    34 +-
 target/loongarch/insn_trans/trans_privileged.c.inc |    14 +-
 target/loongarch/insn_trans/trans_shift.c.inc      |    11 -
 target/loongarch/insns.decode                      |     3 +-
 target/loongarch/loongarch-qmp-cmds.c              |    37 +
 target/loongarch/meson.build                       |     4 +-
 target/loongarch/tlb_helper.c                      |     2 +-
 target/loongarch/translate.c                       |    26 +-
 target/loongarch/translate.h                       |     3 -
 target/m68k/cpu-param.h                            |     1 -
 target/m68k/cpu-qom.h                              |     4 +-
 target/m68k/cpu.c                                  |    12 +-
 target/m68k/cpu.h                                  |     4 +-
 target/m68k/fpu_helper.c                           |    49 +-
 target/m68k/gdbstub.c                              |     2 +-
 target/m68k/helper.c                               |     1 +
 target/m68k/m68k-semi.c                            |     5 +-
 target/m68k/translate.c                            |   501 +-
 target/microblaze/cpu-param.h                      |     1 -
 target/microblaze/cpu-qom.h                        |     4 +-
 target/microblaze/cpu.c                            |    23 +-
 target/microblaze/cpu.h                            |     8 +-
 target/microblaze/gdbstub.c                        |    47 +-
 target/microblaze/op_helper.c                      |     2 +-
 target/microblaze/translate.c                      |    91 +-
 target/mips/cpu-defs.c.inc                         |    17 +-
 target/mips/cpu-param.h                            |     1 -
 target/mips/cpu-qom.h                              |     4 +-
 target/mips/cpu.c                                  |    55 +-
 target/mips/cpu.h                                  |     4 +-
 target/mips/gdbstub.c                              |     2 +-
 target/mips/internal.h                             |     3 -
 target/mips/kvm.c                                  |    11 +-
 target/mips/sysemu/addr.c                          |    17 -
 target/mips/sysemu/meson.build                     |     1 +
 target/mips/sysemu/mips-qmp-cmds.c                 |    39 +
 target/mips/sysemu/physaddr.c                      |    16 +-
 target/mips/tcg/dsp_helper.c                       |    15 +-
 target/mips/tcg/exception.c                        |     3 +-
 target/mips/tcg/ldst_helper.c                      |     4 +-
 target/mips/tcg/micromips_translate.c.inc          |    12 +-
 target/mips/tcg/mips16e_translate.c.inc            |     6 -
 target/mips/tcg/msa_helper.c                       |   104 +-
 target/mips/tcg/msa_translate.c                    |     9 -
 target/mips/tcg/mxu_translate.c                    |    55 +-
 target/mips/tcg/nanomips_translate.c.inc           |   147 +-
 target/mips/tcg/octeon_translate.c                 |    23 -
 target/mips/tcg/sysemu/mips-semi.c                 |     3 +-
 target/mips/tcg/sysemu/special_helper.c            |     2 +-
 target/mips/tcg/sysemu/tlb_helper.c                |     2 +-
 target/mips/tcg/translate.c                        |   887 +-
 target/mips/tcg/translate_addr_const.c             |     7 -
 target/mips/tcg/tx79_translate.c                   |    45 +-
 target/mips/tcg/vr54xx_translate.c                 |     6 +-
 target/nios2/cpu-param.h                           |     1 -
 target/nios2/cpu.c                                 |    14 +-
 target/nios2/cpu.h                                 |     6 +-
 target/nios2/nios2-semi.c                          |     9 +-
 target/nios2/translate.c                           |    19 +-
 target/openrisc/cpu-param.h                        |     1 -
 target/openrisc/cpu.c                              |    16 +-
 target/openrisc/cpu.h                              |     7 +-
 target/openrisc/gdbstub.c                          |     2 +-
 target/openrisc/interrupt.c                        |     2 +-
 target/openrisc/mmu.c                              |     2 +-
 target/openrisc/translate.c                        |    41 +-
 target/ppc/cpu-param.h                             |     1 -
 target/ppc/cpu-qom.h                               |     6 +-
 target/ppc/cpu.h                                   |    21 +-
 target/ppc/cpu_init.c                              |    87 +-
 target/ppc/dfp_helper.c                            |     4 +-
 target/ppc/excp_helper.c                           |    75 +-
 target/ppc/gdbstub.c                               |     1 +
 target/ppc/helper.h                                |     2 -
 target/ppc/helper_regs.c                           |    14 +-
 target/ppc/insn32.decode                           |    20 +-
 target/ppc/internal.h                              |     5 +
 target/ppc/kvm.c                                   |     1 -
 target/ppc/kvm_ppc.h                               |     3 +
 target/ppc/mem_helper.c                            |    44 -
 target/ppc/meson.build                             |     2 +-
 target/ppc/mmu-hash32.c                            |    14 +-
 target/ppc/mmu-hash64.c                            |    84 +-
 target/ppc/mmu-hash64.h                            |     5 +
 target/ppc/mmu_common.c                            |    31 +-
 target/ppc/mmu_helper.c                            |     4 +-
 target/ppc/monitor.c                               |   174 -
 target/ppc/power8-pmu-regs.c.inc                   |    20 +-
 target/ppc/ppc-qmp-cmds.c                          |   222 +
 target/ppc/spr_common.h                            |     1 +
 target/ppc/translate.c                             |   564 +-
 target/ppc/translate/dfp-impl.c.inc                |    20 -
 target/ppc/translate/fixedpoint-impl.c.inc         |    66 +-
 target/ppc/translate/fp-impl.c.inc                 |   168 +-
 target/ppc/translate/spe-impl.c.inc                |    67 +-
 target/ppc/translate/storage-ctrl-impl.c.inc       |     2 -
 target/ppc/translate/vmx-impl.c.inc                |   430 +-
 target/ppc/translate/vsx-impl.c.inc                |   323 +-
 target/riscv/cpu-param.h                           |     1 -
 target/riscv/cpu.c                                 |   889 +-
 target/riscv/cpu.h                                 |   115 +-
 target/riscv/cpu_bits.h                            |    41 +
 target/riscv/cpu_helper.c                          |    78 +-
 target/riscv/cpu_vendorid.h                        |     6 +
 target/riscv/csr.c                                 |   822 +-
 target/riscv/debug.c                               |   212 +-
 target/riscv/debug.h                               |    13 +
 target/riscv/fpu_helper.c                          |    36 +-
 target/riscv/gdbstub.c                             |   101 +-
 target/riscv/helper.h                              |    10 +-
 target/riscv/insn32.decode                         |    24 +-
 target/riscv/insn_trans/trans_privileged.c.inc     |     4 +-
 target/riscv/insn_trans/trans_rva.c.inc            |    10 +-
 target/riscv/insn_trans/trans_rvb.c.inc            |    25 +-
 target/riscv/insn_trans/trans_rvd.c.inc            |     4 +-
 target/riscv/insn_trans/trans_rvf.c.inc            |    11 +-
 target/riscv/insn_trans/trans_rvh.c.inc            |     3 +
 target/riscv/insn_trans/trans_rvi.c.inc            |    47 +-
 target/riscv/insn_trans/trans_rvk.c.inc            |    15 -
 target/riscv/insn_trans/trans_rvm.c.inc            |    33 -
 target/riscv/insn_trans/trans_rvv.c.inc            |   271 +-
 target/riscv/insn_trans/trans_rvzawrs.c.inc        |    51 +
 target/riscv/insn_trans/trans_rvzfh.c.inc          |    41 +-
 target/riscv/insn_trans/trans_rvzicbo.c.inc        |    57 +
 target/riscv/insn_trans/trans_rvzicond.c.inc       |    49 +
 target/riscv/insn_trans/trans_svinval.c.inc        |     3 +
 target/riscv/insn_trans/trans_xthead.c.inc         |  1068 ++
 target/riscv/kvm.c                                 |     5 +-
 target/riscv/machine.c                             |    47 +-
 target/riscv/meson.build                           |     1 +
 target/riscv/monitor.c                             |     4 +-
 target/riscv/op_helper.c                           |   171 +-
 target/riscv/pmp.c                                 |   101 +-
 target/riscv/pmp.h                                 |     6 +-
 target/riscv/pmu.h                                 |     1 -
 target/riscv/time_helper.c                         |    36 +-
 target/riscv/translate.c                           |   164 +-
 target/riscv/vector_helper.c                       |   136 +-
 target/riscv/xthead.decode                         |   185 +
 target/rx/cpu-param.h                              |     2 -
 target/rx/cpu-qom.h                                |     4 +-
 target/rx/cpu.c                                    |    16 +-
 target/rx/cpu.h                                    |     2 +-
 target/rx/gdbstub.c                                |     2 +-
 target/rx/helper.c                                 |     4 +-
 target/rx/translate.c                              |   170 +-
 target/s390x/arch_dump.c                           |    20 +-
 target/s390x/cpu-param.h                           |     1 -
 target/s390x/cpu-sysemu.c                          |     1 +
 target/s390x/cpu.c                                 |    30 +-
 target/s390x/cpu.h                                 |    10 +
 target/s390x/cpu_features.c                        |     4 +
 target/s390x/cpu_models.c                          |     5 +-
 target/s390x/cpu_models_sysemu.c                   |     1 -
 target/s390x/diag.c                                |     2 +
 target/s390x/gdbstub.c                             |     1 +
 target/s390x/helper.c                              |     2 +-
 target/s390x/helper.h                              |    60 +-
 target/s390x/mmu_helper.c                          |     2 +-
 target/s390x/tcg/excp_helper.c                     |    17 +-
 target/s390x/tcg/fpu_helper.c                      |   110 +-
 target/s390x/tcg/insn-data.h.inc                   |   120 +-
 target/s390x/tcg/int_helper.c                      |    64 +-
 target/s390x/tcg/mem_helper.c                      |   404 +-
 target/s390x/tcg/misc_helper.c                     |     1 -
 target/s390x/tcg/translate.c                       |   968 +-
 target/s390x/tcg/translate_vx.c.inc                |   190 +-
 target/sh4/cpu-param.h                             |     1 -
 target/sh4/cpu-qom.h                               |     4 +-
 target/sh4/cpu.c                                   |    18 +-
 target/sh4/cpu.h                                   |     2 +-
 target/sh4/gdbstub.c                               |     2 +-
 target/sh4/translate.c                             |   161 +-
 target/sparc/cpu-param.h                           |     2 -
 target/sparc/cpu-qom.h                             |     4 +-
 target/sparc/cpu.c                                 |    16 +-
 target/sparc/cpu.h                                 |     6 +-
 target/sparc/gdbstub.c                             |     2 +-
 target/sparc/ldst_helper.c                         |     6 +-
 target/sparc/mmu_helper.c                          |   133 +-
 target/sparc/translate.c                           |   374 +-
 target/tricore/cpu-param.h                         |     1 -
 target/tricore/cpu-qom.h                           |     2 +-
 target/tricore/cpu.c                               |    15 +-
 target/tricore/cpu.h                               |    11 -
 target/tricore/gdbstub.c                           |     4 +-
 target/tricore/helper.c                            |     2 +-
 target/tricore/translate.c                         |  1069 +-
 target/xtensa/core-dc232b.c                        |     2 +-
 target/xtensa/core-dc233c.c                        |     2 +-
 target/xtensa/core-de212.c                         |     2 +-
 target/xtensa/core-de233_fpu.c                     |     2 +-
 target/xtensa/core-dsp3400.c                       |     2 +-
 target/xtensa/core-fsf.c                           |     2 +-
 target/xtensa/core-lx106.c                         |     2 +-
 target/xtensa/core-sample_controller.c             |     2 +-
 target/xtensa/core-test_kc705_be.c                 |     2 +-
 target/xtensa/core-test_mmuhifi_c3.c               |     2 +-
 target/xtensa/cpu-param.h                          |     1 -
 target/xtensa/cpu-qom.h                            |     4 +-
 target/xtensa/cpu.c                                |    15 +-
 target/xtensa/cpu.h                                |     2 +-
 target/xtensa/gdbstub.c                            |     2 +-
 target/xtensa/helper.c                             |     2 +-
 target/xtensa/import_core.sh                       |     2 +-
 target/xtensa/translate.c                          |   189 +-
 tcg/README                                         |   784 -
 tcg/aarch64/tcg-target.c.inc                       |   136 +-
 tcg/aarch64/tcg-target.h                           |    12 +-
 tcg/arm/tcg-target-con-set.h                       |     7 +-
 tcg/arm/tcg-target-con-str.h                       |     2 +
 tcg/arm/tcg-target.c.inc                           |   157 +-
 tcg/arm/tcg-target.h                               |    11 +-
 tcg/i386/tcg-target-con-set.h                      |     5 +-
 tcg/i386/tcg-target.c.inc                          |   160 +-
 tcg/i386/tcg-target.h                              |    21 +-
 tcg/loongarch64/tcg-insn-defs.c.inc                |    10 +-
 tcg/loongarch64/tcg-target-con-set.h               |     5 +-
 tcg/loongarch64/tcg-target-con-str.h               |     2 +-
 tcg/loongarch64/tcg-target.c.inc                   |   404 +-
 tcg/loongarch64/tcg-target.h                       |    19 +-
 tcg/mips/tcg-target.c.inc                          |    79 +-
 tcg/mips/tcg-target.h                              |    12 +-
 tcg/optimize.c                                     |    12 +-
 tcg/ppc/tcg-target.c.inc                           |   251 +-
 tcg/ppc/tcg-target.h                               |     7 +-
 tcg/region.c                                       |    19 +-
 tcg/riscv/tcg-target.c.inc                         |   159 +-
 tcg/riscv/tcg-target.h                             |    14 +-
 tcg/s390x/tcg-target-con-set.h                     |    26 +-
 tcg/s390x/tcg-target-con-str.h                     |    11 +-
 tcg/s390x/tcg-target.c.inc                         |  1314 +-
 tcg/s390x/tcg-target.h                             |    68 +-
 tcg/sparc64/tcg-target.c.inc                       |   201 +-
 tcg/sparc64/tcg-target.h                           |     9 +-
 tcg/tcg-common.c                                   |     2 +-
 tcg/tcg-internal.h                                 |    75 +-
 tcg/tcg-op-gvec.c                                  |   191 +-
 tcg/tcg-op-vec.c                                   |    45 +-
 tcg/tcg-op.c                                       |   716 +-
 tcg/tcg.c                                          |  2421 ++-
 tcg/tci.c                                          |    63 +-
 tcg/tci/tcg-target.c.inc                           |    65 +-
 tcg/tci/tcg-target.h                               |    14 +-
 tests/avocado/acpi-bits.py                         |     2 +-
 tests/avocado/acpi-bits/bits-tests/smbios.py2      |     4 +
 tests/avocado/acpi-bits/bits-tests/testacpi.py2    |     4 +
 tests/avocado/acpi-bits/bits-tests/testcpuid.py2   |     4 +
 tests/avocado/avocado_qemu/__init__.py             |    16 +-
 tests/avocado/boot_linux.py                        |    51 +-
 tests/avocado/boot_linux_console.py                |    67 +-
 tests/avocado/kvm_xen_guest.py                     |   171 +
 tests/avocado/machine_aarch64_virt.py              |    71 +-
 tests/avocado/machine_aspeed.py                    |    70 +-
 tests/avocado/machine_mips_malta.py                |    43 +-
 tests/avocado/multiprocess.py                      |     1 +
 tests/avocado/netdev-ethtool.py                    |   116 +
 tests/avocado/replay_kernel.py                     |     1 +
 tests/avocado/reverse_debugging.py                 |     8 +
 tests/avocado/riscv_opensbi.py                     |    65 +
 tests/avocado/tuxrun_baselines.py                  |   410 +
 tests/avocado/version.py                           |     1 +
 tests/avocado/virtiofs_submounts.py                |   217 -
 tests/bench/benchmark-crypto-akcipher.c            |     6 +-
 tests/bench/meson.build                            |    10 +
 tests/bench/qtree-bench.c                          |   286 +
 tests/bench/xbzrle-bench.c                         |   469 +
 tests/check-block.sh                               |    43 -
 tests/data/acpi/pc/DSDT                            |   Bin 6458 -> 6488 bytes
 tests/data/acpi/pc/DSDT.acpierst                   |   Bin 6418 -> 6411 bytes
 tests/data/acpi/pc/DSDT.acpihmat                   |   Bin 7783 -> 7813 bytes
 tests/data/acpi/pc/DSDT.bridge                     |   Bin 9532 -> 12615 bytes
 tests/data/acpi/pc/DSDT.cphp                       |   Bin 6922 -> 6952 bytes
 tests/data/acpi/pc/DSDT.dimmpxm                    |   Bin 8112 -> 8142 bytes
 tests/data/acpi/pc/DSDT.hpbridge                   |   Bin 6418 -> 6451 bytes
 tests/data/acpi/pc/DSDT.hpbrroot                   |   Bin 3064 -> 3343 bytes
 tests/data/acpi/pc/DSDT.ipmikcs                    |   Bin 6530 -> 6560 bytes
 tests/data/acpi/pc/DSDT.memhp                      |   Bin 7817 -> 7847 bytes
 tests/data/acpi/pc/DSDT.nohpet                     |   Bin 6316 -> 6346 bytes
 tests/data/acpi/pc/DSDT.numamem                    |   Bin 6464 -> 6494 bytes
 tests/data/acpi/pc/DSDT.roothp                     |   Bin 6656 -> 9873 bytes
 tests/data/acpi/q35/DSDT                           |   Bin 8310 -> 8361 bytes
 tests/data/acpi/q35/DSDT.acpierst                  |   Bin 8327 -> 8378 bytes
 tests/data/acpi/q35/DSDT.acpihmat                  |   Bin 9635 -> 9686 bytes
 tests/data/acpi/q35/DSDT.acpihmat-noinitiator      |   Bin 8589 -> 8640 bytes
 tests/data/acpi/q35/DSDT.applesmc                  |   Bin 8356 -> 8407 bytes
 tests/data/acpi/q35/DSDT.bridge                    |   Bin 11439 -> 11590 bytes
 tests/data/acpi/q35/DSDT.core-count2               |   Bin 32450 -> 32501 bytes
 tests/data/acpi/q35/DSDT.cphp                      |   Bin 8774 -> 8825 bytes
 tests/data/acpi/q35/DSDT.cxl                       |   Bin 9636 -> 9673 bytes
 tests/data/acpi/q35/DSDT.dimmpxm                   |   Bin 9964 -> 10015 bytes
 tests/data/acpi/q35/DSDT.ipmibt                    |   Bin 8385 -> 8436 bytes
 tests/data/acpi/q35/DSDT.ipmismbus                 |   Bin 8398 -> 8449 bytes
 tests/data/acpi/q35/DSDT.ivrs                      |   Bin 8327 -> 8378 bytes
 tests/data/acpi/q35/DSDT.memhp                     |   Bin 9669 -> 9720 bytes
 tests/data/acpi/q35/DSDT.mmio64                    |   Bin 9440 -> 9491 bytes
 tests/data/acpi/q35/DSDT.multi-bridge              |   Bin 8630 -> 12770 bytes
 tests/data/acpi/q35/DSDT.noacpihp                  |   Bin 0 -> 8248 bytes
 tests/data/acpi/q35/DSDT.nohpet                    |   Bin 8168 -> 8219 bytes
 tests/data/acpi/q35/DSDT.numamem                   |   Bin 8316 -> 8367 bytes
 tests/data/acpi/q35/DSDT.pvpanic-isa               |   Bin 8411 -> 8462 bytes
 tests/data/acpi/q35/DSDT.tis.tpm12                 |   Bin 8916 -> 8967 bytes
 tests/data/acpi/q35/DSDT.tis.tpm2                  |   Bin 8942 -> 8993 bytes
 tests/data/acpi/q35/DSDT.viot                      |   Bin 9419 -> 9470 bytes
 tests/data/acpi/q35/DSDT.xapic                     |   Bin 35673 -> 35724 bytes
 tests/data/acpi/virt/APIC.memhp                    |   Bin 172 -> 0 bytes
 tests/data/acpi/virt/APIC.numamem                  |   Bin 172 -> 0 bytes
 tests/data/acpi/virt/APIC.topology                 |   Bin 0 -> 732 bytes
 tests/data/acpi/virt/DSDT.numamem                  |   Bin 5196 -> 0 bytes
 tests/data/acpi/virt/DSDT.topology                 |   Bin 0 -> 5398 bytes
 tests/data/acpi/virt/FACP.memhp                    |   Bin 276 -> 0 bytes
 tests/data/acpi/virt/FACP.numamem                  |   Bin 276 -> 0 bytes
 tests/data/acpi/virt/GTDT.memhp                    |   Bin 96 -> 0 bytes
 tests/data/acpi/virt/GTDT.numamem                  |   Bin 96 -> 0 bytes
 tests/data/acpi/virt/IORT.memhp                    |   Bin 128 -> 0 bytes
 tests/data/acpi/virt/IORT.numamem                  |   Bin 128 -> 0 bytes
 tests/data/acpi/virt/IORT.pxb                      |   Bin 128 -> 0 bytes
 tests/data/acpi/virt/MCFG.memhp                    |   Bin 60 -> 0 bytes
 tests/data/acpi/virt/MCFG.numamem                  |   Bin 60 -> 0 bytes
 tests/data/acpi/virt/PPTT                          |   Bin 96 -> 76 bytes
 tests/data/acpi/virt/PPTT.acpihmatvirt             |   Bin 196 -> 156 bytes
 tests/data/acpi/virt/PPTT.topology                 |   Bin 0 -> 336 bytes
 tests/data/acpi/virt/SPCR.memhp                    |   Bin 80 -> 0 bytes
 tests/data/acpi/virt/SPCR.numamem                  |   Bin 80 -> 0 bytes
 tests/data/acpi/virt/SRAT.acpihmatvirt             |   Bin 240 -> 240 bytes
 tests/data/acpi/virt/SSDT.memhp                    |   Bin 1817 -> 1817 bytes
 tests/docker/Makefile.include                      |    33 +-
 tests/docker/docker.py                             |     6 +-
 tests/docker/dockerfiles/alpine.docker             |    11 +-
 tests/docker/dockerfiles/centos8.docker            |    33 +-
 .../dockerfiles/debian-all-test-cross.docker       |     5 +
 tests/docker/dockerfiles/debian-alpha-cross.docker |     5 +
 tests/docker/dockerfiles/debian-amd64-cross.docker |     9 +-
 tests/docker/dockerfiles/debian-amd64.docker       |    11 +-
 tests/docker/dockerfiles/debian-arm64-cross.docker |     9 +-
 tests/docker/dockerfiles/debian-armel-cross.docker |     9 +-
 tests/docker/dockerfiles/debian-armhf-cross.docker |     9 +-
 .../debian-hexagon-cross.d/build-toolchain.sh      |   141 -
 .../docker/dockerfiles/debian-hexagon-cross.docker |    58 +-
 tests/docker/dockerfiles/debian-hppa-cross.docker  |     5 +
 .../dockerfiles/debian-loongarch-cross.docker      |     5 +
 tests/docker/dockerfiles/debian-m68k-cross.docker  |     5 +
 tests/docker/dockerfiles/debian-mips-cross.docker  |     5 +
 .../docker/dockerfiles/debian-mips64-cross.docker  |     5 +
 .../dockerfiles/debian-mips64el-cross.docker       |     9 +-
 .../docker/dockerfiles/debian-mipsel-cross.docker  |     9 +-
 tests/docker/dockerfiles/debian-native.docker      |     5 +
 .../dockerfiles/debian-powerpc-test-cross.docker   |     6 +-
 .../docker/dockerfiles/debian-ppc64el-cross.docker |     9 +-
 .../docker/dockerfiles/debian-riscv64-cross.docker |     6 +
 .../dockerfiles/debian-riscv64-test-cross.docker   |     5 +
 tests/docker/dockerfiles/debian-s390x-cross.docker |     9 +-
 tests/docker/dockerfiles/debian-sh4-cross.docker   |     5 +
 .../docker/dockerfiles/debian-sparc64-cross.docker |     5 +
 tests/docker/dockerfiles/debian-toolchain.docker   |    10 +-
 .../docker/dockerfiles/debian-tricore-cross.docker |    17 +-
 .../docker/dockerfiles/debian-xtensa-cross.docker  |     5 +
 tests/docker/dockerfiles/fedora-cris-cross.docker  |     5 +
 tests/docker/dockerfiles/fedora-i386-cross.docker  |     6 +
 tests/docker/dockerfiles/fedora-win32-cross.docker |    16 +-
 tests/docker/dockerfiles/fedora-win64-cross.docker |    16 +-
 tests/docker/dockerfiles/fedora.docker             |    15 +-
 tests/docker/dockerfiles/opensuse-leap.docker      |    33 +-
 tests/docker/dockerfiles/python.docker             |     6 +-
 tests/docker/dockerfiles/ubuntu2004.docker         |    16 +-
 tests/docker/dockerfiles/ubuntu2204.docker         |   153 +
 tests/docker/test-tsan                             |     2 +-
 tests/fp/berkeley-testfloat-3                      |     2 +-
 tests/fp/fp-test.c                                 |    19 +-
 tests/fp/meson.build                               |     3 +-
 tests/lcitool/libvirt-ci                           |     2 +-
 tests/lcitool/mappings.yml                         |    77 +
 tests/lcitool/projects/qemu.yml                    |     4 +-
 tests/lcitool/refresh                              |    32 +-
 tests/lcitool/targets/centos-stream-8.yml          |     3 +
 tests/lcitool/targets/opensuse-leap-153.yml        |     3 +
 tests/migration/guestperf/engine.py                |    30 +-
 tests/migration/meson.build                        |     4 +-
 tests/qapi-schema/meson.build                      |    13 +-
 tests/qemu-iotests/022                             |     4 +-
 tests/qemu-iotests/065                             |     2 +-
 tests/qemu-iotests/106                             |     4 +-
 tests/qemu-iotests/186                             |     1 +
 tests/qemu-iotests/214                             |     6 +-
 tests/qemu-iotests/262                             |     3 +-
 tests/qemu-iotests/302.out                         |     5 +
 tests/qemu-iotests/308                             |    47 +-
 tests/qemu-iotests/308.out                         |    35 +
 tests/qemu-iotests/312                             |     1 +
 tests/qemu-iotests/check                           |    32 +-
 tests/qemu-iotests/common.filter                   |    22 +-
 tests/qemu-iotests/common.rc                       |    22 +-
 tests/qemu-iotests/iotests.py                      |    22 +-
 tests/qemu-iotests/meson.build                     |    36 +-
 tests/qemu-iotests/testenv.py                      |    20 +-
 tests/qemu-iotests/testrunner.py                   |    43 +-
 .../tests/detect-zeroes-registered-buf             |    58 +
 .../tests/detect-zeroes-registered-buf.out         |     7 +
 .../tests/migrate-bitmaps-postcopy-test            |     2 +-
 tests/qemu-iotests/tests/qemu-img-close-errors     |    96 +
 tests/qemu-iotests/tests/qemu-img-close-errors.out |    23 +
 tests/qemu-iotests/tests/regression-vhdx-log       |    62 +
 tests/qemu-iotests/tests/regression-vhdx-log.out   |    14 +
 tests/qemu-iotests/tests/stream-under-throttle     |     2 +
 tests/qtest/ahci-test.c                            |     3 +
 tests/qtest/arm-cpu-features.c                     |    23 +-
 tests/qtest/bios-tables-test.c                     |   250 +-
 tests/qtest/boot-sector.c                          |     6 +-
 tests/qtest/boot-serial-test.c                     |     2 +-
 tests/qtest/dbus-display-test.c                    |     5 +-
 tests/qtest/device-plug-test.c                     |    41 +-
 tests/qtest/display-vga-test.c                     |    65 +-
 tests/qtest/drive_del-test.c                       |    65 +
 tests/qtest/e1000e-test.c                          |    38 +-
 tests/qtest/erst-test.c                            |     7 +-
 tests/qtest/fuzz-lsi53c895a-test.c                 |     4 +
 tests/qtest/fuzz/fork_fuzz.c                       |    41 -
 tests/qtest/fuzz/fork_fuzz.h                       |    23 -
 tests/qtest/fuzz/fork_fuzz.ld                      |    56 -
 tests/qtest/fuzz/fuzz.c                            |     6 +
 tests/qtest/fuzz/fuzz.h                            |     2 +-
 tests/qtest/fuzz/generic_fuzz.c                    |   120 +-
 tests/qtest/fuzz/generic_fuzz_configs.h            |     5 +
 tests/qtest/fuzz/i440fx_fuzz.c                     |    27 +-
 tests/qtest/fuzz/meson.build                       |     6 +-
 tests/qtest/fuzz/qos_fuzz.c                        |     3 +-
 tests/qtest/fuzz/virtio_blk_fuzz.c                 |    51 +-
 tests/qtest/fuzz/virtio_net_fuzz.c                 |    54 +-
 tests/qtest/fuzz/virtio_scsi_fuzz.c                |    51 +-
 tests/qtest/hd-geo-test.c                          |    38 +-
 tests/qtest/hexloader-test.c                       |     6 +-
 tests/qtest/ide-test.c                             |     3 +-
 tests/qtest/igb-test.c                             |   256 +
 tests/qtest/ivshmem-test.c                         |     4 +-
 tests/qtest/libqmp.c                               |     2 +-
 tests/qtest/libqos/e1000e.c                        |    40 +-
 tests/qtest/libqos/e1000e.h                        |    18 +-
 tests/qtest/libqos/igb.c                           |   185 +
 tests/qtest/libqos/libqos-pc.h                     |     6 +-
 tests/qtest/libqos/libqos-spapr.h                  |     6 +-
 tests/qtest/libqos/libqos.h                        |     6 +-
 tests/qtest/libqos/meson.build                     |     1 +
 tests/qtest/libqos/virtio-9p.c                     |     1 +
 tests/qtest/libqtest.c                             |   186 +-
 tests/qtest/libqtest.h                             |     5 +-
 tests/qtest/meson.build                            |    46 +-
 tests/qtest/microbit-test.c                        |     2 +-
 tests/qtest/migration-helpers.h                    |     1 +
 tests/qtest/migration-test.c                       |    45 +-
 tests/qtest/netdev-socket.c                        |   549 +
 tests/qtest/npcm7xx_pwm-test.c                     |    27 +-
 tests/qtest/pvpanic-pci-test.c                     |     6 +-
 tests/qtest/pvpanic-test.c                         |     6 +-
 tests/qtest/pxe-test.c                             |     4 +
 tests/qtest/qmp-cmd-test.c                         |     3 +-
 tests/qtest/qom-test.c                             |    16 +-
 tests/qtest/readconfig-test.c                      |    42 +-
 tests/qtest/rtas-test.c                            |     2 +-
 tests/qtest/rtl8139-test.c                         |    18 +-
 tests/qtest/tco-test.c                             |     6 +-
 tests/qtest/test-filter-mirror.c                   |     6 +-
 tests/qtest/test-hmp.c                             |     2 +-
 tests/qtest/tpm-emu.c                              |    12 +-
 tests/qtest/usb-hcd-uhci-test.c                    |     4 +-
 tests/qtest/vhost-user-blk-test.c                  |     6 +
 tests/qtest/virtio-ccw-test.c                      |     6 +-
 tests/qtest/vnc-display-test.c                     |    15 +-
 tests/tcg/Makefile.target                          |    11 +-
 tests/tcg/aarch64/Makefile.softmmu-target          |     7 +
 tests/tcg/aarch64/Makefile.target                  |    14 +-
 tests/tcg/aarch64/sme-outprod1.c                   |    83 +
 tests/tcg/aarch64/sysregs.c                        |    24 +-
 tests/tcg/aarch64/system/boot.S                    |     3 +-
 tests/tcg/aarch64/system/semiheap.c                |     4 +-
 tests/tcg/hexagon/Makefile.target                  |    43 +-
 tests/tcg/hexagon/crt.S                            |    14 +
 tests/tcg/hexagon/fpstuff.c                        |    31 +-
 tests/tcg/hexagon/hvx_misc.c                       |    72 +
 tests/tcg/hexagon/mem_noshuf.c                     |     2 +-
 tests/tcg/hexagon/misc.c                           |     6 +-
 tests/tcg/hexagon/preg_alias.c                     |    10 +-
 tests/tcg/hexagon/reg_mut.c                        |   152 +
 tests/tcg/hexagon/scatter_gather.c                 |   513 +-
 tests/tcg/hexagon/signal_context.c                 |    84 +
 tests/tcg/hexagon/test_abs.S                       |    17 +
 tests/tcg/hexagon/test_bitcnt.S                    |    40 +
 tests/tcg/hexagon/test_bitsplit.S                  |    22 +
 tests/tcg/hexagon/test_call.S                      |    64 +
 tests/tcg/hexagon/test_clobber.S                   |    29 +
 tests/tcg/hexagon/test_cmp.S                       |    31 +
 tests/tcg/hexagon/test_dotnew.S                    |    38 +
 tests/tcg/hexagon/test_ext.S                       |    13 +
 tests/tcg/hexagon/test_fibonacci.S                 |    30 +
 tests/tcg/hexagon/test_hl.S                        |    16 +
 tests/tcg/hexagon/test_hwloops.S                   |    19 +
 tests/tcg/hexagon/test_jmp.S                       |    22 +
 tests/tcg/hexagon/test_lsr.S                       |    36 +
 tests/tcg/hexagon/test_mpyi.S                      |    17 +
 tests/tcg/hexagon/test_packet.S                    |    29 +
 tests/tcg/hexagon/test_reorder.S                   |    33 +
 tests/tcg/hexagon/test_round.S                     |    29 +
 tests/tcg/hexagon/test_vavgw.S                     |    31 +
 tests/tcg/hexagon/test_vcmpb.S                     |    30 +
 tests/tcg/hexagon/test_vcmpw.S                     |    30 +
 tests/tcg/hexagon/test_vlsrw.S                     |    20 +
 tests/tcg/hexagon/test_vmaxh.S                     |    35 +
 tests/tcg/hexagon/test_vminh.S                     |    35 +
 tests/tcg/hexagon/test_vpmpyh.S                    |    28 +
 tests/tcg/hexagon/test_vspliceb.S                  |    31 +
 tests/tcg/hexagon/usr.c                            |    34 +-
 tests/tcg/multiarch/Makefile.target                |    17 +
 tests/tcg/multiarch/munmap-pthread.c               |    16 +-
 tests/tcg/multiarch/nop_func.h                     |    25 +
 tests/tcg/multiarch/sha512.c                       |     9 +-
 tests/tcg/multiarch/system/Makefile.softmmu-target |     6 +-
 tests/tcg/multiarch/test-vma.c                     |    22 +
 tests/tcg/multiarch/vma-pthread.c                  |   207 +
 tests/tcg/s390x/Makefile.softmmu-target            |    22 +-
 tests/tcg/s390x/Makefile.target                    |    24 +-
 tests/tcg/s390x/bal.S                              |    24 +
 tests/tcg/s390x/br-odd.S                           |    16 +
 tests/tcg/s390x/cdsg.c                             |    93 +
 tests/tcg/s390x/cgrl-unaligned.S                   |    16 +
 tests/tcg/s390x/chrl.c                             |    80 +
 tests/tcg/s390x/clrl-unaligned.S                   |    16 +
 tests/tcg/s390x/clst.c                             |    82 +
 tests/tcg/s390x/crl-unaligned.S                    |    16 +
 tests/tcg/s390x/div.c                              |    75 +
 tests/tcg/s390x/ex-branch.c                        |   158 +
 tests/tcg/s390x/ex-odd.S                           |    17 +
 tests/tcg/s390x/ex-relative-long.c                 |   156 +
 tests/tcg/s390x/exrl-ssm-early.S                   |    43 +
 tests/tcg/s390x/lgrl-unaligned.S                   |    16 +
 tests/tcg/s390x/llgfrl-unaligned.S                 |    16 +
 tests/tcg/s390x/long-double.c                      |    24 +
 tests/tcg/s390x/lpsw.S                             |    36 +
 tests/tcg/s390x/lpswe-early.S                      |    38 +
 tests/tcg/s390x/lpswe-unaligned.S                  |    18 +
 tests/tcg/s390x/lrl-unaligned.S                    |    16 +
 tests/tcg/s390x/mxdb.c                             |    30 +
 tests/tcg/s390x/pgm-specification-softmmu.S        |    40 +
 tests/tcg/s390x/pgm-specification-user.c           |    37 +
 tests/tcg/s390x/pgm-specification.mak              |    15 +
 tests/tcg/s390x/rxsbg.c                            |    46 +
 tests/tcg/s390x/sam.S                              |    67 +
 tests/tcg/s390x/softmmu.ld                         |    20 +
 tests/tcg/s390x/ssm-early.S                        |    41 +
 tests/tcg/s390x/stgrl-unaligned.S                  |    16 +
 tests/tcg/s390x/stosm-early.S                      |    41 +
 tests/tcg/s390x/strl-unaligned.S                   |    16 +
 tests/tcg/tricore/Makefile.softmmu-target          |    11 +-
 tests/tcg/tricore/macros.h                         |    76 +-
 tests/tcg/tricore/test_dextr.S                     |    75 +
 tests/tcg/tricore/test_imask.S                     |    10 +
 tests/tcg/tricore/test_insert.S                    |     9 +
 tests/tcg/tricore/test_ld_bu.S                     |    15 +
 tests/tcg/tricore/test_ld_h.S                      |    15 +
 tests/tcg/x86_64/Makefile.target                   |     3 +
 tests/tcg/x86_64/adox.c                            |    69 +
 tests/tcg/xtensa/Makefile.softmmu-target           |     5 +-
 tests/tcg/xtensaeb/Makefile.softmmu-target         |     5 +
 tests/unit/meson.build                             |    11 +-
 tests/unit/ptimer-test-stubs.c                     |     2 +-
 tests/unit/rcutorture.c                            |     3 +-
 tests/unit/socket-helpers.c                        |     2 +-
 tests/unit/test-aio.c                              |     2 +-
 tests/unit/test-bdrv-drain.c                       |   409 +-
 tests/unit/test-block-iothread.c                   |     7 +-
 tests/unit/test-blockjob.c                         |     9 +-
 tests/unit/test-char.c                             |     1 -
 tests/unit/test-coroutine.c                        |     2 -
 tests/unit/test-crypto-block.c                     |     6 -
 tests/unit/test-crypto-tlssession.c                |     4 +-
 tests/unit/test-cutils.c                           |     9 +-
 tests/unit/test-error-report.c                     |   139 +
 tests/unit/test-interval-tree.c                    |   209 +
 tests/unit/test-io-channel-command.c               |    22 +-
 tests/unit/test-io-channel-socket.c                |     1 +
 tests/unit/test-io-channel-tls.c                   |     2 +-
 tests/unit/test-nested-aio-poll.c                  |   130 +
 tests/unit/test-qmp-cmds.c                         |    39 +-
 tests/unit/test-qmp-event.c                        |     4 +-
 tests/unit/test-qobject-input-visitor.c            |     2 +-
 tests/unit/test-qobject-output-visitor.c           |     2 -
 tests/unit/test-qtree.c                            |   333 +
 tests/unit/test-rcu-list.c                         |     5 +-
 tests/unit/test-seccomp.c                          |     1 -
 tests/unit/test-visitor-serialization.c            |     3 +-
 tests/unit/test-vmstate.c                          |     6 +-
 tests/unit/test-xbzrle.c                           |    39 +-
 tests/unit/test-xs-node.c                          |   871 ++
 tests/vhost-user-bridge.c                          |     4 +-
 tests/vm/basevm.py                                 |     3 +-
 tests/vm/centos.aarch64                            |     2 +-
 tests/vm/freebsd                                   |     4 +-
 tests/vm/haiku.x86_64                              |     7 +-
 tests/vm/netbsd                                    |     3 +-
 tests/vm/openbsd                                   |    30 +-
 tools/ebpf/Makefile.ebpf                           |     8 +-
 tools/ebpf/rss.bpf.c                               |    43 +-
 tools/meson.build                                  |    13 -
 tools/virtiofsd/50-qemu-virtiofsd.json.in          |     5 -
 tools/virtiofsd/buffer.c                           |   350 -
 tools/virtiofsd/fuse_common.h                      |   837 --
 tools/virtiofsd/fuse_i.h                           |   107 -
 tools/virtiofsd/fuse_log.c                         |    39 -
 tools/virtiofsd/fuse_log.h                         |    73 -
 tools/virtiofsd/fuse_lowlevel.c                    |  2744 ----
 tools/virtiofsd/fuse_lowlevel.h                    |  1988 ---
 tools/virtiofsd/fuse_misc.h                        |    59 -
 tools/virtiofsd/fuse_opt.c                         |   446 -
 tools/virtiofsd/fuse_opt.h                         |   272 -
 tools/virtiofsd/fuse_signals.c                     |    93 -
 tools/virtiofsd/fuse_virtio.c                      |  1081 --
 tools/virtiofsd/fuse_virtio.h                      |    33 -
 tools/virtiofsd/helper.c                           |   409 -
 tools/virtiofsd/meson.build                        |    18 -
 tools/virtiofsd/passthrough_helpers.h              |    51 -
 tools/virtiofsd/passthrough_ll.c                   |  4520 ------
 tools/virtiofsd/passthrough_seccomp.c              |   182 -
 tools/virtiofsd/passthrough_seccomp.h              |    14 -
 trace-events                                       |     4 -
 trace/meson.build                                  |     5 +-
 trace/trace-hmp-cmds.c                             |   148 +
 ui/cocoa.m                                         |    30 +-
 ui/console.c                                       |    27 +-
 ui/cursor.c                                        |     5 +-
 ui/dbus-clipboard.c                                |    19 +-
 ui/dbus-console.c                                  |    14 +-
 ui/dbus-listener.c                                 |    23 +-
 ui/dbus.c                                          |    39 +-
 ui/egl-headless.c                                  |    17 +-
 ui/egl-helpers.c                                   |    78 +-
 ui/gtk.c                                           |     5 +-
 ui/input.c                                         |    36 +-
 ui/keycodemapdb                                    |     2 +-
 ui/meson.build                                     |     8 +-
 ui/sdl2.c                                          |    36 +-
 ui/shader/texture-blit-flip.vert                   |     1 -
 ui/shader/texture-blit.frag                        |     1 -
 ui/shader/texture-blit.vert                        |     1 -
 ui/spice-app.c                                     |     1 +
 ui/spice-core.c                                    |    56 +-
 ui/spice-display.c                                 |    19 +-
 ui/udmabuf.c                                       |     2 +-
 ui/ui-hmp-cmds.c                                   |   460 +
 ui/ui-qmp-cmds.c                                   |   177 +
 ui/util.c                                          |     3 +-
 ui/vdagent.c                                       |     5 +-
 ui/vnc-clipboard.c                                 |    10 +-
 ui/vnc.c                                           |    18 +-
 ui/vnc.h                                           |     1 -
 util/aio-posix.c                                   |    38 +-
 util/aio-win32.c                                   |    23 +-
 util/async-teardown.c                              |    29 +-
 util/async.c                                       |    51 +-
 util/bitops.c                                      |     8 +-
 util/bufferiszero.c                                |    44 +-
 util/cacheflush.c                                  |    14 +-
 util/cutils.c                                      |    14 +-
 util/envlist.c                                     |   202 +-
 util/error-report.c                                |     1 +
 util/error.c                                       |    21 +-
 util/guest-random.c                                |     2 +-
 util/hbitmap.c                                     |     2 +-
 util/int128.c                                      |    42 +
 util/interval-tree.c                               |   889 ++
 util/log.c                                         |    86 +-
 util/main-loop.c                                   |    64 +-
 util/meson.build                                   |     4 +-
 util/osdep.c                                       |     4 +-
 util/oslib-posix.c                                 |    76 -
 util/oslib-win32.c                                 |   359 +-
 util/qemu-config.c                                 |   230 +-
 util/qemu-coroutine-lock.c                         |    10 +-
 util/qemu-coroutine-sleep.c                        |     1 -
 util/qemu-coroutine.c                              |     1 -
 util/qemu-sockets.c                                |    48 +-
 util/qemu-thread-posix.c                           |    80 +-
 util/qemu-thread-win32.c                           |    82 +-
 util/qht.c                                         |    97 +-
 util/qtree.c                                       |  1390 ++
 util/readline.c                                    |     8 +
 util/thread-context.c                              |    10 +-
 util/trace-events                                  |     1 +
 util/uri.c                                         |     3 +-
 util/userfaultfd.c                                 |    45 +-
 util/vfio-helpers.c                                |    14 +-
 util/vhost-user-server.c                           |     8 +-
 2577 files changed, 190519 insertions(+), 143114 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
deleted file mode 100644
index 4895987da4..0000000000
--- a/.cirrus.yml
+++ /dev/null
@@ -1,109 +0,0 @@
-env:
-  CIRRUS_CLONE_DEPTH: 1
-
-windows_msys2_task:
-  timeout_in: 90m
-  windows_container:
-    image: cirrusci/windowsservercore:2019
-    os_version: 2019
-    cpu: 8
-    memory: 8G
-  env:
-    CIRRUS_SHELL: powershell
-    MSYS: winsymlinks:native
-    MSYSTEM: MINGW64
-    MSYS2_URL: https://github.com/msys2/msys2-installer/releases/download/2022-06-03/msys2-base-x86_64-20220603.sfx.exe
-    MSYS2_FINGERPRINT: 0
-    MSYS2_PACKAGES: "
-      diffutils git grep make pkg-config sed
-      mingw-w64-x86_64-python
-      mingw-w64-x86_64-python-sphinx
-      mingw-w64-x86_64-toolchain
-      mingw-w64-x86_64-SDL2
-      mingw-w64-x86_64-SDL2_image
-      mingw-w64-x86_64-gtk3
-      mingw-w64-x86_64-glib2
-      mingw-w64-x86_64-ninja
-      mingw-w64-x86_64-jemalloc
-      mingw-w64-x86_64-lzo2
-      mingw-w64-x86_64-zstd
-      mingw-w64-x86_64-libjpeg-turbo
-      mingw-w64-x86_64-pixman
-      mingw-w64-x86_64-libgcrypt
-      mingw-w64-x86_64-libpng
-      mingw-w64-x86_64-libssh
-      mingw-w64-x86_64-snappy
-      mingw-w64-x86_64-libusb
-      mingw-w64-x86_64-usbredir
-      mingw-w64-x86_64-libtasn1
-      mingw-w64-x86_64-nettle
-      mingw-w64-x86_64-cyrus-sasl
-      mingw-w64-x86_64-curl
-      mingw-w64-x86_64-gnutls
-      mingw-w64-x86_64-libnfs
-    "
-    CHERE_INVOKING: 1
-  msys2_cache:
-    folder: C:\tools\archive
-    reupload_on_changes: false
-    # These env variables are used to generate fingerprint to trigger the cache procedure
-    # If wanna to force re-populate msys2, increase MSYS2_FINGERPRINT
-    fingerprint_script:
-      - |
-        echo $env:CIRRUS_TASK_NAME
-        echo $env:MSYS2_URL
-        echo $env:MSYS2_FINGERPRINT
-        echo $env:MSYS2_PACKAGES
-    populate_script:
-      - |
-        md -Force C:\tools\archive\pkg
-        $start_time = Get-Date
-        bitsadmin /transfer msys_download /dynamic /download /priority FOREGROUND $env:MSYS2_URL C:\tools\archive\base.exe
-        Write-Output "Download time taken: $((Get-Date).Subtract($start_time))"
-        cd C:\tools
-        C:\tools\archive\base.exe -y
-        del -Force C:\tools\archive\base.exe
-        Write-Output "Base install time taken: $((Get-Date).Subtract($start_time))"
-        $start_time = Get-Date
-
-        ((Get-Content -path C:\tools\msys64\etc\\post-install\\07-pacman-key.post -Raw) -replace '--refresh-keys', '--version') | Set-Content -Path C:\tools\msys64\etc\\post-install\\07-pacman-key.post
-        C:\tools\msys64\usr\bin\bash.exe -lc "sed -i 's/^CheckSpace/#CheckSpace/g' /etc/pacman.conf"
-        C:\tools\msys64\usr\bin\bash.exe -lc "export"
-        C:\tools\msys64\usr\bin\pacman.exe --noconfirm -Sy
-        echo Y | C:\tools\msys64\usr\bin\pacman.exe --noconfirm -Suu --overwrite=*
-        taskkill /F /FI "MODULES eq msys-2.0.dll"
-        tasklist
-        C:\tools\msys64\usr\bin\bash.exe -lc "mv -f /etc/pacman.conf.pacnew /etc/pacman.conf || true"
-        C:\tools\msys64\usr\bin\bash.exe -lc "pacman --noconfirm -Syuu --overwrite=*"
-        Write-Output "Core install time taken: $((Get-Date).Subtract($start_time))"
-        $start_time = Get-Date
-
-        C:\tools\msys64\usr\bin\bash.exe -lc "pacman --noconfirm -S --needed $env:MSYS2_PACKAGES"
-        Write-Output "Package install time taken: $((Get-Date).Subtract($start_time))"
-        $start_time = Get-Date
-
-        del -Force -ErrorAction SilentlyContinue C:\tools\msys64\etc\mtab
-        del -Force -ErrorAction SilentlyContinue C:\tools\msys64\dev\fd
-        del -Force -ErrorAction SilentlyContinue C:\tools\msys64\dev\stderr
-        del -Force -ErrorAction SilentlyContinue C:\tools\msys64\dev\stdin
-        del -Force -ErrorAction SilentlyContinue C:\tools\msys64\dev\stdout
-        del -Force -Recurse -ErrorAction SilentlyContinue C:\tools\msys64\var\cache\pacman\pkg
-        tar cf C:\tools\archive\msys64.tar -C C:\tools\ msys64
-
-        Write-Output "Package archive time taken: $((Get-Date).Subtract($start_time))"
-        del -Force -Recurse -ErrorAction SilentlyContinue c:\tools\msys64 
-  install_script:
-    - |
-      $start_time = Get-Date
-      cd C:\tools
-      ls C:\tools\archive\msys64.tar
-      tar xf C:\tools\archive\msys64.tar
-      Write-Output "Extract msys2 time taken: $((Get-Date).Subtract($start_time))"
-  script:
-    - C:\tools\msys64\usr\bin\bash.exe -lc "mkdir build"
-    - C:\tools\msys64\usr\bin\bash.exe -lc "cd build && ../configure --python=python3"
-    - C:\tools\msys64\usr\bin\bash.exe -lc "cd build && make -j8"
-    - exit $LastExitCode
-  test_script:
-    - C:\tools\msys64\usr\bin\bash.exe -lc "cd build && make V=1 check"
-    - exit $LastExitCode
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
new file mode 100644
index 0000000000..93718ef425
--- /dev/null
+++ b/.git-blame-ignore-revs
@@ -0,0 +1,21 @@
+#
+# List of code-formatting clean ups the git blame can ignore
+#
+#   git blame --ignore-revs-file .git-blame-ignore-revs
+#
+# or
+#
+#   git config blame.ignoreRevsFile .git-blame-ignore-revs
+#
+
+# gdbstub: clean-up indents
+ad9e4585b3c7425759d3eea697afbca71d2c2082
+
+# e1000e: fix code style
+0eadd56bf53ab196a16d492d7dd31c62e1c24c32
+
+# target/riscv: coding style fixes
+8c7feddddd9218b407792120bcfda0347ed16205
+
+# replace TABs with spaces
+48805df9c22a0700fba4b3b548fafaa21726ca68
diff --git a/.gitlab-ci.d/base.yml b/.gitlab-ci.d/base.yml
index 69b36c148a..2fbb58d2a3 100644
--- a/.gitlab-ci.d/base.yml
+++ b/.gitlab-ci.d/base.yml
@@ -6,6 +6,13 @@
 # most restrictive to least restrictive
 #
 .base_job_template:
+  variables:
+    # Each script line from will be in a collapsible section in the job output
+    # and show the duration of each line.
+    FF_SCRIPT_SECTIONS: 1
+
+  interruptible: true
+
   rules:
     #############################################################
     # Stage 1: exclude scenarios where we definitely don't
@@ -68,5 +75,5 @@
     - if: '$QEMU_CI != "2" && $CI_PROJECT_NAMESPACE != "qemu-project"'
       when: manual
 
-    # Jobs can run if any jobs they depend on were successfull
+    # Jobs can run if any jobs they depend on were successful
     - when: on_success
diff --git a/.gitlab-ci.d/buildtest-template.yml b/.gitlab-ci.d/buildtest-template.yml
index 73ecfabb8d..a6cfe9be97 100644
--- a/.gitlab-ci.d/buildtest-template.yml
+++ b/.gitlab-ci.d/buildtest-template.yml
@@ -11,12 +11,10 @@
       fi
     - mkdir build
     - cd build
-    - if test -n "$TARGETS";
-      then
-        ../configure --enable-werror --disable-docs ${LD_JOBS:+--meson=git} $CONFIGURE_ARGS --target-list="$TARGETS" ;
-      else
-        ../configure --enable-werror --disable-docs ${LD_JOBS:+--meson=git} $CONFIGURE_ARGS ;
-      fi || { cat config.log meson-logs/meson-log.txt && exit 1; }
+    - ../configure --enable-werror --disable-docs --enable-fdt=system
+          ${LD_JOBS:+--meson=git} ${TARGETS:+--target-list="$TARGETS"}
+          $CONFIGURE_ARGS ||
+      { cat config.log meson-logs/meson-log.txt && exit 1; }
     - if test -n "$LD_JOBS";
       then
         ../meson/meson.py configure . -Dbackend_max_links="$LD_JOBS" ;
@@ -27,6 +25,22 @@
         make -j"$JOBS" $MAKE_CHECK_ARGS ;
       fi
 
+# We jump some hoops in common_test_job_template to avoid
+# rebuilding all the object files we skip in the artifacts
+.native_build_artifact_template:
+  artifacts:
+    expire_in: 2 days
+    paths:
+      - build
+      - .git-submodule-status
+    exclude:
+      - build/**/*.p
+      - build/**/*.a.p
+      - build/**/*.fa.p
+      - build/**/*.c.o
+      - build/**/*.c.o.d
+      - build/**/*.fa
+
 .common_test_job_template:
   extends: .base_job_template
   stage: test
diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml
index 10886bb414..bb3650a51c 100644
--- a/.gitlab-ci.d/buildtest.yml
+++ b/.gitlab-ci.d/buildtest.yml
@@ -2,20 +2,16 @@ include:
   - local: '/.gitlab-ci.d/buildtest-template.yml'
 
 build-system-alpine:
-  extends: .native_build_job_template
+  extends:
+    - .native_build_job_template
+    - .native_build_artifact_template
   needs:
     - job: amd64-alpine-container
   variables:
     IMAGE: alpine
-    TARGETS: aarch64-softmmu alpha-softmmu cris-softmmu hppa-softmmu
-      microblazeel-softmmu mips64el-softmmu
+    TARGETS: avr-softmmu loongarch64-softmmu mips64-softmmu mipsel-softmmu
     MAKE_CHECK_ARGS: check-build
     CONFIGURE_ARGS: --enable-docs --enable-trace-backends=log,simple,syslog
-  artifacts:
-    expire_in: 2 days
-    paths:
-      - .git-submodule-status
-      - build
 
 check-system-alpine:
   extends: .native_test_job_template
@@ -36,19 +32,17 @@ avocado-system-alpine:
     MAKE_CHECK_ARGS: check-avocado
 
 build-system-ubuntu:
-  extends: .native_build_job_template
+  extends:
+    - .native_build_job_template
+    - .native_build_artifact_template
   needs:
-    job: amd64-ubuntu2004-container
+    job: amd64-ubuntu2204-container
   variables:
-    IMAGE: ubuntu2004
-    CONFIGURE_ARGS: --enable-docs --enable-fdt=system --enable-capstone
-    TARGETS: aarch64-softmmu alpha-softmmu cris-softmmu hppa-softmmu
+    IMAGE: ubuntu2204
+    CONFIGURE_ARGS: --enable-docs
+    TARGETS: alpha-softmmu cris-softmmu hppa-softmmu
       microblazeel-softmmu mips64el-softmmu
     MAKE_CHECK_ARGS: check-build
-  artifacts:
-    expire_in: 2 days
-    paths:
-      - build
 
 check-system-ubuntu:
   extends: .native_test_job_template
@@ -56,7 +50,7 @@ check-system-ubuntu:
     - job: build-system-ubuntu
       artifacts: true
   variables:
-    IMAGE: ubuntu2004
+    IMAGE: ubuntu2204
     MAKE_CHECK_ARGS: check
 
 avocado-system-ubuntu:
@@ -65,22 +59,21 @@ avocado-system-ubuntu:
     - job: build-system-ubuntu
       artifacts: true
   variables:
-    IMAGE: ubuntu2004
+    IMAGE: ubuntu2204
     MAKE_CHECK_ARGS: check-avocado
 
 build-system-debian:
-  extends: .native_build_job_template
+  extends:
+    - .native_build_job_template
+    - .native_build_artifact_template
   needs:
     job: amd64-debian-container
   variables:
     IMAGE: debian-amd64
-    TARGETS: arm-softmmu avr-softmmu i386-softmmu mipsel-softmmu
-      riscv64-softmmu sh4eb-softmmu sparc-softmmu xtensaeb-softmmu
+    CONFIGURE_ARGS: --with-coroutine=sigaltstack
+    TARGETS: arm-softmmu i386-softmmu riscv64-softmmu sh4eb-softmmu
+      sparc-softmmu xtensaeb-softmmu
     MAKE_CHECK_ARGS: check-build
-  artifacts:
-    expire_in: 2 days
-    paths:
-      - build
 
 check-system-debian:
   extends: .native_test_job_template
@@ -113,20 +106,17 @@ crash-test-debian:
     - tests/venv/bin/python3 scripts/device-crash-test -q --tcg-only ./qemu-system-i386
 
 build-system-fedora:
-  extends: .native_build_job_template
+  extends:
+    - .native_build_job_template
+    - .native_build_artifact_template
   needs:
     job: amd64-fedora-container
   variables:
     IMAGE: fedora
     CONFIGURE_ARGS: --disable-gcrypt --enable-nettle --enable-docs
-             --enable-fdt=system --enable-slirp --enable-capstone
     TARGETS: tricore-softmmu microblaze-softmmu mips-softmmu
       xtensa-softmmu m68k-softmmu riscv32-softmmu ppc-softmmu sparc64-softmmu
     MAKE_CHECK_ARGS: check-build
-  artifacts:
-    expire_in: 2 days
-    paths:
-      - build
 
 check-system-fedora:
   extends: .native_test_job_template
@@ -160,21 +150,18 @@ crash-test-fedora:
     - tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-riscv32
 
 build-system-centos:
-  extends: .native_build_job_template
+  extends:
+    - .native_build_job_template
+    - .native_build_artifact_template
   needs:
     job: amd64-centos8-container
   variables:
     IMAGE: centos8
-    CONFIGURE_ARGS: --disable-nettle --enable-gcrypt --enable-fdt=system
+    CONFIGURE_ARGS: --disable-nettle --enable-gcrypt --enable-vfio-user-server
       --enable-modules --enable-trace-backends=dtrace --enable-docs
-      --enable-vfio-user-server
     TARGETS: ppc64-softmmu or1k-softmmu s390x-softmmu
       x86_64-softmmu rx-softmmu sh4-softmmu nios2-softmmu
     MAKE_CHECK_ARGS: check-build
-  artifacts:
-    expire_in: 2 days
-    paths:
-      - build
 
 check-system-centos:
   extends: .native_test_job_template
@@ -195,18 +182,15 @@ avocado-system-centos:
     MAKE_CHECK_ARGS: check-avocado
 
 build-system-opensuse:
-  extends: .native_build_job_template
+  extends:
+    - .native_build_job_template
+    - .native_build_artifact_template
   needs:
     job: amd64-opensuse-leap-container
   variables:
     IMAGE: opensuse-leap
-    CONFIGURE_ARGS: --enable-fdt=system
     TARGETS: s390x-softmmu x86_64-softmmu aarch64-softmmu
     MAKE_CHECK_ARGS: check-build
-  artifacts:
-    expire_in: 2 days
-    paths:
-      - build
 
 check-system-opensuse:
   extends: .native_test_job_template
@@ -244,6 +228,7 @@ build-tcg-disabled:
     - mkdir build
     - cd build
     - ../configure --disable-tcg --audio-drv-list="" --with-coroutine=ucontext
+                   --disable-docs --disable-sdl --disable-gtk --disable-vnc
       || { cat config.log meson-logs/meson-log.txt && exit 1; }
     - make -j"$JOBS"
     - make check-unit
@@ -275,14 +260,10 @@ build-user-static:
     CONFIGURE_ARGS: --disable-tools --disable-system --static
     MAKE_CHECK_ARGS: check-tcg
 
-# Because the hexagon cross-compiler takes so long to build we don't rely
-# on the CI system to build it and hence this job has an optional dependency
-# declared. The image is manually uploaded.
 build-user-hexagon:
   extends: .native_build_job_template
   needs:
     job: hexagon-cross-container
-    optional: true
   variables:
     IMAGE: debian-hexagon-cross
     TARGETS: hexagon-linux-user
@@ -319,8 +300,7 @@ clang-system:
     IMAGE: fedora
     CONFIGURE_ARGS: --cc=clang --cxx=clang++
       --extra-cflags=-fsanitize=undefined --extra-cflags=-fno-sanitize-recover=undefined


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 16:11:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 16:11:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681072.1059647 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHqm-00049S-SG; Wed, 14 Feb 2024 16:11:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681072.1059647; Wed, 14 Feb 2024 16:11:08 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raHqm-00049L-OL; Wed, 14 Feb 2024 16:11:08 +0000
Received: by outflank-mailman (input) for mailman id 681072;
 Wed, 14 Feb 2024 16:11:07 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHql-00049D-Gq
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 16:11:07 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHql-0007fR-E3
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 16:11:07 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raHql-0005xE-Cx
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 16:11:07 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=v/xJNqXtFVjWI+EoHtmMwvOZG+QUlothXfdhPC/uivI=; b=dhi/S4zgyaNRm5J3KlT7y4dDon
	sZ9yjI+gde1iCzLWo0i9QlWYR+rpJwVjMfzURimAG3+pNEySuZCxdvDmHfQc+g87H1qI/k3XuZndh
	vAjAL56VRf27xPrwsusSFTclQKS09/XE5pVKIrXXBUyDI1u1hjKbo9rSo0OZEdNxC2z4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [qemu-xen staging] Merge tag 'v8.0.4' into 'staging'
Message-Id: <E1raHql-0005xE-Cx@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 16:11:07 +0000

=== This changeset includes merge from high-traffic branch ===
Commits on that branch are not reported individually.

commit 0df9387c8983e1b1e72d8c574356f572342c03e6
Merge: 83a9cdbd65ceb4a443630aed011a00ef217ed408 690346043db881debcace7d22249f3355527c5f9
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Wed Aug 16 10:43:53 2023 +0100
Commit:     Anthony PERARD <anthony.perard@citrix.com>
CommitDate: Wed Aug 16 10:43:53 2023 +0100

    Merge tag 'v8.0.4' into 'staging'
 .cirrus.yml                                        |   109 -
 .git-blame-ignore-revs                             |    21 +
 .gitlab-ci.d/base.yml                              |     9 +-
 .gitlab-ci.d/buildtest-template.yml                |    26 +-
 .gitlab-ci.d/buildtest.yml                         |   181 +-
 .gitlab-ci.d/cirrus.yml                            |     6 +-
 .gitlab-ci.d/cirrus/build.yml                      |     7 +-
 .gitlab-ci.d/cirrus/freebsd-12.vars                |     2 +-
 .gitlab-ci.d/cirrus/freebsd-13.vars                |     2 +-
 .gitlab-ci.d/cirrus/macos-12.vars                  |     2 +-
 .gitlab-ci.d/container-cross.yml                   |    22 +-
 .gitlab-ci.d/container-template.yml                |     9 +-
 .gitlab-ci.d/containers.yml                        |     4 +-
 .gitlab-ci.d/crossbuild-template.yml               |    23 +-
 .gitlab-ci.d/crossbuilds.yml                       |    46 +-
 .gitlab-ci.d/custom-runners.yml                    |    12 +
 .../custom-runners/centos-stream-8-x86_64.yml      |    18 +-
 .gitlab-ci.d/custom-runners/ubuntu-20.04-s390x.yml |    23 +-
 .../custom-runners/ubuntu-22.04-aarch32.yml        |     4 +-
 .../custom-runners/ubuntu-22.04-aarch64.yml        |    25 +-
 .gitlab-ci.d/edk2.yml                              |    85 -
 .gitlab-ci.d/edk2/Dockerfile                       |    27 -
 .gitlab-ci.d/opensbi.yml                           |     4 +-
 .gitlab-ci.d/opensbi/Dockerfile                    |     1 +
 .gitlab-ci.d/qemu-project.yml                      |     1 -
 .gitlab-ci.d/static_checks.yml                     |     4 +-
 .gitlab-ci.d/windows.yml                           |    45 +-
 .gitlab/issue_templates/bug.md                     |    16 +-
 .gitmodules                                        |     3 -
 .mailmap                                           |     2 +
 .travis.yml                                        |    59 +-
 MAINTAINERS                                        |   204 +-
 Makefile                                           |     6 +-
 VERSION                                            |     2 +-
 accel/accel-blocker.c                              |   154 +
 accel/accel-softmmu.c                              |     2 +-
 accel/kvm/kvm-accel-ops.c                          |     8 +
 accel/kvm/kvm-all.c                                |   135 +-
 accel/kvm/kvm-cpus.h                               |     4 +-
 accel/meson.build                                  |    11 +-
 accel/stubs/tcg-stub.c                             |     3 +-
 accel/tcg/atomic_common.c.inc                      |    45 +
 accel/tcg/cpu-exec-common.c                        |     3 +
 accel/tcg/cpu-exec.c                               |   301 +-
 accel/tcg/cputlb.c                                 |   217 +-
 accel/tcg/debuginfo.c                              |    96 +
 accel/tcg/debuginfo.h                              |    79 +
 accel/tcg/hmp.c                                    |    14 -
 accel/tcg/internal.h                               |    94 +-
 accel/tcg/meson.build                              |     4 +-
 accel/tcg/monitor.c                                |   106 +
 accel/tcg/perf.c                                   |   375 +
 accel/tcg/perf.h                                   |    49 +
 accel/tcg/plugin-gen.c                             |   113 +-
 accel/tcg/plugin-helpers.h                         |     4 +-
 accel/tcg/tb-jmp-cache.h                           |    43 +-
 accel/tcg/tb-maint.c                               |  1070 +-
 accel/tcg/tcg-accel-ops.c                          |    20 +-
 accel/tcg/tcg-all.c                                |     2 +-
 accel/tcg/tcg-runtime.h                            |    11 +
 accel/tcg/trace-events                             |     4 +
 accel/tcg/translate-all.c                          |   847 +-
 accel/tcg/translator.c                             |    51 +-
 accel/tcg/user-exec-stub.c                         |     2 +-
 accel/tcg/user-exec.c                              |   759 +-
 accel/xen/xen-all.c                                |   100 +-
 audio/alsaaudio.c                                  |    29 +-
 audio/audio-hmp-cmds.c                             |    83 +
 audio/audio.c                                      |   430 +-
 audio/audio_int.h                                  |    22 +-
 audio/audio_legacy.c                               |    58 +-
 audio/audio_template.h                             |   125 +-
 audio/dbusaudio.c                                  |     7 +-
 audio/meson.build                                  |     1 +
 audio/mixeng.c                                     |    87 +-
 audio/mixeng.h                                     |     2 +
 audio/ossaudio.c                                   |     8 +-
 audio/paaudio.c                                    |    12 +-
 audio/rate_template.h                              |    21 +-
 audio/sndioaudio.c                                 |     4 +-
 audio/wavaudio.c                                   |     2 +-
 authz/listfile.c                                   |     1 -
 backends/cryptodev-builtin.c                       |    42 +-
 backends/cryptodev-hmp-cmds.c                      |    54 +
 backends/cryptodev-lkcf.c                          |    19 +-
 backends/cryptodev-vhost-user.c                    |    13 +-
 backends/cryptodev-vhost.c                         |     5 +-
 backends/cryptodev.c                               |   443 +-
 backends/hostmem-epc.c                             |     2 +-
 backends/hostmem.c                                 |    19 +-
 backends/meson.build                               |     1 +
 backends/rng.c                                     |     1 -
 backends/tpm/tpm_emulator.c                        |     9 +-
 backends/tpm/tpm_ioctl.h                           |     2 -
 backends/tpm/tpm_passthrough.c                     |     2 -
 backends/vhost-user.c                              |    12 -
 block.c                                            |   581 +-
 block/amend.c                                      |     1 +
 block/backup.c                                     |     5 +-
 block/blkdebug.c                                   |    33 +-
 block/blkio.c                                      |    17 +-
 block/blklogwrites.c                               |    40 +-
 block/blkreplay.c                                  |    29 +-
 block/blkverify.c                                  |    10 +-
 block/block-backend.c                              |   145 +-
 block/block-copy.c                                 |    45 +-
 block/block-gen.h                                  |    11 +-
 block/bochs.c                                      |     3 +-
 block/cloop.c                                      |     1 +
 block/commit.c                                     |    14 +-
 block/copy-before-write.c                          |    37 +-
 block/copy-on-read.c                               |    58 +-
 block/coroutines.h                                 |    23 +-
 block/create.c                                     |     9 +-
 block/crypto.c                                     |    55 +-
 block/curl.c                                       |    17 +-
 block/dirty-bitmap.c                               |    93 +-
 block/dmg-lzfse.c                                  |     5 +
 block/dmg.c                                        |     1 +
 block/export/export.c                              |     8 +-
 block/export/fuse.c                                |    14 +-
 block/export/vduse-blk.c                           |     6 +-
 block/export/virtio-blk-handler.c                  |     7 +-
 block/file-posix.c                                 |   212 +-
 block/file-win32.c                                 |    26 +-
 block/filter-compress.c                            |    52 +-
 block/gluster.c                                    |    27 +-
 block/graph-lock.c                                 |   302 +
 block/io.c                                         |   565 +-
 block/iscsi.c                                      |    49 +-
 block/meson.build                                  |     4 +
 block/mirror.c                                     |    67 +-
 block/monitor/bitmap-qmp-cmds.c                    |     2 +
 block/monitor/block-hmp-cmds.c                     |    72 +-
 block/nbd.c                                        |     8 +-
 block/nfs.c                                        |    29 +-
 block/null.c                                       |    14 +-
 block/nvme.c                                       |    15 +-
 block/parallels-ext.c                              |     2 +
 block/parallels.c                                  |    51 +-
 block/preallocate.c                                |    54 +-
 block/progress_meter.c                             |     2 +
 block/qapi-sysemu.c                                |    74 +-
 block/qapi.c                                       |   381 +-
 block/qcow.c                                       |    79 +-
 block/qcow2-bitmap.c                               |     2 +
 block/qcow2-cache.c                                |     1 +
 block/qcow2-cluster.c                              |    18 +-
 block/qcow2-refcount.c                             |     3 +-
 block/qcow2-threads.c                              |     1 +
 block/qcow2.c                                      |   225 +-
 block/qcow2.h                                      |    27 +-
 block/qed-check.c                                  |     4 +-
 block/qed-table.c                                  |    11 +-
 block/qed.c                                        |   157 +-
 block/qed.h                                        |    45 +-
 block/quorum.c                                     |    70 +-
 block/raw-format.c                                 |   101 +-
 block/rbd.c                                        |   215 +-
 block/replication.c                                |    29 +-
 block/snapshot-access.c                            |     8 +-
 block/ssh.c                                        |     7 +-
 block/stream.c                                     |    67 +-
 block/throttle.c                                   |    50 +-
 block/vdi.c                                        |    36 +-
 block/vhdx-log.c                                   |     1 +
 block/vhdx.c                                       |    41 +-
 block/vmdk.c                                       |   232 +-
 block/vpc.c                                        |    34 +-
 block/vvfat.c                                      |     4 +-
 block/win32-aio.c                                  |     1 +
 block/write-threshold.c                            |     1 +
 blockdev-nbd.c                                     |     9 +-
 blockdev.c                                         |   215 +-
 blockjob.c                                         |     6 +-
 bsd-user/arm/signal.c                              |     1 +
 bsd-user/arm/target_arch_cpu.c                     |     2 +
 bsd-user/bsd-proc.h                                |     4 -
 bsd-user/elfload.c                                 |     2 +-
 bsd-user/freebsd/os-sys.c                          |   572 +
 bsd-user/freebsd/os-syscall.c                      |    19 +-
 bsd-user/i386/signal.c                             |     1 +
 bsd-user/i386/target_arch_cpu.c                    |     3 +-
 bsd-user/main.c                                    |    15 +-
 bsd-user/mmap.c                                    |    10 +-
 bsd-user/qemu.h                                    |    11 +-
 bsd-user/signal.c                                  |     1 +
 bsd-user/strace.c                                  |     1 -
 bsd-user/x86_64/signal.c                           |     1 +
 bsd-user/x86_64/target_arch_cpu.c                  |     3 +-
 chardev/baum.c                                     |    66 +-
 chardev/char-fd.c                                  |     2 +-
 chardev/char-file.c                                |     4 +-
 chardev/char-hmp-cmds.c                            |   220 +
 chardev/char-parallel.c                            |    15 +-
 chardev/char-pipe.c                                |     8 +-
 chardev/char-pty.c                                 |     4 +-
 chardev/char-socket.c                              |    14 +-
 chardev/char-udp.c                                 |     1 -
 chardev/char.c                                     |    57 +-
 chardev/meson.build                                |    11 +-
 chardev/spice.c                                    |     2 -
 common-user/host/ppc/safe-syscall.inc.S            |   107 +
 configs/devices/arm-softmmu/default.mak            |     1 +
 configs/devices/mips-softmmu/common.mak            |     6 -
 configs/targets/aarch64-linux-user.mak             |     2 +-
 configs/targets/aarch64-softmmu.mak                |     2 +-
 configs/targets/aarch64_be-linux-user.mak          |     2 +-
 configs/targets/microblaze-linux-user.mak          |     1 +
 configs/targets/microblaze-softmmu.mak             |     1 +
 configs/targets/microblazeel-linux-user.mak        |     1 +
 configs/targets/microblazeel-softmmu.mak           |     1 +
 configs/targets/nios2-softmmu.mak                  |     1 +
 configure                                          |   256 +-
 contrib/elf2dmp/addrspace.c                        |     1 +
 contrib/elf2dmp/main.c                             |   108 +-
 contrib/elf2dmp/pe.h                               |   115 +-
 contrib/gitdm/domain-map                           |    11 +-
 contrib/gitdm/filetypes.txt                        |     3 +-
 contrib/gitdm/group-map-alibaba                    |     7 +
 contrib/gitdm/group-map-amd                        |     8 +
 contrib/gitdm/group-map-facebook                   |     5 +
 contrib/gitdm/group-map-ibm                        |     1 +
 contrib/gitdm/group-map-individuals                |     5 +
 contrib/plugins/cache.c                            |     8 +-
 contrib/vhost-user-blk/vhost-user-blk.c            |     6 +-
 cpu.c                                              |    97 +-
 cpus-common.c                                      |    84 +-
 crypto/afalg.c                                     |     6 +-
 crypto/block-luks-priv.h                           |     2 -
 crypto/block-luks.c                                |    17 +-
 crypto/tlssession.c                                |    14 +
 disas.c                                            |     5 +-
 disas/meson.build                                  |     3 +-
 disas/riscv.c                                      |    35 +-
 docs/about/build-platforms.rst                     |    35 +-
 docs/about/deprecated.rst                          |   135 +-
 docs/about/emulation.rst                           |   190 +
 docs/about/index.rst                               |    17 +-
 docs/about/removed-features.rst                    |    87 +-
 docs/conf.py                                       |    17 -
 docs/config/mach-virt-graphical.cfg                |     4 +-
 docs/config/mach-virt-serial.cfg                   |     4 +-
 docs/config/q35-emulated.cfg                       |     2 +
 docs/config/q35-virtio-graphical.cfg               |     2 +
 docs/config/q35-virtio-serial.cfg                  |     2 +
 docs/devel/acpi-bits.rst                           |     3 +
 docs/devel/atomics.rst                             |    44 +-
 docs/devel/block-coroutine-wrapper.rst             |     6 +-
 docs/devel/fuzzing.rst                             |    22 +-
 docs/devel/index-tcg.rst                           |     1 +
 docs/devel/kconfig.rst                             |     2 +-
 docs/devel/migration.rst                           |    20 +-
 docs/devel/qapi-code-gen.rst                       |    45 +-
 docs/devel/style.rst                               |     7 +
 docs/devel/tcg-ops.rst                             |   965 ++
 docs/devel/tcg-plugins.rst                         |     2 +
 docs/devel/tcg.rst                                 |    25 +-
 docs/devel/testing.rst                             |    80 +-
 docs/devel/vfio-migration.rst                      |   112 +-
 docs/devel/writing-monitor-commands.rst            |    14 +-
 docs/interop/index.rst                             |     1 +
 docs/interop/live-block-operations.rst             |     2 +
 docs/interop/qemu-qmp-ref.rst                      |     2 +
 docs/interop/vhost-user.rst                        |    40 +-
 docs/interop/vnc-ledstate-Pseudo-encoding.txt      |    50 -
 docs/interop/vnc-ledstate-pseudo-encoding.rst      |    50 +
 docs/meson.build                                   |    12 +-
 docs/pcie.txt                                      |    16 +-
 docs/qdev-device-use.txt                           |     4 +-
 docs/sphinx/kerneldoc.py                           |     5 +
 docs/system/arm/aspeed.rst                         |     2 +
 docs/system/arm/cpu-features.rst                   |    76 +-
 docs/system/arm/cubieboard.rst                     |     1 +
 docs/system/arm/emulation.rst                      |     4 +
 docs/system/arm/nuvoton.rst                        |     2 +-
 docs/system/arm/orangepi.rst                       |     1 +
 docs/system/arm/stm32.rst                          |     1 +
 docs/system/arm/virt.rst                           |    18 +
 docs/system/device-emulation.rst                   |     1 +
 docs/system/devices/igb.rst                        |    71 +
 docs/system/i386/xen.rst                           |    92 +
 docs/system/index.rst                              |     4 +-
 docs/system/introduction.rst                       |   220 +
 docs/system/loongarch/loongson3.rst                |   129 -
 docs/system/loongarch/virt.rst                     |   108 +
 docs/system/multi-process.rst                      |     2 +
 docs/system/ppc/ppce500.rst                        |    13 +
 docs/system/quickstart.rst                         |    21 -
 docs/system/s390x/pcidevices.rst                   |    41 +
 docs/system/target-i386.rst                        |     1 +
 docs/system/target-mips.rst                        |    14 -
 docs/system/target-s390x.rst                       |     1 +
 docs/tools/index.rst                               |     3 +-
 docs/tools/virtiofsd.rst                           |   403 -
 docs/user/index.rst                                |     2 +
 dump/dump-hmp-cmds.c                               |     2 +-
 dump/dump.c                                        |    48 +-
 dump/meson.build                                   |     6 +-
 dump/win_dump.c                                    |    39 +-
 dump/win_dump.h                                    |     5 +-
 ebpf/rss.bpf.skeleton.h                            |  1171 +-
 fsdev/p9array.h                                    |     2 -
 gdb-xml/aarch64-pauth.xml                          |    15 +
 gdb-xml/microblaze-core.xml                        |    67 +
 gdb-xml/microblaze-stack-protect.xml               |    12 +
 gdbstub/gdbstub.c                                  |  1661 +-
 gdbstub/internals.h                                |   218 +-
 gdbstub/meson.build                                |    36 +-
 gdbstub/softmmu.c                                  |   606 +-
 gdbstub/syscalls.c                                 |   205 +
 gdbstub/trace-events                               |     4 +-
 gdbstub/user-target.c                              |   283 +
 gdbstub/user.c                                     |   426 +-
 gitdm.config                                       |     3 +
 hmp-commands-info.hx                               |    14 +
 hmp-commands.hx                                    |    35 +-
 hw/9pfs/9p-local.c                                 |    40 +-
 hw/9pfs/9p-synth.c                                 |    22 +-
 hw/9pfs/9p-util.h                                  |    29 +-
 hw/9pfs/9p.c                                       |     2 -
 hw/9pfs/codir.c                                    |     1 -
 hw/9pfs/cofile.c                                   |     1 -
 hw/9pfs/cofs.c                                     |     1 -
 hw/9pfs/coth.h                                     |     2 +-
 hw/9pfs/coxattr.c                                  |     1 -
 hw/9pfs/meson.build                                |     2 +-
 hw/9pfs/xen-9p-backend.c                           |    32 +-
 hw/Kconfig                                         |     1 +
 hw/acpi/Kconfig                                    |    13 +-
 hw/acpi/acpi-pci-hotplug-stub.c                    |     9 +-
 hw/acpi/acpi-qmp-cmds.c                            |    30 +
 hw/acpi/acpi-stub.c                                |     4 +-
 hw/acpi/acpi-x86-stub.c                            |     5 +-
 hw/acpi/acpi_interface.c                           |    10 +
 hw/acpi/aml-build.c                                |     2 +-
 hw/acpi/core.c                                     |    14 +-
 hw/acpi/cpu.c                                      |     4 +-
 hw/acpi/erst.c                                     |     2 +-
 hw/acpi/ich9.c                                     |    39 +-
 hw/acpi/ich9_tco.c                                 |   275 +
 hw/acpi/memory_hotplug.c                           |     3 +-
 hw/acpi/meson.build                                |     7 +-
 hw/acpi/pci-bridge-stub.c                          |    20 +
 hw/acpi/pci-bridge.c                               |    37 +
 hw/acpi/pcihp.c                                    |   148 +-
 hw/acpi/piix4.c                                    |    35 +-
 hw/acpi/tco.c                                      |   260 -
 hw/acpi/trace-events                               |     2 +
 hw/acpi/vmgenid.c                                  |    18 -
 hw/alpha/alpha_sys.h                               |     1 -
 hw/alpha/dp264.c                                   |     1 -
 hw/alpha/pci.c                                     |     1 +
 hw/alpha/typhoon.c                                 |     2 +-
 hw/arm/Kconfig                                     |    14 +-
 hw/arm/allwinner-a10.c                             |    41 +
 hw/arm/allwinner-h3.c                              |    38 +-
 hw/arm/armsse.c                                    |     3 +-
 hw/arm/aspeed.c                                    |   276 +-
 hw/arm/aspeed_ast10x0.c                            |    83 +-
 hw/arm/aspeed_ast2600.c                            |    17 +-
 hw/arm/aspeed_eeprom.c                             |   127 +
 hw/arm/aspeed_eeprom.h                             |    25 +
 hw/arm/aspeed_soc.c                                |    18 +-
 hw/arm/bcm2836.c                                   |     9 +-
 hw/arm/boot.c                                      |    22 +-
 hw/arm/collie.c                                    |    27 +-
 hw/arm/cubieboard.c                                |    12 +
 hw/arm/exynos4210.c                                |     4 +-
 hw/arm/fby35.c                                     |     8 +-
 hw/arm/fsl-imx6ul.c                                |     2 +-
 hw/arm/fsl-imx7.c                                  |    41 +-
 hw/arm/gumstix.c                                   |    45 +-
 hw/arm/mainstone.c                                 |    37 +-
 hw/arm/meson.build                                 |    13 +-
 hw/arm/mps2-tz.c                                   |     2 +-
 hw/arm/mps2.c                                      |    41 +-
 hw/arm/msf2-som.c                                  |     5 +-
 hw/arm/musicpal.c                                  |    18 +-
 hw/arm/npcm7xx.c                                   |    25 +-
 hw/arm/npcm7xx_boards.c                            |    22 +-
 hw/arm/nseries.c                                   |    30 +-
 hw/arm/olimex-stm32-h405.c                         |    69 +
 hw/arm/omap1.c                                     |   115 +-
 hw/arm/omap2.c                                     |    40 +-
 hw/arm/omap_sx1.c                                  |    57 +-
 hw/arm/orangepi.c                                  |     1 +
 hw/arm/palm.c                                      |     4 +-
 hw/arm/pxa2xx.c                                    |     8 +-
 hw/arm/realview.c                                  |     2 +-
 hw/arm/sbsa-ref.c                                  |     6 +-
 hw/arm/smmu-common.c                               |    48 +-
 hw/arm/smmuv3-internal.h                           |     7 +
 hw/arm/smmuv3.c                                    |    94 +-
 hw/arm/spitz.c                                     |     6 +-
 hw/arm/stellaris.c                                 |    84 +-
 hw/arm/stm32f405_soc.c                             |     8 +
 hw/arm/strongarm.c                                 |    24 +-
 hw/arm/tosa.c                                      |     2 +-
 hw/arm/versatilepb.c                               |     8 +-
 hw/arm/vexpress.c                                  |    12 +-
 hw/arm/virt.c                                      |   437 +-
 hw/arm/xlnx-versal.c                               |     1 -
 hw/arm/z2.c                                        |    16 +-
 hw/audio/ac97.c                                    |    47 +-
 hw/audio/ac97.h                                    |    65 +
 hw/audio/cs4231a.c                                 |     5 +-
 hw/audio/es1370.c                                  |    12 +-
 hw/audio/gus.c                                     |     5 +-
 hw/audio/hda-codec.c                               |     7 +-
 hw/audio/sb16.c                                    |     7 +-
 hw/audio/trace-events                              |     6 +
 hw/audio/via-ac97.c                                |   455 +-
 hw/block/block.c                                   |    36 +-
 hw/block/dataplane/meson.build                     |     2 +-
 hw/block/dataplane/virtio-blk.c                    |    17 +-
 hw/block/dataplane/xen-block.c                     |    12 +-
 hw/block/fdc-isa.c                                 |     5 +-
 hw/block/fdc.c                                     |     4 +-
 hw/block/m25p80.c                                  |     7 +-
 hw/block/m25p80_sfdp.c                             |    40 +
 hw/block/m25p80_sfdp.h                             |     2 +
 hw/block/meson.build                               |     2 +-
 hw/block/nand.c                                    |   222 +-
 hw/block/onenand.c                                 |   128 +-
 hw/block/pflash_cfi01.c                            |     3 +-
 hw/block/tc58128.c                                 |   136 +-
 hw/block/virtio-blk.c                              |    49 +-
 hw/block/xen-block.c                               |    23 +-
 hw/char/cadence_uart.c                             |     6 +-
 hw/char/digic-uart.c                               |     4 +-
 hw/char/etraxfs_ser.c                              |     4 +-
 hw/char/ibex_uart.c                                |     1 +
 hw/char/meson.build                                |     2 +-
 hw/char/omap_uart.c                                |     7 +-
 hw/char/parallel.c                                 |    24 +-
 hw/char/pl011.c                                    |   110 +-
 hw/char/riscv_htif.c                               |   172 +-
 hw/char/serial-pci-multi.c                         |     2 +-
 hw/char/serial-pci.c                               |     2 +-
 hw/char/serial.c                                   |    68 +-
 hw/char/sifive_uart.c                              |     4 +-
 hw/char/xen_console.c                              |    50 +-
 hw/char/xilinx_uartlite.c                          |     4 +-
 hw/core/cpu-common.c                               |    10 +-
 hw/core/irq.c                                      |     9 +-
 hw/core/loader.c                                   |   147 +-
 hw/core/machine-hmp-cmds.c                         |   210 +-
 hw/core/machine-qmp-cmds.c                         |   175 +-
 hw/core/machine-smp.c                              |     4 +
 hw/core/machine.c                                  |    24 +-
 hw/core/nmi.c                                      |     3 +-
 hw/core/numa.c                                     |     8 +-
 hw/core/or-irq.c                                   |    18 +-
 hw/core/ptimer.c                                   |     2 +-
 hw/core/qdev-clock.c                               |     2 +-
 hw/core/qdev-properties-system.c                   |    34 +-
 hw/core/qdev.c                                     |    70 +-
 hw/core/sysbus.c                                   |     4 +-
 hw/core/trace-events                               |     6 -
 hw/cpu/meson.build                                 |     4 +-
 hw/cxl/cxl-cdat.c                                  |     2 +-
 hw/cxl/cxl-component-utils.c                       |    20 +-
 hw/cxl/cxl-device-utils.c                          |     2 +-
 hw/cxl/cxl-host.c                                  |    33 +-
 hw/cxl/cxl-mailbox-utils.c                         |    28 +-
 hw/display/Kconfig                                 |     2 +-
 hw/display/ati_int.h                               |     2 +-
 hw/display/bochs-display.c                         |     2 +-
 hw/display/cirrus_vga.c                            |     6 +-
 hw/display/g364fb.c                                |     4 +-
 hw/display/meson.build                             |    24 +-
 hw/display/omap_dss.c                              |    15 +-
 hw/display/omap_lcdc.c                             |     9 +-
 hw/display/qxl-render.c                            |     4 +-
 hw/display/qxl.c                                   |    28 +-
 hw/display/qxl.h                                   |     5 +-
 hw/display/sm501.c                                 |   562 +-
 hw/display/trace-events                            |     1 -
 hw/display/vga-pci.c                               |     2 +-
 hw/display/vga.c                                   |     8 +-
 hw/display/vhost-user-gpu.c                        |    19 +
 hw/display/virtio-gpu-udmabuf.c                    |     2 +-
 hw/display/virtio-gpu-virgl.c                      |     1 +
 hw/display/virtio-vga.c                            |    15 +-
 hw/display/virtio-vga.h                            |     2 +-
 hw/display/vmware_vga.c                            |     6 +-
 hw/display/xenfb.c                                 |    32 +-
 hw/dma/etraxfs_dma.c                               |   864 +-
 hw/dma/i82374.c                                    |     2 +-
 hw/dma/omap_dma.c                                  |    15 +-
 hw/dma/pl330.c                                     |    14 +-
 hw/dma/xilinx_axidma.c                             |     4 +-
 hw/dma/xlnx_csu_dma.c                              |     4 +-
 hw/gpio/max7310.c                                  |    27 +-
 hw/gpio/omap_gpio.c                                |    48 +-
 hw/hppa/machine.c                                  |     3 +-
 hw/hyperv/syndbg.c                                 |     6 +-
 hw/hyperv/vmbus.c                                  |    14 +-
 hw/i2c/Kconfig                                     |     6 +-
 hw/i2c/allwinner-i2c.c                             |   479 +
 hw/i2c/arm_sbcon_i2c.c                             |   107 +
 hw/i2c/aspeed_i2c.c                                |     2 +
 hw/i2c/bitbang_i2c.c                               |    82 +-
 hw/i2c/core.c                                      |    37 +-
 hw/i2c/meson.build                                 |     5 +-
 hw/i2c/mpc_i2c.c                                   |     4 +-
 hw/i2c/pmbus_device.c                              |     8 +-
 hw/i2c/smbus_ich9.c                                |    44 +-
 hw/i2c/trace-events                                |    12 +
 hw/i2c/versatile_i2c.c                             |   112 -
 hw/i386/Kconfig                                    |    10 +-
 hw/i386/acpi-build.c                               |   418 +-
 hw/i386/acpi-common.c                              |     7 +-
 hw/i386/acpi-microvm.c                             |     3 +-
 hw/i386/amd_iommu.c                                |     2 +-
 hw/i386/intel_iommu.c                              |    41 +-
 hw/i386/intel_iommu_internal.h                     |     9 +
 hw/i386/kvm/i8259.c                                |     4 +-
 hw/i386/kvm/ioapic.c                               |     7 +-
 hw/i386/kvm/meson.build                            |    14 +
 hw/i386/kvm/trace-events                           |    20 +
 hw/i386/kvm/trace.h                                |     1 +
 hw/i386/kvm/xen-stubs.c                            |    44 +
 hw/i386/kvm/xen_evtchn.c                           |  2357 +++
 hw/i386/kvm/xen_evtchn.h                           |    88 +
 hw/i386/kvm/xen_gnttab.c                           |   547 +
 hw/i386/kvm/xen_gnttab.h                           |    26 +
 hw/i386/kvm/xen_overlay.c                          |   272 +
 hw/i386/kvm/xen_overlay.h                          |    26 +
 hw/i386/kvm/xen_xenstore.c                         |  1728 +++
 hw/i386/kvm/xen_xenstore.h                         |    20 +
 hw/i386/kvm/xenstore_impl.c                        |  1927 +++
 hw/i386/kvm/xenstore_impl.h                        |    63 +
 hw/i386/microvm.c                                  |    30 +-
 hw/i386/multiboot.c                                |     8 +-
 hw/i386/pc.c                                       |   129 +-
 hw/i386/pc_piix.c                                  |    64 +-
 hw/i386/pc_q35.c                                   |    81 +-
 hw/i386/sgx.c                                      |    16 +-
 hw/i386/x86-iommu.c                                |     2 +-
 hw/i386/x86.c                                      |    27 +-
 hw/i386/xen/meson.build                            |     5 +-
 hw/i386/xen/xen-hvm.c                              |    54 +-
 hw/i386/xen/xen-mapcache.c                         |    18 +-
 hw/i386/xen/xen_platform.c                         |    65 +-
 hw/i386/xen/xen_pvdevice.c                         |     2 +-
 hw/ide/ahci.c                                      |    13 +-
 hw/ide/ahci_internal.h                             |     2 +-
 hw/ide/atapi.c                                     |    13 +-
 hw/ide/cmd646.c                                    |    32 +-
 hw/ide/core.c                                      |   207 +-
 hw/ide/ich.c                                       |     1 +
 hw/ide/ioport.c                                    |    10 -
 hw/ide/isa.c                                       |    22 +-
 hw/ide/macio.c                                     |    15 +-
 hw/ide/microdrive.c                                |   369 +-
 hw/ide/mmio.c                                      |    37 +-
 hw/ide/pci.c                                       |    11 +-
 hw/ide/piix.c                                      |    50 +-
 hw/ide/qdev.c                                      |    34 +-
 hw/ide/sii3112.c                                   |     4 +-
 hw/ide/trace-events                                |     3 +-
 hw/ide/via.c                                       |    16 +-
 hw/input/adb.c                                     |     2 +-
 hw/input/ads7846.c                                 |    54 +-
 hw/input/ps2.c                                     |    51 +-
 hw/input/tsc2005.c                                 |     2 +-
 hw/input/tsc210x.c                                 |     4 +-
 hw/intc/Kconfig                                    |     3 +
 hw/intc/apic.c                                     |     6 +-
 hw/intc/apic_common.c                              |    30 +-
 hw/intc/arm_gic_common.c                           |     7 +-
 hw/intc/arm_gic_kvm.c                              |    14 +-
 hw/intc/arm_gicv3_common.c                         |     7 +-
 hw/intc/arm_gicv3_cpuif.c                          |    18 +-
 hw/intc/arm_gicv3_dist.c                           |    12 +-
 hw/intc/arm_gicv3_its.c                            |    28 +-
 hw/intc/arm_gicv3_its_common.c                     |     7 +-
 hw/intc/arm_gicv3_its_kvm.c                        |    14 +-
 hw/intc/arm_gicv3_kvm.c                            |    14 +-
 hw/intc/arm_gicv3_redist.c                         |     8 +-
 hw/intc/armv7m_nvic.c                              |    64 +-
 hw/intc/exynos4210_combiner.c                      |    10 +-
 hw/intc/i8259.c                                    |    25 +-
 hw/intc/i8259_common.c                             |    24 +-
 hw/intc/ioapic.c                                   |     7 +-
 hw/intc/ioapic_common.c                            |     4 +-
 hw/intc/ioapic_internal.h                          |   118 +
 hw/intc/kvm_irqcount.c                             |    49 +
 hw/intc/loongarch_pch_msi.c                        |    29 +-
 hw/intc/loongarch_pch_pic.c                        |    35 +-
 hw/intc/meson.build                                |    18 +-
 hw/intc/mips_gic.c                                 |     4 +-
 hw/intc/omap_intc.c                                |    38 +-
 hw/intc/pnv_xive.c                                 |     1 +
 hw/intc/pnv_xive2.c                                |     1 +
 hw/intc/riscv_aclint.c                             |    16 +-
 hw/intc/riscv_aplic.c                              |     4 +-
 hw/intc/riscv_imsic.c                              |     6 +-
 hw/intc/sifive_plic.c                              |    66 +-
 hw/intc/trace-events                               |     9 +-
 hw/intc/xics.c                                     |    11 +-
 hw/intc/xilinx_intc.c                              |    28 +-
 hw/ipack/tpci200.c                                 |     2 +-
 hw/ipmi/pci_ipmi_bt.c                              |     2 +-
 hw/ipmi/pci_ipmi_kcs.c                             |     2 +-
 hw/isa/Kconfig                                     |     4 +-
 hw/isa/i82378.c                                    |    19 +-
 hw/isa/isa-bus.c                                   |    42 +-
 hw/isa/lpc_ich9.c                                  |    47 +-
 hw/isa/piix3.c                                     |    22 +-
 hw/isa/piix4.c                                     |    41 +-
 hw/isa/trace-events                                |     5 +
 hw/isa/vt82c686.c                                  |    54 +-
 hw/loongarch/Kconfig                               |     1 +
 hw/loongarch/acpi-build.c                          |    23 +-
 hw/loongarch/virt.c                                |   105 +-
 hw/m68k/next-cube.c                                |     1 +
 hw/m68k/q800.c                                     |     1 +
 hw/m68k/virt.c                                     |    10 +-
 hw/mem/cxl_type3.c                                 |   320 +-
 hw/mem/cxl_type3_stubs.c                           |    17 +
 hw/mem/memory-device.c                             |     1 +
 hw/mem/meson.build                                 |     2 +
 hw/mem/pc-dimm.c                                   |     1 -
 hw/mem/sparse-mem.c                                |    14 +-
 hw/microblaze/petalogix_s3adsp1800_mmu.c           |     7 +-
 hw/mips/Kconfig                                    |     2 +
 hw/mips/bootloader.c                               |   139 +-
 hw/mips/boston.c                                   |     8 +-
 hw/mips/cps.c                                      |    35 +-
 hw/mips/fuloong2e.c                                |     2 +-
 hw/mips/gt64xxx_pci.c                              |  1234 --
 hw/mips/jazz.c                                     |     2 +-
 hw/mips/malta.c                                    |   405 +-
 hw/mips/meson.build                                |     2 +-
 hw/mips/mips_int.c                                 |    11 +-
 hw/mips/trace-events                               |     9 +-
 hw/misc/Kconfig                                    |    14 +-
 hw/misc/allwinner-a10-ccm.c                        |   224 +
 hw/misc/allwinner-a10-dramc.c                      |   179 +
 hw/misc/applesmc.c                                 |     1 +
 hw/misc/aspeed_hace.c                              |    21 +-
 hw/misc/aspeed_sdmc.c                              |     1 -
 hw/misc/auxbus.c                                   |     2 +-
 hw/misc/axp209.c                                   |   238 +
 hw/misc/edu.c                                      |     5 +
 hw/misc/i2c-echo.c                                 |   156 +
 hw/misc/imx6_src.c                                 |     2 +-
 hw/misc/imx6ul_ccm.c                               |     6 -
 hw/misc/imx7_ccm.c                                 |    49 +-
 hw/misc/iotkit-sysctl.c                            |     1 -
 hw/misc/ivshmem.c                                  |     6 +-
 hw/misc/mac_via.c                                  |    26 +-
 hw/misc/macio/cuda.c                               |    17 +-
 hw/misc/macio/gpio.c                               |     1 +
 hw/misc/macio/mac_dbdma.c                          |     4 +-
 hw/misc/macio/macio.c                              |   167 +-
 hw/misc/macio/pmu.c                                |    18 +-
 hw/misc/mchp_pfsoc_ioscb.c                         |    78 +-
 hw/misc/mchp_pfsoc_sysreg.c                        |    18 +-
 hw/misc/meson.build                                |    17 +-
 hw/misc/mips_cmgcr.c                               |     2 +-
 hw/misc/mips_itu.c                                 |    30 +-
 hw/misc/mos6522.c                                  |     8 +-
 hw/misc/mst_fpga.c                                 |     4 +-
 hw/misc/omap_gpmc.c                                |    12 +-
 hw/misc/omap_l4.c                                  |     7 +-
 hw/misc/omap_sdrc.c                                |     7 +-
 hw/misc/omap_tap.c                                 |     5 +-
 hw/misc/pci-testdev.c                              |     2 +-
 hw/misc/pvpanic-pci.c                              |     2 +-
 hw/misc/sbsa_ec.c                                  |    12 +-
 hw/misc/sga.c                                      |    71 -
 hw/misc/sifive_u_otp.c                             |     7 -
 hw/misc/trace-events                               |     5 +
 hw/misc/xlnx-zynqmp-apu-ctrl.c                     |     1 -
 hw/net/Kconfig                                     |     7 +-
 hw/net/allwinner-sun8i-emac.c                      |     4 +-
 hw/net/allwinner_emac.c                            |     4 +-
 hw/net/cadence_gem.c                               |     2 +-
 hw/net/can/can_kvaser_pci.c                        |     2 +-
 hw/net/can/can_mioe3680_pci.c                      |     2 +-
 hw/net/can/can_pcm3680_pci.c                       |     2 +-
 hw/net/can/ctucan_pci.c                            |     2 +-
 hw/net/e1000.c                                     |   263 +-
 hw/net/e1000_common.h                              |   102 +
 hw/net/e1000_regs.h                                |   958 +-
 hw/net/e1000e.c                                    |   102 +-
 hw/net/e1000e_core.c                               |   765 +-
 hw/net/e1000e_core.h                               |    70 +-
 hw/net/e1000x_common.c                             |    65 +-
 hw/net/e1000x_common.h                             |   138 +-
 hw/net/e1000x_regs.h                               |   971 ++
 hw/net/eepro100.c                                  |     2 +-
 hw/net/fsl_etsec/etsec.c                           |    15 +-
 hw/net/fsl_etsec/etsec.h                           |    17 -
 hw/net/fsl_etsec/miim.c                            |     5 +-
 hw/net/fsl_etsec/rings.c                           |     4 +-
 hw/net/ftgmac100.c                                 |     4 +-
 hw/net/igb.c                                       |   635 +
 hw/net/igb_common.h                                |   146 +
 hw/net/igb_core.c                                  |  4199 ++++++
 hw/net/igb_core.h                                  |   145 +
 hw/net/igb_regs.h                                  |   659 +
 hw/net/igbvf.c                                     |   327 +
 hw/net/imx_fec.c                                   |     8 +-
 hw/net/lan9118.c                                   |    17 +-
 hw/net/meson.build                                 |     3 +
 hw/net/ne2000-pci.c                                |     2 +-
 hw/net/net_rx_pkt.c                                |   112 +-
 hw/net/net_rx_pkt.h                                |    41 +-
 hw/net/net_tx_pkt.c                                |   360 +-
 hw/net/net_tx_pkt.h                                |    30 +-
 hw/net/pcnet-pci.c                                 |     2 +-
 hw/net/pcnet.c                                     |     4 +-
 hw/net/rocker/qmp-norocker.c                       |    12 +-
 hw/net/rocker/rocker-hmp-cmds.c                    |   316 +
 hw/net/rocker/rocker.c                             |    28 +-
 hw/net/rocker/rocker_desc.c                        |     4 +-
 hw/net/rocker/rocker_of_dpa.c                      |    13 +-
 hw/net/rtl8139.c                                   |     2 +-
 hw/net/sungem.c                                    |     2 +-
 hw/net/sunhme.c                                    |     2 +-
 hw/net/trace-events                                |    52 +-
 hw/net/tulip.c                                     |     2 +-
 hw/net/vhost_net-stub.c                            |    14 +
 hw/net/vhost_net.c                                 |    18 +
 hw/net/virtio-net.c                                |   177 +-
 hw/net/vmxnet3.c                                   |    69 +-
 hw/net/vmxnet3_defs.h                              |     2 +-
 hw/net/xen_nic.c                                   |    25 +-
 hw/net/xilinx_axienet.c                            |     5 +-
 hw/net/xilinx_ethlite.c                            |     6 +-
 hw/nubus/nubus-device.c                            |     1 +
 hw/nvme/ctrl.c                                     |  1012 +-
 hw/nvme/ns.c                                       |   148 +
 hw/nvme/nvme.h                                     |    94 +-
 hw/nvme/subsys.c                                   |    94 +-
 hw/nvme/trace-events                               |     9 +-
 hw/nvram/eeprom_at24c.c                            |    88 +-
 hw/nvram/fw_cfg.c                                  |     2 +-
 hw/nvram/mac_nvram.c                               |    28 +
 hw/openrisc/boot.c                                 |     1 +
 hw/pci-bridge/cxl_downstream.c                     |     3 +-
 hw/pci-bridge/cxl_root_port.c                      |    78 +-
 hw/pci-bridge/cxl_upstream.c                       |     1 -
 hw/pci-bridge/dec.c                                |   164 -
 hw/pci-bridge/dec.h                                |     9 -
 hw/pci-bridge/gen_pcie_root_port.c                 |     7 +-
 hw/pci-bridge/i82801b11.c                          |     5 +-
 hw/pci-bridge/meson.build                          |     2 -
 hw/pci-bridge/pci_bridge_dev.c                     |     2 -
 hw/pci-bridge/pci_expander_bridge.c                |    47 +-
 hw/pci-bridge/pcie_pci_bridge.c                    |     1 -
 hw/pci-bridge/pcie_root_port.c                     |     9 +-
 hw/pci-bridge/simba.c                              |     1 -
 hw/pci-bridge/xio3130_downstream.c                 |     1 -
 hw/pci-bridge/xio3130_upstream.c                   |     1 -
 hw/pci-host/Kconfig                                |     6 +
 hw/pci-host/bonito.c                               |    53 +-
 hw/pci-host/designware.c                           |     1 -
 hw/pci-host/dino.c                                 |     2 +-
 hw/pci-host/grackle.c                              |     4 +-
 hw/pci-host/gt64120.c                              |  1288 ++
 hw/pci-host/i440fx.c                               |     3 +-
 hw/pci-host/meson.build                            |     1 +
 hw/pci-host/mv64361.c                              |    14 +-
 hw/pci-host/pnv_phb.c                              |    29 +-
 hw/pci-host/pnv_phb.h                              |     2 +-
 hw/pci-host/pnv_phb3.c                             |     1 +
 hw/pci-host/pnv_phb3_msi.c                         |    22 +-
 hw/pci-host/pnv_phb4.c                             |     2 +-
 hw/pci-host/pnv_phb4_pec.c                         |    62 +-
 hw/pci-host/ppce500.c                              |     6 +-
 hw/pci-host/q35.c                                  |     3 +-
 hw/pci-host/raven.c                                |    13 +-
 hw/pci-host/sh_pci.c                               |     2 +-
 hw/pci-host/trace-events                           |     7 +
 hw/pci-host/uninorth.c                             |    44 +-
 hw/pci-host/versatile.c                            |     5 +-
 hw/pci-host/xilinx-pcie.c                          |     1 -
 hw/pci/meson.build                                 |     2 +
 hw/pci/msi.c                                       |    12 +-
 hw/pci/msix.c                                      |     9 +
 hw/pci/pci-hmp-cmds.c                              |   239 +
 hw/pci/pci-internal.h                              |    24 +
 hw/pci/pci-qmp-cmds.c                              |   199 +
 hw/pci/pci-stub.c                                  |     9 +-
 hw/pci/pci.c                                       |   381 +-
 hw/pci/pci_bridge.c                                |    16 +-
 hw/pci/pci_host.c                                  |    25 +-
 hw/pci/pcie.c                                      |    36 +-
 hw/pci/pcie_aer.c                                  |   130 +-
 hw/pci/pcie_host.c                                 |     2 +-
 hw/pci/pcie_port.c                                 |    49 +-
 hw/pci/pcie_sriov.c                                |     7 +-
 hw/pci/shpc.c                                      |   114 +-
 hw/pci/slotid_cap.c                                |     2 +-
 hw/pci/trace-events                                |     1 +
 hw/ppc/Kconfig                                     |     4 +-
 hw/ppc/e500.c                                      |    77 +-
 hw/ppc/e500.h                                      |     1 +
 hw/ppc/e500plat.c                                  |    10 +-
 hw/ppc/mac_newworld.c                              |     3 +-
 hw/ppc/mac_oldworld.c                              |    11 +-
 hw/ppc/pegasos2.c                                  |    43 +-
 hw/ppc/pnv.c                                       |    73 +-
 hw/ppc/pnv_core.c                                  |     1 +
 hw/ppc/pnv_homer.c                                 |     1 +
 hw/ppc/pnv_lpc.c                                   |     3 +-
 hw/ppc/pnv_psi.c                                   |     1 +
 hw/ppc/pnv_xscom.c                                 |     1 +
 hw/ppc/ppc.c                                       |    43 +-
 hw/ppc/ppc405_uc.c                                 |     2 -
 hw/ppc/ppc440_bamboo.c                             |     1 -
 hw/ppc/ppc440_pcix.c                               |     2 +-
 hw/ppc/ppc4xx_pci.c                                |     2 +-
 hw/ppc/ppc4xx_sdram.c                              |    18 +-
 hw/ppc/prep.c                                      |    11 +-
 hw/ppc/sam460ex.c                                  |     4 +-
 hw/ppc/spapr.c                                     |    18 +-
 hw/ppc/spapr_drc.c                                 |     4 +-
 hw/ppc/spapr_hcall.c                               |     1 +
 hw/ppc/spapr_pci.c                                 |    15 +-
 hw/ppc/spapr_pci_vfio.c                            |     1 +
 hw/ppc/spapr_softmmu.c                             |     2 +
 hw/ppc/virtex_ml507.c                              |     2 +-
 hw/rdma/rdma_utils.c                               |     1 +
 hw/rdma/rdma_utils.h                               |     1 -
 hw/rdma/vmw/pvrdma.h                               |     2 +-
 hw/rdma/vmw/pvrdma_cmd.c                           |    66 +-
 hw/rdma/vmw/pvrdma_dev_ring.c                      |     1 -
 hw/rdma/vmw/pvrdma_qp_ops.c                        |     6 +-
 hw/remote/machine.c                                |     4 +-
 hw/remote/proxy-memory-listener.c                  |     1 -
 hw/remote/remote-obj.c                             |     1 -
 hw/remote/vfio-user-obj.c                          |     7 +-
 hw/riscv/Kconfig                                   |    23 +-
 hw/riscv/boot.c                                    |   234 +-
 hw/riscv/meson.build                               |     1 +
 hw/riscv/microchip_pfsoc.c                         |   148 +-
 hw/riscv/numa.c                                    |    14 +-
 hw/riscv/opentitan.c                               |    98 +-
 hw/riscv/shakti_c.c                                |     1 +
 hw/riscv/sifive_e.c                                |     5 +-
 hw/riscv/sifive_u.c                                |    80 +-
 hw/riscv/spike.c                                   |   114 +-
 hw/riscv/virt-acpi-build.c                         |   417 +
 hw/riscv/virt.c                                    |   632 +-
 hw/rtc/exynos4210_rtc.c                            |     4 +-
 hw/rtc/m48t59-isa.c                                |     2 +-
 hw/rtc/m48t59.c                                    |   150 +-
 hw/rtc/mc146818rtc.c                               |   149 +-
 hw/rtc/meson.build                                 |     3 +-
 hw/rtc/twl92230.c                                  |   160 +-
 hw/s390x/event-facility.c                          |     3 +-
 hw/s390x/pv.c                                      |    74 +
 hw/s390x/s390-pci-bus.c                            |    28 +
 hw/s390x/s390-pci-inst.c                           |    56 +-
 hw/s390x/s390-pci-vfio.c                           |    13 +
 hw/s390x/s390-stattrib.c                           |    11 +-
 hw/s390x/s390-virtio-ccw.c                         |    21 +-
 hw/s390x/virtio-ccw-serial.c                       |     1 -
 hw/scsi/esp-pci.c                                  |     2 +-
 hw/scsi/lsi53c895a.c                               |     2 +-
 hw/scsi/mptsas.h                                   |     2 +-
 hw/scsi/scsi-bus.c                                 |     4 +-
 hw/scsi/scsi-disk.c                                |    28 +-
 hw/scsi/scsi-generic.c                             |    11 +-
 hw/scsi/vhost-scsi-common.c                        |     1 +
 hw/scsi/viosrp.h                                   |     3 +-
 hw/scsi/virtio-scsi.c                              |   170 +-
 hw/sd/omap_mmc.c                                   |     9 +-
 hw/sd/sd.c                                         |   184 +-
 hw/sd/sdhci-internal.h                             |     1 +
 hw/sd/sdhci.c                                      |    32 +-
 hw/sensor/adm1272.c                                |     1 -
 hw/sensor/dps310.c                                 |     1 -
 hw/sh4/r2d.c                                       |     4 +-
 hw/sh4/sh7750.c                                    |     4 +-
 hw/sh4/sh7750_regs.h                               |     3 +-
 hw/smbios/smbios-stub.c                            |     4 +-
 hw/smbios/smbios.c                                 |     1 +
 hw/sparc64/niagara.c                               |     1 +
 hw/sparc64/sun4u.c                                 |    13 +-
 hw/ssi/aspeed_smc.c                                |     5 +-
 hw/ssi/ibex_spi_host.c                             |     1 +
 hw/ssi/meson.build                                 |     2 +-
 hw/ssi/npcm_pspi.c                                 |   221 +
 hw/ssi/omap_spi.c                                  |     7 +-
 hw/ssi/sifive_spi.c                                |     2 +-
 hw/ssi/trace-events                                |     5 +
 hw/ssi/xilinx_spi.c                                |     5 +-
 hw/ssi/xilinx_spips.c                              |     8 +-
 hw/timer/digic-timer.c                             |     4 +-
 hw/timer/etraxfs_timer.c                           |     3 +-
 hw/timer/exynos4210_mct.c                          |     2 +-
 hw/timer/exynos4210_pwm.c                          |     4 +-
 hw/timer/hpet.c                                    |     1 +
 hw/timer/imx_epit.c                                |   370 +-
 hw/timer/imx_gpt.c                                 |    25 +
 hw/timer/omap_gptimer.c                            |    22 +-
 hw/timer/omap_synctimer.c                          |     4 +-
 hw/timer/xilinx_timer.c                            |    27 +-
 hw/tpm/meson.build                                 |     4 +-
 hw/usb/ccid-card-emulated.c                        |     2 +-
 hw/usb/dev-smartcard-reader.c                      |     7 +-
 hw/usb/dev-storage-bot.c                           |     1 -
 hw/usb/dev-storage-classic.c                       |     1 -
 hw/usb/dev-uas.c                                   |     2 +-
 hw/usb/hcd-ehci.h                                  |     3 +-
 hw/usb/hcd-ohci-pci.c                              |     2 +-
 hw/usb/hcd-ohci.c                                  |   463 +-
 hw/usb/hcd-ohci.h                                  |    11 +-
 hw/usb/hcd-uhci.c                                  |    23 +-
 hw/usb/hcd-uhci.h                                  |     8 +-
 hw/usb/hcd-xhci-nec.c                              |     8 +-
 hw/usb/hcd-xhci-pci.h                              |     1 +
 hw/usb/imx-usb-phy.c                               |    19 +-
 hw/usb/meson.build                                 |     6 +-
 hw/usb/trace-events                                |     4 +
 hw/usb/u2f.h                                       |    16 +-
 hw/usb/vt82c686-uhci-pci.c                         |    12 -
 hw/usb/xen-usb.c                                   |    29 +-
 hw/vfio/ccw.c                                      |    40 +-
 hw/vfio/common.c                                   |   765 +-
 hw/vfio/display.c                                  |     1 +
 hw/vfio/igd.c                                      |     1 +
 hw/vfio/migration.c                                |   768 +-
 hw/vfio/pci.c                                      |    12 +-
 hw/vfio/pci.h                                      |     2 +-
 hw/vfio/trace-events                               |    35 +-
 hw/virtio/Kconfig                                  |     5 +
 hw/virtio/meson.build                              |    45 +-
 hw/virtio/trace-events                             |     6 +-
 hw/virtio/vdpa-dev-pci.c                           |   102 +
 hw/virtio/vdpa-dev.c                               |   386 +
 hw/virtio/vhost-shadow-virtqueue.c                 |    52 +-
 hw/virtio/vhost-shadow-virtqueue.h                 |     5 +-
 hw/virtio/vhost-stub.c                             |     4 +
 hw/virtio/vhost-user-fs.c                          |    22 +-
 hw/virtio/vhost-user-gpio.c                        |    10 +
 hw/virtio/vhost-user.c                             |    45 +-
 hw/virtio/vhost-vdpa.c                             |   298 +-
 hw/virtio/vhost-vsock-common.c                     |    18 +
 hw/virtio/vhost.c                                  |   199 +-
 hw/virtio/virtio-balloon.c                         |    20 +-
 hw/virtio/virtio-config-io.c                       |   204 +
 hw/virtio/virtio-crypto.c                          |    71 +-
 hw/virtio/virtio-hmp-cmds.c                        |   321 +
 hw/virtio/virtio-iommu.c                           |    10 +-
 hw/virtio/virtio-mem-pci.c                         |     4 +-
 hw/virtio/virtio-mem.c                             |   166 +-
 hw/virtio/virtio-mmio.c                            |    31 +-
 hw/virtio/virtio-pci.c                             |   425 +-
 hw/virtio/virtio-pmem-pci.c                        |     1 -
 hw/virtio/virtio-pmem.c                            |     1 +
 hw/virtio/virtio-qmp.c                             |   848 ++
 hw/virtio/virtio-qmp.h                             |    30 +
 hw/virtio/virtio.c                                 |  1024 +-
 hw/watchdog/trace-events                           |     4 +
 hw/watchdog/watchdog.c                             |     4 +
 hw/watchdog/wdt_aspeed.c                           |    24 +-
 hw/watchdog/wdt_i6300esb.c                         |     2 +-
 hw/watchdog/wdt_ib700.c                            |     2 +-
 hw/xen/Kconfig                                     |     3 +
 hw/xen/meson.build                                 |     6 +-
 hw/xen/trace-events                                |     2 +-
 hw/xen/xen-bus-helper.c                            |    62 +-
 hw/xen/xen-bus.c                                   |   412 +-
 hw/xen/xen-legacy-backend.c                        |   308 +-
 hw/xen/xen-operations.c                            |   478 +
 hw/xen/xen_devconfig.c                             |     4 +-
 hw/xen/xen_pt.c                                    |     6 +-
 hw/xen/xen_pt.h                                    |     3 +-
 hw/xen/xen_pt_config_init.c                        |     2 +-
 hw/xen/xen_pt_graphics.c                           |     1 -
 hw/xen/xen_pt_msi.c                                |     4 +-
 hw/xen/xen_pvdev.c                                 |    64 +-
 hw/xenpv/xen_machine_pv.c                          |     8 +-
 include/block/aio-wait.h                           |     2 +-
 include/block/aio.h                                |    26 +-
 include/block/aio_task.h                           |     2 -
 include/block/block-common.h                       |    52 +-
 include/block/block-copy.h                         |     9 +-
 include/block/block-global-state.h                 |    65 +-
 include/block/block-hmp-cmds.h                     |     2 +
 include/block/block-io.h                           |   235 +-
 include/block/block.h                              |     4 +-
 include/block/block_backup.h                       |     2 +-
 include/block/block_int-common.h                   |   256 +-
 include/block/block_int-global-state.h             |    22 +-
 include/block/block_int-io.h                       |    66 +-
 include/block/block_int.h                          |     5 +-
 include/block/blockjob.h                           |     2 +-
 include/block/blockjob_int.h                       |     1 -
 include/block/dirty-bitmap.h                       |    11 +-
 include/block/graph-lock.h                         |   277 +
 include/block/nbd.h                                |     1 +
 include/block/nvme.h                               |   236 +-
 include/block/qapi.h                               |    16 +-
 include/block/raw-aio.h                            |     1 -
 include/block/thread-pool.h                        |     2 +-
 include/block/throttle-groups.h                    |     2 +-
 include/block/write-threshold.h                    |     2 -
 include/crypto/aes.h                               |     8 +-
 include/crypto/desrfb.h                            |    16 +-
 include/crypto/tlssession.h                        |    11 +
 include/disas/dis-asm.h                            |    76 +-
 include/elf.h                                      |  1801 +--
 include/exec/cpu-all.h                             |    17 +-
 include/exec/cpu-defs.h                            |    37 +-
 include/exec/cpu_ldst.h                            |    10 +
 include/exec/exec-all.h                            |    82 +-
 include/exec/gdbstub.h                             |   208 -
 include/exec/gen-icount.h                          |    15 +-
 include/exec/helper-head.h                         |    11 +-
 include/exec/helper-proto.h                        |    32 +-
 include/exec/hwaddr.h                              |     2 +-
 include/exec/memory-internal.h                     |     4 -
 include/exec/memory.h                              |    40 +
 include/exec/plugin-gen.h                          |     1 +
 include/exec/poison.h                              |     1 -
 include/exec/replay-core.h                         |    80 +
 include/exec/target_long.h                         |    42 +
 include/exec/tb-flush.h                            |    26 +
 include/exec/translate-all.h                       |     6 -
 include/exec/translator.h                          |     6 +-
 include/gdbstub/helpers.h                          |   103 +
 include/gdbstub/syscalls.h                         |   113 +
 include/gdbstub/user.h                             |    43 +
 include/hw/acpi/acpi.h                             |     4 +-
 include/hw/acpi/acpi_aml_interface.h               |     3 +
 include/hw/acpi/acpi_dev_interface.h               |     3 +-
 include/hw/acpi/erst.h                             |     3 +
 include/hw/acpi/ich9.h                             |     9 +-
 include/hw/acpi/ich9_tco.h                         |    82 +
 include/hw/acpi/pci.h                              |     4 +
 include/hw/acpi/pcihp.h                            |    11 +-
 include/hw/acpi/piix4.h                            |     4 +-
 include/hw/acpi/tco.h                              |    82 -
 include/hw/adc/npcm7xx_adc.h                       |     7 +-
 include/hw/arm/allwinner-a10.h                     |    29 +-
 include/hw/arm/allwinner-h3.h                      |     9 +
 include/hw/arm/armsse.h                            |     6 +-
 include/hw/arm/aspeed_soc.h                        |    19 +
 include/hw/arm/bcm2835_peripherals.h               |     2 +-
 include/hw/arm/exynos4210.h                        |     4 +-
 include/hw/arm/fsl-imx6ul.h                        |     1 -
 include/hw/arm/fsl-imx7.h                          |    21 +-
 include/hw/arm/npcm7xx.h                           |    20 +-
 include/hw/arm/omap.h                              |    24 +-
 include/hw/arm/pxa.h                               |    11 +-
 include/hw/arm/raspi_platform.h                    |     3 +-
 include/hw/arm/smmu-common.h                       |     5 -
 include/hw/arm/smmuv3.h                            |     4 +-
 include/hw/arm/stm32f205_soc.h                     |     2 +-
 include/hw/arm/stm32f405_soc.h                     |     7 +-
 include/hw/arm/virt.h                              |    17 +-
 include/hw/arm/xlnx-versal.h                       |     6 +-
 include/hw/arm/xlnx-zynqmp.h                       |     2 +-
 include/hw/block/flash.h                           |    20 +-
 include/hw/block/swim.h                            |     1 +
 include/hw/boards.h                                |     7 +-
 include/hw/char/cmsdk-apb-uart.h                   |    33 -
 include/hw/char/goldfish_tty.h                     |     1 +
 include/hw/char/ibex_uart.h                        |     1 -
 include/hw/char/pl011.h                            |    41 +-
 include/hw/char/riscv_htif.h                       |    19 +-
 include/hw/char/xilinx_uartlite.h                  |    21 +-
 include/hw/core/cpu.h                              |    57 +-
 include/hw/core/tcg-cpu-ops.h                      |    43 +
 include/hw/cris/etraxfs.h                          |     1 +
 include/hw/cxl/cxl.h                               |     6 +-
 include/hw/cxl/cxl_cdat.h                          |     1 +
 include/hw/cxl/cxl_component.h                     |    30 +-
 include/hw/cxl/cxl_device.h                        |    15 +-
 include/hw/cxl/cxl_host.h                          |     1 -
 include/hw/cxl/cxl_pci.h                           |     4 -
 include/hw/display/macfb.h                         |     3 +-
 include/hw/dma/sifive_pdma.h                       |     2 +
 include/hw/elf_ops.h                               |    42 +-
 include/hw/hotplug.h                               |     2 +
 include/hw/i2c/allwinner-i2c.h                     |    61 +
 include/hw/i2c/arm_sbcon_i2c.h                     |     6 +-
 include/hw/i2c/bitbang_i2c.h                       |     2 +
 include/hw/i2c/i2c.h                               |     2 +
 include/hw/i2c/npcm7xx_smbus.h                     |     7 +-
 include/hw/i386/apic.h                             |     2 -
 include/hw/i386/apic_internal.h                    |     3 +-
 include/hw/i386/ich9.h                             |   256 -
 include/hw/i386/intel_iommu.h                      |    88 +-
 include/hw/i386/ioapic.h                           |    33 -
 include/hw/i386/ioapic_internal.h                  |   117 -
 include/hw/i386/pc.h                               |    14 +-
 include/hw/i386/sgx-epc.h                          |     1 +
 include/hw/i386/x86-iommu.h                        |    51 +-
 include/hw/i386/x86.h                              |     8 +-
 include/hw/ide.h                                   |    12 -
 include/hw/ide/internal.h                          |   278 +-
 include/hw/ide/isa.h                               |    20 +
 include/hw/ide/mmio.h                              |    26 +
 include/hw/ide/pci.h                               |     9 +-
 include/hw/input/pl050.h                           |     1 -
 include/hw/input/ps2.h                             |     2 +-
 include/hw/input/tsc2xxx.h                         |     4 +-
 include/hw/intc/armv7m_nvic.h                      |   128 +-
 include/hw/intc/goldfish_pic.h                     |     2 +
 include/hw/intc/i8259.h                            |    16 +-
 include/hw/intc/ioapic.h                           |    33 +
 include/hw/intc/kvm_irqcount.h                     |    10 +
 include/hw/intc/loongarch_pch_msi.h                |    11 +-
 include/hw/intc/loongarch_pch_pic.h                |     8 +-
 include/hw/intc/mips_gic.h                         |     4 +-
 include/hw/intc/nios2_vic.h                        |     2 +
 include/hw/intc/sifive_plic.h                      |     1 -
 include/hw/isa/i8259_internal.h                    |     3 +-
 include/hw/isa/isa.h                               |    36 +-
 include/hw/isa/superio.h                           |     2 +-
 include/hw/isa/vt82c686.h                          |    26 +-
 include/hw/loader.h                                |    22 +-
 include/hw/loongarch/virt.h                        |     6 +
 include/hw/mips/bootloader.h                       |    10 +-
 include/hw/misc/allwinner-a10-ccm.h                |    67 +
 include/hw/misc/allwinner-a10-dramc.h              |    68 +
 include/hw/misc/aspeed_lpc.h                       |     2 -
 include/hw/misc/mac_via.h                          |     1 +
 include/hw/misc/macio/cuda.h                       |     1 +
 include/hw/misc/macio/macio.h                      |     2 +-
 include/hw/misc/macio/pmu.h                        |     1 +
 include/hw/misc/mchp_pfsoc_dmc.h                   |     2 +
 include/hw/misc/mchp_pfsoc_ioscb.h                 |     6 +
 include/hw/misc/mchp_pfsoc_sysreg.h                |     3 +
 include/hw/misc/mips_cmgcr.h                       |     2 +-
 include/hw/misc/mips_itu.h                         |     9 +-
 include/hw/misc/mos6522.h                          |     5 +-
 include/hw/misc/npcm7xx_clk.h                      |     2 +-
 include/hw/misc/npcm7xx_gcr.h                      |     6 +-
 include/hw/misc/npcm7xx_mft.h                      |     7 +-
 include/hw/misc/npcm7xx_pwm.h                      |     3 +-
 include/hw/misc/npcm7xx_rng.h                      |     6 +-
 include/hw/misc/pvpanic.h                          |     1 +
 include/hw/misc/sifive_e_prci.h                    |     3 +-
 include/hw/misc/sifive_u_otp.h                     |     3 +-
 include/hw/misc/sifive_u_prci.h                    |     3 +-
 include/hw/misc/virt_ctrl.h                        |     2 +
 include/hw/misc/xlnx-versal-pmc-iou-slcr.h         |     1 +
 include/hw/misc/xlnx-zynqmp-apu-ctrl.h             |     2 +-
 include/hw/net/lasi_82596.h                        |     2 +-
 include/hw/net/mii.h                               |    14 +-
 include/hw/net/npcm7xx_emc.h                       |     5 +-
 include/hw/net/xlnx-zynqmp-can.h                   |     1 +
 include/hw/nvram/eeprom_at24c.h                    |    39 +
 include/hw/nvram/mac_nvram.h                       |     1 +
 include/hw/or-irq.h                                |     5 +-
 include/hw/pci-host/bonito.h                       |    18 +
 include/hw/pci-host/designware.h                   |     3 -
 include/hw/pci-host/gpex.h                         |     2 +-
 include/hw/pci-host/i440fx.h                       |     2 +-
 include/hw/pci-host/ls7a.h                         |    21 +-
 include/hw/pci-host/pnv_phb3.h                     |     3 -
 include/hw/pci-host/pnv_phb4.h                     |    16 +-
 include/hw/pci-host/q35.h                          |     2 +-
 include/hw/pci-host/sabre.h                        |     2 +-
 include/hw/pci-host/xilinx-pcie.h                  |     1 -
 include/hw/pci/msi.h                               |     3 +-
 include/hw/pci/pci.h                               |   359 +-
 include/hw/pci/pci_bridge.h                        |    15 +-
 include/hw/pci/pci_device.h                        |   350 +
 include/hw/pci/pci_ids.h                           |     1 -
 include/hw/pci/pcie.h                              |     9 -
 include/hw/pci/pcie_aer.h                          |     1 +
 include/hw/pci/pcie_doe.h                          |     1 -
 include/hw/pci/pcie_port.h                         |     8 +-
 include/hw/pci/pcie_regs.h                         |    17 +-
 include/hw/pci/pcie_sriov.h                        |     5 +
 include/hw/pci/shpc.h                              |     2 +-
 include/hw/pcmcia.h                                |    32 +-
 include/hw/ppc/pnv.h                               |   148 +-
 include/hw/ppc/pnv_chip.h                          |   147 +
 include/hw/ppc/pnv_core.h                          |     3 +-
 include/hw/ppc/pnv_homer.h                         |     2 +-
 include/hw/ppc/pnv_lpc.h                           |    11 +-
 include/hw/ppc/pnv_occ.h                           |     3 +-
 include/hw/ppc/pnv_pnor.h                          |     2 +-
 include/hw/ppc/pnv_psi.h                           |     2 +-
 include/hw/ppc/pnv_sbe.h                           |     3 +-
 include/hw/ppc/pnv_xive.h                          |     7 +-
 include/hw/ppc/pnv_xscom.h                         |     3 +-
 include/hw/ppc/spapr.h                             |     3 +-
 include/hw/ppc/vof.h                               |     2 +-
 include/hw/ppc/xics.h                              |     2 +-
 include/hw/ppc/xive2.h                             |     2 +
 include/hw/ppc/xive2_regs.h                        |     2 +
 include/hw/qdev-core.h                             |    50 +-
 include/hw/remote/iohub.h                          |     2 +-
 include/hw/remote/proxy.h                          |     2 +-
 include/hw/riscv/boot.h                            |    14 +-
 include/hw/riscv/boot_opensbi.h                    |     2 +
 include/hw/riscv/microchip_pfsoc.h                 |    10 +-
 include/hw/riscv/numa.h                            |    11 +-
 include/hw/riscv/opentitan.h                       |    16 +-
 include/hw/riscv/shakti_c.h                        |     2 +-
 include/hw/riscv/sifive_e.h                        |     9 +-
 include/hw/riscv/sifive_u.h                        |     6 +-
 include/hw/riscv/spike.h                           |     4 +-
 include/hw/riscv/virt.h                            |    16 +-
 include/hw/rtc/mc146818rtc.h                       |    15 +-
 include/hw/s390x/pv.h                              |     4 +-
 include/hw/s390x/s390-pci-bus.h                    |     6 +
 include/hw/scsi/scsi.h                             |     2 +-
 include/hw/sd/npcm7xx_sdhci.h                      |     4 +-
 include/hw/sd/sd.h                                 |     8 +-
 include/hw/sd/sdhci.h                              |     3 +-
 include/hw/southbridge/ich9.h                      |   245 +
 include/hw/southbridge/piix.h                      |     3 +-
 include/hw/ssi/ibex_spi_host.h                     |     2 -
 include/hw/ssi/npcm_pspi.h                         |    53 +
 include/hw/ssi/sifive_spi.h                        |     3 +
 include/hw/timer/cmsdk-apb-timer.h                 |     1 -
 include/hw/timer/i8254.h                           |     3 +-
 include/hw/timer/i8254_internal.h                  |     2 +-
 include/hw/timer/imx_epit.h                        |     8 +-
 include/hw/timer/imx_gpt.h                         |     1 +
 include/hw/timer/sse-timer.h                       |     1 +
 include/hw/tricore/triboard.h                      |     1 -
 include/hw/tricore/tricore_testdevice.h            |     1 -
 include/hw/usb/hcd-dwc3.h                          |     1 +
 include/hw/usb/hcd-musb.h                          |     2 +
 include/hw/usb/xlnx-usb-subsystem.h                |     2 +
 include/hw/usb/xlnx-versal-usb2-ctrl-regs.h        |     3 +
 include/hw/vfio/vfio-common.h                      |    18 +-
 include/hw/virtio/vdpa-dev.h                       |    43 +
 include/hw/virtio/vhost-backend.h                  |     7 +
 include/hw/virtio/vhost-vdpa.h                     |    21 +-
 include/hw/virtio/vhost.h                          |    30 +-
 include/hw/virtio/virtio-blk.h                     |     2 -
 include/hw/virtio/virtio-mem.h                     |     8 +
 include/hw/virtio/virtio-mmio.h                    |     2 +-
 include/hw/virtio/virtio-pci.h                     |     9 +-
 include/hw/virtio/virtio-scsi.h                    |    12 +-
 include/hw/virtio/virtio.h                         |    31 +-
 include/hw/watchdog/wdt_aspeed.h                   |     4 +-
 include/hw/xen/interface/arch-arm.h                |   510 +
 include/hw/xen/interface/arch-x86/cpuid.h          |   118 +
 include/hw/xen/interface/arch-x86/xen-x86_32.h     |   194 +
 include/hw/xen/interface/arch-x86/xen-x86_64.h     |   241 +
 include/hw/xen/interface/arch-x86/xen.h            |   398 +
 include/hw/xen/interface/event_channel.h           |   388 +
 include/hw/xen/interface/features.h                |   143 +
 include/hw/xen/interface/grant_table.h             |   650 +
 include/hw/xen/interface/hvm/hvm_op.h              |   395 +
 include/hw/xen/interface/hvm/params.h              |   318 +
 include/hw/xen/interface/io/blkif.h                |    14 +-
 include/hw/xen/interface/io/console.h              |    10 +
 include/hw/xen/interface/io/fbif.h                 |    20 +
 include/hw/xen/interface/io/kbdif.h                |    10 +
 include/hw/xen/interface/io/netif.h                |    94 +-
 include/hw/xen/interface/io/ring.h                 |    99 +-
 include/hw/xen/interface/io/usbif.h                |   377 +-
 include/hw/xen/interface/io/xenbus.h               |    10 +
 include/hw/xen/interface/io/xs_wire.h              |   153 +
 include/hw/xen/interface/memory.h                  |   754 +
 include/hw/xen/interface/physdev.h                 |   383 +
 include/hw/xen/interface/sched.h                   |   202 +
 include/hw/xen/interface/trace.h                   |   341 +
 include/hw/xen/interface/vcpu.h                    |   248 +
 include/hw/xen/interface/version.h                 |   113 +
 include/hw/xen/interface/xen-compat.h              |    46 +
 include/hw/xen/interface/xen.h                     |  1049 ++
 include/hw/xen/xen-bus-helper.h                    |    32 +-
 include/hw/xen/xen-bus.h                           |    24 +-
 include/hw/xen/xen-legacy-backend.h                |    27 +-
 include/hw/xen/xen.h                               |    29 +-
 include/hw/xen/xen_backend_ops.h                   |   408 +
 include/hw/xen/xen_common.h                        |   690 -
 include/hw/xen/xen_native.h                        |   629 +
 include/hw/xen/xen_pvdev.h                         |     6 +-
 include/io/channel-tls.h                           |     1 +
 include/io/channel.h                               |    20 +-
 include/migration/misc.h                           |     4 +-
 include/migration/register.h                       |    31 +-
 include/migration/vmstate.h                        |    35 +-
 include/monitor/hmp-target.h                       |     6 +
 include/monitor/hmp.h                              |    40 +-
 include/monitor/monitor.h                          |     4 +-
 include/monitor/qmp-helpers.h                      |    29 +
 include/monitor/stats.h                            |    45 -
 include/net/eth.h                                  |    21 +-
 include/net/net.h                                  |    24 +-
 include/net/vhost-user.h                           |     1 +
 include/net/vhost_net.h                            |     4 +
 include/qapi/error.h                               |     6 +
 include/qapi/qmp/qerror.h                          |     6 -
 include/qemu/accel.h                               |     4 +-
 include/qemu/async-teardown.h                      |     2 -
 include/qemu/atomic.h                              |    17 +-
 include/qemu/atomic128.h                           |    29 +-
 include/qemu/bitmap.h                              |    52 +-
 include/qemu/bswap.h                               |   103 +-
 include/qemu/clang-tsa.h                           |   114 +
 include/qemu/compiler.h                            |     4 +-
 include/qemu/config-file.h                         |     2 +-
 include/qemu/coroutine-core.h                      |   154 +
 include/qemu/coroutine.h                           |   113 +-
 include/qemu/cpuid.h                               |     7 +
 include/qemu/dbus.h                                |     1 -
 include/qemu/envlist.h                             |     8 -
 include/qemu/hbitmap.h                             |     2 +-
 include/qemu/host-utils.h                          |     1 -
 include/qemu/int128.h                              |    25 +-
 include/qemu/interval-tree.h                       |    99 +
 include/qemu/lockable.h                            |     2 +-
 include/qemu/main-loop.h                           |    31 +-
 include/qemu/osdep.h                               |    87 +-
 include/qemu/plugin-event.h                        |    26 +
 include/qemu/plugin-memory.h                       |     3 +
 include/qemu/plugin.h                              |    30 +-
 include/qemu/progress_meter.h                      |     2 +-
 include/qemu/qemu-plugin.h                         |    47 +-
 include/qemu/qtree.h                               |   201 +
 include/qemu/rcu.h                                 |     8 -
 include/qemu/rcu_queue.h                           |     8 -
 include/qemu/readline.h                            |     2 +
 include/qemu/sockets.h                             |     2 -
 include/qemu/thread.h                              |    19 +-
 include/qemu/typedefs.h                            |    13 +-
 include/qemu/uri.h                                 |    42 +-
 include/qemu/userfaultfd.h                         |    13 +-
 include/qemu/uuid.h                                |    12 +
 include/qemu/vhost-user-server.h                   |     1 -
 include/qemu/xattr.h                               |     4 +-
 include/scsi/pr-manager.h                          |     1 -
 include/standard-headers/drm/drm_fourcc.h          |    63 +-
 include/standard-headers/linux/ethtool.h           |    81 +-
 include/standard-headers/linux/fuse.h              |    20 +-
 include/standard-headers/linux/input-event-codes.h |     4 +
 include/standard-headers/linux/pci_regs.h          |     2 +
 include/standard-headers/linux/virtio_blk.h        |    19 +
 include/standard-headers/linux/virtio_bt.h         |     8 +
 include/standard-headers/linux/virtio_net.h        |     4 +
 include/sysemu/accel-blocker.h                     |    55 +
 include/sysemu/accel-ops.h                         |     7 +-
 include/sysemu/block-backend-global-state.h        |    26 +-
 include/sysemu/block-backend-io.h                  |   112 +-
 include/sysemu/cpus.h                              |     1 -
 include/sysemu/cryptodev.h                         |   113 +-
 include/sysemu/dirtyrate.h                         |     2 +
 include/sysemu/dump.h                              |     1 +
 include/sysemu/event-loop-base.h                   |     1 -
 include/sysemu/kvm.h                               |     2 -
 include/sysemu/kvm_int.h                           |    12 +
 include/sysemu/kvm_xen.h                           |    43 +
 include/sysemu/os-posix.h                          |     3 -
 include/sysemu/os-win32.h                          |    58 +-
 include/sysemu/replay.h                            |    67 +-
 include/sysemu/stats.h                             |    45 +
 include/sysemu/sysemu.h                            |     3 -
 include/tcg/tcg-op.h                               |    68 +-
 include/tcg/tcg-temp-internal.h                    |    83 +
 include/tcg/tcg.h                                  |   261 +-
 include/ui/console.h                               |     8 +-
 include/ui/egl-helpers.h                           |     4 +
 include/ui/qemu-spice.h                            |     8 +-
 include/ui/spice-display.h                         |     2 -
 include/user/syscall-trace.h                       |     2 +
 io/channel-buffer.c                                |     1 +
 io/channel-command.c                               |     1 +
 io/channel-file.c                                  |     1 +
 io/channel-null.c                                  |     1 +
 io/channel-socket.c                                |    27 +-
 io/channel-tls.c                                   |    86 +-
 io/channel-watch.c                                 |    10 +-
 io/channel-websock.c                               |     1 +
 io/channel.c                                       |    49 +-
 iothread.c                                         |     6 +-
 job-qmp.c                                          |     3 +-
 linux-headers/asm-arm64/kvm.h                      |     1 +
 linux-headers/asm-generic/hugetlb_encode.h         |    26 +-
 linux-headers/asm-generic/mman-common.h            |     2 +
 linux-headers/asm-mips/mman.h                      |     2 +
 linux-headers/asm-riscv/kvm.h                      |     7 +
 linux-headers/asm-x86/kvm.h                        |    11 +-
 linux-headers/linux/kvm.h                          |    35 +-
 linux-headers/linux/psci.h                         |    14 +
 linux-headers/linux/userfaultfd.h                  |     4 +
 linux-headers/linux/vfio.h                         |   278 +-
 linux-user/aarch64/cpu_loop.c                      |    11 +-
 linux-user/aarch64/signal.c                        |    13 +-
 linux-user/aarch64/target_flat.h                   |     1 +
 linux-user/alpha/target_mman.h                     |     4 +
 linux-user/arm/cpu_loop.c                          |    13 +-
 linux-user/arm/target_cpu.h                        |     2 +-
 linux-user/arm/target_flat.h                       |     1 +
 linux-user/elfload.c                               |    78 +-
 linux-user/exit.c                                  |     5 +-
 linux-user/fd-trans.c                              |    64 +-
 linux-user/flatload.c                              |     2 +-
 linux-user/generic/target_flat.h                   |    16 +
 linux-user/generic/target_mman.h                   |    13 +
 linux-user/hexagon/signal.c                        |    17 +-
 linux-user/hppa/target_mman.h                      |     4 +
 linux-user/i386/cpu_loop.c                         |     9 +
 linux-user/include/host/ppc/host-signal.h          |    39 +
 linux-user/m68k/target_flat.h                      |     1 +
 linux-user/main.c                                  |    71 +-
 linux-user/meson.build                             |     1 +
 linux-user/microblaze/cpu_loop.c                   |    10 +-
 linux-user/microblaze/target_flat.h                |     1 +
 linux-user/mips/target_elf.h                       |     3 +
 linux-user/mmap.c                                  |    82 +-
 linux-user/sh4/target_flat.h                       |     1 +
 linux-user/signal.c                                |    10 +-
 linux-user/sparc/cpu_loop.c                        |   190 +-
 linux-user/sparc/signal.c                          |    36 +-
 linux-user/sparc/target_signal.h                   |     2 +-
 linux-user/strace.c                                |   302 +-
 linux-user/strace.list                             |    69 +-
 linux-user/syscall.c                               |   500 +-
 linux-user/syscall_defs.h                          |     7 +-
 linux-user/target_flat.h                           |    16 -
 linux-user/user-internals.h                        |    15 +-
 meson.build                                        |   208 +-
 meson_options.txt                                  |    16 +-
 migration/block-dirty-bitmap.c                     |    20 +-
 migration/block.c                                  |    31 +-
 migration/channel-block.c                          |     1 +
 migration/channel.c                                |    45 +
 migration/channel.h                                |     5 +
 migration/colo-failover.c                          |     3 +-
 migration/colo.c                                   |     2 -
 migration/dirtyrate.c                              |    21 +-
 migration/exec.c                                   |    25 +
 migration/meson.build                              |     2 +
 migration/migration-hmp-cmds.c                     |   806 +
 migration/migration.c                              |   377 +-
 migration/migration.h                              |    67 +-
 migration/multifd-zlib.c                           |    14 +-
 migration/multifd-zstd.c                           |    12 +-
 migration/multifd.c                                |   156 +-
 migration/multifd.h                                |    13 +-
 migration/postcopy-ram.c                           |    76 +-
 migration/postcopy-ram.h                           |     6 +-
 migration/qemu-file.c                              |    34 +
 migration/qemu-file.h                              |     1 +
 migration/ram.c                                    |   965 +-
 migration/ram.h                                    |    23 +
 migration/rdma.c                                   |    27 +-
 migration/savevm.c                                 |   192 +-
 migration/savevm.h                                 |     8 +-
 migration/target.c                                 |     2 +-
 migration/threadinfo.c                             |    51 +
 migration/threadinfo.h                             |    28 +
 migration/tls.c                                    |     6 +-
 migration/trace-events                             |     8 +-
 migration/vmstate.c                                |     2 +
 migration/xbzrle.c                                 |   124 +
 migration/xbzrle.h                                 |     4 +
 monitor/fds.c                                      |   517 +
 monitor/hmp-cmds-target.c                          |   380 +
 monitor/hmp-cmds.c                                 |  2854 +---
 monitor/hmp-target.c                               |   178 +
 monitor/hmp.c                                      |    16 +-
 monitor/meson.build                                |     4 +-
 monitor/misc.c                                     |  1994 ---
 monitor/monitor-internal.h                         |     1 -
 monitor/monitor.c                                  |    41 +-
 monitor/qmp-cmds-control.c                         |     1 -
 monitor/qmp-cmds.c                                 |   518 +-
 nbd/client-connection.c                            |     1 +
 nbd/nbd-internal.h                                 |     1 -
 nbd/server.c                                       |    71 +-
 net/announce.c                                     |     8 +-
 net/colo-compare.c                                 |    13 +-
 net/dgram.c                                        |    14 +-
 net/dump.c                                         |    11 +-
 net/eth.c                                          |   134 +-
 net/hub.c                                          |     2 +-
 net/l2tpv3.c                                       |    21 +-
 net/meson.build                                    |     1 +
 net/net-hmp-cmds.c                                 |   170 +
 net/net.c                                          |   121 +-
 net/slirp.c                                        |    20 +-
 net/socket.c                                       |    56 +-
 net/stream.c                                       |    53 +-
 net/tap-bsd.c                                      |     6 +-
 net/tap-linux.c                                    |     2 +-
 net/tap-solaris.c                                  |     8 +-
 net/tap-win32.c                                    |     2 +-
 net/tap.c                                          |    77 +-
 net/vhost-user.c                                   |    27 +-
 net/vhost-vdpa.c                                   |   395 +-
 net/vmnet-common.m                                 |    48 +-
 net/vmnet-host.c                                   |    20 +-
 net/vmnet-shared.c                                 |    16 +-
 net/vmnet_int.h                                    |     3 +-
 os-posix.c                                         |    16 +-
 pc-bios/README                                     |    10 +-
 pc-bios/bios-256k.bin                              |   Bin 262144 -> 262144 bytes
 pc-bios/bios-microvm.bin                           |   Bin 131072 -> 131072 bytes
 pc-bios/bios.bin                                   |   Bin 131072 -> 131072 bytes
 pc-bios/edk2-aarch64-code.fd.bz2                   |   Bin 1161290 -> 1508184 bytes
 pc-bios/edk2-arm-code.fd.bz2                       |   Bin 1161845 -> 1483149 bytes
 pc-bios/edk2-i386-code.fd.bz2                      |   Bin 1282120 -> 1695318 bytes
 pc-bios/edk2-i386-secure-code.fd.bz2               |   Bin 1473677 -> 1922002 bytes
 pc-bios/edk2-riscv.fd.bz2                          |   Bin 0 -> 1096418 bytes
 pc-bios/edk2-x86_64-code.fd.bz2                    |   Bin 1327522 -> 1796544 bytes
 pc-bios/edk2-x86_64-microvm.fd.bz2                 |   Bin 1309407 -> 1697788 bytes
 pc-bios/edk2-x86_64-secure-code.fd.bz2             |   Bin 1513711 -> 1999841 bytes
 pc-bios/keymaps/meson.build                        |     2 +-
 pc-bios/meson.build                                |     1 -
 pc-bios/openbios-ppc                               |   Bin 677196 -> 677196 bytes
 pc-bios/openbios-sparc32                           |   Bin 382080 -> 382080 bytes
 pc-bios/openbios-sparc64                           |   Bin 1593408 -> 1593408 bytes
 pc-bios/opensbi-riscv32-generic-fw_dynamic.bin     |   Bin 117704 -> 123072 bytes
 pc-bios/opensbi-riscv64-generic-fw_dynamic.bin     |   Bin 115344 -> 121800 bytes
 pc-bios/optionrom/optionrom.h                      |   262 +-
 pc-bios/s390-ccw.img                               |   Bin 42608 -> 42608 bytes
 pc-bios/s390-ccw/bootmap.c                         |   157 +-
 pc-bios/s390-ccw/bootmap.h                         |    30 +-
 pc-bios/sgabios.bin                                |   Bin 4096 -> 0 bytes
 pc-bios/vgabios-ati.bin                            |   Bin 39936 -> 39936 bytes
 pc-bios/vgabios-bochs-display.bin                  |   Bin 28672 -> 28672 bytes
 pc-bios/vgabios-cirrus.bin                         |   Bin 39424 -> 39424 bytes
 pc-bios/vgabios-qxl.bin                            |   Bin 39936 -> 39936 bytes
 pc-bios/vgabios-ramfb.bin                          |   Bin 29184 -> 29184 bytes
 pc-bios/vgabios-stdvga.bin                         |   Bin 39936 -> 39936 bytes
 pc-bios/vgabios-virtio.bin                         |   Bin 39936 -> 39936 bytes
 pc-bios/vgabios-vmware.bin                         |   Bin 39936 -> 39936 bytes
 pc-bios/vgabios.bin                                |   Bin 39424 -> 39424 bytes
 plugins/core.c                                     |    35 +-
 plugins/loader.c                                   |     2 +-
 python/.gitignore                                  |     4 +-
 python/Makefile                                    |    53 +-
 python/Pipfile                                     |    13 -
 python/Pipfile.lock                                |   347 -
 python/README.rst                                  |     3 -
 python/qemu/machine/console_socket.py              |     2 +-
 python/qemu/machine/machine.py                     |    62 +-
 python/qemu/machine/qtest.py                       |     2 +-
 python/qemu/qmp/legacy.py                          |    18 +-
 python/qemu/qmp/protocol.py                        |    29 +-
 python/qemu/qmp/qmp_client.py                      |     4 +-
 python/qemu/qmp/qmp_tui.py                         |     6 +-
 python/qemu/utils/qemu_ga_client.py                |     6 +-
 python/setup.cfg                                   |    10 +-
 python/tests/minreqs.txt                           |    45 +
 qapi/audio.json                                    |    57 +-
 qapi/block-core.json                               |   150 +-
 qapi/cryptodev.json                                |    89 +
 qapi/cxl.json                                      |   128 +
 qapi/machine.json                                  |     4 +-
 qapi/meson.build                                   |     2 +
 qapi/migration.json                                |    29 +
 qapi/misc-target.json                              |   128 +-
 qapi/misc.json                                     |    36 +-
 qapi/net.json                                      |     7 +-
 qapi/qapi-schema.json                              |     2 +
 qapi/qom.json                                      |     8 +-
 qapi/stats.json                                    |    10 +-
 qapi/ui.json                                       |    15 +-
 qemu-img.c                                         |   122 +-
 qemu-io-cmds.c                                     |   275 +-
 qemu-keymap.c                                      |     2 +
 qemu-nbd.c                                         |    37 +-
 qemu-options.hx                                    |   118 +-
 qga/commands-bsd.c                                 |     5 +
 qga/commands-posix.c                               |    46 +-
 qga/commands-win32.c                               |    80 +-
 qga/commands.c                                     |    11 +-
 qga/cutils.c                                       |     3 +-
 qga/cutils.h                                       |     2 -
 qga/installer/qemu-ga.wxs                          |    31 +-
 qga/main.c                                         |    57 +-
 qga/meson.build                                    |    25 +-
 qga/messages-win32.mc                              |     9 +
 qga/vss-win32/install.cpp                          |     9 +
 qga/vss-win32/qga-vss.def                          |     2 +
 qga/vss-win32/requester.cpp                        |    41 +-
 qga/vss-win32/vss-handles.h                        |     3 +
 qom/object_interfaces.c                            |     2 +-
 qom/qom-hmp-cmds.c                                 |    67 +
 qom/qom-qmp-cmds.c                                 |     7 +-
 replay/replay-debugging.c                          |     1 -
 replay/replay-time.c                               |     5 +-
 replay/replay.c                                    |     6 +-
 replay/stubs-system.c                              |     2 +-
 roms/Makefile                                      |    38 +-
 roms/Makefile.edk2                                 |   178 -
 roms/edk2                                          |     2 +-
 roms/edk2-build.config                             |   124 +
 roms/edk2-build.py                                 |   380 +
 roms/edk2-build.sh                                 |    55 -
 roms/edk2-funcs.sh                                 |   273 -
 roms/openbios                                      |     2 +-
 roms/opensbi                                       |     2 +-
 roms/seabios                                       |     2 +-
 roms/sgabios                                       |     1 -
 scripts/block-coroutine-wrapper.py                 |   201 +-
 scripts/checkpatch.pl                              |     3 +
 .../ci/org.centos/stream/8/build-environment.yml   |    39 +-
 scripts/ci/org.centos/stream/8/x86_64/configure    |     5 +-
 scripts/ci/org.centos/stream/8/x86_64/test-avocado |     8 +-
 scripts/ci/setup/build-environment.yml             |    59 +-
 scripts/ci/setup/gitlab-runner.yml                 |    70 +-
 scripts/ci/setup/vars.yml.template                 |     2 -
 scripts/clean-includes                             |    27 +-
 scripts/coccinelle/return_directly.cocci           |     5 +-
 scripts/coverage/compare_gcov_json.py              |   119 +
 scripts/coverity-scan/COMPONENTS.md                |     3 -
 scripts/git.orderfile                              |     2 +
 scripts/make-config-poison.sh                      |     2 +-
 scripts/make-release                               |    16 +-
 scripts/meson-buildoptions.py                      |     7 +-
 scripts/meson-buildoptions.sh                      |    34 +-
 scripts/oss-fuzz/lsan_suppressions.txt             |     2 +
 scripts/probe-gdb-support.py                       |    88 +
 scripts/qapi/.flake8                               |     3 +-
 scripts/qapi/commands.py                           |     9 +-
 scripts/qapi/events.py                             |     3 +-
 scripts/qapi/expr.py                               |   100 +-
 scripts/qapi/gen.py                                |     2 +-
 scripts/qapi/parser.py                             |    41 +-
 scripts/qapi/pylintrc                              |     1 +
 scripts/qapi/schema.py                             |    86 +-
 scripts/qapi/types.py                              |     2 +-
 scripts/qapi/visit.py                              |    17 +-
 scripts/tracetool/__init__.py                      |    23 -
 scripts/tracetool/transform.py                     |   168 -
 scsi/qemu-pr-helper.c                              |     2 +-
 semihosting/arm-compat-semi.c                      |     1 +
 semihosting/console.c                              |     4 +-
 semihosting/guestfd.c                              |     2 +-
 semihosting/syscalls.c                             |    69 +-
 semihosting/uaccess.c                              |     2 +-
 softmmu/cpus.c                                     |     1 +
 softmmu/dirtylimit.c                               |     1 -
 softmmu/dma-helpers.c                              |    12 +-
 softmmu/globals.c                                  |     6 +-
 softmmu/memory.c                                   |    42 +-
 softmmu/memory_mapping.c                           |     4 +-
 softmmu/meson.build                                |     5 +-
 softmmu/physmem.c                                  |   234 +-
 softmmu/qdev-monitor.c                             |    82 +
 softmmu/qtest.c                                    |     1 -
 softmmu/rtc.c                                      |    11 +-
 softmmu/runstate-hmp-cmds.c                        |    82 +
 softmmu/runstate.c                                 |    36 +-
 softmmu/tpm-hmp-cmds.c                             |    65 +
 softmmu/vl.c                                       |    59 +-
 softmmu/watchpoint.c                               |   226 +
 stats/meson.build                                  |     1 +
 stats/stats-hmp-cmds.c                             |   252 +
 stats/stats-qmp-cmds.c                             |   164 +
 storage-daemon/qemu-storage-daemon.c               |     5 +-
 stubs/graph-lock.c                                 |    10 +
 stubs/meson.build                                  |     3 +-
 stubs/qdev.c                                       |     6 +-
 stubs/replay.c                                     |     2 +-
 stubs/semihost-all.c                               |    17 +
 stubs/semihost.c                                   |     5 -
 stubs/vmgenid.c                                    |    10 -
 subprojects/libvduse/libvduse.c                    |     9 +-
 subprojects/libvduse/meson.build                   |     8 +-
 subprojects/libvhost-user/libvhost-user.c          |    56 +-
 subprojects/libvhost-user/libvhost-user.h          |    22 +-
 subprojects/libvhost-user/meson.build              |     8 +-
 target/alpha/STATUS                                |    28 -
 target/alpha/cpu-param.h                           |     2 -
 target/alpha/cpu.h                                 |     2 +-
 target/alpha/gdbstub.c                             |     2 +-
 target/alpha/sys_helper.c                          |     1 +
 target/alpha/translate.c                           |    73 +-
 target/arm/a32-uncond.decode                       |    74 -
 target/arm/a32.decode                              |   557 -
 target/arm/arm-powerctl.c                          |     7 +-
 target/arm/arm-qmp-cmds.c                          |   257 +
 target/arm/cpregs.h                                |   582 +-
 target/arm/cpu-param.h                             |     4 -
 target/arm/cpu-qom.h                               |     4 +-
 target/arm/cpu.c                                   |    84 +-
 target/arm/cpu.h                                   |   303 +-
 target/arm/cpu64.c                                 |   146 +-
 target/arm/cpu_tcg.c                               |    46 +
 target/arm/crypto_helper.c                         |   778 -
 target/arm/debug_helper.c                          |   669 +-
 target/arm/gdbstub.c                               |   283 +-
 target/arm/gdbstub64.c                             |   180 +-
 target/arm/helper-a64.c                            |  1101 --
 target/arm/helper-a64.h                            |     8 -
 target/arm/helper-sme.h                            |     3 +-
 target/arm/helper.c                                |  1717 ++-
 target/arm/helper.h                                |    11 +-
 target/arm/hvf/hvf.c                               |   151 +
 target/arm/hvf/trace-events                        |     2 +
 target/arm/internals.h                             |   126 +-
 target/arm/iwmmxt_helper.c                         |   670 -
 target/arm/kvm-consts.h                            |     8 +-
 target/arm/m-nocp.decode                           |    72 -
 target/arm/m_helper.c                              |  2892 ----
 target/arm/machine.c                               |    58 +-
 target/arm/meson.build                             |    48 +-
 target/arm/monitor.c                               |   230 -
 target/arm/mte_helper.c                            |   908 --
 target/arm/mve.decode                              |   832 -
 target/arm/mve_helper.c                            |  3450 -----
 target/arm/neon-dp.decode                          |   646 -
 target/arm/neon-ls.decode                          |    52 -
 target/arm/neon-shared.decode                      |    99 -
 target/arm/neon_helper.c                           |  1740 ---
 target/arm/op_helper.c                             |  1010 --
 target/arm/pauth_helper.c                          |   515 -
 target/arm/psci.c                                  |   222 -
 target/arm/ptw.c                                   |   412 +-
 target/arm/sme-fa64.decode                         |    60 -
 target/arm/sme.decode                              |    88 -
 target/arm/sme_helper.c                            |  1201 --
 target/arm/sve.decode                              |  1702 ---
 target/arm/sve_helper.c                            |  7489 ---------
 target/arm/syndrome.h                              |    10 +
 target/arm/t16.decode                              |   281 -
 target/arm/t32.decode                              |   753 -
 target/arm/tcg-stubs.c                             |    27 +
 target/arm/tcg/a32-uncond.decode                   |    74 +
 target/arm/tcg/a32.decode                          |   557 +
 target/arm/tcg/crypto_helper.c                     |   778 +
 target/arm/tcg/helper-a64.c                        |   954 ++
 target/arm/tcg/hflags.c                            |   403 +
 target/arm/tcg/iwmmxt_helper.c                     |   670 +
 target/arm/tcg/m-nocp.decode                       |    72 +
 target/arm/tcg/m_helper.c                          |  2901 ++++
 target/arm/tcg/meson.build                         |    50 +
 target/arm/tcg/mte_helper.c                        |   909 ++
 target/arm/tcg/mve.decode                          |   832 +
 target/arm/tcg/mve_helper.c                        |  3450 +++++
 target/arm/tcg/neon-dp.decode                      |   646 +
 target/arm/tcg/neon-ls.decode                      |    52 +
 target/arm/tcg/neon-shared.decode                  |    99 +
 target/arm/tcg/neon_helper.c                       |  1740 +++
 target/arm/tcg/op_helper.c                         |  1069 ++
 target/arm/tcg/pauth_helper.c                      |   517 +
 target/arm/tcg/psci.c                              |   222 +
 target/arm/tcg/sme-fa64.decode                     |    60 +
 target/arm/tcg/sme.decode                          |    88 +
 target/arm/tcg/sme_helper.c                        |  1168 ++
 target/arm/tcg/sve.decode                          |  1702 +++
 target/arm/tcg/sve_helper.c                        |  7490 +++++++++
 target/arm/tcg/t16.decode                          |   281 +
 target/arm/tcg/t32.decode                          |   753 +
 target/arm/tcg/tlb_helper.c                        |   278 +
 target/arm/tcg/translate-a64.c                     | 14554 ++++++++++++++++++
 target/arm/tcg/translate-a64.h                     |   198 +
 target/arm/tcg/translate-m-nocp.c                  |   768 +
 target/arm/tcg/translate-mve.c                     |  2262 +++
 target/arm/tcg/translate-neon.c                    |  3935 +++++
 target/arm/tcg/translate-sme.c                     |   357 +
 target/arm/tcg/translate-sve.c                     |  7369 +++++++++
 target/arm/tcg/translate-vfp.c                     |  3420 +++++
 target/arm/tcg/translate.c                         |  9724 ++++++++++++
 target/arm/tcg/translate.h                         |   654 +
 target/arm/tcg/vec_helper.c                        |  2716 ++++
 target/arm/tcg/vec_internal.h                      |   246 +
 target/arm/tcg/vfp-uncond.decode                   |    82 +
 target/arm/tcg/vfp.decode                          |   247 +
 target/arm/tlb_helper.c                            |   292 -
 target/arm/translate-a64.c                         | 15063 -------------------
 target/arm/translate-a64.h                         |   201 -
 target/arm/translate-m-nocp.c                      |   788 -
 target/arm/translate-mve.c                         |  2310 ---
 target/arm/translate-neon.c                        |  4064 -----
 target/arm/translate-sme.c                         |   373 -
 target/arm/translate-sve.c                         |  7583 ----------
 target/arm/translate-vfp.c                         |  3619 -----
 target/arm/translate.c                             |  9941 ------------
 target/arm/translate.h                             |   631 -
 target/arm/vec_helper.c                            |  2716 ----
 target/arm/vec_internal.h                          |   246 -
 target/arm/vfp-uncond.decode                       |    82 -
 target/arm/vfp.decode                              |   247 -
 target/arm/vfp_helper.c                            |    35 +-
 target/avr/cpu-param.h                             |     1 -
 target/avr/cpu-qom.h                               |     4 +-
 target/avr/cpu.c                                   |    16 +-
 target/avr/cpu.h                                   |     4 +-
 target/avr/gdbstub.c                               |     2 +-
 target/avr/translate.c                             |   301 +-
 target/cris/cpu-param.h                            |     1 -
 target/cris/cpu-qom.h                              |     4 +-
 target/cris/cpu.c                                  |    12 +-
 target/cris/cpu.h                                  |     3 +-
 target/cris/gdbstub.c                              |     2 +-
 target/cris/translate.c                            |   167 +-
 target/cris/translate_v10.c.inc                    |    85 +-
 target/hexagon/README                              |    49 +-
 target/hexagon/attribs_def.h.inc                   |     1 +
 target/hexagon/cpu-param.h                         |     2 -
 target/hexagon/cpu.c                               |    22 +-
 target/hexagon/cpu.h                               |    21 +-
 target/hexagon/decode.c                            |    15 +-
 target/hexagon/gdbstub.c                           |     2 +-
 target/hexagon/gen_analyze_funcs.py                |   252 +
 target/hexagon/gen_helper_funcs.py                 |    47 +-
 target/hexagon/gen_helper_protos.py                |    41 +-
 target/hexagon/gen_idef_parser_funcs.py            |   130 +
 target/hexagon/gen_tcg.h                           |   525 +-
 target/hexagon/gen_tcg_funcs.py                    |   298 +-
 target/hexagon/gen_tcg_hvx.h                       |    36 +-
 target/hexagon/genptr.c                            |   895 +-
 target/hexagon/genptr.h                            |    36 +
 target/hexagon/hex_arch_types.h                    |     1 -
 target/hexagon/hex_common.py                       |    50 +-
 target/hexagon/hex_regs.h                          |     2 +-
 target/hexagon/idef-parser/README.rst              |   714 +
 target/hexagon/idef-parser/idef-parser.h           |   251 +
 target/hexagon/idef-parser/idef-parser.lex         |   448 +
 target/hexagon/idef-parser/idef-parser.y           |   916 ++
 target/hexagon/idef-parser/macros.inc              |   131 +
 target/hexagon/idef-parser/parser-helpers.c        |  2145 +++
 target/hexagon/idef-parser/parser-helpers.h        |   366 +
 target/hexagon/idef-parser/prepare                 |    24 +
 target/hexagon/insn.h                              |     9 +-
 target/hexagon/macros.h                            |    59 +-
 target/hexagon/meson.build                         |   168 +-
 target/hexagon/mmvec/macros.h                      |     5 +-
 target/hexagon/op_helper.c                         |    81 +-
 target/hexagon/op_helper.h                         |    36 +
 target/hexagon/translate.c                         |   464 +-
 target/hexagon/translate.h                         |    92 +-
 target/hppa/cpu-param.h                            |     1 -
 target/hppa/cpu.c                                  |     8 +-
 target/hppa/cpu.h                                  |     7 +-
 target/hppa/fpu_helper.c                           |   450 +
 target/hppa/gdbstub.c                              |     2 +-
 target/hppa/insns.decode                           |     5 +-
 target/hppa/meson.build                            |     2 +
 target/hppa/op_helper.c                            |   504 -
 target/hppa/sys_helper.c                           |   101 +
 target/hppa/translate.c                            |   146 +-
 target/i386/cpu-dump.c                             |     5 +-
 target/i386/cpu-param.h                            |     5 -
 target/i386/cpu-qom.h                              |     4 +-
 target/i386/cpu-sysemu.c                           |    22 +-
 target/i386/cpu.c                                  |   240 +-
 target/i386/cpu.h                                  |    42 +-
 target/i386/gdbstub.c                              |     6 +-
 target/i386/hax/hax-all.c                          |     5 +-
 target/i386/hax/hax-i386.h                         |     2 -
 target/i386/helper.c                               |     2 +-
 target/i386/helper.h                               |     6 -
 target/i386/host-cpu.c                             |     1 +
 target/i386/hvf/hvf-i386.h                         |     4 -
 target/i386/kvm/kvm.c                              |   280 +-
 target/i386/kvm/kvm_i386.h                         |     2 +
 target/i386/kvm/meson.build                        |     2 +
 target/i386/kvm/trace-events                       |     7 +
 target/i386/kvm/xen-compat.h                       |    70 +
 target/i386/kvm/xen-emu.c                          |  1903 +++
 target/i386/kvm/xen-emu.h                          |    33 +
 target/i386/machine.c                              |    25 +
 target/i386/monitor.c                              |     7 +-
 target/i386/ops_sse.h                              |     4 +
 target/i386/sev-sysemu-stub.c                      |     1 -
 target/i386/sev.c                                  |     2 +-
 target/i386/tcg/decode-new.c.inc                   |    36 +-
 target/i386/tcg/emit.c.inc                         |     8 +-
 target/i386/tcg/mem_helper.c                       |   126 -
 target/i386/tcg/seg_helper.c                       |     8 +-
 target/i386/tcg/sysemu/excp_helper.c               |     4 +-
 target/i386/tcg/tcg-cpu.c                          |     8 +-
 target/i386/tcg/translate.c                        |   344 +-
 target/i386/whpx/whpx-all.c                        |     4 +-
 target/i386/whpx/whpx-apic.c                       |     1 +
 target/loongarch/cpu-param.h                       |     1 -
 target/loongarch/cpu.c                             |    51 +-
 target/loongarch/cpu.h                             |     9 +-
 target/loongarch/csr_helper.c                      |     9 +
 target/loongarch/disas.c                           |    39 +-
 target/loongarch/gdbstub.c                         |     1 +
 target/loongarch/helper.h                          |     1 +
 target/loongarch/insn_trans/trans_arith.c.inc      |    12 -
 target/loongarch/insn_trans/trans_atomic.c.inc     |     3 -
 target/loongarch/insn_trans/trans_bit.c.inc        |    12 -
 target/loongarch/insn_trans/trans_branch.c.inc     |     2 +-
 target/loongarch/insn_trans/trans_fcmp.c.inc       |     3 -
 target/loongarch/insn_trans/trans_fmemory.c.inc    |    20 +-
 target/loongarch/insn_trans/trans_fmov.c.inc       |     6 -
 target/loongarch/insn_trans/trans_memory.c.inc     |    34 +-
 target/loongarch/insn_trans/trans_privileged.c.inc |    14 +-
 target/loongarch/insn_trans/trans_shift.c.inc      |    11 -
 target/loongarch/insns.decode                      |     3 +-
 target/loongarch/loongarch-qmp-cmds.c              |    37 +
 target/loongarch/meson.build                       |     4 +-
 target/loongarch/tlb_helper.c                      |     2 +-
 target/loongarch/translate.c                       |    26 +-
 target/loongarch/translate.h                       |     3 -
 target/m68k/cpu-param.h                            |     1 -
 target/m68k/cpu-qom.h                              |     4 +-
 target/m68k/cpu.c                                  |    12 +-
 target/m68k/cpu.h                                  |     4 +-
 target/m68k/fpu_helper.c                           |    49 +-
 target/m68k/gdbstub.c                              |     2 +-
 target/m68k/helper.c                               |     1 +
 target/m68k/m68k-semi.c                            |     5 +-
 target/m68k/translate.c                            |   501 +-
 target/microblaze/cpu-param.h                      |     1 -
 target/microblaze/cpu-qom.h                        |     4 +-
 target/microblaze/cpu.c                            |    23 +-
 target/microblaze/cpu.h                            |     8 +-
 target/microblaze/gdbstub.c                        |    47 +-
 target/microblaze/op_helper.c                      |     2 +-
 target/microblaze/translate.c                      |    91 +-
 target/mips/cpu-defs.c.inc                         |    17 +-
 target/mips/cpu-param.h                            |     1 -
 target/mips/cpu-qom.h                              |     4 +-
 target/mips/cpu.c                                  |    55 +-
 target/mips/cpu.h                                  |     4 +-
 target/mips/gdbstub.c                              |     2 +-
 target/mips/internal.h                             |     3 -
 target/mips/kvm.c                                  |    11 +-
 target/mips/sysemu/addr.c                          |    17 -
 target/mips/sysemu/meson.build                     |     1 +
 target/mips/sysemu/mips-qmp-cmds.c                 |    39 +
 target/mips/sysemu/physaddr.c                      |    16 +-
 target/mips/tcg/dsp_helper.c                       |    15 +-
 target/mips/tcg/exception.c                        |     3 +-
 target/mips/tcg/ldst_helper.c                      |     4 +-
 target/mips/tcg/micromips_translate.c.inc          |    12 +-
 target/mips/tcg/mips16e_translate.c.inc            |     6 -
 target/mips/tcg/msa_helper.c                       |   104 +-
 target/mips/tcg/msa_translate.c                    |     9 -
 target/mips/tcg/mxu_translate.c                    |    55 +-
 target/mips/tcg/nanomips_translate.c.inc           |   147 +-
 target/mips/tcg/octeon_translate.c                 |    23 -
 target/mips/tcg/sysemu/mips-semi.c                 |     3 +-
 target/mips/tcg/sysemu/special_helper.c            |     2 +-
 target/mips/tcg/sysemu/tlb_helper.c                |     2 +-
 target/mips/tcg/translate.c                        |   887 +-
 target/mips/tcg/translate_addr_const.c             |     7 -
 target/mips/tcg/tx79_translate.c                   |    45 +-
 target/mips/tcg/vr54xx_translate.c                 |     6 +-
 target/nios2/cpu-param.h                           |     1 -
 target/nios2/cpu.c                                 |    14 +-
 target/nios2/cpu.h                                 |     6 +-
 target/nios2/nios2-semi.c                          |     9 +-
 target/nios2/translate.c                           |    19 +-
 target/openrisc/cpu-param.h                        |     1 -
 target/openrisc/cpu.c                              |    16 +-
 target/openrisc/cpu.h                              |     7 +-
 target/openrisc/gdbstub.c                          |     2 +-
 target/openrisc/interrupt.c                        |     2 +-
 target/openrisc/mmu.c                              |     2 +-
 target/openrisc/translate.c                        |    41 +-
 target/ppc/cpu-param.h                             |     1 -
 target/ppc/cpu-qom.h                               |     6 +-
 target/ppc/cpu.h                                   |    21 +-
 target/ppc/cpu_init.c                              |    87 +-
 target/ppc/dfp_helper.c                            |     4 +-
 target/ppc/excp_helper.c                           |    75 +-
 target/ppc/gdbstub.c                               |     1 +
 target/ppc/helper.h                                |     2 -
 target/ppc/helper_regs.c                           |    14 +-
 target/ppc/insn32.decode                           |    20 +-
 target/ppc/internal.h                              |     5 +
 target/ppc/kvm.c                                   |     1 -
 target/ppc/kvm_ppc.h                               |     3 +
 target/ppc/mem_helper.c                            |    44 -
 target/ppc/meson.build                             |     2 +-
 target/ppc/mmu-hash32.c                            |    14 +-
 target/ppc/mmu-hash64.c                            |    84 +-
 target/ppc/mmu-hash64.h                            |     5 +
 target/ppc/mmu_common.c                            |    31 +-
 target/ppc/mmu_helper.c                            |     4 +-
 target/ppc/monitor.c                               |   174 -
 target/ppc/power8-pmu-regs.c.inc                   |    20 +-
 target/ppc/ppc-qmp-cmds.c                          |   222 +
 target/ppc/spr_common.h                            |     1 +
 target/ppc/translate.c                             |   564 +-
 target/ppc/translate/dfp-impl.c.inc                |    20 -
 target/ppc/translate/fixedpoint-impl.c.inc         |    66 +-
 target/ppc/translate/fp-impl.c.inc                 |   168 +-
 target/ppc/translate/spe-impl.c.inc                |    67 +-
 target/ppc/translate/storage-ctrl-impl.c.inc       |     2 -
 target/ppc/translate/vmx-impl.c.inc                |   430 +-
 target/ppc/translate/vsx-impl.c.inc                |   323 +-
 target/riscv/cpu-param.h                           |     1 -
 target/riscv/cpu.c                                 |   889 +-
 target/riscv/cpu.h                                 |   115 +-
 target/riscv/cpu_bits.h                            |    41 +
 target/riscv/cpu_helper.c                          |    78 +-
 target/riscv/cpu_vendorid.h                        |     6 +
 target/riscv/csr.c                                 |   822 +-
 target/riscv/debug.c                               |   212 +-
 target/riscv/debug.h                               |    13 +
 target/riscv/fpu_helper.c                          |    36 +-
 target/riscv/gdbstub.c                             |   101 +-
 target/riscv/helper.h                              |    10 +-
 target/riscv/insn32.decode                         |    24 +-
 target/riscv/insn_trans/trans_privileged.c.inc     |     4 +-
 target/riscv/insn_trans/trans_rva.c.inc            |    10 +-
 target/riscv/insn_trans/trans_rvb.c.inc            |    25 +-
 target/riscv/insn_trans/trans_rvd.c.inc            |     4 +-
 target/riscv/insn_trans/trans_rvf.c.inc            |    11 +-
 target/riscv/insn_trans/trans_rvh.c.inc            |     3 +
 target/riscv/insn_trans/trans_rvi.c.inc            |    47 +-
 target/riscv/insn_trans/trans_rvk.c.inc            |    15 -
 target/riscv/insn_trans/trans_rvm.c.inc            |    33 -
 target/riscv/insn_trans/trans_rvv.c.inc            |   271 +-
 target/riscv/insn_trans/trans_rvzawrs.c.inc        |    51 +
 target/riscv/insn_trans/trans_rvzfh.c.inc          |    41 +-
 target/riscv/insn_trans/trans_rvzicbo.c.inc        |    57 +
 target/riscv/insn_trans/trans_rvzicond.c.inc       |    49 +
 target/riscv/insn_trans/trans_svinval.c.inc        |     3 +
 target/riscv/insn_trans/trans_xthead.c.inc         |  1068 ++
 target/riscv/kvm.c                                 |     5 +-
 target/riscv/machine.c                             |    47 +-
 target/riscv/meson.build                           |     1 +
 target/riscv/monitor.c                             |     4 +-
 target/riscv/op_helper.c                           |   171 +-
 target/riscv/pmp.c                                 |   101 +-
 target/riscv/pmp.h                                 |     6 +-
 target/riscv/pmu.h                                 |     1 -
 target/riscv/time_helper.c                         |    36 +-
 target/riscv/translate.c                           |   164 +-
 target/riscv/vector_helper.c                       |   136 +-
 target/riscv/xthead.decode                         |   185 +
 target/rx/cpu-param.h                              |     2 -
 target/rx/cpu-qom.h                                |     4 +-
 target/rx/cpu.c                                    |    16 +-
 target/rx/cpu.h                                    |     2 +-
 target/rx/gdbstub.c                                |     2 +-
 target/rx/helper.c                                 |     4 +-
 target/rx/translate.c                              |   170 +-
 target/s390x/arch_dump.c                           |    20 +-
 target/s390x/cpu-param.h                           |     1 -
 target/s390x/cpu-sysemu.c                          |     1 +
 target/s390x/cpu.c                                 |    30 +-
 target/s390x/cpu.h                                 |    10 +
 target/s390x/cpu_features.c                        |     4 +
 target/s390x/cpu_models.c                          |     5 +-
 target/s390x/cpu_models_sysemu.c                   |     1 -
 target/s390x/diag.c                                |     2 +
 target/s390x/gdbstub.c                             |     1 +
 target/s390x/helper.c                              |     2 +-
 target/s390x/helper.h                              |    60 +-
 target/s390x/mmu_helper.c                          |     2 +-
 target/s390x/tcg/excp_helper.c                     |    17 +-
 target/s390x/tcg/fpu_helper.c                      |   110 +-
 target/s390x/tcg/insn-data.h.inc                   |   120 +-
 target/s390x/tcg/int_helper.c                      |    64 +-
 target/s390x/tcg/mem_helper.c                      |   404 +-
 target/s390x/tcg/misc_helper.c                     |     1 -
 target/s390x/tcg/translate.c                       |   968 +-
 target/s390x/tcg/translate_vx.c.inc                |   190 +-
 target/sh4/cpu-param.h                             |     1 -
 target/sh4/cpu-qom.h                               |     4 +-
 target/sh4/cpu.c                                   |    18 +-
 target/sh4/cpu.h                                   |     2 +-
 target/sh4/gdbstub.c                               |     2 +-
 target/sh4/translate.c                             |   161 +-
 target/sparc/cpu-param.h                           |     2 -
 target/sparc/cpu-qom.h                             |     4 +-
 target/sparc/cpu.c                                 |    16 +-
 target/sparc/cpu.h                                 |     6 +-
 target/sparc/gdbstub.c                             |     2 +-
 target/sparc/ldst_helper.c                         |     6 +-
 target/sparc/mmu_helper.c                          |   133 +-
 target/sparc/translate.c                           |   374 +-
 target/tricore/cpu-param.h                         |     1 -
 target/tricore/cpu-qom.h                           |     2 +-
 target/tricore/cpu.c                               |    15 +-
 target/tricore/cpu.h                               |    11 -
 target/tricore/gdbstub.c                           |     4 +-
 target/tricore/helper.c                            |     2 +-
 target/tricore/translate.c                         |  1069 +-
 target/xtensa/core-dc232b.c                        |     2 +-
 target/xtensa/core-dc233c.c                        |     2 +-
 target/xtensa/core-de212.c                         |     2 +-
 target/xtensa/core-de233_fpu.c                     |     2 +-
 target/xtensa/core-dsp3400.c                       |     2 +-
 target/xtensa/core-fsf.c                           |     2 +-
 target/xtensa/core-lx106.c                         |     2 +-
 target/xtensa/core-sample_controller.c             |     2 +-
 target/xtensa/core-test_kc705_be.c                 |     2 +-
 target/xtensa/core-test_mmuhifi_c3.c               |     2 +-
 target/xtensa/cpu-param.h                          |     1 -
 target/xtensa/cpu-qom.h                            |     4 +-
 target/xtensa/cpu.c                                |    15 +-
 target/xtensa/cpu.h                                |     2 +-
 target/xtensa/gdbstub.c                            |     2 +-
 target/xtensa/helper.c                             |     2 +-
 target/xtensa/import_core.sh                       |     2 +-
 target/xtensa/translate.c                          |   189 +-
 tcg/README                                         |   784 -
 tcg/aarch64/tcg-target.c.inc                       |   136 +-
 tcg/aarch64/tcg-target.h                           |    12 +-
 tcg/arm/tcg-target-con-set.h                       |     7 +-
 tcg/arm/tcg-target-con-str.h                       |     2 +
 tcg/arm/tcg-target.c.inc                           |   157 +-
 tcg/arm/tcg-target.h                               |    11 +-
 tcg/i386/tcg-target-con-set.h                      |     5 +-
 tcg/i386/tcg-target.c.inc                          |   160 +-
 tcg/i386/tcg-target.h                              |    21 +-
 tcg/loongarch64/tcg-insn-defs.c.inc                |    10 +-
 tcg/loongarch64/tcg-target-con-set.h               |     5 +-
 tcg/loongarch64/tcg-target-con-str.h               |     2 +-
 tcg/loongarch64/tcg-target.c.inc                   |   404 +-
 tcg/loongarch64/tcg-target.h                       |    19 +-
 tcg/mips/tcg-target.c.inc                          |    79 +-
 tcg/mips/tcg-target.h                              |    12 +-
 tcg/optimize.c                                     |    12 +-
 tcg/ppc/tcg-target.c.inc                           |   251 +-
 tcg/ppc/tcg-target.h                               |     7 +-
 tcg/region.c                                       |    19 +-
 tcg/riscv/tcg-target.c.inc                         |   159 +-
 tcg/riscv/tcg-target.h                             |    14 +-
 tcg/s390x/tcg-target-con-set.h                     |    26 +-
 tcg/s390x/tcg-target-con-str.h                     |    11 +-
 tcg/s390x/tcg-target.c.inc                         |  1314 +-
 tcg/s390x/tcg-target.h                             |    68 +-
 tcg/sparc64/tcg-target.c.inc                       |   201 +-
 tcg/sparc64/tcg-target.h                           |     9 +-
 tcg/tcg-common.c                                   |     2 +-
 tcg/tcg-internal.h                                 |    75 +-
 tcg/tcg-op-gvec.c                                  |   191 +-
 tcg/tcg-op-vec.c                                   |    45 +-
 tcg/tcg-op.c                                       |   716 +-
 tcg/tcg.c                                          |  2421 ++-
 tcg/tci.c                                          |    63 +-
 tcg/tci/tcg-target.c.inc                           |    65 +-
 tcg/tci/tcg-target.h                               |    14 +-
 tests/avocado/acpi-bits.py                         |     2 +-
 tests/avocado/acpi-bits/bits-tests/smbios.py2      |     4 +
 tests/avocado/acpi-bits/bits-tests/testacpi.py2    |     4 +
 tests/avocado/acpi-bits/bits-tests/testcpuid.py2   |     4 +
 tests/avocado/avocado_qemu/__init__.py             |    16 +-
 tests/avocado/boot_linux.py                        |    51 +-
 tests/avocado/boot_linux_console.py                |    67 +-
 tests/avocado/kvm_xen_guest.py                     |   171 +
 tests/avocado/machine_aarch64_virt.py              |    71 +-
 tests/avocado/machine_aspeed.py                    |    70 +-
 tests/avocado/machine_mips_malta.py                |    43 +-
 tests/avocado/multiprocess.py                      |     1 +
 tests/avocado/netdev-ethtool.py                    |   116 +
 tests/avocado/replay_kernel.py                     |     1 +
 tests/avocado/reverse_debugging.py                 |     8 +
 tests/avocado/riscv_opensbi.py                     |    65 +
 tests/avocado/tuxrun_baselines.py                  |   410 +
 tests/avocado/version.py                           |     1 +
 tests/avocado/virtiofs_submounts.py                |   217 -
 tests/bench/benchmark-crypto-akcipher.c            |     6 +-
 tests/bench/meson.build                            |    10 +
 tests/bench/qtree-bench.c                          |   286 +
 tests/bench/xbzrle-bench.c                         |   469 +
 tests/check-block.sh                               |    43 -
 tests/data/acpi/pc/DSDT                            |   Bin 6458 -> 6488 bytes
 tests/data/acpi/pc/DSDT.acpierst                   |   Bin 6418 -> 6411 bytes
 tests/data/acpi/pc/DSDT.acpihmat                   |   Bin 7783 -> 7813 bytes
 tests/data/acpi/pc/DSDT.bridge                     |   Bin 9532 -> 12615 bytes
 tests/data/acpi/pc/DSDT.cphp                       |   Bin 6922 -> 6952 bytes
 tests/data/acpi/pc/DSDT.dimmpxm                    |   Bin 8112 -> 8142 bytes
 tests/data/acpi/pc/DSDT.hpbridge                   |   Bin 6418 -> 6451 bytes
 tests/data/acpi/pc/DSDT.hpbrroot                   |   Bin 3064 -> 3343 bytes
 tests/data/acpi/pc/DSDT.ipmikcs                    |   Bin 6530 -> 6560 bytes
 tests/data/acpi/pc/DSDT.memhp                      |   Bin 7817 -> 7847 bytes
 tests/data/acpi/pc/DSDT.nohpet                     |   Bin 6316 -> 6346 bytes
 tests/data/acpi/pc/DSDT.numamem                    |   Bin 6464 -> 6494 bytes
 tests/data/acpi/pc/DSDT.roothp                     |   Bin 6656 -> 9873 bytes
 tests/data/acpi/q35/DSDT                           |   Bin 8310 -> 8361 bytes
 tests/data/acpi/q35/DSDT.acpierst                  |   Bin 8327 -> 8378 bytes
 tests/data/acpi/q35/DSDT.acpihmat                  |   Bin 9635 -> 9686 bytes
 tests/data/acpi/q35/DSDT.acpihmat-noinitiator      |   Bin 8589 -> 8640 bytes
 tests/data/acpi/q35/DSDT.applesmc                  |   Bin 8356 -> 8407 bytes
 tests/data/acpi/q35/DSDT.bridge                    |   Bin 11439 -> 11590 bytes
 tests/data/acpi/q35/DSDT.core-count2               |   Bin 32450 -> 32501 bytes
 tests/data/acpi/q35/DSDT.cphp                      |   Bin 8774 -> 8825 bytes
 tests/data/acpi/q35/DSDT.cxl                       |   Bin 9636 -> 9673 bytes
 tests/data/acpi/q35/DSDT.dimmpxm                   |   Bin 9964 -> 10015 bytes
 tests/data/acpi/q35/DSDT.ipmibt                    |   Bin 8385 -> 8436 bytes
 tests/data/acpi/q35/DSDT.ipmismbus                 |   Bin 8398 -> 8449 bytes
 tests/data/acpi/q35/DSDT.ivrs                      |   Bin 8327 -> 8378 bytes
 tests/data/acpi/q35/DSDT.memhp                     |   Bin 9669 -> 9720 bytes
 tests/data/acpi/q35/DSDT.mmio64                    |   Bin 9440 -> 9491 bytes
 tests/data/acpi/q35/DSDT.multi-bridge              |   Bin 8630 -> 12770 bytes
 tests/data/acpi/q35/DSDT.noacpihp                  |   Bin 0 -> 8248 bytes
 tests/data/acpi/q35/DSDT.nohpet                    |   Bin 8168 -> 8219 bytes
 tests/data/acpi/q35/DSDT.numamem                   |   Bin 8316 -> 8367 bytes
 tests/data/acpi/q35/DSDT.pvpanic-isa               |   Bin 8411 -> 8462 bytes
 tests/data/acpi/q35/DSDT.tis.tpm12                 |   Bin 8916 -> 8967 bytes
 tests/data/acpi/q35/DSDT.tis.tpm2                  |   Bin 8942 -> 8993 bytes
 tests/data/acpi/q35/DSDT.viot                      |   Bin 9419 -> 9470 bytes
 tests/data/acpi/q35/DSDT.xapic                     |   Bin 35673 -> 35724 bytes
 tests/data/acpi/virt/APIC.memhp                    |   Bin 172 -> 0 bytes
 tests/data/acpi/virt/APIC.numamem                  |   Bin 172 -> 0 bytes
 tests/data/acpi/virt/APIC.topology                 |   Bin 0 -> 732 bytes
 tests/data/acpi/virt/DSDT.numamem                  |   Bin 5196 -> 0 bytes
 tests/data/acpi/virt/DSDT.topology                 |   Bin 0 -> 5398 bytes
 tests/data/acpi/virt/FACP.memhp                    |   Bin 276 -> 0 bytes
 tests/data/acpi/virt/FACP.numamem                  |   Bin 276 -> 0 bytes
 tests/data/acpi/virt/GTDT.memhp                    |   Bin 96 -> 0 bytes
 tests/data/acpi/virt/GTDT.numamem                  |   Bin 96 -> 0 bytes
 tests/data/acpi/virt/IORT.memhp                    |   Bin 128 -> 0 bytes
 tests/data/acpi/virt/IORT.numamem                  |   Bin 128 -> 0 bytes
 tests/data/acpi/virt/IORT.pxb                      |   Bin 128 -> 0 bytes
 tests/data/acpi/virt/MCFG.memhp                    |   Bin 60 -> 0 bytes
 tests/data/acpi/virt/MCFG.numamem                  |   Bin 60 -> 0 bytes
 tests/data/acpi/virt/PPTT                          |   Bin 96 -> 76 bytes
 tests/data/acpi/virt/PPTT.acpihmatvirt             |   Bin 196 -> 156 bytes
 tests/data/acpi/virt/PPTT.topology                 |   Bin 0 -> 336 bytes
 tests/data/acpi/virt/SPCR.memhp                    |   Bin 80 -> 0 bytes
 tests/data/acpi/virt/SPCR.numamem                  |   Bin 80 -> 0 bytes
 tests/data/acpi/virt/SRAT.acpihmatvirt             |   Bin 240 -> 240 bytes
 tests/data/acpi/virt/SSDT.memhp                    |   Bin 1817 -> 1817 bytes
 tests/docker/Makefile.include                      |    33 +-
 tests/docker/docker.py                             |     6 +-
 tests/docker/dockerfiles/alpine.docker             |    11 +-
 tests/docker/dockerfiles/centos8.docker            |    33 +-
 .../dockerfiles/debian-all-test-cross.docker       |     5 +
 tests/docker/dockerfiles/debian-alpha-cross.docker |     5 +
 tests/docker/dockerfiles/debian-amd64-cross.docker |     9 +-
 tests/docker/dockerfiles/debian-amd64.docker       |    11 +-
 tests/docker/dockerfiles/debian-arm64-cross.docker |     9 +-
 tests/docker/dockerfiles/debian-armel-cross.docker |     9 +-
 tests/docker/dockerfiles/debian-armhf-cross.docker |     9 +-
 .../debian-hexagon-cross.d/build-toolchain.sh      |   141 -
 .../docker/dockerfiles/debian-hexagon-cross.docker |    58 +-
 tests/docker/dockerfiles/debian-hppa-cross.docker  |     5 +
 .../dockerfiles/debian-loongarch-cross.docker      |     5 +
 tests/docker/dockerfiles/debian-m68k-cross.docker  |     5 +
 tests/docker/dockerfiles/debian-mips-cross.docker  |     5 +
 .../docker/dockerfiles/debian-mips64-cross.docker  |     5 +
 .../dockerfiles/debian-mips64el-cross.docker       |     9 +-
 .../docker/dockerfiles/debian-mipsel-cross.docker  |     9 +-
 tests/docker/dockerfiles/debian-native.docker      |     5 +
 .../dockerfiles/debian-powerpc-test-cross.docker   |     6 +-
 .../docker/dockerfiles/debian-ppc64el-cross.docker |     9 +-
 .../docker/dockerfiles/debian-riscv64-cross.docker |     6 +
 .../dockerfiles/debian-riscv64-test-cross.docker   |     5 +
 tests/docker/dockerfiles/debian-s390x-cross.docker |     9 +-
 tests/docker/dockerfiles/debian-sh4-cross.docker   |     5 +
 .../docker/dockerfiles/debian-sparc64-cross.docker |     5 +
 tests/docker/dockerfiles/debian-toolchain.docker   |    10 +-
 .../docker/dockerfiles/debian-tricore-cross.docker |    17 +-
 .../docker/dockerfiles/debian-xtensa-cross.docker  |     5 +
 tests/docker/dockerfiles/fedora-cris-cross.docker  |     5 +
 tests/docker/dockerfiles/fedora-i386-cross.docker  |     6 +
 tests/docker/dockerfiles/fedora-win32-cross.docker |    16 +-
 tests/docker/dockerfiles/fedora-win64-cross.docker |    16 +-
 tests/docker/dockerfiles/fedora.docker             |    15 +-
 tests/docker/dockerfiles/opensuse-leap.docker      |    33 +-
 tests/docker/dockerfiles/python.docker             |     6 +-
 tests/docker/dockerfiles/ubuntu2004.docker         |    16 +-
 tests/docker/dockerfiles/ubuntu2204.docker         |   153 +
 tests/docker/test-tsan                             |     2 +-
 tests/fp/berkeley-testfloat-3                      |     2 +-
 tests/fp/fp-test.c                                 |    19 +-
 tests/fp/meson.build                               |     3 +-
 tests/lcitool/libvirt-ci                           |     2 +-
 tests/lcitool/mappings.yml                         |    77 +
 tests/lcitool/projects/qemu.yml                    |     4 +-
 tests/lcitool/refresh                              |    32 +-
 tests/lcitool/targets/centos-stream-8.yml          |     3 +
 tests/lcitool/targets/opensuse-leap-153.yml        |     3 +
 tests/migration/guestperf/engine.py                |    30 +-
 tests/migration/meson.build                        |     4 +-
 tests/qapi-schema/meson.build                      |    13 +-
 tests/qemu-iotests/022                             |     4 +-
 tests/qemu-iotests/065                             |     2 +-
 tests/qemu-iotests/106                             |     4 +-
 tests/qemu-iotests/186                             |     1 +
 tests/qemu-iotests/214                             |     6 +-
 tests/qemu-iotests/262                             |     3 +-
 tests/qemu-iotests/302.out                         |     5 +
 tests/qemu-iotests/308                             |    47 +-
 tests/qemu-iotests/308.out                         |    35 +
 tests/qemu-iotests/312                             |     1 +
 tests/qemu-iotests/check                           |    32 +-
 tests/qemu-iotests/common.filter                   |    22 +-
 tests/qemu-iotests/common.rc                       |    22 +-
 tests/qemu-iotests/iotests.py                      |    22 +-
 tests/qemu-iotests/meson.build                     |    36 +-
 tests/qemu-iotests/testenv.py                      |    20 +-
 tests/qemu-iotests/testrunner.py                   |    43 +-
 .../tests/detect-zeroes-registered-buf             |    58 +
 .../tests/detect-zeroes-registered-buf.out         |     7 +
 .../tests/migrate-bitmaps-postcopy-test            |     2 +-
 tests/qemu-iotests/tests/qemu-img-close-errors     |    96 +
 tests/qemu-iotests/tests/qemu-img-close-errors.out |    23 +
 tests/qemu-iotests/tests/regression-vhdx-log       |    62 +
 tests/qemu-iotests/tests/regression-vhdx-log.out   |    14 +
 tests/qemu-iotests/tests/stream-under-throttle     |     2 +
 tests/qtest/ahci-test.c                            |     3 +
 tests/qtest/arm-cpu-features.c                     |    23 +-
 tests/qtest/bios-tables-test.c                     |   250 +-
 tests/qtest/boot-sector.c                          |     6 +-
 tests/qtest/boot-serial-test.c                     |     2 +-
 tests/qtest/dbus-display-test.c                    |     5 +-
 tests/qtest/device-plug-test.c                     |    41 +-
 tests/qtest/display-vga-test.c                     |    65 +-
 tests/qtest/drive_del-test.c                       |    65 +
 tests/qtest/e1000e-test.c                          |    38 +-
 tests/qtest/erst-test.c                            |     7 +-
 tests/qtest/fuzz-lsi53c895a-test.c                 |     4 +
 tests/qtest/fuzz/fork_fuzz.c                       |    41 -
 tests/qtest/fuzz/fork_fuzz.h                       |    23 -
 tests/qtest/fuzz/fork_fuzz.ld                      |    56 -
 tests/qtest/fuzz/fuzz.c                            |     6 +
 tests/qtest/fuzz/fuzz.h                            |     2 +-
 tests/qtest/fuzz/generic_fuzz.c                    |   120 +-
 tests/qtest/fuzz/generic_fuzz_configs.h            |     5 +
 tests/qtest/fuzz/i440fx_fuzz.c                     |    27 +-
 tests/qtest/fuzz/meson.build                       |     6 +-
 tests/qtest/fuzz/qos_fuzz.c                        |     3 +-
 tests/qtest/fuzz/virtio_blk_fuzz.c                 |    51 +-
 tests/qtest/fuzz/virtio_net_fuzz.c                 |    54 +-
 tests/qtest/fuzz/virtio_scsi_fuzz.c                |    51 +-
 tests/qtest/hd-geo-test.c                          |    38 +-
 tests/qtest/hexloader-test.c                       |     6 +-
 tests/qtest/ide-test.c                             |     3 +-
 tests/qtest/igb-test.c                             |   256 +
 tests/qtest/ivshmem-test.c                         |     4 +-
 tests/qtest/libqmp.c                               |     2 +-
 tests/qtest/libqos/e1000e.c                        |    40 +-
 tests/qtest/libqos/e1000e.h                        |    18 +-
 tests/qtest/libqos/igb.c                           |   185 +
 tests/qtest/libqos/libqos-pc.h                     |     6 +-
 tests/qtest/libqos/libqos-spapr.h                  |     6 +-
 tests/qtest/libqos/libqos.h                        |     6 +-
 tests/qtest/libqos/meson.build                     |     1 +
 tests/qtest/libqos/virtio-9p.c                     |     1 +
 tests/qtest/libqtest.c                             |   186 +-
 tests/qtest/libqtest.h                             |     5 +-
 tests/qtest/meson.build                            |    46 +-
 tests/qtest/microbit-test.c                        |     2 +-
 tests/qtest/migration-helpers.h                    |     1 +
 tests/qtest/migration-test.c                       |    45 +-
 tests/qtest/netdev-socket.c                        |   549 +
 tests/qtest/npcm7xx_pwm-test.c                     |    27 +-
 tests/qtest/pvpanic-pci-test.c                     |     6 +-
 tests/qtest/pvpanic-test.c                         |     6 +-
 tests/qtest/pxe-test.c                             |     4 +
 tests/qtest/qmp-cmd-test.c                         |     3 +-
 tests/qtest/qom-test.c                             |    16 +-
 tests/qtest/readconfig-test.c                      |    42 +-
 tests/qtest/rtas-test.c                            |     2 +-
 tests/qtest/rtl8139-test.c                         |    18 +-
 tests/qtest/tco-test.c                             |     6 +-
 tests/qtest/test-filter-mirror.c                   |     6 +-
 tests/qtest/test-hmp.c                             |     2 +-
 tests/qtest/tpm-emu.c                              |    12 +-
 tests/qtest/usb-hcd-uhci-test.c                    |     4 +-
 tests/qtest/vhost-user-blk-test.c                  |     6 +
 tests/qtest/virtio-ccw-test.c                      |     6 +-
 tests/qtest/vnc-display-test.c                     |    15 +-
 tests/tcg/Makefile.target                          |    11 +-
 tests/tcg/aarch64/Makefile.softmmu-target          |     7 +
 tests/tcg/aarch64/Makefile.target                  |    14 +-
 tests/tcg/aarch64/sme-outprod1.c                   |    83 +
 tests/tcg/aarch64/sysregs.c                        |    24 +-
 tests/tcg/aarch64/system/boot.S                    |     3 +-
 tests/tcg/aarch64/system/semiheap.c                |     4 +-
 tests/tcg/hexagon/Makefile.target                  |    43 +-
 tests/tcg/hexagon/crt.S                            |    14 +
 tests/tcg/hexagon/fpstuff.c                        |    31 +-
 tests/tcg/hexagon/hvx_misc.c                       |    72 +
 tests/tcg/hexagon/mem_noshuf.c                     |     2 +-
 tests/tcg/hexagon/misc.c                           |     6 +-
 tests/tcg/hexagon/preg_alias.c                     |    10 +-
 tests/tcg/hexagon/reg_mut.c                        |   152 +
 tests/tcg/hexagon/scatter_gather.c                 |   513 +-
 tests/tcg/hexagon/signal_context.c                 |    84 +
 tests/tcg/hexagon/test_abs.S                       |    17 +
 tests/tcg/hexagon/test_bitcnt.S                    |    40 +
 tests/tcg/hexagon/test_bitsplit.S                  |    22 +
 tests/tcg/hexagon/test_call.S                      |    64 +
 tests/tcg/hexagon/test_clobber.S                   |    29 +
 tests/tcg/hexagon/test_cmp.S                       |    31 +
 tests/tcg/hexagon/test_dotnew.S                    |    38 +
 tests/tcg/hexagon/test_ext.S                       |    13 +
 tests/tcg/hexagon/test_fibonacci.S                 |    30 +
 tests/tcg/hexagon/test_hl.S                        |    16 +
 tests/tcg/hexagon/test_hwloops.S                   |    19 +
 tests/tcg/hexagon/test_jmp.S                       |    22 +
 tests/tcg/hexagon/test_lsr.S                       |    36 +
 tests/tcg/hexagon/test_mpyi.S                      |    17 +
 tests/tcg/hexagon/test_packet.S                    |    29 +
 tests/tcg/hexagon/test_reorder.S                   |    33 +
 tests/tcg/hexagon/test_round.S                     |    29 +
 tests/tcg/hexagon/test_vavgw.S                     |    31 +
 tests/tcg/hexagon/test_vcmpb.S                     |    30 +
 tests/tcg/hexagon/test_vcmpw.S                     |    30 +
 tests/tcg/hexagon/test_vlsrw.S                     |    20 +
 tests/tcg/hexagon/test_vmaxh.S                     |    35 +
 tests/tcg/hexagon/test_vminh.S                     |    35 +
 tests/tcg/hexagon/test_vpmpyh.S                    |    28 +
 tests/tcg/hexagon/test_vspliceb.S                  |    31 +
 tests/tcg/hexagon/usr.c                            |    34 +-
 tests/tcg/multiarch/Makefile.target                |    17 +
 tests/tcg/multiarch/munmap-pthread.c               |    16 +-
 tests/tcg/multiarch/nop_func.h                     |    25 +
 tests/tcg/multiarch/sha512.c                       |     9 +-
 tests/tcg/multiarch/system/Makefile.softmmu-target |     6 +-
 tests/tcg/multiarch/test-vma.c                     |    22 +
 tests/tcg/multiarch/vma-pthread.c                  |   207 +
 tests/tcg/s390x/Makefile.softmmu-target            |    22 +-
 tests/tcg/s390x/Makefile.target                    |    24 +-
 tests/tcg/s390x/bal.S                              |    24 +
 tests/tcg/s390x/br-odd.S                           |    16 +
 tests/tcg/s390x/cdsg.c                             |    93 +
 tests/tcg/s390x/cgrl-unaligned.S                   |    16 +
 tests/tcg/s390x/chrl.c                             |    80 +
 tests/tcg/s390x/clrl-unaligned.S                   |    16 +
 tests/tcg/s390x/clst.c                             |    82 +
 tests/tcg/s390x/crl-unaligned.S                    |    16 +
 tests/tcg/s390x/div.c                              |    75 +
 tests/tcg/s390x/ex-branch.c                        |   158 +
 tests/tcg/s390x/ex-odd.S                           |    17 +
 tests/tcg/s390x/ex-relative-long.c                 |   156 +
 tests/tcg/s390x/exrl-ssm-early.S                   |    43 +
 tests/tcg/s390x/lgrl-unaligned.S                   |    16 +
 tests/tcg/s390x/llgfrl-unaligned.S                 |    16 +
 tests/tcg/s390x/long-double.c                      |    24 +
 tests/tcg/s390x/lpsw.S                             |    36 +
 tests/tcg/s390x/lpswe-early.S                      |    38 +
 tests/tcg/s390x/lpswe-unaligned.S                  |    18 +
 tests/tcg/s390x/lrl-unaligned.S                    |    16 +
 tests/tcg/s390x/mxdb.c                             |    30 +
 tests/tcg/s390x/pgm-specification-softmmu.S        |    40 +
 tests/tcg/s390x/pgm-specification-user.c           |    37 +
 tests/tcg/s390x/pgm-specification.mak              |    15 +
 tests/tcg/s390x/rxsbg.c                            |    46 +
 tests/tcg/s390x/sam.S                              |    67 +
 tests/tcg/s390x/softmmu.ld                         |    20 +
 tests/tcg/s390x/ssm-early.S                        |    41 +
 tests/tcg/s390x/stgrl-unaligned.S                  |    16 +
 tests/tcg/s390x/stosm-early.S                      |    41 +
 tests/tcg/s390x/strl-unaligned.S                   |    16 +
 tests/tcg/tricore/Makefile.softmmu-target          |    11 +-
 tests/tcg/tricore/macros.h                         |    76 +-
 tests/tcg/tricore/test_dextr.S                     |    75 +
 tests/tcg/tricore/test_imask.S                     |    10 +
 tests/tcg/tricore/test_insert.S                    |     9 +
 tests/tcg/tricore/test_ld_bu.S                     |    15 +
 tests/tcg/tricore/test_ld_h.S                      |    15 +
 tests/tcg/x86_64/Makefile.target                   |     3 +
 tests/tcg/x86_64/adox.c                            |    69 +
 tests/tcg/xtensa/Makefile.softmmu-target           |     5 +-
 tests/tcg/xtensaeb/Makefile.softmmu-target         |     5 +
 tests/unit/meson.build                             |    11 +-
 tests/unit/ptimer-test-stubs.c                     |     2 +-
 tests/unit/rcutorture.c                            |     3 +-
 tests/unit/socket-helpers.c                        |     2 +-
 tests/unit/test-aio.c                              |     2 +-
 tests/unit/test-bdrv-drain.c                       |   409 +-
 tests/unit/test-block-iothread.c                   |     7 +-
 tests/unit/test-blockjob.c                         |     9 +-
 tests/unit/test-char.c                             |     1 -
 tests/unit/test-coroutine.c                        |     2 -
 tests/unit/test-crypto-block.c                     |     6 -
 tests/unit/test-crypto-tlssession.c                |     4 +-
 tests/unit/test-cutils.c                           |     9 +-
 tests/unit/test-error-report.c                     |   139 +
 tests/unit/test-interval-tree.c                    |   209 +
 tests/unit/test-io-channel-command.c               |    22 +-
 tests/unit/test-io-channel-socket.c                |     1 +
 tests/unit/test-io-channel-tls.c                   |     2 +-
 tests/unit/test-nested-aio-poll.c                  |   130 +
 tests/unit/test-qmp-cmds.c                         |    39 +-
 tests/unit/test-qmp-event.c                        |     4 +-
 tests/unit/test-qobject-input-visitor.c            |     2 +-
 tests/unit/test-qobject-output-visitor.c           |     2 -
 tests/unit/test-qtree.c                            |   333 +
 tests/unit/test-rcu-list.c                         |     5 +-
 tests/unit/test-seccomp.c                          |     1 -
 tests/unit/test-visitor-serialization.c            |     3 +-
 tests/unit/test-vmstate.c                          |     6 +-
 tests/unit/test-xbzrle.c                           |    39 +-
 tests/unit/test-xs-node.c                          |   871 ++
 tests/vhost-user-bridge.c                          |     4 +-
 tests/vm/basevm.py                                 |     3 +-
 tests/vm/centos.aarch64                            |     2 +-
 tests/vm/freebsd                                   |     4 +-
 tests/vm/haiku.x86_64                              |     7 +-
 tests/vm/netbsd                                    |     3 +-
 tests/vm/openbsd                                   |    30 +-
 tools/ebpf/Makefile.ebpf                           |     8 +-
 tools/ebpf/rss.bpf.c                               |    43 +-
 tools/meson.build                                  |    13 -
 tools/virtiofsd/50-qemu-virtiofsd.json.in          |     5 -
 tools/virtiofsd/buffer.c                           |   350 -
 tools/virtiofsd/fuse_common.h                      |   837 --
 tools/virtiofsd/fuse_i.h                           |   107 -
 tools/virtiofsd/fuse_log.c                         |    39 -
 tools/virtiofsd/fuse_log.h                         |    73 -
 tools/virtiofsd/fuse_lowlevel.c                    |  2744 ----
 tools/virtiofsd/fuse_lowlevel.h                    |  1988 ---
 tools/virtiofsd/fuse_misc.h                        |    59 -
 tools/virtiofsd/fuse_opt.c                         |   446 -
 tools/virtiofsd/fuse_opt.h                         |   272 -
 tools/virtiofsd/fuse_signals.c                     |    93 -
 tools/virtiofsd/fuse_virtio.c                      |  1081 --
 tools/virtiofsd/fuse_virtio.h                      |    33 -
 tools/virtiofsd/helper.c                           |   409 -
 tools/virtiofsd/meson.build                        |    18 -
 tools/virtiofsd/passthrough_helpers.h              |    51 -
 tools/virtiofsd/passthrough_ll.c                   |  4520 ------
 tools/virtiofsd/passthrough_seccomp.c              |   182 -
 tools/virtiofsd/passthrough_seccomp.h              |    14 -
 trace-events                                       |     4 -
 trace/meson.build                                  |     5 +-
 trace/trace-hmp-cmds.c                             |   148 +
 ui/cocoa.m                                         |    30 +-
 ui/console.c                                       |    27 +-
 ui/cursor.c                                        |     5 +-
 ui/dbus-clipboard.c                                |    19 +-
 ui/dbus-console.c                                  |    14 +-
 ui/dbus-listener.c                                 |    23 +-
 ui/dbus.c                                          |    39 +-
 ui/egl-headless.c                                  |    17 +-
 ui/egl-helpers.c                                   |    78 +-
 ui/gtk.c                                           |     5 +-
 ui/input.c                                         |    36 +-
 ui/keycodemapdb                                    |     2 +-
 ui/meson.build                                     |     8 +-
 ui/sdl2.c                                          |    36 +-
 ui/shader/texture-blit-flip.vert                   |     1 -
 ui/shader/texture-blit.frag                        |     1 -
 ui/shader/texture-blit.vert                        |     1 -
 ui/spice-app.c                                     |     1 +
 ui/spice-core.c                                    |    56 +-
 ui/spice-display.c                                 |    19 +-
 ui/udmabuf.c                                       |     2 +-
 ui/ui-hmp-cmds.c                                   |   460 +
 ui/ui-qmp-cmds.c                                   |   177 +
 ui/util.c                                          |     3 +-
 ui/vdagent.c                                       |     5 +-
 ui/vnc-clipboard.c                                 |    10 +-
 ui/vnc.c                                           |    18 +-
 ui/vnc.h                                           |     1 -
 util/aio-posix.c                                   |    38 +-
 util/aio-win32.c                                   |    23 +-
 util/async-teardown.c                              |    29 +-
 util/async.c                                       |    51 +-
 util/bitops.c                                      |     8 +-
 util/bufferiszero.c                                |    44 +-
 util/cacheflush.c                                  |    14 +-
 util/cutils.c                                      |    14 +-
 util/envlist.c                                     |   202 +-
 util/error-report.c                                |     1 +
 util/error.c                                       |    21 +-
 util/guest-random.c                                |     2 +-
 util/hbitmap.c                                     |     2 +-
 util/int128.c                                      |    42 +
 util/interval-tree.c                               |   889 ++
 util/log.c                                         |    86 +-
 util/main-loop.c                                   |    64 +-
 util/meson.build                                   |     4 +-
 util/osdep.c                                       |     4 +-
 util/oslib-posix.c                                 |    76 -
 util/oslib-win32.c                                 |   359 +-
 util/qemu-config.c                                 |   230 +-
 util/qemu-coroutine-lock.c                         |    10 +-
 util/qemu-coroutine-sleep.c                        |     1 -
 util/qemu-coroutine.c                              |     1 -
 util/qemu-sockets.c                                |    48 +-
 util/qemu-thread-posix.c                           |    80 +-
 util/qemu-thread-win32.c                           |    82 +-
 util/qht.c                                         |    97 +-
 util/qtree.c                                       |  1390 ++
 util/readline.c                                    |     8 +
 util/thread-context.c                              |    10 +-
 util/trace-events                                  |     1 +
 util/uri.c                                         |     3 +-
 util/userfaultfd.c                                 |    45 +-
 util/vfio-helpers.c                                |    14 +-
 util/vhost-user-server.c                           |     8 +-
 2577 files changed, 190519 insertions(+), 143114 deletions(-)

diff --git a/.cirrus.yml b/.cirrus.yml
deleted file mode 100644
index 4895987da4..0000000000
--- a/.cirrus.yml
+++ /dev/null
@@ -1,109 +0,0 @@
-env:
-  CIRRUS_CLONE_DEPTH: 1
-
-windows_msys2_task:
-  timeout_in: 90m
-  windows_container:
-    image: cirrusci/windowsservercore:2019
-    os_version: 2019
-    cpu: 8
-    memory: 8G
-  env:
-    CIRRUS_SHELL: powershell
-    MSYS: winsymlinks:native
-    MSYSTEM: MINGW64
-    MSYS2_URL: https://github.com/msys2/msys2-installer/releases/download/2022-06-03/msys2-base-x86_64-20220603.sfx.exe
-    MSYS2_FINGERPRINT: 0
-    MSYS2_PACKAGES: "
-      diffutils git grep make pkg-config sed
-      mingw-w64-x86_64-python
-      mingw-w64-x86_64-python-sphinx
-      mingw-w64-x86_64-toolchain
-      mingw-w64-x86_64-SDL2
-      mingw-w64-x86_64-SDL2_image
-      mingw-w64-x86_64-gtk3
-      mingw-w64-x86_64-glib2
-      mingw-w64-x86_64-ninja
-      mingw-w64-x86_64-jemalloc
-      mingw-w64-x86_64-lzo2
-      mingw-w64-x86_64-zstd
-      mingw-w64-x86_64-libjpeg-turbo
-      mingw-w64-x86_64-pixman
-      mingw-w64-x86_64-libgcrypt
-      mingw-w64-x86_64-libpng
-      mingw-w64-x86_64-libssh
-      mingw-w64-x86_64-snappy
-      mingw-w64-x86_64-libusb
-      mingw-w64-x86_64-usbredir
-      mingw-w64-x86_64-libtasn1
-      mingw-w64-x86_64-nettle
-      mingw-w64-x86_64-cyrus-sasl
-      mingw-w64-x86_64-curl
-      mingw-w64-x86_64-gnutls
-      mingw-w64-x86_64-libnfs
-    "
-    CHERE_INVOKING: 1
-  msys2_cache:
-    folder: C:\tools\archive
-    reupload_on_changes: false
-    # These env variables are used to generate fingerprint to trigger the cache procedure
-    # If wanna to force re-populate msys2, increase MSYS2_FINGERPRINT
-    fingerprint_script:
-      - |
-        echo $env:CIRRUS_TASK_NAME
-        echo $env:MSYS2_URL
-        echo $env:MSYS2_FINGERPRINT
-        echo $env:MSYS2_PACKAGES
-    populate_script:
-      - |
-        md -Force C:\tools\archive\pkg
-        $start_time = Get-Date
-        bitsadmin /transfer msys_download /dynamic /download /priority FOREGROUND $env:MSYS2_URL C:\tools\archive\base.exe
-        Write-Output "Download time taken: $((Get-Date).Subtract($start_time))"
-        cd C:\tools
-        C:\tools\archive\base.exe -y
-        del -Force C:\tools\archive\base.exe
-        Write-Output "Base install time taken: $((Get-Date).Subtract($start_time))"
-        $start_time = Get-Date
-
-        ((Get-Content -path C:\tools\msys64\etc\\post-install\\07-pacman-key.post -Raw) -replace '--refresh-keys', '--version') | Set-Content -Path C:\tools\msys64\etc\\post-install\\07-pacman-key.post
-        C:\tools\msys64\usr\bin\bash.exe -lc "sed -i 's/^CheckSpace/#CheckSpace/g' /etc/pacman.conf"
-        C:\tools\msys64\usr\bin\bash.exe -lc "export"
-        C:\tools\msys64\usr\bin\pacman.exe --noconfirm -Sy
-        echo Y | C:\tools\msys64\usr\bin\pacman.exe --noconfirm -Suu --overwrite=*
-        taskkill /F /FI "MODULES eq msys-2.0.dll"
-        tasklist
-        C:\tools\msys64\usr\bin\bash.exe -lc "mv -f /etc/pacman.conf.pacnew /etc/pacman.conf || true"
-        C:\tools\msys64\usr\bin\bash.exe -lc "pacman --noconfirm -Syuu --overwrite=*"
-        Write-Output "Core install time taken: $((Get-Date).Subtract($start_time))"
-        $start_time = Get-Date
-
-        C:\tools\msys64\usr\bin\bash.exe -lc "pacman --noconfirm -S --needed $env:MSYS2_PACKAGES"
-        Write-Output "Package install time taken: $((Get-Date).Subtract($start_time))"
-        $start_time = Get-Date
-
-        del -Force -ErrorAction SilentlyContinue C:\tools\msys64\etc\mtab
-        del -Force -ErrorAction SilentlyContinue C:\tools\msys64\dev\fd
-        del -Force -ErrorAction SilentlyContinue C:\tools\msys64\dev\stderr
-        del -Force -ErrorAction SilentlyContinue C:\tools\msys64\dev\stdin
-        del -Force -ErrorAction SilentlyContinue C:\tools\msys64\dev\stdout
-        del -Force -Recurse -ErrorAction SilentlyContinue C:\tools\msys64\var\cache\pacman\pkg
-        tar cf C:\tools\archive\msys64.tar -C C:\tools\ msys64
-
-        Write-Output "Package archive time taken: $((Get-Date).Subtract($start_time))"
-        del -Force -Recurse -ErrorAction SilentlyContinue c:\tools\msys64 
-  install_script:
-    - |
-      $start_time = Get-Date
-      cd C:\tools
-      ls C:\tools\archive\msys64.tar
-      tar xf C:\tools\archive\msys64.tar
-      Write-Output "Extract msys2 time taken: $((Get-Date).Subtract($start_time))"
-  script:
-    - C:\tools\msys64\usr\bin\bash.exe -lc "mkdir build"
-    - C:\tools\msys64\usr\bin\bash.exe -lc "cd build && ../configure --python=python3"
-    - C:\tools\msys64\usr\bin\bash.exe -lc "cd build && make -j8"
-    - exit $LastExitCode
-  test_script:
-    - C:\tools\msys64\usr\bin\bash.exe -lc "cd build && make V=1 check"
-    - exit $LastExitCode
diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs
new file mode 100644
index 0000000000..93718ef425
--- /dev/null
+++ b/.git-blame-ignore-revs
@@ -0,0 +1,21 @@
+#
+# List of code-formatting clean ups the git blame can ignore
+#
+#   git blame --ignore-revs-file .git-blame-ignore-revs
+#
+# or
+#
+#   git config blame.ignoreRevsFile .git-blame-ignore-revs
+#
+
+# gdbstub: clean-up indents
+ad9e4585b3c7425759d3eea697afbca71d2c2082
+
+# e1000e: fix code style
+0eadd56bf53ab196a16d492d7dd31c62e1c24c32
+
+# target/riscv: coding style fixes
+8c7feddddd9218b407792120bcfda0347ed16205
+
+# replace TABs with spaces
+48805df9c22a0700fba4b3b548fafaa21726ca68
diff --git a/.gitlab-ci.d/base.yml b/.gitlab-ci.d/base.yml
index 69b36c148a..2fbb58d2a3 100644
--- a/.gitlab-ci.d/base.yml
+++ b/.gitlab-ci.d/base.yml
@@ -6,6 +6,13 @@
 # most restrictive to least restrictive
 #
 .base_job_template:
+  variables:
+    # Each script line from will be in a collapsible section in the job output
+    # and show the duration of each line.
+    FF_SCRIPT_SECTIONS: 1
+
+  interruptible: true
+
   rules:
     #############################################################
     # Stage 1: exclude scenarios where we definitely don't
@@ -68,5 +75,5 @@
     - if: '$QEMU_CI != "2" && $CI_PROJECT_NAMESPACE != "qemu-project"'
       when: manual
 
-    # Jobs can run if any jobs they depend on were successfull
+    # Jobs can run if any jobs they depend on were successful
     - when: on_success
diff --git a/.gitlab-ci.d/buildtest-template.yml b/.gitlab-ci.d/buildtest-template.yml
index 73ecfabb8d..a6cfe9be97 100644
--- a/.gitlab-ci.d/buildtest-template.yml
+++ b/.gitlab-ci.d/buildtest-template.yml
@@ -11,12 +11,10 @@
       fi
     - mkdir build
     - cd build
-    - if test -n "$TARGETS";
-      then
-        ../configure --enable-werror --disable-docs ${LD_JOBS:+--meson=git} $CONFIGURE_ARGS --target-list="$TARGETS" ;
-      else
-        ../configure --enable-werror --disable-docs ${LD_JOBS:+--meson=git} $CONFIGURE_ARGS ;
-      fi || { cat config.log meson-logs/meson-log.txt && exit 1; }
+    - ../configure --enable-werror --disable-docs --enable-fdt=system
+          ${LD_JOBS:+--meson=git} ${TARGETS:+--target-list="$TARGETS"}
+          $CONFIGURE_ARGS ||
+      { cat config.log meson-logs/meson-log.txt && exit 1; }
     - if test -n "$LD_JOBS";
       then
         ../meson/meson.py configure . -Dbackend_max_links="$LD_JOBS" ;
@@ -27,6 +25,22 @@
         make -j"$JOBS" $MAKE_CHECK_ARGS ;
       fi
 
+# We jump some hoops in common_test_job_template to avoid
+# rebuilding all the object files we skip in the artifacts
+.native_build_artifact_template:
+  artifacts:
+    expire_in: 2 days
+    paths:
+      - build
+      - .git-submodule-status
+    exclude:
+      - build/**/*.p
+      - build/**/*.a.p
+      - build/**/*.fa.p
+      - build/**/*.c.o
+      - build/**/*.c.o.d
+      - build/**/*.fa
+
 .common_test_job_template:
   extends: .base_job_template
   stage: test
diff --git a/.gitlab-ci.d/buildtest.yml b/.gitlab-ci.d/buildtest.yml
index 10886bb414..bb3650a51c 100644
--- a/.gitlab-ci.d/buildtest.yml
+++ b/.gitlab-ci.d/buildtest.yml
@@ -2,20 +2,16 @@ include:
   - local: '/.gitlab-ci.d/buildtest-template.yml'
 
 build-system-alpine:
-  extends: .native_build_job_template
+  extends:
+    - .native_build_job_template
+    - .native_build_artifact_template
   needs:
     - job: amd64-alpine-container
   variables:
     IMAGE: alpine
-    TARGETS: aarch64-softmmu alpha-softmmu cris-softmmu hppa-softmmu
-      microblazeel-softmmu mips64el-softmmu
+    TARGETS: avr-softmmu loongarch64-softmmu mips64-softmmu mipsel-softmmu
     MAKE_CHECK_ARGS: check-build
     CONFIGURE_ARGS: --enable-docs --enable-trace-backends=log,simple,syslog
-  artifacts:
-    expire_in: 2 days
-    paths:
-      - .git-submodule-status
-      - build
 
 check-system-alpine:
   extends: .native_test_job_template
@@ -36,19 +32,17 @@ avocado-system-alpine:
     MAKE_CHECK_ARGS: check-avocado
 
 build-system-ubuntu:
-  extends: .native_build_job_template
+  extends:
+    - .native_build_job_template
+    - .native_build_artifact_template
   needs:
-    job: amd64-ubuntu2004-container
+    job: amd64-ubuntu2204-container
   variables:
-    IMAGE: ubuntu2004
-    CONFIGURE_ARGS: --enable-docs --enable-fdt=system --enable-capstone
-    TARGETS: aarch64-softmmu alpha-softmmu cris-softmmu hppa-softmmu
+    IMAGE: ubuntu2204
+    CONFIGURE_ARGS: --enable-docs
+    TARGETS: alpha-softmmu cris-softmmu hppa-softmmu
       microblazeel-softmmu mips64el-softmmu
     MAKE_CHECK_ARGS: check-build
-  artifacts:
-    expire_in: 2 days
-    paths:
-      - build
 
 check-system-ubuntu:
   extends: .native_test_job_template
@@ -56,7 +50,7 @@ check-system-ubuntu:
     - job: build-system-ubuntu
       artifacts: true
   variables:
-    IMAGE: ubuntu2004
+    IMAGE: ubuntu2204
     MAKE_CHECK_ARGS: check
 
 avocado-system-ubuntu:
@@ -65,22 +59,21 @@ avocado-system-ubuntu:
     - job: build-system-ubuntu
       artifacts: true
   variables:
-    IMAGE: ubuntu2004
+    IMAGE: ubuntu2204
     MAKE_CHECK_ARGS: check-avocado
 
 build-system-debian:
-  extends: .native_build_job_template
+  extends:
+    - .native_build_job_template
+    - .native_build_artifact_template
   needs:
     job: amd64-debian-container
   variables:
     IMAGE: debian-amd64
-    TARGETS: arm-softmmu avr-softmmu i386-softmmu mipsel-softmmu
-      riscv64-softmmu sh4eb-softmmu sparc-softmmu xtensaeb-softmmu
+    CONFIGURE_ARGS: --with-coroutine=sigaltstack
+    TARGETS: arm-softmmu i386-softmmu riscv64-softmmu sh4eb-softmmu
+      sparc-softmmu xtensaeb-softmmu
     MAKE_CHECK_ARGS: check-build
-  artifacts:
-    expire_in: 2 days
-    paths:
-      - build
 
 check-system-debian:
   extends: .native_test_job_template
@@ -113,20 +106,17 @@ crash-test-debian:
     - tests/venv/bin/python3 scripts/device-crash-test -q --tcg-only ./qemu-system-i386
 
 build-system-fedora:
-  extends: .native_build_job_template
+  extends:
+    - .native_build_job_template
+    - .native_build_artifact_template
   needs:
     job: amd64-fedora-container
   variables:
     IMAGE: fedora
     CONFIGURE_ARGS: --disable-gcrypt --enable-nettle --enable-docs
-             --enable-fdt=system --enable-slirp --enable-capstone
     TARGETS: tricore-softmmu microblaze-softmmu mips-softmmu
       xtensa-softmmu m68k-softmmu riscv32-softmmu ppc-softmmu sparc64-softmmu
     MAKE_CHECK_ARGS: check-build
-  artifacts:
-    expire_in: 2 days
-    paths:
-      - build
 
 check-system-fedora:
   extends: .native_test_job_template
@@ -160,21 +150,18 @@ crash-test-fedora:
     - tests/venv/bin/python3 scripts/device-crash-test -q ./qemu-system-riscv32
 
 build-system-centos:
-  extends: .native_build_job_template
+  extends:
+    - .native_build_job_template
+    - .native_build_artifact_template
   needs:
     job: amd64-centos8-container
   variables:
     IMAGE: centos8
-    CONFIGURE_ARGS: --disable-nettle --enable-gcrypt --enable-fdt=system
+    CONFIGURE_ARGS: --disable-nettle --enable-gcrypt --enable-vfio-user-server
       --enable-modules --enable-trace-backends=dtrace --enable-docs
-      --enable-vfio-user-server
     TARGETS: ppc64-softmmu or1k-softmmu s390x-softmmu
       x86_64-softmmu rx-softmmu sh4-softmmu nios2-softmmu
     MAKE_CHECK_ARGS: check-build
-  artifacts:
-    expire_in: 2 days
-    paths:
-      - build
 
 check-system-centos:
   extends: .native_test_job_template
@@ -195,18 +182,15 @@ avocado-system-centos:
     MAKE_CHECK_ARGS: check-avocado
 
 build-system-opensuse:
-  extends: .native_build_job_template
+  extends:
+    - .native_build_job_template
+    - .native_build_artifact_template
   needs:
     job: amd64-opensuse-leap-container
   variables:
     IMAGE: opensuse-leap
-    CONFIGURE_ARGS: --enable-fdt=system
     TARGETS: s390x-softmmu x86_64-softmmu aarch64-softmmu
     MAKE_CHECK_ARGS: check-build
-  artifacts:
-    expire_in: 2 days
-    paths:
-      - build
 
 check-system-opensuse:
   extends: .native_test_job_template
@@ -244,6 +228,7 @@ build-tcg-disabled:
     - mkdir build
     - cd build
     - ../configure --disable-tcg --audio-drv-list="" --with-coroutine=ucontext
+                   --disable-docs --disable-sdl --disable-gtk --disable-vnc
       || { cat config.log meson-logs/meson-log.txt && exit 1; }
     - make -j"$JOBS"
     - make check-unit
@@ -275,14 +260,10 @@ build-user-static:
     CONFIGURE_ARGS: --disable-tools --disable-system --static
     MAKE_CHECK_ARGS: check-tcg
 
-# Because the hexagon cross-compiler takes so long to build we don't rely
-# on the CI system to build it and hence this job has an optional dependency
-# declared. The image is manually uploaded.
 build-user-hexagon:
   extends: .native_build_job_template
   needs:
     job: hexagon-cross-container
-    optional: true
   variables:
     IMAGE: debian-hexagon-cross
     TARGETS: hexagon-linux-user
@@ -319,8 +300,7 @@ clang-system:
     IMAGE: fedora
     CONFIGURE_ARGS: --cc=clang --cxx=clang++
       --extra-cflags=-fsanitize=undefined --extra-cflags=-fno-sanitize-recover=undefined


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 22:22:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 22:22:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681188.1059801 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raNdi-0005QK-Sd; Wed, 14 Feb 2024 22:22:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681188.1059801; Wed, 14 Feb 2024 22:22:02 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raNdi-0005QC-Pq; Wed, 14 Feb 2024 22:22:02 +0000
Received: by outflank-mailman (input) for mailman id 681188;
 Wed, 14 Feb 2024 22:22:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNdi-0005Q6-4b
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNdi-00067R-2R
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNdi-0007Fd-1R
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=KcZbvCEA30fxrQNaIJ3IXi5oFeA/OHyZowFlKKNyedM=; b=jS0WmSBY3U9ukdAD2/NDNzaUxi
	SOaQxKgiXukIug9IUXX30cSDFTqq7MRzdVOpB4CCBiPc4jhD41p19X+J6LuLiPIt1ghcum4Rukjh/
	YgxXX0xWPavblOwuI/rXIo7ZuTpeenpS+TsogeYAykPqPMihOy/CXhguWQbGfgmFuy1g=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] Argo: drop meaningless mfn_valid() check
Message-Id: <E1raNdi-0007Fd-1R@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 22:22:02 +0000

commit 9bb281d328cb7c6319f44897a2c29909eeb8674b
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Wed Feb 14 10:38:38 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Feb 14 10:38:38 2024 +0100

    Argo: drop meaningless mfn_valid() check
    
    Holding a valid struct page_info * in hands already means the referenced
    MFN is valid; there's no need to check that again. Convert the checking
    logic to a switch(), to help keeping the extra (and questionable) x86-
    only check in somewhat tidy shape.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Christopher Clark <christopher.w.clark@gmail.com>
---
 xen/common/argo.c | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/xen/common/argo.c b/xen/common/argo.c
index f29fa720fc..5dc5e45c7b 100644
--- a/xen/common/argo.c
+++ b/xen/common/argo.c
@@ -1421,15 +1421,24 @@ find_ring_mfn(struct domain *d, gfn_t gfn, mfn_t *mfn)
         return ret;
 
     *mfn = page_to_mfn(page);
-    if ( !mfn_valid(*mfn) )
-        ret = -EINVAL;
+
+    switch ( p2mt )
+    {
+    case p2m_ram_rw:
+        if ( !get_page_and_type(page, d, PGT_writable_page) )
+            ret = -EINVAL;
+        break;
+
 #ifdef CONFIG_X86
-    else if ( p2mt == p2m_ram_logdirty )
+    case p2m_ram_logdirty:
         ret = -EAGAIN;
+        break;
 #endif
-    else if ( (p2mt != p2m_ram_rw) ||
-              !get_page_and_type(page, d, PGT_writable_page) )
+
+    default:
         ret = -EINVAL;
+        break;
+    }
 
     put_page(page);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 22:22:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 22:22:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681189.1059804 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raNds-0005SM-Tu; Wed, 14 Feb 2024 22:22:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681189.1059804; Wed, 14 Feb 2024 22:22:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raNds-0005SF-RM; Wed, 14 Feb 2024 22:22:12 +0000
Received: by outflank-mailman (input) for mailman id 681189;
 Wed, 14 Feb 2024 22:22:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNds-0005S7-7X
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNds-00067Z-6i
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNds-0007GU-4k
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=kyAbIM3p0diyVRM3BZM7Q+YOU/6ulzCgKjxeOdG/Lws=; b=nWzpoKdHX1t9TwZVrl2te00tos
	TW796x+HCa4RojI9ht9c351moGFAoBhZpK8pVa2pwi3gPjwr2hHTDTwGjGqPLmncAd1j0cRKOmJ0A
	tV9WdU0uVJcZxSzXi8ZnykOiZSUI13YfI/PWHfSKukXhcMUrFR/zcKFMdluuc7hIIWps=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/riscv: define an address of frame table
Message-Id: <E1raNds-0007GU-4k@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 22:22:12 +0000

commit 4f2c81d5091552408720de502994bc375be4ec61
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Wed Feb 14 10:40:02 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Feb 14 10:40:02 2024 +0100

    xen/riscv: define an address of frame table
    
    Also, the patch adds some helpful macros that assist in avoiding
    the redefinition of memory layout for each MMU mode.
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/riscv/include/asm/config.h | 105 ++++++++++++++++++++++++++----------
 1 file changed, 77 insertions(+), 28 deletions(-)

diff --git a/xen/arch/riscv/include/asm/config.h b/xen/arch/riscv/include/asm/config.h
index a80cdd4f85..2c7f2b1ff9 100644
--- a/xen/arch/riscv/include/asm/config.h
+++ b/xen/arch/riscv/include/asm/config.h
@@ -6,6 +6,16 @@
 #include <xen/const.h>
 #include <xen/page-size.h>
 
+#include <asm/riscv_encoding.h>
+
+#ifdef CONFIG_RISCV_64
+#define CONFIG_PAGING_LEVELS 3
+#define RV_STAGE1_MODE SATP_MODE_SV39
+#else
+#define CONFIG_PAGING_LEVELS 2
+#define RV_STAGE1_MODE SATP_MODE_SV32
+#endif
+
 /*
  * RISC-V64 Layout:
  *
@@ -23,25 +33,78 @@
  * It means that:
  *   top VA bits are simply ignored for the purpose of translating to PA.
  *
+ * Amount of slots for Frametable were calculated base on
+ * sizeof(struct page_info) = 48. If the 'struct page_info' is changed,
+ * the table below must be updated.
+ *
  * ============================================================================
- *    Start addr    |   End addr        |  Size  | Slot       |area description
- * ============================================================================
- * FFFFFFFFC0800000 |  FFFFFFFFFFFFFFFF |1016 MB | L2 511     | Unused
- * FFFFFFFFC0600000 |  FFFFFFFFC0800000 |  2 MB  | L2 511     | Fixmap
- * FFFFFFFFC0200000 |  FFFFFFFFC0600000 |  4 MB  | L2 511     | FDT
- * FFFFFFFFC0000000 |  FFFFFFFFC0200000 |  2 MB  | L2 511     | Xen
- *                 ...                  |  1 GB  | L2 510     | Unused
- * 0000003200000000 |  0000007F80000000 | 309 GB | L2 200-509 | Direct map
- *                 ...                  |  1 GB  | L2 199     | Unused
- * 0000003100000000 |  00000031C0000000 |  3 GB  | L2 196-198 | Frametable
- *                 ...                  |  1 GB  | L2 195     | Unused
- * 0000003080000000 |  00000030C0000000 |  1 GB  | L2 194     | VMAP
- *                 ...                  | 194 GB | L2 0 - 193 | Unused
+ * Start addr          | End addr         | Slot       | area description
  * ============================================================================
- *
+ *                   .....                 L2 511          Unused
+ *  0xffffffffc0600000  0xffffffffc0800000 L2 511          Fixmap
+ *  0xffffffffc0200000  0xffffffffc0600000 L2 511          FDT
+ *  0xffffffffc0000000  0xffffffffc0200000 L2 511          Xen
+ *                   .....                 L2 510          Unused
+ *  0x3200000000        0x7f40000000       L2 200-509      Direct map
+ *                   .....                 L2 199          Unused
+ *  0x30c0000000        0x31c0000000       L2 195-198      Frametable
+ *                   .....                 L2 194          Unused
+ *  0x3040000000        0x3080000000       L2 193          VMAP
+ *                   .....                 L2 0-192        Unused
+#elif RV_STAGE1_MODE == SATP_MODE_SV48
+ * Memory layout is the same as for SV39 in terms of slots, so only start and
+ * end addresses should be shifted by 9
 #endif
  */
 
+#define HYP_PT_ROOT_LEVEL (CONFIG_PAGING_LEVELS - 1)
+
+#ifdef CONFIG_RISCV_64
+
+#define VPN_BITS (9)
+
+#define SLOTN_ENTRY_BITS        (HYP_PT_ROOT_LEVEL * VPN_BITS + PAGE_SHIFT)
+#define SLOTN(slot)             (_AT(vaddr_t, slot) << SLOTN_ENTRY_BITS)
+
+#if RV_STAGE1_MODE == SATP_MODE_SV39
+#define XEN_VIRT_START 0xFFFFFFFFC0000000
+#elif RV_STAGE1_MODE == SATP_MODE_SV48
+#define XEN_VIRT_START 0xFFFFFF8000000000
+#else
+#error "unsupported RV_STAGE1_MODE"
+#endif
+
+#define DIRECTMAP_SLOT_END      509
+#define DIRECTMAP_SLOT_START    200
+#define DIRECTMAP_VIRT_START    SLOTN(DIRECTMAP_SLOT_START)
+#define DIRECTMAP_SIZE          (SLOTN(DIRECTMAP_SLOT_END) - SLOTN(DIRECTMAP_SLOT_START))
+
+#define FRAMETABLE_SCALE_FACTOR  (PAGE_SIZE/sizeof(struct page_info))
+#define FRAMETABLE_SIZE_IN_SLOTS (((DIRECTMAP_SIZE / SLOTN(1)) / FRAMETABLE_SCALE_FACTOR) + 1)
+
+/*
+ * We have to skip Unused slot between DIRECTMAP and FRAMETABLE (look at mem.
+ * layout), so -1 is needed
+ */
+#define FRAMETABLE_SLOT_START   (DIRECTMAP_SLOT_START - FRAMETABLE_SIZE_IN_SLOTS - 1)
+#define FRAMETABLE_SIZE         (FRAMETABLE_SIZE_IN_SLOTS * SLOTN(1))
+#define FRAMETABLE_VIRT_START   SLOTN(FRAMETABLE_SLOT_START)
+#define FRAMETABLE_NR           (FRAMETABLE_SIZE / sizeof(*frame_table))
+#define FRAMETABLE_VIRT_END     (FRAMETABLE_VIRT_START + FRAMETABLE_SIZE - 1)
+
+/*
+ * We have to skip Unused slot between Frametable and VMAP (look at mem.
+ * layout), so an additional -1 is needed */
+#define VMAP_SLOT_START         (FRAMETABLE_SLOT_START - 1 - 1)
+#define VMAP_VIRT_START         SLOTN(VMAP_SLOT_START)
+#define VMAP_VIRT_SIZE          GB(1)
+
+#else
+#error "RV32 isn't supported"
+#endif
+
+#define HYPERVISOR_VIRT_START XEN_VIRT_START
+
 #if defined(CONFIG_RISCV_64)
 # define LONG_BYTEORDER 3
 # define ELFSIZE 64
@@ -73,24 +136,10 @@
 #define CODE_FILL /* empty */
 #endif
 
-#ifdef CONFIG_RISCV_64
-#define XEN_VIRT_START 0xFFFFFFFFC0000000 /* (_AC(-1, UL) + 1 - GB(1)) */
-#else
-#error "RV32 isn't supported"
-#endif
-
 #define SMP_CACHE_BYTES (1 << 6)
 
 #define STACK_SIZE PAGE_SIZE
 
-#ifdef CONFIG_RISCV_64
-#define CONFIG_PAGING_LEVELS 3
-#define RV_STAGE1_MODE SATP_MODE_SV39
-#else
-#define CONFIG_PAGING_LEVELS 2
-#define RV_STAGE1_MODE SATP_MODE_SV32
-#endif
-
 #define IDENT_AREA_SIZE 64
 
 #endif /* __RISCV_CONFIG_H__ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 22:22:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 22:22:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681190.1059809 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raNe2-0005VN-W2; Wed, 14 Feb 2024 22:22:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681190.1059809; Wed, 14 Feb 2024 22:22:22 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raNe2-0005VF-Sz; Wed, 14 Feb 2024 22:22:22 +0000
Received: by outflank-mailman (input) for mailman id 681190;
 Wed, 14 Feb 2024 22:22:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNe2-0005V5-BQ
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNe2-00067i-AE
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNe2-0007IW-9J
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=FFVZCv4caxttOY0fPaxdCRInQV9IlQzj2+8BvpgERfA=; b=JKD7Y4kxTF/lk827EfYijptYPK
	eLRJas2PmyBQS0DavlMiaLnebKmEemg46n8nKmlV7vB3r5zxQyx+U9salPRHjCPw9a8l955cbPh//
	XacrM+BASEnvGY1s058Moqal3DFFo8maDUttye4fLptyMAaFGRwD+yASZjD+I9oQqJ2U=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] libxl: Create empty file for Phy cdrom
Message-Id: <E1raNe2-0007IW-9J@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 22:22:22 +0000

commit 4e41947bad8189d5b40cd29894f554b740ce272f
Author:     Jason Andryuk <jandryuk@gmail.com>
AuthorDate: Wed Feb 14 10:40:56 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Feb 14 10:40:56 2024 +0100

    libxl: Create empty file for Phy cdrom
    
    With a device model stubdom, dom0 exports a PV disk to the stubdom.
    Inside the stubdom, QEMU emulates a cdrom to the guest with a
    host_device pointing at the PV frontend (/dev/xvdc)
    
    An empty cdrom drive causes problems booting the stubdom.  The PV disk
    protocol isn't designed to support no media.  That can be partially
    hacked around, but the stubdom kernel waits for all block devices to
    transition to Connected.  Since the backend never connects empty media,
    stubdom launch times out and it is destroyed.
    
    Empty media and the PV disks not connecting is fine at runtime since the
    stubdom keeps running irrespective of the disk state.
    
    Empty media can be worked around my providing an empty file to the
    stubdom for the PV disk source.  This works as the disk is exposed as a
    zero-size disk.  Dynamically create the empty file as needed and remove
    in the stubdom cleanup.
    
    libxl__device_disk_set_backend() needs to allow through these "empty"
    disks with a pdev_path.
    
    Fixup the params writing since scripts have trouble with an empty params
    field.
    
    This works for non-stubdom HVMs as well.
    
    Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libs/light/libxl_device.c   |  5 ++++-
 tools/libs/light/libxl_disk.c     | 36 ++++++++++++++++++++++++++++++++----
 tools/libs/light/libxl_domain.c   |  4 ++++
 tools/libs/light/libxl_internal.h |  1 +
 4 files changed, 41 insertions(+), 5 deletions(-)

diff --git a/tools/libs/light/libxl_device.c b/tools/libs/light/libxl_device.c
index ae2b71b0bf..8bd780493f 100644
--- a/tools/libs/light/libxl_device.c
+++ b/tools/libs/light/libxl_device.c
@@ -427,7 +427,10 @@ int libxl__device_disk_set_backend(libxl__gc *gc, libxl_device_disk *disk) {
             LOG(ERROR, "Disk vdev=%s is empty but not cdrom", disk->vdev);
             return ERROR_INVAL;
         }
-        if (disk->pdev_path != NULL && strcmp(disk->pdev_path, "")) {
+        if (disk->pdev_path != NULL &&
+            (strcmp(disk->pdev_path, "") &&
+             strncmp(disk->pdev_path, LIBXL_STUBDOM_EMPTY_CDROM,
+                     strlen(LIBXL_STUBDOM_EMPTY_CDROM)))) {
             LOG(ERROR,
                 "Disk vdev=%s is empty but an image has been provided: %s",
                 disk->vdev, disk->pdev_path);
diff --git a/tools/libs/light/libxl_disk.c b/tools/libs/light/libxl_disk.c
index 59ff996837..95b32f9d29 100644
--- a/tools/libs/light/libxl_disk.c
+++ b/tools/libs/light/libxl_disk.c
@@ -201,6 +201,32 @@ static int libxl__device_disk_setdefault(libxl__gc *gc, uint32_t domid,
         disk->backend = LIBXL_DISK_BACKEND_QDISK;
     }
 
+    if (disk->is_cdrom &&
+        disk->format == LIBXL_DISK_FORMAT_EMPTY &&
+        disk->backend == LIBXL_DISK_BACKEND_PHY &&
+        disk->backend_domid == LIBXL_TOOLSTACK_DOMID) {
+        uint32_t target_domid;
+        int fd;
+
+        if (libxl_is_stubdom(CTX, domid, &target_domid)) {
+            LOGED(DEBUG, domid, "Using target_domid %u", target_domid);
+        } else {
+            target_domid = domid;
+        }
+        free(disk->pdev_path);
+        disk->pdev_path =
+            libxl__sprintf(NOGC, LIBXL_STUBDOM_EMPTY_CDROM ".%u",
+                           target_domid);
+        fd = creat(disk->pdev_path, 0400);
+        if (fd < 0) {
+            LOGED(ERROR, domid, "Failed to create empty cdrom \"%s\"",
+                  disk->pdev_path);
+            return ERROR_FAIL;
+        }
+
+        close(fd);
+    }
+
     rc = libxl__device_disk_set_backend(gc, disk);
     return rc;
 }
@@ -998,7 +1024,7 @@ static void cdrom_insert_ejected(libxl__egc *egc,
     empty = flexarray_make(gc, 4, 1);
     flexarray_append_pair(empty, "type",
                           libxl__device_disk_string_of_backend(disk->backend));
-    flexarray_append_pair(empty, "params", "");
+    flexarray_append_pair(empty, "params", disk->pdev_path ?: "");
 
     for (;;) {
         rc = libxl__xs_transaction_start(gc, &t);
@@ -1174,13 +1200,15 @@ static void cdrom_insert_inserted(libxl__egc *egc,
     insert = flexarray_make(gc, 4, 1);
     flexarray_append_pair(insert, "type",
                       libxl__device_disk_string_of_backend(disk->backend));
-    if (disk->format != LIBXL_DISK_FORMAT_EMPTY)
+    if (disk->backend == LIBXL_DISK_BACKEND_QDISK &&
+        disk->format != LIBXL_DISK_FORMAT_EMPTY) {
         flexarray_append_pair(insert, "params",
                     GCSPRINTF("%s:%s",
                         libxl__device_disk_string_of_format(disk->format),
                         disk->pdev_path));
-    else
-        flexarray_append_pair(insert, "params", "");
+    } else {
+        flexarray_append_pair(insert, "params", disk->pdev_path ?: "");
+    }
 
     for (;;) {
         rc = libxl__xs_transaction_start(gc, &t);
diff --git a/tools/libs/light/libxl_domain.c b/tools/libs/light/libxl_domain.c
index 5ee1544d9c..6751fc785f 100644
--- a/tools/libs/light/libxl_domain.c
+++ b/tools/libs/light/libxl_domain.c
@@ -1525,6 +1525,10 @@ static void devices_destroy_cb(libxl__egc *egc,
     if (rc < 0)
         LOGD(ERROR, domid, "libxl__devices_destroy failed");
 
+    /* Remove the file after the hotplug scripts have run.  The scripts won't
+     * run if the file doesn't exist when they are run.  */
+    libxl__remove_file(gc, GCSPRINTF(LIBXL_STUBDOM_EMPTY_CDROM ".%u", domid));
+
     vm_path = libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/vm", dom_path));
     if (vm_path)
         if (!xs_rm(ctx->xsh, XBT_NULL, vm_path))
diff --git a/tools/libs/light/libxl_internal.h b/tools/libs/light/libxl_internal.h
index d5732d1c37..094d0df9b1 100644
--- a/tools/libs/light/libxl_internal.h
+++ b/tools/libs/light/libxl_internal.h
@@ -120,6 +120,7 @@
 #define STUBDOM_CONSOLE_SERIAL 3
 #define STUBDOM_SPECIAL_CONSOLES 3
 #define LIBXL_LINUX_STUBDOM_MEM 128
+#define LIBXL_STUBDOM_EMPTY_CDROM XEN_RUN_DIR "/empty-cdrom" /* .$domid */
 #define TAP_DEVICE_SUFFIX "-emu"
 #define DOMID_XS_PATH "domid"
 #define PVSHIM_BASENAME "xen-shim"
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 22:22:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 22:22:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681191.1059812 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raNeE-0005Yi-0m; Wed, 14 Feb 2024 22:22:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681191.1059812; Wed, 14 Feb 2024 22:22:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raNeD-0005Yb-UV; Wed, 14 Feb 2024 22:22:33 +0000
Received: by outflank-mailman (input) for mailman id 681191;
 Wed, 14 Feb 2024 22:22:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNeC-0005YJ-FB
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNeC-00068A-Da
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNeC-0007JA-CY
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=8ZKKddmxSPcJffj9AJHx5fwTK0tpSP8FZdZB0MezuuE=; b=eg38NCPdGvH4P5UWgGdo2JnE1O
	wSehvhtL6XdrdMec9eZ+z0nTZCN0TErQdcZpKqw6B7WajeZvAZeHQCC/Jf2BwThLYEZSxlfp6ITNV
	Hv2klCXN95ycjYcih+RQr1jDwLacgHOUOiKbiALKm+lNbLC/eTbMyLnEMDiIAgH5Je+I=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] libxl: Allow Phy backend for CDROM devices
Message-Id: <E1raNeC-0007JA-CY@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 22:22:32 +0000

commit d9d4c5a142c9c519a7c6b71f157f04234b8d09a5
Author:     Jason Andryuk <jandryuk@gmail.com>
AuthorDate: Wed Feb 14 10:41:17 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Feb 14 10:41:17 2024 +0100

    libxl: Allow Phy backend for CDROM devices
    
    A Linux HVM domain ignores PV block devices with type cdrom.  The
    Windows PV drivers also ignore device-type != "disk".  Therefore QEMU's
    emulated CD-ROM support is used.  This allows ejection and other CD-ROM
    features to work.
    
    With a stubdom, QEMU is running in the stubdom.  A PV disk is still
    connected into the stubdom, and then QEMU can emulate the CD-ROM into
    the guest.  Phy support has been enhanced to provide a placeholder file
    forempty disks, so it is usable as a CDROM backend as well.  Allow Phy
    to pass the check as well.
    
    (Bypassing just for a linux-based stubdom doesn't work because
    libxl__device_disk_setdefault() gets called early in domain creation
    before xenstore is populated with relevant information for the stubdom
    type.  The build information isn't readily available and won't exist in
    some call trees, so it isn't usable either.)
    
    Let disk_try_backend() allow format empty for Phy cdrom drives.
    
    Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libs/light/libxl_device.c | 12 ++++++++----
 tools/libs/light/libxl_disk.c   | 11 +++++++----
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/tools/libs/light/libxl_device.c b/tools/libs/light/libxl_device.c
index 8bd780493f..6f0100d05e 100644
--- a/tools/libs/light/libxl_device.c
+++ b/tools/libs/light/libxl_device.c
@@ -301,13 +301,17 @@ static int disk_try_backend(disk_try_backend_args *a,
 
     switch (backend) {
     case LIBXL_DISK_BACKEND_PHY:
-        if (a->disk->format != LIBXL_DISK_FORMAT_RAW) {
-            goto bad_format;
-        }
-
         if (libxl_defbool_val(a->disk->colo_enable))
             goto bad_colo;
 
+        if (a->disk->is_cdrom && a->disk->format == LIBXL_DISK_FORMAT_EMPTY) {
+            LOG(DEBUG, "Disk vdev=%s is an empty cdrom", a->disk->vdev);
+            return backend;
+        }
+
+        if (a->disk->format != LIBXL_DISK_FORMAT_RAW)
+            goto bad_format;
+
         if (a->disk->backend_domid != LIBXL_TOOLSTACK_DOMID) {
             LOG(DEBUG, "Disk vdev=%s, is using a storage driver domain, "
                        "skipping physical device check", a->disk->vdev);
diff --git a/tools/libs/light/libxl_disk.c b/tools/libs/light/libxl_disk.c
index 95b32f9d29..ee2e4b0bd3 100644
--- a/tools/libs/light/libxl_disk.c
+++ b/tools/libs/light/libxl_disk.c
@@ -190,15 +190,18 @@ static int libxl__device_disk_setdefault(libxl__gc *gc, uint32_t domid,
         return ERROR_FAIL;
     }
 
-    /* Force Qdisk backend for CDROM devices of guests with a device model. */
+    /* Only allow Qdisk or Phy for CDROM devices. */
     if (disk->is_cdrom != 0 &&
         libxl__domain_type(gc, domid) == LIBXL_DOMAIN_TYPE_HVM) {
+        if (disk->backend == LIBXL_DISK_BACKEND_UNKNOWN)
+            disk->backend = LIBXL_DISK_BACKEND_QDISK;
+
         if (!(disk->backend == LIBXL_DISK_BACKEND_QDISK ||
-              disk->backend == LIBXL_DISK_BACKEND_UNKNOWN)) {
-            LOGD(ERROR, domid, "Backend for CD devices on HVM guests must be Qdisk");
+              disk->backend == LIBXL_DISK_BACKEND_PHY)) {
+            LOGD(ERROR, domid,
+                 "Backend for CD devices on HVM guests must be Qdisk or Phy");
             return ERROR_FAIL;
         }
-        disk->backend = LIBXL_DISK_BACKEND_QDISK;
     }
 
     if (disk->is_cdrom &&
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 22:22:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 22:22:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681192.1059817 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raNeO-0005bo-2i; Wed, 14 Feb 2024 22:22:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681192.1059817; Wed, 14 Feb 2024 22:22:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raNeN-0005bg-W6; Wed, 14 Feb 2024 22:22:43 +0000
Received: by outflank-mailman (input) for mailman id 681192;
 Wed, 14 Feb 2024 22:22:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNeM-0005bY-HQ
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNeM-00068H-Gg
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNeM-0007Jn-Fl
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=iea0QFNayYKkoY4R0cjiedDIIK5+yBf439AcyJrEOf4=; b=XtBSEsKwJzS3KSAU+BMEHslMXq
	hB0SxM7m0yvTPc24i7gr/w/USrx/Ptso1NkVmGbhrPXgfdeLRaJ+/IlsNtQsqUWiXqxcQQExUD2Ya
	B1bN7z4w5J4Sp5vXdeGLBkuS1n5rRIOzyOP3pKRTHqUa1n6nU1dD85dfpKGDgP5IvHXs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xentop: add option to display dom0 first
Message-Id: <E1raNeM-0007Jn-Fl@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 22:22:42 +0000

commit 03e08d44c8aebc78f1b6ae8235f65d4cbdd75242
Author:     Cyril Rébert <slack@rabbit.lu>
AuthorDate: Wed Feb 14 10:41:43 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Feb 14 10:41:43 2024 +0100

    tools/xentop: add option to display dom0 first
    
    Add a command line option to xentop to be able to display dom0 first, on top of the list.
    This is unconditional, so sorting domains with the S option will also ignore dom0.
    
    Signed-off-by: Cyril Rébert (zithro) <slack@rabbit.lu>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 docs/man/xentop.1.pod |  6 +++++-
 tools/xentop/xentop.c | 30 +++++++++++++++++++++++++++---
 2 files changed, 32 insertions(+), 4 deletions(-)

diff --git a/docs/man/xentop.1.pod b/docs/man/xentop.1.pod
index 126f43d2f3..593a484ce7 100644
--- a/docs/man/xentop.1.pod
+++ b/docs/man/xentop.1.pod
@@ -5,7 +5,7 @@ xentop - displays real-time information about a Xen system and domains
 =head1 SYNOPSIS
 
 B<xentop> [B<-h>] [B<-V>] [B<-d>SECONDS] [B<-n>] [B<-r>] [B<-v>] [B<-f>]
-[B<-b>] [B<-i>ITERATIONS]
+[B<-b>] [B<-i>ITERATIONS] [B<-z>]
 
 =head1 DESCRIPTION
 
@@ -57,6 +57,10 @@ output data in batch mode (to stdout)
 
 maximum number of iterations xentop should produce before ending
 
+=item B<-z>, B<--dom0-first>
+
+display dom0 first, ignoring interactive sorting
+
 =back
 
 =head1 INTERACTIVE COMMANDS
diff --git a/tools/xentop/xentop.c b/tools/xentop/xentop.c
index 545bd5e96d..0a2fab7f15 100644
--- a/tools/xentop/xentop.c
+++ b/tools/xentop/xentop.c
@@ -211,6 +211,7 @@ int show_networks = 0;
 int show_vbds = 0;
 int repeat_header = 0;
 int show_full_name = 0;
+int dom0_first = 0;
 #define PROMPT_VAL_LEN 80
 const char *prompt = NULL;
 char prompt_val[PROMPT_VAL_LEN];
@@ -240,6 +241,7 @@ static void usage(const char *program)
 	       "-b, --batch	     output in batch mode, no user input accepted\n"
 	       "-i, --iterations     number of iterations before exiting\n"
 	       "-f, --full-name      output the full domain name (not truncated)\n"
+	       "-z, --dom0-first     display dom0 first (ignore sorting)\n"
 	       "\n" XENTOP_BUGSTO,
 	       program);
 	return;
@@ -1163,6 +1165,8 @@ static void top(void)
 {
 	xenstat_domain **domains;
 	unsigned int i, num_domains = 0;
+	int dom0_index = -1;
+	int sort_start = 0, sort_count = 0;
 
 	/* Now get the node information */
 	if (prev_node != NULL)
@@ -1183,11 +1187,27 @@ static void top(void)
 	if(domains == NULL)
 		fail("Failed to allocate memory\n");
 
-	for (i=0; i < num_domains; i++)
+	for (i=0; i < num_domains; i++) {
 		domains[i] = xenstat_node_domain_by_index(cur_node, i);
+		if ( strcmp(xenstat_domain_name(domains[i]), "Domain-0") == 0 )
+			dom0_index = i;
+	}
+
+	/* Handle dom0 position, not for dom0-less */
+	if ( dom0_first == 1 && dom0_index != -1 ){
+		/* if dom0 is not first in domains, swap it there */
+		if ( dom0_index != 0 ){
+			xenstat_domain *tmp;
+			tmp = domains[0];
+			domains[0] = domains[dom0_index];
+			domains[dom0_index] = tmp;
+		}
+		sort_start = 1;
+		sort_count = 1;
+	}
 
 	/* Sort */
-	qsort(domains, num_domains, sizeof(xenstat_domain *),
+	qsort((domains+sort_start), (num_domains-sort_count), sizeof(xenstat_domain *),
 	      (int(*)(const void *, const void *))compare_domains);
 
 	if(first_domain_index >= num_domains)
@@ -1242,9 +1262,10 @@ int main(int argc, char **argv)
 		{ "batch",	   no_argument,	      NULL, 'b' },
 		{ "iterations",	   required_argument, NULL, 'i' },
 		{ "full-name",     no_argument,       NULL, 'f' },
+		{ "dom0-first",    no_argument,       NULL, 'z' },
 		{ 0, 0, 0, 0 },
 	};
-	const char *sopts = "hVnxrvd:bi:f";
+	const char *sopts = "hVnxrvd:bi:fz";
 
 	if (atexit(cleanup) != 0)
 		fail("Failed to install cleanup handler.\n");
@@ -1286,6 +1307,9 @@ int main(int argc, char **argv)
 		case 'f':
 			show_full_name = 1;
 			break;
+		case 'z':
+			dom0_first = 1;
+			break;
 		}
 	}
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 22:22:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 22:22:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681193.1059820 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raNeY-0005eo-5D; Wed, 14 Feb 2024 22:22:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681193.1059820; Wed, 14 Feb 2024 22:22:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raNeY-0005eh-2X; Wed, 14 Feb 2024 22:22:54 +0000
Received: by outflank-mailman (input) for mailman id 681193;
 Wed, 14 Feb 2024 22:22:52 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNeW-0005eW-KD
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:52 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNeW-00068e-JU
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNeW-0007KJ-Ii
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:22:52 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=IvEQnQWqfiuCEh2PjRcsAXHbNq+gOCX6JwVGkcikAyM=; b=xne1ArRnYs43GykhxAXoHdiJFn
	ScK6r5v/OP2/DZu+VuNo8vJrJ0W3q23JZzmIRnUpxcmaG0duaY4xFviF3jCoeqN7XrwioUa/gk4sx
	HurRQPSggeI0y7OEUXPYCFvEMcvKlF1snjmojriXr3FdpT88bTDqIiTBOJJO3ASOP2LI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools: add access macros for unaligned data
Message-Id: <E1raNeW-0007KJ-Ii@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 22:22:52 +0000

commit 40da8a7e4b94e4925bbc259e206d7f8690486263
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Wed Feb 14 10:41:59 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Feb 14 10:41:59 2024 +0100

    tools: add access macros for unaligned data
    
    Add the basic access macros for unaligned data to common-macros.h.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/include/xen-tools/common-macros.h | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/tools/include/xen-tools/common-macros.h b/tools/include/xen-tools/common-macros.h
index e5ed603904..81fba2e9f5 100644
--- a/tools/include/xen-tools/common-macros.h
+++ b/tools/include/xen-tools/common-macros.h
@@ -79,6 +79,10 @@
 #define __must_check __attribute__((__warn_unused_result__))
 #endif
 
+#ifndef __packed
+#define __packed __attribute__((__packed__))
+#endif
+
 #define container_of(ptr, type, member) ({              \
     typeof(((type *)0)->member) *mptr__ = (ptr);        \
     (type *)((char *)mptr__ - offsetof(type, member));  \
@@ -87,4 +91,17 @@
 #define __AC(X, Y)   (X ## Y)
 #define _AC(X, Y)    __AC(X, Y)
 
+#define get_unaligned_t(type, ptr) ({                               \
+    const struct { type x; } __packed *ptr_ = (typeof(ptr_))(ptr);  \
+    ptr_->x;                                                        \
+})
+
+#define put_unaligned_t(type, val, ptr) do {                        \
+    struct { type x; } __packed *ptr_ = (typeof(ptr_))(ptr);        \
+    ptr_->x = val;                                                  \
+} while (0)
+
+#define get_unaligned(ptr)      get_unaligned_t(typeof(*(ptr)), ptr)
+#define put_unaligned(val, ptr) put_unaligned_t(typeof(*(ptr)), val, ptr)
+
 #endif	/* __XEN_TOOLS_COMMON_MACROS__ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 14 22:23:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 14 Feb 2024 22:23:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681194.1059824 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raNei-0005hC-6X; Wed, 14 Feb 2024 22:23:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681194.1059824; Wed, 14 Feb 2024 22:23:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raNei-0005h4-3w; Wed, 14 Feb 2024 22:23:04 +0000
Received: by outflank-mailman (input) for mailman id 681194;
 Wed, 14 Feb 2024 22:23:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNeg-0005gw-No
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:23:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNeg-000691-N0
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:23:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raNeg-0007Kv-Lg
 for xen-changelog@lists.xenproject.org; Wed, 14 Feb 2024 22:23:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=064FgxMVQPNiZYh1mBzfiy54ddyfwwEKqOr+hN4+Sig=; b=q1SJT2wwsYf1L9BzcxKP5fvNMW
	0tNWr0z5Adu71Ap4Ia4X8PDlWqCkPKiyHNV4nNHwFHA/Nwn3fT6zWbBuQmYa7FGhF2dAzV4iz82Xe
	JQOUTsQm9oReuXcA5JvEnlYg6eAgS5t6+K12gfo666OHeqtC+sL0U8wm6+Rtcj5oAXXU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] libxl: Fix comment for LIBXL_HAVE_VMTRACE_BUF_KB
Message-Id: <E1raNeg-0007Kv-Lg@xenbits.xenproject.org>
Date: Wed, 14 Feb 2024 22:23:02 +0000

commit d670c1a38ba3561296f68c0079209365760b3001
Author:     Petr Beneš <w1benny@gmail.com>
AuthorDate: Wed Feb 14 10:56:19 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Feb 14 10:56:19 2024 +0100

    libxl: Fix comment for LIBXL_HAVE_VMTRACE_BUF_KB
    
    It's located in libxl_domain_build_info, not libxl_domain_create_info.
    
    Fixes: 45ba9a7d7688 ("tools/[lib]xl: Add vmtrace_buf_size parameter")
    Signed-off-by: Petr Beneš <w1benny@gmail.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/include/libxl.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/include/libxl.h b/tools/include/libxl.h
index f1652b1664..46bc774126 100644
--- a/tools/include/libxl.h
+++ b/tools/include/libxl.h
@@ -519,7 +519,7 @@
 #define LIBXL_HAVE_PHYSINFO_CAP_VMTRACE 1
 
 /*
- * LIBXL_HAVE_VMTRACE_BUF_KB indicates that libxl_domain_create_info has a
+ * LIBXL_HAVE_VMTRACE_BUF_KB indicates that libxl_domain_build_info has a
  * vmtrace_buf_kb parameter, which allows to enable pre-allocation of
  * processor tracing buffers of given size.
  */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 15 07:11:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 15 Feb 2024 07:11:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681360.1060119 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raVtg-0003Y8-1Y; Thu, 15 Feb 2024 07:11:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681360.1060119; Thu, 15 Feb 2024 07:11:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raVtf-0003Y0-Uz; Thu, 15 Feb 2024 07:11:03 +0000
Received: by outflank-mailman (input) for mailman id 681360;
 Thu, 15 Feb 2024 07:11:01 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raVtd-0003Xm-Tl
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 07:11:01 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raVtd-0007ZY-Si
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 07:11:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raVtd-0003SS-Rh
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 07:11:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=SSg/Et5OHeQEZbiufocakRaycuR5d55K1B49WD7wswk=; b=Glo7tPKFNjC8IeulX1DsXA/Smf
	k6f5QPfZZJ0p/6TK1OrOu5fv9F0XlixHqgc4TwyY24KmDIlyimGHW77kDpdQUlsfjm7psDTNHxB+j
	Q+ay//tQ/A92796oQOq9Y97Ix1VPKcql0TCYUuExqQGerWLo6Hmm5ywDW4M7jXP2IZiQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] iommu/x86: fix IVMD/RMRR range checker loop increment
Message-Id: <E1raVtd-0003SS-Rh@xenbits.xenproject.org>
Date: Thu, 15 Feb 2024 07:11:01 +0000

commit d9bfc2810e1cbe4cd27555bdc48315d36ee91f14
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Wed Feb 14 14:18:06 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Feb 14 14:18:06 2024 +0100

    iommu/x86: fix IVMD/RMRR range checker loop increment
    
    mfn_add() doesn't store the incremented value in the parameter, and instead
    returns it to the caller.  As a result, the loop in iommu_unity_region_ok()
    didn't make progress.  Fix it by storing the incremented value.
    
    Fixes: e45801dea17b ('iommu/x86: introduce a generic IVMD/RMRR range validity helper')
    Coverity-ID: 1592056
    Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/drivers/passthrough/x86/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c
index 1c8cf3271a..a3fa0aef7c 100644
--- a/xen/drivers/passthrough/x86/iommu.c
+++ b/xen/drivers/passthrough/x86/iommu.c
@@ -804,7 +804,7 @@ bool __init iommu_unity_region_ok(const char *prefix, mfn_t start, mfn_t end)
            "%s: [%#" PRI_mfn " ,%#" PRI_mfn "] is not (entirely) in reserved memory\n",
            prefix, mfn_x(start), mfn_x(end));
 
-    for ( addr = start; mfn_x(addr) <= mfn_x(end); mfn_add(addr, 1) )
+    for ( addr = start; mfn_x(addr) <= mfn_x(end); addr = mfn_add(addr, 1) )
     {
         unsigned int type = page_get_ram_type(addr);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 15 12:22:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 15 Feb 2024 12:22:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681667.1060522 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raake-0004xR-Mp; Thu, 15 Feb 2024 12:22:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681667.1060522; Thu, 15 Feb 2024 12:22:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1raake-0004xK-KL; Thu, 15 Feb 2024 12:22:04 +0000
Received: by outflank-mailman (input) for mailman id 681667;
 Thu, 15 Feb 2024 12:22:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raakd-0004xE-QZ
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 12:22:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raakd-0005uj-Ke
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 12:22:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1raakd-0006RX-Jd
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 12:22:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=QxhvCzbZimUUIxgC/phnZcoi5s8ZCMdVRPqpvUOPOVo=; b=EeO0X0Lr/PMukbDBRtXtmvkaG+
	5W6xsyiywMfp/h/UCyoz7GeUP+91SetE5QEcTM5HJZalcJ6HMFIbyKO0j4Bs69r9KdfJt9sFrbq7D
	ZI1jTJWSjgnXthoKmuMjDtVriFJ+DJVAVJYUpT29q9/PngTLt0n9nbrgxdTRo2RtDBSg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] docs: add a best practices coding guide
Message-Id: <E1raakd-0006RX-Jd@xenbits.xenproject.org>
Date: Thu, 15 Feb 2024 12:22:03 +0000

commit c4d6802d33f962a306405a20f4dccdc287990d07
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 8 17:05:15 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu Feb 15 12:11:07 2024 +0000

    docs: add a best practices coding guide
    
    Today the CODING_STYLE contains a section "Handling unexpected
    conditions" specific to the hypervisor. This section is kind of
    misplaced for a coding style. It should rather be part of a "Coding
    best practices" guide.
    
    Add such a guide as docs/process/coding-best-practices.pandoc and
    move the mentioned section from CODING_STYLE to the new file, while
    converting the format to pandoc.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 CODING_STYLE                              | 102 ------------------------------
 docs/process/coding-best-practices.pandoc |  92 +++++++++++++++++++++++++++
 2 files changed, 92 insertions(+), 102 deletions(-)

diff --git a/CODING_STYLE b/CODING_STYLE
index ed13ee2b66..7f6e9ad065 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -167,105 +167,3 @@ the end of files.  It should be:
  * indent-tabs-mode: nil
  * End:
  */
-
-Handling unexpected conditions
-------------------------------
-
-GUIDELINES:
-
-Passing errors up the stack should be used when the caller is already
-expecting to handle errors, and the state when the error was
-discovered isn’t broken, or isn't too hard to fix.
-
-domain_crash() should be used when passing errors up the stack is too
-difficult, and/or when fixing up state of a guest is impractical, but
-where fixing up the state of Xen will allow Xen to continue running.
-This is particularly appropriate when the guest is exhibiting behavior
-well-behaved guests shouldn't.
-
-BUG_ON() should be used when you can’t pass errors up the stack, and
-either continuing or crashing the guest would likely cause an
-information leak or privilege escalation vulnerability.
-
-ASSERT() IS NOT AN ERROR HANDLING MECHANISM.  ASSERT is a way to move
-detection of a bug earlier in the programming cycle; it is a
-more-noticeable printk.  It should only be added after one of the
-other three error-handling mechanisms has been evaluated for
-reliability and security.
-
-RATIONALE:
-
-It's frequently the case that code is written with the assumption that
-certain conditions can never happen.  There are several possible
-actions programmers can take in these situations:
-
-* Programmers can simply not handle those cases in any way, other than
-perhaps to write a comment documenting what the assumption is.
-
-* Programmers can try to handle the case gracefully -- fixing up
-in-progress state and returning an error to the user.
-
-* Programmers can crash the guest.
-
-* Programmers can use ASSERT(), which will cause the check to be
-executed in DEBUG builds, and cause the hypervisor to crash if it's
-violated
-
-* Programmers can use BUG_ON(), which will cause the check to be
-executed in both DEBUG and non-DEBUG builds, and cause the hypervisor
-to crash if it's violated.
-
-In selecting which response to use, we want to achieve several goals:
-
-- To minimize risk of introducing security vulnerabilities,
-  particularly as the code evolves over time
-
-- To efficiently spend programmer time
-
-- To detect violations of assumptions as early as possible
-
-- To minimize the impact of bugs on production use cases
-
-The guidelines above attempt to balance these:
-
-- When the caller is expecting to handle errors, and there is no
-broken state at the time the unexpected condition is discovered, or
-when fixing the state is straightforward, then fixing up the state and
-returning an error is the most robust thing to do.  However, if the
-caller isn't expecting to handle errors, or if the state is difficult
-to fix, then returning an error may require extensive refactoring,
-which is not a good use of programmer time when they're certain that
-this condition cannot occur.
-
-- BUG_ON() will stop all hypervisor action immediately.  In situations
-where continuing might allow an attacker to escalate privilege, a
-BUG_ON() can change a privilege escalation or information leak into a
-denial-of-service (an improvement).  But in situations where
-continuing (say, returning an error) might be safe, then BUG_ON() can
-change a benign failure into denial-of-service (a degradation).
-
-- domain_crash() is similar to BUG_ON(), but with a more limited
-effect: it stops that domain immediately.  In situations where
-continuing might cause guest or hypervisor corruption, but destroying
-the guest allows the hypervisor to continue, this can change a more
-serious bug into a guest denial-of-service.  But in situations where
-returning an error might be safe, then domain_crash() can change a
-benign failure into a guest denial-of-service.
-
-- ASSERT() will stop the hypervisor during development, but allow
-hypervisor action to continue during production.  In situations where
-continuing will at worst result in a denial-of-service, and at best
-may have little effect other than perhaps quirky behavior, using an
-ASSERT() will allow violation of assumptions to be detected as soon as
-possible, while not causing undue degradation in production
-hypervisors.  However, in situations where continuing could cause
-privilege escalation or information leaks, using an ASSERT() can
-introduce security vulnerabilities.
-
-Note however that domain_crash() has its own traps: callers far up the
-call stack may not realize that the domain is now dying as a result of
-an innocuous-looking operation, particularly if somewhere on the
-callstack between the initial function call and the failure, no error
-is returned.  Using domain_crash() requires careful inspection and
-documentation of the code to make sure all callers at the stack handle
-a newly-dead domain gracefully.
diff --git a/docs/process/coding-best-practices.pandoc b/docs/process/coding-best-practices.pandoc
new file mode 100644
index 0000000000..f611aa9a55
--- /dev/null
+++ b/docs/process/coding-best-practices.pandoc
@@ -0,0 +1,92 @@
+# Best Practices in the Hypervisor
+
+## Handling unexpected conditions
+
+### Guidelines
+
+Passing errors up the stack should be used when the caller is already
+expecting to handle errors, and the state when the error was
+discovered isn’t broken, or isn't too hard to fix.
+
+domain_crash() should be used when passing errors up the stack is too
+difficult, and/or when fixing up state of a guest is impractical, but
+where fixing up the state of Xen will allow Xen to continue running.
+This is particularly appropriate when the guest is exhibiting behavior
+well-behaved guests shouldn't.
+
+BUG_ON() should be used when you can’t pass errors up the stack, and
+either continuing or crashing the guest would likely cause an
+information leak or privilege escalation vulnerability.
+
+ASSERT() IS NOT AN ERROR HANDLING MECHANISM.  ASSERT is a way to move
+detection of a bug earlier in the programming cycle; it is a
+more-noticeable printk.  It should only be added after one of the
+other three error-handling mechanisms has been evaluated for
+reliability and security.
+
+### Rationale
+
+It's frequently the case that code is written with the assumption that
+certain conditions can never happen.  There are several possible
+actions programmers can take in these situations:
+
+ * Programmers can simply not handle those cases in any way, other than
+   perhaps to write a comment documenting what the assumption is.
+ * Programmers can try to handle the case gracefully -- fixing up
+   in-progress state and returning an error to the user.
+ * Programmers can crash the guest.
+ * Programmers can use ASSERT(), which will cause the check to be
+   executed in DEBUG builds, and cause the hypervisor to crash if it's
+   violated
+ * Programmers can use BUG_ON(), which will cause the check to be
+   executed in both DEBUG and non-DEBUG builds, and cause the hypervisor
+   to crash if it's violated.
+
+In selecting which response to use, we want to achieve several goals:
+
+ * To minimize risk of introducing security vulnerabilities,
+   particularly as the code evolves over time
+ * To efficiently spend programmer time
+ * To detect violations of assumptions as early as possible
+ * To minimize the impact of bugs on production use cases
+
+The guidelines above attempt to balance these:
+
+ * When the caller is expecting to handle errors, and there is no
+   broken state at the time the unexpected condition is discovered, or
+   when fixing the state is straightforward, then fixing up the state and
+   returning an error is the most robust thing to do.  However, if the
+   caller isn't expecting to handle errors, or if the state is difficult
+   to fix, then returning an error may require extensive refactoring,
+   which is not a good use of programmer time when they're certain that
+   this condition cannot occur.
+ * BUG_ON() will stop all hypervisor action immediately.  In situations
+   where continuing might allow an attacker to escalate privilege, a
+   BUG_ON() can change a privilege escalation or information leak into a
+   denial-of-service (an improvement).  But in situations where
+   continuing (say, returning an error) might be safe, then BUG_ON() can
+   change a benign failure into denial-of-service (a degradation).
+ * domain_crash() is similar to BUG_ON(), but with a more limited
+   effect: it stops that domain immediately.  In situations where
+   continuing might cause guest or hypervisor corruption, but destroying
+   the guest allows the hypervisor to continue, this can change a more
+   serious bug into a guest denial-of-service.  But in situations where
+   returning an error might be safe, then domain_crash() can change a
+   benign failure into a guest denial-of-service.
+ * ASSERT() will stop the hypervisor during development, but allow
+   hypervisor action to continue during production.  In situations where
+   continuing will at worst result in a denial-of-service, and at best
+   may have little effect other than perhaps quirky behavior, using an
+   ASSERT() will allow violation of assumptions to be detected as soon as
+   possible, while not causing undue degradation in production
+   hypervisors.  However, in situations where continuing could cause
+   privilege escalation or information leaks, using an ASSERT() can
+   introduce security vulnerabilities.
+
+Note however that domain_crash() has its own traps: callers far up the
+call stack may not realize that the domain is now dying as a result of
+an innocuous-looking operation, particularly if somewhere on the
+callstack between the initial function call and the failure, no error
+is returned.  Using domain_crash() requires careful inspection and
+documentation of the code to make sure all callers at the stack handle
+a newly-dead domain gracefully.
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 15 18:00:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 15 Feb 2024 18:00:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681970.1060987 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag1l-0000SQ-IG; Thu, 15 Feb 2024 18:00:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681970.1060987; Thu, 15 Feb 2024 18:00:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag1l-0000S4-FC; Thu, 15 Feb 2024 18:00:05 +0000
Received: by outflank-mailman (input) for mailman id 681970;
 Thu, 15 Feb 2024 18:00:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag1k-0000Dl-CG
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag1k-0004oQ-4t
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag1k-0005mb-1X
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=0uDWYrlX844k3w+HAJ1GfOZQZVI1qBwecVywTQdaNvM=; b=tTKp+0TrpUwlHIHnQRt69ry2dk
	1/EJKVSbPncxJv1MgF+1PlNbR4n5JTtSEwMC1jpkwPlCU/gfaWAaetOIGsGls7JuRDvdt9yjTyIUO
	sD0Rmjgn+vBe80nDQ12dSllcYD6S7ocZjtYHEpV+xvjjrGZ4iLjayA5gK8jsrZtBSWEc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools: add a new xen 9pfs daemon
Message-Id: <E1rag1k-0005mb-1X@xenbits.xenproject.org>
Date: Thu, 15 Feb 2024 18:00:04 +0000

commit c3e583b01bd0652af8aed62b2d7dac1d3d57b065
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:49 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools: add a new xen 9pfs daemon
    
    Add "xen-9pfsd", a new 9pfs daemon meant to support infrastructure
    domains (e.g. xenstore-stubdom) to access files in dom0.
    
    For now only add the code needed for starting the daemon and
    registering it with Xenstore via a new "libxl/xen-9pfs/state" node by
    writing the "running" state to it.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/9pfsd/.gitignore  |   1 +
 tools/9pfsd/Makefile    |  38 +++++++++++++
 tools/9pfsd/xen-9pfsd.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++++
 tools/Makefile          |   1 +
 4 files changed, 187 insertions(+)

diff --git a/tools/9pfsd/.gitignore b/tools/9pfsd/.gitignore
new file mode 100644
index 0000000000..d0c2d223ef
--- /dev/null
+++ b/tools/9pfsd/.gitignore
@@ -0,0 +1 @@
+/xen-9pfsd
diff --git a/tools/9pfsd/Makefile b/tools/9pfsd/Makefile
new file mode 100644
index 0000000000..089cf5ae24
--- /dev/null
+++ b/tools/9pfsd/Makefile
@@ -0,0 +1,38 @@
+#
+# tools/9pfsd/Makefile
+#
+
+XEN_ROOT = $(CURDIR)/../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+CFLAGS += $(PTHREAD_CFLAGS)
+LDFLAGS += $(PTHREAD_LDFLAGS)
+
+TARGETS := xen-9pfsd
+
+XEN-9PFSD_OBJS = xen-9pfsd.o
+$(XEN-9PFSD_OBJS): CFLAGS += $(CFLAGS_libxenstore)
+$(XEN-9PFSD_OBJS): CFLAGS += $(CFLAGS_libxenevtchn)
+$(XEN-9PFSD_OBJS): CFLAGS += $(CFLAGS_libxengnttab)
+xen-9pfsd: LDLIBS += $(call xenlibs-ldlibs,store evtchn gnttab)
+
+.PHONY: all
+all: $(TARGETS)
+
+xen-9pfsd: $(XEN-9PFSD_OBJS)
+	$(CC) $(LDFLAGS) -o $@ $(XEN-9PFSD_OBJS) $(LDLIBS) $(APPEND_LDFLAGS)
+
+.PHONY: install
+install: all
+	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
+	for i in $(TARGETS); do $(INSTALL_PROG) $$i $(DESTDIR)$(LIBEXEC_BIN); done
+
+.PHONY: uninstall
+uninstall:
+	for i in $(TARGETS); do rm -f $(DESTDIR)$(LIBEXEC_BIN)/$$i; done
+
+.PHONY: clean
+clean:
+	$(RM) *.o $(TARGETS) $(DEPS_RM)
+
+distclean: clean
diff --git a/tools/9pfsd/xen-9pfsd.c b/tools/9pfsd/xen-9pfsd.c
new file mode 100644
index 0000000000..6939d01574
--- /dev/null
+++ b/tools/9pfsd/xen-9pfsd.c
@@ -0,0 +1,147 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+/*
+ * xen-9pfsd - Xen 9pfs daemon
+ *
+ * Copyright (C) 2024 Juergen Gross <jgross@suse.com>
+ *
+ * Daemon to enable guests to access a directory of the dom0 file system.
+ * Access is made via the 9pfs protocol (xen-9pfsd acts as a PV 9pfs backend).
+ *
+ * Usage: xen-9pfsd
+ *
+ * xen-9pfsd does NOT support writing any links (neither soft links nor hard
+ * links), and it is accepting only canonicalized file paths in order to
+ * avoid the possibility to "escape" from the guest specific directory.
+ *
+ * The backend device string is "xen_9pfs", the tag used for mounting the
+ * 9pfs device is "Xen".
+ *
+ * As an additional security measure the maximum file space used by the guest
+ * can be limited by the backend Xenstore node "max-size" specifying the size
+ * in MBytes. This size includes the size of the root directory of the guest.
+ */
+
+#include <err.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <xenevtchn.h>
+#include <xengnttab.h>
+#include <xenstore.h>
+
+static volatile bool stop_me;
+static bool daemon_running;
+static struct xs_handle *xs;
+static xengnttab_handle *xg;
+static xenevtchn_handle *xe;
+
+static void handle_stop(int sig)
+{
+    stop_me = true;
+}
+
+static void close_all(void)
+{
+    if ( daemon_running )
+        xs_rm(xs, XBT_NULL, "libxl/xen-9pfs");
+    if ( xe )
+        xenevtchn_close(xe);
+    if ( xg )
+        xengnttab_close(xg);
+    if ( xs )
+        xs_close(xs);
+    closelog();
+}
+
+static void do_err(const char *msg)
+{
+    syslog(LOG_ALERT, "%s, errno = %d, %s", msg, errno, strerror(errno));
+    close_all();
+    exit(1);
+}
+
+static void xen_connect(void)
+{
+    xs_transaction_t t;
+    char *val;
+    unsigned int len;
+
+    xs = xs_open(0);
+    if ( xs == NULL )
+        do_err("xs_open() failed");
+
+    xg = xengnttab_open(NULL, 0);
+    if ( xg == NULL )
+        do_err("xengnttab_open() failed");
+
+    xe = xenevtchn_open(NULL, 0);
+    if ( xe == NULL )
+        do_err("xenevtchn_open() failed");
+
+    while ( true )
+    {
+        t = xs_transaction_start(xs);
+        if ( t == XBT_NULL )
+            do_err("xs_transaction_start() failed");
+
+        val = xs_read(xs, t, "libxl/xen-9pfs/state", &len);
+        if ( val )
+        {
+            free(val);
+            xs_transaction_end(xs, t, true);
+            syslog(LOG_INFO, "daemon already running");
+            close_all();
+            exit(0);
+        }
+
+        if ( !xs_write(xs, t, "libxl/xen-9pfs/state", "running",
+                       strlen("running")) )
+        {
+            xs_transaction_end(xs, t, true);
+            do_err("xs_write() failed writing state");
+        }
+
+        if ( xs_transaction_end(xs, t, false) )
+            break;
+        if ( errno != EAGAIN )
+            do_err("xs_transaction_end() failed");
+    }
+
+    daemon_running = true;
+}
+
+int main(int argc, char *argv[])
+{
+    struct sigaction act = { .sa_handler = handle_stop, };
+    int syslog_mask = LOG_MASK(LOG_WARNING) | LOG_MASK(LOG_ERR) |
+                      LOG_MASK(LOG_CRIT) | LOG_MASK(LOG_ALERT) |
+                      LOG_MASK(LOG_EMERG);
+
+    umask(027);
+    if ( getenv("XEN_9PFSD_VERBOSE") )
+        syslog_mask |= LOG_MASK(LOG_NOTICE) | LOG_MASK(LOG_INFO);
+    openlog("xen-9pfsd", LOG_CONS, LOG_DAEMON);
+    setlogmask(syslog_mask);
+
+    sigemptyset(&act.sa_mask);
+    sigaction(SIGHUP, &act, NULL);
+
+    xen_connect();
+
+    while ( !stop_me )
+    {
+        sleep(60);
+    }
+
+    close_all();
+
+    return 0;
+}
diff --git a/tools/Makefile b/tools/Makefile
index 3a510663a0..7d17211782 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -32,6 +32,7 @@ SUBDIRS-y += xenpmd
 SUBDIRS-$(CONFIG_GOLANG) += golang
 SUBDIRS-y += xl
 SUBDIRS-y += helpers
+SUBDIRS-y += 9pfsd
 SUBDIRS-$(CONFIG_X86) += xenpaging
 SUBDIRS-$(CONFIG_X86) += debugger
 SUBDIRS-$(CONFIG_TESTS) += tests
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 15 18:00:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 15 Feb 2024 18:00:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681971.1060991 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag1v-0000e8-Ji; Thu, 15 Feb 2024 18:00:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681971.1060991; Thu, 15 Feb 2024 18:00:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag1v-0000e0-Gf; Thu, 15 Feb 2024 18:00:15 +0000
Received: by outflank-mailman (input) for mailman id 681971;
 Thu, 15 Feb 2024 18:00:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag1u-0000do-DM
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag1u-0004ow-C1
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag1u-0005nr-74
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=uxybwU4sMU6xELtMVR444UaPUDgzPxL6v2MfgPpsS1o=; b=w+pe4r07dw8va9Xp4aYSgoC1AZ
	X8CzWgl/tj5ERgDZImT/d7Z1xu/8UTSCNhbmbY/NTu2LZNSZUEB6NP5XFh0DHgkd9VmFy4isv8HuK
	wnN8bX8KVnZS0RH+JYWooauZhfQZJBkHUb/vBpcpWKMKZee4pJBhBKhDSCikonTunKOQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xen-9pfsd: connect to frontend
Message-Id: <E1rag1u-0005nr-74@xenbits.xenproject.org>
Date: Thu, 15 Feb 2024 18:00:14 +0000

commit d43c72a7850df3aaff48b924f471905076a7cc42
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:50 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: connect to frontend
    
    Add the code for connecting to frontends to xenlogd.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/Makefile    |   2 +-
 tools/9pfsd/io.c        |  45 ++++
 tools/9pfsd/xen-9pfsd.c | 653 +++++++++++++++++++++++++++++++++++++++++++++++-
 tools/9pfsd/xen-9pfsd.h |  61 +++++
 4 files changed, 757 insertions(+), 4 deletions(-)

diff --git a/tools/9pfsd/Makefile b/tools/9pfsd/Makefile
index 089cf5ae24..50573121ed 100644
--- a/tools/9pfsd/Makefile
+++ b/tools/9pfsd/Makefile
@@ -10,7 +10,7 @@ LDFLAGS += $(PTHREAD_LDFLAGS)
 
 TARGETS := xen-9pfsd
 
-XEN-9PFSD_OBJS = xen-9pfsd.o
+XEN-9PFSD_OBJS = xen-9pfsd.o io.o
 $(XEN-9PFSD_OBJS): CFLAGS += $(CFLAGS_libxenstore)
 $(XEN-9PFSD_OBJS): CFLAGS += $(CFLAGS_libxenevtchn)
 $(XEN-9PFSD_OBJS): CFLAGS += $(CFLAGS_libxengnttab)
diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
new file mode 100644
index 0000000000..eb7c136e09
--- /dev/null
+++ b/tools/9pfsd/io.c
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+/*
+ * xen-9pfsd - Xen 9pfs daemon
+ *
+ * Copyright (C) 2024 Juergen Gross <jgross@suse.com>
+ *
+ * I/O thread handling.
+ */
+
+#include <stdbool.h>
+#include <string.h>
+#include <syslog.h>
+
+#include "xen-9pfsd.h"
+
+static bool io_work_pending(struct ring *ring)
+{
+    if ( ring->stop_thread )
+        return true;
+    return false;
+}
+
+void *io_thread(void *arg)
+{
+    struct ring *ring = arg;
+
+    while ( !ring->stop_thread )
+    {
+        pthread_mutex_lock(&ring->mutex);
+        if ( !io_work_pending(ring) )
+        {
+            if ( xenevtchn_unmask(xe, ring->evtchn) < 0 )
+                syslog(LOG_WARNING, "xenevtchn_unmask() failed");
+            pthread_cond_wait(&ring->cond, &ring->mutex);
+        }
+        pthread_mutex_unlock(&ring->mutex);
+
+        /* TODO: I/O handling. */
+    }
+
+    ring->thread_active = false;
+
+    return NULL;
+}
diff --git a/tools/9pfsd/xen-9pfsd.c b/tools/9pfsd/xen-9pfsd.c
index 6939d01574..73b6c3a30e 100644
--- a/tools/9pfsd/xen-9pfsd.c
+++ b/tools/9pfsd/xen-9pfsd.c
@@ -24,34 +24,632 @@
 
 #include <err.h>
 #include <errno.h>
+#include <fcntl.h>
+#include <poll.h>
+#include <pthread.h>
 #include <signal.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <syslog.h>
+#include <sys/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <xenevtchn.h>
 #include <xengnttab.h>
 #include <xenstore.h>
 
+#include "xen-9pfsd.h"
+
+/*
+ * List of currently known devices.
+ * The list itself is modified only in the main thread. When a device is being
+ * removed its memory needs to be freed after the I/O thread (if existing)
+ * has stopped.
+ */
+static XEN_TAILQ_HEAD(devhead, device) devs = XEN_TAILQ_HEAD_INITIALIZER(devs);
+
+struct path {
+    char path[100];
+};
+
 static volatile bool stop_me;
 static bool daemon_running;
 static struct xs_handle *xs;
 static xengnttab_handle *xg;
-static xenevtchn_handle *xe;
+static unsigned int now;
+
+xenevtchn_handle *xe;
 
 static void handle_stop(int sig)
 {
     stop_me = true;
 }
 
+static int check_host_path(device *device)
+{
+    struct stat statbuf;
+    char *path, *p;
+    int ret = 1;
+
+    if ( !device->host_path )
+        return 1;
+
+    /* Path must be absolute. */
+    if ( device->host_path[0] != '/' )
+        return 1;
+
+    /* No double "/". */
+    if ( strstr(device->host_path, "//") )
+        return 1;
+
+    /* No trailing "/" (includes refusing to share "/"). */
+    if ( device->host_path[strlen(device->host_path) - 1] == '/' )
+        return 1;
+
+    path = strdup(device->host_path);
+    if ( !path )
+    {
+        syslog(LOG_CRIT, "memory allocation failure!");
+        return 1;
+    }
+
+    for ( p = path; p; )
+    {
+        p = strchr(p + 1, '/');
+        if ( p )
+            *p = 0;
+        if ( !stat(path, &statbuf) )
+        {
+            if ( !(statbuf.st_mode & S_IFDIR) )
+                break;
+            if ( !p )
+            {
+                ret = 0;
+                break;
+            }
+            *p = '/';
+            continue;
+        }
+        if ( mkdir(path, 0777) )
+            break;
+        if ( p )
+            *p = '/';
+    }
+
+    free(path);
+    return ret;
+}
+
+static void construct_frontend_path(device *device, const char *node,
+                                    struct path *p)
+{
+    snprintf(p->path, sizeof(p->path), "/local/domain/%u/device/9pfs/%u/%s",
+             device->domid, device->devid, node);
+}
+
+static void construct_backend_path(device *device, const char *node,
+                                   struct path *p)
+{
+    snprintf(p->path, sizeof(p->path), "backend/xen_9pfs/%u/%u/%s",
+             device->domid, device->devid, node);
+}
+
+static char *read_backend_node(device *device, const char *node)
+{
+    struct path p;
+    char *val;
+    unsigned int len;
+
+    construct_backend_path(device, node, &p);
+    val = xs_read(xs, XBT_NULL, p.path, &len);
+
+    return val;
+}
+
+static unsigned int uint_from_string(char *string, unsigned int def)
+{
+    unsigned long val;
+    char *end;
+
+    if ( !string )
+        return def;
+
+    val = strtoul(string, &end, 10);
+    if ( *end || val > UINT_MAX )
+        val = def;
+    free(string);
+
+    return val;
+}
+
+static unsigned int read_backend_node_uint(device *device, const char *node,
+                                           unsigned int def)
+{
+    return uint_from_string(read_backend_node(device, node), def);
+}
+
+static unsigned int read_frontend_node_uint(device *device, const char *node,
+                                            unsigned int def)
+{
+    struct path p;
+    unsigned int len;
+
+    construct_frontend_path(device, node, &p);
+
+    return uint_from_string(xs_read(xs, XBT_NULL, p.path, &len), def);
+}
+
+static bool write_backend_node(device *device, const char *node,
+                               const char *val)
+{
+    struct path p;
+    unsigned int num_perms;
+    struct xs_permissions *old_perms;
+    struct xs_permissions perms[2] = {
+        { .id = 0, .perms = XS_PERM_NONE },
+        { .id = device->domid, .perms = XS_PERM_READ }
+    };
+
+    construct_backend_path(device, node, &p);
+    if ( !xs_write(xs, XBT_NULL, p.path, val, strlen(val)) )
+    {
+        syslog(LOG_ERR, "error writing bacḱend node \"%s\" for device %u/%u",
+               node, device->domid, device->devid);
+        return false;
+    }
+
+    old_perms = xs_get_permissions(xs, XBT_NULL, p.path, &num_perms);
+    if ( !old_perms )
+    {
+        syslog(LOG_ERR, "error getting permissions for \"%s\"", p.path);
+        return false;
+    }
+
+    perms[0] = old_perms[0];
+    free(old_perms);
+    if ( !xs_set_permissions(xs, XBT_NULL, p.path, perms, 2) )
+    {
+        syslog(LOG_ERR, "error setting permissions for \"%s\"", p.path);
+        return false;
+    }
+
+    return true;
+}
+
+static bool write_backend_node_uint(device *device, const char *node,
+                                   unsigned int val)
+{
+    char str[12];
+
+    snprintf(str, sizeof(str), "%u", val);
+
+    return write_backend_node(device, node, str);
+}
+
+static bool write_backend_state(device *device, enum xenbus_state state)
+{
+    struct path p;
+    char val[2];
+
+    snprintf(val, sizeof(val), "%u", state);
+    construct_backend_path(device, "state", &p);
+    if ( !xs_write(xs, XBT_NULL, p.path, val, 1) )
+    {
+        syslog(LOG_ERR, "error writing backend state %u for device %u/%u",
+               state, device->domid, device->devid);
+        return false;
+    }
+
+    device->backend_state = state;
+
+    return true;
+}
+
+static device *find_device(unsigned int domid, unsigned int devid)
+{
+    device *device;
+
+    XEN_TAILQ_FOREACH( device, &devs, list )
+    {
+        if ( domid == device->domid && devid == device->devid )
+            return device;
+    }
+
+    return NULL;
+}
+
+static void free_device(device *device)
+{
+    char token[20];
+    struct path p;
+
+    construct_frontend_path(device, "state", &p);
+    snprintf(token, sizeof(token), "%u/%u", device->domid, device->devid);
+    xs_unwatch(xs, p.path, token);
+
+    if ( device->root_fd >= 0 )
+        close(device->root_fd);
+
+    free(device->host_path);
+    free(device);
+}
+
+static device *new_device(unsigned int domid, unsigned int devid)
+{
+    device *device;
+    char token[20];
+    struct path p;
+    char *val;
+
+    device = calloc(1, sizeof(*device));
+    if ( !device )
+    {
+        syslog(LOG_CRIT, "Got no memory for new device %u/%u", domid, devid);
+        return NULL;
+    }
+
+    device->domid = domid;
+    device->devid = devid;
+    device->root_fd = -1;
+
+    construct_frontend_path(device, "state", &p);
+    snprintf(token, sizeof(token), "%u/%u", domid, devid);
+    if ( !xs_watch(xs, p.path, token) )
+    {
+        syslog(LOG_ERR, "Setting up watch for device %u/%u failed",
+               domid, devid);
+        free(device);
+        return NULL;
+    }
+
+    val = read_backend_node(device, "security_model");
+    if ( !val || strcmp(val, "none") )
+    {
+        syslog(LOG_ERR, "Security model \"%s\" for device %u/%u invalid.",
+               val, domid, devid);
+        free(val);
+        goto err;
+    }
+    free(val);
+
+    device->max_space = read_backend_node_uint(device, "max-space", 0);
+    device->max_files = read_backend_node_uint(device, "max-files", 0);
+    device->max_open_files =
+        read_backend_node_uint(device, "max-open-files", 0)
+        ?: MAX_OPEN_FILES_DEFAULT;
+    device->auto_delete = read_backend_node_uint(device, "auto-delete", 0);
+
+    device->host_path = read_backend_node(device, "path");
+    if ( check_host_path(device) )
+    {
+        syslog(LOG_ERR, "Host path \"%s\" for device %u/%u invalid.",
+               device->host_path, domid, devid);
+        goto err;
+    }
+    device->root_fd = open(device->host_path, O_RDONLY | O_DIRECTORY);
+    if ( device->root_fd < 0 )
+        goto err;
+
+    if ( !write_backend_node(device, "versions", "1") )
+        goto err;
+    if ( !write_backend_node_uint(device, "max-rings", MAX_RINGS) )
+        goto err;
+    if ( !write_backend_node_uint(device, "max-ring-page-order",
+                                 MAX_RING_ORDER) )
+        goto err;
+
+    if ( !write_backend_state(device, XenbusStateInitWait) )
+        goto err;
+
+    XEN_TAILQ_INSERT_TAIL(&devs, device, list);
+    syslog(LOG_INFO, "New device %u/%u added", domid, devid);
+
+    return device;
+
+ err:
+    free_device(device);
+    return NULL;
+}
+
+static void disconnect_ring(struct ring *ring)
+{
+    if ( !ring )
+        return;
+
+    if ( ring->thread_active )
+    {
+        ring->stop_thread = true;
+        pthread_cond_signal(&ring->cond);
+        pthread_join(ring->thread, NULL);
+        ring->stop_thread = false;
+    }
+
+    if ( ring->data.in )
+    {
+        xengnttab_unmap(xg, ring->data.in, 1 << ring->ring_order);
+        ring->data.in = NULL;
+    }
+    if ( ring->intf )
+    {
+        xengnttab_unmap(xg, ring->intf, 1 );
+        ring->intf = NULL;
+    }
+
+    if ( ring->evtchn )
+    {
+        xenevtchn_unbind(xe, ring->evtchn);
+        ring->evtchn = 0;
+    }
+
+    pthread_mutex_destroy(&ring->mutex);
+    pthread_cond_destroy(&ring->cond);
+}
+
+static void disconnect_guest(device *device)
+{
+    unsigned int ring_idx;
+
+    for ( ring_idx = 0; ring_idx < device->num_rings; ring_idx++ )
+    {
+        disconnect_ring(device->ring[ring_idx]);
+        free(device->ring[ring_idx]);
+        device->ring[ring_idx] = NULL;
+    }
+
+    device->num_rings = 0;
+}
+
+static void close_device(device *device, enum xenbus_state state)
+{
+    disconnect_guest(device);
+    write_backend_state(device, state);
+}
+
+static void connect_err(device *device, const char *msg)
+{
+    syslog(LOG_WARNING, "%s", msg);
+    close_device(device, XenbusStateClosed);
+}
+
+static void connect_device(device *device)
+{
+    unsigned int val;
+    unsigned int ring_idx;
+    char node[20];
+    struct ring *ring;
+    xenevtchn_port_or_error_t evtchn;
+
+    val = read_frontend_node_uint(device, "version", 0);
+    if ( val != 1 )
+        return connect_err(device, "frontend specifies illegal version");
+    device->num_rings = read_frontend_node_uint(device, "num-rings", 0);
+    if ( device->num_rings < 1 || device->num_rings > MAX_RINGS )
+        return connect_err(device, "frontend specifies illegal ring number");
+
+    for ( ring_idx = 0; ring_idx < device->num_rings; ring_idx++ )
+    {
+        ring = calloc(1, sizeof(*ring));
+        if ( !ring )
+            return connect_err(device, "could not allocate ring memory");
+        device->ring[ring_idx] = ring;
+        ring->device = device;
+        pthread_cond_init(&ring->cond, NULL);
+        pthread_mutex_init(&ring->mutex, NULL);
+
+        snprintf(node, sizeof(node), "event-channel-%u", ring_idx);
+        val = read_frontend_node_uint(device, node, 0);
+        if ( val == 0 )
+            return connect_err(device, "frontend specifies illegal evtchn");
+        evtchn = xenevtchn_bind_interdomain(xe, device->domid, val);
+        if ( evtchn < 0 )
+            return connect_err(device, "could not bind to event channel");
+        ring->evtchn = evtchn;
+
+        snprintf(node, sizeof(node), "ring-ref%u", ring_idx);
+        val = read_frontend_node_uint(device, node, 0);
+        if ( val == 0 )
+            return connect_err(device,
+                               "frontend specifies illegal grant for ring");
+        ring->intf = xengnttab_map_grant_ref(xg, device->domid, val,
+                                             PROT_READ | PROT_WRITE);
+        if ( !ring->intf )
+            return connect_err(device, "could not map interface page");
+        ring->ring_order = ring->intf->ring_order;
+        if ( ring->ring_order > MAX_RING_ORDER || ring->ring_order < 1 )
+            return connect_err(device, "frontend specifies illegal ring order");
+        ring->ring_size = XEN_FLEX_RING_SIZE(ring->ring_order);
+        ring->data.in = xengnttab_map_domain_grant_refs(xg,
+                                                        1 << ring->ring_order,
+                                                        device->domid,
+                                                        ring->intf->ref,
+                                                        PROT_READ | PROT_WRITE);
+        if ( !ring->data.in )
+            return connect_err(device, "could not map ring pages");
+        ring->data.out = ring->data.in + ring->ring_size;
+
+        if ( pthread_create(&ring->thread, NULL, io_thread, ring) )
+            return connect_err(device, "could not start I/O thread");
+        ring->thread_active = true;
+    }
+
+    write_backend_state(device, XenbusStateConnected);
+}
+
+static void remove_device(device *device)
+{
+    XEN_TAILQ_REMOVE(&devs, device, list);
+
+    disconnect_guest(device);
+    free_device(device);
+}
+
+static void remove_all_devices(void)
+{
+    device *device, *tmp;
+
+    XEN_TAILQ_FOREACH_SAFE( device, &devs, list, tmp )
+        remove_device(device);
+}
+
+static void frontend_changed(device *device)
+{
+    struct path p;
+    char *state, *end;
+    unsigned int len;
+    unsigned long new_state;
+
+    construct_frontend_path(device, "state", &p);
+    state = xs_read(xs, XBT_NULL, p.path, &len);
+    if ( !state )
+    {
+        close_device(device, XenbusStateClosed);
+        return;
+    }
+
+    new_state = strtoul(state, &end, 10);
+    if ( *end || new_state > XenbusStateReconfigured )
+    {
+        syslog(LOG_WARNING, "unknown state \"%s\" seen for device %u/%u", state,
+               device->domid, device->devid);
+        new_state = XenbusStateUnknown;
+    }
+    free(state);
+
+    if ( new_state == device->frontend_state )
+        return;
+
+    switch ( new_state )
+    {
+    case XenbusStateInitialising:
+        break;
+
+    case XenbusStateInitialised:
+        connect_device(device);
+        break;
+
+    case XenbusStateConnected:
+        break;
+
+    case XenbusStateClosing:
+        close_device(device, XenbusStateClosing);
+        break;
+
+    case XenbusStateClosed:
+        close_device(device, XenbusStateClosed);
+        break;
+
+    default:
+        syslog(LOG_WARNING, "not handled frontend state %lu for device %u/%u",
+               new_state, device->domid, device->devid);
+        break;
+    }
+
+    device->frontend_state = new_state;
+}
+
+static void check_device(unsigned int domid, unsigned int devid)
+{
+    device *device;
+
+    device = find_device(domid, devid);
+    if ( !device )
+    {
+        device = new_device(domid, devid);
+        if ( !device )
+            return;
+    }
+
+    device->last_seen = now;
+}
+
+static void scan_backend(void)
+{
+    char **doms;
+    unsigned int n_doms, dom;
+    char **devices;
+    unsigned int n_devs, dev;
+    char dom_path[24];
+    unsigned long domid, devid;
+    char *end;
+    device *device, *tmp;
+
+    now++;
+
+    doms = xs_directory(xs, XBT_NULL, "backend/xen_9pfs", &n_doms);
+    if ( doms == NULL )
+        return;
+
+    for ( dom = 0; dom < n_doms; dom++ )
+    {
+        errno = 0;
+        domid = strtoul(doms[dom], &end, 10);
+        if ( errno || *end || domid >= DOMID_FIRST_RESERVED )
+            continue;
+
+        snprintf(dom_path, sizeof(dom_path), "backend/xen_9pfs/%lu", domid);
+        devices = xs_directory(xs, XBT_NULL, dom_path, &n_devs);
+
+        for ( dev = 0; dev < n_devs; dev++ )
+        {
+            errno = 0;
+            devid = strtoul(devices[dev], &end, 10);
+            if ( errno || *end || devid > UINT_MAX )
+                continue;
+
+            check_device(domid, devid);
+        }
+
+        free(devices);
+    }
+
+    free(doms);
+
+    XEN_TAILQ_FOREACH_SAFE( device, &devs, list, tmp )
+    {
+        if ( device->last_seen != now )
+            remove_device(device);
+    }
+}
+
+static void handle_watch(char *path, char *token)
+{
+    unsigned int domid, devid;
+    device *device;
+
+    if ( !strcmp(token, "main") )
+    {
+        scan_backend();
+        return;
+    }
+
+    if ( sscanf(token, "%u/%u", &domid, &devid) != 2 )
+    {
+        syslog(LOG_WARNING, "unknown watch event %s %s", path, token);
+        return;
+    }
+
+    device = find_device(domid, devid);
+    if ( !device )
+    {
+        syslog(LOG_WARNING, "watch event for unknown device %u/%u",
+               domid, devid);
+        return;
+    }
+
+    frontend_changed(device);
+}
+
 static void close_all(void)
 {
     if ( daemon_running )
+    {
         xs_rm(xs, XBT_NULL, "libxl/xen-9pfs");
+        xs_unwatch(xs, "backend/xen_9pfs", "main");
+
+        remove_all_devices();
+    }
     if ( xe )
         xenevtchn_close(xe);
     if ( xg )
@@ -68,6 +666,33 @@ static void do_err(const char *msg)
     exit(1);
 }
 
+static void handle_event(void)
+{
+    xenevtchn_port_or_error_t evtchn;
+    device *device;
+    struct ring *ring;
+    unsigned int ring_idx;
+
+    evtchn = xenevtchn_pending(xe);
+    if ( evtchn < 0 )
+        do_err("xenevtchn_pending() failed");
+
+    XEN_TAILQ_FOREACH( device, &devs, list )
+    {
+        for ( ring_idx = 0; ring_idx < device->num_rings; ring_idx++ )
+        {
+            ring = device->ring[ring_idx];
+            if ( ring && ring->evtchn == evtchn )
+            {
+                pthread_mutex_lock(&ring->mutex);
+                pthread_cond_signal(&ring->cond);
+                pthread_mutex_unlock(&ring->mutex);
+                return;
+            }
+        }
+    }
+}
+
 static void xen_connect(void)
 {
     xs_transaction_t t;
@@ -124,6 +749,11 @@ int main(int argc, char *argv[])
     int syslog_mask = LOG_MASK(LOG_WARNING) | LOG_MASK(LOG_ERR) |
                       LOG_MASK(LOG_CRIT) | LOG_MASK(LOG_ALERT) |
                       LOG_MASK(LOG_EMERG);
+    char **watch;
+    struct pollfd p[2] = {
+        { .events = POLLIN },
+        { .events = POLLIN }
+    };
 
     umask(027);
     if ( getenv("XEN_9PFSD_VERBOSE") )
@@ -136,9 +766,26 @@ int main(int argc, char *argv[])
 
     xen_connect();
 
+    if ( !xs_watch(xs, "backend/xen_9pfs", "main") )
+        do_err("xs_watch() in main thread failed");
+    p[0].fd = xs_fileno(xs);
+    p[1].fd = xenevtchn_fd(xe);
+
+    scan_backend();
+
     while ( !stop_me )
     {
-        sleep(60);
+        while ( (p[0].revents & POLLIN) &&
+                (watch = xs_check_watch(xs)) != NULL )
+        {
+            handle_watch(watch[XS_WATCH_PATH], watch[XS_WATCH_TOKEN]);
+            free(watch);
+        }
+
+        if ( p[1].revents & POLLIN )
+            handle_event();
+
+        poll(p, 2, -1);
     }
 
     close_all();
diff --git a/tools/9pfsd/xen-9pfsd.h b/tools/9pfsd/xen-9pfsd.h
new file mode 100644
index 0000000000..ff3562164a
--- /dev/null
+++ b/tools/9pfsd/xen-9pfsd.h
@@ -0,0 +1,61 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef XEN_9PFSD_H
+#define XEN_9PFSD_H
+
+#include <pthread.h>
+#include <stdbool.h>
+#include <xenevtchn.h>
+#include <xen_list.h>
+#include <xen/xen.h>
+#include <xen/io/xenbus.h>
+#include <xen/io/9pfs.h>
+
+#define MAX_RINGS                4
+#define MAX_RING_ORDER           9
+#define MAX_OPEN_FILES_DEFAULT   5
+
+typedef struct device device;
+
+struct ring {
+    device *device;
+    pthread_t thread;
+    bool thread_active;
+    bool stop_thread;
+    pthread_cond_t cond;
+    pthread_mutex_t mutex;
+
+    evtchn_port_t evtchn;
+    struct xen_9pfs_data_intf *intf;
+    unsigned int ring_order;
+    RING_IDX ring_size;
+    struct xen_9pfs_data data;
+};
+
+struct device {
+    /* Admin data. */
+    XEN_TAILQ_ENTRY(device) list;
+    unsigned int last_seen;    /* Set in scan_backend(). */
+    unsigned int domid;
+    unsigned int devid;
+
+    /* Tool side configuration data. */
+    char *host_path;
+    unsigned int max_space;
+    unsigned int max_files;
+    unsigned int max_open_files;
+    bool auto_delete;
+
+    /* Connection data. */
+    enum xenbus_state backend_state;
+    enum xenbus_state frontend_state;
+    unsigned int num_rings;
+    struct ring *ring[MAX_RINGS];
+    int root_fd;
+};
+
+extern xenevtchn_handle *xe;
+
+void *io_thread(void *arg);
+
+#endif /* XEN_9PFSD_H */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 15 18:00:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 15 Feb 2024 18:00:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681972.1060994 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag25-0000gq-NH; Thu, 15 Feb 2024 18:00:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681972.1060994; Thu, 15 Feb 2024 18:00:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag25-0000gg-Kf; Thu, 15 Feb 2024 18:00:25 +0000
Received: by outflank-mailman (input) for mailman id 681972;
 Thu, 15 Feb 2024 18:00:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag24-0000gS-GT
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag24-0004p9-Fj
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag24-0005oP-EA
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:24 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=vDdKXx8nvXZn0n6m+YEmsUpM4QKzyOFz21xGBvCc4aw=; b=fHckJOUFJ/iWSekpHX5oQbYD6s
	0GKDEPl5GpfPz92XdbaXPNgbYjUvdV3OBs6FxUT9T8VRuIgaPENDsG+V69c8/SeEP6KK2VQJTCe4n
	4RnPRCSi+2IaqncIu8HikZkillUwg1CfwnKWWFwFHMs4TVYzsKxQQpndSjDkRqZo3XTQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xen-9pfsd: add transport layer
Message-Id: <E1rag24-0005oP-EA@xenbits.xenproject.org>
Date: Thu, 15 Feb 2024 18:00:24 +0000

commit 8219809423a6c2164e4f036ae418087a39f40dd1
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:51 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add transport layer
    
    Add the transport layer of 9pfs. This is basically the infrastructure
    to receive requests from the frontend and to send the related answers
    via the rings.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/9pfsd/io.c        | 143 +++++++++++++++++++++++++++++++++++++++++++++++-
 tools/9pfsd/xen-9pfsd.h |  16 ++++++
 2 files changed, 156 insertions(+), 3 deletions(-)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index eb7c136e09..996017a8be 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -6,39 +6,176 @@
  * Copyright (C) 2024 Juergen Gross <jgross@suse.com>
  *
  * I/O thread handling.
+ *
+ * Only handle one request at a time, pushing out the complete response
+ * before looking for the next request.
  */
 
 #include <stdbool.h>
+#include <stdlib.h>
 #include <string.h>
 #include <syslog.h>
+#include <xenctrl.h>           /* For cpu barriers. */
+#include <xen-tools/common-macros.h>
 
 #include "xen-9pfsd.h"
 
+/*
+ * Note that the ring names "in" and "out" are from the frontend's
+ * perspective, so the "in" ring will be used for responses to the frontend,
+ * while the "out" ring is used for requests from the frontend to the
+ * backend.
+ */
+static unsigned int ring_in_free(struct ring *ring)
+{
+    unsigned int queued;
+
+    queued = xen_9pfs_queued(ring->prod_pvt_in, ring->intf->in_cons,
+                             ring->ring_size);
+    xen_rmb();
+
+    return ring->ring_size - queued;
+}
+
+static unsigned int ring_out_data(struct ring *ring)
+{
+    unsigned int queued;
+
+    queued = xen_9pfs_queued(ring->intf->out_prod, ring->cons_pvt_out,
+                             ring->ring_size);
+    xen_rmb();
+
+    return queued;
+}
+
+static unsigned int get_request_bytes(struct ring *ring, unsigned int off,
+                                      unsigned int total_len)
+{
+    unsigned int size;
+    unsigned int out_data = ring_out_data(ring);
+    RING_IDX prod, cons;
+
+    size = min(total_len - off, out_data);
+    prod = xen_9pfs_mask(ring->intf->out_prod, ring->ring_size);
+    cons = xen_9pfs_mask(ring->cons_pvt_out, ring->ring_size);
+    xen_9pfs_read_packet(ring->buffer + off, ring->data.out, size,
+                         prod, &cons, ring->ring_size);
+
+    xen_rmb();           /* Read data out before setting visible consumer. */
+    ring->cons_pvt_out += size;
+    ring->intf->out_cons = ring->cons_pvt_out;
+
+    /* Signal that more space is available now. */
+    xenevtchn_notify(xe, ring->evtchn);
+
+    return size;
+}
+
+static unsigned int put_response_bytes(struct ring *ring, unsigned int off,
+                                       unsigned int total_len)
+{
+    unsigned int size;
+    unsigned int in_data = ring_in_free(ring);
+    RING_IDX prod, cons;
+
+    size = min(total_len - off, in_data);
+    prod = xen_9pfs_mask(ring->prod_pvt_in, ring->ring_size);
+    cons = xen_9pfs_mask(ring->intf->in_cons, ring->ring_size);
+    xen_9pfs_write_packet(ring->data.in, ring->buffer + off, size,
+                          &prod, cons, ring->ring_size);
+
+    xen_wmb();           /* Write data out before setting visible producer. */
+    ring->prod_pvt_in += size;
+    ring->intf->in_prod = ring->prod_pvt_in;
+
+    return size;
+}
+
 static bool io_work_pending(struct ring *ring)
 {
     if ( ring->stop_thread )
         return true;
-    return false;
+    if ( ring->error )
+        return false;
+    return ring->handle_response ? ring_in_free(ring) : ring_out_data(ring);
 }
 
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
+    unsigned int count = 0;
+    struct p9_header hdr = { .size = 0 };
+    bool in_hdr = true;
+
+    ring->max_size = ring->ring_size;
+    ring->buffer = malloc(ring->max_size);
+    if ( !ring->buffer )
+    {
+        syslog(LOG_CRIT, "memory allocation failure!");
+        return NULL;
+    }
 
     while ( !ring->stop_thread )
     {
         pthread_mutex_lock(&ring->mutex);
         if ( !io_work_pending(ring) )
         {
-            if ( xenevtchn_unmask(xe, ring->evtchn) < 0 )
+            if ( !ring->error && xenevtchn_unmask(xe, ring->evtchn) < 0 )
                 syslog(LOG_WARNING, "xenevtchn_unmask() failed");
             pthread_cond_wait(&ring->cond, &ring->mutex);
         }
         pthread_mutex_unlock(&ring->mutex);
 
-        /* TODO: I/O handling. */
+        if ( ring->stop_thread || ring->error )
+            continue;
+
+        if ( !ring->handle_response )
+        {
+            if ( in_hdr )
+            {
+                count += get_request_bytes(ring, count, sizeof(hdr));
+                if ( count != sizeof(hdr) )
+                    continue;
+                hdr = *(struct p9_header *)ring->buffer;
+                if ( hdr.size > ring->max_size || hdr.size < sizeof(hdr) )
+                {
+                    syslog(LOG_ERR, "%u.%u specified illegal request length %u",
+                           ring->device->domid, ring->device->devid, hdr.size);
+                    ring->error = true;
+                    continue;
+                }
+                in_hdr = false;
+            }
+
+            count += get_request_bytes(ring, count, hdr.size);
+            if ( count < hdr.size )
+                continue;
+
+            /* TODO: handle request (will rewrite hdr.size). */
+
+            ring->handle_response = true;
+            hdr.size = ((struct p9_header *)ring->buffer)->size;
+            count = 0;
+        }
+
+        if ( ring->handle_response )
+        {
+            count += put_response_bytes(ring, count, hdr.size);
+
+            if ( count == hdr.size )
+            {
+                /* Signal presence of response. */
+                xenevtchn_notify(xe, ring->evtchn);
+
+                ring->handle_response = false;
+                in_hdr = true;
+                count = 0;
+            }
+        }
     }
 
+    free(ring->buffer);
+
     ring->thread_active = false;
 
     return NULL;
diff --git a/tools/9pfsd/xen-9pfsd.h b/tools/9pfsd/xen-9pfsd.h
index ff3562164a..d587f59a32 100644
--- a/tools/9pfsd/xen-9pfsd.h
+++ b/tools/9pfsd/xen-9pfsd.h
@@ -15,6 +15,12 @@
 #define MAX_RING_ORDER           9
 #define MAX_OPEN_FILES_DEFAULT   5
 
+struct p9_header {
+    uint32_t size;
+    uint8_t cmd;
+    uint16_t tag;
+} __attribute__((packed));
+
 typedef struct device device;
 
 struct ring {
@@ -29,7 +35,17 @@ struct ring {
     struct xen_9pfs_data_intf *intf;
     unsigned int ring_order;
     RING_IDX ring_size;
+
+    /* Transport layer data. */
     struct xen_9pfs_data data;
+    RING_IDX prod_pvt_in;
+    RING_IDX cons_pvt_out;
+
+    /* Request and response handling. */
+    uint32_t max_size;
+    bool error;             /* Protocol error - stop processing. */
+    bool handle_response;   /* Main loop now handling response. */
+    void *buffer;           /* Request/response buffer. */
 };
 
 struct device {
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 15 18:00:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 15 Feb 2024 18:00:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681973.1060998 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag2F-0000ir-Ol; Thu, 15 Feb 2024 18:00:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681973.1060998; Thu, 15 Feb 2024 18:00:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag2F-0000ij-M9; Thu, 15 Feb 2024 18:00:35 +0000
Received: by outflank-mailman (input) for mailman id 681973;
 Thu, 15 Feb 2024 18:00:34 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag2E-0000iZ-Jg
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag2E-0004pL-Ir
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag2E-0005p0-Ht
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:34 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=XF8hnk45BSkTtvLuE57HScdlexMq96/apRU5oRmUGs0=; b=6tKBU+OPbUjorVEDB5kOlUvgFg
	dwQRpB0CKlCgKqFYmQOVIjyJK11zfSBHbzoH8aSqmi40tU8BoFq9yHLUUPhhQmHzzY5XyJtRGfnRa
	SRJnpF9AlBAphlmDPWg5zyXJvd4odGWJTlYUotZM/ilSHntxBSAtKI6hT+Ee+jAAqHiQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xen-9pfsd: add 9pfs response generation support
Message-Id: <E1rag2E-0005p0-Ht@xenbits.xenproject.org>
Date: Thu, 15 Feb 2024 18:00:34 +0000

commit 7809132b1a1d2c8b36ec28c296230e06bb7401e3
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:52 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs response generation support
    
    Add support for generation a 9pfs protocol response via a format based
    approach.
    
    Strings are stored in a per device string buffer and they are
    referenced via their offset in this buffer. This allows to avoid
    having to dynamically allocate memory for each single string.
    
    As a first user of the response handling add a generic p9_error()
    function which will be used to return any error to the client.
    
    Add all format parsing variants in order to avoid additional code churn
    later when adding the users of those variants. Prepare a special case
    for the "read" case already (format character 'D'): in order to avoid
    adding another buffer for read data support doing the read I/O directly
    into the response buffer.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/io.c        | 217 +++++++++++++++++++++++++++++++++++++++++++++++-
 tools/9pfsd/xen-9pfsd.h |   3 +
 2 files changed, 219 insertions(+), 1 deletion(-)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 996017a8be..12539677df 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -11,6 +11,7 @@
  * before looking for the next request.
  */
 
+#include <errno.h>
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
@@ -20,6 +21,16 @@
 
 #include "xen-9pfsd.h"
 
+/* P9 protocol commands (response is either cmd+1 or P9_CMD_ERROR). */
+#define P9_CMD_ERROR      107
+
+struct p9_qid {
+    uint8_t type;
+#define QID_TYPE_DIR      0x80
+    uint32_t version;
+    uint64_t path;
+};
+
 /*
  * Note that the ring names "in" and "out" are from the frontend's
  * perspective, so the "in" ring will be used for responses to the frontend,
@@ -100,6 +111,200 @@ static bool io_work_pending(struct ring *ring)
     return ring->handle_response ? ring_in_free(ring) : ring_out_data(ring);
 }
 
+static void fmt_err(const char *fmt)
+{
+    syslog(LOG_CRIT, "illegal format %s passed to fill_buffer()", fmt);
+    exit(1);
+}
+
+/*
+ * Fill buffer with response data.
+ * fmt is a sequence of format characters. Supported characters are:
+ * a: an array (2 bytes number of elements + the following format as elements)
+ *    The number of elements is passed in the first unsigned int parameter, the
+ *    next parameter is a pointer to an array of elements as denoted by the next
+ *    format character.
+ * b: 1 byte unsigned integer
+ * u: 2 byte unsigned integer
+ *    The parameter is a pointer to a uint16_t value
+ * D: Data blob (4 byte length + <length> bytes)
+ *    2 parameters are consumed, first an unsigned int for the length, then a
+ *    pointer to the first uint8_t value.
+ *    No array support.
+ * L: 8 byte unsigned integer
+ *    The parameter is a pointer to a uint64_t value
+ * Q: Qid (struct p9_qid)
+ * S: String (2 byte length + <length> characters)
+ *    The length is obtained via strlen() of the parameter, being a pointer
+ *    to the first character of the string
+ * U: 4 byte unsigned integer
+ *    The parameter is a pointer to a uint32_t value
+ */
+static void fill_buffer_at(void **data, const char *fmt, ...);
+static void vfill_buffer_at(void **data, const char *fmt, va_list ap)
+{
+    const char *f;
+    const void *par;
+    const char *str_val;
+    const struct p9_qid *qid;
+    unsigned int len;
+    unsigned int array_sz = 0;
+    unsigned int elem_sz = 0;
+
+    for ( f = fmt; *f; f++ )
+    {
+        if ( !array_sz )
+            par = va_arg(ap, const void *);
+        else
+        {
+            par += elem_sz;
+            array_sz--;
+        }
+
+        switch ( *f )
+        {
+        case 'a':
+            f++;
+            if ( !*f || array_sz )
+                fmt_err(fmt);
+            array_sz = *(const unsigned int *)par;
+            if ( array_sz > 0xffff )
+            {
+                syslog(LOG_CRIT, "array size %u in fill_buffer()", array_sz);
+                exit(1);
+            }
+            put_unaligned(array_sz, (uint16_t *)*data);
+            *data += sizeof(uint16_t);
+            par = va_arg(ap, const void *);
+            elem_sz = 0;
+            break;
+
+        case 'b':
+            put_unaligned(*(const uint8_t *)par, (uint8_t *)*data);
+            elem_sz = sizeof(uint8_t);
+            *data += sizeof(uint8_t);
+            break;
+
+        case 'u':
+            put_unaligned(*(const uint16_t *)par, (uint16_t *)*data);
+            elem_sz = sizeof(uint16_t);
+            *data += sizeof(uint16_t);
+            break;
+
+        case 'D':
+            if ( array_sz )
+                fmt_err(fmt);
+            len = *(const unsigned int *)par;
+            put_unaligned(len, (uint32_t *)*data);
+            *data += sizeof(uint32_t);
+            par = va_arg(ap, const void *);
+            if ( *data != par )
+                memcpy(*data, par, len);
+            *data += len;
+            break;
+
+        case 'L':
+            put_unaligned(*(const uint64_t *)par, (uint64_t *)*data);
+            elem_sz = sizeof(uint64_t);
+            *data += sizeof(uint64_t);
+            break;
+
+        case 'Q':
+            qid = par;
+            elem_sz = sizeof(*qid);
+            fill_buffer_at(data, "bUL", &qid->type, &qid->version, &qid->path);
+            break;
+
+        case 'S':
+            str_val = par;
+            elem_sz = sizeof(str_val);
+            len = strlen(str_val);
+            if ( len > 0xffff )
+            {
+                syslog(LOG_CRIT, "string length %u in fill_buffer()", len);
+                exit(1);
+            }
+            put_unaligned(len, (uint16_t *)*data);
+            *data += sizeof(uint16_t);
+            memcpy(*data, str_val, len);
+            *data += len;
+            break;
+
+        case 'U':
+            put_unaligned(*(const uint32_t *)par, (uint32_t *)*data);
+            elem_sz = sizeof(uint32_t);
+            *data += sizeof(uint32_t);
+            break;
+
+        default:
+            fmt_err(fmt);
+        }
+
+        if ( array_sz )
+            f--;
+    }
+}
+
+static void fill_buffer_at(void **data, const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    vfill_buffer_at(data, fmt, ap);
+    va_end(ap);
+}
+
+static void fill_buffer(struct ring *ring, uint8_t cmd, uint16_t tag,
+                        const char *fmt, ...)
+{
+    struct p9_header *hdr = ring->buffer;
+    void *data = hdr + 1;
+    va_list ap;
+
+    hdr->cmd = cmd;
+    hdr->tag = tag;
+
+    va_start(ap, fmt);
+    vfill_buffer_at(&data, fmt, ap);
+    va_end(ap);
+
+    hdr->size = data - ring->buffer;
+}
+
+static unsigned int add_string(struct ring *ring, const char *str,
+                               unsigned int len)
+{
+    char *tmp;
+    unsigned int ret;
+
+    if ( ring->str_used + len + 1 > ring->str_size )
+    {
+        tmp = realloc(ring->str, ring->str_used + len + 1);
+        if ( !tmp )
+            return ~0;
+        ring->str = tmp;
+        ring->str_size = ring->str_used + len + 1;
+    }
+
+    ret = ring->str_used;
+    memcpy(ring->str + ret, str, len);
+    ring->str_used += len;
+    ring->str[ring->str_used++] = 0;
+
+    return ret;
+}
+
+static void p9_error(struct ring *ring, uint16_t tag, uint32_t err)
+{
+    unsigned int erroff;
+
+    strerror_r(err, ring->buffer, ring->ring_size);
+    erroff = add_string(ring, ring->buffer, strlen(ring->buffer));
+    fill_buffer(ring, P9_CMD_ERROR, tag, "SU",
+                erroff != ~0 ? ring->str + erroff : "cannot allocate memory",
+                &err);
+}
+
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
@@ -151,7 +356,16 @@ void *io_thread(void *arg)
             if ( count < hdr.size )
                 continue;
 
-            /* TODO: handle request (will rewrite hdr.size). */
+            ring->str_used = 0;
+
+            switch ( hdr.cmd )
+            {
+            default:
+                syslog(LOG_DEBUG, "%u.%u sent unhandled command %u\n",
+                       ring->device->domid, ring->device->devid, hdr.cmd);
+                p9_error(ring, hdr.tag, EOPNOTSUPP);
+                break;
+            }
 
             ring->handle_response = true;
             hdr.size = ((struct p9_header *)ring->buffer)->size;
@@ -174,6 +388,7 @@ void *io_thread(void *arg)
         }
     }
 
+    free(ring->str);
     free(ring->buffer);
 
     ring->thread_active = false;
diff --git a/tools/9pfsd/xen-9pfsd.h b/tools/9pfsd/xen-9pfsd.h
index d587f59a32..0cde0d2bb8 100644
--- a/tools/9pfsd/xen-9pfsd.h
+++ b/tools/9pfsd/xen-9pfsd.h
@@ -46,6 +46,9 @@ struct ring {
     bool error;             /* Protocol error - stop processing. */
     bool handle_response;   /* Main loop now handling response. */
     void *buffer;           /* Request/response buffer. */
+    char *str;              /* String work space. */
+    unsigned int str_size;  /* Size of *str. */
+    unsigned int str_used;  /* Currently used size of *str. */
 };
 
 struct device {
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 15 18:00:46 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 15 Feb 2024 18:00:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681974.1061003 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag2Q-0000lF-Qj; Thu, 15 Feb 2024 18:00:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681974.1061003; Thu, 15 Feb 2024 18:00:46 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag2Q-0000l8-Nn; Thu, 15 Feb 2024 18:00:46 +0000
Received: by outflank-mailman (input) for mailman id 681974;
 Thu, 15 Feb 2024 18:00:44 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag2O-0000ks-QU
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:44 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag2O-0004pU-Ny
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:44 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag2O-0005qG-LD
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:44 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=DgCuSsvgw2q67SetGz9s/tbGDeoWEsl2m2/3XDvzC0Y=; b=qnEFYdUiR8T88KnsVU/vKpAw6T
	uy/bvFN3fEc43VIkGhl1eKyQgPjbVPYdiOzpet8yOncYEgLeBHuQ9DWExwvg7xaN5XCzLYt0oCImx
	9B3SBse0RIrbDfwLNa++EOa35YTvcv+1RF1TFZTPp9yl2KJXeNOA3RYkP8HjSsvVTGuc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xen-9pfsd: add 9pfs version request support
Message-Id: <E1rag2O-0005qG-LD@xenbits.xenproject.org>
Date: Thu, 15 Feb 2024 18:00:44 +0000

commit bcec59cf7ff4c3dfa1a417332b59e7e87c0f1f71
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:53 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs version request support
    
    Add the version request of the 9pfs protocol. For the version use the
    "9P2000.u" variant, as it is supported by Mini-OS and Linux.
    
    For the request parsing add all format items needed even in future in
    order to avoid code churn for those additions later.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/io.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 201 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 12539677df..27571da192 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -22,8 +22,12 @@
 #include "xen-9pfsd.h"
 
 /* P9 protocol commands (response is either cmd+1 or P9_CMD_ERROR). */
+#define P9_CMD_VERSION    100
 #define P9_CMD_ERROR      107
 
+#define P9_MIN_MSIZE      2048
+#define P9_VERSION        "9P2000.u"
+
 struct p9_qid {
     uint8_t type;
 #define QID_TYPE_DIR      0x80
@@ -294,6 +298,169 @@ static unsigned int add_string(struct ring *ring, const char *str,
     return ret;
 }
 
+static bool chk_data(struct ring *ring, void *data, unsigned int len)
+{
+    struct p9_header *hdr = ring->buffer;
+
+    if ( data + len <= ring->buffer + hdr->size )
+        return true;
+
+    errno = E2BIG;
+
+    return false;
+}
+
+static bool fill_data_elem(void **par, void **array, unsigned int *array_sz,
+                           unsigned int elem_sz, void *data)
+{
+    if ( *array_sz && !*array )
+    {
+        *array = calloc(*array_sz, elem_sz);
+        if ( !*array )
+            return false;
+        *par = *array;
+    }
+
+    memcpy(*par, data, elem_sz);
+
+    if ( *array_sz )
+    {
+        *par += elem_sz;
+        *array_sz -= 1;
+    }
+
+    return true;
+}
+
+/*
+ * Fill variables with request data.
+ * fmt is a sequence of format characters. Supported characters are:
+ * a: an array (2 bytes number of elements + the following format as elements)
+ *    The number of elements is stored in the first unsigned int parameter, the
+ *    next parameter is a pointer to an array of elements as denoted by the next
+ *    format character. The array is allocated dynamically.
+ * b: 1 byte unsigned integer
+ *    The value is stored in the next parameter with type uint8_t.
+ * D: Data blob (4 byte length + <length> bytes)
+ *    2 parameters are consumed, first an unsigned int for the length, then a
+ *    pointer to the first uint8_t value.
+ *    No array support.
+ * L: 8 byte unsigned integer
+ *    The value is stored in the next parameter with type uint64_t.
+ * S: String (2 byte length + <length> characters)
+ *    The 0-terminated string is stored in device->str + off, off is stored in
+ *    the next parameter with type unsigned int.
+ * U: 4 byte unsigned integer
+ *    The value is stored in the next parameter with type uint32_t.
+ *
+ * Return value: number of filled variables, errno will be set in case of
+ *   error.
+ */
+static int fill_data(struct ring *ring, const char *fmt, ...)
+{
+    struct p9_header *hdr = ring->buffer;
+    void *data = hdr + 1;
+    void *par;
+    unsigned int pars = 0;
+    const char *f;
+    va_list ap;
+    unsigned int len;
+    unsigned int str_off;
+    unsigned int array_sz = 0;
+    void **array = NULL;
+
+    va_start(ap, fmt);
+
+    for ( f = fmt; *f; f++ )
+    {
+        if ( !array_sz )
+            par = va_arg(ap, void *);
+
+        switch ( *f )
+        {
+        case 'a':
+            f++;
+            if ( !*f || array_sz )
+                fmt_err(fmt);
+            if ( !chk_data(ring, data, sizeof(uint16_t)) )
+                return pars;
+            array_sz = get_unaligned((uint16_t *)data);
+            data += sizeof(uint16_t);
+            *(unsigned int *)par = array_sz;
+            array = va_arg(ap, void **);
+            *array = NULL;
+            break;
+
+        case 'b':
+            if ( !chk_data(ring, data, sizeof(uint8_t)) )
+                return pars;
+            if ( !fill_data_elem(&par, array, &array_sz, sizeof(uint8_t),
+                                 data) )
+                return pars;
+            data += sizeof(uint8_t);
+            break;
+
+        case 'D':
+            if ( array_sz )
+                fmt_err(fmt);
+            if ( !chk_data(ring, data, sizeof(uint32_t)) )
+                return pars;
+            len = get_unaligned((uint32_t *)data);
+            data += sizeof(uint32_t);
+            *(unsigned int *)par = len;
+            par = va_arg(ap, void *);
+            if ( !chk_data(ring, data, len) )
+                return pars;
+            memcpy(par, data, len);
+            data += len;
+            break;
+
+        case 'L':
+            if ( !chk_data(ring, data, sizeof(uint64_t)) )
+                return pars;
+            if ( !fill_data_elem(&par, array, &array_sz, sizeof(uint64_t),
+                                 data) )
+                return pars;
+            data += sizeof(uint64_t);
+            break;
+
+        case 'S':
+            if ( !chk_data(ring, data, sizeof(uint16_t)) )
+                return pars;
+            len = get_unaligned((uint16_t *)data);
+            data += sizeof(uint16_t);
+            if ( !chk_data(ring, data, len) )
+                return pars;
+            str_off = add_string(ring, data, len);
+            if ( str_off == ~0 )
+                return pars;
+            if ( !fill_data_elem(&par, array, &array_sz, sizeof(unsigned int),
+                                 &str_off) )
+                return pars;
+            data += len;
+            break;
+
+        case 'U':
+            if ( !chk_data(ring, data, sizeof(uint32_t)) )
+                return pars;
+            if ( !fill_data_elem(&par, array, &array_sz, sizeof(uint32_t),
+                                 data) )
+                return pars;
+            data += sizeof(uint32_t);
+            break;
+
+        default:
+            fmt_err(fmt);
+        }
+
+        if ( array_sz )
+            f--;
+        pars++;
+    }
+
+    return pars;
+}
+
 static void p9_error(struct ring *ring, uint16_t tag, uint32_t err)
 {
     unsigned int erroff;
@@ -305,6 +472,36 @@ static void p9_error(struct ring *ring, uint16_t tag, uint32_t err)
                 &err);
 }
 
+static void p9_version(struct ring *ring, struct p9_header *hdr)
+{
+    uint32_t max_size;
+    unsigned int off;
+    char *version;
+    int ret;
+
+    ret = fill_data(ring, "US", &max_size, &off);
+    if ( ret != 2 )
+    {
+        p9_error(ring, hdr->tag, errno);
+        return;
+    }
+
+    if ( max_size < P9_MIN_MSIZE )
+    {
+        p9_error(ring, hdr->tag, EMSGSIZE);
+        return;
+    }
+
+    if ( max_size < ring->max_size )
+        ring->max_size = max_size;
+
+    version = ring->str + off;
+    if ( strcmp(version, P9_VERSION) )
+        version = "unknown";
+
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "US", &ring->max_size, version);
+}
+
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
@@ -360,6 +557,10 @@ void *io_thread(void *arg)
 
             switch ( hdr.cmd )
             {
+            case P9_CMD_VERSION:
+                p9_version(ring, &hdr);
+                break;
+
             default:
                 syslog(LOG_DEBUG, "%u.%u sent unhandled command %u\n",
                        ring->device->domid, ring->device->devid, hdr.cmd);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 15 18:00:56 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 15 Feb 2024 18:00:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681975.1061006 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag2a-0000p9-U2; Thu, 15 Feb 2024 18:00:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681975.1061006; Thu, 15 Feb 2024 18:00:56 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag2a-0000p1-RJ; Thu, 15 Feb 2024 18:00:56 +0000
Received: by outflank-mailman (input) for mailman id 681975;
 Thu, 15 Feb 2024 18:00:54 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag2Y-0000oT-Tq
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:54 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag2Y-0004pb-T5
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:54 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag2Y-0005r6-QL
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:00:54 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=QAAz7801utpuzpuZh0m8os2Ak16a6xmGgJyyt25h+Bo=; b=KwAOCkswnzZITc7vcgCUGeckJq
	Du/qST0bBinPmlMrZn9Ji35RB5kwZX0/Bkz6g30/8gvjFFtv91XQ1XVyDOopC/LgsdXn7U9iw4Qgu
	roLmUlAPeHj25nc//1x6+TFGsI+2U+YpFnBKq49IC3cvQaCAfg5HPbFCRDvGLYOr5CA0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xen-9pfsd: add 9pfs attach request support
Message-Id: <E1rag2Y-0005r6-QL@xenbits.xenproject.org>
Date: Thu, 15 Feb 2024 18:00:54 +0000

commit 27815b5f8f82236541a42602ce356ca6d4d1348f
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:54 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs attach request support
    
    Add the attach request of the 9pfs protocol. This introduces the "fid"
    scheme of the 9pfs protocol.
    
    As this will be needed later, use a dedicated memory allocation
    function in alloc_fid() and prepare a fid reference count.
    
    For filling the qid data take the approach from the qemu 9pfs backend
    implementation.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/io.c        | 162 ++++++++++++++++++++++++++++++++++++++++++++++++
 tools/9pfsd/xen-9pfsd.c |   6 ++
 tools/9pfsd/xen-9pfsd.h |  14 +++++
 3 files changed, 182 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 27571da192..3fd4289f7c 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -11,11 +11,14 @@
  * before looking for the next request.
  */
 
+#include <assert.h>
 #include <errno.h>
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
 #include <syslog.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <xenctrl.h>           /* For cpu barriers. */
 #include <xen-tools/common-macros.h>
 
@@ -23,6 +26,7 @@
 
 /* P9 protocol commands (response is either cmd+1 or P9_CMD_ERROR). */
 #define P9_CMD_VERSION    100
+#define P9_CMD_ATTACH     104
 #define P9_CMD_ERROR      107
 
 #define P9_MIN_MSIZE      2048
@@ -461,6 +465,124 @@ static int fill_data(struct ring *ring, const char *fmt, ...)
     return pars;
 }
 
+static struct p9_fid *find_fid(device *device, unsigned int fid)
+{
+    struct p9_fid *fidp;
+
+    XEN_TAILQ_FOREACH(fidp, &device->fids, list)
+    {
+        if ( fidp->fid == fid )
+            return fidp;
+    }
+
+    return NULL;
+}
+
+static struct p9_fid *alloc_fid_mem(device *device, unsigned int fid,
+                                    const char *path)
+{
+    struct p9_fid *fidp;
+
+    fidp = calloc(sizeof(*fidp) + strlen(path) + 1, 1);
+    if ( !fidp )
+        return NULL;
+
+    fidp->fid = fid;
+    strcpy(fidp->path, path);
+
+    return fidp;
+}
+
+static struct p9_fid *alloc_fid(device *device, unsigned int fid,
+                                const char *path)
+{
+    struct p9_fid *fidp = NULL;
+
+    pthread_mutex_lock(&device->fid_mutex);
+
+    if ( find_fid(device, fid) )
+    {
+        errno = EBADF;
+        goto out;
+    }
+
+    if ( device->n_fids >= device->max_open_files )
+    {
+        errno = EMFILE;
+        goto out;
+    }
+
+    fidp = alloc_fid_mem(device, fid, path);
+    if ( !fidp )
+        goto out;
+
+    fidp->ref = 1;
+    XEN_TAILQ_INSERT_HEAD(&device->fids, fidp, list);
+    device->n_fids++;
+
+ out:
+    pthread_mutex_unlock(&device->fid_mutex);
+
+    return fidp;
+}
+
+static void free_fid(device *device, struct p9_fid *fidp)
+{
+    if ( !fidp )
+        return;
+
+    pthread_mutex_lock(&device->fid_mutex);
+
+    fidp->ref--;
+    if ( !fidp->ref )
+    {
+        device->n_fids--;
+        XEN_TAILQ_REMOVE(&device->fids, fidp, list);
+        free(fidp);
+    }
+
+    pthread_mutex_unlock(&device->fid_mutex);
+}
+
+void free_fids(device *device)
+{
+    struct p9_fid *fidp;
+
+    while ( (fidp = XEN_TAILQ_FIRST(&device->fids)) != NULL )
+    {
+        XEN_TAILQ_REMOVE(&device->fids, fidp, list);
+        free(fidp);
+    }
+}
+
+static const char *relpath_from_path(const char *path)
+{
+    if (!strcmp(path, "/"))
+        return ".";
+
+    return (path[0] == '/') ? path + 1 : path;
+}
+
+static int fill_qid(device *device, const char *path, struct p9_qid *qid,
+                    const struct stat *stbuf)
+{
+    struct stat st;
+
+    if ( !stbuf )
+    {
+        if ( fstatat(device->root_fd, path, &st, 0) )
+            return errno;
+
+        stbuf = &st;
+    }
+
+    qid->type = S_ISDIR(stbuf->st_mode) ? QID_TYPE_DIR : 0;
+    qid->version = stbuf->st_mtime ^ (stbuf->st_size << 8);
+    qid->path = stbuf->st_ino;
+
+    return 0;
+}
+
 static void p9_error(struct ring *ring, uint16_t tag, uint32_t err)
 {
     unsigned int erroff;
@@ -502,6 +624,42 @@ static void p9_version(struct ring *ring, struct p9_header *hdr)
     fill_buffer(ring, hdr->cmd + 1, hdr->tag, "US", &ring->max_size, version);
 }
 
+static void p9_attach(struct ring *ring, struct p9_header *hdr)
+{
+    device *device = ring->device;
+    uint32_t fid;
+    uint32_t dummy_u32;
+    unsigned int dummy_uint;
+    struct p9_qid qid;
+    int ret;
+
+    ret = fill_data(ring, "UUSSU", &fid, &dummy_u32, &dummy_uint, &dummy_uint,
+                    &dummy_u32);
+    if ( ret != 5 )
+    {
+        p9_error(ring, hdr->tag, errno);
+        return;
+    }
+
+    device->root_fid = alloc_fid(device, fid, relpath_from_path("/"));
+    if ( !device->root_fid )
+    {
+        p9_error(ring, hdr->tag, errno);
+        return;
+    }
+
+    ret = fill_qid(device, device->root_fid->path, &qid, NULL);
+    if ( ret )
+    {
+        free_fid(device, device->root_fid);
+        device->root_fid = NULL;
+        p9_error(ring, hdr->tag, ret);
+        return;
+    }
+
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "Q", &qid);
+}
+
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
@@ -561,6 +719,10 @@ void *io_thread(void *arg)
                 p9_version(ring, &hdr);
                 break;
 
+            case P9_CMD_ATTACH:
+                p9_attach(ring, &hdr);
+                break;
+
             default:
                 syslog(LOG_DEBUG, "%u.%u sent unhandled command %u\n",
                        ring->device->domid, ring->device->devid, hdr.cmd);
diff --git a/tools/9pfsd/xen-9pfsd.c b/tools/9pfsd/xen-9pfsd.c
index 73b6c3a30e..b83b896bcc 100644
--- a/tools/9pfsd/xen-9pfsd.c
+++ b/tools/9pfsd/xen-9pfsd.c
@@ -304,6 +304,9 @@ static device *new_device(unsigned int domid, unsigned int devid)
         return NULL;
     }
 
+    pthread_mutex_init(&device->fid_mutex, NULL);
+    XEN_TAILQ_INIT(&device->fids);
+
     val = read_backend_node(device, "security_model");
     if ( !val || strcmp(val, "none") )
     {
@@ -399,6 +402,8 @@ static void disconnect_guest(device *device)
     }
 
     device->num_rings = 0;
+
+    free_fids(device);
 }
 
 static void close_device(device *device, enum xenbus_state state)
@@ -482,6 +487,7 @@ static void remove_device(device *device)
     XEN_TAILQ_REMOVE(&devs, device, list);
 
     disconnect_guest(device);
+    pthread_mutex_destroy(&device->fid_mutex);
     free_device(device);
 }
 
diff --git a/tools/9pfsd/xen-9pfsd.h b/tools/9pfsd/xen-9pfsd.h
index 0cde0d2bb8..6c755411a7 100644
--- a/tools/9pfsd/xen-9pfsd.h
+++ b/tools/9pfsd/xen-9pfsd.h
@@ -21,6 +21,13 @@ struct p9_header {
     uint16_t tag;
 } __attribute__((packed));
 
+struct p9_fid {
+    XEN_TAILQ_ENTRY(struct p9_fid) list;
+    unsigned int fid;
+    unsigned int ref;
+    char path[];
+};
+
 typedef struct device device;
 
 struct ring {
@@ -71,10 +78,17 @@ struct device {
     unsigned int num_rings;
     struct ring *ring[MAX_RINGS];
     int root_fd;
+
+    /* File system handling. */
+    pthread_mutex_t fid_mutex;
+    XEN_TAILQ_HEAD(fidhead, struct p9_fid) fids;
+    struct p9_fid *root_fid;
+    unsigned int n_fids;
 };
 
 extern xenevtchn_handle *xe;
 
 void *io_thread(void *arg);
+void free_fids(device *device);
 
 #endif /* XEN_9PFSD_H */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 15 18:01:07 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 15 Feb 2024 18:01:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681976.1061011 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag2k-0000st-VU; Thu, 15 Feb 2024 18:01:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681976.1061011; Thu, 15 Feb 2024 18:01:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag2k-0000sl-Ss; Thu, 15 Feb 2024 18:01:06 +0000
Received: by outflank-mailman (input) for mailman id 681976;
 Thu, 15 Feb 2024 18:01:05 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag2j-0000sW-0h
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:05 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag2i-0004qF-W8
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag2i-0005sS-VE
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=4Co9LHGnQGA+XBohpeidwhRxM5HszILiNbjNs0wyEWQ=; b=FztehXhfkxTLLec81NM+uPgGOl
	TX+XvTmKTh564gOhd5SFZbyvaPMgH2GV4lYWmAzYlA/yCH330zjbSfAL8IpO/g0t+roc9OAxzMRUZ
	DN3Lv6/vzzU6HqlpW1RRO5scAOKpjhptOTKIUdg/fLm5y4oNut/QI1FKnA9HQQW7JzNA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xen-9pfsd: add 9pfs walk request support
Message-Id: <E1rag2i-0005sS-VE@xenbits.xenproject.org>
Date: Thu, 15 Feb 2024 18:01:04 +0000

commit 9615e40f4700f548ed77cd10c13c22b42d5f4a99
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:55 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs walk request support
    
    Add the walk request of the 9pfs protocol.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/io.c        | 171 ++++++++++++++++++++++++++++++++++++++++++++++++
 tools/9pfsd/xen-9pfsd.h |   1 +
 2 files changed, 172 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 3fd4289f7c..98af20a21d 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -28,9 +28,11 @@
 #define P9_CMD_VERSION    100
 #define P9_CMD_ATTACH     104
 #define P9_CMD_ERROR      107
+#define P9_CMD_WALK       110
 
 #define P9_MIN_MSIZE      2048
 #define P9_VERSION        "9P2000.u"
+#define P9_WALK_MAXELEM   16
 
 struct p9_qid {
     uint8_t type;
@@ -478,6 +480,21 @@ static struct p9_fid *find_fid(device *device, unsigned int fid)
     return NULL;
 }
 
+static struct p9_fid *get_fid_ref(device *device, unsigned int fid)
+{
+    struct p9_fid *fidp;
+
+    pthread_mutex_lock(&device->fid_mutex);
+
+    fidp = find_fid(device, fid);
+    if ( fidp )
+        fidp->ref++;
+
+    pthread_mutex_unlock(&device->fid_mutex);
+
+    return fidp;
+}
+
 static struct p9_fid *alloc_fid_mem(device *device, unsigned int fid,
                                     const char *path)
 {
@@ -576,6 +593,10 @@ static int fill_qid(device *device, const char *path, struct p9_qid *qid,
         stbuf = &st;
     }
 
+    /* Don't allow symbolic links. */
+    if ( S_ISLNK(stbuf->st_mode) )
+        return EMLINK;
+
     qid->type = S_ISDIR(stbuf->st_mode) ? QID_TYPE_DIR : 0;
     qid->version = stbuf->st_mtime ^ (stbuf->st_size << 8);
     qid->path = stbuf->st_ino;
@@ -583,6 +604,20 @@ static int fill_qid(device *device, const char *path, struct p9_qid *qid,
     return 0;
 }
 
+static bool name_ok(const char *str)
+{
+    if ( !*str )
+        return false;
+
+    if ( strchr(str, '/' ) )
+        return false;
+
+    if ( !strcmp(str, "..") || !strcmp(str, ".") )
+        return false;
+
+    return true;
+}
+
 static void p9_error(struct ring *ring, uint16_t tag, uint32_t err)
 {
     unsigned int erroff;
@@ -660,6 +695,138 @@ static void p9_attach(struct ring *ring, struct p9_header *hdr)
     fill_buffer(ring, hdr->cmd + 1, hdr->tag, "Q", &qid);
 }
 
+static void p9_walk(struct ring *ring, struct p9_header *hdr)
+{
+    device *device = ring->device;
+    uint32_t fid;
+    uint32_t newfid;
+    struct p9_fid *fidp = NULL;
+    struct p9_qid *qids = NULL;
+    unsigned int n_names = 0;
+    unsigned int *names = NULL;
+    unsigned int walked = 0;
+    unsigned int i;
+    char *path = NULL;
+    unsigned int path_len;
+    int ret;
+
+    ret = fill_data(ring, "UUaS", &fid, &newfid, &n_names, &names);
+    if ( n_names > P9_WALK_MAXELEM )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        goto out;
+    }
+    if ( ret != 3 + n_names )
+    {
+        p9_error(ring, hdr->tag, errno);
+        goto out;
+    }
+
+    fidp = get_fid_ref(device, fid);
+    if ( !fidp )
+    {
+        p9_error(ring, hdr->tag, ENOENT);
+        goto out;
+    }
+    if ( fidp->opened )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        goto out;
+    }
+
+    path_len = strlen(fidp->path) + 1;
+    for ( i = 0; i < n_names; i++ )
+    {
+        if ( !name_ok(ring->str + names[i]) )
+        {
+            p9_error(ring, hdr->tag, ENOENT);
+            goto out;
+        }
+        path_len += strlen(ring->str + names[i]) + 1;
+    }
+    path = calloc(path_len + 1, 1);
+    if ( !path )
+    {
+        p9_error(ring, hdr->tag, ENOMEM);
+        goto out;
+    }
+    strcpy(path, fidp->path);
+
+    if ( n_names )
+    {
+        qids = calloc(n_names, sizeof(*qids));
+        if ( !qids )
+        {
+            p9_error(ring, hdr->tag, ENOMEM);
+            goto out;
+        }
+        for ( i = 0; i < n_names; i++ )
+        {
+            strcat(path, "/");
+            strcat(path, ring->str + names[i]);
+            ret = fill_qid(device, path, qids + i, NULL);
+            if ( ret )
+            {
+                if ( !walked )
+                {
+                    p9_error(ring, hdr->tag, errno);
+                    goto out;
+                }
+                break;
+            }
+            walked++;
+        }
+    }
+
+    if ( walked == n_names )
+    {
+        bool ok = false;
+
+        if ( fid == newfid )
+        {
+            struct p9_fid *new_fidp;
+
+            pthread_mutex_lock(&device->fid_mutex);
+
+            if ( fidp->ref != 2 )
+            {
+                errno = EBUSY;
+            }
+            else
+            {
+                new_fidp = alloc_fid_mem(device, fid, path);
+                if ( new_fidp )
+                {
+                    new_fidp->ref = 2;
+                    XEN_TAILQ_REMOVE(&device->fids, fidp, list);
+                    XEN_TAILQ_INSERT_HEAD(&device->fids, new_fidp, list);
+                    free(fidp);
+                    fidp = new_fidp;
+                    ok = true;
+                }
+            }
+
+            pthread_mutex_unlock(&device->fid_mutex);
+        }
+        else
+            ok = alloc_fid(device, newfid, path);
+
+        if ( !ok )
+        {
+            p9_error(ring, hdr->tag, errno);
+            goto out;
+        }
+    }
+
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "aQ", &walked, qids);
+
+ out:
+    free_fid(device, fidp);
+    free(qids);
+    free(path);
+    free(names);
+}
+
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
@@ -723,6 +890,10 @@ void *io_thread(void *arg)
                 p9_attach(ring, &hdr);
                 break;
 
+            case P9_CMD_WALK:
+                p9_walk(ring, &hdr);
+                break;
+
             default:
                 syslog(LOG_DEBUG, "%u.%u sent unhandled command %u\n",
                        ring->device->domid, ring->device->devid, hdr.cmd);
diff --git a/tools/9pfsd/xen-9pfsd.h b/tools/9pfsd/xen-9pfsd.h
index 6c755411a7..f01fffb0bb 100644
--- a/tools/9pfsd/xen-9pfsd.h
+++ b/tools/9pfsd/xen-9pfsd.h
@@ -25,6 +25,7 @@ struct p9_fid {
     XEN_TAILQ_ENTRY(struct p9_fid) list;
     unsigned int fid;
     unsigned int ref;
+    bool opened;
     char path[];
 };
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 15 18:01:17 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 15 Feb 2024 18:01:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681977.1061014 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag2v-0000ve-0e; Thu, 15 Feb 2024 18:01:17 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681977.1061014; Thu, 15 Feb 2024 18:01:16 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag2u-0000vW-UO; Thu, 15 Feb 2024 18:01:16 +0000
Received: by outflank-mailman (input) for mailman id 681977;
 Thu, 15 Feb 2024 18:01:15 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag2t-0000v3-3d
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:15 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag2t-0004qV-2t
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:15 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag2t-0005te-1z
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:15 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=1eLpOqHWmn5wyamzXkLwof7sK3BnpFwKav9K2zCYiqQ=; b=i7TbOG6PgHo8mZLGiq8mv6f7/Y
	qrdvM+uiFcP3x+X77RmvbMTurQbiEMT1ln/8VAp/kN5V5QOriYCb8SglE9awUrFn3S7oZ0pM73mRX
	yhiQ62R+fDG0Z7zABZx4pifszRatn+1xBd3ulXsRt3aqOfJNXcnTyq4fRTq6dXBflGG0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xen-9pfsd: add 9pfs open request support
Message-Id: <E1rag2t-0005te-1z@xenbits.xenproject.org>
Date: Thu, 15 Feb 2024 18:01:15 +0000

commit 7c0d5f3cac1040130edd7701afc15e5db7ead940
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:56 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs open request support
    
    Add the open request of the 9pfs protocol.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/io.c        | 137 ++++++++++++++++++++++++++++++++++++++++++++++++
 tools/9pfsd/xen-9pfsd.h |   4 ++
 2 files changed, 141 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 98af20a21d..9ff3bcccca 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -19,6 +19,8 @@
 #include <syslog.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <dirent.h>
+#include <fcntl.h>
 #include <xenctrl.h>           /* For cpu barriers. */
 #include <xen-tools/common-macros.h>
 
@@ -29,6 +31,15 @@
 #define P9_CMD_ATTACH     104
 #define P9_CMD_ERROR      107
 #define P9_CMD_WALK       110
+#define P9_CMD_OPEN       112
+
+/* P9 protocol open flags. */
+#define P9_OREAD            0   /* read */
+#define P9_OWRITE           1   /* write */
+#define P9_ORDWR            2   /* read and write */
+#define P9_OMODEMASK     0x03
+#define P9_OTRUNC        0x10   /* or'ed in, truncate file first */
+#define P9_OREMOVE       0x40   /* or'ed in, remove file after clunk */
 
 #define P9_MIN_MSIZE      2048
 #define P9_VERSION        "9P2000.u"
@@ -827,6 +838,128 @@ static void p9_walk(struct ring *ring, struct p9_header *hdr)
     free(names);
 }
 
+static int open_flags_from_mode(uint8_t mode)
+{
+    int flags;
+
+    switch ( mode & P9_OMODEMASK )
+    {
+    case P9_OREAD:
+        flags = O_RDONLY;
+        break;
+
+    case P9_OWRITE:
+        flags = O_WRONLY;
+        break;
+
+    case P9_ORDWR:
+        flags = O_RDWR;
+        break;
+
+    default:
+        errno = EINVAL;
+        return -1;
+    }
+
+    if ( mode & P9_OTRUNC )
+        flags |= O_TRUNC;
+
+    return flags;
+}
+
+static unsigned int get_iounit(struct ring *ring, struct stat *st)
+{
+    return (ring->max_size - st->st_blksize) & ~(st->st_blksize - 1);
+}
+
+static void p9_open(struct ring *ring, struct p9_header *hdr)
+{
+    device *device = ring->device;
+    uint32_t fid;
+    uint8_t mode;
+    struct p9_fid *fidp;
+    struct stat st;
+    struct p9_qid qid;
+    uint32_t iounit;
+    int flags;
+    int ret;
+
+    ret = fill_data(ring, "Ub", &fid, &mode);
+    if ( ret != 2 )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+    if ( mode & ~(P9_OMODEMASK | P9_OTRUNC | P9_OREMOVE) )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+
+    fidp = get_fid_ref(device, fid);
+    if ( !fidp )
+    {
+        p9_error(ring, hdr->tag, ENOENT);
+        return;
+    }
+    if ( fidp->opened )
+    {
+        errno = EINVAL;
+        goto err;
+    }
+
+    if ( fstatat(device->root_fd, fidp->path, &st, 0) < 0 )
+    {
+        errno = ENOENT;
+        goto err;
+    }
+
+    if ( S_ISLNK(st.st_mode) )
+    {
+        errno = EMLINK;
+        goto err;
+    }
+
+    fidp->isdir = S_ISDIR(st.st_mode);
+    fidp->mode = mode;
+    if ( fidp->isdir )
+    {
+        if ( mode != P9_OREAD )
+        {
+            errno = EINVAL;
+            goto err;
+        }
+        fidp->fd = openat(device->root_fd, fidp->path, O_RDONLY);
+        if ( fidp->fd < 0 )
+            goto err;
+        fidp->data = fdopendir(fidp->fd);
+        if ( !fidp->data )
+            goto err;
+    }
+    else
+    {
+        flags = open_flags_from_mode(mode);
+        if ( flags < 0 )
+            goto err;
+
+        fidp->fd = openat(device->root_fd, fidp->path, flags);
+        if ( fidp->fd < 0 )
+            goto err;
+    }
+
+    fill_qid(device, fidp->path, &qid, &st);
+    iounit = get_iounit(ring, &st);
+    fidp->opened = true;
+
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "QU", &qid, &iounit);
+
+    return;
+
+ err:
+    free_fid(device, fidp);
+    p9_error(ring, hdr->tag, errno);
+}
+
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
@@ -894,6 +1027,10 @@ void *io_thread(void *arg)
                 p9_walk(ring, &hdr);
                 break;
 
+            case P9_CMD_OPEN:
+                p9_open(ring, &hdr);
+                break;
+
             default:
                 syslog(LOG_DEBUG, "%u.%u sent unhandled command %u\n",
                        ring->device->domid, ring->device->devid, hdr.cmd);
diff --git a/tools/9pfsd/xen-9pfsd.h b/tools/9pfsd/xen-9pfsd.h
index f01fffb0bb..757be2da4b 100644
--- a/tools/9pfsd/xen-9pfsd.h
+++ b/tools/9pfsd/xen-9pfsd.h
@@ -25,7 +25,11 @@ struct p9_fid {
     XEN_TAILQ_ENTRY(struct p9_fid) list;
     unsigned int fid;
     unsigned int ref;
+    int fd;
+    uint8_t mode;
     bool opened;
+    bool isdir;
+    void *data;    /* File type specific. */
     char path[];
 };
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 15 18:01:26 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 15 Feb 2024 18:01:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681978.1061018 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag34-0000y4-2C; Thu, 15 Feb 2024 18:01:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681978.1061018; Thu, 15 Feb 2024 18:01:26 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag33-0000xw-Vq; Thu, 15 Feb 2024 18:01:25 +0000
Received: by outflank-mailman (input) for mailman id 681978;
 Thu, 15 Feb 2024 18:01:25 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag33-0000xk-6c
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:25 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag33-0004qf-5y
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:25 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag33-0005uZ-54
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:25 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=7cpPU7ob2qyqi0aBlOxbtykUkTO9zHptGDoxCC1dNO0=; b=OqQLN72esfgD5O8TdAsIZ17XVE
	mcnQquUouBpg4BZAyngddPrNT5hJGAvEwdTaX/kEiyNPtbkwhxzoD+DD0k8ZinUpZSfD54phE25UR
	Go5TzsObKG/pFNaX+bFOH2kl259jAnTTC/ByXwnwJfDrt8OJHEmkfwIfANJEezNs5j0o=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xen-9pfsd: add 9pfs clunk request support
Message-Id: <E1rag33-0005uZ-54@xenbits.xenproject.org>
Date: Thu, 15 Feb 2024 18:01:25 +0000

commit 052a3a7fd90c3aa749c9fb03df622d1c0915ea8c
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:57 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs clunk request support
    
    Add the clunk request of the 9pfs protocol.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/io.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 9ff3bcccca..7c773bc65e 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -32,6 +32,7 @@
 #define P9_CMD_ERROR      107
 #define P9_CMD_WALK       110
 #define P9_CMD_OPEN       112
+#define P9_CMD_CLUNK      120
 
 /* P9 protocol open flags. */
 #define P9_OREAD            0   /* read */
@@ -960,6 +961,44 @@ static void p9_open(struct ring *ring, struct p9_header *hdr)
     p9_error(ring, hdr->tag, errno);
 }
 
+static void p9_clunk(struct ring *ring, struct p9_header *hdr)
+{
+    device *device = ring->device;
+    uint32_t fid;
+    struct p9_fid *fidp;
+    int ret;
+
+    ret = fill_data(ring, "U", &fid);
+    if ( ret != 1 )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+
+    fidp = get_fid_ref(device, fid);
+    if ( !fidp )
+    {
+        p9_error(ring, hdr->tag, ENOENT);
+        return;
+    }
+
+    if ( fidp->opened )
+    {
+        fidp->opened = false;
+        free_fid(device, fidp);
+        close(fidp->fd);
+        if ( fidp->mode & P9_OREMOVE )
+            unlinkat(device->root_fd, fidp->path,
+                     fidp->isdir ? AT_REMOVEDIR : 0);
+    }
+
+    /* 2 calls of free_fid(): one for our reference, and one to free it. */
+    free_fid(device, fidp);
+    free_fid(device, fidp);
+
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "");
+}
+
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
@@ -1031,6 +1070,10 @@ void *io_thread(void *arg)
                 p9_open(ring, &hdr);
                 break;
 
+            case P9_CMD_CLUNK:
+                p9_clunk(ring, &hdr);
+                break;
+
             default:
                 syslog(LOG_DEBUG, "%u.%u sent unhandled command %u\n",
                        ring->device->domid, ring->device->devid, hdr.cmd);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 15 18:01:36 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 15 Feb 2024 18:01:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681979.1061022 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag3E-00010b-3X; Thu, 15 Feb 2024 18:01:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681979.1061022; Thu, 15 Feb 2024 18:01:36 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag3E-00010U-12; Thu, 15 Feb 2024 18:01:36 +0000
Received: by outflank-mailman (input) for mailman id 681979;
 Thu, 15 Feb 2024 18:01:35 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag3D-00010I-9k
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:35 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag3D-0004qo-8z
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:35 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag3D-0005vO-81
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:35 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=whtnlutSE9jUZez5zklV4KbnVEagzIrHi41u24VCFcc=; b=Lx+lK19NLehGvzMziqqQPj8DxJ
	jeHD3yEMd1rh7srEzOTYYrES6gmQNQYJLlOKn1N3QO78v6nxQJVP/Zhh0yn/3nhUAHqBl6lwxfz3w
	OFbtDa8TxBvHALUNR5tUfcjbWRyrQrtDmSPEGw0t6ORnleFNN6FHZ+tBKcQl4X/Z+U2w=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xen-9pfsd: add 9pfs create request support
Message-Id: <E1rag3D-0005vO-81@xenbits.xenproject.org>
Date: Thu, 15 Feb 2024 18:01:35 +0000

commit 34449f8cf061449d79c68c845d83a14c413ae8cf
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:58 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs create request support
    
    Add the create request of the 9pfs protocol.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/io.c | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 151 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 7c773bc65e..70426a04fd 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -32,6 +32,7 @@
 #define P9_CMD_ERROR      107
 #define P9_CMD_WALK       110
 #define P9_CMD_OPEN       112
+#define P9_CMD_CREATE     114
 #define P9_CMD_CLUNK      120
 
 /* P9 protocol open flags. */
@@ -42,6 +43,12 @@
 #define P9_OTRUNC        0x10   /* or'ed in, truncate file first */
 #define P9_OREMOVE       0x40   /* or'ed in, remove file after clunk */
 
+/* P9 protocol create permission masks. */
+#define P9_CREATE_PERM_DIR        0x80000000
+#define P9_CREATE_PERM_NOTSUPP    0x03b00000   /* link, symlink, ... */
+#define P9_CREATE_PERM_DIR_MASK   0777
+#define P9_CREATE_PERM_FILE_MASK  0666
+
 #define P9_MIN_MSIZE      2048
 #define P9_VERSION        "9P2000.u"
 #define P9_WALK_MAXELEM   16
@@ -961,6 +968,146 @@ static void p9_open(struct ring *ring, struct p9_header *hdr)
     p9_error(ring, hdr->tag, errno);
 }
 
+static void p9_create(struct ring *ring, struct p9_header *hdr)
+{
+    device *device = ring->device;
+    uint32_t fid;
+    unsigned int name_off;
+    uint32_t perm;
+    uint8_t mode;
+    unsigned int ext_off;
+    struct p9_fid *fidp;
+    struct p9_fid *new_fidp;
+    char *path;
+    struct stat st;
+    struct p9_qid qid;
+    uint32_t iounit;
+    int flags;
+    int ret;
+
+    ret = fill_data(ring, "USUbS", &fid, &name_off, &perm, &mode, &ext_off);
+    if ( ret != 5 )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+
+    if ( !name_ok(ring->str + name_off) )
+    {
+        p9_error(ring, hdr->tag, ENOENT);
+        return;
+    }
+
+    if ( perm & P9_CREATE_PERM_NOTSUPP )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+
+    fidp = get_fid_ref(device, fid);
+    if ( !fidp || fidp->opened )
+    {
+        free_fid(device, fidp);
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+    if ( fstatat(device->root_fd, fidp->path, &st, 0) < 0 )
+    {
+        free_fid(device, fidp);
+        p9_error(ring, hdr->tag, errno);
+        return;
+    }
+
+    path = malloc(strlen(fidp->path) + strlen(ring->str + name_off) + 2);
+    if ( !path )
+    {
+        free_fid(device, fidp);
+        p9_error(ring, hdr->tag, ENOMEM);
+        return;
+    }
+    sprintf(path, "%s/%s", fidp->path, ring->str + name_off);
+    new_fidp = alloc_fid_mem(device, fid, path);
+    free(path);
+    if ( !new_fidp )
+    {
+        free_fid(device, fidp);
+        p9_error(ring, hdr->tag, ENOMEM);
+        return;
+    }
+
+    pthread_mutex_lock(&device->fid_mutex);
+
+    new_fidp->ref = fidp->ref;
+
+    if ( perm & P9_CREATE_PERM_DIR )
+    {
+        perm &= P9_CREATE_PERM_DIR_MASK & st.st_mode;
+        if ( mode != P9_OREAD )
+        {
+            errno = EINVAL;
+            goto err;
+        }
+        if ( mkdirat(device->root_fd, new_fidp->path, perm) < 0 )
+            goto err;
+
+        XEN_TAILQ_REMOVE(&device->fids, fidp, list);
+        XEN_TAILQ_INSERT_HEAD(&device->fids, new_fidp, list);
+        free(fidp);
+        fidp = new_fidp;
+        new_fidp = NULL;
+
+        fidp->fd = openat(device->root_fd, fidp->path, O_RDONLY);
+        if ( fidp->fd < 0 )
+            goto err;
+        fidp->data = fdopendir(fidp->fd);
+        if ( !fidp->data )
+            goto err;
+    }
+    else
+    {
+        flags = open_flags_from_mode(mode);
+        if ( flags < 0 )
+        {
+            errno = EINVAL;
+            goto err;
+        }
+        perm &= P9_CREATE_PERM_FILE_MASK & st.st_mode;
+
+        XEN_TAILQ_REMOVE(&device->fids, fidp, list);
+        XEN_TAILQ_INSERT_HEAD(&device->fids, new_fidp, list);
+        free(fidp);
+        fidp = new_fidp;
+        new_fidp = NULL;
+
+        fidp->fd = openat(device->root_fd, fidp->path, flags | O_CREAT | O_EXCL,
+                          perm);
+        if ( fidp->fd < 0 )
+            goto err;
+    }
+
+    if ( fstatat(device->root_fd, fidp->path, &st, 0) < 0 )
+        goto err;
+
+    fill_qid(device, fidp->path, &qid, &st);
+    iounit = get_iounit(ring, &st);
+    fidp->opened = true;
+    fidp->mode = mode;
+
+    pthread_mutex_unlock(&device->fid_mutex);
+
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "QU", &qid, &iounit);
+
+    return;
+
+ err:
+    p9_error(ring, hdr->tag, errno);
+
+    pthread_mutex_unlock(&device->fid_mutex);
+
+    free(new_fidp);
+    free_fid(device, fidp);
+}
+
 static void p9_clunk(struct ring *ring, struct p9_header *hdr)
 {
     device *device = ring->device;
@@ -1070,6 +1217,10 @@ void *io_thread(void *arg)
                 p9_open(ring, &hdr);
                 break;
 
+            case P9_CMD_CREATE:
+                p9_create(ring, &hdr);
+                break;
+
             case P9_CMD_CLUNK:
                 p9_clunk(ring, &hdr);
                 break;
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 15 18:01:46 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 15 Feb 2024 18:01:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681980.1061027 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag3O-00013U-6N; Thu, 15 Feb 2024 18:01:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681980.1061027; Thu, 15 Feb 2024 18:01:46 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag3O-00013N-3o; Thu, 15 Feb 2024 18:01:46 +0000
Received: by outflank-mailman (input) for mailman id 681980;
 Thu, 15 Feb 2024 18:01:45 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag3N-00013A-CT
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:45 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag3N-0004qv-Bm
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:45 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag3N-0005wK-B4
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:45 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=z4a+mhToIbGA75TEJM6khRWp3z0dyd+gz4ElY8hRyVQ=; b=P1FNf250ue/z0WL6xQdQ/siSZs
	q3ox3BRkFe53Z/nRY7ovWjPUx9zwTsEP/JF9BPIDY0Uf52aGbrT494i2XifvsGO4dQeQD2BB68HXC
	te+LVVUca0qHnsjG8saS+XgzYsfQPGgP60PhAwmlCGTd1UaaJYqAVmItAW5KB39vCDVo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xen-9pfsd: add 9pfs stat request support
Message-Id: <E1rag3N-0005wK-B4@xenbits.xenproject.org>
Date: Thu, 15 Feb 2024 18:01:45 +0000

commit 01c569f3fca5f76f6e5ec1661280bdd2381019b9
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:59 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs stat request support
    
    Add the stat request of the 9pfs protocol.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/io.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 102 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 70426a04fd..75e516738b 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -34,6 +34,7 @@
 #define P9_CMD_OPEN       112
 #define P9_CMD_CREATE     114
 #define P9_CMD_CLUNK      120
+#define P9_CMD_STAT       124
 
 /* P9 protocol open flags. */
 #define P9_OREAD            0   /* read */
@@ -60,6 +61,25 @@ struct p9_qid {
     uint64_t path;
 };
 
+struct p9_stat {
+    uint16_t size;
+    uint16_t type;
+    uint32_t dev;
+    struct p9_qid qid;
+    uint32_t mode;
+    uint32_t atime;
+    uint32_t mtime;
+    uint64_t length;
+    const char *name;
+    const char *uid;
+    const char *gid;
+    const char *muid;
+    const char *extension;
+    uint32_t n_uid;
+    uint32_t n_gid;
+    uint32_t n_muid;
+};
+
 /*
  * Note that the ring names "in" and "out" are from the frontend's
  * perspective, so the "in" ring will be used for responses to the frontend,
@@ -166,6 +186,7 @@ static void fmt_err(const char *fmt)
  * S: String (2 byte length + <length> characters)
  *    The length is obtained via strlen() of the parameter, being a pointer
  *    to the first character of the string
+ * s: stat (struct p9_stat)
  * U: 4 byte unsigned integer
  *    The parameter is a pointer to a uint32_t value
  */
@@ -176,6 +197,8 @@ static void vfill_buffer_at(void **data, const char *fmt, va_list ap)
     const void *par;
     const char *str_val;
     const struct p9_qid *qid;
+    const struct p9_stat *stat;
+    uint16_t tlen;
     unsigned int len;
     unsigned int array_sz = 0;
     unsigned int elem_sz = 0;
@@ -259,6 +282,18 @@ static void vfill_buffer_at(void **data, const char *fmt, va_list ap)
             *data += len;
             break;
 
+        case 's':
+            stat = par;
+            elem_sz = sizeof(*stat);
+            tlen = stat->size + sizeof(stat->size);
+            fill_buffer_at(data, "uuuUQUUULSSSSSUUU", &tlen, &stat->size,
+                           &stat->type, &stat->dev, &stat->qid, &stat->mode,
+                           &stat->atime, &stat->mtime, &stat->length,
+                           stat->name, stat->uid, stat->gid, stat->muid,
+                           stat->extension, &stat->n_uid, &stat->n_gid,
+                           &stat->n_muid);
+            break;
+
         case 'U':
             put_unaligned(*(const uint32_t *)par, (uint32_t *)*data);
             elem_sz = sizeof(uint32_t);
@@ -1146,6 +1181,69 @@ static void p9_clunk(struct ring *ring, struct p9_header *hdr)
     fill_buffer(ring, hdr->cmd + 1, hdr->tag, "");
 }
 
+static void fill_p9_stat(device *device, struct p9_stat *p9s, struct stat *st,
+                         const char *name)
+{
+    memset(p9s, 0, sizeof(*p9s));
+    fill_qid(device, NULL, &p9s->qid, st);
+    p9s->mode = st->st_mode & 0777;
+    if ( S_ISDIR(st->st_mode) )
+        p9s->mode |= P9_CREATE_PERM_DIR;
+    p9s->atime = st->st_atime;
+    p9s->mtime = st->st_mtime;
+    p9s->length = st->st_size;
+    p9s->name = name;
+    p9s->uid = "";
+    p9s->gid = "";
+    p9s->muid = "";
+    p9s->extension = "";
+    p9s->n_uid = 0;
+    p9s->n_gid = 0;
+    p9s->n_muid = 0;
+
+    /*
+     * Size of individual fields without the size field, including 5 2-byte
+     * string length fields.
+     */
+    p9s->size = 71 + strlen(p9s->name);
+}
+
+static void p9_stat(struct ring *ring, struct p9_header *hdr)
+{
+    device *device = ring->device;
+    uint32_t fid;
+    struct p9_fid *fidp;
+    struct p9_stat p9s;
+    struct stat st;
+    int ret;
+
+    ret = fill_data(ring, "U", &fid);
+    if ( ret != 1 )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+
+    fidp = get_fid_ref(device, fid);
+    if ( !fidp )
+    {
+        p9_error(ring, hdr->tag, ENOENT);
+        return;
+    }
+
+    if ( fstatat(device->root_fd, fidp->path, &st, 0) < 0 )
+    {
+        p9_error(ring, hdr->tag, errno);
+        goto out;
+    }
+    fill_p9_stat(device, &p9s, &st, strrchr(fidp->path, '/') + 1);
+
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "s", &p9s);
+
+ out:
+    free_fid(device, fidp);
+}
+
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
@@ -1225,6 +1323,10 @@ void *io_thread(void *arg)
                 p9_clunk(ring, &hdr);
                 break;
 
+            case P9_CMD_STAT:
+                p9_stat(ring, &hdr);
+                break;
+
             default:
                 syslog(LOG_DEBUG, "%u.%u sent unhandled command %u\n",
                        ring->device->domid, ring->device->devid, hdr.cmd);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 15 18:01:56 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 15 Feb 2024 18:01:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681981.1061031 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag3Y-00016I-86; Thu, 15 Feb 2024 18:01:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681981.1061031; Thu, 15 Feb 2024 18:01:56 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag3Y-00016A-5T; Thu, 15 Feb 2024 18:01:56 +0000
Received: by outflank-mailman (input) for mailman id 681981;
 Thu, 15 Feb 2024 18:01:55 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag3X-000162-GP
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:55 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag3X-0004r3-FX
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:55 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag3X-0005x7-Do
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:01:55 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=3bZ9Q8127t2tjnzHd2+oQcDpW6J74CoTdSFTzZZ5tfc=; b=3pkkpbHumGdsRX963bSp6Oulif
	4atO2a8INvpsYIjcvqVxlQLbMveXm3fOAjsOtNuEwLzGTzSAL2jLS63GxTRa4eS043p1HsDJ7ZfzK
	5zA8Z8dBlsVaca2enNsuW0ozxyqxWQGYsLobZY5w+rvjEDR1/F8EfcUXpqE2vYOW7iNs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xen-9pfsd: add 9pfs write request support
Message-Id: <E1rag3X-0005x7-Do@xenbits.xenproject.org>
Date: Thu, 15 Feb 2024 18:01:55 +0000

commit e93172d57dd72efa4d9a15eaeacc827a3fa6123e
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:05:00 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs write request support
    
    Add the write request of the 9pfs protocol.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/9pfsd/io.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 75e516738b..a7a6e70b66 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -33,6 +33,7 @@
 #define P9_CMD_WALK       110
 #define P9_CMD_OPEN       112
 #define P9_CMD_CREATE     114
+#define P9_CMD_WRITE      118
 #define P9_CMD_CLUNK      120
 #define P9_CMD_STAT       124
 
@@ -1244,6 +1245,55 @@ static void p9_stat(struct ring *ring, struct p9_header *hdr)
     free_fid(device, fidp);
 }
 
+static void p9_write(struct ring *ring, struct p9_header *hdr)
+{
+    device *device = ring->device;
+    uint32_t fid;
+    uint64_t off;
+    unsigned int len;
+    uint32_t written;
+    void *buf;
+    struct p9_fid *fidp;
+    int ret;
+
+    ret = fill_data(ring, "ULD", &fid, &off, &len, ring->buffer);
+    if ( ret != 3 )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+
+    fidp = get_fid_ref(device, fid);
+    if ( !fidp || !fidp->opened || fidp->isdir )
+    {
+        p9_error(ring, hdr->tag, EBADF);
+        goto out;
+    }
+
+    buf = ring->buffer;
+
+    while ( len != 0 )
+    {
+        ret = pwrite(fidp->fd, buf, len, off);
+        if ( ret < 0 )
+            break;
+        len -= ret;
+        buf += ret;
+        off += ret;
+    }
+
+    written = buf - ring->buffer;
+    if ( written == 0 )
+    {
+        p9_error(ring, hdr->tag, errno);
+        goto out;
+    }
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "U", &written);
+
+ out:
+    free_fid(device, fidp);
+}
+
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
@@ -1319,6 +1369,10 @@ void *io_thread(void *arg)
                 p9_create(ring, &hdr);
                 break;
 
+            case P9_CMD_WRITE:
+                p9_write(ring, &hdr);
+                break;
+
             case P9_CMD_CLUNK:
                 p9_clunk(ring, &hdr);
                 break;
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 15 18:02:06 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 15 Feb 2024 18:02:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.681982.1061035 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag3i-00019F-9f; Thu, 15 Feb 2024 18:02:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 681982.1061035; Thu, 15 Feb 2024 18:02:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rag3i-000197-6x; Thu, 15 Feb 2024 18:02:06 +0000
Received: by outflank-mailman (input) for mailman id 681982;
 Thu, 15 Feb 2024 18:02:05 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag3h-000190-JN
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:02:05 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag3h-0004rk-IY
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:02:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rag3h-0005yb-Hf
 for xen-changelog@lists.xenproject.org; Thu, 15 Feb 2024 18:02:05 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=TTQxqprrjtFm3O/wDc3VCSxrU0IFFuZnPtnyX1tWrSU=; b=n1ho2f7IBho3hlyxp8ub9+WOue
	absE01CKyuDUGiOi9PJ2pdf/2+IyAxEPJj5wBM0sZ/zd8Yn7oiHo43KxgmsPtzE6saw/gMQUrlF0l
	xp4PcTHJyf05vglBpNGc4smsp+soUFJWV3x9/xmAvl4FeEen8e6pCvHZ/9h1zbTbM7zM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xen-9pfsd: add 9pfs read request support
Message-Id: <E1rag3h-0005yb-Hf@xenbits.xenproject.org>
Date: Thu, 15 Feb 2024 18:02:05 +0000

commit 78398afae10bfb4ab94e8af17b7ed58510a57d96
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:05:01 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs read request support
    
    Add the read request of the 9pfs protocol.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/9pfsd/io.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index a7a6e70b66..ebc4102713 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -33,6 +33,7 @@
 #define P9_CMD_WALK       110
 #define P9_CMD_OPEN       112
 #define P9_CMD_CREATE     114
+#define P9_CMD_READ       116
 #define P9_CMD_WRITE      118
 #define P9_CMD_CLUNK      120
 #define P9_CMD_STAT       124
@@ -1245,6 +1246,94 @@ static void p9_stat(struct ring *ring, struct p9_header *hdr)
     free_fid(device, fidp);
 }
 
+static void p9_read(struct ring *ring, struct p9_header *hdr)
+{
+    device *device = ring->device;
+    uint32_t fid;
+    uint64_t off;
+    unsigned int len;
+    uint32_t count;
+    void *buf;
+    struct p9_fid *fidp;
+    int ret;
+
+    ret = fill_data(ring, "ULU", &fid, &off, &count);
+    if ( ret != 3 )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+
+    fidp = get_fid_ref(device, fid);
+    if ( !fidp || !fidp->opened )
+    {
+        errno = EBADF;
+        goto err;
+    }
+
+    len = count;
+    buf = ring->buffer + sizeof(*hdr) + sizeof(uint32_t);
+
+    if ( fidp->isdir )
+    {
+        struct dirent *dirent;
+        struct stat st;
+        struct p9_stat p9s;
+
+        if ( off == 0 )
+            rewinddir(fidp->data);
+
+        while ( len != 0 )
+        {
+            errno = 0;
+            dirent = readdir(fidp->data);
+            if ( !dirent )
+            {
+                if ( errno )
+                    goto err;
+                break;
+            }
+            if ( fstatat(fidp->fd, dirent->d_name, &st, 0) < 0 )
+                goto err;
+            fill_p9_stat(device, &p9s, &st, dirent->d_name);
+            if ( p9s.size + sizeof(p9s.size) > len )
+            {
+                seekdir(fidp->data, dirent->d_off);
+                break;
+            }
+            fill_buffer_at(&buf, "s", &p9s);
+            len -= p9s.size + sizeof(p9s.size);
+        }
+    }
+    else
+    {
+        while ( len != 0 )
+        {
+            ret = pread(fidp->fd, buf, len, off);
+            if ( ret <= 0 )
+                break;
+            len -= ret;
+            buf += ret;
+            off += ret;
+        }
+        if ( ret < 0 && len == count )
+            goto err;
+    }
+
+    buf = ring->buffer + sizeof(*hdr) + sizeof(uint32_t);
+    len = count - len;
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "D", &len, buf);
+
+ out:
+    free_fid(device, fidp);
+
+    return;
+
+ err:
+    p9_error(ring, hdr->tag, errno);
+    goto out;
+}
+
 static void p9_write(struct ring *ring, struct p9_header *hdr)
 {
     device *device = ring->device;
@@ -1369,6 +1458,10 @@ void *io_thread(void *arg)
                 p9_create(ring, &hdr);
                 break;
 
+            case P9_CMD_READ:
+                p9_read(ring, &hdr);
+                break;
+
             case P9_CMD_WRITE:
                 p9_write(ring, &hdr);
                 break;
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri Feb 16 01:33:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 16 Feb 2024 01:33:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682019.1061079 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ran66-0007ku-Bc; Fri, 16 Feb 2024 01:33:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682019.1061079; Fri, 16 Feb 2024 01:33:02 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ran66-0007km-89; Fri, 16 Feb 2024 01:33:02 +0000
Received: by outflank-mailman (input) for mailman id 682019;
 Fri, 16 Feb 2024 01:33:01 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ran65-0007kg-PR
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 01:33:01 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ran65-0003Tt-Eu
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 01:33:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ran65-0007Sn-Dt
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 01:33:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=3Nqa8TPXyUIyYTodDU2oBLh6RHE9oWKKO60w0TEmoEs=; b=cK4RLspDnMq3owBUcQVBgtt/09
	+l3X7xLfIxOcAZvvl/KoS4FNL9PjBczqOF9j82oDIO3YC7VAZxmkAcSWxxR0Dnf3pBIUHE8x7zpeC
	4HZw5TG0YwsSScFAHkVOXJl6tASKe9a07fbFhIP6mzH8+6gi1PbtiozH7qt9wuhiBJH4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] docs: add a best practices coding guide
Message-Id: <E1ran65-0007Sn-Dt@xenbits.xenproject.org>
Date: Fri, 16 Feb 2024 01:33:01 +0000

commit c4d6802d33f962a306405a20f4dccdc287990d07
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 8 17:05:15 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu Feb 15 12:11:07 2024 +0000

    docs: add a best practices coding guide
    
    Today the CODING_STYLE contains a section "Handling unexpected
    conditions" specific to the hypervisor. This section is kind of
    misplaced for a coding style. It should rather be part of a "Coding
    best practices" guide.
    
    Add such a guide as docs/process/coding-best-practices.pandoc and
    move the mentioned section from CODING_STYLE to the new file, while
    converting the format to pandoc.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 CODING_STYLE                              | 102 ------------------------------
 docs/process/coding-best-practices.pandoc |  92 +++++++++++++++++++++++++++
 2 files changed, 92 insertions(+), 102 deletions(-)

diff --git a/CODING_STYLE b/CODING_STYLE
index ed13ee2b66..7f6e9ad065 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -167,105 +167,3 @@ the end of files.  It should be:
  * indent-tabs-mode: nil
  * End:
  */
-
-Handling unexpected conditions
-------------------------------
-
-GUIDELINES:
-
-Passing errors up the stack should be used when the caller is already
-expecting to handle errors, and the state when the error was
-discovered isn’t broken, or isn't too hard to fix.
-
-domain_crash() should be used when passing errors up the stack is too
-difficult, and/or when fixing up state of a guest is impractical, but
-where fixing up the state of Xen will allow Xen to continue running.
-This is particularly appropriate when the guest is exhibiting behavior
-well-behaved guests shouldn't.
-
-BUG_ON() should be used when you can’t pass errors up the stack, and
-either continuing or crashing the guest would likely cause an
-information leak or privilege escalation vulnerability.
-
-ASSERT() IS NOT AN ERROR HANDLING MECHANISM.  ASSERT is a way to move
-detection of a bug earlier in the programming cycle; it is a
-more-noticeable printk.  It should only be added after one of the
-other three error-handling mechanisms has been evaluated for
-reliability and security.
-
-RATIONALE:
-
-It's frequently the case that code is written with the assumption that
-certain conditions can never happen.  There are several possible
-actions programmers can take in these situations:
-
-* Programmers can simply not handle those cases in any way, other than
-perhaps to write a comment documenting what the assumption is.
-
-* Programmers can try to handle the case gracefully -- fixing up
-in-progress state and returning an error to the user.
-
-* Programmers can crash the guest.
-
-* Programmers can use ASSERT(), which will cause the check to be
-executed in DEBUG builds, and cause the hypervisor to crash if it's
-violated
-
-* Programmers can use BUG_ON(), which will cause the check to be
-executed in both DEBUG and non-DEBUG builds, and cause the hypervisor
-to crash if it's violated.
-
-In selecting which response to use, we want to achieve several goals:
-
-- To minimize risk of introducing security vulnerabilities,
-  particularly as the code evolves over time
-
-- To efficiently spend programmer time
-
-- To detect violations of assumptions as early as possible
-
-- To minimize the impact of bugs on production use cases
-
-The guidelines above attempt to balance these:
-
-- When the caller is expecting to handle errors, and there is no
-broken state at the time the unexpected condition is discovered, or
-when fixing the state is straightforward, then fixing up the state and
-returning an error is the most robust thing to do.  However, if the
-caller isn't expecting to handle errors, or if the state is difficult
-to fix, then returning an error may require extensive refactoring,
-which is not a good use of programmer time when they're certain that
-this condition cannot occur.
-
-- BUG_ON() will stop all hypervisor action immediately.  In situations
-where continuing might allow an attacker to escalate privilege, a
-BUG_ON() can change a privilege escalation or information leak into a
-denial-of-service (an improvement).  But in situations where
-continuing (say, returning an error) might be safe, then BUG_ON() can
-change a benign failure into denial-of-service (a degradation).
-
-- domain_crash() is similar to BUG_ON(), but with a more limited
-effect: it stops that domain immediately.  In situations where
-continuing might cause guest or hypervisor corruption, but destroying
-the guest allows the hypervisor to continue, this can change a more
-serious bug into a guest denial-of-service.  But in situations where
-returning an error might be safe, then domain_crash() can change a
-benign failure into a guest denial-of-service.
-
-- ASSERT() will stop the hypervisor during development, but allow
-hypervisor action to continue during production.  In situations where
-continuing will at worst result in a denial-of-service, and at best
-may have little effect other than perhaps quirky behavior, using an
-ASSERT() will allow violation of assumptions to be detected as soon as
-possible, while not causing undue degradation in production
-hypervisors.  However, in situations where continuing could cause
-privilege escalation or information leaks, using an ASSERT() can
-introduce security vulnerabilities.
-
-Note however that domain_crash() has its own traps: callers far up the
-call stack may not realize that the domain is now dying as a result of
-an innocuous-looking operation, particularly if somewhere on the
-callstack between the initial function call and the failure, no error
-is returned.  Using domain_crash() requires careful inspection and
-documentation of the code to make sure all callers at the stack handle
-a newly-dead domain gracefully.
diff --git a/docs/process/coding-best-practices.pandoc b/docs/process/coding-best-practices.pandoc
new file mode 100644
index 0000000000..f611aa9a55
--- /dev/null
+++ b/docs/process/coding-best-practices.pandoc
@@ -0,0 +1,92 @@
+# Best Practices in the Hypervisor
+
+## Handling unexpected conditions
+
+### Guidelines
+
+Passing errors up the stack should be used when the caller is already
+expecting to handle errors, and the state when the error was
+discovered isn’t broken, or isn't too hard to fix.
+
+domain_crash() should be used when passing errors up the stack is too
+difficult, and/or when fixing up state of a guest is impractical, but
+where fixing up the state of Xen will allow Xen to continue running.
+This is particularly appropriate when the guest is exhibiting behavior
+well-behaved guests shouldn't.
+
+BUG_ON() should be used when you can’t pass errors up the stack, and
+either continuing or crashing the guest would likely cause an
+information leak or privilege escalation vulnerability.
+
+ASSERT() IS NOT AN ERROR HANDLING MECHANISM.  ASSERT is a way to move
+detection of a bug earlier in the programming cycle; it is a
+more-noticeable printk.  It should only be added after one of the
+other three error-handling mechanisms has been evaluated for
+reliability and security.
+
+### Rationale
+
+It's frequently the case that code is written with the assumption that
+certain conditions can never happen.  There are several possible
+actions programmers can take in these situations:
+
+ * Programmers can simply not handle those cases in any way, other than
+   perhaps to write a comment documenting what the assumption is.
+ * Programmers can try to handle the case gracefully -- fixing up
+   in-progress state and returning an error to the user.
+ * Programmers can crash the guest.
+ * Programmers can use ASSERT(), which will cause the check to be
+   executed in DEBUG builds, and cause the hypervisor to crash if it's
+   violated
+ * Programmers can use BUG_ON(), which will cause the check to be
+   executed in both DEBUG and non-DEBUG builds, and cause the hypervisor
+   to crash if it's violated.
+
+In selecting which response to use, we want to achieve several goals:
+
+ * To minimize risk of introducing security vulnerabilities,
+   particularly as the code evolves over time
+ * To efficiently spend programmer time
+ * To detect violations of assumptions as early as possible
+ * To minimize the impact of bugs on production use cases
+
+The guidelines above attempt to balance these:
+
+ * When the caller is expecting to handle errors, and there is no
+   broken state at the time the unexpected condition is discovered, or
+   when fixing the state is straightforward, then fixing up the state and
+   returning an error is the most robust thing to do.  However, if the
+   caller isn't expecting to handle errors, or if the state is difficult
+   to fix, then returning an error may require extensive refactoring,
+   which is not a good use of programmer time when they're certain that
+   this condition cannot occur.
+ * BUG_ON() will stop all hypervisor action immediately.  In situations
+   where continuing might allow an attacker to escalate privilege, a
+   BUG_ON() can change a privilege escalation or information leak into a
+   denial-of-service (an improvement).  But in situations where
+   continuing (say, returning an error) might be safe, then BUG_ON() can
+   change a benign failure into denial-of-service (a degradation).
+ * domain_crash() is similar to BUG_ON(), but with a more limited
+   effect: it stops that domain immediately.  In situations where
+   continuing might cause guest or hypervisor corruption, but destroying
+   the guest allows the hypervisor to continue, this can change a more
+   serious bug into a guest denial-of-service.  But in situations where
+   returning an error might be safe, then domain_crash() can change a
+   benign failure into a guest denial-of-service.
+ * ASSERT() will stop the hypervisor during development, but allow
+   hypervisor action to continue during production.  In situations where
+   continuing will at worst result in a denial-of-service, and at best
+   may have little effect other than perhaps quirky behavior, using an
+   ASSERT() will allow violation of assumptions to be detected as soon as
+   possible, while not causing undue degradation in production
+   hypervisors.  However, in situations where continuing could cause
+   privilege escalation or information leaks, using an ASSERT() can
+   introduce security vulnerabilities.
+
+Note however that domain_crash() has its own traps: callers far up the
+call stack may not realize that the domain is now dying as a result of
+an innocuous-looking operation, particularly if somewhere on the
+callstack between the initial function call and the failure, no error
+is returned.  Using domain_crash() requires careful inspection and
+documentation of the code to make sure all callers at the stack handle
+a newly-dead domain gracefully.
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 16 10:55:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 16 Feb 2024 10:55:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682139.1061190 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravrz-0007sO-PS; Fri, 16 Feb 2024 10:55:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682139.1061190; Fri, 16 Feb 2024 10:55:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravrz-0007sG-Mc; Fri, 16 Feb 2024 10:55:03 +0000
Received: by outflank-mailman (input) for mailman id 682139;
 Fri, 16 Feb 2024 10:55:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravry-0007s5-Ei
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravry-0007nt-5p
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravry-0005LK-2Y
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=oOCcSfK8SefxlCSc0QKglMt8aR2NDUGzCFShcwjA1KU=; b=ej8dAubRFZDAo2J1sXmcg5o1tO
	tUsNfOJdn7KxWuCCRSFiytI8Q1zgQQn1RCR5cqUSOZA58gedxrAX7QEBjlZt+sHO0FsqztqY+/n/n
	XZ6RTYzbEJ1G9OkravMzv/OdLG8xaVkM2qwTjlSmWn5cf0RcDsniLa8/ZWAFZ5r4KvM8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools: add a new xen 9pfs daemon
Message-Id: <E1ravry-0005LK-2Y@xenbits.xenproject.org>
Date: Fri, 16 Feb 2024 10:55:02 +0000

commit c3e583b01bd0652af8aed62b2d7dac1d3d57b065
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:49 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools: add a new xen 9pfs daemon
    
    Add "xen-9pfsd", a new 9pfs daemon meant to support infrastructure
    domains (e.g. xenstore-stubdom) to access files in dom0.
    
    For now only add the code needed for starting the daemon and
    registering it with Xenstore via a new "libxl/xen-9pfs/state" node by
    writing the "running" state to it.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/9pfsd/.gitignore  |   1 +
 tools/9pfsd/Makefile    |  38 +++++++++++++
 tools/9pfsd/xen-9pfsd.c | 147 ++++++++++++++++++++++++++++++++++++++++++++++++
 tools/Makefile          |   1 +
 4 files changed, 187 insertions(+)

diff --git a/tools/9pfsd/.gitignore b/tools/9pfsd/.gitignore
new file mode 100644
index 0000000000..d0c2d223ef
--- /dev/null
+++ b/tools/9pfsd/.gitignore
@@ -0,0 +1 @@
+/xen-9pfsd
diff --git a/tools/9pfsd/Makefile b/tools/9pfsd/Makefile
new file mode 100644
index 0000000000..089cf5ae24
--- /dev/null
+++ b/tools/9pfsd/Makefile
@@ -0,0 +1,38 @@
+#
+# tools/9pfsd/Makefile
+#
+
+XEN_ROOT = $(CURDIR)/../..
+include $(XEN_ROOT)/tools/Rules.mk
+
+CFLAGS += $(PTHREAD_CFLAGS)
+LDFLAGS += $(PTHREAD_LDFLAGS)
+
+TARGETS := xen-9pfsd
+
+XEN-9PFSD_OBJS = xen-9pfsd.o
+$(XEN-9PFSD_OBJS): CFLAGS += $(CFLAGS_libxenstore)
+$(XEN-9PFSD_OBJS): CFLAGS += $(CFLAGS_libxenevtchn)
+$(XEN-9PFSD_OBJS): CFLAGS += $(CFLAGS_libxengnttab)
+xen-9pfsd: LDLIBS += $(call xenlibs-ldlibs,store evtchn gnttab)
+
+.PHONY: all
+all: $(TARGETS)
+
+xen-9pfsd: $(XEN-9PFSD_OBJS)
+	$(CC) $(LDFLAGS) -o $@ $(XEN-9PFSD_OBJS) $(LDLIBS) $(APPEND_LDFLAGS)
+
+.PHONY: install
+install: all
+	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
+	for i in $(TARGETS); do $(INSTALL_PROG) $$i $(DESTDIR)$(LIBEXEC_BIN); done
+
+.PHONY: uninstall
+uninstall:
+	for i in $(TARGETS); do rm -f $(DESTDIR)$(LIBEXEC_BIN)/$$i; done
+
+.PHONY: clean
+clean:
+	$(RM) *.o $(TARGETS) $(DEPS_RM)
+
+distclean: clean
diff --git a/tools/9pfsd/xen-9pfsd.c b/tools/9pfsd/xen-9pfsd.c
new file mode 100644
index 0000000000..6939d01574
--- /dev/null
+++ b/tools/9pfsd/xen-9pfsd.c
@@ -0,0 +1,147 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+/*
+ * xen-9pfsd - Xen 9pfs daemon
+ *
+ * Copyright (C) 2024 Juergen Gross <jgross@suse.com>
+ *
+ * Daemon to enable guests to access a directory of the dom0 file system.
+ * Access is made via the 9pfs protocol (xen-9pfsd acts as a PV 9pfs backend).
+ *
+ * Usage: xen-9pfsd
+ *
+ * xen-9pfsd does NOT support writing any links (neither soft links nor hard
+ * links), and it is accepting only canonicalized file paths in order to
+ * avoid the possibility to "escape" from the guest specific directory.
+ *
+ * The backend device string is "xen_9pfs", the tag used for mounting the
+ * 9pfs device is "Xen".
+ *
+ * As an additional security measure the maximum file space used by the guest
+ * can be limited by the backend Xenstore node "max-size" specifying the size
+ * in MBytes. This size includes the size of the root directory of the guest.
+ */
+
+#include <err.h>
+#include <errno.h>
+#include <signal.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <syslog.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <xenevtchn.h>
+#include <xengnttab.h>
+#include <xenstore.h>
+
+static volatile bool stop_me;
+static bool daemon_running;
+static struct xs_handle *xs;
+static xengnttab_handle *xg;
+static xenevtchn_handle *xe;
+
+static void handle_stop(int sig)
+{
+    stop_me = true;
+}
+
+static void close_all(void)
+{
+    if ( daemon_running )
+        xs_rm(xs, XBT_NULL, "libxl/xen-9pfs");
+    if ( xe )
+        xenevtchn_close(xe);
+    if ( xg )
+        xengnttab_close(xg);
+    if ( xs )
+        xs_close(xs);
+    closelog();
+}
+
+static void do_err(const char *msg)
+{
+    syslog(LOG_ALERT, "%s, errno = %d, %s", msg, errno, strerror(errno));
+    close_all();
+    exit(1);
+}
+
+static void xen_connect(void)
+{
+    xs_transaction_t t;
+    char *val;
+    unsigned int len;
+
+    xs = xs_open(0);
+    if ( xs == NULL )
+        do_err("xs_open() failed");
+
+    xg = xengnttab_open(NULL, 0);
+    if ( xg == NULL )
+        do_err("xengnttab_open() failed");
+
+    xe = xenevtchn_open(NULL, 0);
+    if ( xe == NULL )
+        do_err("xenevtchn_open() failed");
+
+    while ( true )
+    {
+        t = xs_transaction_start(xs);
+        if ( t == XBT_NULL )
+            do_err("xs_transaction_start() failed");
+
+        val = xs_read(xs, t, "libxl/xen-9pfs/state", &len);
+        if ( val )
+        {
+            free(val);
+            xs_transaction_end(xs, t, true);
+            syslog(LOG_INFO, "daemon already running");
+            close_all();
+            exit(0);
+        }
+
+        if ( !xs_write(xs, t, "libxl/xen-9pfs/state", "running",
+                       strlen("running")) )
+        {
+            xs_transaction_end(xs, t, true);
+            do_err("xs_write() failed writing state");
+        }
+
+        if ( xs_transaction_end(xs, t, false) )
+            break;
+        if ( errno != EAGAIN )
+            do_err("xs_transaction_end() failed");
+    }
+
+    daemon_running = true;
+}
+
+int main(int argc, char *argv[])
+{
+    struct sigaction act = { .sa_handler = handle_stop, };
+    int syslog_mask = LOG_MASK(LOG_WARNING) | LOG_MASK(LOG_ERR) |
+                      LOG_MASK(LOG_CRIT) | LOG_MASK(LOG_ALERT) |
+                      LOG_MASK(LOG_EMERG);
+
+    umask(027);
+    if ( getenv("XEN_9PFSD_VERBOSE") )
+        syslog_mask |= LOG_MASK(LOG_NOTICE) | LOG_MASK(LOG_INFO);
+    openlog("xen-9pfsd", LOG_CONS, LOG_DAEMON);
+    setlogmask(syslog_mask);
+
+    sigemptyset(&act.sa_mask);
+    sigaction(SIGHUP, &act, NULL);
+
+    xen_connect();
+
+    while ( !stop_me )
+    {
+        sleep(60);
+    }
+
+    close_all();
+
+    return 0;
+}
diff --git a/tools/Makefile b/tools/Makefile
index 3a510663a0..7d17211782 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -32,6 +32,7 @@ SUBDIRS-y += xenpmd
 SUBDIRS-$(CONFIG_GOLANG) += golang
 SUBDIRS-y += xl
 SUBDIRS-y += helpers
+SUBDIRS-y += 9pfsd
 SUBDIRS-$(CONFIG_X86) += xenpaging
 SUBDIRS-$(CONFIG_X86) += debugger
 SUBDIRS-$(CONFIG_TESTS) += tests
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 16 10:55:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 16 Feb 2024 10:55:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682140.1061192 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravs9-0007ua-R4; Fri, 16 Feb 2024 10:55:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682140.1061192; Fri, 16 Feb 2024 10:55:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravs9-0007uT-O3; Fri, 16 Feb 2024 10:55:13 +0000
Received: by outflank-mailman (input) for mailman id 682140;
 Fri, 16 Feb 2024 10:55:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravs8-0007uF-Bj
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravs8-0007o9-9A
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravs8-0005ME-83
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=OSCc+BAv7h+JCsX5E9XeMGkGkVKZ+d1peMcy0eFONfo=; b=LuZPXBVqZww+bslkZCknn4C8V2
	B2frNs8c3F6KF9CP86JfYAvamqv6fLT9mMbOpn3qwg37Ao3Pyh2BUCMfhTTB+WBShkTpa4r1VkLqO
	rpUITUBvpxrR0EgBgBswXiNKbD6h/hKqkBAvatXYnMHy4dphBW0pSI/CqFOLvJPLGzJg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xen-9pfsd: connect to frontend
Message-Id: <E1ravs8-0005ME-83@xenbits.xenproject.org>
Date: Fri, 16 Feb 2024 10:55:12 +0000

commit d43c72a7850df3aaff48b924f471905076a7cc42
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:50 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: connect to frontend
    
    Add the code for connecting to frontends to xenlogd.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/Makefile    |   2 +-
 tools/9pfsd/io.c        |  45 ++++
 tools/9pfsd/xen-9pfsd.c | 653 +++++++++++++++++++++++++++++++++++++++++++++++-
 tools/9pfsd/xen-9pfsd.h |  61 +++++
 4 files changed, 757 insertions(+), 4 deletions(-)

diff --git a/tools/9pfsd/Makefile b/tools/9pfsd/Makefile
index 089cf5ae24..50573121ed 100644
--- a/tools/9pfsd/Makefile
+++ b/tools/9pfsd/Makefile
@@ -10,7 +10,7 @@ LDFLAGS += $(PTHREAD_LDFLAGS)
 
 TARGETS := xen-9pfsd
 
-XEN-9PFSD_OBJS = xen-9pfsd.o
+XEN-9PFSD_OBJS = xen-9pfsd.o io.o
 $(XEN-9PFSD_OBJS): CFLAGS += $(CFLAGS_libxenstore)
 $(XEN-9PFSD_OBJS): CFLAGS += $(CFLAGS_libxenevtchn)
 $(XEN-9PFSD_OBJS): CFLAGS += $(CFLAGS_libxengnttab)
diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
new file mode 100644
index 0000000000..eb7c136e09
--- /dev/null
+++ b/tools/9pfsd/io.c
@@ -0,0 +1,45 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+/*
+ * xen-9pfsd - Xen 9pfs daemon
+ *
+ * Copyright (C) 2024 Juergen Gross <jgross@suse.com>
+ *
+ * I/O thread handling.
+ */
+
+#include <stdbool.h>
+#include <string.h>
+#include <syslog.h>
+
+#include "xen-9pfsd.h"
+
+static bool io_work_pending(struct ring *ring)
+{
+    if ( ring->stop_thread )
+        return true;
+    return false;
+}
+
+void *io_thread(void *arg)
+{
+    struct ring *ring = arg;
+
+    while ( !ring->stop_thread )
+    {
+        pthread_mutex_lock(&ring->mutex);
+        if ( !io_work_pending(ring) )
+        {
+            if ( xenevtchn_unmask(xe, ring->evtchn) < 0 )
+                syslog(LOG_WARNING, "xenevtchn_unmask() failed");
+            pthread_cond_wait(&ring->cond, &ring->mutex);
+        }
+        pthread_mutex_unlock(&ring->mutex);
+
+        /* TODO: I/O handling. */
+    }
+
+    ring->thread_active = false;
+
+    return NULL;
+}
diff --git a/tools/9pfsd/xen-9pfsd.c b/tools/9pfsd/xen-9pfsd.c
index 6939d01574..73b6c3a30e 100644
--- a/tools/9pfsd/xen-9pfsd.c
+++ b/tools/9pfsd/xen-9pfsd.c
@@ -24,34 +24,632 @@
 
 #include <err.h>
 #include <errno.h>
+#include <fcntl.h>
+#include <poll.h>
+#include <pthread.h>
 #include <signal.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <syslog.h>
+#include <sys/mman.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
-#include <xenevtchn.h>
 #include <xengnttab.h>
 #include <xenstore.h>
 
+#include "xen-9pfsd.h"
+
+/*
+ * List of currently known devices.
+ * The list itself is modified only in the main thread. When a device is being
+ * removed its memory needs to be freed after the I/O thread (if existing)
+ * has stopped.
+ */
+static XEN_TAILQ_HEAD(devhead, device) devs = XEN_TAILQ_HEAD_INITIALIZER(devs);
+
+struct path {
+    char path[100];
+};
+
 static volatile bool stop_me;
 static bool daemon_running;
 static struct xs_handle *xs;
 static xengnttab_handle *xg;
-static xenevtchn_handle *xe;
+static unsigned int now;
+
+xenevtchn_handle *xe;
 
 static void handle_stop(int sig)
 {
     stop_me = true;
 }
 
+static int check_host_path(device *device)
+{
+    struct stat statbuf;
+    char *path, *p;
+    int ret = 1;
+
+    if ( !device->host_path )
+        return 1;
+
+    /* Path must be absolute. */
+    if ( device->host_path[0] != '/' )
+        return 1;
+
+    /* No double "/". */
+    if ( strstr(device->host_path, "//") )
+        return 1;
+
+    /* No trailing "/" (includes refusing to share "/"). */
+    if ( device->host_path[strlen(device->host_path) - 1] == '/' )
+        return 1;
+
+    path = strdup(device->host_path);
+    if ( !path )
+    {
+        syslog(LOG_CRIT, "memory allocation failure!");
+        return 1;
+    }
+
+    for ( p = path; p; )
+    {
+        p = strchr(p + 1, '/');
+        if ( p )
+            *p = 0;
+        if ( !stat(path, &statbuf) )
+        {
+            if ( !(statbuf.st_mode & S_IFDIR) )
+                break;
+            if ( !p )
+            {
+                ret = 0;
+                break;
+            }
+            *p = '/';
+            continue;
+        }
+        if ( mkdir(path, 0777) )
+            break;
+        if ( p )
+            *p = '/';
+    }
+
+    free(path);
+    return ret;
+}
+
+static void construct_frontend_path(device *device, const char *node,
+                                    struct path *p)
+{
+    snprintf(p->path, sizeof(p->path), "/local/domain/%u/device/9pfs/%u/%s",
+             device->domid, device->devid, node);
+}
+
+static void construct_backend_path(device *device, const char *node,
+                                   struct path *p)
+{
+    snprintf(p->path, sizeof(p->path), "backend/xen_9pfs/%u/%u/%s",
+             device->domid, device->devid, node);
+}
+
+static char *read_backend_node(device *device, const char *node)
+{
+    struct path p;
+    char *val;
+    unsigned int len;
+
+    construct_backend_path(device, node, &p);
+    val = xs_read(xs, XBT_NULL, p.path, &len);
+
+    return val;
+}
+
+static unsigned int uint_from_string(char *string, unsigned int def)
+{
+    unsigned long val;
+    char *end;
+
+    if ( !string )
+        return def;
+
+    val = strtoul(string, &end, 10);
+    if ( *end || val > UINT_MAX )
+        val = def;
+    free(string);
+
+    return val;
+}
+
+static unsigned int read_backend_node_uint(device *device, const char *node,
+                                           unsigned int def)
+{
+    return uint_from_string(read_backend_node(device, node), def);
+}
+
+static unsigned int read_frontend_node_uint(device *device, const char *node,
+                                            unsigned int def)
+{
+    struct path p;
+    unsigned int len;
+
+    construct_frontend_path(device, node, &p);
+
+    return uint_from_string(xs_read(xs, XBT_NULL, p.path, &len), def);
+}
+
+static bool write_backend_node(device *device, const char *node,
+                               const char *val)
+{
+    struct path p;
+    unsigned int num_perms;
+    struct xs_permissions *old_perms;
+    struct xs_permissions perms[2] = {
+        { .id = 0, .perms = XS_PERM_NONE },
+        { .id = device->domid, .perms = XS_PERM_READ }
+    };
+
+    construct_backend_path(device, node, &p);
+    if ( !xs_write(xs, XBT_NULL, p.path, val, strlen(val)) )
+    {
+        syslog(LOG_ERR, "error writing bacḱend node \"%s\" for device %u/%u",
+               node, device->domid, device->devid);
+        return false;
+    }
+
+    old_perms = xs_get_permissions(xs, XBT_NULL, p.path, &num_perms);
+    if ( !old_perms )
+    {
+        syslog(LOG_ERR, "error getting permissions for \"%s\"", p.path);
+        return false;
+    }
+
+    perms[0] = old_perms[0];
+    free(old_perms);
+    if ( !xs_set_permissions(xs, XBT_NULL, p.path, perms, 2) )
+    {
+        syslog(LOG_ERR, "error setting permissions for \"%s\"", p.path);
+        return false;
+    }
+
+    return true;
+}
+
+static bool write_backend_node_uint(device *device, const char *node,
+                                   unsigned int val)
+{
+    char str[12];
+
+    snprintf(str, sizeof(str), "%u", val);
+
+    return write_backend_node(device, node, str);
+}
+
+static bool write_backend_state(device *device, enum xenbus_state state)
+{
+    struct path p;
+    char val[2];
+
+    snprintf(val, sizeof(val), "%u", state);
+    construct_backend_path(device, "state", &p);
+    if ( !xs_write(xs, XBT_NULL, p.path, val, 1) )
+    {
+        syslog(LOG_ERR, "error writing backend state %u for device %u/%u",
+               state, device->domid, device->devid);
+        return false;
+    }
+
+    device->backend_state = state;
+
+    return true;
+}
+
+static device *find_device(unsigned int domid, unsigned int devid)
+{
+    device *device;
+
+    XEN_TAILQ_FOREACH( device, &devs, list )
+    {
+        if ( domid == device->domid && devid == device->devid )
+            return device;
+    }
+
+    return NULL;
+}
+
+static void free_device(device *device)
+{
+    char token[20];
+    struct path p;
+
+    construct_frontend_path(device, "state", &p);
+    snprintf(token, sizeof(token), "%u/%u", device->domid, device->devid);
+    xs_unwatch(xs, p.path, token);
+
+    if ( device->root_fd >= 0 )
+        close(device->root_fd);
+
+    free(device->host_path);
+    free(device);
+}
+
+static device *new_device(unsigned int domid, unsigned int devid)
+{
+    device *device;
+    char token[20];
+    struct path p;
+    char *val;
+
+    device = calloc(1, sizeof(*device));
+    if ( !device )
+    {
+        syslog(LOG_CRIT, "Got no memory for new device %u/%u", domid, devid);
+        return NULL;
+    }
+
+    device->domid = domid;
+    device->devid = devid;
+    device->root_fd = -1;
+
+    construct_frontend_path(device, "state", &p);
+    snprintf(token, sizeof(token), "%u/%u", domid, devid);
+    if ( !xs_watch(xs, p.path, token) )
+    {
+        syslog(LOG_ERR, "Setting up watch for device %u/%u failed",
+               domid, devid);
+        free(device);
+        return NULL;
+    }
+
+    val = read_backend_node(device, "security_model");
+    if ( !val || strcmp(val, "none") )
+    {
+        syslog(LOG_ERR, "Security model \"%s\" for device %u/%u invalid.",
+               val, domid, devid);
+        free(val);
+        goto err;
+    }
+    free(val);
+
+    device->max_space = read_backend_node_uint(device, "max-space", 0);
+    device->max_files = read_backend_node_uint(device, "max-files", 0);
+    device->max_open_files =
+        read_backend_node_uint(device, "max-open-files", 0)
+        ?: MAX_OPEN_FILES_DEFAULT;
+    device->auto_delete = read_backend_node_uint(device, "auto-delete", 0);
+
+    device->host_path = read_backend_node(device, "path");
+    if ( check_host_path(device) )
+    {
+        syslog(LOG_ERR, "Host path \"%s\" for device %u/%u invalid.",
+               device->host_path, domid, devid);
+        goto err;
+    }
+    device->root_fd = open(device->host_path, O_RDONLY | O_DIRECTORY);
+    if ( device->root_fd < 0 )
+        goto err;
+
+    if ( !write_backend_node(device, "versions", "1") )
+        goto err;
+    if ( !write_backend_node_uint(device, "max-rings", MAX_RINGS) )
+        goto err;
+    if ( !write_backend_node_uint(device, "max-ring-page-order",
+                                 MAX_RING_ORDER) )
+        goto err;
+
+    if ( !write_backend_state(device, XenbusStateInitWait) )
+        goto err;
+
+    XEN_TAILQ_INSERT_TAIL(&devs, device, list);
+    syslog(LOG_INFO, "New device %u/%u added", domid, devid);
+
+    return device;
+
+ err:
+    free_device(device);
+    return NULL;
+}
+
+static void disconnect_ring(struct ring *ring)
+{
+    if ( !ring )
+        return;
+
+    if ( ring->thread_active )
+    {
+        ring->stop_thread = true;
+        pthread_cond_signal(&ring->cond);
+        pthread_join(ring->thread, NULL);
+        ring->stop_thread = false;
+    }
+
+    if ( ring->data.in )
+    {
+        xengnttab_unmap(xg, ring->data.in, 1 << ring->ring_order);
+        ring->data.in = NULL;
+    }
+    if ( ring->intf )
+    {
+        xengnttab_unmap(xg, ring->intf, 1 );
+        ring->intf = NULL;
+    }
+
+    if ( ring->evtchn )
+    {
+        xenevtchn_unbind(xe, ring->evtchn);
+        ring->evtchn = 0;
+    }
+
+    pthread_mutex_destroy(&ring->mutex);
+    pthread_cond_destroy(&ring->cond);
+}
+
+static void disconnect_guest(device *device)
+{
+    unsigned int ring_idx;
+
+    for ( ring_idx = 0; ring_idx < device->num_rings; ring_idx++ )
+    {
+        disconnect_ring(device->ring[ring_idx]);
+        free(device->ring[ring_idx]);
+        device->ring[ring_idx] = NULL;
+    }
+
+    device->num_rings = 0;
+}
+
+static void close_device(device *device, enum xenbus_state state)
+{
+    disconnect_guest(device);
+    write_backend_state(device, state);
+}
+
+static void connect_err(device *device, const char *msg)
+{
+    syslog(LOG_WARNING, "%s", msg);
+    close_device(device, XenbusStateClosed);
+}
+
+static void connect_device(device *device)
+{
+    unsigned int val;
+    unsigned int ring_idx;
+    char node[20];
+    struct ring *ring;
+    xenevtchn_port_or_error_t evtchn;
+
+    val = read_frontend_node_uint(device, "version", 0);
+    if ( val != 1 )
+        return connect_err(device, "frontend specifies illegal version");
+    device->num_rings = read_frontend_node_uint(device, "num-rings", 0);
+    if ( device->num_rings < 1 || device->num_rings > MAX_RINGS )
+        return connect_err(device, "frontend specifies illegal ring number");
+
+    for ( ring_idx = 0; ring_idx < device->num_rings; ring_idx++ )
+    {
+        ring = calloc(1, sizeof(*ring));
+        if ( !ring )
+            return connect_err(device, "could not allocate ring memory");
+        device->ring[ring_idx] = ring;
+        ring->device = device;
+        pthread_cond_init(&ring->cond, NULL);
+        pthread_mutex_init(&ring->mutex, NULL);
+
+        snprintf(node, sizeof(node), "event-channel-%u", ring_idx);
+        val = read_frontend_node_uint(device, node, 0);
+        if ( val == 0 )
+            return connect_err(device, "frontend specifies illegal evtchn");
+        evtchn = xenevtchn_bind_interdomain(xe, device->domid, val);
+        if ( evtchn < 0 )
+            return connect_err(device, "could not bind to event channel");
+        ring->evtchn = evtchn;
+
+        snprintf(node, sizeof(node), "ring-ref%u", ring_idx);
+        val = read_frontend_node_uint(device, node, 0);
+        if ( val == 0 )
+            return connect_err(device,
+                               "frontend specifies illegal grant for ring");
+        ring->intf = xengnttab_map_grant_ref(xg, device->domid, val,
+                                             PROT_READ | PROT_WRITE);
+        if ( !ring->intf )
+            return connect_err(device, "could not map interface page");
+        ring->ring_order = ring->intf->ring_order;
+        if ( ring->ring_order > MAX_RING_ORDER || ring->ring_order < 1 )
+            return connect_err(device, "frontend specifies illegal ring order");
+        ring->ring_size = XEN_FLEX_RING_SIZE(ring->ring_order);
+        ring->data.in = xengnttab_map_domain_grant_refs(xg,
+                                                        1 << ring->ring_order,
+                                                        device->domid,
+                                                        ring->intf->ref,
+                                                        PROT_READ | PROT_WRITE);
+        if ( !ring->data.in )
+            return connect_err(device, "could not map ring pages");
+        ring->data.out = ring->data.in + ring->ring_size;
+
+        if ( pthread_create(&ring->thread, NULL, io_thread, ring) )
+            return connect_err(device, "could not start I/O thread");
+        ring->thread_active = true;
+    }
+
+    write_backend_state(device, XenbusStateConnected);
+}
+
+static void remove_device(device *device)
+{
+    XEN_TAILQ_REMOVE(&devs, device, list);
+
+    disconnect_guest(device);
+    free_device(device);
+}
+
+static void remove_all_devices(void)
+{
+    device *device, *tmp;
+
+    XEN_TAILQ_FOREACH_SAFE( device, &devs, list, tmp )
+        remove_device(device);
+}
+
+static void frontend_changed(device *device)
+{
+    struct path p;
+    char *state, *end;
+    unsigned int len;
+    unsigned long new_state;
+
+    construct_frontend_path(device, "state", &p);
+    state = xs_read(xs, XBT_NULL, p.path, &len);
+    if ( !state )
+    {
+        close_device(device, XenbusStateClosed);
+        return;
+    }
+
+    new_state = strtoul(state, &end, 10);
+    if ( *end || new_state > XenbusStateReconfigured )
+    {
+        syslog(LOG_WARNING, "unknown state \"%s\" seen for device %u/%u", state,
+               device->domid, device->devid);
+        new_state = XenbusStateUnknown;
+    }
+    free(state);
+
+    if ( new_state == device->frontend_state )
+        return;
+
+    switch ( new_state )
+    {
+    case XenbusStateInitialising:
+        break;
+
+    case XenbusStateInitialised:
+        connect_device(device);
+        break;
+
+    case XenbusStateConnected:
+        break;
+
+    case XenbusStateClosing:
+        close_device(device, XenbusStateClosing);
+        break;
+
+    case XenbusStateClosed:
+        close_device(device, XenbusStateClosed);
+        break;
+
+    default:
+        syslog(LOG_WARNING, "not handled frontend state %lu for device %u/%u",
+               new_state, device->domid, device->devid);
+        break;
+    }
+
+    device->frontend_state = new_state;
+}
+
+static void check_device(unsigned int domid, unsigned int devid)
+{
+    device *device;
+
+    device = find_device(domid, devid);
+    if ( !device )
+    {
+        device = new_device(domid, devid);
+        if ( !device )
+            return;
+    }
+
+    device->last_seen = now;
+}
+
+static void scan_backend(void)
+{
+    char **doms;
+    unsigned int n_doms, dom;
+    char **devices;
+    unsigned int n_devs, dev;
+    char dom_path[24];
+    unsigned long domid, devid;
+    char *end;
+    device *device, *tmp;
+
+    now++;
+
+    doms = xs_directory(xs, XBT_NULL, "backend/xen_9pfs", &n_doms);
+    if ( doms == NULL )
+        return;
+
+    for ( dom = 0; dom < n_doms; dom++ )
+    {
+        errno = 0;
+        domid = strtoul(doms[dom], &end, 10);
+        if ( errno || *end || domid >= DOMID_FIRST_RESERVED )
+            continue;
+
+        snprintf(dom_path, sizeof(dom_path), "backend/xen_9pfs/%lu", domid);
+        devices = xs_directory(xs, XBT_NULL, dom_path, &n_devs);
+
+        for ( dev = 0; dev < n_devs; dev++ )
+        {
+            errno = 0;
+            devid = strtoul(devices[dev], &end, 10);
+            if ( errno || *end || devid > UINT_MAX )
+                continue;
+
+            check_device(domid, devid);
+        }
+
+        free(devices);
+    }
+
+    free(doms);
+
+    XEN_TAILQ_FOREACH_SAFE( device, &devs, list, tmp )
+    {
+        if ( device->last_seen != now )
+            remove_device(device);
+    }
+}
+
+static void handle_watch(char *path, char *token)
+{
+    unsigned int domid, devid;
+    device *device;
+
+    if ( !strcmp(token, "main") )
+    {
+        scan_backend();
+        return;
+    }
+
+    if ( sscanf(token, "%u/%u", &domid, &devid) != 2 )
+    {
+        syslog(LOG_WARNING, "unknown watch event %s %s", path, token);
+        return;
+    }
+
+    device = find_device(domid, devid);
+    if ( !device )
+    {
+        syslog(LOG_WARNING, "watch event for unknown device %u/%u",
+               domid, devid);
+        return;
+    }
+
+    frontend_changed(device);
+}
+
 static void close_all(void)
 {
     if ( daemon_running )
+    {
         xs_rm(xs, XBT_NULL, "libxl/xen-9pfs");
+        xs_unwatch(xs, "backend/xen_9pfs", "main");
+
+        remove_all_devices();
+    }
     if ( xe )
         xenevtchn_close(xe);
     if ( xg )
@@ -68,6 +666,33 @@ static void do_err(const char *msg)
     exit(1);
 }
 
+static void handle_event(void)
+{
+    xenevtchn_port_or_error_t evtchn;
+    device *device;
+    struct ring *ring;
+    unsigned int ring_idx;
+
+    evtchn = xenevtchn_pending(xe);
+    if ( evtchn < 0 )
+        do_err("xenevtchn_pending() failed");
+
+    XEN_TAILQ_FOREACH( device, &devs, list )
+    {
+        for ( ring_idx = 0; ring_idx < device->num_rings; ring_idx++ )
+        {
+            ring = device->ring[ring_idx];
+            if ( ring && ring->evtchn == evtchn )
+            {
+                pthread_mutex_lock(&ring->mutex);
+                pthread_cond_signal(&ring->cond);
+                pthread_mutex_unlock(&ring->mutex);
+                return;
+            }
+        }
+    }
+}
+
 static void xen_connect(void)
 {
     xs_transaction_t t;
@@ -124,6 +749,11 @@ int main(int argc, char *argv[])
     int syslog_mask = LOG_MASK(LOG_WARNING) | LOG_MASK(LOG_ERR) |
                       LOG_MASK(LOG_CRIT) | LOG_MASK(LOG_ALERT) |
                       LOG_MASK(LOG_EMERG);
+    char **watch;
+    struct pollfd p[2] = {
+        { .events = POLLIN },
+        { .events = POLLIN }
+    };
 
     umask(027);
     if ( getenv("XEN_9PFSD_VERBOSE") )
@@ -136,9 +766,26 @@ int main(int argc, char *argv[])
 
     xen_connect();
 
+    if ( !xs_watch(xs, "backend/xen_9pfs", "main") )
+        do_err("xs_watch() in main thread failed");
+    p[0].fd = xs_fileno(xs);
+    p[1].fd = xenevtchn_fd(xe);
+
+    scan_backend();
+
     while ( !stop_me )
     {
-        sleep(60);
+        while ( (p[0].revents & POLLIN) &&
+                (watch = xs_check_watch(xs)) != NULL )
+        {
+            handle_watch(watch[XS_WATCH_PATH], watch[XS_WATCH_TOKEN]);
+            free(watch);
+        }
+
+        if ( p[1].revents & POLLIN )
+            handle_event();
+
+        poll(p, 2, -1);
     }
 
     close_all();
diff --git a/tools/9pfsd/xen-9pfsd.h b/tools/9pfsd/xen-9pfsd.h
new file mode 100644
index 0000000000..ff3562164a
--- /dev/null
+++ b/tools/9pfsd/xen-9pfsd.h
@@ -0,0 +1,61 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef XEN_9PFSD_H
+#define XEN_9PFSD_H
+
+#include <pthread.h>
+#include <stdbool.h>
+#include <xenevtchn.h>
+#include <xen_list.h>
+#include <xen/xen.h>
+#include <xen/io/xenbus.h>
+#include <xen/io/9pfs.h>
+
+#define MAX_RINGS                4
+#define MAX_RING_ORDER           9
+#define MAX_OPEN_FILES_DEFAULT   5
+
+typedef struct device device;
+
+struct ring {
+    device *device;
+    pthread_t thread;
+    bool thread_active;
+    bool stop_thread;
+    pthread_cond_t cond;
+    pthread_mutex_t mutex;
+
+    evtchn_port_t evtchn;
+    struct xen_9pfs_data_intf *intf;
+    unsigned int ring_order;
+    RING_IDX ring_size;
+    struct xen_9pfs_data data;
+};
+
+struct device {
+    /* Admin data. */
+    XEN_TAILQ_ENTRY(device) list;
+    unsigned int last_seen;    /* Set in scan_backend(). */
+    unsigned int domid;
+    unsigned int devid;
+
+    /* Tool side configuration data. */
+    char *host_path;
+    unsigned int max_space;
+    unsigned int max_files;
+    unsigned int max_open_files;
+    bool auto_delete;
+
+    /* Connection data. */
+    enum xenbus_state backend_state;
+    enum xenbus_state frontend_state;
+    unsigned int num_rings;
+    struct ring *ring[MAX_RINGS];
+    int root_fd;
+};
+
+extern xenevtchn_handle *xe;
+
+void *io_thread(void *arg);
+
+#endif /* XEN_9PFSD_H */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 16 10:55:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 16 Feb 2024 10:55:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682141.1061197 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravsJ-0007xW-Tx; Fri, 16 Feb 2024 10:55:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682141.1061197; Fri, 16 Feb 2024 10:55:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravsJ-0007xP-RR; Fri, 16 Feb 2024 10:55:23 +0000
Received: by outflank-mailman (input) for mailman id 682141;
 Fri, 16 Feb 2024 10:55:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravsI-0007xA-DS
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravsI-0007oW-Cj
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravsI-0005Me-BL
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=oowD8CWv/4N0KSfa3i8+H2cpmtt95uaHx/o+ohLfpSw=; b=LLgQmASlpc06HcpoF6NFCWArPH
	2GZYSprNR4ABY+i6VJxdSFqr9ZW5EG3Fc6QRB98YnG732jGiMvsTedwDZcDyoE/qup3zMxSNJPOs7
	4dLYRHbUPa5i0o2LTbLOe8ubEE4pLV7jfxWCCzqXWwTDAjFbJf9qpMse3f0JD0vOwBQA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xen-9pfsd: add transport layer
Message-Id: <E1ravsI-0005Me-BL@xenbits.xenproject.org>
Date: Fri, 16 Feb 2024 10:55:22 +0000

commit 8219809423a6c2164e4f036ae418087a39f40dd1
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:51 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add transport layer
    
    Add the transport layer of 9pfs. This is basically the infrastructure
    to receive requests from the frontend and to send the related answers
    via the rings.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/9pfsd/io.c        | 143 +++++++++++++++++++++++++++++++++++++++++++++++-
 tools/9pfsd/xen-9pfsd.h |  16 ++++++
 2 files changed, 156 insertions(+), 3 deletions(-)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index eb7c136e09..996017a8be 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -6,39 +6,176 @@
  * Copyright (C) 2024 Juergen Gross <jgross@suse.com>
  *
  * I/O thread handling.
+ *
+ * Only handle one request at a time, pushing out the complete response
+ * before looking for the next request.
  */
 
 #include <stdbool.h>
+#include <stdlib.h>
 #include <string.h>
 #include <syslog.h>
+#include <xenctrl.h>           /* For cpu barriers. */
+#include <xen-tools/common-macros.h>
 
 #include "xen-9pfsd.h"
 
+/*
+ * Note that the ring names "in" and "out" are from the frontend's
+ * perspective, so the "in" ring will be used for responses to the frontend,
+ * while the "out" ring is used for requests from the frontend to the
+ * backend.
+ */
+static unsigned int ring_in_free(struct ring *ring)
+{
+    unsigned int queued;
+
+    queued = xen_9pfs_queued(ring->prod_pvt_in, ring->intf->in_cons,
+                             ring->ring_size);
+    xen_rmb();
+
+    return ring->ring_size - queued;
+}
+
+static unsigned int ring_out_data(struct ring *ring)
+{
+    unsigned int queued;
+
+    queued = xen_9pfs_queued(ring->intf->out_prod, ring->cons_pvt_out,
+                             ring->ring_size);
+    xen_rmb();
+
+    return queued;
+}
+
+static unsigned int get_request_bytes(struct ring *ring, unsigned int off,
+                                      unsigned int total_len)
+{
+    unsigned int size;
+    unsigned int out_data = ring_out_data(ring);
+    RING_IDX prod, cons;
+
+    size = min(total_len - off, out_data);
+    prod = xen_9pfs_mask(ring->intf->out_prod, ring->ring_size);
+    cons = xen_9pfs_mask(ring->cons_pvt_out, ring->ring_size);
+    xen_9pfs_read_packet(ring->buffer + off, ring->data.out, size,
+                         prod, &cons, ring->ring_size);
+
+    xen_rmb();           /* Read data out before setting visible consumer. */
+    ring->cons_pvt_out += size;
+    ring->intf->out_cons = ring->cons_pvt_out;
+
+    /* Signal that more space is available now. */
+    xenevtchn_notify(xe, ring->evtchn);
+
+    return size;
+}
+
+static unsigned int put_response_bytes(struct ring *ring, unsigned int off,
+                                       unsigned int total_len)
+{
+    unsigned int size;
+    unsigned int in_data = ring_in_free(ring);
+    RING_IDX prod, cons;
+
+    size = min(total_len - off, in_data);
+    prod = xen_9pfs_mask(ring->prod_pvt_in, ring->ring_size);
+    cons = xen_9pfs_mask(ring->intf->in_cons, ring->ring_size);
+    xen_9pfs_write_packet(ring->data.in, ring->buffer + off, size,
+                          &prod, cons, ring->ring_size);
+
+    xen_wmb();           /* Write data out before setting visible producer. */
+    ring->prod_pvt_in += size;
+    ring->intf->in_prod = ring->prod_pvt_in;
+
+    return size;
+}
+
 static bool io_work_pending(struct ring *ring)
 {
     if ( ring->stop_thread )
         return true;
-    return false;
+    if ( ring->error )
+        return false;
+    return ring->handle_response ? ring_in_free(ring) : ring_out_data(ring);
 }
 
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
+    unsigned int count = 0;
+    struct p9_header hdr = { .size = 0 };
+    bool in_hdr = true;
+
+    ring->max_size = ring->ring_size;
+    ring->buffer = malloc(ring->max_size);
+    if ( !ring->buffer )
+    {
+        syslog(LOG_CRIT, "memory allocation failure!");
+        return NULL;
+    }
 
     while ( !ring->stop_thread )
     {
         pthread_mutex_lock(&ring->mutex);
         if ( !io_work_pending(ring) )
         {
-            if ( xenevtchn_unmask(xe, ring->evtchn) < 0 )
+            if ( !ring->error && xenevtchn_unmask(xe, ring->evtchn) < 0 )
                 syslog(LOG_WARNING, "xenevtchn_unmask() failed");
             pthread_cond_wait(&ring->cond, &ring->mutex);
         }
         pthread_mutex_unlock(&ring->mutex);
 
-        /* TODO: I/O handling. */
+        if ( ring->stop_thread || ring->error )
+            continue;
+
+        if ( !ring->handle_response )
+        {
+            if ( in_hdr )
+            {
+                count += get_request_bytes(ring, count, sizeof(hdr));
+                if ( count != sizeof(hdr) )
+                    continue;
+                hdr = *(struct p9_header *)ring->buffer;
+                if ( hdr.size > ring->max_size || hdr.size < sizeof(hdr) )
+                {
+                    syslog(LOG_ERR, "%u.%u specified illegal request length %u",
+                           ring->device->domid, ring->device->devid, hdr.size);
+                    ring->error = true;
+                    continue;
+                }
+                in_hdr = false;
+            }
+
+            count += get_request_bytes(ring, count, hdr.size);
+            if ( count < hdr.size )
+                continue;
+
+            /* TODO: handle request (will rewrite hdr.size). */
+
+            ring->handle_response = true;
+            hdr.size = ((struct p9_header *)ring->buffer)->size;
+            count = 0;
+        }
+
+        if ( ring->handle_response )
+        {
+            count += put_response_bytes(ring, count, hdr.size);
+
+            if ( count == hdr.size )
+            {
+                /* Signal presence of response. */
+                xenevtchn_notify(xe, ring->evtchn);
+
+                ring->handle_response = false;
+                in_hdr = true;
+                count = 0;
+            }
+        }
     }
 
+    free(ring->buffer);
+
     ring->thread_active = false;
 
     return NULL;
diff --git a/tools/9pfsd/xen-9pfsd.h b/tools/9pfsd/xen-9pfsd.h
index ff3562164a..d587f59a32 100644
--- a/tools/9pfsd/xen-9pfsd.h
+++ b/tools/9pfsd/xen-9pfsd.h
@@ -15,6 +15,12 @@
 #define MAX_RING_ORDER           9
 #define MAX_OPEN_FILES_DEFAULT   5
 
+struct p9_header {
+    uint32_t size;
+    uint8_t cmd;
+    uint16_t tag;
+} __attribute__((packed));
+
 typedef struct device device;
 
 struct ring {
@@ -29,7 +35,17 @@ struct ring {
     struct xen_9pfs_data_intf *intf;
     unsigned int ring_order;
     RING_IDX ring_size;
+
+    /* Transport layer data. */
     struct xen_9pfs_data data;
+    RING_IDX prod_pvt_in;
+    RING_IDX cons_pvt_out;
+
+    /* Request and response handling. */
+    uint32_t max_size;
+    bool error;             /* Protocol error - stop processing. */
+    bool handle_response;   /* Main loop now handling response. */
+    void *buffer;           /* Request/response buffer. */
 };
 
 struct device {
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 16 10:55:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 16 Feb 2024 10:55:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682142.1061201 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravsT-00080E-Vk; Fri, 16 Feb 2024 10:55:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682142.1061201; Fri, 16 Feb 2024 10:55:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravsT-000806-TA; Fri, 16 Feb 2024 10:55:33 +0000
Received: by outflank-mailman (input) for mailman id 682142;
 Fri, 16 Feb 2024 10:55:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravsS-0007zt-Gi
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravsS-0007od-Ft
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravsS-0005N3-F0
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Tj9aKUYUGZ/D5LlvduOIvs00ubZA0fEDKJODyiPLUJA=; b=g/uPK7P4KXszF9kD5iIHbCjQSq
	PVr6yLhv/8zsbRBLg3niEnBFlbfKou/Rhzl0H3VOwfRqq8dfuxanJEvj7TGli82mW6thhlECl2TwV
	94XYf+8cCyXW3HbaGP2D9gVLuVdQdAR7/NllxFZLE5TAV6L6ryEEOXEBS2M4GZYYt89A=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xen-9pfsd: add 9pfs response generation support
Message-Id: <E1ravsS-0005N3-F0@xenbits.xenproject.org>
Date: Fri, 16 Feb 2024 10:55:32 +0000

commit 7809132b1a1d2c8b36ec28c296230e06bb7401e3
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:52 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs response generation support
    
    Add support for generation a 9pfs protocol response via a format based
    approach.
    
    Strings are stored in a per device string buffer and they are
    referenced via their offset in this buffer. This allows to avoid
    having to dynamically allocate memory for each single string.
    
    As a first user of the response handling add a generic p9_error()
    function which will be used to return any error to the client.
    
    Add all format parsing variants in order to avoid additional code churn
    later when adding the users of those variants. Prepare a special case
    for the "read" case already (format character 'D'): in order to avoid
    adding another buffer for read data support doing the read I/O directly
    into the response buffer.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/io.c        | 217 +++++++++++++++++++++++++++++++++++++++++++++++-
 tools/9pfsd/xen-9pfsd.h |   3 +
 2 files changed, 219 insertions(+), 1 deletion(-)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 996017a8be..12539677df 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -11,6 +11,7 @@
  * before looking for the next request.
  */
 
+#include <errno.h>
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
@@ -20,6 +21,16 @@
 
 #include "xen-9pfsd.h"
 
+/* P9 protocol commands (response is either cmd+1 or P9_CMD_ERROR). */
+#define P9_CMD_ERROR      107
+
+struct p9_qid {
+    uint8_t type;
+#define QID_TYPE_DIR      0x80
+    uint32_t version;
+    uint64_t path;
+};
+
 /*
  * Note that the ring names "in" and "out" are from the frontend's
  * perspective, so the "in" ring will be used for responses to the frontend,
@@ -100,6 +111,200 @@ static bool io_work_pending(struct ring *ring)
     return ring->handle_response ? ring_in_free(ring) : ring_out_data(ring);
 }
 
+static void fmt_err(const char *fmt)
+{
+    syslog(LOG_CRIT, "illegal format %s passed to fill_buffer()", fmt);
+    exit(1);
+}
+
+/*
+ * Fill buffer with response data.
+ * fmt is a sequence of format characters. Supported characters are:
+ * a: an array (2 bytes number of elements + the following format as elements)
+ *    The number of elements is passed in the first unsigned int parameter, the
+ *    next parameter is a pointer to an array of elements as denoted by the next
+ *    format character.
+ * b: 1 byte unsigned integer
+ * u: 2 byte unsigned integer
+ *    The parameter is a pointer to a uint16_t value
+ * D: Data blob (4 byte length + <length> bytes)
+ *    2 parameters are consumed, first an unsigned int for the length, then a
+ *    pointer to the first uint8_t value.
+ *    No array support.
+ * L: 8 byte unsigned integer
+ *    The parameter is a pointer to a uint64_t value
+ * Q: Qid (struct p9_qid)
+ * S: String (2 byte length + <length> characters)
+ *    The length is obtained via strlen() of the parameter, being a pointer
+ *    to the first character of the string
+ * U: 4 byte unsigned integer
+ *    The parameter is a pointer to a uint32_t value
+ */
+static void fill_buffer_at(void **data, const char *fmt, ...);
+static void vfill_buffer_at(void **data, const char *fmt, va_list ap)
+{
+    const char *f;
+    const void *par;
+    const char *str_val;
+    const struct p9_qid *qid;
+    unsigned int len;
+    unsigned int array_sz = 0;
+    unsigned int elem_sz = 0;
+
+    for ( f = fmt; *f; f++ )
+    {
+        if ( !array_sz )
+            par = va_arg(ap, const void *);
+        else
+        {
+            par += elem_sz;
+            array_sz--;
+        }
+
+        switch ( *f )
+        {
+        case 'a':
+            f++;
+            if ( !*f || array_sz )
+                fmt_err(fmt);
+            array_sz = *(const unsigned int *)par;
+            if ( array_sz > 0xffff )
+            {
+                syslog(LOG_CRIT, "array size %u in fill_buffer()", array_sz);
+                exit(1);
+            }
+            put_unaligned(array_sz, (uint16_t *)*data);
+            *data += sizeof(uint16_t);
+            par = va_arg(ap, const void *);
+            elem_sz = 0;
+            break;
+
+        case 'b':
+            put_unaligned(*(const uint8_t *)par, (uint8_t *)*data);
+            elem_sz = sizeof(uint8_t);
+            *data += sizeof(uint8_t);
+            break;
+
+        case 'u':
+            put_unaligned(*(const uint16_t *)par, (uint16_t *)*data);
+            elem_sz = sizeof(uint16_t);
+            *data += sizeof(uint16_t);
+            break;
+
+        case 'D':
+            if ( array_sz )
+                fmt_err(fmt);
+            len = *(const unsigned int *)par;
+            put_unaligned(len, (uint32_t *)*data);
+            *data += sizeof(uint32_t);
+            par = va_arg(ap, const void *);
+            if ( *data != par )
+                memcpy(*data, par, len);
+            *data += len;
+            break;
+
+        case 'L':
+            put_unaligned(*(const uint64_t *)par, (uint64_t *)*data);
+            elem_sz = sizeof(uint64_t);
+            *data += sizeof(uint64_t);
+            break;
+
+        case 'Q':
+            qid = par;
+            elem_sz = sizeof(*qid);
+            fill_buffer_at(data, "bUL", &qid->type, &qid->version, &qid->path);
+            break;
+
+        case 'S':
+            str_val = par;
+            elem_sz = sizeof(str_val);
+            len = strlen(str_val);
+            if ( len > 0xffff )
+            {
+                syslog(LOG_CRIT, "string length %u in fill_buffer()", len);
+                exit(1);
+            }
+            put_unaligned(len, (uint16_t *)*data);
+            *data += sizeof(uint16_t);
+            memcpy(*data, str_val, len);
+            *data += len;
+            break;
+
+        case 'U':
+            put_unaligned(*(const uint32_t *)par, (uint32_t *)*data);
+            elem_sz = sizeof(uint32_t);
+            *data += sizeof(uint32_t);
+            break;
+
+        default:
+            fmt_err(fmt);
+        }
+
+        if ( array_sz )
+            f--;
+    }
+}
+
+static void fill_buffer_at(void **data, const char *fmt, ...)
+{
+    va_list ap;
+
+    va_start(ap, fmt);
+    vfill_buffer_at(data, fmt, ap);
+    va_end(ap);
+}
+
+static void fill_buffer(struct ring *ring, uint8_t cmd, uint16_t tag,
+                        const char *fmt, ...)
+{
+    struct p9_header *hdr = ring->buffer;
+    void *data = hdr + 1;
+    va_list ap;
+
+    hdr->cmd = cmd;
+    hdr->tag = tag;
+
+    va_start(ap, fmt);
+    vfill_buffer_at(&data, fmt, ap);
+    va_end(ap);
+
+    hdr->size = data - ring->buffer;
+}
+
+static unsigned int add_string(struct ring *ring, const char *str,
+                               unsigned int len)
+{
+    char *tmp;
+    unsigned int ret;
+
+    if ( ring->str_used + len + 1 > ring->str_size )
+    {
+        tmp = realloc(ring->str, ring->str_used + len + 1);
+        if ( !tmp )
+            return ~0;
+        ring->str = tmp;
+        ring->str_size = ring->str_used + len + 1;
+    }
+
+    ret = ring->str_used;
+    memcpy(ring->str + ret, str, len);
+    ring->str_used += len;
+    ring->str[ring->str_used++] = 0;
+
+    return ret;
+}
+
+static void p9_error(struct ring *ring, uint16_t tag, uint32_t err)
+{
+    unsigned int erroff;
+
+    strerror_r(err, ring->buffer, ring->ring_size);
+    erroff = add_string(ring, ring->buffer, strlen(ring->buffer));
+    fill_buffer(ring, P9_CMD_ERROR, tag, "SU",
+                erroff != ~0 ? ring->str + erroff : "cannot allocate memory",
+                &err);
+}
+
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
@@ -151,7 +356,16 @@ void *io_thread(void *arg)
             if ( count < hdr.size )
                 continue;
 
-            /* TODO: handle request (will rewrite hdr.size). */
+            ring->str_used = 0;
+
+            switch ( hdr.cmd )
+            {
+            default:
+                syslog(LOG_DEBUG, "%u.%u sent unhandled command %u\n",
+                       ring->device->domid, ring->device->devid, hdr.cmd);
+                p9_error(ring, hdr.tag, EOPNOTSUPP);
+                break;
+            }
 
             ring->handle_response = true;
             hdr.size = ((struct p9_header *)ring->buffer)->size;
@@ -174,6 +388,7 @@ void *io_thread(void *arg)
         }
     }
 
+    free(ring->str);
     free(ring->buffer);
 
     ring->thread_active = false;
diff --git a/tools/9pfsd/xen-9pfsd.h b/tools/9pfsd/xen-9pfsd.h
index d587f59a32..0cde0d2bb8 100644
--- a/tools/9pfsd/xen-9pfsd.h
+++ b/tools/9pfsd/xen-9pfsd.h
@@ -46,6 +46,9 @@ struct ring {
     bool error;             /* Protocol error - stop processing. */
     bool handle_response;   /* Main loop now handling response. */
     void *buffer;           /* Request/response buffer. */
+    char *str;              /* String work space. */
+    unsigned int str_size;  /* Size of *str. */
+    unsigned int str_used;  /* Currently used size of *str. */
 };
 
 struct device {
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 16 10:55:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 16 Feb 2024 10:55:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682143.1061204 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravse-00083T-1K; Fri, 16 Feb 2024 10:55:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682143.1061204; Fri, 16 Feb 2024 10:55:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravsd-00083K-Uf; Fri, 16 Feb 2024 10:55:43 +0000
Received: by outflank-mailman (input) for mailman id 682143;
 Fri, 16 Feb 2024 10:55:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravsc-000838-Kf
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravsc-0007ok-Js
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravsc-0005NU-IH
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=JbZemRzMHPdIbr6c2YEiIEZRFHjEM1d/dEVTpZrjEXg=; b=HrPAezskhrKavD44j4An/75GeF
	3F7Ls8V8RPnowLGBftZQeMet1M+7n1YmdmEslYH9EHWn7KVeJAKb9LEfLCnHCRKmc+C7B6B4peC8v
	rGEOy6t/OtSJpGZekwSMV5SF5VJTCsOiRMtiKc0KFGnciB9sT3WjZkskSN7uRIYbRZpk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xen-9pfsd: add 9pfs version request support
Message-Id: <E1ravsc-0005NU-IH@xenbits.xenproject.org>
Date: Fri, 16 Feb 2024 10:55:42 +0000

commit bcec59cf7ff4c3dfa1a417332b59e7e87c0f1f71
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:53 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs version request support
    
    Add the version request of the 9pfs protocol. For the version use the
    "9P2000.u" variant, as it is supported by Mini-OS and Linux.
    
    For the request parsing add all format items needed even in future in
    order to avoid code churn for those additions later.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/io.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 201 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 12539677df..27571da192 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -22,8 +22,12 @@
 #include "xen-9pfsd.h"
 
 /* P9 protocol commands (response is either cmd+1 or P9_CMD_ERROR). */
+#define P9_CMD_VERSION    100
 #define P9_CMD_ERROR      107
 
+#define P9_MIN_MSIZE      2048
+#define P9_VERSION        "9P2000.u"
+
 struct p9_qid {
     uint8_t type;
 #define QID_TYPE_DIR      0x80
@@ -294,6 +298,169 @@ static unsigned int add_string(struct ring *ring, const char *str,
     return ret;
 }
 
+static bool chk_data(struct ring *ring, void *data, unsigned int len)
+{
+    struct p9_header *hdr = ring->buffer;
+
+    if ( data + len <= ring->buffer + hdr->size )
+        return true;
+
+    errno = E2BIG;
+
+    return false;
+}
+
+static bool fill_data_elem(void **par, void **array, unsigned int *array_sz,
+                           unsigned int elem_sz, void *data)
+{
+    if ( *array_sz && !*array )
+    {
+        *array = calloc(*array_sz, elem_sz);
+        if ( !*array )
+            return false;
+        *par = *array;
+    }
+
+    memcpy(*par, data, elem_sz);
+
+    if ( *array_sz )
+    {
+        *par += elem_sz;
+        *array_sz -= 1;
+    }
+
+    return true;
+}
+
+/*
+ * Fill variables with request data.
+ * fmt is a sequence of format characters. Supported characters are:
+ * a: an array (2 bytes number of elements + the following format as elements)
+ *    The number of elements is stored in the first unsigned int parameter, the
+ *    next parameter is a pointer to an array of elements as denoted by the next
+ *    format character. The array is allocated dynamically.
+ * b: 1 byte unsigned integer
+ *    The value is stored in the next parameter with type uint8_t.
+ * D: Data blob (4 byte length + <length> bytes)
+ *    2 parameters are consumed, first an unsigned int for the length, then a
+ *    pointer to the first uint8_t value.
+ *    No array support.
+ * L: 8 byte unsigned integer
+ *    The value is stored in the next parameter with type uint64_t.
+ * S: String (2 byte length + <length> characters)
+ *    The 0-terminated string is stored in device->str + off, off is stored in
+ *    the next parameter with type unsigned int.
+ * U: 4 byte unsigned integer
+ *    The value is stored in the next parameter with type uint32_t.
+ *
+ * Return value: number of filled variables, errno will be set in case of
+ *   error.
+ */
+static int fill_data(struct ring *ring, const char *fmt, ...)
+{
+    struct p9_header *hdr = ring->buffer;
+    void *data = hdr + 1;
+    void *par;
+    unsigned int pars = 0;
+    const char *f;
+    va_list ap;
+    unsigned int len;
+    unsigned int str_off;
+    unsigned int array_sz = 0;
+    void **array = NULL;
+
+    va_start(ap, fmt);
+
+    for ( f = fmt; *f; f++ )
+    {
+        if ( !array_sz )
+            par = va_arg(ap, void *);
+
+        switch ( *f )
+        {
+        case 'a':
+            f++;
+            if ( !*f || array_sz )
+                fmt_err(fmt);
+            if ( !chk_data(ring, data, sizeof(uint16_t)) )
+                return pars;
+            array_sz = get_unaligned((uint16_t *)data);
+            data += sizeof(uint16_t);
+            *(unsigned int *)par = array_sz;
+            array = va_arg(ap, void **);
+            *array = NULL;
+            break;
+
+        case 'b':
+            if ( !chk_data(ring, data, sizeof(uint8_t)) )
+                return pars;
+            if ( !fill_data_elem(&par, array, &array_sz, sizeof(uint8_t),
+                                 data) )
+                return pars;
+            data += sizeof(uint8_t);
+            break;
+
+        case 'D':
+            if ( array_sz )
+                fmt_err(fmt);
+            if ( !chk_data(ring, data, sizeof(uint32_t)) )
+                return pars;
+            len = get_unaligned((uint32_t *)data);
+            data += sizeof(uint32_t);
+            *(unsigned int *)par = len;
+            par = va_arg(ap, void *);
+            if ( !chk_data(ring, data, len) )
+                return pars;
+            memcpy(par, data, len);
+            data += len;
+            break;
+
+        case 'L':
+            if ( !chk_data(ring, data, sizeof(uint64_t)) )
+                return pars;
+            if ( !fill_data_elem(&par, array, &array_sz, sizeof(uint64_t),
+                                 data) )
+                return pars;
+            data += sizeof(uint64_t);
+            break;
+
+        case 'S':
+            if ( !chk_data(ring, data, sizeof(uint16_t)) )
+                return pars;
+            len = get_unaligned((uint16_t *)data);
+            data += sizeof(uint16_t);
+            if ( !chk_data(ring, data, len) )
+                return pars;
+            str_off = add_string(ring, data, len);
+            if ( str_off == ~0 )
+                return pars;
+            if ( !fill_data_elem(&par, array, &array_sz, sizeof(unsigned int),
+                                 &str_off) )
+                return pars;
+            data += len;
+            break;
+
+        case 'U':
+            if ( !chk_data(ring, data, sizeof(uint32_t)) )
+                return pars;
+            if ( !fill_data_elem(&par, array, &array_sz, sizeof(uint32_t),
+                                 data) )
+                return pars;
+            data += sizeof(uint32_t);
+            break;
+
+        default:
+            fmt_err(fmt);
+        }
+
+        if ( array_sz )
+            f--;
+        pars++;
+    }
+
+    return pars;
+}
+
 static void p9_error(struct ring *ring, uint16_t tag, uint32_t err)
 {
     unsigned int erroff;
@@ -305,6 +472,36 @@ static void p9_error(struct ring *ring, uint16_t tag, uint32_t err)
                 &err);
 }
 
+static void p9_version(struct ring *ring, struct p9_header *hdr)
+{
+    uint32_t max_size;
+    unsigned int off;
+    char *version;
+    int ret;
+
+    ret = fill_data(ring, "US", &max_size, &off);
+    if ( ret != 2 )
+    {
+        p9_error(ring, hdr->tag, errno);
+        return;
+    }
+
+    if ( max_size < P9_MIN_MSIZE )
+    {
+        p9_error(ring, hdr->tag, EMSGSIZE);
+        return;
+    }
+
+    if ( max_size < ring->max_size )
+        ring->max_size = max_size;
+
+    version = ring->str + off;
+    if ( strcmp(version, P9_VERSION) )
+        version = "unknown";
+
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "US", &ring->max_size, version);
+}
+
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
@@ -360,6 +557,10 @@ void *io_thread(void *arg)
 
             switch ( hdr.cmd )
             {
+            case P9_CMD_VERSION:
+                p9_version(ring, &hdr);
+                break;
+
             default:
                 syslog(LOG_DEBUG, "%u.%u sent unhandled command %u\n",
                        ring->device->domid, ring->device->devid, hdr.cmd);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 16 10:55:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 16 Feb 2024 10:55:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682144.1061208 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravso-00086V-3w; Fri, 16 Feb 2024 10:55:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682144.1061208; Fri, 16 Feb 2024 10:55:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravso-00086N-1J; Fri, 16 Feb 2024 10:55:54 +0000
Received: by outflank-mailman (input) for mailman id 682144;
 Fri, 16 Feb 2024 10:55:52 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravsm-00086D-Nn
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:52 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravsm-0007or-My
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravsm-0005Nv-M6
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:55:52 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=/lyze1akuAt4w4V8nmw3LmyTPzXZHZRJbzsN7cjQsA8=; b=ivyt6XkrVT7xaEJYDJScMKfFUd
	ed+JcMgsvr0K3d9oed54o0vPTKZ2NsuRIg1d9HRxykfEVSt53UzT3SOJp4YA3pNDUhEzuT7+BCqCm
	ZehzlzPKvMRUz9xNQFcLx1RoOwe9sbYzwd39LKwYbBiNie0trisKxGXJE9h6eqW0Vw+Q=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xen-9pfsd: add 9pfs attach request support
Message-Id: <E1ravsm-0005Nv-M6@xenbits.xenproject.org>
Date: Fri, 16 Feb 2024 10:55:52 +0000

commit 27815b5f8f82236541a42602ce356ca6d4d1348f
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:54 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs attach request support
    
    Add the attach request of the 9pfs protocol. This introduces the "fid"
    scheme of the 9pfs protocol.
    
    As this will be needed later, use a dedicated memory allocation
    function in alloc_fid() and prepare a fid reference count.
    
    For filling the qid data take the approach from the qemu 9pfs backend
    implementation.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/io.c        | 162 ++++++++++++++++++++++++++++++++++++++++++++++++
 tools/9pfsd/xen-9pfsd.c |   6 ++
 tools/9pfsd/xen-9pfsd.h |  14 +++++
 3 files changed, 182 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 27571da192..3fd4289f7c 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -11,11 +11,14 @@
  * before looking for the next request.
  */
 
+#include <assert.h>
 #include <errno.h>
 #include <stdbool.h>
 #include <stdlib.h>
 #include <string.h>
 #include <syslog.h>
+#include <sys/types.h>
+#include <sys/stat.h>
 #include <xenctrl.h>           /* For cpu barriers. */
 #include <xen-tools/common-macros.h>
 
@@ -23,6 +26,7 @@
 
 /* P9 protocol commands (response is either cmd+1 or P9_CMD_ERROR). */
 #define P9_CMD_VERSION    100
+#define P9_CMD_ATTACH     104
 #define P9_CMD_ERROR      107
 
 #define P9_MIN_MSIZE      2048
@@ -461,6 +465,124 @@ static int fill_data(struct ring *ring, const char *fmt, ...)
     return pars;
 }
 
+static struct p9_fid *find_fid(device *device, unsigned int fid)
+{
+    struct p9_fid *fidp;
+
+    XEN_TAILQ_FOREACH(fidp, &device->fids, list)
+    {
+        if ( fidp->fid == fid )
+            return fidp;
+    }
+
+    return NULL;
+}
+
+static struct p9_fid *alloc_fid_mem(device *device, unsigned int fid,
+                                    const char *path)
+{
+    struct p9_fid *fidp;
+
+    fidp = calloc(sizeof(*fidp) + strlen(path) + 1, 1);
+    if ( !fidp )
+        return NULL;
+
+    fidp->fid = fid;
+    strcpy(fidp->path, path);
+
+    return fidp;
+}
+
+static struct p9_fid *alloc_fid(device *device, unsigned int fid,
+                                const char *path)
+{
+    struct p9_fid *fidp = NULL;
+
+    pthread_mutex_lock(&device->fid_mutex);
+
+    if ( find_fid(device, fid) )
+    {
+        errno = EBADF;
+        goto out;
+    }
+
+    if ( device->n_fids >= device->max_open_files )
+    {
+        errno = EMFILE;
+        goto out;
+    }
+
+    fidp = alloc_fid_mem(device, fid, path);
+    if ( !fidp )
+        goto out;
+
+    fidp->ref = 1;
+    XEN_TAILQ_INSERT_HEAD(&device->fids, fidp, list);
+    device->n_fids++;
+
+ out:
+    pthread_mutex_unlock(&device->fid_mutex);
+
+    return fidp;
+}
+
+static void free_fid(device *device, struct p9_fid *fidp)
+{
+    if ( !fidp )
+        return;
+
+    pthread_mutex_lock(&device->fid_mutex);
+
+    fidp->ref--;
+    if ( !fidp->ref )
+    {
+        device->n_fids--;
+        XEN_TAILQ_REMOVE(&device->fids, fidp, list);
+        free(fidp);
+    }
+
+    pthread_mutex_unlock(&device->fid_mutex);
+}
+
+void free_fids(device *device)
+{
+    struct p9_fid *fidp;
+
+    while ( (fidp = XEN_TAILQ_FIRST(&device->fids)) != NULL )
+    {
+        XEN_TAILQ_REMOVE(&device->fids, fidp, list);
+        free(fidp);
+    }
+}
+
+static const char *relpath_from_path(const char *path)
+{
+    if (!strcmp(path, "/"))
+        return ".";
+
+    return (path[0] == '/') ? path + 1 : path;
+}
+
+static int fill_qid(device *device, const char *path, struct p9_qid *qid,
+                    const struct stat *stbuf)
+{
+    struct stat st;
+
+    if ( !stbuf )
+    {
+        if ( fstatat(device->root_fd, path, &st, 0) )
+            return errno;
+
+        stbuf = &st;
+    }
+
+    qid->type = S_ISDIR(stbuf->st_mode) ? QID_TYPE_DIR : 0;
+    qid->version = stbuf->st_mtime ^ (stbuf->st_size << 8);
+    qid->path = stbuf->st_ino;
+
+    return 0;
+}
+
 static void p9_error(struct ring *ring, uint16_t tag, uint32_t err)
 {
     unsigned int erroff;
@@ -502,6 +624,42 @@ static void p9_version(struct ring *ring, struct p9_header *hdr)
     fill_buffer(ring, hdr->cmd + 1, hdr->tag, "US", &ring->max_size, version);
 }
 
+static void p9_attach(struct ring *ring, struct p9_header *hdr)
+{
+    device *device = ring->device;
+    uint32_t fid;
+    uint32_t dummy_u32;
+    unsigned int dummy_uint;
+    struct p9_qid qid;
+    int ret;
+
+    ret = fill_data(ring, "UUSSU", &fid, &dummy_u32, &dummy_uint, &dummy_uint,
+                    &dummy_u32);
+    if ( ret != 5 )
+    {
+        p9_error(ring, hdr->tag, errno);
+        return;
+    }
+
+    device->root_fid = alloc_fid(device, fid, relpath_from_path("/"));
+    if ( !device->root_fid )
+    {
+        p9_error(ring, hdr->tag, errno);
+        return;
+    }
+
+    ret = fill_qid(device, device->root_fid->path, &qid, NULL);
+    if ( ret )
+    {
+        free_fid(device, device->root_fid);
+        device->root_fid = NULL;
+        p9_error(ring, hdr->tag, ret);
+        return;
+    }
+
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "Q", &qid);
+}
+
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
@@ -561,6 +719,10 @@ void *io_thread(void *arg)
                 p9_version(ring, &hdr);
                 break;
 
+            case P9_CMD_ATTACH:
+                p9_attach(ring, &hdr);
+                break;
+
             default:
                 syslog(LOG_DEBUG, "%u.%u sent unhandled command %u\n",
                        ring->device->domid, ring->device->devid, hdr.cmd);
diff --git a/tools/9pfsd/xen-9pfsd.c b/tools/9pfsd/xen-9pfsd.c
index 73b6c3a30e..b83b896bcc 100644
--- a/tools/9pfsd/xen-9pfsd.c
+++ b/tools/9pfsd/xen-9pfsd.c
@@ -304,6 +304,9 @@ static device *new_device(unsigned int domid, unsigned int devid)
         return NULL;
     }
 
+    pthread_mutex_init(&device->fid_mutex, NULL);
+    XEN_TAILQ_INIT(&device->fids);
+
     val = read_backend_node(device, "security_model");
     if ( !val || strcmp(val, "none") )
     {
@@ -399,6 +402,8 @@ static void disconnect_guest(device *device)
     }
 
     device->num_rings = 0;
+
+    free_fids(device);
 }
 
 static void close_device(device *device, enum xenbus_state state)
@@ -482,6 +487,7 @@ static void remove_device(device *device)
     XEN_TAILQ_REMOVE(&devs, device, list);
 
     disconnect_guest(device);
+    pthread_mutex_destroy(&device->fid_mutex);
     free_device(device);
 }
 
diff --git a/tools/9pfsd/xen-9pfsd.h b/tools/9pfsd/xen-9pfsd.h
index 0cde0d2bb8..6c755411a7 100644
--- a/tools/9pfsd/xen-9pfsd.h
+++ b/tools/9pfsd/xen-9pfsd.h
@@ -21,6 +21,13 @@ struct p9_header {
     uint16_t tag;
 } __attribute__((packed));
 
+struct p9_fid {
+    XEN_TAILQ_ENTRY(struct p9_fid) list;
+    unsigned int fid;
+    unsigned int ref;
+    char path[];
+};
+
 typedef struct device device;
 
 struct ring {
@@ -71,10 +78,17 @@ struct device {
     unsigned int num_rings;
     struct ring *ring[MAX_RINGS];
     int root_fd;
+
+    /* File system handling. */
+    pthread_mutex_t fid_mutex;
+    XEN_TAILQ_HEAD(fidhead, struct p9_fid) fids;
+    struct p9_fid *root_fid;
+    unsigned int n_fids;
 };
 
 extern xenevtchn_handle *xe;
 
 void *io_thread(void *arg);
+void free_fids(device *device);
 
 #endif /* XEN_9PFSD_H */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 16 10:56:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 16 Feb 2024 10:56:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682145.1061212 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravsy-00088o-5R; Fri, 16 Feb 2024 10:56:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682145.1061212; Fri, 16 Feb 2024 10:56:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravsy-00088h-2o; Fri, 16 Feb 2024 10:56:04 +0000
Received: by outflank-mailman (input) for mailman id 682145;
 Fri, 16 Feb 2024 10:56:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravsw-00088Q-QW
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravsw-0007pC-Pt
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravsw-0005P9-P8
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=A07Y9ILaf+yWqhFbvlWGQhJMWViCBk7fnki7PzzZP4c=; b=FNc/dCkU2ReaoHtgSMwY4ISO91
	/4rfZNLkfWV9OUzFl1D4yeYQ6O5Pxd+djSMZHgiPw/YIhJVCjxNVhVBU4Tl0SBRq/oqboVYhJO+UH
	cTyn1tWoBqqp/hbO6NEX8pS8aL+rxDeQh21oHsIzKbXB+0SD8rrXwM0+1ilpThDt6Jb0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xen-9pfsd: add 9pfs walk request support
Message-Id: <E1ravsw-0005P9-P8@xenbits.xenproject.org>
Date: Fri, 16 Feb 2024 10:56:02 +0000

commit 9615e40f4700f548ed77cd10c13c22b42d5f4a99
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:55 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs walk request support
    
    Add the walk request of the 9pfs protocol.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/io.c        | 171 ++++++++++++++++++++++++++++++++++++++++++++++++
 tools/9pfsd/xen-9pfsd.h |   1 +
 2 files changed, 172 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 3fd4289f7c..98af20a21d 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -28,9 +28,11 @@
 #define P9_CMD_VERSION    100
 #define P9_CMD_ATTACH     104
 #define P9_CMD_ERROR      107
+#define P9_CMD_WALK       110
 
 #define P9_MIN_MSIZE      2048
 #define P9_VERSION        "9P2000.u"
+#define P9_WALK_MAXELEM   16
 
 struct p9_qid {
     uint8_t type;
@@ -478,6 +480,21 @@ static struct p9_fid *find_fid(device *device, unsigned int fid)
     return NULL;
 }
 
+static struct p9_fid *get_fid_ref(device *device, unsigned int fid)
+{
+    struct p9_fid *fidp;
+
+    pthread_mutex_lock(&device->fid_mutex);
+
+    fidp = find_fid(device, fid);
+    if ( fidp )
+        fidp->ref++;
+
+    pthread_mutex_unlock(&device->fid_mutex);
+
+    return fidp;
+}
+
 static struct p9_fid *alloc_fid_mem(device *device, unsigned int fid,
                                     const char *path)
 {
@@ -576,6 +593,10 @@ static int fill_qid(device *device, const char *path, struct p9_qid *qid,
         stbuf = &st;
     }
 
+    /* Don't allow symbolic links. */
+    if ( S_ISLNK(stbuf->st_mode) )
+        return EMLINK;
+
     qid->type = S_ISDIR(stbuf->st_mode) ? QID_TYPE_DIR : 0;
     qid->version = stbuf->st_mtime ^ (stbuf->st_size << 8);
     qid->path = stbuf->st_ino;
@@ -583,6 +604,20 @@ static int fill_qid(device *device, const char *path, struct p9_qid *qid,
     return 0;
 }
 
+static bool name_ok(const char *str)
+{
+    if ( !*str )
+        return false;
+
+    if ( strchr(str, '/' ) )
+        return false;
+
+    if ( !strcmp(str, "..") || !strcmp(str, ".") )
+        return false;
+
+    return true;
+}
+
 static void p9_error(struct ring *ring, uint16_t tag, uint32_t err)
 {
     unsigned int erroff;
@@ -660,6 +695,138 @@ static void p9_attach(struct ring *ring, struct p9_header *hdr)
     fill_buffer(ring, hdr->cmd + 1, hdr->tag, "Q", &qid);
 }
 
+static void p9_walk(struct ring *ring, struct p9_header *hdr)
+{
+    device *device = ring->device;
+    uint32_t fid;
+    uint32_t newfid;
+    struct p9_fid *fidp = NULL;
+    struct p9_qid *qids = NULL;
+    unsigned int n_names = 0;
+    unsigned int *names = NULL;
+    unsigned int walked = 0;
+    unsigned int i;
+    char *path = NULL;
+    unsigned int path_len;
+    int ret;
+
+    ret = fill_data(ring, "UUaS", &fid, &newfid, &n_names, &names);
+    if ( n_names > P9_WALK_MAXELEM )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        goto out;
+    }
+    if ( ret != 3 + n_names )
+    {
+        p9_error(ring, hdr->tag, errno);
+        goto out;
+    }
+
+    fidp = get_fid_ref(device, fid);
+    if ( !fidp )
+    {
+        p9_error(ring, hdr->tag, ENOENT);
+        goto out;
+    }
+    if ( fidp->opened )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        goto out;
+    }
+
+    path_len = strlen(fidp->path) + 1;
+    for ( i = 0; i < n_names; i++ )
+    {
+        if ( !name_ok(ring->str + names[i]) )
+        {
+            p9_error(ring, hdr->tag, ENOENT);
+            goto out;
+        }
+        path_len += strlen(ring->str + names[i]) + 1;
+    }
+    path = calloc(path_len + 1, 1);
+    if ( !path )
+    {
+        p9_error(ring, hdr->tag, ENOMEM);
+        goto out;
+    }
+    strcpy(path, fidp->path);
+
+    if ( n_names )
+    {
+        qids = calloc(n_names, sizeof(*qids));
+        if ( !qids )
+        {
+            p9_error(ring, hdr->tag, ENOMEM);
+            goto out;
+        }
+        for ( i = 0; i < n_names; i++ )
+        {
+            strcat(path, "/");
+            strcat(path, ring->str + names[i]);
+            ret = fill_qid(device, path, qids + i, NULL);
+            if ( ret )
+            {
+                if ( !walked )
+                {
+                    p9_error(ring, hdr->tag, errno);
+                    goto out;
+                }
+                break;
+            }
+            walked++;
+        }
+    }
+
+    if ( walked == n_names )
+    {
+        bool ok = false;
+
+        if ( fid == newfid )
+        {
+            struct p9_fid *new_fidp;
+
+            pthread_mutex_lock(&device->fid_mutex);
+
+            if ( fidp->ref != 2 )
+            {
+                errno = EBUSY;
+            }
+            else
+            {
+                new_fidp = alloc_fid_mem(device, fid, path);
+                if ( new_fidp )
+                {
+                    new_fidp->ref = 2;
+                    XEN_TAILQ_REMOVE(&device->fids, fidp, list);
+                    XEN_TAILQ_INSERT_HEAD(&device->fids, new_fidp, list);
+                    free(fidp);
+                    fidp = new_fidp;
+                    ok = true;
+                }
+            }
+
+            pthread_mutex_unlock(&device->fid_mutex);
+        }
+        else
+            ok = alloc_fid(device, newfid, path);
+
+        if ( !ok )
+        {
+            p9_error(ring, hdr->tag, errno);
+            goto out;
+        }
+    }
+
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "aQ", &walked, qids);
+
+ out:
+    free_fid(device, fidp);
+    free(qids);
+    free(path);
+    free(names);
+}
+
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
@@ -723,6 +890,10 @@ void *io_thread(void *arg)
                 p9_attach(ring, &hdr);
                 break;
 
+            case P9_CMD_WALK:
+                p9_walk(ring, &hdr);
+                break;
+
             default:
                 syslog(LOG_DEBUG, "%u.%u sent unhandled command %u\n",
                        ring->device->domid, ring->device->devid, hdr.cmd);
diff --git a/tools/9pfsd/xen-9pfsd.h b/tools/9pfsd/xen-9pfsd.h
index 6c755411a7..f01fffb0bb 100644
--- a/tools/9pfsd/xen-9pfsd.h
+++ b/tools/9pfsd/xen-9pfsd.h
@@ -25,6 +25,7 @@ struct p9_fid {
     XEN_TAILQ_ENTRY(struct p9_fid) list;
     unsigned int fid;
     unsigned int ref;
+    bool opened;
     char path[];
 };
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 16 10:56:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 16 Feb 2024 10:56:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682146.1061216 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravt8-0008BW-6l; Fri, 16 Feb 2024 10:56:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682146.1061216; Fri, 16 Feb 2024 10:56:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravt8-0008BP-4K; Fri, 16 Feb 2024 10:56:14 +0000
Received: by outflank-mailman (input) for mailman id 682146;
 Fri, 16 Feb 2024 10:56:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravt6-0008BH-U3
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravt6-0007pR-TL
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravt6-0005Px-S8
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=5IA7eGQgi6tCVXs8ASF9XT54NK3tFP+x6WIuAV0+054=; b=F/OxuPiGG56lQdG8992thMQpyv
	0WC6JbvvQvsB9MUOKiASc4XzirF8zUepKDOwxJw5H8aK9vumnjx1XdWyYdBaoyivYVTvsWFw84QeO
	WkyMcjjfbCs2cZEdlCP9O7unyElgS5Lm3njZK9sYm/1rm7Azp+uPMaVILuC1ktXtXxuQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xen-9pfsd: add 9pfs open request support
Message-Id: <E1ravt6-0005Px-S8@xenbits.xenproject.org>
Date: Fri, 16 Feb 2024 10:56:12 +0000

commit 7c0d5f3cac1040130edd7701afc15e5db7ead940
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:56 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs open request support
    
    Add the open request of the 9pfs protocol.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/io.c        | 137 ++++++++++++++++++++++++++++++++++++++++++++++++
 tools/9pfsd/xen-9pfsd.h |   4 ++
 2 files changed, 141 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 98af20a21d..9ff3bcccca 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -19,6 +19,8 @@
 #include <syslog.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <dirent.h>
+#include <fcntl.h>
 #include <xenctrl.h>           /* For cpu barriers. */
 #include <xen-tools/common-macros.h>
 
@@ -29,6 +31,15 @@
 #define P9_CMD_ATTACH     104
 #define P9_CMD_ERROR      107
 #define P9_CMD_WALK       110
+#define P9_CMD_OPEN       112
+
+/* P9 protocol open flags. */
+#define P9_OREAD            0   /* read */
+#define P9_OWRITE           1   /* write */
+#define P9_ORDWR            2   /* read and write */
+#define P9_OMODEMASK     0x03
+#define P9_OTRUNC        0x10   /* or'ed in, truncate file first */
+#define P9_OREMOVE       0x40   /* or'ed in, remove file after clunk */
 
 #define P9_MIN_MSIZE      2048
 #define P9_VERSION        "9P2000.u"
@@ -827,6 +838,128 @@ static void p9_walk(struct ring *ring, struct p9_header *hdr)
     free(names);
 }
 
+static int open_flags_from_mode(uint8_t mode)
+{
+    int flags;
+
+    switch ( mode & P9_OMODEMASK )
+    {
+    case P9_OREAD:
+        flags = O_RDONLY;
+        break;
+
+    case P9_OWRITE:
+        flags = O_WRONLY;
+        break;
+
+    case P9_ORDWR:
+        flags = O_RDWR;
+        break;
+
+    default:
+        errno = EINVAL;
+        return -1;
+    }
+
+    if ( mode & P9_OTRUNC )
+        flags |= O_TRUNC;
+
+    return flags;
+}
+
+static unsigned int get_iounit(struct ring *ring, struct stat *st)
+{
+    return (ring->max_size - st->st_blksize) & ~(st->st_blksize - 1);
+}
+
+static void p9_open(struct ring *ring, struct p9_header *hdr)
+{
+    device *device = ring->device;
+    uint32_t fid;
+    uint8_t mode;
+    struct p9_fid *fidp;
+    struct stat st;
+    struct p9_qid qid;
+    uint32_t iounit;
+    int flags;
+    int ret;
+
+    ret = fill_data(ring, "Ub", &fid, &mode);
+    if ( ret != 2 )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+    if ( mode & ~(P9_OMODEMASK | P9_OTRUNC | P9_OREMOVE) )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+
+    fidp = get_fid_ref(device, fid);
+    if ( !fidp )
+    {
+        p9_error(ring, hdr->tag, ENOENT);
+        return;
+    }
+    if ( fidp->opened )
+    {
+        errno = EINVAL;
+        goto err;
+    }
+
+    if ( fstatat(device->root_fd, fidp->path, &st, 0) < 0 )
+    {
+        errno = ENOENT;
+        goto err;
+    }
+
+    if ( S_ISLNK(st.st_mode) )
+    {
+        errno = EMLINK;
+        goto err;
+    }
+
+    fidp->isdir = S_ISDIR(st.st_mode);
+    fidp->mode = mode;
+    if ( fidp->isdir )
+    {
+        if ( mode != P9_OREAD )
+        {
+            errno = EINVAL;
+            goto err;
+        }
+        fidp->fd = openat(device->root_fd, fidp->path, O_RDONLY);
+        if ( fidp->fd < 0 )
+            goto err;
+        fidp->data = fdopendir(fidp->fd);
+        if ( !fidp->data )
+            goto err;
+    }
+    else
+    {
+        flags = open_flags_from_mode(mode);
+        if ( flags < 0 )
+            goto err;
+
+        fidp->fd = openat(device->root_fd, fidp->path, flags);
+        if ( fidp->fd < 0 )
+            goto err;
+    }
+
+    fill_qid(device, fidp->path, &qid, &st);
+    iounit = get_iounit(ring, &st);
+    fidp->opened = true;
+
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "QU", &qid, &iounit);
+
+    return;
+
+ err:
+    free_fid(device, fidp);
+    p9_error(ring, hdr->tag, errno);
+}
+
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
@@ -894,6 +1027,10 @@ void *io_thread(void *arg)
                 p9_walk(ring, &hdr);
                 break;
 
+            case P9_CMD_OPEN:
+                p9_open(ring, &hdr);
+                break;
+
             default:
                 syslog(LOG_DEBUG, "%u.%u sent unhandled command %u\n",
                        ring->device->domid, ring->device->devid, hdr.cmd);
diff --git a/tools/9pfsd/xen-9pfsd.h b/tools/9pfsd/xen-9pfsd.h
index f01fffb0bb..757be2da4b 100644
--- a/tools/9pfsd/xen-9pfsd.h
+++ b/tools/9pfsd/xen-9pfsd.h
@@ -25,7 +25,11 @@ struct p9_fid {
     XEN_TAILQ_ENTRY(struct p9_fid) list;
     unsigned int fid;
     unsigned int ref;
+    int fd;
+    uint8_t mode;
     bool opened;
+    bool isdir;
+    void *data;    /* File type specific. */
     char path[];
 };
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 16 10:56:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 16 Feb 2024 10:56:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682147.1061220 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravtI-0008Eg-8E; Fri, 16 Feb 2024 10:56:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682147.1061220; Fri, 16 Feb 2024 10:56:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravtI-0008EZ-5m; Fri, 16 Feb 2024 10:56:24 +0000
Received: by outflank-mailman (input) for mailman id 682147;
 Fri, 16 Feb 2024 10:56:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravtH-0008EO-0t
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravtH-0007pr-0C
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravtG-0005QR-VS
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=/KkvqB5sFdmNN8l8N9mjrOQhdJgP05TI80Y1LXlY5w0=; b=fqIlXEqpB38ASY1uPrHOpf06IW
	xW9jGaHNQRvFQc2icMDqhUFDTDVdSSv+NzQO/+koKUwNgBJlm6+Kt5/ouc/HXOJnJqq2L3XIO6HrG
	XgjHvdcAd5UfTZh+YHHsw39icU5W/rt5btBxMOWHrfCVrWxIxsukDRyf1Rju4BbHIWCY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xen-9pfsd: add 9pfs clunk request support
Message-Id: <E1ravtG-0005QR-VS@xenbits.xenproject.org>
Date: Fri, 16 Feb 2024 10:56:22 +0000

commit 052a3a7fd90c3aa749c9fb03df622d1c0915ea8c
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:57 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs clunk request support
    
    Add the clunk request of the 9pfs protocol.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/io.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 9ff3bcccca..7c773bc65e 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -32,6 +32,7 @@
 #define P9_CMD_ERROR      107
 #define P9_CMD_WALK       110
 #define P9_CMD_OPEN       112
+#define P9_CMD_CLUNK      120
 
 /* P9 protocol open flags. */
 #define P9_OREAD            0   /* read */
@@ -960,6 +961,44 @@ static void p9_open(struct ring *ring, struct p9_header *hdr)
     p9_error(ring, hdr->tag, errno);
 }
 
+static void p9_clunk(struct ring *ring, struct p9_header *hdr)
+{
+    device *device = ring->device;
+    uint32_t fid;
+    struct p9_fid *fidp;
+    int ret;
+
+    ret = fill_data(ring, "U", &fid);
+    if ( ret != 1 )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+
+    fidp = get_fid_ref(device, fid);
+    if ( !fidp )
+    {
+        p9_error(ring, hdr->tag, ENOENT);
+        return;
+    }
+
+    if ( fidp->opened )
+    {
+        fidp->opened = false;
+        free_fid(device, fidp);
+        close(fidp->fd);
+        if ( fidp->mode & P9_OREMOVE )
+            unlinkat(device->root_fd, fidp->path,
+                     fidp->isdir ? AT_REMOVEDIR : 0);
+    }
+
+    /* 2 calls of free_fid(): one for our reference, and one to free it. */
+    free_fid(device, fidp);
+    free_fid(device, fidp);
+
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "");
+}
+
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
@@ -1031,6 +1070,10 @@ void *io_thread(void *arg)
                 p9_open(ring, &hdr);
                 break;
 
+            case P9_CMD_CLUNK:
+                p9_clunk(ring, &hdr);
+                break;
+
             default:
                 syslog(LOG_DEBUG, "%u.%u sent unhandled command %u\n",
                        ring->device->domid, ring->device->devid, hdr.cmd);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 16 10:56:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 16 Feb 2024 10:56:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682148.1061224 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravtT-0008H4-AD; Fri, 16 Feb 2024 10:56:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682148.1061224; Fri, 16 Feb 2024 10:56:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravtT-0008Gw-7U; Fri, 16 Feb 2024 10:56:35 +0000
Received: by outflank-mailman (input) for mailman id 682148;
 Fri, 16 Feb 2024 10:56:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravtR-0008Gl-4B
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravtR-0007pz-3D
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravtR-0005Qu-2J
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=6R0OCTc888yeGKq1ftYRdZGFn7w6DSyTtG/YIy4LHYw=; b=lgp9Ik4hwbxC9jcKtU3TghKeO8
	/o0hXw+SCEWjTopz4F0qsLInbjW89dHP35Zy/vof7FB5PGtQCoy//V0xq84mAouNgxWO6qbjbRsqn
	5piMEjmDY9RiUsBhhhYiLnWX/Yh7TYLMe6Py90pb2FlEhSWpde3C8vjQRilUyOCJzxvA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xen-9pfsd: add 9pfs create request support
Message-Id: <E1ravtR-0005Qu-2J@xenbits.xenproject.org>
Date: Fri, 16 Feb 2024 10:56:33 +0000

commit 34449f8cf061449d79c68c845d83a14c413ae8cf
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:58 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs create request support
    
    Add the create request of the 9pfs protocol.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/io.c | 151 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 151 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 7c773bc65e..70426a04fd 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -32,6 +32,7 @@
 #define P9_CMD_ERROR      107
 #define P9_CMD_WALK       110
 #define P9_CMD_OPEN       112
+#define P9_CMD_CREATE     114
 #define P9_CMD_CLUNK      120
 
 /* P9 protocol open flags. */
@@ -42,6 +43,12 @@
 #define P9_OTRUNC        0x10   /* or'ed in, truncate file first */
 #define P9_OREMOVE       0x40   /* or'ed in, remove file after clunk */
 
+/* P9 protocol create permission masks. */
+#define P9_CREATE_PERM_DIR        0x80000000
+#define P9_CREATE_PERM_NOTSUPP    0x03b00000   /* link, symlink, ... */
+#define P9_CREATE_PERM_DIR_MASK   0777
+#define P9_CREATE_PERM_FILE_MASK  0666
+
 #define P9_MIN_MSIZE      2048
 #define P9_VERSION        "9P2000.u"
 #define P9_WALK_MAXELEM   16
@@ -961,6 +968,146 @@ static void p9_open(struct ring *ring, struct p9_header *hdr)
     p9_error(ring, hdr->tag, errno);
 }
 
+static void p9_create(struct ring *ring, struct p9_header *hdr)
+{
+    device *device = ring->device;
+    uint32_t fid;
+    unsigned int name_off;
+    uint32_t perm;
+    uint8_t mode;
+    unsigned int ext_off;
+    struct p9_fid *fidp;
+    struct p9_fid *new_fidp;
+    char *path;
+    struct stat st;
+    struct p9_qid qid;
+    uint32_t iounit;
+    int flags;
+    int ret;
+
+    ret = fill_data(ring, "USUbS", &fid, &name_off, &perm, &mode, &ext_off);
+    if ( ret != 5 )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+
+    if ( !name_ok(ring->str + name_off) )
+    {
+        p9_error(ring, hdr->tag, ENOENT);
+        return;
+    }
+
+    if ( perm & P9_CREATE_PERM_NOTSUPP )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+
+    fidp = get_fid_ref(device, fid);
+    if ( !fidp || fidp->opened )
+    {
+        free_fid(device, fidp);
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+    if ( fstatat(device->root_fd, fidp->path, &st, 0) < 0 )
+    {
+        free_fid(device, fidp);
+        p9_error(ring, hdr->tag, errno);
+        return;
+    }
+
+    path = malloc(strlen(fidp->path) + strlen(ring->str + name_off) + 2);
+    if ( !path )
+    {
+        free_fid(device, fidp);
+        p9_error(ring, hdr->tag, ENOMEM);
+        return;
+    }
+    sprintf(path, "%s/%s", fidp->path, ring->str + name_off);
+    new_fidp = alloc_fid_mem(device, fid, path);
+    free(path);
+    if ( !new_fidp )
+    {
+        free_fid(device, fidp);
+        p9_error(ring, hdr->tag, ENOMEM);
+        return;
+    }
+
+    pthread_mutex_lock(&device->fid_mutex);
+
+    new_fidp->ref = fidp->ref;
+
+    if ( perm & P9_CREATE_PERM_DIR )
+    {
+        perm &= P9_CREATE_PERM_DIR_MASK & st.st_mode;
+        if ( mode != P9_OREAD )
+        {
+            errno = EINVAL;
+            goto err;
+        }
+        if ( mkdirat(device->root_fd, new_fidp->path, perm) < 0 )
+            goto err;
+
+        XEN_TAILQ_REMOVE(&device->fids, fidp, list);
+        XEN_TAILQ_INSERT_HEAD(&device->fids, new_fidp, list);
+        free(fidp);
+        fidp = new_fidp;
+        new_fidp = NULL;
+
+        fidp->fd = openat(device->root_fd, fidp->path, O_RDONLY);
+        if ( fidp->fd < 0 )
+            goto err;
+        fidp->data = fdopendir(fidp->fd);
+        if ( !fidp->data )
+            goto err;
+    }
+    else
+    {
+        flags = open_flags_from_mode(mode);
+        if ( flags < 0 )
+        {
+            errno = EINVAL;
+            goto err;
+        }
+        perm &= P9_CREATE_PERM_FILE_MASK & st.st_mode;
+
+        XEN_TAILQ_REMOVE(&device->fids, fidp, list);
+        XEN_TAILQ_INSERT_HEAD(&device->fids, new_fidp, list);
+        free(fidp);
+        fidp = new_fidp;
+        new_fidp = NULL;
+
+        fidp->fd = openat(device->root_fd, fidp->path, flags | O_CREAT | O_EXCL,
+                          perm);
+        if ( fidp->fd < 0 )
+            goto err;
+    }
+
+    if ( fstatat(device->root_fd, fidp->path, &st, 0) < 0 )
+        goto err;
+
+    fill_qid(device, fidp->path, &qid, &st);
+    iounit = get_iounit(ring, &st);
+    fidp->opened = true;
+    fidp->mode = mode;
+
+    pthread_mutex_unlock(&device->fid_mutex);
+
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "QU", &qid, &iounit);
+
+    return;
+
+ err:
+    p9_error(ring, hdr->tag, errno);
+
+    pthread_mutex_unlock(&device->fid_mutex);
+
+    free(new_fidp);
+    free_fid(device, fidp);
+}
+
 static void p9_clunk(struct ring *ring, struct p9_header *hdr)
 {
     device *device = ring->device;
@@ -1070,6 +1217,10 @@ void *io_thread(void *arg)
                 p9_open(ring, &hdr);
                 break;
 
+            case P9_CMD_CREATE:
+                p9_create(ring, &hdr);
+                break;
+
             case P9_CMD_CLUNK:
                 p9_clunk(ring, &hdr);
                 break;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 16 10:56:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 16 Feb 2024 10:56:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682149.1061229 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravtc-0008Jy-Cy; Fri, 16 Feb 2024 10:56:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682149.1061229; Fri, 16 Feb 2024 10:56:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravtc-0008Jn-AM; Fri, 16 Feb 2024 10:56:44 +0000
Received: by outflank-mailman (input) for mailman id 682149;
 Fri, 16 Feb 2024 10:56:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravtb-0008Jd-77
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:43 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravtb-0007q6-6I
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravtb-0005Ra-5N
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=mxRlnx9SJnNeqK1UxwPE1YMginX/II1KfYiPcViHytg=; b=NiWJz+F0pBdw3f6BTaYBehHiBN
	W60/ru81OMe8iJCuxm3D2jfhFVOvtYAqB/UXpHvp4N0PLpOMfi7ZzsZ1FLOIsQHX8qtYyNEFX+grq
	5Nh7oGEg12twooRos23YHjJgovaTg8nlXVrMszmcAVZpU7M/IpXvOHt8bO6//iZdUPic=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xen-9pfsd: add 9pfs stat request support
Message-Id: <E1ravtb-0005Ra-5N@xenbits.xenproject.org>
Date: Fri, 16 Feb 2024 10:56:43 +0000

commit 01c569f3fca5f76f6e5ec1661280bdd2381019b9
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:04:59 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs stat request support
    
    Add the stat request of the 9pfs protocol.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/9pfsd/io.c | 102 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 102 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 70426a04fd..75e516738b 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -34,6 +34,7 @@
 #define P9_CMD_OPEN       112
 #define P9_CMD_CREATE     114
 #define P9_CMD_CLUNK      120
+#define P9_CMD_STAT       124
 
 /* P9 protocol open flags. */
 #define P9_OREAD            0   /* read */
@@ -60,6 +61,25 @@ struct p9_qid {
     uint64_t path;
 };
 
+struct p9_stat {
+    uint16_t size;
+    uint16_t type;
+    uint32_t dev;
+    struct p9_qid qid;
+    uint32_t mode;
+    uint32_t atime;
+    uint32_t mtime;
+    uint64_t length;
+    const char *name;
+    const char *uid;
+    const char *gid;
+    const char *muid;
+    const char *extension;
+    uint32_t n_uid;
+    uint32_t n_gid;
+    uint32_t n_muid;
+};
+
 /*
  * Note that the ring names "in" and "out" are from the frontend's
  * perspective, so the "in" ring will be used for responses to the frontend,
@@ -166,6 +186,7 @@ static void fmt_err(const char *fmt)
  * S: String (2 byte length + <length> characters)
  *    The length is obtained via strlen() of the parameter, being a pointer
  *    to the first character of the string
+ * s: stat (struct p9_stat)
  * U: 4 byte unsigned integer
  *    The parameter is a pointer to a uint32_t value
  */
@@ -176,6 +197,8 @@ static void vfill_buffer_at(void **data, const char *fmt, va_list ap)
     const void *par;
     const char *str_val;
     const struct p9_qid *qid;
+    const struct p9_stat *stat;
+    uint16_t tlen;
     unsigned int len;
     unsigned int array_sz = 0;
     unsigned int elem_sz = 0;
@@ -259,6 +282,18 @@ static void vfill_buffer_at(void **data, const char *fmt, va_list ap)
             *data += len;
             break;
 
+        case 's':
+            stat = par;
+            elem_sz = sizeof(*stat);
+            tlen = stat->size + sizeof(stat->size);
+            fill_buffer_at(data, "uuuUQUUULSSSSSUUU", &tlen, &stat->size,
+                           &stat->type, &stat->dev, &stat->qid, &stat->mode,
+                           &stat->atime, &stat->mtime, &stat->length,
+                           stat->name, stat->uid, stat->gid, stat->muid,
+                           stat->extension, &stat->n_uid, &stat->n_gid,
+                           &stat->n_muid);
+            break;
+
         case 'U':
             put_unaligned(*(const uint32_t *)par, (uint32_t *)*data);
             elem_sz = sizeof(uint32_t);
@@ -1146,6 +1181,69 @@ static void p9_clunk(struct ring *ring, struct p9_header *hdr)
     fill_buffer(ring, hdr->cmd + 1, hdr->tag, "");
 }
 
+static void fill_p9_stat(device *device, struct p9_stat *p9s, struct stat *st,
+                         const char *name)
+{
+    memset(p9s, 0, sizeof(*p9s));
+    fill_qid(device, NULL, &p9s->qid, st);
+    p9s->mode = st->st_mode & 0777;
+    if ( S_ISDIR(st->st_mode) )
+        p9s->mode |= P9_CREATE_PERM_DIR;
+    p9s->atime = st->st_atime;
+    p9s->mtime = st->st_mtime;
+    p9s->length = st->st_size;
+    p9s->name = name;
+    p9s->uid = "";
+    p9s->gid = "";
+    p9s->muid = "";
+    p9s->extension = "";
+    p9s->n_uid = 0;
+    p9s->n_gid = 0;
+    p9s->n_muid = 0;
+
+    /*
+     * Size of individual fields without the size field, including 5 2-byte
+     * string length fields.
+     */
+    p9s->size = 71 + strlen(p9s->name);
+}
+
+static void p9_stat(struct ring *ring, struct p9_header *hdr)
+{
+    device *device = ring->device;
+    uint32_t fid;
+    struct p9_fid *fidp;
+    struct p9_stat p9s;
+    struct stat st;
+    int ret;
+
+    ret = fill_data(ring, "U", &fid);
+    if ( ret != 1 )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+
+    fidp = get_fid_ref(device, fid);
+    if ( !fidp )
+    {
+        p9_error(ring, hdr->tag, ENOENT);
+        return;
+    }
+
+    if ( fstatat(device->root_fd, fidp->path, &st, 0) < 0 )
+    {
+        p9_error(ring, hdr->tag, errno);
+        goto out;
+    }
+    fill_p9_stat(device, &p9s, &st, strrchr(fidp->path, '/') + 1);
+
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "s", &p9s);
+
+ out:
+    free_fid(device, fidp);
+}
+
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
@@ -1225,6 +1323,10 @@ void *io_thread(void *arg)
                 p9_clunk(ring, &hdr);
                 break;
 
+            case P9_CMD_STAT:
+                p9_stat(ring, &hdr);
+                break;
+
             default:
                 syslog(LOG_DEBUG, "%u.%u sent unhandled command %u\n",
                        ring->device->domid, ring->device->devid, hdr.cmd);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 16 10:56:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 16 Feb 2024 10:56:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682150.1061232 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravtm-0008N6-EX; Fri, 16 Feb 2024 10:56:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682150.1061232; Fri, 16 Feb 2024 10:56:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravtm-0008My-Bt; Fri, 16 Feb 2024 10:56:54 +0000
Received: by outflank-mailman (input) for mailman id 682150;
 Fri, 16 Feb 2024 10:56:53 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravtl-0008Mn-9s
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:53 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravtl-0007qF-9A
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:53 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravtl-0005S1-8T
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:56:53 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=moIClaULkH5Tf/DXpY0koI5fvDEzVQRiAxf5y5l0F5s=; b=iVMh6LTeptbSVdeooLt+4+5wJq
	c4m//OHwsrAnCrzKSvwN5wTleFFDXMDmnXv1OC1RYDn1T6GpHILnVwnwdoYef81l/UtCGGBoRhH4K
	FrS7jXTE/YfugTJcVt6SY06OTAl/UY8mVvQ8EzczQFp7L4/aYauNz3+RIuilrEQmSgpg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xen-9pfsd: add 9pfs write request support
Message-Id: <E1ravtl-0005S1-8T@xenbits.xenproject.org>
Date: Fri, 16 Feb 2024 10:56:53 +0000

commit e93172d57dd72efa4d9a15eaeacc827a3fa6123e
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:05:00 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs write request support
    
    Add the write request of the 9pfs protocol.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/9pfsd/io.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index 75e516738b..a7a6e70b66 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -33,6 +33,7 @@
 #define P9_CMD_WALK       110
 #define P9_CMD_OPEN       112
 #define P9_CMD_CREATE     114
+#define P9_CMD_WRITE      118
 #define P9_CMD_CLUNK      120
 #define P9_CMD_STAT       124
 
@@ -1244,6 +1245,55 @@ static void p9_stat(struct ring *ring, struct p9_header *hdr)
     free_fid(device, fidp);
 }
 
+static void p9_write(struct ring *ring, struct p9_header *hdr)
+{
+    device *device = ring->device;
+    uint32_t fid;
+    uint64_t off;
+    unsigned int len;
+    uint32_t written;
+    void *buf;
+    struct p9_fid *fidp;
+    int ret;
+
+    ret = fill_data(ring, "ULD", &fid, &off, &len, ring->buffer);
+    if ( ret != 3 )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+
+    fidp = get_fid_ref(device, fid);
+    if ( !fidp || !fidp->opened || fidp->isdir )
+    {
+        p9_error(ring, hdr->tag, EBADF);
+        goto out;
+    }
+
+    buf = ring->buffer;
+
+    while ( len != 0 )
+    {
+        ret = pwrite(fidp->fd, buf, len, off);
+        if ( ret < 0 )
+            break;
+        len -= ret;
+        buf += ret;
+        off += ret;
+    }
+
+    written = buf - ring->buffer;
+    if ( written == 0 )
+    {
+        p9_error(ring, hdr->tag, errno);
+        goto out;
+    }
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "U", &written);
+
+ out:
+    free_fid(device, fidp);
+}
+
 void *io_thread(void *arg)
 {
     struct ring *ring = arg;
@@ -1319,6 +1369,10 @@ void *io_thread(void *arg)
                 p9_create(ring, &hdr);
                 break;
 
+            case P9_CMD_WRITE:
+                p9_write(ring, &hdr);
+                break;
+
             case P9_CMD_CLUNK:
                 p9_clunk(ring, &hdr);
                 break;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 16 10:57:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 16 Feb 2024 10:57:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682151.1061236 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravtw-0008Px-GA; Fri, 16 Feb 2024 10:57:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682151.1061236; Fri, 16 Feb 2024 10:57:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ravtw-0008Pn-DN; Fri, 16 Feb 2024 10:57:04 +0000
Received: by outflank-mailman (input) for mailman id 682151;
 Fri, 16 Feb 2024 10:57:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravtv-0008Pg-Cz
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:57:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravtv-0007qa-CE
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:57:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ravtv-0005Sf-BW
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 10:57:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=sVWyE2ZVydcNs9AdM34dM5MmdmGFirWLoWkAQg7vNCo=; b=aUKvOSJUKHpZNsmknFFUUBPv+m
	iuLmStqvO7WUPKRBf9HkkzXfF4bOQLL5vWc2+gOXHonGft8Ul98o8K+M62y2cHztHnj6+Z3GzmOiv
	60aiD0YS5B9PaHUuaxNysEOxNvD9CF2IYcLC8VbjvaQZX2yqCxcf6aCfpnmiXudSZrgc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xen-9pfsd: add 9pfs read request support
Message-Id: <E1ravtv-0005Sf-BW@xenbits.xenproject.org>
Date: Fri, 16 Feb 2024 10:57:03 +0000

commit 78398afae10bfb4ab94e8af17b7ed58510a57d96
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 15 14:05:01 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Feb 15 16:24:39 2024 +0000

    tools/xen-9pfsd: add 9pfs read request support
    
    Add the read request of the 9pfs protocol.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/9pfsd/io.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 93 insertions(+)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index a7a6e70b66..ebc4102713 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -33,6 +33,7 @@
 #define P9_CMD_WALK       110
 #define P9_CMD_OPEN       112
 #define P9_CMD_CREATE     114
+#define P9_CMD_READ       116
 #define P9_CMD_WRITE      118
 #define P9_CMD_CLUNK      120
 #define P9_CMD_STAT       124
@@ -1245,6 +1246,94 @@ static void p9_stat(struct ring *ring, struct p9_header *hdr)
     free_fid(device, fidp);
 }
 
+static void p9_read(struct ring *ring, struct p9_header *hdr)
+{
+    device *device = ring->device;
+    uint32_t fid;
+    uint64_t off;
+    unsigned int len;
+    uint32_t count;
+    void *buf;
+    struct p9_fid *fidp;
+    int ret;
+
+    ret = fill_data(ring, "ULU", &fid, &off, &count);
+    if ( ret != 3 )
+    {
+        p9_error(ring, hdr->tag, EINVAL);
+        return;
+    }
+
+    fidp = get_fid_ref(device, fid);
+    if ( !fidp || !fidp->opened )
+    {
+        errno = EBADF;
+        goto err;
+    }
+
+    len = count;
+    buf = ring->buffer + sizeof(*hdr) + sizeof(uint32_t);
+
+    if ( fidp->isdir )
+    {
+        struct dirent *dirent;
+        struct stat st;
+        struct p9_stat p9s;
+
+        if ( off == 0 )
+            rewinddir(fidp->data);
+
+        while ( len != 0 )
+        {
+            errno = 0;
+            dirent = readdir(fidp->data);
+            if ( !dirent )
+            {
+                if ( errno )
+                    goto err;
+                break;
+            }
+            if ( fstatat(fidp->fd, dirent->d_name, &st, 0) < 0 )
+                goto err;
+            fill_p9_stat(device, &p9s, &st, dirent->d_name);
+            if ( p9s.size + sizeof(p9s.size) > len )
+            {
+                seekdir(fidp->data, dirent->d_off);
+                break;
+            }
+            fill_buffer_at(&buf, "s", &p9s);
+            len -= p9s.size + sizeof(p9s.size);
+        }
+    }
+    else
+    {
+        while ( len != 0 )
+        {
+            ret = pread(fidp->fd, buf, len, off);
+            if ( ret <= 0 )
+                break;
+            len -= ret;
+            buf += ret;
+            off += ret;
+        }
+        if ( ret < 0 && len == count )
+            goto err;
+    }
+
+    buf = ring->buffer + sizeof(*hdr) + sizeof(uint32_t);
+    len = count - len;
+    fill_buffer(ring, hdr->cmd + 1, hdr->tag, "D", &len, buf);
+
+ out:
+    free_fid(device, fidp);
+
+    return;
+
+ err:
+    p9_error(ring, hdr->tag, errno);
+    goto out;
+}
+
 static void p9_write(struct ring *ring, struct p9_header *hdr)
 {
     device *device = ring->device;
@@ -1369,6 +1458,10 @@ void *io_thread(void *arg)
                 p9_create(ring, &hdr);
                 break;
 
+            case P9_CMD_READ:
+                p9_read(ring, &hdr);
+                break;
+
             case P9_CMD_WRITE:
                 p9_write(ring, &hdr);
                 break;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 16 17:22:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 16 Feb 2024 17:22:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682336.1061483 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rb1uW-0003LP-W1; Fri, 16 Feb 2024 17:22:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682336.1061483; Fri, 16 Feb 2024 17:22:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rb1uW-0003LI-TG; Fri, 16 Feb 2024 17:22:04 +0000
Received: by outflank-mailman (input) for mailman id 682336;
 Fri, 16 Feb 2024 17:22:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rb1uV-0003LC-Qv
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 17:22:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rb1uV-0007FN-Q0
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 17:22:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rb1uV-0000nZ-OK
 for xen-changelog@lists.xenproject.org; Fri, 16 Feb 2024 17:22:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=BJm7ESIYR1UskEQEdNqmXd/52zvzXNRyy3xCxIxJfT8=; b=MUKredXuhDg/n0ljhtuUH3mZXV
	GTCGATrLTASYTlb2kiFHXlzL6Wz8FYuy92+1PWGT+3SXCfz3R42gho/vYitc2JrN/nglxJe9rXcL0
	jZ+7gGVYkUvcK8f5V/UagrUdl/exHRTsgd1+z9VM5VpEYqoPvuzL48F71vjUQ0lcxmX0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/arm: fixmap: Rename the fixmap slots to follow the x86 convention
Message-Id: <E1rb1uV-0000nZ-OK@xenbits.xenproject.org>
Date: Fri, 16 Feb 2024 17:22:03 +0000

commit 0441c3acc7e9e72e984ce49d32e61827894ae4a3
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Tue Jan 16 19:25:58 2024 +0000
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Fri Feb 16 17:16:08 2024 +0000

    xen/arm: fixmap: Rename the fixmap slots to follow the x86 convention
    
    At the moment the fixmap slots are prefixed differently between arm and
    x86.
    
    Some of them (e.g. the PMAP slots) are used in common code. So it would
    be better if they are named the same way to avoid having to create
    aliases.
    
    I have decided to use the x86 naming because they are less change. So
    all the Arm fixmap slots will now be prefixed with FIX rather than
    FIXMAP.
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Signed-off-by: Elias El Yandouzi <eliasely@amazon.com>
    
    Reviewed-by: Henry Wang <Henry.Wang@arm.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
 xen/arch/arm/acpi/lib.c                 | 18 +++++++++---------
 xen/arch/arm/include/asm/early_printk.h |  2 +-
 xen/arch/arm/include/asm/fixmap.h       | 16 ++++++++--------
 xen/arch/arm/mmu/setup.c                |  6 +++---
 xen/common/pmap.c                       |  8 ++++----
 5 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
index 41d521f720..736cf09eca 100644
--- a/xen/arch/arm/acpi/lib.c
+++ b/xen/arch/arm/acpi/lib.c
@@ -40,10 +40,10 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
         return NULL;
 
     offset = phys & (PAGE_SIZE - 1);
-    base = FIXMAP_ADDR(FIXMAP_ACPI_BEGIN) + offset;
+    base = FIXMAP_ADDR(FIX_ACPI_BEGIN) + offset;
 
     /* Check the fixmap is big enough to map the region */
-    if ( (FIXMAP_ADDR(FIXMAP_ACPI_END) + PAGE_SIZE - base) < size )
+    if ( (FIXMAP_ADDR(FIX_ACPI_END) + PAGE_SIZE - base) < size )
         return NULL;
 
     /* With the fixmap, we can only map one region at the time */
@@ -54,7 +54,7 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
 
     size += offset;
     mfn = maddr_to_mfn(phys);
-    idx = FIXMAP_ACPI_BEGIN;
+    idx = FIX_ACPI_BEGIN;
 
     do {
         set_fixmap(idx, mfn, PAGE_HYPERVISOR);
@@ -72,8 +72,8 @@ bool __acpi_unmap_table(const void *ptr, unsigned long size)
     unsigned int idx;
 
     /* We are only handling fixmap address in the arch code */
-    if ( (vaddr < FIXMAP_ADDR(FIXMAP_ACPI_BEGIN)) ||
-         (vaddr >= (FIXMAP_ADDR(FIXMAP_ACPI_END) + PAGE_SIZE)) )
+    if ( (vaddr < FIXMAP_ADDR(FIX_ACPI_BEGIN)) ||
+         (vaddr >= (FIXMAP_ADDR(FIX_ACPI_END) + PAGE_SIZE)) )
         return false;
 
     /*
@@ -81,16 +81,16 @@ bool __acpi_unmap_table(const void *ptr, unsigned long size)
      * for the ACPI fixmap region. The caller is expected to free with
      * the same address.
      */
-    ASSERT((vaddr & PAGE_MASK) == FIXMAP_ADDR(FIXMAP_ACPI_BEGIN));
+    ASSERT((vaddr & PAGE_MASK) == FIXMAP_ADDR(FIX_ACPI_BEGIN));
 
     /* The region allocated fit in the ACPI fixmap region. */
-    ASSERT(size < (FIXMAP_ADDR(FIXMAP_ACPI_END) + PAGE_SIZE - vaddr));
+    ASSERT(size < (FIXMAP_ADDR(FIX_ACPI_END) + PAGE_SIZE - vaddr));
     ASSERT(fixmap_inuse);
 
     fixmap_inuse = false;
 
-    size += vaddr - FIXMAP_ADDR(FIXMAP_ACPI_BEGIN);
-    idx = FIXMAP_ACPI_BEGIN;
+    size += vaddr - FIXMAP_ADDR(FIX_ACPI_BEGIN);
+    idx = FIX_ACPI_BEGIN;
 
     do
     {
diff --git a/xen/arch/arm/include/asm/early_printk.h b/xen/arch/arm/include/asm/early_printk.h
index c1e84f8b00..f444e89a86 100644
--- a/xen/arch/arm/include/asm/early_printk.h
+++ b/xen/arch/arm/include/asm/early_printk.h
@@ -17,7 +17,7 @@
 
 /* need to add the uart address offset in page to the fixmap address */
 #define EARLY_UART_VIRTUAL_ADDRESS \
-    (FIXMAP_ADDR(FIXMAP_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
+    (FIXMAP_ADDR(FIX_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
 
 #define TEMPORARY_EARLY_UART_VIRTUAL_ADDRESS \
     (TEMPORARY_FIXMAP_ADDR(FIXMAP_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
diff --git a/xen/arch/arm/include/asm/fixmap.h b/xen/arch/arm/include/asm/fixmap.h
index 734eb9b1d4..a823456ecb 100644
--- a/xen/arch/arm/include/asm/fixmap.h
+++ b/xen/arch/arm/include/asm/fixmap.h
@@ -8,17 +8,17 @@
 #include <xen/pmap.h>
 
 /* Fixmap slots */
-#define FIXMAP_CONSOLE  0  /* The primary UART */
-#define FIXMAP_MISC     1  /* Ephemeral mappings of hardware */
-#define FIXMAP_ACPI_BEGIN  2  /* Start mappings of ACPI tables */
-#define FIXMAP_ACPI_END    (FIXMAP_ACPI_BEGIN + NUM_FIXMAP_ACPI_PAGES - 1)  /* End mappings of ACPI tables */
-#define FIXMAP_PMAP_BEGIN (FIXMAP_ACPI_END + 1) /* Start of PMAP */
-#define FIXMAP_PMAP_END (FIXMAP_PMAP_BEGIN + NUM_FIX_PMAP - 1) /* End of PMAP */
+#define FIX_CONSOLE  0  /* The primary UART */
+#define FIX_MISC     1  /* Ephemeral mappings of hardware */
+#define FIX_ACPI_BEGIN  2  /* Start mappings of ACPI tables */
+#define FIX_ACPI_END    (FIX_ACPI_BEGIN + NUM_FIXMAP_ACPI_PAGES - 1)  /* End mappings of ACPI tables */
+#define FIX_PMAP_BEGIN (FIX_ACPI_END + 1) /* Start of PMAP */
+#define FIX_PMAP_END (FIX_PMAP_BEGIN + NUM_FIX_PMAP - 1) /* End of PMAP */
 
-#define FIXMAP_LAST FIXMAP_PMAP_END
+#define FIX_LAST FIX_PMAP_END
 
 #define FIXADDR_START FIXMAP_ADDR(0)
-#define FIXADDR_TOP FIXMAP_ADDR(FIXMAP_LAST)
+#define FIXADDR_TOP FIXMAP_ADDR(FIX_LAST)
 
 #ifndef __ASSEMBLY__
 
diff --git a/xen/arch/arm/mmu/setup.c b/xen/arch/arm/mmu/setup.c
index 72725840b6..57f1b46499 100644
--- a/xen/arch/arm/mmu/setup.c
+++ b/xen/arch/arm/mmu/setup.c
@@ -351,7 +351,7 @@ void free_init_memory(void)
  */
 void __init copy_from_paddr(void *dst, paddr_t paddr, unsigned long len)
 {
-    void *src = (void *)FIXMAP_ADDR(FIXMAP_MISC);
+    void *src = (void *)FIXMAP_ADDR(FIX_MISC);
 
     while (len) {
         unsigned long l, s;
@@ -359,10 +359,10 @@ void __init copy_from_paddr(void *dst, paddr_t paddr, unsigned long len)
         s = paddr & (PAGE_SIZE - 1);
         l = min(PAGE_SIZE - s, len);
 
-        set_fixmap(FIXMAP_MISC, maddr_to_mfn(paddr), PAGE_HYPERVISOR_WC);
+        set_fixmap(FIX_MISC, maddr_to_mfn(paddr), PAGE_HYPERVISOR_WC);
         memcpy(dst, src + s, l);
         clean_dcache_va_range(dst, l);
-        clear_fixmap(FIXMAP_MISC);
+        clear_fixmap(FIX_MISC);
 
         paddr += l;
         dst += l;
diff --git a/xen/common/pmap.c b/xen/common/pmap.c
index 14517198aa..6e3ba9298d 100644
--- a/xen/common/pmap.c
+++ b/xen/common/pmap.c
@@ -32,8 +32,8 @@ void *__init pmap_map(mfn_t mfn)
 
     __set_bit(idx, inuse);
 
-    slot = idx + FIXMAP_PMAP_BEGIN;
-    ASSERT(slot >= FIXMAP_PMAP_BEGIN && slot <= FIXMAP_PMAP_END);
+    slot = idx + FIX_PMAP_BEGIN;
+    ASSERT(slot >= FIX_PMAP_BEGIN && slot <= FIX_PMAP_END);
 
     /*
      * We cannot use set_fixmap() here. We use PMAP when the domain map
@@ -53,10 +53,10 @@ void __init pmap_unmap(const void *p)
     unsigned int slot = virt_to_fix((unsigned long)p);
 
     ASSERT(system_state < SYS_STATE_smp_boot);
-    ASSERT(slot >= FIXMAP_PMAP_BEGIN && slot <= FIXMAP_PMAP_END);
+    ASSERT(slot >= FIX_PMAP_BEGIN && slot <= FIX_PMAP_END);
     ASSERT(!in_irq());
 
-    idx = slot - FIXMAP_PMAP_BEGIN;
+    idx = slot - FIX_PMAP_BEGIN;
 
     __clear_bit(idx, inuse);
     arch_pmap_unmap(slot);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Sat Feb 17 16:55:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 17 Feb 2024 16:55:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682476.1061564 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rbNxv-000061-E6; Sat, 17 Feb 2024 16:55:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682476.1061564; Sat, 17 Feb 2024 16:55:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rbNxv-00005t-BN; Sat, 17 Feb 2024 16:55:03 +0000
Received: by outflank-mailman (input) for mailman id 682476;
 Sat, 17 Feb 2024 16:55:01 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rbNxt-00005h-Rm
 for xen-changelog@lists.xenproject.org; Sat, 17 Feb 2024 16:55:01 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rbNxt-000212-MB
 for xen-changelog@lists.xenproject.org; Sat, 17 Feb 2024 16:55:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rbNxt-00051G-In
 for xen-changelog@lists.xenproject.org; Sat, 17 Feb 2024 16:55:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=RGmAM///mZxcXS9c37oEBWS6Hk+5s1dX3AIplHTKuKQ=; b=AU3RSM2Lt9kREfpwHfDbwEGegI
	3QpuYPKFOZUd1VlDO0KTMPgSrkSWdhvVMgkATeqEbI75PgoZ3QOukUh2JqOy5GhqxqgI2rRTbSXrX
	1LvFMF63NiLuU5uyUAdYkPsXktYWePe8pnQKYovV8/0FF9grM0rnZAEBOq56WpKz3ei8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: fixmap: Rename the fixmap slots to follow the x86 convention
Message-Id: <E1rbNxt-00051G-In@xenbits.xenproject.org>
Date: Sat, 17 Feb 2024 16:55:01 +0000

commit 0441c3acc7e9e72e984ce49d32e61827894ae4a3
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Tue Jan 16 19:25:58 2024 +0000
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Fri Feb 16 17:16:08 2024 +0000

    xen/arm: fixmap: Rename the fixmap slots to follow the x86 convention
    
    At the moment the fixmap slots are prefixed differently between arm and
    x86.
    
    Some of them (e.g. the PMAP slots) are used in common code. So it would
    be better if they are named the same way to avoid having to create
    aliases.
    
    I have decided to use the x86 naming because they are less change. So
    all the Arm fixmap slots will now be prefixed with FIX rather than
    FIXMAP.
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Signed-off-by: Elias El Yandouzi <eliasely@amazon.com>
    
    Reviewed-by: Henry Wang <Henry.Wang@arm.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
 xen/arch/arm/acpi/lib.c                 | 18 +++++++++---------
 xen/arch/arm/include/asm/early_printk.h |  2 +-
 xen/arch/arm/include/asm/fixmap.h       | 16 ++++++++--------
 xen/arch/arm/mmu/setup.c                |  6 +++---
 xen/common/pmap.c                       |  8 ++++----
 5 files changed, 25 insertions(+), 25 deletions(-)

diff --git a/xen/arch/arm/acpi/lib.c b/xen/arch/arm/acpi/lib.c
index 41d521f720..736cf09eca 100644
--- a/xen/arch/arm/acpi/lib.c
+++ b/xen/arch/arm/acpi/lib.c
@@ -40,10 +40,10 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
         return NULL;
 
     offset = phys & (PAGE_SIZE - 1);
-    base = FIXMAP_ADDR(FIXMAP_ACPI_BEGIN) + offset;
+    base = FIXMAP_ADDR(FIX_ACPI_BEGIN) + offset;
 
     /* Check the fixmap is big enough to map the region */
-    if ( (FIXMAP_ADDR(FIXMAP_ACPI_END) + PAGE_SIZE - base) < size )
+    if ( (FIXMAP_ADDR(FIX_ACPI_END) + PAGE_SIZE - base) < size )
         return NULL;
 
     /* With the fixmap, we can only map one region at the time */
@@ -54,7 +54,7 @@ char *__acpi_map_table(paddr_t phys, unsigned long size)
 
     size += offset;
     mfn = maddr_to_mfn(phys);
-    idx = FIXMAP_ACPI_BEGIN;
+    idx = FIX_ACPI_BEGIN;
 
     do {
         set_fixmap(idx, mfn, PAGE_HYPERVISOR);
@@ -72,8 +72,8 @@ bool __acpi_unmap_table(const void *ptr, unsigned long size)
     unsigned int idx;
 
     /* We are only handling fixmap address in the arch code */
-    if ( (vaddr < FIXMAP_ADDR(FIXMAP_ACPI_BEGIN)) ||
-         (vaddr >= (FIXMAP_ADDR(FIXMAP_ACPI_END) + PAGE_SIZE)) )
+    if ( (vaddr < FIXMAP_ADDR(FIX_ACPI_BEGIN)) ||
+         (vaddr >= (FIXMAP_ADDR(FIX_ACPI_END) + PAGE_SIZE)) )
         return false;
 
     /*
@@ -81,16 +81,16 @@ bool __acpi_unmap_table(const void *ptr, unsigned long size)
      * for the ACPI fixmap region. The caller is expected to free with
      * the same address.
      */
-    ASSERT((vaddr & PAGE_MASK) == FIXMAP_ADDR(FIXMAP_ACPI_BEGIN));
+    ASSERT((vaddr & PAGE_MASK) == FIXMAP_ADDR(FIX_ACPI_BEGIN));
 
     /* The region allocated fit in the ACPI fixmap region. */
-    ASSERT(size < (FIXMAP_ADDR(FIXMAP_ACPI_END) + PAGE_SIZE - vaddr));
+    ASSERT(size < (FIXMAP_ADDR(FIX_ACPI_END) + PAGE_SIZE - vaddr));
     ASSERT(fixmap_inuse);
 
     fixmap_inuse = false;
 
-    size += vaddr - FIXMAP_ADDR(FIXMAP_ACPI_BEGIN);
-    idx = FIXMAP_ACPI_BEGIN;
+    size += vaddr - FIXMAP_ADDR(FIX_ACPI_BEGIN);
+    idx = FIX_ACPI_BEGIN;
 
     do
     {
diff --git a/xen/arch/arm/include/asm/early_printk.h b/xen/arch/arm/include/asm/early_printk.h
index c1e84f8b00..f444e89a86 100644
--- a/xen/arch/arm/include/asm/early_printk.h
+++ b/xen/arch/arm/include/asm/early_printk.h
@@ -17,7 +17,7 @@
 
 /* need to add the uart address offset in page to the fixmap address */
 #define EARLY_UART_VIRTUAL_ADDRESS \
-    (FIXMAP_ADDR(FIXMAP_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
+    (FIXMAP_ADDR(FIX_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
 
 #define TEMPORARY_EARLY_UART_VIRTUAL_ADDRESS \
     (TEMPORARY_FIXMAP_ADDR(FIXMAP_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
diff --git a/xen/arch/arm/include/asm/fixmap.h b/xen/arch/arm/include/asm/fixmap.h
index 734eb9b1d4..a823456ecb 100644
--- a/xen/arch/arm/include/asm/fixmap.h
+++ b/xen/arch/arm/include/asm/fixmap.h
@@ -8,17 +8,17 @@
 #include <xen/pmap.h>
 
 /* Fixmap slots */
-#define FIXMAP_CONSOLE  0  /* The primary UART */
-#define FIXMAP_MISC     1  /* Ephemeral mappings of hardware */
-#define FIXMAP_ACPI_BEGIN  2  /* Start mappings of ACPI tables */
-#define FIXMAP_ACPI_END    (FIXMAP_ACPI_BEGIN + NUM_FIXMAP_ACPI_PAGES - 1)  /* End mappings of ACPI tables */
-#define FIXMAP_PMAP_BEGIN (FIXMAP_ACPI_END + 1) /* Start of PMAP */
-#define FIXMAP_PMAP_END (FIXMAP_PMAP_BEGIN + NUM_FIX_PMAP - 1) /* End of PMAP */
+#define FIX_CONSOLE  0  /* The primary UART */
+#define FIX_MISC     1  /* Ephemeral mappings of hardware */
+#define FIX_ACPI_BEGIN  2  /* Start mappings of ACPI tables */
+#define FIX_ACPI_END    (FIX_ACPI_BEGIN + NUM_FIXMAP_ACPI_PAGES - 1)  /* End mappings of ACPI tables */
+#define FIX_PMAP_BEGIN (FIX_ACPI_END + 1) /* Start of PMAP */
+#define FIX_PMAP_END (FIX_PMAP_BEGIN + NUM_FIX_PMAP - 1) /* End of PMAP */
 
-#define FIXMAP_LAST FIXMAP_PMAP_END
+#define FIX_LAST FIX_PMAP_END
 
 #define FIXADDR_START FIXMAP_ADDR(0)
-#define FIXADDR_TOP FIXMAP_ADDR(FIXMAP_LAST)
+#define FIXADDR_TOP FIXMAP_ADDR(FIX_LAST)
 
 #ifndef __ASSEMBLY__
 
diff --git a/xen/arch/arm/mmu/setup.c b/xen/arch/arm/mmu/setup.c
index 72725840b6..57f1b46499 100644
--- a/xen/arch/arm/mmu/setup.c
+++ b/xen/arch/arm/mmu/setup.c
@@ -351,7 +351,7 @@ void free_init_memory(void)
  */
 void __init copy_from_paddr(void *dst, paddr_t paddr, unsigned long len)
 {
-    void *src = (void *)FIXMAP_ADDR(FIXMAP_MISC);
+    void *src = (void *)FIXMAP_ADDR(FIX_MISC);
 
     while (len) {
         unsigned long l, s;
@@ -359,10 +359,10 @@ void __init copy_from_paddr(void *dst, paddr_t paddr, unsigned long len)
         s = paddr & (PAGE_SIZE - 1);
         l = min(PAGE_SIZE - s, len);
 
-        set_fixmap(FIXMAP_MISC, maddr_to_mfn(paddr), PAGE_HYPERVISOR_WC);
+        set_fixmap(FIX_MISC, maddr_to_mfn(paddr), PAGE_HYPERVISOR_WC);
         memcpy(dst, src + s, l);
         clean_dcache_va_range(dst, l);
-        clear_fixmap(FIXMAP_MISC);
+        clear_fixmap(FIX_MISC);
 
         paddr += l;
         dst += l;
diff --git a/xen/common/pmap.c b/xen/common/pmap.c
index 14517198aa..6e3ba9298d 100644
--- a/xen/common/pmap.c
+++ b/xen/common/pmap.c
@@ -32,8 +32,8 @@ void *__init pmap_map(mfn_t mfn)
 
     __set_bit(idx, inuse);
 
-    slot = idx + FIXMAP_PMAP_BEGIN;
-    ASSERT(slot >= FIXMAP_PMAP_BEGIN && slot <= FIXMAP_PMAP_END);
+    slot = idx + FIX_PMAP_BEGIN;
+    ASSERT(slot >= FIX_PMAP_BEGIN && slot <= FIX_PMAP_END);
 
     /*
      * We cannot use set_fixmap() here. We use PMAP when the domain map
@@ -53,10 +53,10 @@ void __init pmap_unmap(const void *p)
     unsigned int slot = virt_to_fix((unsigned long)p);
 
     ASSERT(system_state < SYS_STATE_smp_boot);
-    ASSERT(slot >= FIXMAP_PMAP_BEGIN && slot <= FIXMAP_PMAP_END);
+    ASSERT(slot >= FIX_PMAP_BEGIN && slot <= FIX_PMAP_END);
     ASSERT(!in_irq());
 
-    idx = slot - FIXMAP_PMAP_BEGIN;
+    idx = slot - FIX_PMAP_BEGIN;
 
     __clear_bit(idx, inuse);
     arch_pmap_unmap(slot);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Mon Feb 19 11:55:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 19 Feb 2024 11:55:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682802.1061972 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rc2Ek-0008Qi-Bl; Mon, 19 Feb 2024 11:55:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682802.1061972; Mon, 19 Feb 2024 11:55:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rc2Ek-0008Qa-8m; Mon, 19 Feb 2024 11:55:06 +0000
Received: by outflank-mailman (input) for mailman id 682802;
 Mon, 19 Feb 2024 11:55:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rc2Ei-0008QU-Bq
 for xen-changelog@lists.xenproject.org; Mon, 19 Feb 2024 11:55:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rc2Ei-0005JH-4T
 for xen-changelog@lists.xenproject.org; Mon, 19 Feb 2024 11:55:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rc2Ei-0004C6-3T
 for xen-changelog@lists.xenproject.org; Mon, 19 Feb 2024 11:55:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=2nKK2kxGwyJdb7fYVwCGC+qka1XOFqhVuryaWNw70hI=; b=amdNIUC+zWEPWfNx7kntBwJlgr
	TEWkibC7gFfrDbMCd/rVbCY6yU3HS1LeBNbbSxYa+S+PV1tr+Z0Zc3nkGgJOLF3KGSyx/Iiv04T1a
	rwmr+P576MEQ24BDzSVnmpI6fggBJ7Vi2cVDQBG7RNu1a6qdQXGkokbHFS8q+0lRpGqo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] mm: add the __must_check attribute to {gfn,mfn,dfn}_add()
Message-Id: <E1rc2Ei-0004C6-3T@xenbits.xenproject.org>
Date: Mon, 19 Feb 2024 11:55:04 +0000

commit 4917b9a423cbb09a44403c6a0d292a4baf85b93c
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon Feb 19 12:44:50 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 19 12:44:50 2024 +0100

    mm: add the __must_check attribute to {gfn,mfn,dfn}_add()
    
    It's not obvious from just the function name whether the incremented value will
    be stored in the parameter, or returned to the caller.  That has leads to bugs
    in the past as callers may assume the incremented value is stored in the
    parameter.
    
    Add the __must_check attribute to the function to easily spot callers that
    don't consume the returned value, which signals an error in the caller logic.
    
    No functional change intended.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/include/xen/iommu.h    | 2 +-
 xen/include/xen/mm-frame.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
index 7aa6a77209..9621459c63 100644
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -42,7 +42,7 @@ TYPE_SAFE(uint64_t, dfn);
 #undef dfn_x
 #endif
 
-static inline dfn_t dfn_add(dfn_t dfn, unsigned long i)
+static inline dfn_t __must_check dfn_add(dfn_t dfn, unsigned long i)
 {
     return _dfn(dfn_x(dfn) + i);
 }
diff --git a/xen/include/xen/mm-frame.h b/xen/include/xen/mm-frame.h
index 922ae41880..c25e836f25 100644
--- a/xen/include/xen/mm-frame.h
+++ b/xen/include/xen/mm-frame.h
@@ -23,7 +23,7 @@ TYPE_SAFE(unsigned long, mfn);
 #undef mfn_x
 #endif
 
-static inline mfn_t mfn_add(mfn_t mfn, unsigned long i)
+static inline mfn_t __must_check mfn_add(mfn_t mfn, unsigned long i)
 {
     return _mfn(mfn_x(mfn) + i);
 }
@@ -62,7 +62,7 @@ TYPE_SAFE(unsigned long, gfn);
 #undef gfn_x
 #endif
 
-static inline gfn_t gfn_add(gfn_t gfn, unsigned long i)
+static inline gfn_t __must_check gfn_add(gfn_t gfn, unsigned long i)
 {
     return _gfn(gfn_x(gfn) + i);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 19 11:55:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 19 Feb 2024 11:55:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682803.1061975 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rc2Et-0008SO-Co; Mon, 19 Feb 2024 11:55:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682803.1061975; Mon, 19 Feb 2024 11:55:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rc2Et-0008SG-AB; Mon, 19 Feb 2024 11:55:15 +0000
Received: by outflank-mailman (input) for mailman id 682803;
 Mon, 19 Feb 2024 11:55:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rc2Es-0008S8-9n
 for xen-changelog@lists.xenproject.org; Mon, 19 Feb 2024 11:55:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rc2Es-0005Jp-8z
 for xen-changelog@lists.xenproject.org; Mon, 19 Feb 2024 11:55:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rc2Es-0004Cm-6Y
 for xen-changelog@lists.xenproject.org; Mon, 19 Feb 2024 11:55:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=SEnRa7uMYqlVRjr5ev4wyqqdoAhpDFBoheGfoDtXoY8=; b=mWWxQ/7yenU3MKsxtXpQOra+TX
	ZGfIfZvjfEfj7EPFiIY+SBEL1wp5aI6XCELFssX1SsevWX7Nt6QVlBgux1HGjD/MGOFGkjgmC/T5J
	ZpFMKmc4L4oW5p5U+yvhsZeXsihxA0xV2Jm7yspfNRojwJmOlIcbDBoybT3j8QWnLQjw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] build: Replace `which` with `command -v`
Message-Id: <E1rc2Es-0004Cm-6Y@xenbits.xenproject.org>
Date: Mon, 19 Feb 2024 11:55:14 +0000

commit f93629b18b528a5ab1b1092949c5420069c7226c
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Mon Feb 19 12:45:48 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 19 12:45:48 2024 +0100

    build: Replace `which` with `command -v`
    
    The `which` command is not standard, may not exist on the build host,
    or may not behave as expected by the build system. It is recommended
    to use `command -v` to find out if a command exist and have its path,
    and it's part of a POSIX shell standard (at least, it seems to be
    mandatory since IEEE Std 1003.1-2008, but was optional before).
    
    Fixes: c8a8645f1efe ("xen/build: Automatically locate a suitable python interpreter")
    Fixes: 3b47bcdb6d38 ("xen/build: Use a distro version of figlet")
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Tested-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/Makefile | 4 ++--
 xen/build.mk | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/Makefile b/xen/Makefile
index 21832d6402..767e47d6c7 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -25,8 +25,8 @@ export XEN_BUILD_HOST	:= $(shell hostname)
 endif
 
 # Best effort attempt to find a python interpreter, defaulting to Python 3 if
-# available.  Fall back to just `python` if `which` is nowhere to be found.
-PYTHON_INTERPRETER	:= $(word 1,$(shell which python3 python python2 2>/dev/null) python)
+# available.  Fall back to just `python`.
+PYTHON_INTERPRETER	:= $(word 1,$(shell command -v python3 || command -v python || command -v python2) python)
 export PYTHON		?= $(PYTHON_INTERPRETER)
 
 export CHECKPOLICY	?= checkpolicy
diff --git a/xen/build.mk b/xen/build.mk
index 26dd5a8e87..0f490ca71b 100644
--- a/xen/build.mk
+++ b/xen/build.mk
@@ -1,6 +1,6 @@
 quiet_cmd_banner = BANNER  $@
 define cmd_banner
-    if which figlet >/dev/null 2>&1 ; then \
+    if command -v figlet >/dev/null 2>&1 ; then \
 	echo " Xen $(XEN_FULLVERSION)" | figlet -f $< > $@.tmp; \
     else \
 	echo " Xen $(XEN_FULLVERSION)" > $@.tmp; \
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 19 11:55:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 19 Feb 2024 11:55:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682804.1061979 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rc2F3-0008Uf-Ek; Mon, 19 Feb 2024 11:55:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682804.1061979; Mon, 19 Feb 2024 11:55:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rc2F3-0008UY-Bg; Mon, 19 Feb 2024 11:55:25 +0000
Received: by outflank-mailman (input) for mailman id 682804;
 Mon, 19 Feb 2024 11:55:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rc2F2-0008UK-DX
 for xen-changelog@lists.xenproject.org; Mon, 19 Feb 2024 11:55:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rc2F2-0005K2-Cf
 for xen-changelog@lists.xenproject.org; Mon, 19 Feb 2024 11:55:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rc2F2-0004DG-Bl
 for xen-changelog@lists.xenproject.org; Mon, 19 Feb 2024 11:55:24 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=CWY3tTFiW7k13s6+A42a5oWxpw/+EegxY8Me6Cb3N1s=; b=DTrO/oFJSwva0/MmTvMM1F5c2G
	bfI98VJTPLpexXgvg18n/Wr4x6vylH2MUvJJUlk4GwA1mf0lnSzyrsXaMDYvzUdjdeB3Fxs0Y2tQk
	0JRNrsPzN6OUdG6CxQ/Ap10C7yVXkw2Wy+FT3zsRoGqAVaR6zbOe56VeYYINnlV2KNgQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] libxl: Add "grant_usage" parameter for virtio disk devices
Message-Id: <E1rc2F2-0004DG-Bl@xenbits.xenproject.org>
Date: Mon, 19 Feb 2024 11:55:24 +0000

commit 1eb013ef972408020013a6fb16a36c5a345c6ff7
Author:     Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
AuthorDate: Mon Feb 19 12:46:07 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 19 12:46:07 2024 +0100

    libxl: Add "grant_usage" parameter for virtio disk devices
    
    Allow administrators to control whether Xen grant mappings for
    the virtio disk devices should be used. By default (when new
    parameter is not specified), the existing behavior is retained
    (we enable grants if backend-domid != 0).
    
    Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 docs/man/xl-disk-configuration.5.pod.in |   24 +
 tools/golang/xenlight/helpers.gen.go    |    6 +
 tools/golang/xenlight/types.gen.go      |    1 +
 tools/include/libxl.h                   |    7 +
 tools/libs/light/libxl_arm.c            |    4 +-
 tools/libs/light/libxl_disk.c           |   13 +
 tools/libs/light/libxl_types.idl        |    1 +
 tools/libs/util/libxlu_disk_l.c         | 1001 ++++++++++++++++---------------
 tools/libs/util/libxlu_disk_l.h         |    9 +-
 tools/libs/util/libxlu_disk_l.l         |    3 +
 10 files changed, 590 insertions(+), 479 deletions(-)

diff --git a/docs/man/xl-disk-configuration.5.pod.in b/docs/man/xl-disk-configuration.5.pod.in
index cb442bd5b4..986666ebf8 100644
--- a/docs/man/xl-disk-configuration.5.pod.in
+++ b/docs/man/xl-disk-configuration.5.pod.in
@@ -406,6 +406,30 @@ Virtio frontend driver (virtio-blk) to be used. Please note, the virtual
 device (vdev) is not passed to the guest in that case, but it still must be
 specified for the internal purposes.
 
+=item B<grant_usage=BOOLEAN>
+
+=over 4
+
+=item Description
+
+Specifies the usage of Xen grants for accessing guest memory. Only applicable
+to specification "virtio".
+
+=item Supported values
+
+1, 0
+
+=item Mandatory
+
+No
+
+=item Default value
+
+If this option is missing, then the default grant setting will be used,
+i.e. "grant_usage=1" if backend-domid != 0 or "grant_usage=0" otherwise.
+
+=back
+
 =back
 
 =head1 COLO Parameters
diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/helpers.gen.go
index 0f8e23773c..acdf1c1820 100644
--- a/tools/golang/xenlight/helpers.gen.go
+++ b/tools/golang/xenlight/helpers.gen.go
@@ -1885,6 +1885,9 @@ x.ActiveDisk = C.GoString(xc.active_disk)
 x.HiddenDisk = C.GoString(xc.hidden_disk)
 if err := x.Trusted.fromC(&xc.trusted);err != nil {
 return fmt.Errorf("converting field Trusted: %v", err)
+}
+if err := x.GrantUsage.fromC(&xc.grant_usage);err != nil {
+return fmt.Errorf("converting field GrantUsage: %v", err)
 }
 
  return nil}
@@ -1933,6 +1936,9 @@ if x.HiddenDisk != "" {
 xc.hidden_disk = C.CString(x.HiddenDisk)}
 if err := x.Trusted.toC(&xc.trusted); err != nil {
 return fmt.Errorf("converting field Trusted: %v", err)
+}
+if err := x.GrantUsage.toC(&xc.grant_usage); err != nil {
+return fmt.Errorf("converting field GrantUsage: %v", err)
 }
 
  return nil
diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/types.gen.go
index 9c8b7b81f6..76b4ed991b 100644
--- a/tools/golang/xenlight/types.gen.go
+++ b/tools/golang/xenlight/types.gen.go
@@ -741,6 +741,7 @@ ColoExport string
 ActiveDisk string
 HiddenDisk string
 Trusted Defbool
+GrantUsage Defbool
 }
 
 type DeviceNic struct {
diff --git a/tools/include/libxl.h b/tools/include/libxl.h
index 46bc774126..a370528ba1 100644
--- a/tools/include/libxl.h
+++ b/tools/include/libxl.h
@@ -578,6 +578,13 @@
  */
 #define LIBXL_HAVE_DEVICE_DISK_SPECIFICATION 1
 
+/*
+ * LIBXL_HAVE_DISK_GRANT_USAGE indicates that the libxl_device_disk
+ * has 'grant_usage' field to specify the usage of Xen grants for
+ * the specification 'virtio'.
+ */
+#define LIBXL_HAVE_DISK_GRANT_USAGE 1
+
 /*
  * LIBXL_HAVE_CONSOLE_ADD_XENSTORE indicates presence of the function
  * libxl_console_add_xenstore() in libxl.
diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
index 1539191774..1cb89fa584 100644
--- a/tools/libs/light/libxl_arm.c
+++ b/tools/libs/light/libxl_arm.c
@@ -1372,12 +1372,12 @@ next_resize:
             libxl_device_disk *disk = &d_config->disks[i];
 
             if (disk->specification == LIBXL_DISK_SPECIFICATION_VIRTIO) {
-                if (disk->backend_domid != LIBXL_TOOLSTACK_DOMID)
+                if (libxl_defbool_val(disk->grant_usage))
                     iommu_needed = true;
 
                 FDT( make_virtio_mmio_node(gc, fdt, disk->base, disk->irq,
                                            disk->backend_domid,
-                                           disk->backend_domid != LIBXL_TOOLSTACK_DOMID) );
+                                           libxl_defbool_val(disk->grant_usage)) );
             }
         }
 
diff --git a/tools/libs/light/libxl_disk.c b/tools/libs/light/libxl_disk.c
index ee2e4b0bd3..fa7856f28c 100644
--- a/tools/libs/light/libxl_disk.c
+++ b/tools/libs/light/libxl_disk.c
@@ -183,6 +183,9 @@ static int libxl__device_disk_setdefault(libxl__gc *gc, uint32_t domid,
             return ERROR_INVAL;
         }
         disk->transport = LIBXL_DISK_TRANSPORT_MMIO;
+
+        libxl_defbool_setdefault(&disk->grant_usage,
+                                 disk->backend_domid != LIBXL_TOOLSTACK_DOMID);
     }
 
     if (hotplug && disk->specification == LIBXL_DISK_SPECIFICATION_VIRTIO) {
@@ -468,6 +471,8 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,
             flexarray_append(back, libxl__device_disk_string_of_transport(disk->transport));
             flexarray_append_pair(back, "base", GCSPRINTF("%"PRIu64, disk->base));
             flexarray_append_pair(back, "irq", GCSPRINTF("%u", disk->irq));
+            flexarray_append_pair(back, "grant_usage",
+                                  libxl_defbool_val(disk->grant_usage) ? "1" : "0");
         }
 
         flexarray_append(front, "backend-id");
@@ -662,6 +667,14 @@ static int libxl__disk_from_xenstore(libxl__gc *gc, const char *libxl_path,
             goto cleanup;
         }
         disk->irq = strtoul(tmp, NULL, 10);
+
+        tmp = libxl__xs_read(gc, XBT_NULL,
+                             GCSPRINTF("%s/grant_usage", libxl_path));
+        if (!tmp)
+            libxl_defbool_set(&disk->grant_usage,
+                              disk->backend_domid != LIBXL_TOOLSTACK_DOMID);
+        else
+            libxl_defbool_set(&disk->grant_usage, strtoul(tmp, NULL, 0));
     }
 
     disk->vdev = xs_read(ctx->xsh, XBT_NULL,
diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_types.idl
index 899ad30969..6d76f25528 100644
--- a/tools/libs/light/libxl_types.idl
+++ b/tools/libs/light/libxl_types.idl
@@ -803,6 +803,7 @@ libxl_device_disk = Struct("device_disk", [
     ("active_disk", string),
     ("hidden_disk", string),
     ("trusted", libxl_defbool),
+    ("grant_usage", libxl_defbool),
     ])
 
 libxl_device_nic = Struct("device_nic", [
diff --git a/tools/libs/util/libxlu_disk_l.c b/tools/libs/util/libxlu_disk_l.c
index 0b59723b71..9213dd957c 100644
--- a/tools/libs/util/libxlu_disk_l.c
+++ b/tools/libs/util/libxlu_disk_l.c
@@ -1,7 +1,10 @@
 #line 1 "libxlu_disk_l.c"
+#line 31 "libxlu_disk_l.l"
 #define _GNU_SOURCE
 
-#line 4 "libxlu_disk_l.c"
+
+
+#line 7 "libxlu_disk_l.c"
 
 #define  YY_INT_ALIGNED short int
 
@@ -549,8 +552,8 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
 	yyg->yy_hold_char = *yy_cp; \
 	*yy_cp = '\0'; \
 	yyg->yy_c_buf_p = yy_cp;
-#define YY_NUM_RULES 37
-#define YY_END_OF_BUFFER 38
+#define YY_NUM_RULES 41
+#define YY_END_OF_BUFFER 42
 /* This struct is not used in this scanner,
    but its presence is necessary. */
 struct yy_trans_info
@@ -558,119 +561,127 @@ struct yy_trans_info
 	flex_int32_t yy_verify;
 	flex_int32_t yy_nxt;
 	};
-static const flex_int16_t yy_acclist[594] =
+static const flex_int16_t yy_acclist[634] =
     {   0,
-       36,   36,   38,   34,   35,   37, 8193,   34,   35,   37,
-    16385, 8193,   34,   37,16385,   34,   35,   37,   35,   37,
-       34,   35,   37,   34,   35,   37,   34,   35,   37,   34,
-       35,   37,   34,   35,   37,   34,   35,   37,   34,   35,
-       37,   34,   35,   37,   34,   35,   37,   34,   35,   37,
-       34,   35,   37,   34,   35,   37,   34,   35,   37,   34,
-       35,   37,   34,   35,   37,   34,   35,   37,   36,   37,
-       37,   34,   34, 8193,   34, 8193,   34,16385, 8193,   34,
-     8193,   34,   34, 8225,   34,16417,   34,   34,   34,   34,
-       34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
-
-       34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
-       36, 8193,   34, 8193,   34, 8193, 8225,   34, 8225,   34,
-     8225,   24,   34,   34,   34,   34,   34,   34,   34,   34,
-       34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
-       34,   34,   34,   34,   34,   34,   34, 8225,   34, 8225,
-       34, 8225,   24,   34,   34,   29, 8225,   34,16417,   34,
-       34,   16,   34,   34,   34,   34,   34,   34,   34,   34,
-       34, 8218, 8225,   34,16410,16417,   34,   34,   32, 8225,
-       34,16417,   34, 8217, 8225,   34,16409,16417,   34,   34,
-       34, 8220, 8225,   34,16412,16417,   34,   34,   34,   34,
-
-       34,   29, 8225,   34,   29, 8225,   34,   29,   34,   29,
-     8225,   34,    3,   34,   16,   34,   34,   34,   34,   34,
-       31, 8225,   34,16417,   34,   34,   34, 8218, 8225,   34,
-     8218, 8225,   34, 8218,   34, 8218, 8225,   34,   34,   32,
-     8225,   34,   32, 8225,   34,   32,   34,   32, 8225, 8217,
-     8225,   34, 8217, 8225,   34, 8217,   34, 8217, 8225,   34,
-       34, 8220, 8225,   34, 8220, 8225,   34, 8220,   34, 8220,
-     8225,   34,   34,   11,   34,   34,   29, 8225,   34,   29,
-     8225,   34,   29, 8225,   29,   34,   29,   34,    3,   34,
-       34,   34,   34,   34,   34,   34,   31, 8225,   34,   31,
-
-     8225,   34,   31,   34,   31, 8225,   34,   34,   30, 8225,
-       34,16417, 8218, 8225,   34, 8218, 8225,   34, 8218, 8225,
-     8218,   34, 8218,   34,   34,   32, 8225,   34,   32, 8225,
-       34,   32, 8225,   32,   34,   32, 8217, 8225,   34, 8217,
-     8225,   34, 8217, 8225, 8217,   34, 8217,   34,   34, 8220,
-     8225,   34, 8220, 8225,   34, 8220, 8225, 8220,   34, 8220,
-       34,   34,   11,   24,   11,    7,   34,   34,   34,   34,
-       34,   34,   34,   14,   34,   31, 8225,   34,   31, 8225,
-       34,   31, 8225,   31,   34,   31,    2,   34,   30, 8225,
-       34,   30, 8225,   34,   30,   34,   30, 8225,   17,   34,
-
-       34,   12,   34,   34,   23,   11,   11,   24,    7,   24,
-        7,   34,    8,   34,   34,   34,   34,    6,   34,   14,
-       34,    2,   24,    2,   34,   30, 8225,   34,   30, 8225,
-       34,   30, 8225,   30,   34,   30,   17,   34,   34,   12,
-       24,   12,   34,   27, 8225,   34,16417,   23,   24,   23,
-        7,    7,   24,   34,    8,   24,    8,   34,   34,   34,
-       34,    6,   24,    6,    6,   24,    6,   24,   34,    2,
-        2,   24,   34,   34,   12,   12,   24,   34,   27, 8225,
-       34,   27, 8225,   34,   27,   34,   27, 8225,   23,   24,
-       34,    8,    8,   24,   34,   34,   18,   19,    6,    6,
-
-       24,    6,    6,   34,   34,   15,   34,   34,   27, 8225,
-       34,   27, 8225,   34,   27, 8225,   27,   34,   27,   34,
-       34,   34,   18,   24,   18,   19,   24,   19,    6,    6,
-       34,   34,   15,   34,   34,   21,    9,   20,   18,   18,
-       24,   19,   19,   24,    6,    5,    6,   34,   22,   34,
-       21,   24,   21,    9,   24,    9,   20,   24,   20,    4,
-        6,    5,    6,   34,   22,   24,   22,   34,   21,   21,
-       24,    9,    9,   24,   20,   20,   24,    4,    6,   13,
-       34,   22,   22,   24,   10,   13,   34,   10,   24,   10,
-       10,   10,   24
-
+       40,   40,   42,   38,   39,   41, 8193,   38,   39,   41,
+    16385, 8193,   38,   41,16385,   38,   39,   41,   39,   41,
+       38,   39,   41,   38,   39,   41,   38,   39,   41,   38,
+       39,   41,   38,   39,   41,   38,   39,   41,   38,   39,
+       41,   38,   39,   41,   38,   39,   41,   38,   39,   41,
+       38,   39,   41,   38,   39,   41,   38,   39,   41,   38,
+       39,   41,   38,   39,   41,   38,   39,   41,   38,   39,
+       41,   38,   39,   41,   40,   41,   41,   38,   38, 8193,
+       38, 8193,   38,16385, 8193,   38, 8193,   38,   38, 8229,
+       38,16421,   38,   38,   38,   38,   38,   38,   38,   38,
+
+       38,   38,   38,   38,   38,   38,   38,   38,   38,   38,
+       38,   38,   38,   38,   38,   38,   38,   38,   38,   40,
+     8193,   38, 8193,   38, 8193, 8229,   38, 8229,   38, 8229,
+       28,   38,   38,   38,   38,   38,   38,   38,   38,   38,
+       38,   38,   38,   38,   38,   38,   38,   38,   38,   38,
+       38,   38,   38,   38,   38,   38,   38,   38,   38, 8229,
+       38, 8229,   38, 8229,   28,   38,   38,   33, 8229,   38,
+    16421,   38,   38,   16,   38,   38,   38,   38,   38,   38,
+       38,   38,   38,   38, 8222, 8229,   38,16414,16421,   38,
+       38,   36, 8229,   38,16421,   38, 8221, 8229,   38,16413,
+
+    16421,   38,   38,   38, 8224, 8229,   38,16416,16421,   38,
+       38,   38,   38,   38,   38,   38,   33, 8229,   38,   33,
+     8229,   38,   33,   38,   33, 8229,   38,    3,   38,   16,
+       38,   38,   38,   38,   38,   35, 8229,   38,16421,   38,
+       38,   38,   38, 8222, 8229,   38, 8222, 8229,   38, 8222,
+       38, 8222, 8229,   38,   38,   36, 8229,   38,   36, 8229,
+       38,   36,   38,   36, 8229, 8221, 8229,   38, 8221, 8229,
+       38, 8221,   38, 8221, 8229,   38,   38, 8224, 8229,   38,
+     8224, 8229,   38, 8224,   38, 8224, 8229,   38,   38,   38,
+       38,   11,   38,   38,   33, 8229,   38,   33, 8229,   38,
+
+       33, 8229,   33,   38,   33,   38,    3,   38,   38,   38,
+       38,   38,   38,   38,   35, 8229,   38,   35, 8229,   38,
+       35,   38,   35, 8229,   38,   38,   38,   34, 8229,   38,
+    16421, 8222, 8229,   38, 8222, 8229,   38, 8222, 8229, 8222,
+       38, 8222,   38,   38,   36, 8229,   38,   36, 8229,   38,
+       36, 8229,   36,   38,   36, 8221, 8229,   38, 8221, 8229,
+       38, 8221, 8229, 8221,   38, 8221,   38,   38, 8224, 8229,
+       38, 8224, 8229,   38, 8224, 8229, 8224,   38, 8224,   38,
+       38,   38,   38,   11,   28,   11,    7,   38,   38,   38,
+       38,   38,   38,   38,   14,   38,   35, 8229,   38,   35,
+
+     8229,   38,   35, 8229,   35,   38,   35,    2,   38,   38,
+       34, 8229,   38,   34, 8229,   38,   34,   38,   34, 8229,
+       17,   38,   38,   12,   38,   38,   27,   23,   38,   38,
+       11,   11,   28,    7,   28,    7,   38,    8,   38,   38,
+       38,   38,    6,   38,   14,   38,    2,   28,    2,   38,
+       38,   34, 8229,   38,   34, 8229,   38,   34, 8229,   34,
+       38,   34,   17,   38,   38,   12,   28,   12,   38,   31,
+     8229,   38,16421,   27,   28,   27,   23,   38,   38,    7,
+        7,   28,   38,    8,   28,    8,   38,   38,   38,   38,
+        6,   28,    6,    6,   28,    6,   28,   38,    2,    2,
+
+       28,   38,   38,   38,   12,   12,   28,   38,   31, 8229,
+       38,   31, 8229,   38,   31,   38,   31, 8229,   27,   28,
+       24,   38,   38,    8,    8,   28,   38,   38,   18,   19,
+        6,    6,   28,    6,    6,   38,   38,   38,   15,   38,
+       38,   31, 8229,   38,   31, 8229,   38,   31, 8229,   31,
+       38,   31,   24,   38,   38,   38,   38,   18,   28,   18,
+       19,   28,   19,    6,    6,   38,   38,   38,   15,   38,
+       38,   21,    9,   20,   18,   18,   28,   19,   19,   28,
+        6,    5,    6,   38,   22,   38,   21,   28,   21,    9,
+       28,    9,   20,   28,   20,    4,    6,    5,    6,   38,
+
+       26,   25,   22,   28,   22,   38,   21,   21,   28,    9,
+        9,   28,   20,   20,   28,    4,    6,   13,   38,   26,
+       25,   22,   22,   28,   10,   13,   38,   10,   28,   10,
+       10,   10,   28
     } ;
 
-static const flex_int16_t yy_accept[373] =
+static const flex_int16_t yy_accept[406] =
     {   0,
         1,    1,    1,    2,    3,    4,    7,   12,   16,   19,
        21,   24,   27,   30,   33,   36,   39,   42,   45,   48,
-       51,   54,   57,   60,   63,   66,   69,   71,   72,   73,
-       74,   76,   79,   81,   82,   83,   84,   87,   87,   88,
-       89,   90,   91,   92,   93,   94,   95,   96,   97,   98,
-       99,  100,  101,  102,  103,  104,  105,  106,  107,  108,
-      109,  110,  111,  112,  114,  116,  117,  119,  121,  122,
-      123,  124,  125,  126,  127,  128,  129,  130,  131,  132,
-      133,  134,  135,  136,  137,  138,  139,  140,  141,  142,
-      143,  144,  145,  146,  147,  148,  150,  152,  153,  154,
-
-      155,  156,  160,  161,  162,  164,  165,  166,  167,  168,
-      169,  170,  171,  172,  177,  178,  179,  183,  184,  189,
-      190,  191,  192,  197,  198,  199,  200,  201,  202,  205,
-      208,  210,  212,  213,  215,  217,  218,  219,  220,  221,
-      225,  226,  227,  228,  231,  234,  236,  238,  239,  240,
-      243,  246,  248,  250,  253,  256,  258,  260,  261,  262,
-      265,  268,  270,  272,  273,  274,  275,  276,  277,  280,
-      283,  285,  287,  288,  289,  291,  292,  293,  294,  295,
-      296,  297,  300,  303,  305,  307,  308,  309,  313,  316,
-      319,  321,  323,  324,  325,  326,  329,  332,  334,  336,
-
-      337,  340,  343,  345,  347,  348,  349,  350,  353,  356,
-      358,  360,  361,  362,  363,  365,  366,  367,  368,  369,
-      370,  371,  372,  373,  374,  376,  379,  382,  384,  386,
-      387,  388,  389,  392,  395,  397,  399,  401,  402,  403,
-      404,  405,  406,  407,  409,  411,  412,  413,  414,  415,
-      416,  417,  418,  419,  420,  422,  424,  425,  426,  429,
-      432,  434,  436,  437,  439,  440,  442,  443,  444,  448,
-      450,  451,  452,  454,  455,  457,  458,  459,  460,  461,
-      462,  464,  465,  467,  469,  470,  471,  473,  474,  475,
-      476,  478,  479,  482,  485,  487,  489,  491,  492,  493,
-
-      495,  496,  497,  498,  499,  500,  502,  503,  504,  505,
-      506,  508,  509,  512,  515,  517,  519,  520,  521,  522,
-      523,  525,  526,  528,  529,  530,  531,  532,  533,  535,
-      536,  537,  538,  539,  540,  542,  543,  545,  546,  548,
-      549,  550,  551,  553,  554,  556,  557,  559,  560,  562,
-      564,  565,  567,  568,  569,  570,  572,  573,  575,  576,
-      578,  580,  582,  583,  585,  586,  588,  590,  591,  592,
-      594,  594
+       51,   54,   57,   60,   63,   66,   69,   72,   75,   77,
+       78,   79,   80,   82,   85,   87,   88,   89,   90,   93,
+       93,   94,   95,   96,   97,   98,   99,  100,  101,  102,
+      103,  104,  105,  106,  107,  108,  109,  110,  111,  112,
+      113,  114,  115,  116,  117,  118,  119,  120,  121,  123,
+      125,  126,  128,  130,  131,  132,  133,  134,  135,  136,
+      137,  138,  139,  140,  141,  142,  143,  144,  145,  146,
+      147,  148,  149,  150,  151,  152,  153,  154,  155,  156,
+
+      157,  158,  159,  160,  162,  164,  165,  166,  167,  168,
+      172,  173,  174,  176,  177,  178,  179,  180,  181,  182,
+      183,  184,  185,  190,  191,  192,  196,  197,  202,  203,
+      204,  205,  210,  211,  212,  213,  214,  215,  216,  217,
+      220,  223,  225,  227,  228,  230,  232,  233,  234,  235,
+      236,  240,  241,  242,  243,  244,  247,  250,  252,  254,
+      255,  256,  259,  262,  264,  266,  269,  272,  274,  276,
+      277,  278,  281,  284,  286,  288,  289,  290,  291,  292,
+      293,  294,  295,  298,  301,  303,  305,  306,  307,  309,
+      310,  311,  312,  313,  314,  315,  318,  321,  323,  325,
+
+      326,  327,  328,  332,  335,  338,  340,  342,  343,  344,
+      345,  348,  351,  353,  355,  356,  359,  362,  364,  366,
+      367,  368,  369,  372,  375,  377,  379,  380,  381,  382,
+      383,  384,  386,  387,  388,  389,  390,  391,  392,  393,
+      394,  395,  397,  400,  403,  405,  407,  408,  409,  410,
+      411,  414,  417,  419,  421,  423,  424,  425,  426,  427,
+      428,  430,  431,  432,  434,  436,  437,  438,  439,  440,
+      441,  442,  443,  444,  445,  447,  449,  450,  451,  452,
+      455,  458,  460,  462,  463,  465,  466,  468,  469,  470,
+      474,  476,  477,  479,  480,  481,  483,  484,  486,  487,
+
+      488,  489,  490,  491,  493,  494,  496,  498,  499,  500,
+      502,  503,  504,  505,  506,  508,  509,  512,  515,  517,
+      519,  521,  523,  524,  525,  527,  528,  529,  530,  531,
+      532,  534,  535,  536,  537,  538,  539,  541,  542,  545,
+      548,  550,  552,  553,  555,  556,  557,  558,  560,  561,
+      563,  564,  565,  566,  567,  568,  569,  571,  572,  573,
+      574,  575,  576,  578,  579,  581,  582,  584,  585,  585,
+      586,  587,  589,  590,  592,  593,  595,  596,  598,  600,
+      601,  602,  603,  605,  606,  607,  608,  610,  611,  613,
+      614,  616,  618,  620,  621,  622,  623,  625,  626,  628,
+
+      630,  631,  632,  634,  634
     } ;
 
 static const YY_CHAR yy_ec[256] =
@@ -679,16 +690,16 @@ static const YY_CHAR yy_ec[256] =
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    2,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    4,    5,    1,    1,    6,    6,    7,
-        6,    6,    6,    6,    6,    6,    6,    8,    1,    1,
-        9,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    4,    5,    1,    1,    6,    7,    8,
+        9,    9,    9,    9,    9,    9,    9,   10,    1,    1,
+       11,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,   10,   11,   12,   13,
+        1,    1,    1,    1,   12,    1,   13,   14,   15,   16,
 
-       14,   15,   16,   17,   18,   19,   20,   21,   22,   23,
-       24,   25,   26,   27,   28,   29,   30,   31,   32,   33,
-       34,   19,    1,    1,    1,    1,    1,    1,    1,    1,
+       17,   18,   19,   20,   21,   22,   23,   24,   25,   26,
+       27,   28,   29,   30,   31,   32,   33,   34,   35,   36,
+       37,   22,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -705,340 +716,362 @@ static const YY_CHAR yy_ec[256] =
         1,    1,    1,    1,    1
     } ;
 
-static const YY_CHAR yy_meta[35] =
+static const YY_CHAR yy_meta[38] =
     {   0,
-        1,    1,    2,    3,    1,    1,    1,    1,    4,    1,
+        1,    1,    2,    3,    1,    1,    1,    1,    1,    1,
+        4,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1
+        1,    1,    1,    1,    1,    1,    1
     } ;
 
-static const flex_int16_t yy_base[443] =
+static const flex_int16_t yy_base[476] =
     {   0,
-        0,    0,  936,  935,  937,  932,   33,   36,  940,  940,
-       45,   63,   31,   42,   51,   52,  925,   33,   65,   67,
-       69,   70,  924,   71,  923,   75,    0,  940,  928,  940,
-       91,   95,    0,    0,  104,  921,  113,    0,   91,   99,
-      114,   92,  115,   80,  100,   48,  119,  121,  122,   74,
-      123,  128,  131,  129,  125,  133,  135,  136,  137,  143,
-      138,  145,    0,  157,    0,    0,  168,    0,    0,  926,
-      140,  146,  165,  159,  152,  164,  155,  168,  171,  176,
-      177,  170,  180,  175,  184,  188,  212,  191,  185,  192,
-      193,  194,  219,  212,  199,  230,    0,    0,  940,  195,
-
-      200,  239,  235,  197,  246,  225,  226,  919,  244,  918,
-      243,  236,  245,  266,  248,  264,  282,  271,  291,  248,
-      270,  254,  300,  279,  296,  302,  288,  303,  311,    0,
-      315,    0,  311,  318,  940,  313,  319,  208,  313,  344,
-      321,  331,  325,  333,    0,  352,    0,  345,  347,  359,
-        0,  361,    0,  368,    0,  370,    0,  322,  366,  379,
-        0,  381,    0,  359,  357,  923,  382,  384,  392,    0,
-        0,    0,    0,  387,  940,  386,  390,  392,  329,  401,
-      397,  409,    0,  417,    0,  399,  412,  426,  429,    0,
-        0,    0,    0,  412,  427,  438,    0,    0,    0,    0,
-
-      440,    0,    0,    0,    0,  436,  405,  447,    0,    0,
-        0,    0,  438,  443,  922,  940,  921,  442,  450,  449,
-      452,  454,  459,  458,  453,  469,    0,    0,    0,    0,
-      920,  470,  481,    0,  483,    0,  484,  481,  919,  368,
-      467,  495,  918,  940,  917,  940,  488,  916,  479,  490,
-      492,  495,  505,  498,  940,  915,  940,  507,  523,    0,
-        0,    0,    0,  940,  503,  864,  940,  846,  532,  836,
-        0,  824,  940,  516,  796,  940,  513,  530,  536,  538,
-      784,  940,  542,  535,  547,  772,  940,  549,  551,  768,
-      940,  502,  562,    0,  564,    0,    0,  562,  764,  940,
-
-      544,  557,  760,  752,  744,  940,  552,  568,  571,  568,
-      581,  577,  588,    0,    0,    0,    0,  589,  580,  591,
-      736,  940,  728,  940,  601,  602,  597,  599,  940,  603,
-      720,  712,  700,  672,  940,  665,  940,  610,  656,  603,
-      648,  607,  629,  940,  627,  940,  625,  940,  624,  940,
-      607,  574,  940,  614,  572,  940,  491,  940,  433,  940,
-      940,  622,  389,  940,  303,  940,  261,  940,  204,  940,
-      940,  635,  639,  642,  646,  650,  654,  658,  662,  666,
-      670,  674,  678,  682,  686,  690,  694,  698,  702,  706,
-      710,  714,  718,  722,  726,  730,  734,  738,  742,  746,
-
-      750,  754,  758,  762,  766,  770,  774,  778,  782,  786,
-      790,  794,  798,  802,  806,  810,  814,  818,  822,  826,
-      830,  834,  838,  842,  846,  850,  854,  858,  862,  866,
-      870,  874,  878,  882,  886,  890,  894,  898,  902,  906,
-      910,  914
+        0,    0, 1008, 1007, 1009, 1004,   36,   39, 1012, 1012,
+       50,   71,   32,   72,   31,   43,   33,   45,   64,  994,
+       65,   67,   54,  993,   73,   77,   83,   84,    0, 1012,
+     1001, 1012,   95,  108,    0,    0,  119,  991,  131,    0,
+      112,   81,   90,  115,  100,  103,  125,  101,  104,  126,
+      127,  990,  133,  134,  139,  145,  154,  135,  147,  140,
+      149,  151,  150,  152,   36,  153,  160,    0,  178,    0,
+        0,  180,    0,    0,  998,  173,  156,  182,  174,  175,
+      180,  181,  183,  186,  190,  191,  185,  192,  196,  198,
+      201,  206,  232,  207,  202,  211,  209,  212,  241,  226,
+
+      215,  225,  216,  249,    0,    0, 1012,  227,  228,  262,
+      258,  243,  265,  246,  264,  988,  271,  987,  248,  269,
+      263,  272,  296,  275,  273,  308,  313,  326,  304,  274,
+      312,  338,  303,  334,  301,  302,  292,  321,  340,  351,
+        0,  355,    0,  343,  357, 1012,  348,  332,  354,  358,
+      388,  362,  360,  361,  367,  392,    0,  398,    0,  389,
+      366,  403,    0,  407,    0,  412,    0,  416,    0,  399,
+      213,  418,    0,  421,    0,  395,  404,  366,  415,  995,
+      333,  425,  430,    0,    0,    0,    0,  424, 1012,  427,
+      429,  432,  422,  444,  437,  451,    0,  457,    0,  453,
+
+      447,  460,  480,  466,    0,    0,    0,    0,  459,  369,
+      468,    0,    0,    0,    0,  484,    0,    0,    0,    0,
+      465,  476,  490,    0,    0,    0,    0,  483,  487,  486,
+      490,  994, 1012,  993,  489,  496,  495,  498,  500,  506,
+      505,  454,  521,    0,    0,    0,    0,  992,  504,  518,
+      533,    0,  535,    0,  527,  532,  991,  536,  540,  537,
+      514,  539,  990, 1012,  989, 1012,  539,  988,  544,  543,
+      546,  548,  561,  552, 1012,  987, 1012,  562,  567,  581,
+        0,    0,    0,    0, 1012,  556,  986, 1012,  976,  592,
+      984,    0, 1012,  574,  983, 1012,  558,  982, 1012,  578,
+
+      583,  594,  596,  981, 1012,  288,  596,  603,  930, 1012,
+      597,  599,  605,  918, 1012,  609,  620,    0,  622,    0,
+        0,  623,  619,  902, 1012,  615,  622,  890,  862,  850,
+     1012,  625,  635,  628,  636,  633,  642,  639,  658,    0,
+        0,    0,    0, 1012,  652,  634,  659,  838, 1012,  834,
+     1012,  646,  660,  663,  661,  666, 1012,  658,  830,  826,
+      818,  810, 1012,  802, 1012,  676,  794,  671,  684,  786,
+      671,  778, 1012,  766, 1012,  738, 1012,  731, 1012,  677,
+      722,  714,  691, 1012,  685,  647, 1012,  565, 1012,  508,
+     1012, 1012,  684, 1012, 1012,  448, 1012,  374, 1012,  167,
+
+     1012,  122, 1012, 1012,  701,  705,  708,  712,  716,  720,
+      724,  728,  732,  736,  740,  744,  748,  752,  756,  760,
+      764,  768,  772,  776,  780,  784,  788,  792,  796,  800,
+      804,  808,  812,  816,  820,  824,  828,  832,  836,  840,
+      844,  848,  852,  856,  860,  864,  868,  872,  876,  880,
+      884,  888,  892,  896,  900,  904,  908,  912,  916,  920,
+      924,  928,  932,  936,  940,  944,  948,  952,  956,  960,
+      964,  968,  972,  976,  980
     } ;
 
-static const flex_int16_t yy_def[443] =
+static const flex_int16_t yy_def[476] =
     {   0,
-      371,    1,  372,  372,  371,  373,  374,  374,  371,  371,
-      375,  375,   12,   12,   12,   12,   12,   12,   12,   12,
-       12,   12,   12,   12,   12,   12,  376,  371,  373,  371,
-      377,  374,  378,  378,  379,   12,  373,  380,   12,   12,
+      404,    1,  405,  405,  404,  406,  407,  407,  404,  404,
+      408,  408,   12,   12,   12,   12,   12,   12,   12,   12,
+       12,   12,   12,   12,   12,   12,   12,   12,  409,  404,
+      406,  404,  410,  407,  411,  411,  412,   12,  406,  413,
+       12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
        12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
+       12,   12,   12,   12,   12,   12,   12,  409,  410,  411,
+      411,  414,  415,  415,  404,   12,   12,   12,   12,   12,
        12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
-       12,   12,  376,  377,  378,  378,  381,  382,  382,  371,
+       12,   12,  412,   12,   12,   12,   12,   12,   12,   12,
+
+       12,   12,   12,  414,  415,  415,  404,   12,   12,  416,
        12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
-       12,   12,   12,   12,   12,   12,  379,   12,   12,   12,
-       12,   12,   12,   12,   12,  381,  382,  382,  371,   12,
-
-       12,  383,   12,   12,   12,   12,   12,   12,   12,   12,
-       12,   12,   12,  384,   87,   87,  385,   12,  386,   12,
-       12,   12,  387,   12,   12,   12,   12,   12,  388,  389,
-      383,  389,   12,   12,  371,   87,   12,   12,   12,  390,
-       12,   12,   12,  391,  392,  384,  392,   87,   87,  393,
-      394,  385,  394,  395,  396,  386,  396,   12,   12,  397,
-      398,  387,  398,   12,   12,  399,   12,   12,  388,  389,
-      389,  400,  400,   12,  371,   87,   87,   87,   12,   12,
-       12,  401,  402,  390,  402,   12,   12,  403,  391,  392,
-      392,  404,  404,   87,   87,  393,  394,  394,  405,  405,
-
-      395,  396,  396,  406,  406,   12,   12,  397,  398,  398,
-      407,  407,   12,   12,  408,  371,  409,   87,   12,   87,
-       87,   87,   12,   87,   12,  401,  402,  402,  410,  410,
-      411,   87,  412,  413,  403,  413,   87,   87,  414,   12,
-       12,  415,  408,  371,  416,  371,   87,  417,   12,   87,
-       87,   87,  418,   87,  371,  419,  371,   87,  412,  413,
-      413,  420,  420,  371,   87,  421,  371,   12,  422,  423,
-      423,  416,  371,   87,  424,  371,   12,   87,   87,   87,
-      425,  371,  425,  425,   87,  419,  371,   87,   87,  421,
-      371,   12,  426,  427,  422,  427,  423,   87,  424,  371,
-
-       12,   87,  428,  429,  425,  371,  425,  425,   87,   87,
-       87,   12,  426,  427,  427,  430,  430,   87,   12,   87,
-      431,  371,  432,  371,  425,  425,   87,   87,  371,   12,
-      433,  434,  435,  431,  371,  432,  371,  425,  425,   87,
-      436,   12,  437,  371,  438,  371,  439,  371,  425,  371,
-       87,  440,  371,   12,  437,  371,  438,  371,  439,  371,
-      371,   87,  440,  371,  441,  371,  442,  371,  442,  371,
-        0,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371
+       12,   12,  417,   93,   93,  418,   12,  419,   12,   12,
+       12,  420,   12,   12,   12,   12,   12,   12,   12,  421,
+      422,  416,  422,   12,   12,  404,   93,   12,   12,   12,
+      423,   12,   12,   12,   12,  424,  425,  417,  425,   93,
+       93,  426,  427,  418,  427,  428,  429,  419,  429,   12,
+       12,  430,  431,  420,  431,   12,   12,   12,   12,  432,
+       12,   12,  421,  422,  422,  433,  433,   12,  404,   93,
+       93,   93,   12,   12,   12,  434,  435,  423,  435,   12,
+
+      406,   12,  436,  424,  425,  425,  437,  437,   93,   93,
+      426,  427,  427,  438,  438,  428,  429,  429,  439,  439,
+       12,   12,  430,  431,  431,  440,  440,   12,   12,   12,
+       12,  441,  404,  442,   93,   12,   93,   93,   93,   12,
+       93,   12,  434,  435,  435,  443,  443,  444,  406,   93,
+      445,  446,  436,  446,   93,   93,  447,   12,   12,  448,
+       12,   12,  441,  404,  449,  404,   93,  450,   12,   93,
+       93,   93,  451,   93,  404,  452,  404,  406,   93,  445,
+      446,  446,  453,  453,  404,   93,  454,  404,   12,  455,
+      456,  456,  404,   12,  449,  404,   93,  457,  404,   12,
+
+       93,   93,   93,  458,  404,  458,  458,   93,  452,  404,
+      406,   93,   93,  454,  404,   12,  459,  460,  455,  460,
+      456,   12,   93,  457,  404,   12,   93,  461,  462,  458,
+      404,  458,  458,   93,  406,   93,   93,   12,  459,  460,
+      460,  463,  463,  404,   93,   12,   93,  464,  404,  465,
+      404,  458,  458,   93,  406,   93,  404,   12,  466,  467,
+      468,  464,  404,  465,  404,  458,  458,   93,  404,  469,
+       12,  470,  404,  471,  404,  472,  404,  458,  404,   93,
+      404,  404,  473,  404,   12,  470,  404,  471,  404,  472,
+      404,  404,   93,  404,  404,  473,  404,  474,  404,  475,
+
+      404,  475,  404,    0,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404
     } ;
 
-static const flex_int16_t yy_nxt[975] =
+static const flex_int16_t yy_nxt[1050] =
     {   0,
-        6,    7,    8,    9,    6,    6,    6,    6,   10,   11,
-       12,   13,   14,   15,   16,   17,   18,   19,   17,   17,
-       17,   17,   20,   17,   21,   22,   23,   24,   25,   17,
-       26,   17,   17,   17,   32,   32,   33,   32,   32,   33,
-       36,   34,   36,   42,   34,   29,   29,   29,   30,   35,
-       50,   36,   37,   38,   43,   44,   39,   36,   80,   45,
-       36,   36,   40,   29,   29,   29,   30,   35,   46,   48,
-       37,   38,   41,   47,   36,   49,   36,   53,   36,   36,
-       36,   56,   58,   36,   36,   55,   83,   61,   51,   36,
-       54,   62,   52,   29,   65,   59,   32,   32,   33,   66,
-
-       36,   36,   71,   34,   29,   29,   29,   30,   36,   36,
-       77,   29,   38,   67,   67,   67,   68,   67,   75,   72,
-       67,   69,   73,   36,   36,   74,   78,   79,   36,   53,
-       36,   36,   36,   87,   36,   76,   84,   36,   36,   85,
-       36,   81,   36,   86,   36,   36,   36,   36,   82,   36,
-       92,   95,   36,  100,   36,   36,   89,   90,   88,   29,
-       65,   36,   91,  101,   36,   66,   90,   93,   36,   94,
-       29,   97,  102,   36,   36,  104,   98,   36,  103,   36,
-       36,  107,  108,  106,   36,   36,   36,  105,   86,   36,
-      109,  110,  111,   36,   36,  114,  112,   36,  117,  119,
-
-       36,   36,   36,   36,   36,  121,   36,  368,   36,   36,
-      120,  113,   29,   29,   29,   30,  118,   36,  134,   29,
-       38,   36,  127,  115,  116,  122,  123,  125,   36,  126,
-      128,  124,   29,   97,   36,   36,  180,  138,   98,  129,
-      129,   67,  130,  129,   36,   36,  129,  132,  133,  135,
-      136,  140,   36,   36,   36,   36,  142,   36,  137,   35,
-       35,  123,   86,   36,  370,  143,  144,  144,   67,  145,
-      144,  148,  158,  144,  147,   35,   35,   90,  119,   36,
-       36,  149,  150,  150,   67,  151,  150,  159,   36,  150,
-      153,  154,  154,   67,  155,  154,  164,   36,  154,  157,
-
-      160,  160,   67,  161,  160,   36,  368,  160,  163,  165,
-      166,   36,   36,   29,  170,  167,  168,   29,  172,  171,
-       36,  175,   36,  173,   35,   35,  176,   36,   36,  177,
-       36,   36,  188,  174,   36,   29,  190,  178,   36,  181,
-       36,  191,  223,  179,  182,  182,   67,  183,  182,  186,
-      206,  182,  185,  187,   29,  192,   35,   35,   35,   35,
-      193,   29,  197,   29,  199,  194,   36,  198,   36,  200,
-       29,  202,   29,  204,  195,   36,  203,   36,  205,  268,
-      207,   29,  209,   29,  211,  214,  213,  210,  218,  212,
-      217,   36,  353,   36,   29,  170,   36,   35,   35,  219,
-
-      171,   35,   35,   35,   35,  224,   36,  231,   36,  225,
-       36,   29,  227,  221,   36,  222,  232,  228,  220,   29,
-      229,   36,  240,   35,   35,  230,  233,  233,   67,  234,
-      233,   29,  190,  233,  236,  237,  348,  191,  238,   35,
-       29,  197,   29,  202,  239,   36,  198,   36,  203,   29,
-      209,  242,   36,   35,  247,  210,  255,  241,  248,   36,
-       35,   35,   36,   35,   35,   35,   35,  253,   36,   35,
-       35,   29,  227,  250,  269,  254,   36,  228,  249,  251,
-      252,   35,  258,   29,  260,   29,  262,  264,   36,  261,
-      265,  263,   35,   35,  346,   35,   35,   70,  271,   35,
-
-       35,   35,   35,   35,   35,  274,   35,   35,  282,   35,
-       35,   36,  277,  278,   35,   35,  283,  284,   35,   35,
-      279,  285,   36,  280,  288,   29,  260,   35,   35,  289,
-      312,  261,  293,  293,   67,  294,  293,  301,  306,  293,
-      296,   35,   35,  298,  303,  306,  304,   35,   35,   35,
-       35,  309,  308,   36,  307,  282,  302,  319,   35,   35,
-       35,   35,   35,  311,   29,  314,   29,  316,   35,   35,
-      315,  282,  317,   35,   35,  344,  310,  364,  325,   35,
-       35,  318,   35,   35,  329,  320,   36,  328,  332,   36,
-       29,  314,   35,   35,  330,  326,  315,  331,  327,  333,
-
-       35,   35,   35,   35,  282,  282,  340,  341,   35,   35,
-       35,   35,   36,  282,   35,   35,   36,  351,   35,   35,
-      362,  339,  365,   36,  338,  366,  342,  361,  360,  354,
-      358,  349,  356,   35,   35,   27,   27,   27,   27,   29,
-       29,   29,   31,   31,   31,   31,   36,   36,   36,   36,
-       63,  353,   63,   63,   64,   64,   64,   64,   66,  350,
-       66,   66,   35,   35,   35,   35,   70,   70,  324,   70,
-       96,   96,   96,   96,   98,  322,   98,   98,  131,  131,
-      131,  131,  146,  146,  146,  146,  152,  152,  152,  152,
-      156,  156,  156,  156,  162,  162,  162,  162,  169,  169,
-
-      169,  169,  171,  348,  171,  171,  184,  184,  184,  184,
-      189,  189,  189,  189,  191,  346,  191,  191,  196,  196,
-      196,  196,  198,  344,  198,  198,  201,  201,  201,  201,
-      203,  337,  203,  203,  208,  208,  208,  208,  210,  335,
-      210,  210,  215,  215,  215,  215,  173,  282,  173,  173,
-      226,  226,  226,  226,  228,  324,  228,  228,  235,  235,
-      235,  235,  193,  322,  193,  193,  200,  276,  200,  200,
-      205,  267,  205,  205,  212,  257,  212,  212,  243,  243,
-      243,  243,  245,  245,  245,  245,  230,  306,  230,  230,
-      256,  256,  256,  256,  259,  259,  259,  259,  261,  300,
-
-      261,  261,  266,  266,  266,  266,  270,  270,  270,  270,
-      272,  272,  272,  272,  275,  275,  275,  275,  281,  281,
-      281,  281,  286,  286,  286,  286,  263,  246,  263,  263,
-      290,  290,  290,  290,  295,  295,  295,  295,  271,  297,
-      271,  271,  299,  299,  299,  299,  305,  305,  305,  305,
-      313,  313,  313,  313,  315,  292,  315,  315,  321,  321,
-      321,  321,  323,  323,  323,  323,  317,  291,  317,  317,
-      334,  334,  334,  334,  336,  336,  336,  336,  343,  343,
-      343,  343,  345,  345,  345,  345,  347,  347,  347,  347,
-      352,  352,  352,  352,  355,  355,  355,  355,  357,  357,
-
-      357,  357,  359,  359,  359,  359,  363,  363,  363,  363,
-      367,  367,  367,  367,  369,  369,  369,  369,  287,  276,
-      273,  216,  267,  257,  246,  244,  216,  141,  139,   99,
-       36,   30,   60,   57,   36,   30,  371,   28,   28,    5,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371
+        6,    7,    8,    9,    6,    6,    6,    6,    6,    6,
+       10,    6,   11,   12,   13,   14,   15,   16,   17,   18,
+       19,   20,   20,   20,   20,   21,   20,   22,   23,   24,
+       25,   26,   27,   28,   20,   20,   20,   34,   34,   35,
+       34,   34,   35,   38,   38,   38,   36,   44,   38,   36,
+       31,   31,   31,   32,   37,   38,   49,   38,   45,   39,
+       40,   31,   52,   50,   41,   53,   38,  102,   59,   51,
+       42,   31,   31,   31,   32,   37,   38,   38,   56,   38,
+       39,   40,   31,   43,   38,   38,   58,   61,   46,   63,
+       54,   57,   47,   38,   55,   38,   38,   31,   70,   66,
+
+       62,   48,   38,   67,   79,   71,   64,   78,   65,   34,
+       34,   35,   38,   38,   85,   38,   38,   56,   36,   31,
+       31,   31,   32,   81,   38,  401,   76,   38,   31,   40,
+       31,   72,   72,   72,   73,   72,   82,   38,   38,   38,
+       72,   74,   72,   77,   80,   38,   38,   38,   89,   86,
+       90,   38,   38,   91,   83,   84,   87,   38,   93,   38,
+       92,   38,   38,   38,   38,   38,   38,   98,   38,  103,
+      403,   94,   38,   95,   96,   96,  109,   99,   97,  100,
+       31,   70,   31,  105,  101,   38,   38,   38,   71,  108,
+      106,  110,   38,   38,   38,   38,  111,   38,   38,  115,
+
+      116,  112,   38,   38,   38,   92,  113,  117,   38,  118,
+       38,  120,  114,   38,   38,  123,  126,  119,   38,   38,
+      128,   38,  121,   38,   38,   38,  130,   38,   38,  129,
+      222,  122,   31,   31,   31,   32,  127,   38,   38,   38,
+       38,   31,   40,   31,  134,  135,  124,  125,  131,  137,
+      132,   31,  105,   38,  136,   38,  133,  138,   38,  106,
+       38,  139,  140,  140,   72,  141,  140,  145,  146,  147,
+       38,  140,  143,  140,  144,   38,   38,   38,  149,  153,
+      151,   38,  148,   38,   38,  154,   38,   37,   37,   37,
+       37,  331,   92,  161,  171,  155,  156,  156,   72,  157,
+
+      156,  160,  180,  332,   38,  156,  159,  156,  162,  162,
+       72,  163,  162,   38,   38,   38,   38,  162,  165,  162,
+       96,  132,  128,  176,   38,   38,  166,  166,   72,  167,
+      166,  170,  178,   38,  179,  166,  169,  166,  172,  172,
+       72,  173,  172,  234,   38,   38,   38,  172,  175,  172,
+      177,  181,   38,   31,  184,   38,  182,   31,  186,  193,
+      189,  185,   37,   37,  190,  187,   38,  191,  188,   38,
+       38,  201,   38,   38,   38,  192,  203,  401,   38,   38,
+       37,   37,  230,  256,   37,  194,  202,  195,  196,  196,
+       72,  197,  196,  200,   31,  205,  210,  196,  199,  196,
+
+       31,  207,  206,   37,   37,   31,  212,   38,  208,   31,
+      214,   38,  209,  213,   31,  217,   38,  215,   31,  219,
+       31,  224,  218,   31,  226,  228,  220,   38,  225,  235,
+      221,  227,   31,  184,   38,  229,   38,   38,  240,  236,
+      185,   37,   37,   37,   37,  231,   37,   37,  241,   38,
+       32,  384,  242,   31,  244,  238,   38,  275,  239,   31,
+      246,  245,  237,  248,  250,   38,   38,  247,   31,  205,
+       31,  212,   38,   37,   37,  257,  206,   38,  213,  249,
+      251,  251,   72,  252,  251,  255,   31,  217,   38,  251,
+      254,  251,   31,  224,  218,   38,  258,  260,   38,   38,
+
+      225,  261,   38,   37,  267,  259,  268,   32,   38,   37,
+       37,  377,   37,   37,   37,   37,  273,  293,   38,   37,
+       37,  262,  270,   31,  244,  274,   38,  269,  271,  272,
+      285,  245,   37,  279,  278,   31,  281,   31,  283,   75,
+      292,   37,   37,  282,  286,  284,   37,   37,   38,  290,
+      289,   38,   38,   37,   37,  294,   38,   37,   37,  297,
+       37,   37,   37,   37,  305,   32,   37,   37,  375,  301,
+       37,   37,   37,   37,  311,  306,  307,  302,  308,  303,
+      300,   37,   37,   31,  281,  313,   38,  312,  323,  322,
+       38,  282,  317,  317,   72,  318,  317,   37,   37,  331,
+
+       32,  317,  320,  317,  328,  326,  329,  334,   37,   37,
+       37,   37,  327,   37,   37,  335,  333,   37,   37,   37,
+      337,   38,   31,  340,   31,  342,  344,   38,  305,  336,
+      341,  346,  343,   37,   37,   38,   37,   37,  305,   32,
+      338,  345,   37,   37,  360,  357,   38,   37,   37,  305,
+      373,   38,  355,  347,  352,  356,   37,   37,  354,  358,
+       31,  340,  359,  305,   32,  353,   37,   37,  341,  361,
+       38,  369,  366,   37,   37,  368,  370,   37,   37,  305,
+       37,   37,  367,   38,  371,   37,   37,  399,  380,  381,
+      382,   37,   37,  393,  397,  398,  385,   38,   37,   37,
+
+      378,   29,   29,   29,   29,   31,   31,   31,   33,   33,
+       33,   33,   38,   38,   38,   38,   68,  395,   68,   68,
+       69,   69,   69,   69,   71,  394,   71,   71,   37,   37,
+       37,   37,   75,   75,  392,   75,  104,  104,  104,  104,
+      106,  391,  106,  106,  142,  142,  142,  142,  158,  158,
+      158,  158,  164,  164,  164,  164,  168,  168,  168,  168,
+      174,  174,  174,  174,  183,  183,  183,  183,  185,  389,
+      185,  185,  198,  198,  198,  198,  204,  204,  204,  204,
+      206,  387,  206,  206,  211,  211,  211,  211,  213,  384,
+      213,  213,  216,  216,  216,  216,  218,  379,  218,  218,
+
+      223,  223,  223,  223,  225,  351,  225,  225,  232,  232,
+      232,  232,  187,  349,  187,  187,  243,  243,  243,  243,
+      245,  377,  245,  245,  253,  253,  253,  253,  208,  375,
+      208,  208,  215,  373,  215,  215,  220,  365,  220,  220,
+      227,  363,  227,  227,  263,  263,  263,  263,  265,  265,
+      265,  265,  247,  305,  247,  247,  276,  276,  276,  276,
+      280,  280,  280,  280,  282,  351,  282,  282,  287,  287,
+      287,  287,  291,  291,  291,  291,  295,  295,  295,  295,
+      298,  298,  298,  298,  304,  304,  304,  304,  309,  309,
+      309,  309,  284,  349,  284,  284,  314,  314,  314,  314,
+
+      319,  319,  319,  319,  292,  299,  292,  292,  324,  324,
+      324,  324,  330,  330,  330,  330,  339,  339,  339,  339,
+      341,  288,  341,  341,  348,  348,  348,  348,  350,  350,
+      350,  350,  343,  277,  343,  343,  362,  362,  362,  362,
+      364,  364,  364,  364,  372,  372,  372,  372,  374,  374,
+      374,  374,  376,  376,  376,  376,  383,  383,  383,  383,
+      386,  386,  386,  386,  388,  388,  388,  388,  390,  390,
+      390,  390,  396,  396,  396,  396,  400,  400,  400,  400,
+      402,  402,  402,  402,  331,  325,  266,  321,  316,  315,
+      310,  299,  296,  233,  288,  277,  266,  264,  233,  152,
+
+      150,  107,   88,   38,   32,   60,   38,   32,  404,   30,
+       30,    5,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404
     } ;
 
-static const flex_int16_t yy_chk[975] =
+static const flex_int16_t yy_chk[1050] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    7,    7,    7,    8,    8,    8,
-       13,    7,   18,   13,    8,   11,   11,   11,   11,   11,
-       18,   14,   11,   11,   13,   14,   11,   46,   46,   14,
-       15,   16,   11,   12,   12,   12,   12,   12,   14,   16,
-       12,   12,   12,   15,   19,   16,   20,   20,   21,   22,
-       24,   22,   24,   50,   26,   21,   50,   26,   19,   44,
-       20,   26,   19,   31,   31,   24,   32,   32,   32,   31,
-
-       39,   42,   39,   32,   35,   35,   35,   35,   40,   45,
-       44,   35,   35,   37,   37,   37,   37,   37,   42,   39,
-       37,   37,   40,   41,   43,   41,   45,   45,   47,   47,
-       48,   49,   51,   54,   55,   43,   51,   52,   54,   52,
-       53,   48,   56,   53,   57,   58,   59,   61,   49,   71,
-       59,   61,   60,   71,   62,   72,   56,   62,   55,   64,
-       64,   75,   58,   72,   77,   64,   57,   60,   74,   60,
-       67,   67,   73,   76,   73,   75,   67,   78,   74,   82,
-       79,   78,   79,   77,   84,   80,   81,   76,   80,   83,
-       81,   82,   83,   85,   89,   86,   84,   86,   88,   90,
-
-       88,   90,   91,   92,  100,   92,  104,  369,   95,  101,
-       91,   85,   87,   87,   87,   87,   89,  138,  104,   87,
-       87,   94,  100,   87,   87,   93,   93,   94,   93,   95,
-      101,   93,   96,   96,  106,  107,  138,  107,   96,  102,
-      102,  102,  102,  102,  103,  112,  102,  102,  103,  105,
-      105,  109,  111,  109,  113,  105,  111,  120,  106,  115,
-      115,  122,  113,  122,  367,  112,  114,  114,  114,  114,
-      114,  115,  120,  114,  114,  116,  116,  118,  118,  121,
-      118,  116,  117,  117,  117,  117,  117,  121,  124,  117,
-      117,  119,  119,  119,  119,  119,  124,  127,  119,  119,
-
-      123,  123,  123,  123,  123,  125,  365,  123,  123,  125,
-      126,  126,  128,  129,  129,  127,  128,  131,  131,  129,
-      133,  134,  139,  131,  136,  136,  136,  134,  137,  136,
-      141,  158,  143,  133,  143,  144,  144,  136,  179,  139,
-      142,  144,  179,  137,  140,  140,  140,  140,  140,  141,
-      158,  140,  140,  142,  146,  146,  148,  148,  149,  149,
-      146,  150,  150,  152,  152,  148,  165,  150,  164,  152,
-      154,  154,  156,  156,  149,  159,  154,  240,  156,  240,
-      159,  160,  160,  162,  162,  165,  164,  160,  168,  162,
-      167,  167,  363,  168,  169,  169,  174,  176,  176,  174,
-
-      169,  177,  177,  178,  178,  180,  181,  186,  186,  181,
-      180,  182,  182,  177,  207,  178,  187,  182,  176,  184,
-      184,  187,  207,  194,  194,  184,  188,  188,  188,  188,
-      188,  189,  189,  188,  188,  194,  359,  189,  195,  195,
-      196,  196,  201,  201,  206,  206,  196,  213,  201,  208,
-      208,  214,  214,  218,  218,  208,  225,  213,  219,  219,
-      220,  220,  225,  221,  221,  222,  222,  223,  223,  224,
-      224,  226,  226,  220,  241,  224,  241,  226,  219,  221,
-      222,  232,  232,  233,  233,  235,  235,  237,  249,  233,
-      238,  235,  238,  238,  357,  237,  237,  242,  242,  247,
-
-      247,  250,  250,  251,  251,  247,  252,  252,  253,  254,
-      254,  292,  249,  250,  265,  265,  253,  253,  258,  258,
-      251,  254,  277,  252,  258,  259,  259,  274,  274,  265,
-      292,  259,  269,  269,  269,  269,  269,  277,  284,  269,
-      269,  278,  278,  274,  279,  283,  280,  279,  279,  280,
-      280,  285,  284,  301,  283,  307,  278,  301,  285,  285,
-      288,  288,  289,  289,  293,  293,  295,  295,  302,  302,
-      293,  308,  295,  298,  298,  355,  288,  352,  307,  310,
-      310,  298,  309,  309,  311,  302,  312,  310,  319,  319,
-      313,  313,  311,  311,  312,  308,  313,  318,  309,  320,
-
-      318,  318,  320,  320,  325,  326,  327,  328,  327,  327,
-      328,  328,  330,  338,  340,  340,  342,  340,  351,  351,
-      351,  326,  354,  354,  325,  362,  330,  349,  347,  342,
-      345,  338,  343,  362,  362,  372,  372,  372,  372,  373,
-      373,  373,  374,  374,  374,  374,  375,  375,  375,  375,
-      376,  341,  376,  376,  377,  377,  377,  377,  378,  339,
-      378,  378,  379,  379,  379,  379,  380,  380,  336,  380,
-      381,  381,  381,  381,  382,  334,  382,  382,  383,  383,
-      383,  383,  384,  384,  384,  384,  385,  385,  385,  385,
-      386,  386,  386,  386,  387,  387,  387,  387,  388,  388,
-
-      388,  388,  389,  333,  389,  389,  390,  390,  390,  390,
-      391,  391,  391,  391,  392,  332,  392,  392,  393,  393,
-      393,  393,  394,  331,  394,  394,  395,  395,  395,  395,
-      396,  323,  396,  396,  397,  397,  397,  397,  398,  321,
-      398,  398,  399,  399,  399,  399,  400,  305,  400,  400,
-      401,  401,  401,  401,  402,  304,  402,  402,  403,  403,
-      403,  403,  404,  303,  404,  404,  405,  299,  405,  405,
-      406,  290,  406,  406,  407,  286,  407,  407,  408,  408,
-      408,  408,  409,  409,  409,  409,  410,  281,  410,  410,
-      411,  411,  411,  411,  412,  412,  412,  412,  413,  275,
-
-      413,  413,  414,  414,  414,  414,  415,  415,  415,  415,
-      416,  416,  416,  416,  417,  417,  417,  417,  418,  418,
-      418,  418,  419,  419,  419,  419,  420,  272,  420,  420,
-      421,  421,  421,  421,  422,  422,  422,  422,  423,  270,
-      423,  423,  424,  424,  424,  424,  425,  425,  425,  425,
-      426,  426,  426,  426,  427,  268,  427,  427,  428,  428,
-      428,  428,  429,  429,  429,  429,  430,  266,  430,  430,
-      431,  431,  431,  431,  432,  432,  432,  432,  433,  433,
-      433,  433,  434,  434,  434,  434,  435,  435,  435,  435,
-      436,  436,  436,  436,  437,  437,  437,  437,  438,  438,
-
-      438,  438,  439,  439,  439,  439,  440,  440,  440,  440,
-      441,  441,  441,  441,  442,  442,  442,  442,  256,  248,
-      245,  243,  239,  231,  217,  215,  166,  110,  108,   70,
-       36,   29,   25,   23,   17,    6,    5,    4,    3,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371
+        1,    1,    1,    1,    1,    1,    1,    7,    7,    7,
+        8,    8,    8,   15,   13,   17,    7,   13,   65,    8,
+       11,   11,   11,   11,   11,   16,   15,   18,   13,   11,
+       11,   11,   17,   16,   11,   18,   23,   65,   23,   16,
+       11,   12,   12,   12,   12,   12,   19,   21,   21,   22,
+       12,   12,   12,   12,   14,   25,   22,   25,   14,   26,
+       19,   21,   14,   42,   19,   27,   28,   33,   33,   28,
+
+       25,   14,   43,   28,   43,   33,   26,   42,   27,   34,
+       34,   34,   45,   48,   48,   46,   49,   49,   34,   37,
+       37,   37,   37,   45,   41,  402,   41,   44,   37,   37,
+       37,   39,   39,   39,   39,   39,   46,   47,   50,   51,
+       39,   39,   39,   41,   44,   53,   54,   58,   53,   50,
+       54,   55,   60,   55,   47,   47,   51,   56,   57,   59,
+       56,   61,   63,   62,   64,   66,   57,   62,   77,   66,
+      400,   58,   67,   59,   60,   67,   77,   63,   61,   63,
+       69,   69,   72,   72,   64,   76,   79,   80,   69,   76,
+       72,   78,   81,   82,   78,   83,   79,   87,   84,   83,
+
+       84,   80,   85,   86,   88,   85,   81,   86,   89,   87,
+       90,   89,   82,   91,   95,   92,   94,   88,   92,   94,
+       96,   97,   90,   96,   98,  171,   98,  101,  103,   97,
+      171,   91,   93,   93,   93,   93,   95,  102,  100,  108,
+      109,   93,   93,   93,  100,  101,   93,   93,   99,  103,
+       99,  104,  104,   99,  102,  112,   99,  108,  114,  104,
+      119,  109,  110,  110,  110,  110,  110,  112,  113,  113,
+      111,  110,  110,  110,  111,  121,  115,  113,  115,  119,
+      117,  120,  114,  117,  122,  120,  130,  125,  125,  124,
+      124,  306,  122,  125,  130,  121,  123,  123,  123,  123,
+
+      123,  124,  137,  306,  137,  123,  123,  123,  126,  126,
+      126,  126,  126,  135,  136,  133,  129,  126,  126,  126,
+      127,  131,  127,  133,  131,  127,  128,  128,  128,  128,
+      128,  129,  135,  138,  136,  128,  128,  128,  132,  132,
+      132,  132,  132,  181,  148,  181,  134,  132,  132,  132,
+      134,  138,  139,  140,  140,  144,  139,  142,  142,  148,
+      145,  140,  147,  147,  147,  142,  149,  147,  144,  145,
+      150,  153,  153,  154,  152,  147,  155,  398,  178,  155,
+      161,  161,  178,  210,  210,  149,  154,  150,  151,  151,
+      151,  151,  151,  152,  156,  156,  161,  151,  151,  151,
+
+      158,  158,  156,  160,  160,  162,  162,  176,  158,  164,
+      164,  170,  160,  162,  166,  166,  177,  164,  168,  168,
+      172,  172,  166,  174,  174,  176,  168,  179,  172,  182,
+      170,  174,  183,  183,  193,  177,  188,  182,  193,  188,
+      183,  190,  190,  191,  191,  179,  192,  192,  194,  195,
+      201,  396,  195,  196,  196,  191,  194,  242,  192,  198,
+      198,  196,  190,  200,  202,  200,  242,  198,  204,  204,
+      211,  211,  202,  209,  209,  221,  204,  221,  211,  201,
+      203,  203,  203,  203,  203,  209,  216,  216,  222,  203,
+      203,  203,  223,  223,  216,  228,  222,  229,  230,  229,
+
+      223,  230,  231,  235,  235,  228,  236,  249,  236,  237,
+      237,  390,  238,  238,  239,  239,  240,  261,  240,  241,
+      241,  231,  237,  243,  243,  241,  261,  236,  238,  239,
+      255,  243,  250,  250,  249,  251,  251,  253,  253,  260,
+      260,  255,  255,  251,  256,  253,  256,  256,  258,  259,
+      258,  262,  259,  267,  267,  262,  269,  270,  270,  267,
+      271,  271,  272,  272,  273,  278,  274,  274,  388,  270,
+      286,  286,  297,  297,  278,  273,  273,  271,  274,  272,
+      269,  279,  279,  280,  280,  286,  294,  279,  297,  294,
+      300,  280,  290,  290,  290,  290,  290,  301,  301,  307,
+
+      311,  290,  290,  290,  302,  300,  303,  308,  302,  302,
+      303,  303,  301,  312,  312,  311,  307,  308,  308,  313,
+      313,  316,  317,  317,  319,  319,  322,  326,  332,  312,
+      317,  326,  319,  323,  323,  322,  327,  327,  333,  335,
+      316,  323,  334,  334,  346,  337,  346,  336,  336,  352,
+      386,  338,  335,  327,  332,  336,  337,  337,  334,  338,
+      339,  339,  345,  353,  355,  333,  345,  345,  339,  347,
+      358,  355,  352,  347,  347,  354,  356,  354,  354,  366,
+      356,  356,  353,  371,  358,  368,  368,  393,  368,  369,
+      369,  380,  380,  380,  383,  385,  371,  385,  393,  393,
+
+      366,  405,  405,  405,  405,  406,  406,  406,  407,  407,
+      407,  407,  408,  408,  408,  408,  409,  382,  409,  409,
+      410,  410,  410,  410,  411,  381,  411,  411,  412,  412,
+      412,  412,  413,  413,  378,  413,  414,  414,  414,  414,
+      415,  376,  415,  415,  416,  416,  416,  416,  417,  417,
+      417,  417,  418,  418,  418,  418,  419,  419,  419,  419,
+      420,  420,  420,  420,  421,  421,  421,  421,  422,  374,
+      422,  422,  423,  423,  423,  423,  424,  424,  424,  424,
+      425,  372,  425,  425,  426,  426,  426,  426,  427,  370,
+      427,  427,  428,  428,  428,  428,  429,  367,  429,  429,
+
+      430,  430,  430,  430,  431,  364,  431,  431,  432,  432,
+      432,  432,  433,  362,  433,  433,  434,  434,  434,  434,
+      435,  361,  435,  435,  436,  436,  436,  436,  437,  360,
+      437,  437,  438,  359,  438,  438,  439,  350,  439,  439,
+      440,  348,  440,  440,  441,  441,  441,  441,  442,  442,
+      442,  442,  443,  330,  443,  443,  444,  444,  444,  444,
+      445,  445,  445,  445,  446,  329,  446,  446,  447,  447,
+      447,  447,  448,  448,  448,  448,  449,  449,  449,  449,
+      450,  450,  450,  450,  451,  451,  451,  451,  452,  452,
+      452,  452,  453,  328,  453,  453,  454,  454,  454,  454,
+
+      455,  455,  455,  455,  456,  324,  456,  456,  457,  457,
+      457,  457,  458,  458,  458,  458,  459,  459,  459,  459,
+      460,  314,  460,  460,  461,  461,  461,  461,  462,  462,
+      462,  462,  463,  309,  463,  463,  464,  464,  464,  464,
+      465,  465,  465,  465,  466,  466,  466,  466,  467,  467,
+      467,  467,  468,  468,  468,  468,  469,  469,  469,  469,
+      470,  470,  470,  470,  471,  471,  471,  471,  472,  472,
+      472,  472,  473,  473,  473,  473,  474,  474,  474,  474,
+      475,  475,  475,  475,  304,  298,  295,  291,  289,  287,
+      276,  268,  265,  263,  257,  248,  234,  232,  180,  118,
+
+      116,   75,   52,   38,   31,   24,   20,    6,    5,    4,
+        3,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404
     } ;
 
 #define YY_TRAILING_MASK 0x2000
@@ -1224,9 +1257,9 @@ static int vdev_and_devtype(DiskParseContext *dpc, char *str) {
 #undef DPC /* needs to be defined differently the actual lexer */
 #define DPC ((DiskParseContext*)yyextra)
 
-#line 1227 "libxlu_disk_l.c"
+#line 1260 "libxlu_disk_l.c"
 
-#line 1229 "libxlu_disk_l.c"
+#line 1262 "libxlu_disk_l.c"
 
 #define INITIAL 0
 #define LEXERR 1
@@ -1508,7 +1541,7 @@ YY_DECL
 #line 188 "libxlu_disk_l.l"
  /*----- the scanner rules which do the parsing -----*/
 
-#line 1511 "libxlu_disk_l.c"
+#line 1544 "libxlu_disk_l.c"
 
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
@@ -1540,14 +1573,14 @@ yy_match:
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 				{
 				yy_current_state = (int) yy_def[yy_current_state];
-				if ( yy_current_state >= 372 )
+				if ( yy_current_state >= 405 )
 					yy_c = yy_meta[yy_c];
 				}
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 			*yyg->yy_state_ptr++ = yy_current_state;
 			++yy_cp;
 			}
-		while ( yy_current_state != 371 );
+		while ( yy_current_state != 404 );
 
 yy_find_action:
 		yy_current_state = *--yyg->yy_state_ptr;
@@ -1721,34 +1754,54 @@ YY_RULE_SETUP
 #line 219 "libxlu_disk_l.l"
 { STRIP(','); SAVESTRING("hidden-disk", hidden_disk, FROMEQUALS); }
 	YY_BREAK
-/* the target magic parameter, eats the rest of the string */
 case 23:
 YY_RULE_SETUP
-#line 223 "libxlu_disk_l.l"
+#line 221 "libxlu_disk_l.l"
+{ libxl_defbool_set(&DPC->disk->trusted, true); }
+	YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 222 "libxlu_disk_l.l"
+{ libxl_defbool_set(&DPC->disk->trusted, false); }
+	YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 224 "libxlu_disk_l.l"
+{ libxl_defbool_set(&DPC->disk->grant_usage, true); }
+	YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 225 "libxlu_disk_l.l"
+{ libxl_defbool_set(&DPC->disk->grant_usage, false); }
+	YY_BREAK
+/* the target magic parameter, eats the rest of the string */
+case 27:
+YY_RULE_SETUP
+#line 229 "libxlu_disk_l.l"
 { STRIP(','); SAVESTRING("target", pdev_path, FROMEQUALS); }
 	YY_BREAK
 /* unknown parameters */
-case 24:
-/* rule 24 can match eol */
+case 28:
+/* rule 28 can match eol */
 YY_RULE_SETUP
-#line 227 "libxlu_disk_l.l"
+#line 233 "libxlu_disk_l.l"
 { xlu__disk_err(DPC,yytext,"unknown parameter"); }
 	YY_BREAK
 /* deprecated prefixes */
 /* the "/.*" in these patterns ensures that they count as if they
    * matched the whole string, so these patterns take precedence */
-case 25:
+case 29:
 YY_RULE_SETUP
-#line 234 "libxlu_disk_l.l"
+#line 240 "libxlu_disk_l.l"
 {
                     STRIP(':');
                     DPC->had_depr_prefix=1; DEPRECATE("use `[format=]...,'");
                     setformat(DPC, yytext);
                  }
 	YY_BREAK
-case 26:
+case 30:
 YY_RULE_SETUP
-#line 240 "libxlu_disk_l.l"
+#line 246 "libxlu_disk_l.l"
 {
                     char *newscript;
                     STRIP(':');
@@ -1762,65 +1815,65 @@ YY_RULE_SETUP
                     free(newscript);
                 }
 	YY_BREAK
-case 27:
+case 31:
 *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
 yyg->yy_c_buf_p = yy_cp = yy_bp + 8;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 253 "libxlu_disk_l.l"
+#line 259 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
 	YY_BREAK
-case 28:
+case 32:
 YY_RULE_SETUP
-#line 254 "libxlu_disk_l.l"
+#line 260 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
 	YY_BREAK
-case 29:
+case 33:
 *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
 yyg->yy_c_buf_p = yy_cp = yy_bp + 4;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 255 "libxlu_disk_l.l"
+#line 261 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
 	YY_BREAK
-case 30:
+case 34:
 *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
 yyg->yy_c_buf_p = yy_cp = yy_bp + 6;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 256 "libxlu_disk_l.l"
+#line 262 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
 	YY_BREAK
-case 31:
+case 35:
 *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
 yyg->yy_c_buf_p = yy_cp = yy_bp + 5;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 257 "libxlu_disk_l.l"
+#line 263 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
 	YY_BREAK
-case 32:
+case 36:
 *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
 yyg->yy_c_buf_p = yy_cp = yy_bp + 4;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 258 "libxlu_disk_l.l"
+#line 264 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
 	YY_BREAK
-case 33:
-/* rule 33 can match eol */
+case 37:
+/* rule 37 can match eol */
 YY_RULE_SETUP
-#line 260 "libxlu_disk_l.l"
+#line 266 "libxlu_disk_l.l"
 {
 		  xlu__disk_err(DPC,yytext,"unknown deprecated disk prefix");
 		  return 0;
 		}
 	YY_BREAK
 /* positional parameters */
-case 34:
-/* rule 34 can match eol */
+case 38:
+/* rule 38 can match eol */
 YY_RULE_SETUP
-#line 267 "libxlu_disk_l.l"
+#line 273 "libxlu_disk_l.l"
 {
     STRIP(',');
 
@@ -1847,27 +1900,27 @@ YY_RULE_SETUP
     }
 }
 	YY_BREAK
-case 35:
+case 39:
 YY_RULE_SETUP
-#line 293 "libxlu_disk_l.l"
+#line 299 "libxlu_disk_l.l"
 {
     BEGIN(LEXERR);
     yymore();
 }
 	YY_BREAK
-case 36:
+case 40:
 YY_RULE_SETUP
-#line 297 "libxlu_disk_l.l"
+#line 303 "libxlu_disk_l.l"
 {
     xlu__disk_err(DPC,yytext,"bad disk syntax"); return 0;
 }
 	YY_BREAK
-case 37:
+case 41:
 YY_RULE_SETUP
-#line 300 "libxlu_disk_l.l"
+#line 306 "libxlu_disk_l.l"
 YY_FATAL_ERROR( "flex scanner jammed" );
 	YY_BREAK
-#line 1870 "libxlu_disk_l.c"
+#line 1923 "libxlu_disk_l.c"
 			case YY_STATE_EOF(INITIAL):
 			case YY_STATE_EOF(LEXERR):
 				yyterminate();
@@ -2135,7 +2188,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			{
 			yy_current_state = (int) yy_def[yy_current_state];
-			if ( yy_current_state >= 372 )
+			if ( yy_current_state >= 405 )
 				yy_c = yy_meta[yy_c];
 			}
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@@ -2159,11 +2212,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		{
 		yy_current_state = (int) yy_def[yy_current_state];
-		if ( yy_current_state >= 372 )
+		if ( yy_current_state >= 405 )
 			yy_c = yy_meta[yy_c];
 		}
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
-	yy_is_jam = (yy_current_state == 371);
+	yy_is_jam = (yy_current_state == 404);
 	if ( ! yy_is_jam )
 		*yyg->yy_state_ptr++ = yy_current_state;
 
@@ -2972,4 +3025,4 @@ void yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 300 "libxlu_disk_l.l"
+#line 306 "libxlu_disk_l.l"
diff --git a/tools/libs/util/libxlu_disk_l.h b/tools/libs/util/libxlu_disk_l.h
index 509aad67dc..c868422568 100644
--- a/tools/libs/util/libxlu_disk_l.h
+++ b/tools/libs/util/libxlu_disk_l.h
@@ -3,9 +3,12 @@
 #define xlu__disk_yyIN_HEADER 1
 
 #line 5 "libxlu_disk_l.h"
+#line 31 "libxlu_disk_l.l"
 #define _GNU_SOURCE
 
-#line 8 "libxlu_disk_l.h"
+
+
+#line 11 "libxlu_disk_l.h"
 
 #define  YY_INT_ALIGNED short int
 
@@ -694,8 +697,8 @@ extern int yylex (yyscan_t yyscanner);
 #undef yyTABLES_NAME
 #endif
 
-#line 300 "libxlu_disk_l.l"
+#line 306 "libxlu_disk_l.l"
 
-#line 699 "libxlu_disk_l.h"
+#line 702 "libxlu_disk_l.h"
 #undef xlu__disk_yyIN_HEADER
 #endif /* xlu__disk_yyHEADER_H */
diff --git a/tools/libs/util/libxlu_disk_l.l b/tools/libs/util/libxlu_disk_l.l
index 6d53c093a3..f37dd443bd 100644
--- a/tools/libs/util/libxlu_disk_l.l
+++ b/tools/libs/util/libxlu_disk_l.l
@@ -220,6 +220,9 @@ hidden-disk=[^,]*,?	{ STRIP(','); SAVESTRING("hidden-disk", hidden_disk, FROMEQU
 trusted,?		{ libxl_defbool_set(&DPC->disk->trusted, true); }
 untrusted,?		{ libxl_defbool_set(&DPC->disk->trusted, false); }
 
+grant_usage=1,?		{ libxl_defbool_set(&DPC->disk->grant_usage, true); }
+grant_usage=0,?		{ libxl_defbool_set(&DPC->disk->grant_usage, false); }
+
  /* the target magic parameter, eats the rest of the string */
 
 target=.*	{ STRIP(','); SAVESTRING("target", pdev_path, FROMEQUALS); }
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 19 11:55:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 19 Feb 2024 11:55:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.682805.1061982 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rc2FD-00006a-Hn; Mon, 19 Feb 2024 11:55:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 682805.1061982; Mon, 19 Feb 2024 11:55:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rc2FD-00006T-FF; Mon, 19 Feb 2024 11:55:35 +0000
Received: by outflank-mailman (input) for mailman id 682805;
 Mon, 19 Feb 2024 11:55:34 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rc2FC-00006J-Ip
 for xen-changelog@lists.xenproject.org; Mon, 19 Feb 2024 11:55:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rc2FC-0005KA-Hv
 for xen-changelog@lists.xenproject.org; Mon, 19 Feb 2024 11:55:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rc2FC-0004Df-Es
 for xen-changelog@lists.xenproject.org; Mon, 19 Feb 2024 11:55:34 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=AdsUwOVG2gPz7QiNXp9FkR+8Vo6Q/CBoDBia6Yk29UU=; b=eh8qxWmrWkVStWmNRl4wQxvaKI
	oQs/f01g+i8+15SSqD0nP3FGFZ19g9skK3cD9zLKo9dfCehUayx5ftmTB9wPprQuh6q69OOVDrdbU
	mPDxrcLeti7s+Lu6cbrGfsyxEQplMdCuL6/T1jK6Ngukyw09RBLjZMm4JM6qt2BbmM+c=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86: Reduce assembly code size of entry points
Message-Id: <E1rc2FC-0004Df-Es@xenbits.xenproject.org>
Date: Mon, 19 Feb 2024 11:55:34 +0000

commit c144b9e32427ba37e0e0443a0d3fa53e9fb878b6
Author:     Frediano Ziglio <frediano.ziglio@cloud.com>
AuthorDate: Mon Feb 19 12:46:21 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 19 12:46:21 2024 +0100

    x86: Reduce assembly code size of entry points
    
    On many entries we push 8-bytes zero and exception constants are
    small so we can just write a single byte saving 3 bytes for
    instruction.
    With ENDBR64 this reduces the size of many entry points from 32 to
    16 bytes (due to alignment).
    The push and the mov are overlapping stores either way.  Swapping
    between movl and movb will make no difference at all on performance.
    Similar code is already used in autogen_stubs.
    
    Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/x86_64/entry.S | 66 +++++++++++++++++++++++++++------------------
 1 file changed, 40 insertions(+), 26 deletions(-)

diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index ecdd6e5b47..a7bd8f0ca5 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -22,6 +22,14 @@
 #endif
 .endm
 
+.macro BUILD_BUG_ON condstr cond:vararg
+        .if \cond
+        .error "Condition \"\condstr\" not satisfied"
+        .endif
+.endm
+/* preprocessor macro to make error message more user friendly */
+#define BUILD_BUG_ON(cond) BUILD_BUG_ON #cond cond
+
 #ifdef CONFIG_PV
 /* %rbx: struct vcpu */
 FUNC_LOCAL(switch_to_kernel)
@@ -187,7 +195,8 @@ FUNC_LOCAL(restore_all_guest)
         SPEC_CTRL_EXIT_TO_PV    /* Req: a=spec_ctrl %rsp=regs/cpuinfo, Clob: cd */
 
         RESTORE_ALL
-        testw $TRAP_syscall,4(%rsp)
+        BUILD_BUG_ON(TRAP_syscall & 0xff)
+        testb $TRAP_syscall >> 8, 4+1(%rsp)
         jz    iret_exit_to_guest
 
         movq  24(%rsp),%r11           # RFLAGS
@@ -254,7 +263,8 @@ FUNC(lstar_enter)
         pushq $FLAT_KERNEL_CS64
         pushq %rcx
         pushq $0
-        movl  $TRAP_syscall, 4(%rsp)
+        BUILD_BUG_ON(TRAP_syscall & 0xff)
+        movb  $TRAP_syscall >> 8, 4+1(%rsp)
         SAVE_ALL
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
@@ -292,7 +302,8 @@ FUNC(cstar_enter)
         pushq $FLAT_USER_CS32
         pushq %rcx
         pushq $0
-        movl  $TRAP_syscall, 4(%rsp)
+        BUILD_BUG_ON(TRAP_syscall & 0xff)
+        movb  $TRAP_syscall >> 8, 4+1(%rsp)
         SAVE_ALL
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
@@ -334,7 +345,8 @@ LABEL(sysenter_eflags_saved, 0)
         pushq $3 /* ring 3 null cs */
         pushq $0 /* null rip */
         pushq $0
-        movl  $TRAP_syscall, 4(%rsp)
+        BUILD_BUG_ON(TRAP_syscall & 0xff)
+        movb  $TRAP_syscall >> 8, 4+1(%rsp)
         SAVE_ALL
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
@@ -389,7 +401,7 @@ FUNC(entry_int80)
         ENDBR64
         ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
         pushq $0
-        movl  $0x80, 4(%rsp)
+        movb  $0x80, 4(%rsp)
         SAVE_ALL
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
@@ -561,7 +573,8 @@ __UNLIKELY_END(create_bounce_frame_bad_sp)
         /* Rewrite our stack frame and return to guest-OS mode. */
         /* IA32 Ref. Vol. 3: TF, VM, RF and NT flags are cleared on trap. */
         /* Also clear AC: alignment checks shouldn't trigger in kernel mode. */
-        orl   $TRAP_syscall,UREGS_entry_vector+8(%rsp)
+        BUILD_BUG_ON(TRAP_syscall & 0xff)
+        orb   $TRAP_syscall >> 8, UREGS_entry_vector+8+1(%rsp)
         andl  $~(X86_EFLAGS_AC|X86_EFLAGS_VM|X86_EFLAGS_RF|\
                  X86_EFLAGS_NT|X86_EFLAGS_TF),UREGS_eflags+8(%rsp)
         movq  $FLAT_KERNEL_SS,UREGS_ss+8(%rsp)
@@ -653,7 +666,7 @@ END(ret_from_intr)
         .section .init.text, "ax", @progbits
 FUNC(early_page_fault)
         ENDBR64
-        movl  $X86_EXC_PF, 4(%rsp)
+        movb  $X86_EXC_PF, 4(%rsp)
         SAVE_ALL
         movq  %rsp, %rdi
         call  do_early_page_fault
@@ -722,7 +735,7 @@ END(common_interrupt)
 
 FUNC(entry_PF)
         ENDBR64
-        movl  $X86_EXC_PF, 4(%rsp)
+        movb  $X86_EXC_PF, 4(%rsp)
 END(entry_PF)
 /* No special register assumptions. */
 FUNC(handle_exception, 0)
@@ -898,105 +911,106 @@ END(handle_exception)
 FUNC(entry_DE)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_DE, 4(%rsp)
+        /* no need to update exception type, already 0 */
+        BUILD_BUG_ON(X86_EXC_DE)
         jmp   handle_exception
 END(entry_DE)
 
 FUNC(entry_MF)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_MF, 4(%rsp)
+        movb  $X86_EXC_MF, 4(%rsp)
         jmp   handle_exception
 END(entry_MF)
 
 FUNC(entry_XM)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_XM, 4(%rsp)
+        movb  $X86_EXC_XM, 4(%rsp)
         jmp   handle_exception
 END(entry_XM)
 
 FUNC(entry_NM)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_NM, 4(%rsp)
+        movb  $X86_EXC_NM, 4(%rsp)
         jmp   handle_exception
 END(entry_NM)
 
 FUNC(entry_DB)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_DB, 4(%rsp)
+        movb  $X86_EXC_DB, 4(%rsp)
         jmp   handle_ist_exception
 END(entry_DB)
 
 FUNC(entry_BP)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_BP, 4(%rsp)
+        movb  $X86_EXC_BP, 4(%rsp)
         jmp   handle_exception
 END(entry_BP)
 
 FUNC(entry_OF)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_OF, 4(%rsp)
+        movb  $X86_EXC_OF, 4(%rsp)
         jmp   handle_exception
 END(entry_OF)
 
 FUNC(entry_BR)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_BR, 4(%rsp)
+        movb  $X86_EXC_BR, 4(%rsp)
         jmp   handle_exception
 END(entry_BR)
 
 FUNC(entry_UD)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_UD, 4(%rsp)
+        movb  $X86_EXC_UD, 4(%rsp)
         jmp   handle_exception
 END(entry_UD)
 
 FUNC(entry_TS)
         ENDBR64
-        movl  $X86_EXC_TS, 4(%rsp)
+        movb  $X86_EXC_TS, 4(%rsp)
         jmp   handle_exception
 END(entry_TS)
 
 FUNC(entry_NP)
         ENDBR64
-        movl  $X86_EXC_NP, 4(%rsp)
+        movb  $X86_EXC_NP, 4(%rsp)
         jmp   handle_exception
 END(entry_NP)
 
 FUNC(entry_SS)
         ENDBR64
-        movl  $X86_EXC_SS, 4(%rsp)
+        movb  $X86_EXC_SS, 4(%rsp)
         jmp   handle_exception
 END(entry_SS)
 
 FUNC(entry_GP)
         ENDBR64
-        movl  $X86_EXC_GP, 4(%rsp)
+        movb  $X86_EXC_GP, 4(%rsp)
         jmp   handle_exception
 END(entry_GP)
 
 FUNC(entry_AC)
         ENDBR64
-        movl  $X86_EXC_AC, 4(%rsp)
+        movb  $X86_EXC_AC, 4(%rsp)
         jmp   handle_exception
 END(entry_AC)
 
 FUNC(entry_CP)
         ENDBR64
-        movl  $X86_EXC_CP, 4(%rsp)
+        movb  $X86_EXC_CP, 4(%rsp)
         jmp   handle_exception
 END(entry_CP)
 
 FUNC(entry_DF)
         ENDBR64
-        movl  $X86_EXC_DF, 4(%rsp)
+        movb  $X86_EXC_DF, 4(%rsp)
         /* Set AC to reduce chance of further SMAP faults */
         ALTERNATIVE "", stac, X86_FEATURE_XEN_SMAP
         SAVE_ALL
@@ -1022,7 +1036,7 @@ END(entry_DF)
 FUNC(entry_NMI)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_NMI, 4(%rsp)
+        movb  $X86_EXC_NMI, 4(%rsp)
 END(entry_NMI)
 
 FUNC(handle_ist_exception)
@@ -1158,7 +1172,7 @@ END(handle_ist_exception)
 FUNC(entry_MC)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_MC, 4(%rsp)
+        movb  $X86_EXC_MC, 4(%rsp)
         jmp   handle_ist_exception
 END(entry_MC)
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 20 05:33:09 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 20 Feb 2024 05:33:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.683167.1062531 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcIkZ-0004ty-2J; Tue, 20 Feb 2024 05:33:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 683167.1062531; Tue, 20 Feb 2024 05:33:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcIkY-0004tq-Vy; Tue, 20 Feb 2024 05:33:02 +0000
Received: by outflank-mailman (input) for mailman id 683167;
 Tue, 20 Feb 2024 05:33:01 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcIkX-0004tk-TG
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 05:33:01 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcIkX-0000w8-SI
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 05:33:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcIkX-0002Kn-RL
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 05:33:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=MLUVWbfpFYRss0Ho1UStubdQkEayeeFJ3xawuEbt5Yw=; b=NYrf+OV8r366UsVNJhsIkfizZE
	QJQ22BqlXzBep2er+RtNo2QtcHuNYBfs5O5zcpQ28O5heCT3ZZlIRDpqkos2FqceLQZwHxSHAViZx
	VSxMacZJB+h7mGOpC7SdOCqMZjwLwCcMph1NMfuc52JDy3K8xNy7JgqZtfenxCHXxRzw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] mm: add the __must_check attribute to {gfn,mfn,dfn}_add()
Message-Id: <E1rcIkX-0002Kn-RL@xenbits.xenproject.org>
Date: Tue, 20 Feb 2024 05:33:01 +0000

commit 4917b9a423cbb09a44403c6a0d292a4baf85b93c
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon Feb 19 12:44:50 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 19 12:44:50 2024 +0100

    mm: add the __must_check attribute to {gfn,mfn,dfn}_add()
    
    It's not obvious from just the function name whether the incremented value will
    be stored in the parameter, or returned to the caller.  That has leads to bugs
    in the past as callers may assume the incremented value is stored in the
    parameter.
    
    Add the __must_check attribute to the function to easily spot callers that
    don't consume the returned value, which signals an error in the caller logic.
    
    No functional change intended.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/include/xen/iommu.h    | 2 +-
 xen/include/xen/mm-frame.h | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
index 7aa6a77209..9621459c63 100644
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -42,7 +42,7 @@ TYPE_SAFE(uint64_t, dfn);
 #undef dfn_x
 #endif
 
-static inline dfn_t dfn_add(dfn_t dfn, unsigned long i)
+static inline dfn_t __must_check dfn_add(dfn_t dfn, unsigned long i)
 {
     return _dfn(dfn_x(dfn) + i);
 }
diff --git a/xen/include/xen/mm-frame.h b/xen/include/xen/mm-frame.h
index 922ae41880..c25e836f25 100644
--- a/xen/include/xen/mm-frame.h
+++ b/xen/include/xen/mm-frame.h
@@ -23,7 +23,7 @@ TYPE_SAFE(unsigned long, mfn);
 #undef mfn_x
 #endif
 
-static inline mfn_t mfn_add(mfn_t mfn, unsigned long i)
+static inline mfn_t __must_check mfn_add(mfn_t mfn, unsigned long i)
 {
     return _mfn(mfn_x(mfn) + i);
 }
@@ -62,7 +62,7 @@ TYPE_SAFE(unsigned long, gfn);
 #undef gfn_x
 #endif
 
-static inline gfn_t gfn_add(gfn_t gfn, unsigned long i)
+static inline gfn_t __must_check gfn_add(gfn_t gfn, unsigned long i)
 {
     return _gfn(gfn_x(gfn) + i);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 20 05:33:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 20 Feb 2024 05:33:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.683168.1062535 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcIkj-0004w7-3p; Tue, 20 Feb 2024 05:33:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 683168.1062535; Tue, 20 Feb 2024 05:33:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcIkj-0004vz-16; Tue, 20 Feb 2024 05:33:13 +0000
Received: by outflank-mailman (input) for mailman id 683168;
 Tue, 20 Feb 2024 05:33:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcIki-0004vt-0u
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 05:33:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcIkh-0000wK-WC
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 05:33:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcIkh-0002LE-UO
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 05:33:11 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=OkL6Qld7eKwIZedWhIVD1ZVZ1llZBNEkEZgkBSvTRLk=; b=wMgHg6nf07UzWDA5+uKppaoUCq
	J+Ev7tvchzEdlYw/unWWnbxJLy0DDGpX4I4eDQxXJUl4OUSPBWEW6tq3m0OlfB6e3qJce5f6pzeOE
	UrVk7X08KXkI1akCQfoKB3rbA9gYcdejZYQm7Fu/ALQ7RJIsivq996vZYs2r3l58z0p4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] build: Replace `which` with `command -v`
Message-Id: <E1rcIkh-0002LE-UO@xenbits.xenproject.org>
Date: Tue, 20 Feb 2024 05:33:11 +0000

commit f93629b18b528a5ab1b1092949c5420069c7226c
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Mon Feb 19 12:45:48 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 19 12:45:48 2024 +0100

    build: Replace `which` with `command -v`
    
    The `which` command is not standard, may not exist on the build host,
    or may not behave as expected by the build system. It is recommended
    to use `command -v` to find out if a command exist and have its path,
    and it's part of a POSIX shell standard (at least, it seems to be
    mandatory since IEEE Std 1003.1-2008, but was optional before).
    
    Fixes: c8a8645f1efe ("xen/build: Automatically locate a suitable python interpreter")
    Fixes: 3b47bcdb6d38 ("xen/build: Use a distro version of figlet")
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Tested-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/Makefile | 4 ++--
 xen/build.mk | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/Makefile b/xen/Makefile
index 21832d6402..767e47d6c7 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -25,8 +25,8 @@ export XEN_BUILD_HOST	:= $(shell hostname)
 endif
 
 # Best effort attempt to find a python interpreter, defaulting to Python 3 if
-# available.  Fall back to just `python` if `which` is nowhere to be found.
-PYTHON_INTERPRETER	:= $(word 1,$(shell which python3 python python2 2>/dev/null) python)
+# available.  Fall back to just `python`.
+PYTHON_INTERPRETER	:= $(word 1,$(shell command -v python3 || command -v python || command -v python2) python)
 export PYTHON		?= $(PYTHON_INTERPRETER)
 
 export CHECKPOLICY	?= checkpolicy
diff --git a/xen/build.mk b/xen/build.mk
index 26dd5a8e87..0f490ca71b 100644
--- a/xen/build.mk
+++ b/xen/build.mk
@@ -1,6 +1,6 @@
 quiet_cmd_banner = BANNER  $@
 define cmd_banner
-    if which figlet >/dev/null 2>&1 ; then \
+    if command -v figlet >/dev/null 2>&1 ; then \
 	echo " Xen $(XEN_FULLVERSION)" | figlet -f $< > $@.tmp; \
     else \
 	echo " Xen $(XEN_FULLVERSION)" > $@.tmp; \
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 20 05:33:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 20 Feb 2024 05:33:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.683169.1062539 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcIkt-00050D-5b; Tue, 20 Feb 2024 05:33:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 683169.1062539; Tue, 20 Feb 2024 05:33:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcIkt-000506-2c; Tue, 20 Feb 2024 05:33:23 +0000
Received: by outflank-mailman (input) for mailman id 683169;
 Tue, 20 Feb 2024 05:33:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcIks-0004zw-4e
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 05:33:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcIks-0000wq-3l
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 05:33:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcIks-0002Ld-2k
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 05:33:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=U1sNCLUc7WY/LEMwb8YqibBbVu5Pvu29pTgHsNIUJnU=; b=kKPSf1NBhdtt6SaSyT5URn4yJH
	+xqpxl5qibSneJginIN7hvSbEXKMmrHLsyh1fL0H0fzBq795duFLONNVJXY/Jmt+8mg7dehxlTGdh
	jN/Ic1E97v3eD/UdWnlk9MrwHZ3k8Q+lR679o83ANCDk6rFA1XRN8wm0r0mF+IuOvtj4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] libxl: Add "grant_usage" parameter for virtio disk devices
Message-Id: <E1rcIks-0002Ld-2k@xenbits.xenproject.org>
Date: Tue, 20 Feb 2024 05:33:22 +0000

commit 1eb013ef972408020013a6fb16a36c5a345c6ff7
Author:     Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
AuthorDate: Mon Feb 19 12:46:07 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 19 12:46:07 2024 +0100

    libxl: Add "grant_usage" parameter for virtio disk devices
    
    Allow administrators to control whether Xen grant mappings for
    the virtio disk devices should be used. By default (when new
    parameter is not specified), the existing behavior is retained
    (we enable grants if backend-domid != 0).
    
    Signed-off-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 docs/man/xl-disk-configuration.5.pod.in |   24 +
 tools/golang/xenlight/helpers.gen.go    |    6 +
 tools/golang/xenlight/types.gen.go      |    1 +
 tools/include/libxl.h                   |    7 +
 tools/libs/light/libxl_arm.c            |    4 +-
 tools/libs/light/libxl_disk.c           |   13 +
 tools/libs/light/libxl_types.idl        |    1 +
 tools/libs/util/libxlu_disk_l.c         | 1001 ++++++++++++++++---------------
 tools/libs/util/libxlu_disk_l.h         |    9 +-
 tools/libs/util/libxlu_disk_l.l         |    3 +
 10 files changed, 590 insertions(+), 479 deletions(-)

diff --git a/docs/man/xl-disk-configuration.5.pod.in b/docs/man/xl-disk-configuration.5.pod.in
index cb442bd5b4..986666ebf8 100644
--- a/docs/man/xl-disk-configuration.5.pod.in
+++ b/docs/man/xl-disk-configuration.5.pod.in
@@ -406,6 +406,30 @@ Virtio frontend driver (virtio-blk) to be used. Please note, the virtual
 device (vdev) is not passed to the guest in that case, but it still must be
 specified for the internal purposes.
 
+=item B<grant_usage=BOOLEAN>
+
+=over 4
+
+=item Description
+
+Specifies the usage of Xen grants for accessing guest memory. Only applicable
+to specification "virtio".
+
+=item Supported values
+
+1, 0
+
+=item Mandatory
+
+No
+
+=item Default value
+
+If this option is missing, then the default grant setting will be used,
+i.e. "grant_usage=1" if backend-domid != 0 or "grant_usage=0" otherwise.
+
+=back
+
 =back
 
 =head1 COLO Parameters
diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/helpers.gen.go
index 0f8e23773c..acdf1c1820 100644
--- a/tools/golang/xenlight/helpers.gen.go
+++ b/tools/golang/xenlight/helpers.gen.go
@@ -1885,6 +1885,9 @@ x.ActiveDisk = C.GoString(xc.active_disk)
 x.HiddenDisk = C.GoString(xc.hidden_disk)
 if err := x.Trusted.fromC(&xc.trusted);err != nil {
 return fmt.Errorf("converting field Trusted: %v", err)
+}
+if err := x.GrantUsage.fromC(&xc.grant_usage);err != nil {
+return fmt.Errorf("converting field GrantUsage: %v", err)
 }
 
  return nil}
@@ -1933,6 +1936,9 @@ if x.HiddenDisk != "" {
 xc.hidden_disk = C.CString(x.HiddenDisk)}
 if err := x.Trusted.toC(&xc.trusted); err != nil {
 return fmt.Errorf("converting field Trusted: %v", err)
+}
+if err := x.GrantUsage.toC(&xc.grant_usage); err != nil {
+return fmt.Errorf("converting field GrantUsage: %v", err)
 }
 
  return nil
diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/types.gen.go
index 9c8b7b81f6..76b4ed991b 100644
--- a/tools/golang/xenlight/types.gen.go
+++ b/tools/golang/xenlight/types.gen.go
@@ -741,6 +741,7 @@ ColoExport string
 ActiveDisk string
 HiddenDisk string
 Trusted Defbool
+GrantUsage Defbool
 }
 
 type DeviceNic struct {
diff --git a/tools/include/libxl.h b/tools/include/libxl.h
index 46bc774126..a370528ba1 100644
--- a/tools/include/libxl.h
+++ b/tools/include/libxl.h
@@ -578,6 +578,13 @@
  */
 #define LIBXL_HAVE_DEVICE_DISK_SPECIFICATION 1
 
+/*
+ * LIBXL_HAVE_DISK_GRANT_USAGE indicates that the libxl_device_disk
+ * has 'grant_usage' field to specify the usage of Xen grants for
+ * the specification 'virtio'.
+ */
+#define LIBXL_HAVE_DISK_GRANT_USAGE 1
+
 /*
  * LIBXL_HAVE_CONSOLE_ADD_XENSTORE indicates presence of the function
  * libxl_console_add_xenstore() in libxl.
diff --git a/tools/libs/light/libxl_arm.c b/tools/libs/light/libxl_arm.c
index 1539191774..1cb89fa584 100644
--- a/tools/libs/light/libxl_arm.c
+++ b/tools/libs/light/libxl_arm.c
@@ -1372,12 +1372,12 @@ next_resize:
             libxl_device_disk *disk = &d_config->disks[i];
 
             if (disk->specification == LIBXL_DISK_SPECIFICATION_VIRTIO) {
-                if (disk->backend_domid != LIBXL_TOOLSTACK_DOMID)
+                if (libxl_defbool_val(disk->grant_usage))
                     iommu_needed = true;
 
                 FDT( make_virtio_mmio_node(gc, fdt, disk->base, disk->irq,
                                            disk->backend_domid,
-                                           disk->backend_domid != LIBXL_TOOLSTACK_DOMID) );
+                                           libxl_defbool_val(disk->grant_usage)) );
             }
         }
 
diff --git a/tools/libs/light/libxl_disk.c b/tools/libs/light/libxl_disk.c
index ee2e4b0bd3..fa7856f28c 100644
--- a/tools/libs/light/libxl_disk.c
+++ b/tools/libs/light/libxl_disk.c
@@ -183,6 +183,9 @@ static int libxl__device_disk_setdefault(libxl__gc *gc, uint32_t domid,
             return ERROR_INVAL;
         }
         disk->transport = LIBXL_DISK_TRANSPORT_MMIO;
+
+        libxl_defbool_setdefault(&disk->grant_usage,
+                                 disk->backend_domid != LIBXL_TOOLSTACK_DOMID);
     }
 
     if (hotplug && disk->specification == LIBXL_DISK_SPECIFICATION_VIRTIO) {
@@ -468,6 +471,8 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,
             flexarray_append(back, libxl__device_disk_string_of_transport(disk->transport));
             flexarray_append_pair(back, "base", GCSPRINTF("%"PRIu64, disk->base));
             flexarray_append_pair(back, "irq", GCSPRINTF("%u", disk->irq));
+            flexarray_append_pair(back, "grant_usage",
+                                  libxl_defbool_val(disk->grant_usage) ? "1" : "0");
         }
 
         flexarray_append(front, "backend-id");
@@ -662,6 +667,14 @@ static int libxl__disk_from_xenstore(libxl__gc *gc, const char *libxl_path,
             goto cleanup;
         }
         disk->irq = strtoul(tmp, NULL, 10);
+
+        tmp = libxl__xs_read(gc, XBT_NULL,
+                             GCSPRINTF("%s/grant_usage", libxl_path));
+        if (!tmp)
+            libxl_defbool_set(&disk->grant_usage,
+                              disk->backend_domid != LIBXL_TOOLSTACK_DOMID);
+        else
+            libxl_defbool_set(&disk->grant_usage, strtoul(tmp, NULL, 0));
     }
 
     disk->vdev = xs_read(ctx->xsh, XBT_NULL,
diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_types.idl
index 899ad30969..6d76f25528 100644
--- a/tools/libs/light/libxl_types.idl
+++ b/tools/libs/light/libxl_types.idl
@@ -803,6 +803,7 @@ libxl_device_disk = Struct("device_disk", [
     ("active_disk", string),
     ("hidden_disk", string),
     ("trusted", libxl_defbool),
+    ("grant_usage", libxl_defbool),
     ])
 
 libxl_device_nic = Struct("device_nic", [
diff --git a/tools/libs/util/libxlu_disk_l.c b/tools/libs/util/libxlu_disk_l.c
index 0b59723b71..9213dd957c 100644
--- a/tools/libs/util/libxlu_disk_l.c
+++ b/tools/libs/util/libxlu_disk_l.c
@@ -1,7 +1,10 @@
 #line 1 "libxlu_disk_l.c"
+#line 31 "libxlu_disk_l.l"
 #define _GNU_SOURCE
 
-#line 4 "libxlu_disk_l.c"
+
+
+#line 7 "libxlu_disk_l.c"
 
 #define  YY_INT_ALIGNED short int
 
@@ -549,8 +552,8 @@ static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
 	yyg->yy_hold_char = *yy_cp; \
 	*yy_cp = '\0'; \
 	yyg->yy_c_buf_p = yy_cp;
-#define YY_NUM_RULES 37
-#define YY_END_OF_BUFFER 38
+#define YY_NUM_RULES 41
+#define YY_END_OF_BUFFER 42
 /* This struct is not used in this scanner,
    but its presence is necessary. */
 struct yy_trans_info
@@ -558,119 +561,127 @@ struct yy_trans_info
 	flex_int32_t yy_verify;
 	flex_int32_t yy_nxt;
 	};
-static const flex_int16_t yy_acclist[594] =
+static const flex_int16_t yy_acclist[634] =
     {   0,
-       36,   36,   38,   34,   35,   37, 8193,   34,   35,   37,
-    16385, 8193,   34,   37,16385,   34,   35,   37,   35,   37,
-       34,   35,   37,   34,   35,   37,   34,   35,   37,   34,
-       35,   37,   34,   35,   37,   34,   35,   37,   34,   35,
-       37,   34,   35,   37,   34,   35,   37,   34,   35,   37,
-       34,   35,   37,   34,   35,   37,   34,   35,   37,   34,
-       35,   37,   34,   35,   37,   34,   35,   37,   36,   37,
-       37,   34,   34, 8193,   34, 8193,   34,16385, 8193,   34,
-     8193,   34,   34, 8225,   34,16417,   34,   34,   34,   34,
-       34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
-
-       34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
-       36, 8193,   34, 8193,   34, 8193, 8225,   34, 8225,   34,
-     8225,   24,   34,   34,   34,   34,   34,   34,   34,   34,
-       34,   34,   34,   34,   34,   34,   34,   34,   34,   34,
-       34,   34,   34,   34,   34,   34,   34, 8225,   34, 8225,
-       34, 8225,   24,   34,   34,   29, 8225,   34,16417,   34,
-       34,   16,   34,   34,   34,   34,   34,   34,   34,   34,
-       34, 8218, 8225,   34,16410,16417,   34,   34,   32, 8225,
-       34,16417,   34, 8217, 8225,   34,16409,16417,   34,   34,
-       34, 8220, 8225,   34,16412,16417,   34,   34,   34,   34,
-
-       34,   29, 8225,   34,   29, 8225,   34,   29,   34,   29,
-     8225,   34,    3,   34,   16,   34,   34,   34,   34,   34,
-       31, 8225,   34,16417,   34,   34,   34, 8218, 8225,   34,
-     8218, 8225,   34, 8218,   34, 8218, 8225,   34,   34,   32,
-     8225,   34,   32, 8225,   34,   32,   34,   32, 8225, 8217,
-     8225,   34, 8217, 8225,   34, 8217,   34, 8217, 8225,   34,
-       34, 8220, 8225,   34, 8220, 8225,   34, 8220,   34, 8220,
-     8225,   34,   34,   11,   34,   34,   29, 8225,   34,   29,
-     8225,   34,   29, 8225,   29,   34,   29,   34,    3,   34,
-       34,   34,   34,   34,   34,   34,   31, 8225,   34,   31,
-
-     8225,   34,   31,   34,   31, 8225,   34,   34,   30, 8225,
-       34,16417, 8218, 8225,   34, 8218, 8225,   34, 8218, 8225,
-     8218,   34, 8218,   34,   34,   32, 8225,   34,   32, 8225,
-       34,   32, 8225,   32,   34,   32, 8217, 8225,   34, 8217,
-     8225,   34, 8217, 8225, 8217,   34, 8217,   34,   34, 8220,
-     8225,   34, 8220, 8225,   34, 8220, 8225, 8220,   34, 8220,
-       34,   34,   11,   24,   11,    7,   34,   34,   34,   34,
-       34,   34,   34,   14,   34,   31, 8225,   34,   31, 8225,
-       34,   31, 8225,   31,   34,   31,    2,   34,   30, 8225,
-       34,   30, 8225,   34,   30,   34,   30, 8225,   17,   34,
-
-       34,   12,   34,   34,   23,   11,   11,   24,    7,   24,
-        7,   34,    8,   34,   34,   34,   34,    6,   34,   14,
-       34,    2,   24,    2,   34,   30, 8225,   34,   30, 8225,
-       34,   30, 8225,   30,   34,   30,   17,   34,   34,   12,
-       24,   12,   34,   27, 8225,   34,16417,   23,   24,   23,
-        7,    7,   24,   34,    8,   24,    8,   34,   34,   34,
-       34,    6,   24,    6,    6,   24,    6,   24,   34,    2,
-        2,   24,   34,   34,   12,   12,   24,   34,   27, 8225,
-       34,   27, 8225,   34,   27,   34,   27, 8225,   23,   24,
-       34,    8,    8,   24,   34,   34,   18,   19,    6,    6,
-
-       24,    6,    6,   34,   34,   15,   34,   34,   27, 8225,
-       34,   27, 8225,   34,   27, 8225,   27,   34,   27,   34,
-       34,   34,   18,   24,   18,   19,   24,   19,    6,    6,
-       34,   34,   15,   34,   34,   21,    9,   20,   18,   18,
-       24,   19,   19,   24,    6,    5,    6,   34,   22,   34,
-       21,   24,   21,    9,   24,    9,   20,   24,   20,    4,
-        6,    5,    6,   34,   22,   24,   22,   34,   21,   21,
-       24,    9,    9,   24,   20,   20,   24,    4,    6,   13,
-       34,   22,   22,   24,   10,   13,   34,   10,   24,   10,
-       10,   10,   24
-
+       40,   40,   42,   38,   39,   41, 8193,   38,   39,   41,
+    16385, 8193,   38,   41,16385,   38,   39,   41,   39,   41,
+       38,   39,   41,   38,   39,   41,   38,   39,   41,   38,
+       39,   41,   38,   39,   41,   38,   39,   41,   38,   39,
+       41,   38,   39,   41,   38,   39,   41,   38,   39,   41,
+       38,   39,   41,   38,   39,   41,   38,   39,   41,   38,
+       39,   41,   38,   39,   41,   38,   39,   41,   38,   39,
+       41,   38,   39,   41,   40,   41,   41,   38,   38, 8193,
+       38, 8193,   38,16385, 8193,   38, 8193,   38,   38, 8229,
+       38,16421,   38,   38,   38,   38,   38,   38,   38,   38,
+
+       38,   38,   38,   38,   38,   38,   38,   38,   38,   38,
+       38,   38,   38,   38,   38,   38,   38,   38,   38,   40,
+     8193,   38, 8193,   38, 8193, 8229,   38, 8229,   38, 8229,
+       28,   38,   38,   38,   38,   38,   38,   38,   38,   38,
+       38,   38,   38,   38,   38,   38,   38,   38,   38,   38,
+       38,   38,   38,   38,   38,   38,   38,   38,   38, 8229,
+       38, 8229,   38, 8229,   28,   38,   38,   33, 8229,   38,
+    16421,   38,   38,   16,   38,   38,   38,   38,   38,   38,
+       38,   38,   38,   38, 8222, 8229,   38,16414,16421,   38,
+       38,   36, 8229,   38,16421,   38, 8221, 8229,   38,16413,
+
+    16421,   38,   38,   38, 8224, 8229,   38,16416,16421,   38,
+       38,   38,   38,   38,   38,   38,   33, 8229,   38,   33,
+     8229,   38,   33,   38,   33, 8229,   38,    3,   38,   16,
+       38,   38,   38,   38,   38,   35, 8229,   38,16421,   38,
+       38,   38,   38, 8222, 8229,   38, 8222, 8229,   38, 8222,
+       38, 8222, 8229,   38,   38,   36, 8229,   38,   36, 8229,
+       38,   36,   38,   36, 8229, 8221, 8229,   38, 8221, 8229,
+       38, 8221,   38, 8221, 8229,   38,   38, 8224, 8229,   38,
+     8224, 8229,   38, 8224,   38, 8224, 8229,   38,   38,   38,
+       38,   11,   38,   38,   33, 8229,   38,   33, 8229,   38,
+
+       33, 8229,   33,   38,   33,   38,    3,   38,   38,   38,
+       38,   38,   38,   38,   35, 8229,   38,   35, 8229,   38,
+       35,   38,   35, 8229,   38,   38,   38,   34, 8229,   38,
+    16421, 8222, 8229,   38, 8222, 8229,   38, 8222, 8229, 8222,
+       38, 8222,   38,   38,   36, 8229,   38,   36, 8229,   38,
+       36, 8229,   36,   38,   36, 8221, 8229,   38, 8221, 8229,
+       38, 8221, 8229, 8221,   38, 8221,   38,   38, 8224, 8229,
+       38, 8224, 8229,   38, 8224, 8229, 8224,   38, 8224,   38,
+       38,   38,   38,   11,   28,   11,    7,   38,   38,   38,
+       38,   38,   38,   38,   14,   38,   35, 8229,   38,   35,
+
+     8229,   38,   35, 8229,   35,   38,   35,    2,   38,   38,
+       34, 8229,   38,   34, 8229,   38,   34,   38,   34, 8229,
+       17,   38,   38,   12,   38,   38,   27,   23,   38,   38,
+       11,   11,   28,    7,   28,    7,   38,    8,   38,   38,
+       38,   38,    6,   38,   14,   38,    2,   28,    2,   38,
+       38,   34, 8229,   38,   34, 8229,   38,   34, 8229,   34,
+       38,   34,   17,   38,   38,   12,   28,   12,   38,   31,
+     8229,   38,16421,   27,   28,   27,   23,   38,   38,    7,
+        7,   28,   38,    8,   28,    8,   38,   38,   38,   38,
+        6,   28,    6,    6,   28,    6,   28,   38,    2,    2,
+
+       28,   38,   38,   38,   12,   12,   28,   38,   31, 8229,
+       38,   31, 8229,   38,   31,   38,   31, 8229,   27,   28,
+       24,   38,   38,    8,    8,   28,   38,   38,   18,   19,
+        6,    6,   28,    6,    6,   38,   38,   38,   15,   38,
+       38,   31, 8229,   38,   31, 8229,   38,   31, 8229,   31,
+       38,   31,   24,   38,   38,   38,   38,   18,   28,   18,
+       19,   28,   19,    6,    6,   38,   38,   38,   15,   38,
+       38,   21,    9,   20,   18,   18,   28,   19,   19,   28,
+        6,    5,    6,   38,   22,   38,   21,   28,   21,    9,
+       28,    9,   20,   28,   20,    4,    6,    5,    6,   38,
+
+       26,   25,   22,   28,   22,   38,   21,   21,   28,    9,
+        9,   28,   20,   20,   28,    4,    6,   13,   38,   26,
+       25,   22,   22,   28,   10,   13,   38,   10,   28,   10,
+       10,   10,   28
     } ;
 
-static const flex_int16_t yy_accept[373] =
+static const flex_int16_t yy_accept[406] =
     {   0,
         1,    1,    1,    2,    3,    4,    7,   12,   16,   19,
        21,   24,   27,   30,   33,   36,   39,   42,   45,   48,
-       51,   54,   57,   60,   63,   66,   69,   71,   72,   73,
-       74,   76,   79,   81,   82,   83,   84,   87,   87,   88,
-       89,   90,   91,   92,   93,   94,   95,   96,   97,   98,
-       99,  100,  101,  102,  103,  104,  105,  106,  107,  108,
-      109,  110,  111,  112,  114,  116,  117,  119,  121,  122,
-      123,  124,  125,  126,  127,  128,  129,  130,  131,  132,
-      133,  134,  135,  136,  137,  138,  139,  140,  141,  142,
-      143,  144,  145,  146,  147,  148,  150,  152,  153,  154,
-
-      155,  156,  160,  161,  162,  164,  165,  166,  167,  168,
-      169,  170,  171,  172,  177,  178,  179,  183,  184,  189,
-      190,  191,  192,  197,  198,  199,  200,  201,  202,  205,
-      208,  210,  212,  213,  215,  217,  218,  219,  220,  221,
-      225,  226,  227,  228,  231,  234,  236,  238,  239,  240,
-      243,  246,  248,  250,  253,  256,  258,  260,  261,  262,
-      265,  268,  270,  272,  273,  274,  275,  276,  277,  280,
-      283,  285,  287,  288,  289,  291,  292,  293,  294,  295,
-      296,  297,  300,  303,  305,  307,  308,  309,  313,  316,
-      319,  321,  323,  324,  325,  326,  329,  332,  334,  336,
-
-      337,  340,  343,  345,  347,  348,  349,  350,  353,  356,
-      358,  360,  361,  362,  363,  365,  366,  367,  368,  369,
-      370,  371,  372,  373,  374,  376,  379,  382,  384,  386,
-      387,  388,  389,  392,  395,  397,  399,  401,  402,  403,
-      404,  405,  406,  407,  409,  411,  412,  413,  414,  415,
-      416,  417,  418,  419,  420,  422,  424,  425,  426,  429,
-      432,  434,  436,  437,  439,  440,  442,  443,  444,  448,
-      450,  451,  452,  454,  455,  457,  458,  459,  460,  461,
-      462,  464,  465,  467,  469,  470,  471,  473,  474,  475,
-      476,  478,  479,  482,  485,  487,  489,  491,  492,  493,
-
-      495,  496,  497,  498,  499,  500,  502,  503,  504,  505,
-      506,  508,  509,  512,  515,  517,  519,  520,  521,  522,
-      523,  525,  526,  528,  529,  530,  531,  532,  533,  535,
-      536,  537,  538,  539,  540,  542,  543,  545,  546,  548,
-      549,  550,  551,  553,  554,  556,  557,  559,  560,  562,
-      564,  565,  567,  568,  569,  570,  572,  573,  575,  576,
-      578,  580,  582,  583,  585,  586,  588,  590,  591,  592,
-      594,  594
+       51,   54,   57,   60,   63,   66,   69,   72,   75,   77,
+       78,   79,   80,   82,   85,   87,   88,   89,   90,   93,
+       93,   94,   95,   96,   97,   98,   99,  100,  101,  102,
+      103,  104,  105,  106,  107,  108,  109,  110,  111,  112,
+      113,  114,  115,  116,  117,  118,  119,  120,  121,  123,
+      125,  126,  128,  130,  131,  132,  133,  134,  135,  136,
+      137,  138,  139,  140,  141,  142,  143,  144,  145,  146,
+      147,  148,  149,  150,  151,  152,  153,  154,  155,  156,
+
+      157,  158,  159,  160,  162,  164,  165,  166,  167,  168,
+      172,  173,  174,  176,  177,  178,  179,  180,  181,  182,
+      183,  184,  185,  190,  191,  192,  196,  197,  202,  203,
+      204,  205,  210,  211,  212,  213,  214,  215,  216,  217,
+      220,  223,  225,  227,  228,  230,  232,  233,  234,  235,
+      236,  240,  241,  242,  243,  244,  247,  250,  252,  254,
+      255,  256,  259,  262,  264,  266,  269,  272,  274,  276,
+      277,  278,  281,  284,  286,  288,  289,  290,  291,  292,
+      293,  294,  295,  298,  301,  303,  305,  306,  307,  309,
+      310,  311,  312,  313,  314,  315,  318,  321,  323,  325,
+
+      326,  327,  328,  332,  335,  338,  340,  342,  343,  344,
+      345,  348,  351,  353,  355,  356,  359,  362,  364,  366,
+      367,  368,  369,  372,  375,  377,  379,  380,  381,  382,
+      383,  384,  386,  387,  388,  389,  390,  391,  392,  393,
+      394,  395,  397,  400,  403,  405,  407,  408,  409,  410,
+      411,  414,  417,  419,  421,  423,  424,  425,  426,  427,
+      428,  430,  431,  432,  434,  436,  437,  438,  439,  440,
+      441,  442,  443,  444,  445,  447,  449,  450,  451,  452,
+      455,  458,  460,  462,  463,  465,  466,  468,  469,  470,
+      474,  476,  477,  479,  480,  481,  483,  484,  486,  487,
+
+      488,  489,  490,  491,  493,  494,  496,  498,  499,  500,
+      502,  503,  504,  505,  506,  508,  509,  512,  515,  517,
+      519,  521,  523,  524,  525,  527,  528,  529,  530,  531,
+      532,  534,  535,  536,  537,  538,  539,  541,  542,  545,
+      548,  550,  552,  553,  555,  556,  557,  558,  560,  561,
+      563,  564,  565,  566,  567,  568,  569,  571,  572,  573,
+      574,  575,  576,  578,  579,  581,  582,  584,  585,  585,
+      586,  587,  589,  590,  592,  593,  595,  596,  598,  600,
+      601,  602,  603,  605,  606,  607,  608,  610,  611,  613,
+      614,  616,  618,  620,  621,  622,  623,  625,  626,  628,
+
+      630,  631,  632,  634,  634
     } ;
 
 static const YY_CHAR yy_ec[256] =
@@ -679,16 +690,16 @@ static const YY_CHAR yy_ec[256] =
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    2,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    4,    5,    1,    1,    6,    6,    7,
-        6,    6,    6,    6,    6,    6,    6,    8,    1,    1,
-        9,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    4,    5,    1,    1,    6,    7,    8,
+        9,    9,    9,    9,    9,    9,    9,   10,    1,    1,
+       11,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,   10,   11,   12,   13,
+        1,    1,    1,    1,   12,    1,   13,   14,   15,   16,
 
-       14,   15,   16,   17,   18,   19,   20,   21,   22,   23,
-       24,   25,   26,   27,   28,   29,   30,   31,   32,   33,
-       34,   19,    1,    1,    1,    1,    1,    1,    1,    1,
+       17,   18,   19,   20,   21,   22,   23,   24,   25,   26,
+       27,   28,   29,   30,   31,   32,   33,   34,   35,   36,
+       37,   22,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
@@ -705,340 +716,362 @@ static const YY_CHAR yy_ec[256] =
         1,    1,    1,    1,    1
     } ;
 
-static const YY_CHAR yy_meta[35] =
+static const YY_CHAR yy_meta[38] =
     {   0,
-        1,    1,    2,    3,    1,    1,    1,    1,    4,    1,
+        1,    1,    2,    3,    1,    1,    1,    1,    1,    1,
+        4,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1
+        1,    1,    1,    1,    1,    1,    1
     } ;
 
-static const flex_int16_t yy_base[443] =
+static const flex_int16_t yy_base[476] =
     {   0,
-        0,    0,  936,  935,  937,  932,   33,   36,  940,  940,
-       45,   63,   31,   42,   51,   52,  925,   33,   65,   67,
-       69,   70,  924,   71,  923,   75,    0,  940,  928,  940,
-       91,   95,    0,    0,  104,  921,  113,    0,   91,   99,
-      114,   92,  115,   80,  100,   48,  119,  121,  122,   74,
-      123,  128,  131,  129,  125,  133,  135,  136,  137,  143,
-      138,  145,    0,  157,    0,    0,  168,    0,    0,  926,
-      140,  146,  165,  159,  152,  164,  155,  168,  171,  176,
-      177,  170,  180,  175,  184,  188,  212,  191,  185,  192,
-      193,  194,  219,  212,  199,  230,    0,    0,  940,  195,
-
-      200,  239,  235,  197,  246,  225,  226,  919,  244,  918,
-      243,  236,  245,  266,  248,  264,  282,  271,  291,  248,
-      270,  254,  300,  279,  296,  302,  288,  303,  311,    0,
-      315,    0,  311,  318,  940,  313,  319,  208,  313,  344,
-      321,  331,  325,  333,    0,  352,    0,  345,  347,  359,
-        0,  361,    0,  368,    0,  370,    0,  322,  366,  379,
-        0,  381,    0,  359,  357,  923,  382,  384,  392,    0,
-        0,    0,    0,  387,  940,  386,  390,  392,  329,  401,
-      397,  409,    0,  417,    0,  399,  412,  426,  429,    0,
-        0,    0,    0,  412,  427,  438,    0,    0,    0,    0,
-
-      440,    0,    0,    0,    0,  436,  405,  447,    0,    0,
-        0,    0,  438,  443,  922,  940,  921,  442,  450,  449,
-      452,  454,  459,  458,  453,  469,    0,    0,    0,    0,
-      920,  470,  481,    0,  483,    0,  484,  481,  919,  368,
-      467,  495,  918,  940,  917,  940,  488,  916,  479,  490,
-      492,  495,  505,  498,  940,  915,  940,  507,  523,    0,
-        0,    0,    0,  940,  503,  864,  940,  846,  532,  836,
-        0,  824,  940,  516,  796,  940,  513,  530,  536,  538,
-      784,  940,  542,  535,  547,  772,  940,  549,  551,  768,
-      940,  502,  562,    0,  564,    0,    0,  562,  764,  940,
-
-      544,  557,  760,  752,  744,  940,  552,  568,  571,  568,
-      581,  577,  588,    0,    0,    0,    0,  589,  580,  591,
-      736,  940,  728,  940,  601,  602,  597,  599,  940,  603,
-      720,  712,  700,  672,  940,  665,  940,  610,  656,  603,
-      648,  607,  629,  940,  627,  940,  625,  940,  624,  940,
-      607,  574,  940,  614,  572,  940,  491,  940,  433,  940,
-      940,  622,  389,  940,  303,  940,  261,  940,  204,  940,
-      940,  635,  639,  642,  646,  650,  654,  658,  662,  666,
-      670,  674,  678,  682,  686,  690,  694,  698,  702,  706,
-      710,  714,  718,  722,  726,  730,  734,  738,  742,  746,
-
-      750,  754,  758,  762,  766,  770,  774,  778,  782,  786,
-      790,  794,  798,  802,  806,  810,  814,  818,  822,  826,
-      830,  834,  838,  842,  846,  850,  854,  858,  862,  866,
-      870,  874,  878,  882,  886,  890,  894,  898,  902,  906,
-      910,  914
+        0,    0, 1008, 1007, 1009, 1004,   36,   39, 1012, 1012,
+       50,   71,   32,   72,   31,   43,   33,   45,   64,  994,
+       65,   67,   54,  993,   73,   77,   83,   84,    0, 1012,
+     1001, 1012,   95,  108,    0,    0,  119,  991,  131,    0,
+      112,   81,   90,  115,  100,  103,  125,  101,  104,  126,
+      127,  990,  133,  134,  139,  145,  154,  135,  147,  140,
+      149,  151,  150,  152,   36,  153,  160,    0,  178,    0,
+        0,  180,    0,    0,  998,  173,  156,  182,  174,  175,
+      180,  181,  183,  186,  190,  191,  185,  192,  196,  198,
+      201,  206,  232,  207,  202,  211,  209,  212,  241,  226,
+
+      215,  225,  216,  249,    0,    0, 1012,  227,  228,  262,
+      258,  243,  265,  246,  264,  988,  271,  987,  248,  269,
+      263,  272,  296,  275,  273,  308,  313,  326,  304,  274,
+      312,  338,  303,  334,  301,  302,  292,  321,  340,  351,
+        0,  355,    0,  343,  357, 1012,  348,  332,  354,  358,
+      388,  362,  360,  361,  367,  392,    0,  398,    0,  389,
+      366,  403,    0,  407,    0,  412,    0,  416,    0,  399,
+      213,  418,    0,  421,    0,  395,  404,  366,  415,  995,
+      333,  425,  430,    0,    0,    0,    0,  424, 1012,  427,
+      429,  432,  422,  444,  437,  451,    0,  457,    0,  453,
+
+      447,  460,  480,  466,    0,    0,    0,    0,  459,  369,
+      468,    0,    0,    0,    0,  484,    0,    0,    0,    0,
+      465,  476,  490,    0,    0,    0,    0,  483,  487,  486,
+      490,  994, 1012,  993,  489,  496,  495,  498,  500,  506,
+      505,  454,  521,    0,    0,    0,    0,  992,  504,  518,
+      533,    0,  535,    0,  527,  532,  991,  536,  540,  537,
+      514,  539,  990, 1012,  989, 1012,  539,  988,  544,  543,
+      546,  548,  561,  552, 1012,  987, 1012,  562,  567,  581,
+        0,    0,    0,    0, 1012,  556,  986, 1012,  976,  592,
+      984,    0, 1012,  574,  983, 1012,  558,  982, 1012,  578,
+
+      583,  594,  596,  981, 1012,  288,  596,  603,  930, 1012,
+      597,  599,  605,  918, 1012,  609,  620,    0,  622,    0,
+        0,  623,  619,  902, 1012,  615,  622,  890,  862,  850,
+     1012,  625,  635,  628,  636,  633,  642,  639,  658,    0,
+        0,    0,    0, 1012,  652,  634,  659,  838, 1012,  834,
+     1012,  646,  660,  663,  661,  666, 1012,  658,  830,  826,
+      818,  810, 1012,  802, 1012,  676,  794,  671,  684,  786,
+      671,  778, 1012,  766, 1012,  738, 1012,  731, 1012,  677,
+      722,  714,  691, 1012,  685,  647, 1012,  565, 1012,  508,
+     1012, 1012,  684, 1012, 1012,  448, 1012,  374, 1012,  167,
+
+     1012,  122, 1012, 1012,  701,  705,  708,  712,  716,  720,
+      724,  728,  732,  736,  740,  744,  748,  752,  756,  760,
+      764,  768,  772,  776,  780,  784,  788,  792,  796,  800,
+      804,  808,  812,  816,  820,  824,  828,  832,  836,  840,
+      844,  848,  852,  856,  860,  864,  868,  872,  876,  880,
+      884,  888,  892,  896,  900,  904,  908,  912,  916,  920,
+      924,  928,  932,  936,  940,  944,  948,  952,  956,  960,
+      964,  968,  972,  976,  980
     } ;
 
-static const flex_int16_t yy_def[443] =
+static const flex_int16_t yy_def[476] =
     {   0,
-      371,    1,  372,  372,  371,  373,  374,  374,  371,  371,
-      375,  375,   12,   12,   12,   12,   12,   12,   12,   12,
-       12,   12,   12,   12,   12,   12,  376,  371,  373,  371,
-      377,  374,  378,  378,  379,   12,  373,  380,   12,   12,
+      404,    1,  405,  405,  404,  406,  407,  407,  404,  404,
+      408,  408,   12,   12,   12,   12,   12,   12,   12,   12,
+       12,   12,   12,   12,   12,   12,   12,   12,  409,  404,
+      406,  404,  410,  407,  411,  411,  412,   12,  406,  413,
+       12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
        12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
+       12,   12,   12,   12,   12,   12,   12,  409,  410,  411,
+      411,  414,  415,  415,  404,   12,   12,   12,   12,   12,
        12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
-       12,   12,  376,  377,  378,  378,  381,  382,  382,  371,
+       12,   12,  412,   12,   12,   12,   12,   12,   12,   12,
+
+       12,   12,   12,  414,  415,  415,  404,   12,   12,  416,
        12,   12,   12,   12,   12,   12,   12,   12,   12,   12,
-       12,   12,   12,   12,   12,   12,  379,   12,   12,   12,
-       12,   12,   12,   12,   12,  381,  382,  382,  371,   12,
-
-       12,  383,   12,   12,   12,   12,   12,   12,   12,   12,
-       12,   12,   12,  384,   87,   87,  385,   12,  386,   12,
-       12,   12,  387,   12,   12,   12,   12,   12,  388,  389,
-      383,  389,   12,   12,  371,   87,   12,   12,   12,  390,
-       12,   12,   12,  391,  392,  384,  392,   87,   87,  393,
-      394,  385,  394,  395,  396,  386,  396,   12,   12,  397,
-      398,  387,  398,   12,   12,  399,   12,   12,  388,  389,
-      389,  400,  400,   12,  371,   87,   87,   87,   12,   12,
-       12,  401,  402,  390,  402,   12,   12,  403,  391,  392,
-      392,  404,  404,   87,   87,  393,  394,  394,  405,  405,
-
-      395,  396,  396,  406,  406,   12,   12,  397,  398,  398,
-      407,  407,   12,   12,  408,  371,  409,   87,   12,   87,
-       87,   87,   12,   87,   12,  401,  402,  402,  410,  410,
-      411,   87,  412,  413,  403,  413,   87,   87,  414,   12,
-       12,  415,  408,  371,  416,  371,   87,  417,   12,   87,
-       87,   87,  418,   87,  371,  419,  371,   87,  412,  413,
-      413,  420,  420,  371,   87,  421,  371,   12,  422,  423,
-      423,  416,  371,   87,  424,  371,   12,   87,   87,   87,
-      425,  371,  425,  425,   87,  419,  371,   87,   87,  421,
-      371,   12,  426,  427,  422,  427,  423,   87,  424,  371,
-
-       12,   87,  428,  429,  425,  371,  425,  425,   87,   87,
-       87,   12,  426,  427,  427,  430,  430,   87,   12,   87,
-      431,  371,  432,  371,  425,  425,   87,   87,  371,   12,
-      433,  434,  435,  431,  371,  432,  371,  425,  425,   87,
-      436,   12,  437,  371,  438,  371,  439,  371,  425,  371,
-       87,  440,  371,   12,  437,  371,  438,  371,  439,  371,
-      371,   87,  440,  371,  441,  371,  442,  371,  442,  371,
-        0,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371
+       12,   12,  417,   93,   93,  418,   12,  419,   12,   12,
+       12,  420,   12,   12,   12,   12,   12,   12,   12,  421,
+      422,  416,  422,   12,   12,  404,   93,   12,   12,   12,
+      423,   12,   12,   12,   12,  424,  425,  417,  425,   93,
+       93,  426,  427,  418,  427,  428,  429,  419,  429,   12,
+       12,  430,  431,  420,  431,   12,   12,   12,   12,  432,
+       12,   12,  421,  422,  422,  433,  433,   12,  404,   93,
+       93,   93,   12,   12,   12,  434,  435,  423,  435,   12,
+
+      406,   12,  436,  424,  425,  425,  437,  437,   93,   93,
+      426,  427,  427,  438,  438,  428,  429,  429,  439,  439,
+       12,   12,  430,  431,  431,  440,  440,   12,   12,   12,
+       12,  441,  404,  442,   93,   12,   93,   93,   93,   12,
+       93,   12,  434,  435,  435,  443,  443,  444,  406,   93,
+      445,  446,  436,  446,   93,   93,  447,   12,   12,  448,
+       12,   12,  441,  404,  449,  404,   93,  450,   12,   93,
+       93,   93,  451,   93,  404,  452,  404,  406,   93,  445,
+      446,  446,  453,  453,  404,   93,  454,  404,   12,  455,
+      456,  456,  404,   12,  449,  404,   93,  457,  404,   12,
+
+       93,   93,   93,  458,  404,  458,  458,   93,  452,  404,
+      406,   93,   93,  454,  404,   12,  459,  460,  455,  460,
+      456,   12,   93,  457,  404,   12,   93,  461,  462,  458,
+      404,  458,  458,   93,  406,   93,   93,   12,  459,  460,
+      460,  463,  463,  404,   93,   12,   93,  464,  404,  465,
+      404,  458,  458,   93,  406,   93,  404,   12,  466,  467,
+      468,  464,  404,  465,  404,  458,  458,   93,  404,  469,
+       12,  470,  404,  471,  404,  472,  404,  458,  404,   93,
+      404,  404,  473,  404,   12,  470,  404,  471,  404,  472,
+      404,  404,   93,  404,  404,  473,  404,  474,  404,  475,
+
+      404,  475,  404,    0,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404
     } ;
 
-static const flex_int16_t yy_nxt[975] =
+static const flex_int16_t yy_nxt[1050] =
     {   0,
-        6,    7,    8,    9,    6,    6,    6,    6,   10,   11,
-       12,   13,   14,   15,   16,   17,   18,   19,   17,   17,
-       17,   17,   20,   17,   21,   22,   23,   24,   25,   17,
-       26,   17,   17,   17,   32,   32,   33,   32,   32,   33,
-       36,   34,   36,   42,   34,   29,   29,   29,   30,   35,
-       50,   36,   37,   38,   43,   44,   39,   36,   80,   45,
-       36,   36,   40,   29,   29,   29,   30,   35,   46,   48,
-       37,   38,   41,   47,   36,   49,   36,   53,   36,   36,
-       36,   56,   58,   36,   36,   55,   83,   61,   51,   36,
-       54,   62,   52,   29,   65,   59,   32,   32,   33,   66,
-
-       36,   36,   71,   34,   29,   29,   29,   30,   36,   36,
-       77,   29,   38,   67,   67,   67,   68,   67,   75,   72,
-       67,   69,   73,   36,   36,   74,   78,   79,   36,   53,
-       36,   36,   36,   87,   36,   76,   84,   36,   36,   85,
-       36,   81,   36,   86,   36,   36,   36,   36,   82,   36,
-       92,   95,   36,  100,   36,   36,   89,   90,   88,   29,
-       65,   36,   91,  101,   36,   66,   90,   93,   36,   94,
-       29,   97,  102,   36,   36,  104,   98,   36,  103,   36,
-       36,  107,  108,  106,   36,   36,   36,  105,   86,   36,
-      109,  110,  111,   36,   36,  114,  112,   36,  117,  119,
-
-       36,   36,   36,   36,   36,  121,   36,  368,   36,   36,
-      120,  113,   29,   29,   29,   30,  118,   36,  134,   29,
-       38,   36,  127,  115,  116,  122,  123,  125,   36,  126,
-      128,  124,   29,   97,   36,   36,  180,  138,   98,  129,
-      129,   67,  130,  129,   36,   36,  129,  132,  133,  135,
-      136,  140,   36,   36,   36,   36,  142,   36,  137,   35,
-       35,  123,   86,   36,  370,  143,  144,  144,   67,  145,
-      144,  148,  158,  144,  147,   35,   35,   90,  119,   36,
-       36,  149,  150,  150,   67,  151,  150,  159,   36,  150,
-      153,  154,  154,   67,  155,  154,  164,   36,  154,  157,
-
-      160,  160,   67,  161,  160,   36,  368,  160,  163,  165,
-      166,   36,   36,   29,  170,  167,  168,   29,  172,  171,
-       36,  175,   36,  173,   35,   35,  176,   36,   36,  177,
-       36,   36,  188,  174,   36,   29,  190,  178,   36,  181,
-       36,  191,  223,  179,  182,  182,   67,  183,  182,  186,
-      206,  182,  185,  187,   29,  192,   35,   35,   35,   35,
-      193,   29,  197,   29,  199,  194,   36,  198,   36,  200,
-       29,  202,   29,  204,  195,   36,  203,   36,  205,  268,
-      207,   29,  209,   29,  211,  214,  213,  210,  218,  212,
-      217,   36,  353,   36,   29,  170,   36,   35,   35,  219,
-
-      171,   35,   35,   35,   35,  224,   36,  231,   36,  225,
-       36,   29,  227,  221,   36,  222,  232,  228,  220,   29,
-      229,   36,  240,   35,   35,  230,  233,  233,   67,  234,
-      233,   29,  190,  233,  236,  237,  348,  191,  238,   35,
-       29,  197,   29,  202,  239,   36,  198,   36,  203,   29,
-      209,  242,   36,   35,  247,  210,  255,  241,  248,   36,
-       35,   35,   36,   35,   35,   35,   35,  253,   36,   35,
-       35,   29,  227,  250,  269,  254,   36,  228,  249,  251,
-      252,   35,  258,   29,  260,   29,  262,  264,   36,  261,
-      265,  263,   35,   35,  346,   35,   35,   70,  271,   35,
-
-       35,   35,   35,   35,   35,  274,   35,   35,  282,   35,
-       35,   36,  277,  278,   35,   35,  283,  284,   35,   35,
-      279,  285,   36,  280,  288,   29,  260,   35,   35,  289,
-      312,  261,  293,  293,   67,  294,  293,  301,  306,  293,
-      296,   35,   35,  298,  303,  306,  304,   35,   35,   35,
-       35,  309,  308,   36,  307,  282,  302,  319,   35,   35,
-       35,   35,   35,  311,   29,  314,   29,  316,   35,   35,
-      315,  282,  317,   35,   35,  344,  310,  364,  325,   35,
-       35,  318,   35,   35,  329,  320,   36,  328,  332,   36,
-       29,  314,   35,   35,  330,  326,  315,  331,  327,  333,
-
-       35,   35,   35,   35,  282,  282,  340,  341,   35,   35,
-       35,   35,   36,  282,   35,   35,   36,  351,   35,   35,
-      362,  339,  365,   36,  338,  366,  342,  361,  360,  354,
-      358,  349,  356,   35,   35,   27,   27,   27,   27,   29,
-       29,   29,   31,   31,   31,   31,   36,   36,   36,   36,
-       63,  353,   63,   63,   64,   64,   64,   64,   66,  350,
-       66,   66,   35,   35,   35,   35,   70,   70,  324,   70,
-       96,   96,   96,   96,   98,  322,   98,   98,  131,  131,
-      131,  131,  146,  146,  146,  146,  152,  152,  152,  152,
-      156,  156,  156,  156,  162,  162,  162,  162,  169,  169,
-
-      169,  169,  171,  348,  171,  171,  184,  184,  184,  184,
-      189,  189,  189,  189,  191,  346,  191,  191,  196,  196,
-      196,  196,  198,  344,  198,  198,  201,  201,  201,  201,
-      203,  337,  203,  203,  208,  208,  208,  208,  210,  335,
-      210,  210,  215,  215,  215,  215,  173,  282,  173,  173,
-      226,  226,  226,  226,  228,  324,  228,  228,  235,  235,
-      235,  235,  193,  322,  193,  193,  200,  276,  200,  200,
-      205,  267,  205,  205,  212,  257,  212,  212,  243,  243,
-      243,  243,  245,  245,  245,  245,  230,  306,  230,  230,
-      256,  256,  256,  256,  259,  259,  259,  259,  261,  300,
-
-      261,  261,  266,  266,  266,  266,  270,  270,  270,  270,
-      272,  272,  272,  272,  275,  275,  275,  275,  281,  281,
-      281,  281,  286,  286,  286,  286,  263,  246,  263,  263,
-      290,  290,  290,  290,  295,  295,  295,  295,  271,  297,
-      271,  271,  299,  299,  299,  299,  305,  305,  305,  305,
-      313,  313,  313,  313,  315,  292,  315,  315,  321,  321,
-      321,  321,  323,  323,  323,  323,  317,  291,  317,  317,
-      334,  334,  334,  334,  336,  336,  336,  336,  343,  343,
-      343,  343,  345,  345,  345,  345,  347,  347,  347,  347,
-      352,  352,  352,  352,  355,  355,  355,  355,  357,  357,
-
-      357,  357,  359,  359,  359,  359,  363,  363,  363,  363,
-      367,  367,  367,  367,  369,  369,  369,  369,  287,  276,
-      273,  216,  267,  257,  246,  244,  216,  141,  139,   99,
-       36,   30,   60,   57,   36,   30,  371,   28,   28,    5,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371
+        6,    7,    8,    9,    6,    6,    6,    6,    6,    6,
+       10,    6,   11,   12,   13,   14,   15,   16,   17,   18,
+       19,   20,   20,   20,   20,   21,   20,   22,   23,   24,
+       25,   26,   27,   28,   20,   20,   20,   34,   34,   35,
+       34,   34,   35,   38,   38,   38,   36,   44,   38,   36,
+       31,   31,   31,   32,   37,   38,   49,   38,   45,   39,
+       40,   31,   52,   50,   41,   53,   38,  102,   59,   51,
+       42,   31,   31,   31,   32,   37,   38,   38,   56,   38,
+       39,   40,   31,   43,   38,   38,   58,   61,   46,   63,
+       54,   57,   47,   38,   55,   38,   38,   31,   70,   66,
+
+       62,   48,   38,   67,   79,   71,   64,   78,   65,   34,
+       34,   35,   38,   38,   85,   38,   38,   56,   36,   31,
+       31,   31,   32,   81,   38,  401,   76,   38,   31,   40,
+       31,   72,   72,   72,   73,   72,   82,   38,   38,   38,
+       72,   74,   72,   77,   80,   38,   38,   38,   89,   86,
+       90,   38,   38,   91,   83,   84,   87,   38,   93,   38,
+       92,   38,   38,   38,   38,   38,   38,   98,   38,  103,
+      403,   94,   38,   95,   96,   96,  109,   99,   97,  100,
+       31,   70,   31,  105,  101,   38,   38,   38,   71,  108,
+      106,  110,   38,   38,   38,   38,  111,   38,   38,  115,
+
+      116,  112,   38,   38,   38,   92,  113,  117,   38,  118,
+       38,  120,  114,   38,   38,  123,  126,  119,   38,   38,
+      128,   38,  121,   38,   38,   38,  130,   38,   38,  129,
+      222,  122,   31,   31,   31,   32,  127,   38,   38,   38,
+       38,   31,   40,   31,  134,  135,  124,  125,  131,  137,
+      132,   31,  105,   38,  136,   38,  133,  138,   38,  106,
+       38,  139,  140,  140,   72,  141,  140,  145,  146,  147,
+       38,  140,  143,  140,  144,   38,   38,   38,  149,  153,
+      151,   38,  148,   38,   38,  154,   38,   37,   37,   37,
+       37,  331,   92,  161,  171,  155,  156,  156,   72,  157,
+
+      156,  160,  180,  332,   38,  156,  159,  156,  162,  162,
+       72,  163,  162,   38,   38,   38,   38,  162,  165,  162,
+       96,  132,  128,  176,   38,   38,  166,  166,   72,  167,
+      166,  170,  178,   38,  179,  166,  169,  166,  172,  172,
+       72,  173,  172,  234,   38,   38,   38,  172,  175,  172,
+      177,  181,   38,   31,  184,   38,  182,   31,  186,  193,
+      189,  185,   37,   37,  190,  187,   38,  191,  188,   38,
+       38,  201,   38,   38,   38,  192,  203,  401,   38,   38,
+       37,   37,  230,  256,   37,  194,  202,  195,  196,  196,
+       72,  197,  196,  200,   31,  205,  210,  196,  199,  196,
+
+       31,  207,  206,   37,   37,   31,  212,   38,  208,   31,
+      214,   38,  209,  213,   31,  217,   38,  215,   31,  219,
+       31,  224,  218,   31,  226,  228,  220,   38,  225,  235,
+      221,  227,   31,  184,   38,  229,   38,   38,  240,  236,
+      185,   37,   37,   37,   37,  231,   37,   37,  241,   38,
+       32,  384,  242,   31,  244,  238,   38,  275,  239,   31,
+      246,  245,  237,  248,  250,   38,   38,  247,   31,  205,
+       31,  212,   38,   37,   37,  257,  206,   38,  213,  249,
+      251,  251,   72,  252,  251,  255,   31,  217,   38,  251,
+      254,  251,   31,  224,  218,   38,  258,  260,   38,   38,
+
+      225,  261,   38,   37,  267,  259,  268,   32,   38,   37,
+       37,  377,   37,   37,   37,   37,  273,  293,   38,   37,
+       37,  262,  270,   31,  244,  274,   38,  269,  271,  272,
+      285,  245,   37,  279,  278,   31,  281,   31,  283,   75,
+      292,   37,   37,  282,  286,  284,   37,   37,   38,  290,
+      289,   38,   38,   37,   37,  294,   38,   37,   37,  297,
+       37,   37,   37,   37,  305,   32,   37,   37,  375,  301,
+       37,   37,   37,   37,  311,  306,  307,  302,  308,  303,
+      300,   37,   37,   31,  281,  313,   38,  312,  323,  322,
+       38,  282,  317,  317,   72,  318,  317,   37,   37,  331,
+
+       32,  317,  320,  317,  328,  326,  329,  334,   37,   37,
+       37,   37,  327,   37,   37,  335,  333,   37,   37,   37,
+      337,   38,   31,  340,   31,  342,  344,   38,  305,  336,
+      341,  346,  343,   37,   37,   38,   37,   37,  305,   32,
+      338,  345,   37,   37,  360,  357,   38,   37,   37,  305,
+      373,   38,  355,  347,  352,  356,   37,   37,  354,  358,
+       31,  340,  359,  305,   32,  353,   37,   37,  341,  361,
+       38,  369,  366,   37,   37,  368,  370,   37,   37,  305,
+       37,   37,  367,   38,  371,   37,   37,  399,  380,  381,
+      382,   37,   37,  393,  397,  398,  385,   38,   37,   37,
+
+      378,   29,   29,   29,   29,   31,   31,   31,   33,   33,
+       33,   33,   38,   38,   38,   38,   68,  395,   68,   68,
+       69,   69,   69,   69,   71,  394,   71,   71,   37,   37,
+       37,   37,   75,   75,  392,   75,  104,  104,  104,  104,
+      106,  391,  106,  106,  142,  142,  142,  142,  158,  158,
+      158,  158,  164,  164,  164,  164,  168,  168,  168,  168,
+      174,  174,  174,  174,  183,  183,  183,  183,  185,  389,
+      185,  185,  198,  198,  198,  198,  204,  204,  204,  204,
+      206,  387,  206,  206,  211,  211,  211,  211,  213,  384,
+      213,  213,  216,  216,  216,  216,  218,  379,  218,  218,
+
+      223,  223,  223,  223,  225,  351,  225,  225,  232,  232,
+      232,  232,  187,  349,  187,  187,  243,  243,  243,  243,
+      245,  377,  245,  245,  253,  253,  253,  253,  208,  375,
+      208,  208,  215,  373,  215,  215,  220,  365,  220,  220,
+      227,  363,  227,  227,  263,  263,  263,  263,  265,  265,
+      265,  265,  247,  305,  247,  247,  276,  276,  276,  276,
+      280,  280,  280,  280,  282,  351,  282,  282,  287,  287,
+      287,  287,  291,  291,  291,  291,  295,  295,  295,  295,
+      298,  298,  298,  298,  304,  304,  304,  304,  309,  309,
+      309,  309,  284,  349,  284,  284,  314,  314,  314,  314,
+
+      319,  319,  319,  319,  292,  299,  292,  292,  324,  324,
+      324,  324,  330,  330,  330,  330,  339,  339,  339,  339,
+      341,  288,  341,  341,  348,  348,  348,  348,  350,  350,
+      350,  350,  343,  277,  343,  343,  362,  362,  362,  362,
+      364,  364,  364,  364,  372,  372,  372,  372,  374,  374,
+      374,  374,  376,  376,  376,  376,  383,  383,  383,  383,
+      386,  386,  386,  386,  388,  388,  388,  388,  390,  390,
+      390,  390,  396,  396,  396,  396,  400,  400,  400,  400,
+      402,  402,  402,  402,  331,  325,  266,  321,  316,  315,
+      310,  299,  296,  233,  288,  277,  266,  264,  233,  152,
+
+      150,  107,   88,   38,   32,   60,   38,   32,  404,   30,
+       30,    5,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404
     } ;
 
-static const flex_int16_t yy_chk[975] =
+static const flex_int16_t yy_chk[1050] =
     {   0,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
-        1,    1,    1,    1,    7,    7,    7,    8,    8,    8,
-       13,    7,   18,   13,    8,   11,   11,   11,   11,   11,
-       18,   14,   11,   11,   13,   14,   11,   46,   46,   14,
-       15,   16,   11,   12,   12,   12,   12,   12,   14,   16,
-       12,   12,   12,   15,   19,   16,   20,   20,   21,   22,
-       24,   22,   24,   50,   26,   21,   50,   26,   19,   44,
-       20,   26,   19,   31,   31,   24,   32,   32,   32,   31,
-
-       39,   42,   39,   32,   35,   35,   35,   35,   40,   45,
-       44,   35,   35,   37,   37,   37,   37,   37,   42,   39,
-       37,   37,   40,   41,   43,   41,   45,   45,   47,   47,
-       48,   49,   51,   54,   55,   43,   51,   52,   54,   52,
-       53,   48,   56,   53,   57,   58,   59,   61,   49,   71,
-       59,   61,   60,   71,   62,   72,   56,   62,   55,   64,
-       64,   75,   58,   72,   77,   64,   57,   60,   74,   60,
-       67,   67,   73,   76,   73,   75,   67,   78,   74,   82,
-       79,   78,   79,   77,   84,   80,   81,   76,   80,   83,
-       81,   82,   83,   85,   89,   86,   84,   86,   88,   90,
-
-       88,   90,   91,   92,  100,   92,  104,  369,   95,  101,
-       91,   85,   87,   87,   87,   87,   89,  138,  104,   87,
-       87,   94,  100,   87,   87,   93,   93,   94,   93,   95,
-      101,   93,   96,   96,  106,  107,  138,  107,   96,  102,
-      102,  102,  102,  102,  103,  112,  102,  102,  103,  105,
-      105,  109,  111,  109,  113,  105,  111,  120,  106,  115,
-      115,  122,  113,  122,  367,  112,  114,  114,  114,  114,
-      114,  115,  120,  114,  114,  116,  116,  118,  118,  121,
-      118,  116,  117,  117,  117,  117,  117,  121,  124,  117,
-      117,  119,  119,  119,  119,  119,  124,  127,  119,  119,
-
-      123,  123,  123,  123,  123,  125,  365,  123,  123,  125,
-      126,  126,  128,  129,  129,  127,  128,  131,  131,  129,
-      133,  134,  139,  131,  136,  136,  136,  134,  137,  136,
-      141,  158,  143,  133,  143,  144,  144,  136,  179,  139,
-      142,  144,  179,  137,  140,  140,  140,  140,  140,  141,
-      158,  140,  140,  142,  146,  146,  148,  148,  149,  149,
-      146,  150,  150,  152,  152,  148,  165,  150,  164,  152,
-      154,  154,  156,  156,  149,  159,  154,  240,  156,  240,
-      159,  160,  160,  162,  162,  165,  164,  160,  168,  162,
-      167,  167,  363,  168,  169,  169,  174,  176,  176,  174,
-
-      169,  177,  177,  178,  178,  180,  181,  186,  186,  181,
-      180,  182,  182,  177,  207,  178,  187,  182,  176,  184,
-      184,  187,  207,  194,  194,  184,  188,  188,  188,  188,
-      188,  189,  189,  188,  188,  194,  359,  189,  195,  195,
-      196,  196,  201,  201,  206,  206,  196,  213,  201,  208,
-      208,  214,  214,  218,  218,  208,  225,  213,  219,  219,
-      220,  220,  225,  221,  221,  222,  222,  223,  223,  224,
-      224,  226,  226,  220,  241,  224,  241,  226,  219,  221,
-      222,  232,  232,  233,  233,  235,  235,  237,  249,  233,
-      238,  235,  238,  238,  357,  237,  237,  242,  242,  247,
-
-      247,  250,  250,  251,  251,  247,  252,  252,  253,  254,
-      254,  292,  249,  250,  265,  265,  253,  253,  258,  258,
-      251,  254,  277,  252,  258,  259,  259,  274,  274,  265,
-      292,  259,  269,  269,  269,  269,  269,  277,  284,  269,
-      269,  278,  278,  274,  279,  283,  280,  279,  279,  280,
-      280,  285,  284,  301,  283,  307,  278,  301,  285,  285,
-      288,  288,  289,  289,  293,  293,  295,  295,  302,  302,
-      293,  308,  295,  298,  298,  355,  288,  352,  307,  310,
-      310,  298,  309,  309,  311,  302,  312,  310,  319,  319,
-      313,  313,  311,  311,  312,  308,  313,  318,  309,  320,
-
-      318,  318,  320,  320,  325,  326,  327,  328,  327,  327,
-      328,  328,  330,  338,  340,  340,  342,  340,  351,  351,
-      351,  326,  354,  354,  325,  362,  330,  349,  347,  342,
-      345,  338,  343,  362,  362,  372,  372,  372,  372,  373,
-      373,  373,  374,  374,  374,  374,  375,  375,  375,  375,
-      376,  341,  376,  376,  377,  377,  377,  377,  378,  339,
-      378,  378,  379,  379,  379,  379,  380,  380,  336,  380,
-      381,  381,  381,  381,  382,  334,  382,  382,  383,  383,
-      383,  383,  384,  384,  384,  384,  385,  385,  385,  385,
-      386,  386,  386,  386,  387,  387,  387,  387,  388,  388,
-
-      388,  388,  389,  333,  389,  389,  390,  390,  390,  390,
-      391,  391,  391,  391,  392,  332,  392,  392,  393,  393,
-      393,  393,  394,  331,  394,  394,  395,  395,  395,  395,
-      396,  323,  396,  396,  397,  397,  397,  397,  398,  321,
-      398,  398,  399,  399,  399,  399,  400,  305,  400,  400,
-      401,  401,  401,  401,  402,  304,  402,  402,  403,  403,
-      403,  403,  404,  303,  404,  404,  405,  299,  405,  405,
-      406,  290,  406,  406,  407,  286,  407,  407,  408,  408,
-      408,  408,  409,  409,  409,  409,  410,  281,  410,  410,
-      411,  411,  411,  411,  412,  412,  412,  412,  413,  275,
-
-      413,  413,  414,  414,  414,  414,  415,  415,  415,  415,
-      416,  416,  416,  416,  417,  417,  417,  417,  418,  418,
-      418,  418,  419,  419,  419,  419,  420,  272,  420,  420,
-      421,  421,  421,  421,  422,  422,  422,  422,  423,  270,
-      423,  423,  424,  424,  424,  424,  425,  425,  425,  425,
-      426,  426,  426,  426,  427,  268,  427,  427,  428,  428,
-      428,  428,  429,  429,  429,  429,  430,  266,  430,  430,
-      431,  431,  431,  431,  432,  432,  432,  432,  433,  433,
-      433,  433,  434,  434,  434,  434,  435,  435,  435,  435,
-      436,  436,  436,  436,  437,  437,  437,  437,  438,  438,
-
-      438,  438,  439,  439,  439,  439,  440,  440,  440,  440,
-      441,  441,  441,  441,  442,  442,  442,  442,  256,  248,
-      245,  243,  239,  231,  217,  215,  166,  110,  108,   70,
-       36,   29,   25,   23,   17,    6,    5,    4,    3,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371,  371,  371,  371,  371,  371,  371,
-      371,  371,  371,  371
+        1,    1,    1,    1,    1,    1,    1,    7,    7,    7,
+        8,    8,    8,   15,   13,   17,    7,   13,   65,    8,
+       11,   11,   11,   11,   11,   16,   15,   18,   13,   11,
+       11,   11,   17,   16,   11,   18,   23,   65,   23,   16,
+       11,   12,   12,   12,   12,   12,   19,   21,   21,   22,
+       12,   12,   12,   12,   14,   25,   22,   25,   14,   26,
+       19,   21,   14,   42,   19,   27,   28,   33,   33,   28,
+
+       25,   14,   43,   28,   43,   33,   26,   42,   27,   34,
+       34,   34,   45,   48,   48,   46,   49,   49,   34,   37,
+       37,   37,   37,   45,   41,  402,   41,   44,   37,   37,
+       37,   39,   39,   39,   39,   39,   46,   47,   50,   51,
+       39,   39,   39,   41,   44,   53,   54,   58,   53,   50,
+       54,   55,   60,   55,   47,   47,   51,   56,   57,   59,
+       56,   61,   63,   62,   64,   66,   57,   62,   77,   66,
+      400,   58,   67,   59,   60,   67,   77,   63,   61,   63,
+       69,   69,   72,   72,   64,   76,   79,   80,   69,   76,
+       72,   78,   81,   82,   78,   83,   79,   87,   84,   83,
+
+       84,   80,   85,   86,   88,   85,   81,   86,   89,   87,
+       90,   89,   82,   91,   95,   92,   94,   88,   92,   94,
+       96,   97,   90,   96,   98,  171,   98,  101,  103,   97,
+      171,   91,   93,   93,   93,   93,   95,  102,  100,  108,
+      109,   93,   93,   93,  100,  101,   93,   93,   99,  103,
+       99,  104,  104,   99,  102,  112,   99,  108,  114,  104,
+      119,  109,  110,  110,  110,  110,  110,  112,  113,  113,
+      111,  110,  110,  110,  111,  121,  115,  113,  115,  119,
+      117,  120,  114,  117,  122,  120,  130,  125,  125,  124,
+      124,  306,  122,  125,  130,  121,  123,  123,  123,  123,
+
+      123,  124,  137,  306,  137,  123,  123,  123,  126,  126,
+      126,  126,  126,  135,  136,  133,  129,  126,  126,  126,
+      127,  131,  127,  133,  131,  127,  128,  128,  128,  128,
+      128,  129,  135,  138,  136,  128,  128,  128,  132,  132,
+      132,  132,  132,  181,  148,  181,  134,  132,  132,  132,
+      134,  138,  139,  140,  140,  144,  139,  142,  142,  148,
+      145,  140,  147,  147,  147,  142,  149,  147,  144,  145,
+      150,  153,  153,  154,  152,  147,  155,  398,  178,  155,
+      161,  161,  178,  210,  210,  149,  154,  150,  151,  151,
+      151,  151,  151,  152,  156,  156,  161,  151,  151,  151,
+
+      158,  158,  156,  160,  160,  162,  162,  176,  158,  164,
+      164,  170,  160,  162,  166,  166,  177,  164,  168,  168,
+      172,  172,  166,  174,  174,  176,  168,  179,  172,  182,
+      170,  174,  183,  183,  193,  177,  188,  182,  193,  188,
+      183,  190,  190,  191,  191,  179,  192,  192,  194,  195,
+      201,  396,  195,  196,  196,  191,  194,  242,  192,  198,
+      198,  196,  190,  200,  202,  200,  242,  198,  204,  204,
+      211,  211,  202,  209,  209,  221,  204,  221,  211,  201,
+      203,  203,  203,  203,  203,  209,  216,  216,  222,  203,
+      203,  203,  223,  223,  216,  228,  222,  229,  230,  229,
+
+      223,  230,  231,  235,  235,  228,  236,  249,  236,  237,
+      237,  390,  238,  238,  239,  239,  240,  261,  240,  241,
+      241,  231,  237,  243,  243,  241,  261,  236,  238,  239,
+      255,  243,  250,  250,  249,  251,  251,  253,  253,  260,
+      260,  255,  255,  251,  256,  253,  256,  256,  258,  259,
+      258,  262,  259,  267,  267,  262,  269,  270,  270,  267,
+      271,  271,  272,  272,  273,  278,  274,  274,  388,  270,
+      286,  286,  297,  297,  278,  273,  273,  271,  274,  272,
+      269,  279,  279,  280,  280,  286,  294,  279,  297,  294,
+      300,  280,  290,  290,  290,  290,  290,  301,  301,  307,
+
+      311,  290,  290,  290,  302,  300,  303,  308,  302,  302,
+      303,  303,  301,  312,  312,  311,  307,  308,  308,  313,
+      313,  316,  317,  317,  319,  319,  322,  326,  332,  312,
+      317,  326,  319,  323,  323,  322,  327,  327,  333,  335,
+      316,  323,  334,  334,  346,  337,  346,  336,  336,  352,
+      386,  338,  335,  327,  332,  336,  337,  337,  334,  338,
+      339,  339,  345,  353,  355,  333,  345,  345,  339,  347,
+      358,  355,  352,  347,  347,  354,  356,  354,  354,  366,
+      356,  356,  353,  371,  358,  368,  368,  393,  368,  369,
+      369,  380,  380,  380,  383,  385,  371,  385,  393,  393,
+
+      366,  405,  405,  405,  405,  406,  406,  406,  407,  407,
+      407,  407,  408,  408,  408,  408,  409,  382,  409,  409,
+      410,  410,  410,  410,  411,  381,  411,  411,  412,  412,
+      412,  412,  413,  413,  378,  413,  414,  414,  414,  414,
+      415,  376,  415,  415,  416,  416,  416,  416,  417,  417,
+      417,  417,  418,  418,  418,  418,  419,  419,  419,  419,
+      420,  420,  420,  420,  421,  421,  421,  421,  422,  374,
+      422,  422,  423,  423,  423,  423,  424,  424,  424,  424,
+      425,  372,  425,  425,  426,  426,  426,  426,  427,  370,
+      427,  427,  428,  428,  428,  428,  429,  367,  429,  429,
+
+      430,  430,  430,  430,  431,  364,  431,  431,  432,  432,
+      432,  432,  433,  362,  433,  433,  434,  434,  434,  434,
+      435,  361,  435,  435,  436,  436,  436,  436,  437,  360,
+      437,  437,  438,  359,  438,  438,  439,  350,  439,  439,
+      440,  348,  440,  440,  441,  441,  441,  441,  442,  442,
+      442,  442,  443,  330,  443,  443,  444,  444,  444,  444,
+      445,  445,  445,  445,  446,  329,  446,  446,  447,  447,
+      447,  447,  448,  448,  448,  448,  449,  449,  449,  449,
+      450,  450,  450,  450,  451,  451,  451,  451,  452,  452,
+      452,  452,  453,  328,  453,  453,  454,  454,  454,  454,
+
+      455,  455,  455,  455,  456,  324,  456,  456,  457,  457,
+      457,  457,  458,  458,  458,  458,  459,  459,  459,  459,
+      460,  314,  460,  460,  461,  461,  461,  461,  462,  462,
+      462,  462,  463,  309,  463,  463,  464,  464,  464,  464,
+      465,  465,  465,  465,  466,  466,  466,  466,  467,  467,
+      467,  467,  468,  468,  468,  468,  469,  469,  469,  469,
+      470,  470,  470,  470,  471,  471,  471,  471,  472,  472,
+      472,  472,  473,  473,  473,  473,  474,  474,  474,  474,
+      475,  475,  475,  475,  304,  298,  295,  291,  289,  287,
+      276,  268,  265,  263,  257,  248,  234,  232,  180,  118,
+
+      116,   75,   52,   38,   31,   24,   20,    6,    5,    4,
+        3,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404,  404,
+      404,  404,  404,  404,  404,  404,  404,  404,  404
     } ;
 
 #define YY_TRAILING_MASK 0x2000
@@ -1224,9 +1257,9 @@ static int vdev_and_devtype(DiskParseContext *dpc, char *str) {
 #undef DPC /* needs to be defined differently the actual lexer */
 #define DPC ((DiskParseContext*)yyextra)
 
-#line 1227 "libxlu_disk_l.c"
+#line 1260 "libxlu_disk_l.c"
 
-#line 1229 "libxlu_disk_l.c"
+#line 1262 "libxlu_disk_l.c"
 
 #define INITIAL 0
 #define LEXERR 1
@@ -1508,7 +1541,7 @@ YY_DECL
 #line 188 "libxlu_disk_l.l"
  /*----- the scanner rules which do the parsing -----*/
 
-#line 1511 "libxlu_disk_l.c"
+#line 1544 "libxlu_disk_l.c"
 
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
@@ -1540,14 +1573,14 @@ yy_match:
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 				{
 				yy_current_state = (int) yy_def[yy_current_state];
-				if ( yy_current_state >= 372 )
+				if ( yy_current_state >= 405 )
 					yy_c = yy_meta[yy_c];
 				}
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
 			*yyg->yy_state_ptr++ = yy_current_state;
 			++yy_cp;
 			}
-		while ( yy_current_state != 371 );
+		while ( yy_current_state != 404 );
 
 yy_find_action:
 		yy_current_state = *--yyg->yy_state_ptr;
@@ -1721,34 +1754,54 @@ YY_RULE_SETUP
 #line 219 "libxlu_disk_l.l"
 { STRIP(','); SAVESTRING("hidden-disk", hidden_disk, FROMEQUALS); }
 	YY_BREAK
-/* the target magic parameter, eats the rest of the string */
 case 23:
 YY_RULE_SETUP
-#line 223 "libxlu_disk_l.l"
+#line 221 "libxlu_disk_l.l"
+{ libxl_defbool_set(&DPC->disk->trusted, true); }
+	YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 222 "libxlu_disk_l.l"
+{ libxl_defbool_set(&DPC->disk->trusted, false); }
+	YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 224 "libxlu_disk_l.l"
+{ libxl_defbool_set(&DPC->disk->grant_usage, true); }
+	YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 225 "libxlu_disk_l.l"
+{ libxl_defbool_set(&DPC->disk->grant_usage, false); }
+	YY_BREAK
+/* the target magic parameter, eats the rest of the string */
+case 27:
+YY_RULE_SETUP
+#line 229 "libxlu_disk_l.l"
 { STRIP(','); SAVESTRING("target", pdev_path, FROMEQUALS); }
 	YY_BREAK
 /* unknown parameters */
-case 24:
-/* rule 24 can match eol */
+case 28:
+/* rule 28 can match eol */
 YY_RULE_SETUP
-#line 227 "libxlu_disk_l.l"
+#line 233 "libxlu_disk_l.l"
 { xlu__disk_err(DPC,yytext,"unknown parameter"); }
 	YY_BREAK
 /* deprecated prefixes */
 /* the "/.*" in these patterns ensures that they count as if they
    * matched the whole string, so these patterns take precedence */
-case 25:
+case 29:
 YY_RULE_SETUP
-#line 234 "libxlu_disk_l.l"
+#line 240 "libxlu_disk_l.l"
 {
                     STRIP(':');
                     DPC->had_depr_prefix=1; DEPRECATE("use `[format=]...,'");
                     setformat(DPC, yytext);
                  }
 	YY_BREAK
-case 26:
+case 30:
 YY_RULE_SETUP
-#line 240 "libxlu_disk_l.l"
+#line 246 "libxlu_disk_l.l"
 {
                     char *newscript;
                     STRIP(':');
@@ -1762,65 +1815,65 @@ YY_RULE_SETUP
                     free(newscript);
                 }
 	YY_BREAK
-case 27:
+case 31:
 *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
 yyg->yy_c_buf_p = yy_cp = yy_bp + 8;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 253 "libxlu_disk_l.l"
+#line 259 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
 	YY_BREAK
-case 28:
+case 32:
 YY_RULE_SETUP
-#line 254 "libxlu_disk_l.l"
+#line 260 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
 	YY_BREAK
-case 29:
+case 33:
 *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
 yyg->yy_c_buf_p = yy_cp = yy_bp + 4;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 255 "libxlu_disk_l.l"
+#line 261 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
 	YY_BREAK
-case 30:
+case 34:
 *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
 yyg->yy_c_buf_p = yy_cp = yy_bp + 6;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 256 "libxlu_disk_l.l"
+#line 262 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
 	YY_BREAK
-case 31:
+case 35:
 *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
 yyg->yy_c_buf_p = yy_cp = yy_bp + 5;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 257 "libxlu_disk_l.l"
+#line 263 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
 	YY_BREAK
-case 32:
+case 36:
 *yy_cp = yyg->yy_hold_char; /* undo effects of setting up yytext */
 yyg->yy_c_buf_p = yy_cp = yy_bp + 4;
 YY_DO_BEFORE_ACTION; /* set up yytext again */
 YY_RULE_SETUP
-#line 258 "libxlu_disk_l.l"
+#line 264 "libxlu_disk_l.l"
 { DPC->had_depr_prefix=1; DEPRECATE(0); }
 	YY_BREAK
-case 33:
-/* rule 33 can match eol */
+case 37:
+/* rule 37 can match eol */
 YY_RULE_SETUP
-#line 260 "libxlu_disk_l.l"
+#line 266 "libxlu_disk_l.l"
 {
 		  xlu__disk_err(DPC,yytext,"unknown deprecated disk prefix");
 		  return 0;
 		}
 	YY_BREAK
 /* positional parameters */
-case 34:
-/* rule 34 can match eol */
+case 38:
+/* rule 38 can match eol */
 YY_RULE_SETUP
-#line 267 "libxlu_disk_l.l"
+#line 273 "libxlu_disk_l.l"
 {
     STRIP(',');
 
@@ -1847,27 +1900,27 @@ YY_RULE_SETUP
     }
 }
 	YY_BREAK
-case 35:
+case 39:
 YY_RULE_SETUP
-#line 293 "libxlu_disk_l.l"
+#line 299 "libxlu_disk_l.l"
 {
     BEGIN(LEXERR);
     yymore();
 }
 	YY_BREAK
-case 36:
+case 40:
 YY_RULE_SETUP
-#line 297 "libxlu_disk_l.l"
+#line 303 "libxlu_disk_l.l"
 {
     xlu__disk_err(DPC,yytext,"bad disk syntax"); return 0;
 }
 	YY_BREAK
-case 37:
+case 41:
 YY_RULE_SETUP
-#line 300 "libxlu_disk_l.l"
+#line 306 "libxlu_disk_l.l"
 YY_FATAL_ERROR( "flex scanner jammed" );
 	YY_BREAK
-#line 1870 "libxlu_disk_l.c"
+#line 1923 "libxlu_disk_l.c"
 			case YY_STATE_EOF(INITIAL):
 			case YY_STATE_EOF(LEXERR):
 				yyterminate();
@@ -2135,7 +2188,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			{
 			yy_current_state = (int) yy_def[yy_current_state];
-			if ( yy_current_state >= 372 )
+			if ( yy_current_state >= 405 )
 				yy_c = yy_meta[yy_c];
 			}
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@@ -2159,11 +2212,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		{
 		yy_current_state = (int) yy_def[yy_current_state];
-		if ( yy_current_state >= 372 )
+		if ( yy_current_state >= 405 )
 			yy_c = yy_meta[yy_c];
 		}
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
-	yy_is_jam = (yy_current_state == 371);
+	yy_is_jam = (yy_current_state == 404);
 	if ( ! yy_is_jam )
 		*yyg->yy_state_ptr++ = yy_current_state;
 
@@ -2972,4 +3025,4 @@ void yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 300 "libxlu_disk_l.l"
+#line 306 "libxlu_disk_l.l"
diff --git a/tools/libs/util/libxlu_disk_l.h b/tools/libs/util/libxlu_disk_l.h
index 509aad67dc..c868422568 100644
--- a/tools/libs/util/libxlu_disk_l.h
+++ b/tools/libs/util/libxlu_disk_l.h
@@ -3,9 +3,12 @@
 #define xlu__disk_yyIN_HEADER 1
 
 #line 5 "libxlu_disk_l.h"
+#line 31 "libxlu_disk_l.l"
 #define _GNU_SOURCE
 
-#line 8 "libxlu_disk_l.h"
+
+
+#line 11 "libxlu_disk_l.h"
 
 #define  YY_INT_ALIGNED short int
 
@@ -694,8 +697,8 @@ extern int yylex (yyscan_t yyscanner);
 #undef yyTABLES_NAME
 #endif
 
-#line 300 "libxlu_disk_l.l"
+#line 306 "libxlu_disk_l.l"
 
-#line 699 "libxlu_disk_l.h"
+#line 702 "libxlu_disk_l.h"
 #undef xlu__disk_yyIN_HEADER
 #endif /* xlu__disk_yyHEADER_H */
diff --git a/tools/libs/util/libxlu_disk_l.l b/tools/libs/util/libxlu_disk_l.l
index 6d53c093a3..f37dd443bd 100644
--- a/tools/libs/util/libxlu_disk_l.l
+++ b/tools/libs/util/libxlu_disk_l.l
@@ -220,6 +220,9 @@ hidden-disk=[^,]*,?	{ STRIP(','); SAVESTRING("hidden-disk", hidden_disk, FROMEQU
 trusted,?		{ libxl_defbool_set(&DPC->disk->trusted, true); }
 untrusted,?		{ libxl_defbool_set(&DPC->disk->trusted, false); }
 
+grant_usage=1,?		{ libxl_defbool_set(&DPC->disk->grant_usage, true); }
+grant_usage=0,?		{ libxl_defbool_set(&DPC->disk->grant_usage, false); }
+
  /* the target magic parameter, eats the rest of the string */
 
 target=.*	{ STRIP(','); SAVESTRING("target", pdev_path, FROMEQUALS); }
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 20 05:33:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 20 Feb 2024 05:33:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.683170.1062543 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcIl3-00053p-8j; Tue, 20 Feb 2024 05:33:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 683170.1062543; Tue, 20 Feb 2024 05:33:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcIl3-00053h-6D; Tue, 20 Feb 2024 05:33:33 +0000
Received: by outflank-mailman (input) for mailman id 683170;
 Tue, 20 Feb 2024 05:33:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcIl2-00053U-9P
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 05:33:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcIl2-0000wz-8Z
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 05:33:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcIl2-0002M2-5s
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 05:33:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=bIMWvciGRon6cmP3vyjx0nb+Y7KIA89ucfEX28fgaRc=; b=ViAki+sk2s8LW6TwKV8sNSqTUi
	lDJzUeseCtQBpYdvcRfXcsZgEgeG7RU4Q/lnZJfU66etbcDQzxhSxr64TuugVLOwJE7cMH8OLkuv+
	kJh3iP/Bn65z4BbIZsRBG7GmGkq6MrqoBXC76MoRU0V7vH08xcN3GN2M/FqOcZytbjws=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86: Reduce assembly code size of entry points
Message-Id: <E1rcIl2-0002M2-5s@xenbits.xenproject.org>
Date: Tue, 20 Feb 2024 05:33:32 +0000

commit c144b9e32427ba37e0e0443a0d3fa53e9fb878b6
Author:     Frediano Ziglio <frediano.ziglio@cloud.com>
AuthorDate: Mon Feb 19 12:46:21 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 19 12:46:21 2024 +0100

    x86: Reduce assembly code size of entry points
    
    On many entries we push 8-bytes zero and exception constants are
    small so we can just write a single byte saving 3 bytes for
    instruction.
    With ENDBR64 this reduces the size of many entry points from 32 to
    16 bytes (due to alignment).
    The push and the mov are overlapping stores either way.  Swapping
    between movl and movb will make no difference at all on performance.
    Similar code is already used in autogen_stubs.
    
    Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/x86_64/entry.S | 66 +++++++++++++++++++++++++++------------------
 1 file changed, 40 insertions(+), 26 deletions(-)

diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index ecdd6e5b47..a7bd8f0ca5 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -22,6 +22,14 @@
 #endif
 .endm
 
+.macro BUILD_BUG_ON condstr cond:vararg
+        .if \cond
+        .error "Condition \"\condstr\" not satisfied"
+        .endif
+.endm
+/* preprocessor macro to make error message more user friendly */
+#define BUILD_BUG_ON(cond) BUILD_BUG_ON #cond cond
+
 #ifdef CONFIG_PV
 /* %rbx: struct vcpu */
 FUNC_LOCAL(switch_to_kernel)
@@ -187,7 +195,8 @@ FUNC_LOCAL(restore_all_guest)
         SPEC_CTRL_EXIT_TO_PV    /* Req: a=spec_ctrl %rsp=regs/cpuinfo, Clob: cd */
 
         RESTORE_ALL
-        testw $TRAP_syscall,4(%rsp)
+        BUILD_BUG_ON(TRAP_syscall & 0xff)
+        testb $TRAP_syscall >> 8, 4+1(%rsp)
         jz    iret_exit_to_guest
 
         movq  24(%rsp),%r11           # RFLAGS
@@ -254,7 +263,8 @@ FUNC(lstar_enter)
         pushq $FLAT_KERNEL_CS64
         pushq %rcx
         pushq $0
-        movl  $TRAP_syscall, 4(%rsp)
+        BUILD_BUG_ON(TRAP_syscall & 0xff)
+        movb  $TRAP_syscall >> 8, 4+1(%rsp)
         SAVE_ALL
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
@@ -292,7 +302,8 @@ FUNC(cstar_enter)
         pushq $FLAT_USER_CS32
         pushq %rcx
         pushq $0
-        movl  $TRAP_syscall, 4(%rsp)
+        BUILD_BUG_ON(TRAP_syscall & 0xff)
+        movb  $TRAP_syscall >> 8, 4+1(%rsp)
         SAVE_ALL
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
@@ -334,7 +345,8 @@ LABEL(sysenter_eflags_saved, 0)
         pushq $3 /* ring 3 null cs */
         pushq $0 /* null rip */
         pushq $0
-        movl  $TRAP_syscall, 4(%rsp)
+        BUILD_BUG_ON(TRAP_syscall & 0xff)
+        movb  $TRAP_syscall >> 8, 4+1(%rsp)
         SAVE_ALL
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
@@ -389,7 +401,7 @@ FUNC(entry_int80)
         ENDBR64
         ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
         pushq $0
-        movl  $0x80, 4(%rsp)
+        movb  $0x80, 4(%rsp)
         SAVE_ALL
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
@@ -561,7 +573,8 @@ __UNLIKELY_END(create_bounce_frame_bad_sp)
         /* Rewrite our stack frame and return to guest-OS mode. */
         /* IA32 Ref. Vol. 3: TF, VM, RF and NT flags are cleared on trap. */
         /* Also clear AC: alignment checks shouldn't trigger in kernel mode. */
-        orl   $TRAP_syscall,UREGS_entry_vector+8(%rsp)
+        BUILD_BUG_ON(TRAP_syscall & 0xff)
+        orb   $TRAP_syscall >> 8, UREGS_entry_vector+8+1(%rsp)
         andl  $~(X86_EFLAGS_AC|X86_EFLAGS_VM|X86_EFLAGS_RF|\
                  X86_EFLAGS_NT|X86_EFLAGS_TF),UREGS_eflags+8(%rsp)
         movq  $FLAT_KERNEL_SS,UREGS_ss+8(%rsp)
@@ -653,7 +666,7 @@ END(ret_from_intr)
         .section .init.text, "ax", @progbits
 FUNC(early_page_fault)
         ENDBR64
-        movl  $X86_EXC_PF, 4(%rsp)
+        movb  $X86_EXC_PF, 4(%rsp)
         SAVE_ALL
         movq  %rsp, %rdi
         call  do_early_page_fault
@@ -722,7 +735,7 @@ END(common_interrupt)
 
 FUNC(entry_PF)
         ENDBR64
-        movl  $X86_EXC_PF, 4(%rsp)
+        movb  $X86_EXC_PF, 4(%rsp)
 END(entry_PF)
 /* No special register assumptions. */
 FUNC(handle_exception, 0)
@@ -898,105 +911,106 @@ END(handle_exception)
 FUNC(entry_DE)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_DE, 4(%rsp)
+        /* no need to update exception type, already 0 */
+        BUILD_BUG_ON(X86_EXC_DE)
         jmp   handle_exception
 END(entry_DE)
 
 FUNC(entry_MF)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_MF, 4(%rsp)
+        movb  $X86_EXC_MF, 4(%rsp)
         jmp   handle_exception
 END(entry_MF)
 
 FUNC(entry_XM)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_XM, 4(%rsp)
+        movb  $X86_EXC_XM, 4(%rsp)
         jmp   handle_exception
 END(entry_XM)
 
 FUNC(entry_NM)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_NM, 4(%rsp)
+        movb  $X86_EXC_NM, 4(%rsp)
         jmp   handle_exception
 END(entry_NM)
 
 FUNC(entry_DB)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_DB, 4(%rsp)
+        movb  $X86_EXC_DB, 4(%rsp)
         jmp   handle_ist_exception
 END(entry_DB)
 
 FUNC(entry_BP)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_BP, 4(%rsp)
+        movb  $X86_EXC_BP, 4(%rsp)
         jmp   handle_exception
 END(entry_BP)
 
 FUNC(entry_OF)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_OF, 4(%rsp)
+        movb  $X86_EXC_OF, 4(%rsp)
         jmp   handle_exception
 END(entry_OF)
 
 FUNC(entry_BR)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_BR, 4(%rsp)
+        movb  $X86_EXC_BR, 4(%rsp)
         jmp   handle_exception
 END(entry_BR)
 
 FUNC(entry_UD)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_UD, 4(%rsp)
+        movb  $X86_EXC_UD, 4(%rsp)
         jmp   handle_exception
 END(entry_UD)
 
 FUNC(entry_TS)
         ENDBR64
-        movl  $X86_EXC_TS, 4(%rsp)
+        movb  $X86_EXC_TS, 4(%rsp)
         jmp   handle_exception
 END(entry_TS)
 
 FUNC(entry_NP)
         ENDBR64
-        movl  $X86_EXC_NP, 4(%rsp)
+        movb  $X86_EXC_NP, 4(%rsp)
         jmp   handle_exception
 END(entry_NP)
 
 FUNC(entry_SS)
         ENDBR64
-        movl  $X86_EXC_SS, 4(%rsp)
+        movb  $X86_EXC_SS, 4(%rsp)
         jmp   handle_exception
 END(entry_SS)
 
 FUNC(entry_GP)
         ENDBR64
-        movl  $X86_EXC_GP, 4(%rsp)
+        movb  $X86_EXC_GP, 4(%rsp)
         jmp   handle_exception
 END(entry_GP)
 
 FUNC(entry_AC)
         ENDBR64
-        movl  $X86_EXC_AC, 4(%rsp)
+        movb  $X86_EXC_AC, 4(%rsp)
         jmp   handle_exception
 END(entry_AC)
 
 FUNC(entry_CP)
         ENDBR64
-        movl  $X86_EXC_CP, 4(%rsp)
+        movb  $X86_EXC_CP, 4(%rsp)
         jmp   handle_exception
 END(entry_CP)
 
 FUNC(entry_DF)
         ENDBR64
-        movl  $X86_EXC_DF, 4(%rsp)
+        movb  $X86_EXC_DF, 4(%rsp)
         /* Set AC to reduce chance of further SMAP faults */
         ALTERNATIVE "", stac, X86_FEATURE_XEN_SMAP
         SAVE_ALL
@@ -1022,7 +1036,7 @@ END(entry_DF)
 FUNC(entry_NMI)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_NMI, 4(%rsp)
+        movb  $X86_EXC_NMI, 4(%rsp)
 END(entry_NMI)
 
 FUNC(handle_ist_exception)
@@ -1158,7 +1172,7 @@ END(handle_ist_exception)
 FUNC(entry_MC)
         ENDBR64
         pushq $0
-        movl  $X86_EXC_MC, 4(%rsp)
+        movb  $X86_EXC_MC, 4(%rsp)
         jmp   handle_ist_exception
 END(entry_MC)
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 20 11:33:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 20 Feb 2024 11:33:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.683437.1062946 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcOMz-0000XR-1T; Tue, 20 Feb 2024 11:33:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 683437.1062946; Tue, 20 Feb 2024 11:33:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcOMy-0000XK-VH; Tue, 20 Feb 2024 11:33:04 +0000
Received: by outflank-mailman (input) for mailman id 683437;
 Tue, 20 Feb 2024 11:33:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcOMy-0000XE-4N
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 11:33:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcOMx-0000ge-W6
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 11:33:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcOMx-0001Pi-UK
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 11:33:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=WM99domzZMW50Tn+5hwJ0+cguJiDC1q7gM2zH2riReY=; b=1c5SzSY3t+qUamkKQsflHqbVHu
	zMj9FF1DPYBNXvmv+I3etKmvCrUUDMNDvKNMsuGXjcD/9wE1jG1Xz5aqBMWTp3TrOCpy5MlCAAqXT
	/kFWOmh8w9scFf3XjWBydF5rXRHgNaoqGM4FO9+M6HxICxWMekWC52TLQqrU9gGYZcdE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/asm-generic: introduce generic device.h
Message-Id: <E1rcOMx-0001Pi-UK@xenbits.xenproject.org>
Date: Tue, 20 Feb 2024 11:33:03 +0000

commit c2263735f57645a506608df0fc31509debd92ca8
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Tue Feb 20 12:21:38 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 20 12:21:38 2024 +0100

    xen/asm-generic: introduce generic device.h
    
    Arm, PPC and RISC-V introduce the same things in asm/device.h, so
    generic device.h was introduced.
    Arm's device.h was taken as a base with the following changes:
     - #ifdef ACPI related things.
     - Rename #ifdef guards.
     - Add SPDX tag.
     - #ifdef CONFIG_HAS_DEVICE_TREE related things.
     - #ifdef-ing iommu related things with CONFIG_HAS_PASSTHROUGH.
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/include/asm-generic/device.h | 145 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 145 insertions(+)

diff --git a/xen/include/asm-generic/device.h b/xen/include/asm-generic/device.h
new file mode 100644
index 0000000000..f91bb7f771
--- /dev/null
+++ b/xen/include/asm-generic/device.h
@@ -0,0 +1,145 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_DEVICE_H__
+#define __ASM_GENERIC_DEVICE_H__
+
+#include <xen/stdbool.h>
+
+enum device_type
+{
+#ifdef CONFIG_HAS_DEVICE_TREE
+    DEV_DT,
+#endif
+    DEV_PCI
+};
+
+enum device_class
+{
+    DEVICE_SERIAL,
+    DEVICE_IOMMU,
+    DEVICE_INTERRUPT_CONTROLLER,
+    DEVICE_PCI_HOSTBRIDGE,
+    /* Use for error */
+    DEVICE_UNKNOWN,
+};
+
+struct dev_archdata {
+#ifdef CONFIG_HAS_PASSTHROUGH
+    void *iommu;    /* IOMMU private data */
+#endif
+};
+
+/* struct device - The basic device structure */
+struct device
+{
+    enum device_type type;
+#ifdef CONFIG_HAS_DEVICE_TREE
+    struct dt_device_node *of_node; /* Used by drivers imported from Linux */
+#endif
+    struct dev_archdata archdata;
+#ifdef CONFIG_HAS_PASSTHROUGH
+    struct iommu_fwspec *iommu_fwspec; /* per-device IOMMU instance data */
+#endif
+};
+
+typedef struct device device_t;
+
+#ifdef CONFIG_HAS_DEVICE_TREE
+
+#include <xen/device_tree.h>
+
+#define dev_is_dt(dev)  ((dev)->type == DEV_DT)
+
+/**
+ *  device_init - Initialize a device
+ *  @dev: device to initialize
+ *  @class: class of the device (serial, network...)
+ *  @data: specific data for initializing the device
+ *
+ *  Return 0 on success.
+ */
+int device_init(struct dt_device_node *dev, enum device_class class,
+                const void *data);
+
+/**
+ * device_get_type - Get the type of the device
+ * @dev: device to match
+ *
+ * Return the device type on success or DEVICE_ANY on failure
+ */
+enum device_class device_get_class(const struct dt_device_node *dev);
+
+#define DT_DEVICE_START(dev_name, ident, cls)                   \
+static const struct device_desc __dev_desc_##dev_name __used    \
+__section(".dev.info") = {                                      \
+    .name = ident,                                              \
+    .class = cls,
+
+#define DT_DEVICE_END                                           \
+};
+
+struct device_desc {
+    /* Device name */
+    const char *name;
+    /* Device class */
+    enum device_class class;
+
+    /* List of devices supported by this driver */
+    const struct dt_device_match *dt_match;
+    /*
+     * Device initialization.
+     *
+     * -EAGAIN is used to indicate that device probing is deferred.
+     */
+    int (*init)(struct dt_device_node *dev, const void *data);
+};
+
+#else /* !CONFIG_HAS_DEVICE_TREE */
+#define dev_is_dt(dev) ((void)(dev), false)
+#endif /* CONFIG_HAS_DEVICE_TREE */
+
+#define dev_is_pci(dev) ((dev)->type == DEV_PCI)
+
+#ifdef CONFIG_ACPI
+
+struct acpi_device_desc {
+    /* Device name */
+    const char *name;
+    /* Device class */
+    enum device_class class;
+    /* type of device supported by the driver */
+    const int class_type;
+    /* Device initialization */
+    int (*init)(const void *data);
+};
+
+/**
+ *  acpi_device_init - Initialize a device
+ *  @class: class of the device (serial, network...)
+ *  @data: specific data for initializing the device
+ *
+ *  Return 0 on success.
+ */
+int acpi_device_init(enum device_class class,
+                     const void *data, int class_type);
+
+#define ACPI_DEVICE_START(dev_name, ident, cls)                     \
+static const struct acpi_device_desc __dev_desc_##dev_name __used   \
+__section(".adev.info") = {                                         \
+    .name = ident,                                                  \
+    .class = cls,
+
+#define ACPI_DEVICE_END                                             \
+};
+
+#endif /* CONFIG_ACPI */
+
+#endif /* __ASM_GENERIC_DEVICE_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 20 11:33:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 20 Feb 2024 11:33:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.683438.1062950 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcON9-0000ZP-37; Tue, 20 Feb 2024 11:33:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 683438.1062950; Tue, 20 Feb 2024 11:33:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcON9-0000ZJ-0Y; Tue, 20 Feb 2024 11:33:15 +0000
Received: by outflank-mailman (input) for mailman id 683438;
 Tue, 20 Feb 2024 11:33:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcON8-0000Z7-4b
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 11:33:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcON8-0000gn-3q
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 11:33:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcON8-0001RO-2A
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 11:33:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=5Zl/Fo0AqoqS+pex5HpVL0xunB98+s/yU67GIe07JnI=; b=NY6HJHS4MTASLw2sBSLRMMBQ4t
	G3+gwcbFZ+CJFq6oTxuaqzca6UyJHSB6MjkTyozWMg3feY6+h+D2HRGUjv9tfBNLfFfHYjCobMdJi
	UFoWAjODiA1iXYvnLxxovG3Cmnx/c35NEuajmyKOvgR/QcnL65/zxBvXhiadxDC+y72k=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/arm: switch Arm to use asm-generic/device.h
Message-Id: <E1rcON8-0001RO-2A@xenbits.xenproject.org>
Date: Tue, 20 Feb 2024 11:33:14 +0000

commit c0dd41e055229d5413e979853206ad4a4c8874ce
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Tue Feb 20 12:23:00 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 20 12:23:00 2024 +0100

    xen/arm: switch Arm to use asm-generic/device.h
    
    The following changes were done as a result of switching to
    asm-generic/device.h:
     * DEVICE_GIC was renamed to DEVICE_INTERRUPT_CONTROLLER according
       to definition of enum device_class in asm-generic/device.h.
     * acpi-related things in Arm code were guarded by #ifdef CONFIG_ACPI
       as struct acpi_device_desc was guarded in asm-generic, also functions
       acpi_device_init() was guarded too as they are using structure
       acpi_device_desc inside.
     * drop arm/include/asm/device.h and update arm/include/asm/Makefile
       to use asm-generic/device.h instead.
    
    As 'struct device_desc' is protected by CONFIG_HAS_DEVICE_TREE,
    _sdevice, _edevice, device_init(), and device_get_class should also be
    protected.
    However, this protection was not implemented because Arm always has
    CONFIG_HAS_DEVICE_TREE=y at the moment.
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/device.c             |   5 ++
 xen/arch/arm/domain_build.c       |   2 +-
 xen/arch/arm/gic-v2.c             |   4 +-
 xen/arch/arm/gic-v3.c             |   6 +-
 xen/arch/arm/gic.c                |   4 +-
 xen/arch/arm/include/asm/Makefile |   1 +
 xen/arch/arm/include/asm/device.h | 124 --------------------------------------
 xen/arch/arm/xen.lds.S            |   2 +
 8 files changed, 16 insertions(+), 132 deletions(-)

diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
index 1f631d3274..3e02cff008 100644
--- a/xen/arch/arm/device.c
+++ b/xen/arch/arm/device.c
@@ -16,7 +16,10 @@
 #include <xen/lib.h>
 
 extern const struct device_desc _sdevice[], _edevice[];
+
+#ifdef CONFIG_ACPI
 extern const struct acpi_device_desc _asdevice[], _aedevice[];
+#endif
 
 int __init device_init(struct dt_device_node *dev, enum device_class class,
                        const void *data)
@@ -45,6 +48,7 @@ int __init device_init(struct dt_device_node *dev, enum device_class class,
     return -EBADF;
 }
 
+#ifdef CONFIG_ACPI
 int __init acpi_device_init(enum device_class class, const void *data, int class_type)
 {
     const struct acpi_device_desc *desc;
@@ -61,6 +65,7 @@ int __init acpi_device_init(enum device_class class, const void *data, int class
 
     return -EBADF;
 }
+#endif
 
 enum device_class device_get_class(const struct dt_device_node *dev)
 {
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 46161848dc..085d88671e 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1651,7 +1651,7 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo,
      * Replace these nodes with our own. Note that the original may be
      * used_by DOMID_XEN so this check comes first.
      */
-    if ( device_get_class(node) == DEVICE_GIC )
+    if ( device_get_class(node) == DEVICE_INTERRUPT_CONTROLLER )
         return make_gic_node(d, kinfo->fdt, node);
     if ( dt_match_node(timer_matches, node) )
         return make_timer_node(kinfo);
diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index cf392bfd1c..5d6885e389 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -1366,7 +1366,7 @@ static const struct dt_device_match gicv2_dt_match[] __initconst =
     { /* sentinel */ },
 };
 
-DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC)
+DT_DEVICE_START(gicv2, "GICv2", DEVICE_INTERRUPT_CONTROLLER)
         .dt_match = gicv2_dt_match,
         .init = gicv2_dt_preinit,
 DT_DEVICE_END
@@ -1381,7 +1381,7 @@ static int __init gicv2_acpi_preinit(const void *data)
     return 0;
 }
 
-ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_GIC)
+ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_INTERRUPT_CONTROLLER)
         .class_type = ACPI_MADT_GIC_VERSION_V2,
         .init = gicv2_acpi_preinit,
 ACPI_DEVICE_END
diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index bf0e5c1b75..1cb1360606 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -1909,7 +1909,7 @@ static const struct dt_device_match gicv3_dt_match[] __initconst =
     { /* sentinel */ },
 };
 
-DT_DEVICE_START(gicv3, "GICv3", DEVICE_GIC)
+DT_DEVICE_START(gicv3, "GICv3", DEVICE_INTERRUPT_CONTROLLER)
         .dt_match = gicv3_dt_match,
         .init = gicv3_dt_preinit,
 DT_DEVICE_END
@@ -1924,12 +1924,12 @@ static int __init gicv3_acpi_preinit(const void *data)
     return 0;
 }
 
-ACPI_DEVICE_START(agicv3, "GICv3", DEVICE_GIC)
+ACPI_DEVICE_START(agicv3, "GICv3", DEVICE_INTERRUPT_CONTROLLER)
         .class_type = ACPI_MADT_GIC_VERSION_V3,
         .init = gicv3_acpi_preinit,
 ACPI_DEVICE_END
 
-ACPI_DEVICE_START(agicv4, "GICv4", DEVICE_GIC)
+ACPI_DEVICE_START(agicv4, "GICv4", DEVICE_INTERRUPT_CONTROLLER)
         .class_type = ACPI_MADT_GIC_VERSION_V4,
         .init = gicv3_acpi_preinit,
 ACPI_DEVICE_END
diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index d922ea67aa..b5a9c8266c 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -234,7 +234,7 @@ static void __init gic_dt_preinit(void)
         if ( !dt_get_parent(node) )
             continue;
 
-        rc = device_init(node, DEVICE_GIC, NULL);
+        rc = device_init(node, DEVICE_INTERRUPT_CONTROLLER, NULL);
         if ( !rc )
         {
             /* NOTE: Only one GIC is supported */
@@ -262,7 +262,7 @@ static void __init gic_acpi_preinit(void)
 
     dist = container_of(header, struct acpi_madt_generic_distributor, header);
 
-    if ( acpi_device_init(DEVICE_GIC, NULL, dist->version) )
+    if ( acpi_device_init(DEVICE_INTERRUPT_CONTROLLER, NULL, dist->version) )
         panic("Unable to find compatible GIC in the ACPI table\n");
 }
 #else
diff --git a/xen/arch/arm/include/asm/Makefile b/xen/arch/arm/include/asm/Makefile
index 505cb49090..4a4036c951 100644
--- a/xen/arch/arm/include/asm/Makefile
+++ b/xen/arch/arm/include/asm/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 generic-y += altp2m.h
+generic-y += device.h
 generic-y += hardirq.h
 generic-y += iocap.h
 generic-y += paging.h
diff --git a/xen/arch/arm/include/asm/device.h b/xen/arch/arm/include/asm/device.h
deleted file mode 100644
index b5d451e087..0000000000
--- a/xen/arch/arm/include/asm/device.h
+++ /dev/null
@@ -1,124 +0,0 @@
-#ifndef __ASM_ARM_DEVICE_H
-#define __ASM_ARM_DEVICE_H
-
-enum device_type
-{
-    DEV_DT,
-    DEV_PCI,
-};
-
-struct dev_archdata {
-    void *iommu;    /* IOMMU private data */
-};
-
-/* struct device - The basic device structure */
-struct device
-{
-    enum device_type type;
-#ifdef CONFIG_HAS_DEVICE_TREE
-    struct dt_device_node *of_node; /* Used by drivers imported from Linux */
-#endif
-    struct dev_archdata archdata;
-    struct iommu_fwspec *iommu_fwspec; /* per-device IOMMU instance data */
-};
-
-typedef struct device device_t;
-
-#include <xen/device_tree.h>
-
-#define dev_is_pci(dev) ((dev)->type == DEV_PCI)
-#define dev_is_dt(dev)  ((dev)->type == DEV_DT)
-
-enum device_class
-{
-    DEVICE_SERIAL,
-    DEVICE_IOMMU,
-    DEVICE_GIC,
-    DEVICE_PCI_HOSTBRIDGE,
-    /* Use for error */
-    DEVICE_UNKNOWN,
-};
-
-struct device_desc {
-    /* Device name */
-    const char *name;
-    /* Device class */
-    enum device_class class;
-    /* List of devices supported by this driver */
-    const struct dt_device_match *dt_match;
-    /*
-     * Device initialization.
-     *
-     * -EAGAIN is used to indicate that device probing is deferred.
-     */
-    int (*init)(struct dt_device_node *dev, const void *data);
-};
-
-struct acpi_device_desc {
-    /* Device name */
-    const char *name;
-    /* Device class */
-    enum device_class class;
-    /* type of device supported by the driver */
-    const int class_type;
-    /* Device initialization */
-    int (*init)(const void *data);
-};
-
-/**
- *  acpi_device_init - Initialize a device
- *  @class: class of the device (serial, network...)
- *  @data: specific data for initializing the device
- *
- *  Return 0 on success.
- */
-int acpi_device_init(enum device_class class,
-                     const void *data, int class_type);
-
-/**
- *  device_init - Initialize a device
- *  @dev: device to initialize
- *  @class: class of the device (serial, network...)
- *  @data: specific data for initializing the device
- *
- *  Return 0 on success.
- */
-int device_init(struct dt_device_node *dev, enum device_class class,
-                const void *data);
-
-/**
- * device_get_type - Get the type of the device
- * @dev: device to match
- *
- * Return the device type on success or DEVICE_ANY on failure
- */
-enum device_class device_get_class(const struct dt_device_node *dev);
-
-#define DT_DEVICE_START(_name, _namestr, _class)                    \
-static const struct device_desc __dev_desc_##_name __used           \
-__section(".dev.info") = {                                          \
-    .name = _namestr,                                               \
-    .class = _class,                                                \
-
-#define DT_DEVICE_END                                               \
-};
-
-#define ACPI_DEVICE_START(_name, _namestr, _class)                    \
-static const struct acpi_device_desc __dev_desc_##_name __used           \
-__section(".adev.info") = {                       \
-    .name = _namestr,                                               \
-    .class = _class,                                                \
-
-#define ACPI_DEVICE_END                                               \
-};
-
-#endif /* __ASM_ARM_DEVICE_H */
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index 470c8f2208..2266c9536f 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -138,12 +138,14 @@ SECTIONS
       _edevice = .;
   } :text
 
+#ifdef CONFIG_ACPI
   . = ALIGN(8);
   .adev.info : {
       _asdevice = .;
       *(.adev.info)
       _aedevice = .;
   } :text
+#endif
 
   . = ALIGN(8);
   .teemediator.info : {
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 20 11:33:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 20 Feb 2024 11:33:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.683439.1062955 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcONJ-0000dT-4c; Tue, 20 Feb 2024 11:33:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 683439.1062955; Tue, 20 Feb 2024 11:33:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcONJ-0000dL-24; Tue, 20 Feb 2024 11:33:25 +0000
Received: by outflank-mailman (input) for mailman id 683439;
 Tue, 20 Feb 2024 11:33:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcONI-0000dD-7W
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 11:33:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcONI-0000hI-6n
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 11:33:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcONI-0001ZF-5y
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 11:33:24 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=tFu9V7P1KRT30V0cbmfTVs7A/HfbW0x2v3MLlOWzoD8=; b=DfJHfp/kx+CI/2GxZfjUVN+YC4
	JeQO+PmsCL/VCIYLAGkfU+KTUcnUGw4DdXJcTTGV30eEMiqVfSQQDVrxmmBccXgrpg3Ia+VywhQGv
	kTpCQvWHAxG7+dthIywjJf1f+A5Y/xWpOh+6xzvFDGE3SBW7NLBlx+jMtz7t2+mwwkeI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/asm-generic: fold struct devarch into struct dev
Message-Id: <E1rcONI-0001ZF-5y@xenbits.xenproject.org>
Date: Tue, 20 Feb 2024 11:33:24 +0000

commit 981f722efa876e3f1766629f444d10e8806adc93
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Tue Feb 20 12:23:50 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 20 12:23:50 2024 +0100

    xen/asm-generic: fold struct devarch into struct dev
    
    The 'struct dev_archdata' is exclusively used within 'struct device',
    so it could be merged into 'struct device.'
    
    After the merger, it is necessary to update the 'dev_archdata()'
    macros and the comments above 'struct arm_smmu_xen_device' in
    drivers/passthrough/arm/smmu.c.
    Additionally, it is required to update instances of
    "dev->archdata->iommu" to "dev->iommu".
    
    Suggested-by: Julien Grall <julien@xen.org>
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/drivers/passthrough/arm/smmu.c | 12 ++++++------
 xen/include/asm-generic/device.h   |  8 +-------
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c
index 32e2ff279b..4a272c8779 100644
--- a/xen/drivers/passthrough/arm/smmu.c
+++ b/xen/drivers/passthrough/arm/smmu.c
@@ -227,9 +227,9 @@ struct arm_smmu_xen_domain {
 };
 
 /*
- * Xen: Information about each device stored in dev->archdata.iommu
+ * Xen: Information about each device stored in dev->iommu
  *
- * Initially dev->archdata.iommu only stores the iommu_domain (runtime
+ * Initially dev->iommu only stores the iommu_domain (runtime
  * configuration of the SMMU) but, on Xen, we also have to store the
  * iommu_group (list of streamIDs associated to the device).
  *
@@ -242,7 +242,7 @@ struct arm_smmu_xen_device {
 	struct iommu_group *group;
 };
 
-#define dev_archdata(dev) ((struct arm_smmu_xen_device *)dev->archdata.iommu)
+#define dev_archdata(dev) ((struct arm_smmu_xen_device *)dev->iommu)
 #define dev_iommu_domain(dev) (dev_archdata(dev)->domain)
 #define dev_iommu_group(dev) (dev_archdata(dev)->group)
 
@@ -2777,9 +2777,9 @@ static int arm_smmu_assign_dev(struct domain *d, u8 devfn,
 
 	xen_domain = dom_iommu(d)->arch.priv;
 
-	if (!dev->archdata.iommu) {
-		dev->archdata.iommu = xzalloc(struct arm_smmu_xen_device);
-		if (!dev->archdata.iommu)
+	if (!dev->iommu) {
+		dev->iommu = xzalloc(struct arm_smmu_xen_device);
+		if (!dev->iommu)
 			return -ENOMEM;
 	}
 
diff --git a/xen/include/asm-generic/device.h b/xen/include/asm-generic/device.h
index f91bb7f771..1acd1ba1d8 100644
--- a/xen/include/asm-generic/device.h
+++ b/xen/include/asm-generic/device.h
@@ -22,12 +22,6 @@ enum device_class
     DEVICE_UNKNOWN,
 };
 
-struct dev_archdata {
-#ifdef CONFIG_HAS_PASSTHROUGH
-    void *iommu;    /* IOMMU private data */
-#endif
-};
-
 /* struct device - The basic device structure */
 struct device
 {
@@ -35,8 +29,8 @@ struct device
 #ifdef CONFIG_HAS_DEVICE_TREE
     struct dt_device_node *of_node; /* Used by drivers imported from Linux */
 #endif
-    struct dev_archdata archdata;
 #ifdef CONFIG_HAS_PASSTHROUGH
+    void *iommu; /* IOMMU private data */;
     struct iommu_fwspec *iommu_fwspec; /* per-device IOMMU instance data */
 #endif
 };
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 20 13:22:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 20 Feb 2024 13:22:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.683531.1063089 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcQ4U-0000YK-9A; Tue, 20 Feb 2024 13:22:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 683531.1063089; Tue, 20 Feb 2024 13:22:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcQ4U-0000YC-6Z; Tue, 20 Feb 2024 13:22:06 +0000
Received: by outflank-mailman (input) for mailman id 683531;
 Tue, 20 Feb 2024 13:22:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcQ4S-0000Y6-3T
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 13:22:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcQ4R-0002iw-Ap
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 13:22:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcQ4R-0001ne-9Y
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 13:22:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=xmCgBAACi68EJx1jXBpp+R6sX8MouFX50wTFTOGMmuY=; b=QQ6sqDMQfulgnXJZtEV3ijJuvb
	hDPefPqPr3gO1+C7gXwhPDjFGnvaATVsu2+Tj+cOJymjjtXoS0Mcow3+n+H8qNB/ZfL50846mORT2
	nJPQQ3B/rDcf/mA1IzNmx/bZ6UbHE0rj38v+zmiQyy2XVJxxD8IGandUr8E/zc8gpkHw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/arm: Make hwdom vUART optional feature
Message-Id: <E1rcQ4R-0001ne-9Y@xenbits.xenproject.org>
Date: Tue, 20 Feb 2024 13:22:03 +0000

commit f8791d0fd3adbda3701e7eb9db63a9351b478365
Author:     Michal Orzel <michal.orzel@amd.com>
AuthorDate: Thu Feb 15 15:39:47 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Tue Feb 20 13:20:31 2024 +0000

    xen/arm: Make hwdom vUART optional feature
    
    At the moment, the hardware domain vUART is always compiled in. In the
    spirit of fine granular configuration, make it optional so that the
    feature can be disabled if not needed. This UART is not exposed (e.g.
    via device tree) to a domain and is mostly used to support special use
    cases like Linux early printk, prints from the decompressor code, etc.
    
    Introduce Kconfig option CONFIG_HWDOM_VUART, enabled by default (to keep
    the current behavior) and use it to protect the vUART related code.
    Provide stubs for domain_vuart_{init,free}() in case the feature is
    disabled. Take the opportunity to add a struct domain forward declaration
    to vuart.h, so that the header is self contained.
    
    Signed-off-by: Michal Orzel <michal.orzel@amd.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
    Tested-by: Luca Fancellu <luca.fancellu@arm.com>
---
 xen/arch/arm/Kconfig              |  8 ++++++++
 xen/arch/arm/Makefile             |  2 +-
 xen/arch/arm/include/asm/domain.h |  2 ++
 xen/arch/arm/vuart.h              | 19 +++++++++++++++++++
 4 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index 50e9bfae1a..72af329564 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -150,6 +150,14 @@ config SBSA_VUART_CONSOLE
 	  Allows a guest to use SBSA Generic UART as a console. The
 	  SBSA Generic UART implements a subset of ARM PL011 UART.
 
+config HWDOM_VUART
+	bool "Emulated UART for hardware domain"
+	default y
+	help
+	  Allows a hardware domain to use a minimalistic UART (single transmit
+	  and status register) which takes information from dtuart. Note that this
+	  UART is not intended to be exposed (e.g. via device-tree) to a domain.
+
 config ARM_SSBD
 	bool "Speculative Store Bypass Disable" if EXPERT
 	depends on HAS_ALTERNATIVE
diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 33c677672f..7b1350e2ef 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -71,7 +71,7 @@ obj-y += vtimer.o
 obj-$(CONFIG_SBSA_VUART_CONSOLE) += vpl011.o
 obj-y += vsmc.o
 obj-y += vpsci.o
-obj-y += vuart.o
+obj-$(CONFIG_HWDOM_VUART) += vuart.o
 
 extra-y += xen.lds
 
diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/domain.h
index 5fb8cd79c0..8218afb862 100644
--- a/xen/arch/arm/include/asm/domain.h
+++ b/xen/arch/arm/include/asm/domain.h
@@ -91,6 +91,7 @@ struct arch_domain
 
     struct vgic_dist vgic;
 
+#ifdef CONFIG_HWDOM_VUART
     struct vuart {
 #define VUART_BUF_SIZE 128
         char                        *buf;
@@ -98,6 +99,7 @@ struct arch_domain
         const struct vuart_info     *info;
         spinlock_t                  lock;
     } vuart;
+#endif
 
     unsigned int evtchn_irq;
 #ifdef CONFIG_ACPI
diff --git a/xen/arch/arm/vuart.h b/xen/arch/arm/vuart.h
index bd23bd92f6..e90d84c6ed 100644
--- a/xen/arch/arm/vuart.h
+++ b/xen/arch/arm/vuart.h
@@ -20,9 +20,28 @@
 #ifndef __ARCH_ARM_VUART_H__
 #define __ARCH_ARM_VUART_H__
 
+struct domain;
+
+#ifdef CONFIG_HWDOM_VUART
+
 int domain_vuart_init(struct domain *d);
 void domain_vuart_free(struct domain *d);
 
+#else
+
+static inline int domain_vuart_init(struct domain *d)
+{
+    /*
+     * The vUART is unconditionally inialized for the hw domain. So we
+     * can't return an error.
+     */
+    return 0;
+}
+
+static inline void domain_vuart_free(struct domain *d) {};
+
+#endif /* CONFIG_HWDOM_VUART */
+
 #endif /* __ARCH_ARM_VUART_H__ */
 
 /*
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 20 23:22:09 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 20 Feb 2024 23:22:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.683749.1063329 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcZR6-0006qD-55; Tue, 20 Feb 2024 23:22:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 683749.1063329; Tue, 20 Feb 2024 23:22:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcZR6-0006q1-23; Tue, 20 Feb 2024 23:22:04 +0000
Received: by outflank-mailman (input) for mailman id 683749;
 Tue, 20 Feb 2024 23:22:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcZR4-0006pt-Fs
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 23:22:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcZR4-0004qZ-EH
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 23:22:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcZR4-0001Ly-D0
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 23:22:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=YWi7E464tYB0iwKWZVKfHJXddabHc3s2069apqQqz30=; b=yzLZzgiHWtUjwypz+mvESMdTqb
	betb1hBTzAqpGJadpaF2wB6Z04hJGBB5ogToMdEEwLVekQan6wShlStdK4Kmsua9G0D3kcO02+7Oh
	8IY408vUZH5RNxD0ya/DwJO8kAOFvDrcprvPUGKS01be7fN0CoWlwwDhPg+A1WtYGfuQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/asm-generic: introduce generic device.h
Message-Id: <E1rcZR4-0001Ly-D0@xenbits.xenproject.org>
Date: Tue, 20 Feb 2024 23:22:02 +0000

commit c2263735f57645a506608df0fc31509debd92ca8
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Tue Feb 20 12:21:38 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 20 12:21:38 2024 +0100

    xen/asm-generic: introduce generic device.h
    
    Arm, PPC and RISC-V introduce the same things in asm/device.h, so
    generic device.h was introduced.
    Arm's device.h was taken as a base with the following changes:
     - #ifdef ACPI related things.
     - Rename #ifdef guards.
     - Add SPDX tag.
     - #ifdef CONFIG_HAS_DEVICE_TREE related things.
     - #ifdef-ing iommu related things with CONFIG_HAS_PASSTHROUGH.
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/include/asm-generic/device.h | 145 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 145 insertions(+)

diff --git a/xen/include/asm-generic/device.h b/xen/include/asm-generic/device.h
new file mode 100644
index 0000000000..f91bb7f771
--- /dev/null
+++ b/xen/include/asm-generic/device.h
@@ -0,0 +1,145 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_DEVICE_H__
+#define __ASM_GENERIC_DEVICE_H__
+
+#include <xen/stdbool.h>
+
+enum device_type
+{
+#ifdef CONFIG_HAS_DEVICE_TREE
+    DEV_DT,
+#endif
+    DEV_PCI
+};
+
+enum device_class
+{
+    DEVICE_SERIAL,
+    DEVICE_IOMMU,
+    DEVICE_INTERRUPT_CONTROLLER,
+    DEVICE_PCI_HOSTBRIDGE,
+    /* Use for error */
+    DEVICE_UNKNOWN,
+};
+
+struct dev_archdata {
+#ifdef CONFIG_HAS_PASSTHROUGH
+    void *iommu;    /* IOMMU private data */
+#endif
+};
+
+/* struct device - The basic device structure */
+struct device
+{
+    enum device_type type;
+#ifdef CONFIG_HAS_DEVICE_TREE
+    struct dt_device_node *of_node; /* Used by drivers imported from Linux */
+#endif
+    struct dev_archdata archdata;
+#ifdef CONFIG_HAS_PASSTHROUGH
+    struct iommu_fwspec *iommu_fwspec; /* per-device IOMMU instance data */
+#endif
+};
+
+typedef struct device device_t;
+
+#ifdef CONFIG_HAS_DEVICE_TREE
+
+#include <xen/device_tree.h>
+
+#define dev_is_dt(dev)  ((dev)->type == DEV_DT)
+
+/**
+ *  device_init - Initialize a device
+ *  @dev: device to initialize
+ *  @class: class of the device (serial, network...)
+ *  @data: specific data for initializing the device
+ *
+ *  Return 0 on success.
+ */
+int device_init(struct dt_device_node *dev, enum device_class class,
+                const void *data);
+
+/**
+ * device_get_type - Get the type of the device
+ * @dev: device to match
+ *
+ * Return the device type on success or DEVICE_ANY on failure
+ */
+enum device_class device_get_class(const struct dt_device_node *dev);
+
+#define DT_DEVICE_START(dev_name, ident, cls)                   \
+static const struct device_desc __dev_desc_##dev_name __used    \
+__section(".dev.info") = {                                      \
+    .name = ident,                                              \
+    .class = cls,
+
+#define DT_DEVICE_END                                           \
+};
+
+struct device_desc {
+    /* Device name */
+    const char *name;
+    /* Device class */
+    enum device_class class;
+
+    /* List of devices supported by this driver */
+    const struct dt_device_match *dt_match;
+    /*
+     * Device initialization.
+     *
+     * -EAGAIN is used to indicate that device probing is deferred.
+     */
+    int (*init)(struct dt_device_node *dev, const void *data);
+};
+
+#else /* !CONFIG_HAS_DEVICE_TREE */
+#define dev_is_dt(dev) ((void)(dev), false)
+#endif /* CONFIG_HAS_DEVICE_TREE */
+
+#define dev_is_pci(dev) ((dev)->type == DEV_PCI)
+
+#ifdef CONFIG_ACPI
+
+struct acpi_device_desc {
+    /* Device name */
+    const char *name;
+    /* Device class */
+    enum device_class class;
+    /* type of device supported by the driver */
+    const int class_type;
+    /* Device initialization */
+    int (*init)(const void *data);
+};
+
+/**
+ *  acpi_device_init - Initialize a device
+ *  @class: class of the device (serial, network...)
+ *  @data: specific data for initializing the device
+ *
+ *  Return 0 on success.
+ */
+int acpi_device_init(enum device_class class,
+                     const void *data, int class_type);
+
+#define ACPI_DEVICE_START(dev_name, ident, cls)                     \
+static const struct acpi_device_desc __dev_desc_##dev_name __used   \
+__section(".adev.info") = {                                         \
+    .name = ident,                                                  \
+    .class = cls,
+
+#define ACPI_DEVICE_END                                             \
+};
+
+#endif /* CONFIG_ACPI */
+
+#endif /* __ASM_GENERIC_DEVICE_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 20 23:22:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 20 Feb 2024 23:22:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.683750.1063333 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcZRF-0006s9-6d; Tue, 20 Feb 2024 23:22:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 683750.1063333; Tue, 20 Feb 2024 23:22:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcZRF-0006rw-3a; Tue, 20 Feb 2024 23:22:13 +0000
Received: by outflank-mailman (input) for mailman id 683750;
 Tue, 20 Feb 2024 23:22:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcZRE-0006ro-JJ
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 23:22:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcZRE-0004qe-ID
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 23:22:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcZRE-0001NJ-GZ
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 23:22:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=rzs1l+evIe3eSScrNg5VSnuguyw2QOLWiKCGujZ8ec8=; b=a+3/rNZplm+tpAb8piclkQTin8
	yj0s0aX+sRrAGrBjgGoIK/opl50RWrzBnkVmzt/FfFmwXnR0DmsGuiS0ozbMptmojaDLYl/Rq6vl9
	HNqNYSm63xVOa5/yKsFeswE4fqQqMY/Vif2MortaZDvjB+oJgSftQ7KUZv9MEYmCGei4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: switch Arm to use asm-generic/device.h
Message-Id: <E1rcZRE-0001NJ-GZ@xenbits.xenproject.org>
Date: Tue, 20 Feb 2024 23:22:12 +0000

commit c0dd41e055229d5413e979853206ad4a4c8874ce
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Tue Feb 20 12:23:00 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 20 12:23:00 2024 +0100

    xen/arm: switch Arm to use asm-generic/device.h
    
    The following changes were done as a result of switching to
    asm-generic/device.h:
     * DEVICE_GIC was renamed to DEVICE_INTERRUPT_CONTROLLER according
       to definition of enum device_class in asm-generic/device.h.
     * acpi-related things in Arm code were guarded by #ifdef CONFIG_ACPI
       as struct acpi_device_desc was guarded in asm-generic, also functions
       acpi_device_init() was guarded too as they are using structure
       acpi_device_desc inside.
     * drop arm/include/asm/device.h and update arm/include/asm/Makefile
       to use asm-generic/device.h instead.
    
    As 'struct device_desc' is protected by CONFIG_HAS_DEVICE_TREE,
    _sdevice, _edevice, device_init(), and device_get_class should also be
    protected.
    However, this protection was not implemented because Arm always has
    CONFIG_HAS_DEVICE_TREE=y at the moment.
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/device.c             |   5 ++
 xen/arch/arm/domain_build.c       |   2 +-
 xen/arch/arm/gic-v2.c             |   4 +-
 xen/arch/arm/gic-v3.c             |   6 +-
 xen/arch/arm/gic.c                |   4 +-
 xen/arch/arm/include/asm/Makefile |   1 +
 xen/arch/arm/include/asm/device.h | 124 --------------------------------------
 xen/arch/arm/xen.lds.S            |   2 +
 8 files changed, 16 insertions(+), 132 deletions(-)

diff --git a/xen/arch/arm/device.c b/xen/arch/arm/device.c
index 1f631d3274..3e02cff008 100644
--- a/xen/arch/arm/device.c
+++ b/xen/arch/arm/device.c
@@ -16,7 +16,10 @@
 #include <xen/lib.h>
 
 extern const struct device_desc _sdevice[], _edevice[];
+
+#ifdef CONFIG_ACPI
 extern const struct acpi_device_desc _asdevice[], _aedevice[];
+#endif
 
 int __init device_init(struct dt_device_node *dev, enum device_class class,
                        const void *data)
@@ -45,6 +48,7 @@ int __init device_init(struct dt_device_node *dev, enum device_class class,
     return -EBADF;
 }
 
+#ifdef CONFIG_ACPI
 int __init acpi_device_init(enum device_class class, const void *data, int class_type)
 {
     const struct acpi_device_desc *desc;
@@ -61,6 +65,7 @@ int __init acpi_device_init(enum device_class class, const void *data, int class
 
     return -EBADF;
 }
+#endif
 
 enum device_class device_get_class(const struct dt_device_node *dev)
 {
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 46161848dc..085d88671e 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -1651,7 +1651,7 @@ static int __init handle_node(struct domain *d, struct kernel_info *kinfo,
      * Replace these nodes with our own. Note that the original may be
      * used_by DOMID_XEN so this check comes first.
      */
-    if ( device_get_class(node) == DEVICE_GIC )
+    if ( device_get_class(node) == DEVICE_INTERRUPT_CONTROLLER )
         return make_gic_node(d, kinfo->fdt, node);
     if ( dt_match_node(timer_matches, node) )
         return make_timer_node(kinfo);
diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index cf392bfd1c..5d6885e389 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -1366,7 +1366,7 @@ static const struct dt_device_match gicv2_dt_match[] __initconst =
     { /* sentinel */ },
 };
 
-DT_DEVICE_START(gicv2, "GICv2", DEVICE_GIC)
+DT_DEVICE_START(gicv2, "GICv2", DEVICE_INTERRUPT_CONTROLLER)
         .dt_match = gicv2_dt_match,
         .init = gicv2_dt_preinit,
 DT_DEVICE_END
@@ -1381,7 +1381,7 @@ static int __init gicv2_acpi_preinit(const void *data)
     return 0;
 }
 
-ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_GIC)
+ACPI_DEVICE_START(agicv2, "GICv2", DEVICE_INTERRUPT_CONTROLLER)
         .class_type = ACPI_MADT_GIC_VERSION_V2,
         .init = gicv2_acpi_preinit,
 ACPI_DEVICE_END
diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index bf0e5c1b75..1cb1360606 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -1909,7 +1909,7 @@ static const struct dt_device_match gicv3_dt_match[] __initconst =
     { /* sentinel */ },
 };
 
-DT_DEVICE_START(gicv3, "GICv3", DEVICE_GIC)
+DT_DEVICE_START(gicv3, "GICv3", DEVICE_INTERRUPT_CONTROLLER)
         .dt_match = gicv3_dt_match,
         .init = gicv3_dt_preinit,
 DT_DEVICE_END
@@ -1924,12 +1924,12 @@ static int __init gicv3_acpi_preinit(const void *data)
     return 0;
 }
 
-ACPI_DEVICE_START(agicv3, "GICv3", DEVICE_GIC)
+ACPI_DEVICE_START(agicv3, "GICv3", DEVICE_INTERRUPT_CONTROLLER)
         .class_type = ACPI_MADT_GIC_VERSION_V3,
         .init = gicv3_acpi_preinit,
 ACPI_DEVICE_END
 
-ACPI_DEVICE_START(agicv4, "GICv4", DEVICE_GIC)
+ACPI_DEVICE_START(agicv4, "GICv4", DEVICE_INTERRUPT_CONTROLLER)
         .class_type = ACPI_MADT_GIC_VERSION_V4,
         .init = gicv3_acpi_preinit,
 ACPI_DEVICE_END
diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index d922ea67aa..b5a9c8266c 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -234,7 +234,7 @@ static void __init gic_dt_preinit(void)
         if ( !dt_get_parent(node) )
             continue;
 
-        rc = device_init(node, DEVICE_GIC, NULL);
+        rc = device_init(node, DEVICE_INTERRUPT_CONTROLLER, NULL);
         if ( !rc )
         {
             /* NOTE: Only one GIC is supported */
@@ -262,7 +262,7 @@ static void __init gic_acpi_preinit(void)
 
     dist = container_of(header, struct acpi_madt_generic_distributor, header);
 
-    if ( acpi_device_init(DEVICE_GIC, NULL, dist->version) )
+    if ( acpi_device_init(DEVICE_INTERRUPT_CONTROLLER, NULL, dist->version) )
         panic("Unable to find compatible GIC in the ACPI table\n");
 }
 #else
diff --git a/xen/arch/arm/include/asm/Makefile b/xen/arch/arm/include/asm/Makefile
index 505cb49090..4a4036c951 100644
--- a/xen/arch/arm/include/asm/Makefile
+++ b/xen/arch/arm/include/asm/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 generic-y += altp2m.h
+generic-y += device.h
 generic-y += hardirq.h
 generic-y += iocap.h
 generic-y += paging.h
diff --git a/xen/arch/arm/include/asm/device.h b/xen/arch/arm/include/asm/device.h
deleted file mode 100644
index b5d451e087..0000000000
--- a/xen/arch/arm/include/asm/device.h
+++ /dev/null
@@ -1,124 +0,0 @@
-#ifndef __ASM_ARM_DEVICE_H
-#define __ASM_ARM_DEVICE_H
-
-enum device_type
-{
-    DEV_DT,
-    DEV_PCI,
-};
-
-struct dev_archdata {
-    void *iommu;    /* IOMMU private data */
-};
-
-/* struct device - The basic device structure */
-struct device
-{
-    enum device_type type;
-#ifdef CONFIG_HAS_DEVICE_TREE
-    struct dt_device_node *of_node; /* Used by drivers imported from Linux */
-#endif
-    struct dev_archdata archdata;
-    struct iommu_fwspec *iommu_fwspec; /* per-device IOMMU instance data */
-};
-
-typedef struct device device_t;
-
-#include <xen/device_tree.h>
-
-#define dev_is_pci(dev) ((dev)->type == DEV_PCI)
-#define dev_is_dt(dev)  ((dev)->type == DEV_DT)
-
-enum device_class
-{
-    DEVICE_SERIAL,
-    DEVICE_IOMMU,
-    DEVICE_GIC,
-    DEVICE_PCI_HOSTBRIDGE,
-    /* Use for error */
-    DEVICE_UNKNOWN,
-};
-
-struct device_desc {
-    /* Device name */
-    const char *name;
-    /* Device class */
-    enum device_class class;
-    /* List of devices supported by this driver */
-    const struct dt_device_match *dt_match;
-    /*
-     * Device initialization.
-     *
-     * -EAGAIN is used to indicate that device probing is deferred.
-     */
-    int (*init)(struct dt_device_node *dev, const void *data);
-};
-
-struct acpi_device_desc {
-    /* Device name */
-    const char *name;
-    /* Device class */
-    enum device_class class;
-    /* type of device supported by the driver */
-    const int class_type;
-    /* Device initialization */
-    int (*init)(const void *data);
-};
-
-/**
- *  acpi_device_init - Initialize a device
- *  @class: class of the device (serial, network...)
- *  @data: specific data for initializing the device
- *
- *  Return 0 on success.
- */
-int acpi_device_init(enum device_class class,
-                     const void *data, int class_type);
-
-/**
- *  device_init - Initialize a device
- *  @dev: device to initialize
- *  @class: class of the device (serial, network...)
- *  @data: specific data for initializing the device
- *
- *  Return 0 on success.
- */
-int device_init(struct dt_device_node *dev, enum device_class class,
-                const void *data);
-
-/**
- * device_get_type - Get the type of the device
- * @dev: device to match
- *
- * Return the device type on success or DEVICE_ANY on failure
- */
-enum device_class device_get_class(const struct dt_device_node *dev);
-
-#define DT_DEVICE_START(_name, _namestr, _class)                    \
-static const struct device_desc __dev_desc_##_name __used           \
-__section(".dev.info") = {                                          \
-    .name = _namestr,                                               \
-    .class = _class,                                                \
-
-#define DT_DEVICE_END                                               \
-};
-
-#define ACPI_DEVICE_START(_name, _namestr, _class)                    \
-static const struct acpi_device_desc __dev_desc_##_name __used           \
-__section(".adev.info") = {                       \
-    .name = _namestr,                                               \
-    .class = _class,                                                \
-
-#define ACPI_DEVICE_END                                               \
-};
-
-#endif /* __ASM_ARM_DEVICE_H */
-
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index 470c8f2208..2266c9536f 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -138,12 +138,14 @@ SECTIONS
       _edevice = .;
   } :text
 
+#ifdef CONFIG_ACPI
   . = ALIGN(8);
   .adev.info : {
       _asdevice = .;
       *(.adev.info)
       _aedevice = .;
   } :text
+#endif
 
   . = ALIGN(8);
   .teemediator.info : {
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 20 23:22:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 20 Feb 2024 23:22:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.683751.1063337 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcZRP-0006vA-8D; Tue, 20 Feb 2024 23:22:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 683751.1063337; Tue, 20 Feb 2024 23:22:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcZRP-0006v0-5O; Tue, 20 Feb 2024 23:22:23 +0000
Received: by outflank-mailman (input) for mailman id 683751;
 Tue, 20 Feb 2024 23:22:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcZRO-0006uq-MI
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 23:22:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcZRO-0004qr-L7
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 23:22:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcZRO-0001OU-KO
 for xen-changelog@lists.xenproject.org; Tue, 20 Feb 2024 23:22:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=NxdyCMionRm2G4dfxhQ6s43pxdOdMjwS+RiUzNqld4A=; b=tUeLLYAyLTQMBct+sa+5vjeCV2
	uNo7KzQrUgjN5ZFM+36qqXUyRwqELGaLIVnTc60FQWL1FZXyDutggH5mG+xCYpwgSqWj+/A3FKDcJ
	KKsNofVb80ny0lOS/ziOeApp5EnCXITh6Ok1CgiVXWkDIN0fnmWSVHgMZDWW7QZnMxRI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/asm-generic: fold struct devarch into struct dev
Message-Id: <E1rcZRO-0001OU-KO@xenbits.xenproject.org>
Date: Tue, 20 Feb 2024 23:22:22 +0000

commit 981f722efa876e3f1766629f444d10e8806adc93
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Tue Feb 20 12:23:50 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 20 12:23:50 2024 +0100

    xen/asm-generic: fold struct devarch into struct dev
    
    The 'struct dev_archdata' is exclusively used within 'struct device',
    so it could be merged into 'struct device.'
    
    After the merger, it is necessary to update the 'dev_archdata()'
    macros and the comments above 'struct arm_smmu_xen_device' in
    drivers/passthrough/arm/smmu.c.
    Additionally, it is required to update instances of
    "dev->archdata->iommu" to "dev->iommu".
    
    Suggested-by: Julien Grall <julien@xen.org>
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/drivers/passthrough/arm/smmu.c | 12 ++++++------
 xen/include/asm-generic/device.h   |  8 +-------
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c
index 32e2ff279b..4a272c8779 100644
--- a/xen/drivers/passthrough/arm/smmu.c
+++ b/xen/drivers/passthrough/arm/smmu.c
@@ -227,9 +227,9 @@ struct arm_smmu_xen_domain {
 };
 
 /*
- * Xen: Information about each device stored in dev->archdata.iommu
+ * Xen: Information about each device stored in dev->iommu
  *
- * Initially dev->archdata.iommu only stores the iommu_domain (runtime
+ * Initially dev->iommu only stores the iommu_domain (runtime
  * configuration of the SMMU) but, on Xen, we also have to store the
  * iommu_group (list of streamIDs associated to the device).
  *
@@ -242,7 +242,7 @@ struct arm_smmu_xen_device {
 	struct iommu_group *group;
 };
 
-#define dev_archdata(dev) ((struct arm_smmu_xen_device *)dev->archdata.iommu)
+#define dev_archdata(dev) ((struct arm_smmu_xen_device *)dev->iommu)
 #define dev_iommu_domain(dev) (dev_archdata(dev)->domain)
 #define dev_iommu_group(dev) (dev_archdata(dev)->group)
 
@@ -2777,9 +2777,9 @@ static int arm_smmu_assign_dev(struct domain *d, u8 devfn,
 
 	xen_domain = dom_iommu(d)->arch.priv;
 
-	if (!dev->archdata.iommu) {
-		dev->archdata.iommu = xzalloc(struct arm_smmu_xen_device);
-		if (!dev->archdata.iommu)
+	if (!dev->iommu) {
+		dev->iommu = xzalloc(struct arm_smmu_xen_device);
+		if (!dev->iommu)
 			return -ENOMEM;
 	}
 
diff --git a/xen/include/asm-generic/device.h b/xen/include/asm-generic/device.h
index f91bb7f771..1acd1ba1d8 100644
--- a/xen/include/asm-generic/device.h
+++ b/xen/include/asm-generic/device.h
@@ -22,12 +22,6 @@ enum device_class
     DEVICE_UNKNOWN,
 };
 
-struct dev_archdata {
-#ifdef CONFIG_HAS_PASSTHROUGH
-    void *iommu;    /* IOMMU private data */
-#endif
-};
-
 /* struct device - The basic device structure */
 struct device
 {
@@ -35,8 +29,8 @@ struct device
 #ifdef CONFIG_HAS_DEVICE_TREE
     struct dt_device_node *of_node; /* Used by drivers imported from Linux */
 #endif
-    struct dev_archdata archdata;
 #ifdef CONFIG_HAS_PASSTHROUGH
+    void *iommu; /* IOMMU private data */;
     struct iommu_fwspec *iommu_fwspec; /* per-device IOMMU instance data */
 #endif
 };
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 21 09:11:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 21 Feb 2024 09:11:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.683897.1063511 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcid5-0005Vb-0J; Wed, 21 Feb 2024 09:11:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 683897.1063511; Wed, 21 Feb 2024 09:11:02 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rcid4-0005VU-Tu; Wed, 21 Feb 2024 09:11:02 +0000
Received: by outflank-mailman (input) for mailman id 683897;
 Wed, 21 Feb 2024 09:11:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcid4-0005VO-Ea
 for xen-changelog@lists.xenproject.org; Wed, 21 Feb 2024 09:11:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcid4-0006s6-14
 for xen-changelog@lists.xenproject.org; Wed, 21 Feb 2024 09:11:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rcid4-0002Tm-04
 for xen-changelog@lists.xenproject.org; Wed, 21 Feb 2024 09:11:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ZTiT+OK++1dMDtIdHYQ+YX0h8nlwwaLfV+HC+OOSmI0=; b=IIZWO5jJh5U4CE6ffktuangkd6
	sWeQHk52kLhNiDBtFIFMvTnM7I1cP9fhr0ZFt2Xrre65vhbGQgu4quhr/HD855RP2vAGmdiaEOR66
	CWKxJ3dXyfk57QC2fRfVLx/+ApnNwilV69j9Qpeh2se5or0gqy4M8MWAptCPcWYmE4Yw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: Make hwdom vUART optional feature
Message-Id: <E1rcid4-0002Tm-04@xenbits.xenproject.org>
Date: Wed, 21 Feb 2024 09:11:02 +0000

commit f8791d0fd3adbda3701e7eb9db63a9351b478365
Author:     Michal Orzel <michal.orzel@amd.com>
AuthorDate: Thu Feb 15 15:39:47 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Tue Feb 20 13:20:31 2024 +0000

    xen/arm: Make hwdom vUART optional feature
    
    At the moment, the hardware domain vUART is always compiled in. In the
    spirit of fine granular configuration, make it optional so that the
    feature can be disabled if not needed. This UART is not exposed (e.g.
    via device tree) to a domain and is mostly used to support special use
    cases like Linux early printk, prints from the decompressor code, etc.
    
    Introduce Kconfig option CONFIG_HWDOM_VUART, enabled by default (to keep
    the current behavior) and use it to protect the vUART related code.
    Provide stubs for domain_vuart_{init,free}() in case the feature is
    disabled. Take the opportunity to add a struct domain forward declaration
    to vuart.h, so that the header is self contained.
    
    Signed-off-by: Michal Orzel <michal.orzel@amd.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
    Tested-by: Luca Fancellu <luca.fancellu@arm.com>
---
 xen/arch/arm/Kconfig              |  8 ++++++++
 xen/arch/arm/Makefile             |  2 +-
 xen/arch/arm/include/asm/domain.h |  2 ++
 xen/arch/arm/vuart.h              | 19 +++++++++++++++++++
 4 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index 50e9bfae1a..72af329564 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -150,6 +150,14 @@ config SBSA_VUART_CONSOLE
 	  Allows a guest to use SBSA Generic UART as a console. The
 	  SBSA Generic UART implements a subset of ARM PL011 UART.
 
+config HWDOM_VUART
+	bool "Emulated UART for hardware domain"
+	default y
+	help
+	  Allows a hardware domain to use a minimalistic UART (single transmit
+	  and status register) which takes information from dtuart. Note that this
+	  UART is not intended to be exposed (e.g. via device-tree) to a domain.
+
 config ARM_SSBD
 	bool "Speculative Store Bypass Disable" if EXPERT
 	depends on HAS_ALTERNATIVE
diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
index 33c677672f..7b1350e2ef 100644
--- a/xen/arch/arm/Makefile
+++ b/xen/arch/arm/Makefile
@@ -71,7 +71,7 @@ obj-y += vtimer.o
 obj-$(CONFIG_SBSA_VUART_CONSOLE) += vpl011.o
 obj-y += vsmc.o
 obj-y += vpsci.o
-obj-y += vuart.o
+obj-$(CONFIG_HWDOM_VUART) += vuart.o
 
 extra-y += xen.lds
 
diff --git a/xen/arch/arm/include/asm/domain.h b/xen/arch/arm/include/asm/domain.h
index 5fb8cd79c0..8218afb862 100644
--- a/xen/arch/arm/include/asm/domain.h
+++ b/xen/arch/arm/include/asm/domain.h
@@ -91,6 +91,7 @@ struct arch_domain
 
     struct vgic_dist vgic;
 
+#ifdef CONFIG_HWDOM_VUART
     struct vuart {
 #define VUART_BUF_SIZE 128
         char                        *buf;
@@ -98,6 +99,7 @@ struct arch_domain
         const struct vuart_info     *info;
         spinlock_t                  lock;
     } vuart;
+#endif
 
     unsigned int evtchn_irq;
 #ifdef CONFIG_ACPI
diff --git a/xen/arch/arm/vuart.h b/xen/arch/arm/vuart.h
index bd23bd92f6..e90d84c6ed 100644
--- a/xen/arch/arm/vuart.h
+++ b/xen/arch/arm/vuart.h
@@ -20,9 +20,28 @@
 #ifndef __ARCH_ARM_VUART_H__
 #define __ARCH_ARM_VUART_H__
 
+struct domain;
+
+#ifdef CONFIG_HWDOM_VUART
+
 int domain_vuart_init(struct domain *d);
 void domain_vuart_free(struct domain *d);
 
+#else
+
+static inline int domain_vuart_init(struct domain *d)
+{
+    /*
+     * The vUART is unconditionally inialized for the hw domain. So we
+     * can't return an error.
+     */
+    return 0;
+}
+
+static inline void domain_vuart_free(struct domain *d) {};
+
+#endif /* CONFIG_HWDOM_VUART */
+
 #endif /* __ARCH_ARM_VUART_H__ */
 
 /*
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:00:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:00:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684337.1064119 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6o8-0005nn-Ea; Thu, 22 Feb 2024 11:00:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684337.1064119; Thu, 22 Feb 2024 11:00:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6o8-0005nh-Bn; Thu, 22 Feb 2024 11:00:04 +0000
Received: by outflank-mailman (input) for mailman id 684337;
 Thu, 22 Feb 2024 11:00:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6o7-0005cT-FJ
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6o7-0004l8-EK
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6o7-0002FL-BA
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=5X5qY3denoXGTBbpZ6Snph8YBG0cTMZ7Z+swsX+bbCI=; b=ssVkSKy+N9IemZwH/O+b1tA7+O
	Ju6RxPo4QBQ2sXWBItwDAQZkZVNnj8XezEkw8/6mwTvAkX5ywX1AxwE2rWV0RL7sBpMrXWetVLK7J
	i1tFJP6Ku7M7Jwr774Ax4zd2TnTNCwKWx4w4CQ2zUXbJ22xjH4mXp9AZJLwVUHL8mshY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] libxl: Disable relocating memory for qemu-xen in stubdomain too
Message-Id: <E1rd6o7-0002FL-BA@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:00:03 +0000

commit 97883aa269f6745a6ded232be3a855abb1297e0d
Author:     Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
AuthorDate: Thu Feb 22 11:48:22 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:48:22 2024 +0100

    libxl: Disable relocating memory for qemu-xen in stubdomain too
    
    According to comments (and experiments) qemu-xen cannot handle memory
    reolcation done by hvmloader. The code was already disabled when running
    qemu-xen in dom0 (see libxl__spawn_local_dm()), but it was missed when
    adding qemu-xen support to stubdomain. Adjust libxl__spawn_stub_dm() to
    be consistent in this regard.
    
    Reported-by: Neowutran <xen@neowutran.ovh>
    Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libs/light/libxl_dm.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
index 14b593110f..ed620a9d8e 100644
--- a/tools/libs/light/libxl_dm.c
+++ b/tools/libs/light/libxl_dm.c
@@ -2432,6 +2432,16 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
                         "%s",
                         libxl_bios_type_to_string(guest_config->b_info.u.hvm.bios));
     }
+    /* Disable relocating memory to make the MMIO hole larger
+     * unless we're running qemu-traditional and vNUMA is not
+     * configured. */
+    libxl__xs_printf(gc, XBT_NULL,
+                     libxl__sprintf(gc, "%s/hvmloader/allow-memory-relocate",
+                                    libxl__xs_get_dompath(gc, guest_domid)),
+                     "%d",
+                     guest_config->b_info.device_model_version
+                        == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL &&
+                     !libxl__vnuma_configured(&guest_config->b_info));
     ret = xc_domain_set_target(ctx->xch, dm_domid, guest_domid);
     if (ret<0) {
         LOGED(ERROR, guest_domid, "setting target domain %d -> %d",
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:00:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:00:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684340.1064127 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6oI-0006Gm-KM; Thu, 22 Feb 2024 11:00:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684340.1064127; Thu, 22 Feb 2024 11:00:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6oI-0006Gb-HU; Thu, 22 Feb 2024 11:00:14 +0000
Received: by outflank-mailman (input) for mailman id 684340;
 Thu, 22 Feb 2024 11:00:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6oH-0006GJ-IP
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6oH-0004lN-He
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6oH-0002HC-Gc
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ZWAWLmYfrca9/h0Gh37KM5/Zs0S2U1WPmzOVRCNGtaU=; b=VWjpLXTd0t4BHmndl99OE6iio0
	uKWUXJb/OQQovrg6v87c2ZtA6s9b8iwnqVCbwTuh7vQxPnyc2/gEaRudgrSq62pZhR47fCcQI96wA
	5QL4H6tYyFn9z2gdE5AxhQvonHcVIRF0Xp0BCWGih621S9Vdx2lPzz810he1cx+25UcM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] gnttab: fully ignore zero-size copy requests
Message-Id: <E1rd6oH-0002HC-Gc@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:00:13 +0000

commit a4a790f4327fd80cf4615c11cd146291b0dcc5fc
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 11:49:10 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:49:10 2024 +0100

    gnttab: fully ignore zero-size copy requests
    
    Along the line with observations in the context of XSA-448, no field in
    struct gnttab_copy_ptr is relevant when no data is to be copied, much
    like e.g. the pointers passed to memcpy() are irrelevant (and would
    never be "validated") when the passed length is zero.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/common/grant_table.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index 5721eab225..37b178a67b 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -3061,6 +3061,9 @@ static int gnttab_copy_one(const struct gnttab_copy *op,
 {
     int rc;
 
+    if ( unlikely(!op->len) )
+        return GNTST_okay;
+
     if ( !src->domain || op->source.domid != src->ptr.domid ||
          !dest->domain || op->dest.domid != dest->ptr.domid )
     {
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:00:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:00:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684341.1064131 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6oS-0006JT-Lu; Thu, 22 Feb 2024 11:00:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684341.1064131; Thu, 22 Feb 2024 11:00:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6oS-0006JL-Iz; Thu, 22 Feb 2024 11:00:24 +0000
Received: by outflank-mailman (input) for mailman id 684341;
 Thu, 22 Feb 2024 11:00:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6oR-0006J9-LT
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6oR-0004lU-Km
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6oR-0002Hp-Jl
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=O/RbYfUc7HrGr20aQH7Al5CJrr1kYYDmaA4zsFGhHk0=; b=WPhfGVURPPCLTLL6vBQMySNs6D
	hDH2ibBVDgKJMx4OmFh9puUAgUoxUHku/UUkCYBJAzATtXnnxwIiYLDZIWnCtWZBTW4yLTDffSfWB
	IpctvUlKhkj+bPHeYeeorBgunyU62qLmOKPNkSlrvqqkiYqimPLCWU0cgP8HpiC8pjbU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/riscv: use some asm-generic headers
Message-Id: <E1rd6oR-0002Hp-Jl@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:00:23 +0000

commit 512f88a92d4cf01d84a6da2ae4e72cd8800f4694
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Thu Feb 22 11:50:47 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:50:47 2024 +0100

    xen/riscv: use some asm-generic headers
    
    Some headers are the same as asm-generic verions of them
    so use them instead of arch-specific headers.
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/riscv/include/asm/Makefile | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/xen/arch/riscv/include/asm/Makefile b/xen/arch/riscv/include/asm/Makefile
new file mode 100644
index 0000000000..ced02e26ed
--- /dev/null
+++ b/xen/arch/riscv/include/asm/Makefile
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0-only
+generic-y += altp2m.h
+generic-y += device.h
+generic-y += div64.h
+generic-y += hardirq.h
+generic-y += hypercall.h
+generic-y += iocap.h
+generic-y += paging.h
+generic-y += percpu.h
+generic-y += random.h
+generic-y += softirq.h
+generic-y += vm_event.h
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:00:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:00:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684342.1064134 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6oc-0006Q5-Mu; Thu, 22 Feb 2024 11:00:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684342.1064134; Thu, 22 Feb 2024 11:00:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6oc-0006Py-KR; Thu, 22 Feb 2024 11:00:34 +0000
Received: by outflank-mailman (input) for mailman id 684342;
 Thu, 22 Feb 2024 11:00:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6ob-0006Oa-Ov
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6ob-0004lb-OB
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6ob-0002IL-N8
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=+0I4gnuxgUcuSTWPeYxnCS52zWiUSp+hkUAwzX3a8U4=; b=AacEpmEzx7JC6+UtkPlsQ2yyLd
	NYL0INFEeuAI2XFqrqEztlLfdinYO/35YXIj9VL6US2Qk3bEzeik01cLHmzNl0gJAMdS0Mo6ngApc
	OD7VKTGKGeCk5ylFaXR6MeVrRwf0YoK9W1jG0TSvr2/omyRYPQSQwyh9Rs2Y3VPeqsG0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] Constify some parameters
Message-Id: <E1rd6ob-0002IL-N8@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:00:33 +0000

commit d9fe1d743fd764cd11e4db8e540d2527adc7b701
Author:     Frediano Ziglio <frediano.ziglio@cloud.com>
AuthorDate: Thu Feb 22 11:51:19 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:51:19 2024 +0100

    Constify some parameters
    
    Make clear they are not changed in the functions.
    
    Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Daniel P. Smith <dpsmith@apertussolutions.com> # XSM
    Acked-by: George Dunlap <george.dunlap@cloud.com> # sched
---
 xen/arch/x86/pv/callback.c | 4 ++--
 xen/common/sched/compat.c  | 2 +-
 xen/common/sched/core.c    | 2 +-
 xen/xsm/flask/flask_op.c   | 8 ++++----
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/pv/callback.c b/xen/arch/x86/pv/callback.c
index 17829304fe..caec4fb16f 100644
--- a/xen/arch/x86/pv/callback.c
+++ b/xen/arch/x86/pv/callback.c
@@ -48,7 +48,7 @@ static void unregister_guest_nmi_callback(void)
     memset(t, 0, sizeof(*t));
 }
 
-static long register_guest_callback(struct callback_register *reg)
+static long register_guest_callback(const struct callback_register *reg)
 {
     long ret = 0;
     struct vcpu *curr = current;
@@ -102,7 +102,7 @@ static long register_guest_callback(struct callback_register *reg)
     return ret;
 }
 
-static long unregister_guest_callback(struct callback_unregister *unreg)
+static long unregister_guest_callback(const struct callback_unregister *unreg)
 {
     long ret;
 
diff --git a/xen/common/sched/compat.c b/xen/common/sched/compat.c
index dd97593630..a02204ec9a 100644
--- a/xen/common/sched/compat.c
+++ b/xen/common/sched/compat.c
@@ -26,7 +26,7 @@ CHECK_sched_shutdown;
 CHECK_sched_remote_shutdown;
 #undef xen_sched_remote_shutdown
 
-static int compat_poll(struct compat_sched_poll *compat)
+static int compat_poll(const struct compat_sched_poll *compat)
 {
     struct sched_poll native;
 
diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index d177c675c8..c5db373972 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -1431,7 +1431,7 @@ static void vcpu_block_enable_events(void)
     vcpu_block();
 }
 
-static long do_poll(struct sched_poll *sched_poll)
+static long do_poll(const struct sched_poll *sched_poll)
 {
     struct vcpu   *v = current;
     struct domain *d = v->domain;
diff --git a/xen/xsm/flask/flask_op.c b/xen/xsm/flask/flask_op.c
index b866e8d05f..ea7dd10dc8 100644
--- a/xen/xsm/flask/flask_op.c
+++ b/xen/xsm/flask/flask_op.c
@@ -469,7 +469,7 @@ static int flask_security_load(struct xen_flask_load *load)
     return ret;
 }
 
-static int flask_devicetree_label(struct xen_flask_devicetree_label *arg)
+static int flask_devicetree_label(const struct xen_flask_devicetree_label *arg)
 {
     int rv;
     char *buf;
@@ -492,7 +492,7 @@ static int flask_devicetree_label(struct xen_flask_devicetree_label *arg)
 
 #ifndef COMPAT
 
-static int flask_ocontext_del(struct xen_flask_ocontext *arg)
+static int flask_ocontext_del(const struct xen_flask_ocontext *arg)
 {
     int rv;
 
@@ -506,7 +506,7 @@ static int flask_ocontext_del(struct xen_flask_ocontext *arg)
     return security_ocontext_del(arg->ocon, arg->low, arg->high);
 }
 
-static int flask_ocontext_add(struct xen_flask_ocontext *arg)
+static int flask_ocontext_add(const struct xen_flask_ocontext *arg)
 {
     int rv;
 
@@ -550,7 +550,7 @@ static int flask_get_peer_sid(struct xen_flask_peersid *arg)
     return rv;
 }
 
-static int flask_relabel_domain(struct xen_flask_relabel *arg)
+static int flask_relabel_domain(const struct xen_flask_relabel *arg)
 {
     int rc;
     struct domain *d;
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:00:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:00:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684343.1064138 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6om-0006UZ-OQ; Thu, 22 Feb 2024 11:00:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684343.1064138; Thu, 22 Feb 2024 11:00:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6om-0006UR-Lu; Thu, 22 Feb 2024 11:00:44 +0000
Received: by outflank-mailman (input) for mailman id 684343;
 Thu, 22 Feb 2024 11:00:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6ol-0006UH-SC
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:43 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6ol-0004lt-RR
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6ol-0002J6-QE
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=jmOFe35uZYch40MACorGsVFjjp02lnKM9zj7RvhEfoM=; b=YNOyjr+/o36R53DtAVemMr8J8G
	YT5AiC2Rrjd9Zwt98JhB/GG82dbO/hXo4778hN/yVtWeAMSH71uKVnt4x0mvvOHU/ureo9kjVUKEG
	JblEfSDnJ+JmDmDtjgVQKBx2wpgfRacSUQHjcdhZ52Oxhs16ELTf/dFpl2MUoDMgG7P0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/9pfsd: add missing va_end() in fill_data()
Message-Id: <E1rd6ol-0002J6-QE@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:00:43 +0000

commit bb1619ed4f2edcc7140b6a130b42a553da78fa10
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 22 11:51:56 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:51:56 2024 +0100

    tools/9pfsd: add missing va_end() in fill_data()
    
    In xen-9pfsd fill_data() va_end() needs to be called before returning.
    
    Coverity Id CID 1592145
    
    Fixes: bcec59cf7ff4 ("tools/xen-9pfsd: add 9pfs version request support")
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/9pfsd/io.c | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index ebc4102713..adb887c7d9 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -445,7 +445,7 @@ static int fill_data(struct ring *ring, const char *fmt, ...)
             if ( !*f || array_sz )
                 fmt_err(fmt);
             if ( !chk_data(ring, data, sizeof(uint16_t)) )
-                return pars;
+                goto out;
             array_sz = get_unaligned((uint16_t *)data);
             data += sizeof(uint16_t);
             *(unsigned int *)par = array_sz;
@@ -455,10 +455,10 @@ static int fill_data(struct ring *ring, const char *fmt, ...)
 
         case 'b':
             if ( !chk_data(ring, data, sizeof(uint8_t)) )
-                return pars;
+                goto out;
             if ( !fill_data_elem(&par, array, &array_sz, sizeof(uint8_t),
                                  data) )
-                return pars;
+                goto out;
             data += sizeof(uint8_t);
             break;
 
@@ -466,48 +466,48 @@ static int fill_data(struct ring *ring, const char *fmt, ...)
             if ( array_sz )
                 fmt_err(fmt);
             if ( !chk_data(ring, data, sizeof(uint32_t)) )
-                return pars;
+                goto out;
             len = get_unaligned((uint32_t *)data);
             data += sizeof(uint32_t);
             *(unsigned int *)par = len;
             par = va_arg(ap, void *);
             if ( !chk_data(ring, data, len) )
-                return pars;
+                goto out;
             memcpy(par, data, len);
             data += len;
             break;
 
         case 'L':
             if ( !chk_data(ring, data, sizeof(uint64_t)) )
-                return pars;
+                goto out;
             if ( !fill_data_elem(&par, array, &array_sz, sizeof(uint64_t),
                                  data) )
-                return pars;
+                goto out;
             data += sizeof(uint64_t);
             break;
 
         case 'S':
             if ( !chk_data(ring, data, sizeof(uint16_t)) )
-                return pars;
+                goto out;
             len = get_unaligned((uint16_t *)data);
             data += sizeof(uint16_t);
             if ( !chk_data(ring, data, len) )
-                return pars;
+                goto out;
             str_off = add_string(ring, data, len);
             if ( str_off == ~0 )
-                return pars;
+                goto out;
             if ( !fill_data_elem(&par, array, &array_sz, sizeof(unsigned int),
                                  &str_off) )
-                return pars;
+                goto out;
             data += len;
             break;
 
         case 'U':
             if ( !chk_data(ring, data, sizeof(uint32_t)) )
-                return pars;
+                goto out;
             if ( !fill_data_elem(&par, array, &array_sz, sizeof(uint32_t),
                                  data) )
-                return pars;
+                goto out;
             data += sizeof(uint32_t);
             break;
 
@@ -520,6 +520,9 @@ static int fill_data(struct ring *ring, const char *fmt, ...)
         pars++;
     }
 
+ out:
+    va_end(ap);
+
     return pars;
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:00:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:00:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684344.1064143 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6ow-0006Zd-Q4; Thu, 22 Feb 2024 11:00:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684344.1064143; Thu, 22 Feb 2024 11:00:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6ow-0006ZV-NO; Thu, 22 Feb 2024 11:00:54 +0000
Received: by outflank-mailman (input) for mailman id 684344;
 Thu, 22 Feb 2024 11:00:54 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6ow-0006ZN-0t
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:54 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6ov-0004m0-Uc
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:53 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6ov-0002Jv-Tm
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:00:53 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=+iiSG0wEnV4xBKidtiQWm+HBp2KrCtVSylZNhC9kybQ=; b=pM42D0+xe5kjV1EOuoELH7/mH+
	MFPOyhSoH1/nUTxXPvbJ6GDBQtbQI2iphBMD8pHTgRpch8DVocdeAp+OAejFBhl/Qvn7QC1GTO9Lu
	6JGo1/xDx3dr8Lj8qpK2RPV9Bb0ujV3kCtvqpAP7x4h730YlnMlwTBbDb4WOhGJ5dOig=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] build: make sure build fails when running kconfig fails
Message-Id: <E1rd6ov-0002Jv-Tm@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:00:53 +0000

commit d34e5fa2e8db19f23081f46a3e710bb122130691
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 11:52:47 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:52:47 2024 +0100

    build: make sure build fails when running kconfig fails
    
    Because of using "-include", failure to (re)build auto.conf (with
    auto.conf.cmd produced as a secondary target) won't stop make from
    continuing the build. Arrange for it being possible to drop the - from
    Rules.mk, requiring that the include be skipped for tools-only targets.
    Note that relying on the inclusion in those cases wouldn't be correct
    anyway, as it might be a stale file (yet to be rebuilt) which would be
    included, while during initial build, the file would be absent
    altogether.
    
    Fixes: 8d4c17a90b0a ("xen/build: silence make warnings about missing auto.conf*")
    Reported-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 xen/Makefile | 1 +
 xen/Rules.mk | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/xen/Makefile b/xen/Makefile
index 767e47d6c7..b6c39fc6ae 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -375,6 +375,7 @@ $(KCONFIG_CONFIG): tools_fixdep
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
+	$(Q)rm -f include/config/auto.conf
 	$(Q)$(MAKE) $(build)=tools/kconfig syncconfig
 
 ifeq ($(CONFIG_DEBUG),y)
diff --git a/xen/Rules.mk b/xen/Rules.mk
index 8af3dd7277..d759cccee3 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -15,7 +15,9 @@ srcdir := $(srctree)/$(src)
 PHONY := __build
 __build:
 
--include $(objtree)/include/config/auto.conf
+ifneq ($(firstword $(subst /, ,$(obj))),tools)
+include $(objtree)/include/config/auto.conf
+endif
 
 include $(XEN_ROOT)/Config.mk
 include $(srctree)/scripts/Kbuild.include
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:01:05 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:01:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684346.1064156 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6p7-0006tB-32; Thu, 22 Feb 2024 11:01:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684346.1064156; Thu, 22 Feb 2024 11:01:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6p7-0006t3-0M; Thu, 22 Feb 2024 11:01:05 +0000
Received: by outflank-mailman (input) for mailman id 684346;
 Thu, 22 Feb 2024 11:01:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6p6-0006sg-2F
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:01:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6p6-0004mh-1R
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:01:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6p6-0002LJ-0Z
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:01:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=W/4zDU4df3bLiol2cZ3mKRYyMC27YjM4+H4QW96aHjs=; b=OtrANqZECY4NijogDhGfNz5YxH
	S1WfErfkXNOEOENp1z8ktcRvN0SfKZSPXCwsI8OvYxTV1km+Le74JWqM1ehKYEqYjhYQzT8UeOugf
	Cx69mCiAy3bxo2dRTbAPshAgrNoF4V8+6N8Eio8PeVt21Nu4oWWF2LOdGCnsU983Awo8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/uaccess: add attribute noreturn to __{get,put}_user_bad()
Message-Id: <E1rd6p6-0002LJ-0Z@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:01:04 +0000

commit 54557ee9b4ad8f2ed708c3dd222ee0db74d4c83b
Author:     Federico Serafini <federico.serafini@bugseng.com>
AuthorDate: Thu Feb 22 11:53:23 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:53:23 2024 +0100

    x86/uaccess: add attribute noreturn to __{get,put}_user_bad()
    
    __get_user_bad() and __put_user_bad() are undefined symbols used
    to assert the unreachability of a program point:
    a call to one of such functions is optimized away if it is considered
    unreachable by the compiler. Otherwise, a linker error is reported.
    
    In accordance with the purpose of such constructs:
    1) add the attribute noreturn to __get_user_bad() and __put_user_bad();
    2) change return type of __get_user_bad() to void (returning long is a
       leftover from the past).
    
    Point (1) meets the requirements to deviate MISRA C:2012 Rule 16.3
    ("An unconditional break statement shall terminate every switch
    clause") since functions with noreturn attribute are considered
    as allowed terminals for switch clauses.
    
    Point (2) addresses several violations of MISRA C:2012 Rule 17.7
    ("The value returned by a function having non-void return type
    shall be used").
    
    While there also zap "extern".
    
    No functional change.
    
    Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/include/asm/uaccess.h b/xen/arch/x86/include/asm/uaccess.h
index 7443519d5b..55bc6932fd 100644
--- a/xen/arch/x86/include/asm/uaccess.h
+++ b/xen/arch/x86/include/asm/uaccess.h
@@ -21,8 +21,8 @@ unsigned int copy_from_guest_ll(void *to, const void __user *from, unsigned int
 unsigned int copy_to_unsafe_ll(void *to, const void *from, unsigned int n);
 unsigned int copy_from_unsafe_ll(void *to, const void *from, unsigned int n);
 
-extern long __get_user_bad(void);
-extern void __put_user_bad(void);
+void noreturn __get_user_bad(void);
+void noreturn __put_user_bad(void);
 
 #define UA_KEEP(args...) args
 #define UA_DROP(args...)
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:01:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:01:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684348.1064160 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6pH-00071D-5d; Thu, 22 Feb 2024 11:01:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684348.1064160; Thu, 22 Feb 2024 11:01:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6pH-000715-33; Thu, 22 Feb 2024 11:01:15 +0000
Received: by outflank-mailman (input) for mailman id 684348;
 Thu, 22 Feb 2024 11:01:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6pG-00070j-5z
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:01:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6pG-0004mu-5G
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:01:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6pG-0002MN-3u
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:01:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=vKQW2P0SQRn5lu5d0WV9grdg6TRAq8ddeVZN1QVqXcs=; b=2Wij46f1eVLtacRc0U6/igiSad
	uKjaP80CPYuYwMU62Cix4hAuFfVPZl92Ca7Fts4K6KwjGARZb9b7xAtWGWvXWvYawJoNMbKRkQcmp
	9NaBjVlVONaJbZc+gKWnU6KBXRQZz0fJ47P5z9xuoZ6iYO6b1JM5Exf7BMVhcGGDHNVc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86emul: add missing EVEX.R' checks
Message-Id: <E1rd6pG-0002MN-3u@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:01:14 +0000

commit cb319824bfa8d3c9ea0410cc71daaedc3e11aa2a
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 11:54:07 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:54:07 2024 +0100

    x86emul: add missing EVEX.R' checks
    
    EVEX.R' is not ignored in 64-bit code when encoding a GPR or mask
    register. While for mask registers suitable checks are in place (there
    also covering EVEX.R), they were missing for the few cases where in
    EVEX-encoded instructions ModR/M.reg encodes a GPR. While for VPEXTRW
    the bit is replaced before an emulation stub is invoked, for
    VCVT{,T}{S,D,H}2{,U}SI this actually would have led to #UD from inside
    an emulation stub, in turn raising #UD to the guest, but accompanied by
    log messages indicating something's wrong in Xen nevertheless.
    
    Fixes: 001bd91ad864 ("x86emul: support AVX512{F,BW,DQ} extract insns")
    Fixes: baf4a376f550 ("x86emul: support AVX512F legacy-equivalent scalar int/FP conversion insns")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/x86_emulate/x86_emulate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index ed710596dc..2d5c1de8ec 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -3686,7 +3686,8 @@ x86_emulate(
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x2d): /* vcvts{s,d}2si xmm/mem,reg */
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x78): /* vcvtts{s,d}2usi xmm/mem,reg */
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x79): /* vcvts{s,d}2usi xmm/mem,reg */
-        generate_exception_if((evex.reg != 0xf || !evex.RX || evex.opmsk ||
+        generate_exception_if((evex.reg != 0xf || !evex.RX || !evex.R ||
+                               evex.opmsk ||
                                (ea.type != OP_REG && evex.brs)),
                               X86_EXC_UD);
         host_and_vcpu_must_have(avx512f);
@@ -7327,7 +7328,7 @@ x86_emulate(
         goto pextr;
 
     case X86EMUL_OPC_EVEX_66(0x0f, 0xc5):   /* vpextrw $imm8,xmm,reg */
-        generate_exception_if(ea.type != OP_REG, X86_EXC_UD);
+        generate_exception_if(ea.type != OP_REG || !evex.R, X86_EXC_UD);
         /* Convert to alternative encoding: We want to use a memory operand. */
         evex.opcx = ext_0f3a;
         b = 0x15;
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:01:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:01:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684351.1064165 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6pR-0007Bv-7G; Thu, 22 Feb 2024 11:01:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684351.1064165; Thu, 22 Feb 2024 11:01:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd6pR-0007Bn-4Q; Thu, 22 Feb 2024 11:01:25 +0000
Received: by outflank-mailman (input) for mailman id 684351;
 Thu, 22 Feb 2024 11:01:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6pQ-0007BP-8m
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:01:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6pQ-0004n3-8C
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:01:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd6pQ-0002NQ-7M
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:01:24 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=sajant4DtOn8391OWcy8N6px3OHzRRn8nqW5qTw726Y=; b=oBFOYrdDlDdEVFZOhIxAdskYfX
	WViXezzU2w7t+sp0dpUxYB+VBnGAQ1f0yW8Iz20R12QLix2XrNXWBu1cxsT11CSeQehWgUvggQxy9
	pJCtFb/ogLd0cBEyu25MiGvgV2JmbYn6GXuyKxZQTcT0GgH2HW5rE41QB/OupziCZzKE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86emul: make run32 test harness goal work again
Message-Id: <E1rd6pQ-0002NQ-7M@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:01:24 +0000

commit 9ee7dc877b8754ce2fc82500feea52c04d4e6409
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 11:54:32 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:54:32 2024 +0100

    x86emul: make run32 test harness goal work again
    
    When re-working library call wrapping the sed invocation didn't account
    for all sources living in the parent directory when building the 32-bit
    harness binary.
    
    Fixes: 6fba45ca3be1 ("x86emul: rework wrapping of libc functions in test and fuzzing harnesses")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 tools/tests/x86_emulator/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/tests/x86_emulator/Makefile b/tools/tests/x86_emulator/Makefile
index b45ad09c28..834b2112e7 100644
--- a/tools/tests/x86_emulator/Makefile
+++ b/tools/tests/x86_emulator/Makefile
@@ -255,7 +255,8 @@ OBJS := x86-emulate.o cpuid.o test_x86_emulator.o evex-disp8.o predicates.o wrap
 OBJS += x86_emulate/0f01.o x86_emulate/0fae.o x86_emulate/0fc7.o
 OBJS += x86_emulate/blk.o x86_emulate/decode.o x86_emulate/fpu.o x86_emulate/util.o
 
-WRAPPED := $(shell sed -n 's,^ *WRAP(\([[:alnum:]_]*\));,\1,p' x86-emulate.h)
+WRAPPED := $(shell sed -n 's,^ *WRAP(\([[:alnum:]_]*\));,\1,p' \
+                       $(firstword $(wildcard ../x86-emulate.h) x86-emulate.h))
 
 $(TARGET): $(OBJS)
 	$(HOSTCC) $(HOSTCFLAGS) $(addprefix -Wl$(comma)--wrap=,$(WRAPPED)) -o $@ $^
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:22:09 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:22:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684375.1064199 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd79R-0003oQ-Ax; Thu, 22 Feb 2024 11:22:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684375.1064199; Thu, 22 Feb 2024 11:22:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd79R-0003oI-8J; Thu, 22 Feb 2024 11:22:05 +0000
Received: by outflank-mailman (input) for mailman id 684375;
 Thu, 22 Feb 2024 11:22:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd79Q-0003oC-6o
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd79Q-00059Y-54
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd79Q-0003iE-46
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=zSnyRaN83FOS423CNjkdhTWpIcwVyGTzi3mffjyXjf8=; b=bLSXV6iy1KkG+IXCiBOsovYLZi
	R2cmHudcY1wveMBrPjJNHAb+lg6wM834KL1bXY0PUwsjTwzZX2eH80rIqvWke8W44hiji0VZuSRLk
	UFgQVSV5kvzyBH45530Ay0sVnYyN+hE6r1ELaqXPsL4AP+G1kO70+XwWOTkYPO4N2KNw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] serial: fake IRQ-regs context in poll handlers
Message-Id: <E1rd79Q-0003iE-46@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:22:04 +0000

commit ba3c8373cd67845fd59877959dd3650ec6c557d7
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 12:10:38 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 12:10:38 2024 +0100

    serial: fake IRQ-regs context in poll handlers
    
    In preparation of dropping the register parameters from
    serial_[rt]x_interrupt() and in turn from IRQ handler functions,
    register state needs making available another way for the few key
    handlers which need it. Fake IRQ-like state.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/drivers/char/ehci-dbgp.c | 6 ++++++
 xen/drivers/char/ns16550.c   | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/xen/drivers/char/ehci-dbgp.c b/xen/drivers/char/ehci-dbgp.c
index bbf4e51c02..1497fe7c84 100644
--- a/xen/drivers/char/ehci-dbgp.c
+++ b/xen/drivers/char/ehci-dbgp.c
@@ -1253,6 +1253,7 @@ static void cf_check _ehci_dbgp_poll(struct cpu_user_regs *regs)
     unsigned long flags;
     unsigned int timeout = MICROSECS(DBGP_CHECK_INTERVAL);
     bool empty = false;
+    struct cpu_user_regs *old_regs;
 
     if ( !dbgp->ehci_debug )
         return;
@@ -1268,12 +1269,17 @@ static void cf_check _ehci_dbgp_poll(struct cpu_user_regs *regs)
         spin_unlock_irqrestore(&port->tx_lock, flags);
     }
 
+    /* Mimic interrupt context. */
+    old_regs = set_irq_regs(regs);
+
     if ( dbgp->in.chunk )
         serial_rx_interrupt(port, regs);
 
     if ( empty )
         serial_tx_interrupt(port, regs);
 
+    set_irq_regs(old_regs);
+
     if ( spin_trylock_irqsave(&port->tx_lock, flags) )
     {
         if ( dbgp->state == dbgp_idle && !dbgp->in.chunk &&
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index 97bf098534..664d490571 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -211,10 +211,14 @@ static void cf_check __ns16550_poll(struct cpu_user_regs *regs)
 {
     struct serial_port *port = this_cpu(poll_port);
     struct ns16550 *uart = port->uart;
+    struct cpu_user_regs *old_regs;
 
     if ( uart->intr_works )
         return; /* Interrupts work - no more polling */
 
+    /* Mimic interrupt context. */
+    old_regs = set_irq_regs(regs);
+
     while ( ns_read_reg(uart, UART_LSR) & UART_LSR_DR )
     {
         if ( ns16550_ioport_invalid(uart) )
@@ -227,6 +231,7 @@ static void cf_check __ns16550_poll(struct cpu_user_regs *regs)
         serial_tx_interrupt(port, regs);
 
 out:
+    set_irq_regs(old_regs);
     set_timer(&uart->timer, NOW() + MILLISECS(uart->timeout_ms));
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:22:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:22:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684376.1064204 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd79b-0003tF-Cg; Thu, 22 Feb 2024 11:22:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684376.1064204; Thu, 22 Feb 2024 11:22:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd79b-0003t8-9k; Thu, 22 Feb 2024 11:22:15 +0000
Received: by outflank-mailman (input) for mailman id 684376;
 Thu, 22 Feb 2024 11:22:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd79a-0003t0-8m
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd79a-00059i-86
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd79a-0003ka-7D
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=75QyNY2n95oVMWWnXfr9zami6G3eE5H7+tqO0l4MPKE=; b=J90i/wIaL9J/hQhjTcqGt34+at
	dE0LZtEb++5D4nmmg3Q7GFcfG3np1GrD7W+HZyZpkWZkAmD8XWrYrx1OKAZtBKsEWzApKHK/+GX89
	vz87Cj1LUT8zZxrvQckCTfAtWHZlZFpENSFEomxFKLMxAnZ8IYGD0eUHxXB96sZdyCOA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] keyhandler: drop regs parameter from handle_keyregs()
Message-Id: <E1rd79a-0003ka-7D@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:22:14 +0000

commit feb338d843de4dd0cce78f6be68b3744e91d5567
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 12:11:47 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 12:11:47 2024 +0100

    keyhandler: drop regs parameter from handle_keyregs()
    
    In preparation for further removal of regs parameters, drop it here. In
    the two places where it's actually needed, retrieve IRQ context if
    available, or else guest context.
    
    Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/common/keyhandler.c      | 25 +++++++++++--------------
 xen/common/sysctl.c          |  2 +-
 xen/drivers/char/console.c   |  8 ++++----
 xen/include/xen/keyhandler.h |  5 ++---
 4 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c
index f131034d33..9c23a540e5 100644
--- a/xen/common/keyhandler.c
+++ b/xen/common/keyhandler.c
@@ -73,12 +73,12 @@ static struct keyhandler {
 
 static void cf_check keypress_action(void *unused)
 {
-    handle_keypress(keypress_key, NULL);
+    handle_keypress(keypress_key, true);
 }
 
 static DECLARE_TASKLET(keypress_tasklet, keypress_action, NULL);
 
-void handle_keypress(unsigned char key, struct cpu_user_regs *regs)
+void handle_keypress(unsigned char key, bool need_context)
 {
     struct keyhandler *h;
 
@@ -88,7 +88,7 @@ void handle_keypress(unsigned char key, struct cpu_user_regs *regs)
     if ( !in_irq() || h->irq_callback )
     {
         console_start_log_everything();
-        h->irq_callback ? h->irq_fn(key, regs) : h->fn(key);
+        h->irq_callback ? h->irq_fn(key, need_context) : h->fn(key);
         console_end_log_everything();
     }
     else
@@ -169,7 +169,7 @@ void cf_check dump_execstate(struct cpu_user_regs *regs)
 }
 
 static void cf_check dump_registers(
-    unsigned char key, struct cpu_user_regs *regs)
+    unsigned char key, bool need_context)
 {
     unsigned int cpu;
 
@@ -182,8 +182,8 @@ static void cf_check dump_registers(
     cpumask_copy(&dump_execstate_mask, &cpu_online_map);
 
     /* Get local execution state out immediately, in case we get stuck. */
-    if ( regs )
-        dump_execstate(regs);
+    if ( !need_context )
+        dump_execstate(get_irq_regs() ?: guest_cpu_user_regs());
     else
         run_in_exception_handler(dump_execstate);
 
@@ -245,8 +245,7 @@ static void cf_check dump_hwdom_registers(unsigned char key)
     }
 }
 
-static void cf_check reboot_machine(
-    unsigned char key, struct cpu_user_regs *regs)
+static void cf_check reboot_machine(unsigned char key, bool unused)
 {
     printk("'%c' pressed -> rebooting machine\n", key);
     machine_restart(0);
@@ -474,8 +473,7 @@ static void cf_check run_all_nonirq_keyhandlers(void *unused)
 static DECLARE_TASKLET(run_all_keyhandlers_tasklet,
                        run_all_nonirq_keyhandlers, NULL);
 
-static void cf_check run_all_keyhandlers(
-    unsigned char key, struct cpu_user_regs *regs)
+static void cf_check run_all_keyhandlers(unsigned char key, bool need_context)
 {
     struct keyhandler *h;
     unsigned int k;
@@ -491,7 +489,7 @@ static void cf_check run_all_keyhandlers(
         if ( !h->irq_fn || !h->diagnostic || !h->irq_callback )
             continue;
         printk("[%c: %s]\n", k, h->desc);
-        h->irq_fn(k, regs);
+        h->irq_fn(k, need_context);
     }
 
     watchdog_enable();
@@ -500,8 +498,7 @@ static void cf_check run_all_keyhandlers(
     tasklet_schedule(&run_all_keyhandlers_tasklet);
 }
 
-static void cf_check do_toggle_alt_key(
-    unsigned char key, struct cpu_user_regs *regs)
+static void cf_check do_toggle_alt_key(unsigned char key, bool unused)
 {
     alt_key_handling = !alt_key_handling;
     printk("'%c' pressed -> using %s key handling\n", key,
@@ -566,7 +563,7 @@ void keyhandler_crash_action(enum crash_reason reason)
         if ( *action == '+' )
             mdelay(10);
         else
-            handle_keypress(*action, NULL);
+            handle_keypress(*action, true);
         action++;
     }
 }
diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index 2906f3f294..d02f44fe3a 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -134,7 +134,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
         {
             if ( copy_from_guest_offset(&c, op->u.debug_keys.keys, i, 1) )
                 goto out;
-            handle_keypress(c, guest_cpu_user_regs());
+            handle_keypress(c, false);
         }
         ret = 0;
         copyback = 0;
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index dce0226e87..6e66d0eff1 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -279,7 +279,7 @@ static int *__read_mostly upper_thresh_adj = &xenlog_upper_thresh;
 static int *__read_mostly lower_thresh_adj = &xenlog_lower_thresh;
 static const char *__read_mostly thresh_adj = "standard";
 
-static void cf_check do_toggle_guest(unsigned char key, struct cpu_user_regs *regs)
+static void cf_check do_toggle_guest(unsigned char key, bool unused)
 {
     if ( upper_thresh_adj == &xenlog_upper_thresh )
     {
@@ -306,13 +306,13 @@ static void do_adj_thresh(unsigned char key)
            loglvl_str(*upper_thresh_adj));
 }
 
-static void cf_check do_inc_thresh(unsigned char key, struct cpu_user_regs *regs)
+static void cf_check do_inc_thresh(unsigned char key, bool unused)
 {
     ++*lower_thresh_adj;
     do_adj_thresh(key);
 }
 
-static void cf_check do_dec_thresh(unsigned char key, struct cpu_user_regs *regs)
+static void cf_check do_dec_thresh(unsigned char key, bool unused)
 {
     if ( *lower_thresh_adj )
         --*lower_thresh_adj;
@@ -531,7 +531,7 @@ static void __serial_rx(char c, struct cpu_user_regs *regs)
     switch ( console_rx )
     {
     case 0:
-        return handle_keypress(c, regs);
+        return handle_keypress(c, false);
 
     case 1:
         /*
diff --git a/xen/include/xen/keyhandler.h b/xen/include/xen/keyhandler.h
index 5c6598af98..6fee878fdf 100644
--- a/xen/include/xen/keyhandler.h
+++ b/xen/include/xen/keyhandler.h
@@ -24,9 +24,8 @@ typedef void (keyhandler_fn_t)(unsigned char key);
  *
  * Called in hardirq context with interrupts disabled.
  */
-struct cpu_user_regs;
 typedef void (irq_keyhandler_fn_t)(unsigned char key,
-                                   struct cpu_user_regs *regs);
+                                   bool need_context);
 
 /* Initialize keytable with default handlers. */
 void initialize_keytable(void);
@@ -46,7 +45,7 @@ void register_irq_keyhandler(unsigned char key,
                              bool diagnostic);
 
 /* Inject a keypress into the key-handling subsystem. */
-extern void handle_keypress(unsigned char key, struct cpu_user_regs *regs);
+extern void handle_keypress(unsigned char key, bool need_context);
 
 enum crash_reason {
     CRASHREASON_PANIC,
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:22:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:22:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684377.1064207 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd79l-0003wx-E3; Thu, 22 Feb 2024 11:22:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684377.1064207; Thu, 22 Feb 2024 11:22:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd79l-0003wp-BB; Thu, 22 Feb 2024 11:22:25 +0000
Received: by outflank-mailman (input) for mailman id 684377;
 Thu, 22 Feb 2024 11:22:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd79k-0003wh-Bt
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd79k-00059u-BC
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd79k-0003lB-AD
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:24 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=TE8XMOmlX7sSZiyGGSMquGXlbM2ZvkMEin4CBguSVWg=; b=Yoop6SFSoVCmRagmPWP12UA+QC
	vhaELH/sTQQxTdq8K5iU/aeCvxFtdRvxNUPg2+V8yDXaEttCxGjLO5KuAxwM+cFQWUiMBya1jGJyL
	c0DpAytPMI7yRKXTujR8IphBj2LV+hUnh0eCYrGCR4Bi1K4fvzwOz/pZvIS/Qb4RodHA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] serial: drop serial_rx_fn's regs parameter
Message-Id: <E1rd79k-0003lB-AD@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:22:24 +0000

commit 4f09e5102740b3dd2d269ea04de93fd126f399d1
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 12:12:34 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 12:12:34 2024 +0100

    serial: drop serial_rx_fn's regs parameter
    
    It's simply not needed anymore.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/drivers/char/console.c        | 8 ++++----
 xen/drivers/char/serial.c         | 2 +-
 xen/drivers/char/xen_pv_console.c | 2 +-
 xen/include/xen/serial.h          | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 6e66d0eff1..d2cb0530b2 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -526,7 +526,7 @@ static void switch_serial_input(void)
     printk("\n");
 }
 
-static void __serial_rx(char c, struct cpu_user_regs *regs)
+static void __serial_rx(char c)
 {
     switch ( console_rx )
     {
@@ -578,7 +578,7 @@ static void __serial_rx(char c, struct cpu_user_regs *regs)
 #endif
 }
 
-static void cf_check serial_rx(char c, struct cpu_user_regs *regs)
+static void cf_check serial_rx(char c)
 {
     static int switch_code_count = 0;
 
@@ -594,10 +594,10 @@ static void cf_check serial_rx(char c, struct cpu_user_regs *regs)
     }
 
     for ( ; switch_code_count != 0; switch_code_count-- )
-        __serial_rx(switch_code, regs);
+        __serial_rx(switch_code);
 
     /* Finally process the just-received character. */
-    __serial_rx(c, regs);
+    __serial_rx(c);
 }
 
 static void cf_check notify_dom0_con_ring(void *unused)
diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
index 93e217d348..0b30326843 100644
--- a/xen/drivers/char/serial.c
+++ b/xen/drivers/char/serial.c
@@ -68,7 +68,7 @@ void serial_rx_interrupt(struct serial_port *port, struct cpu_user_regs *regs)
     spin_unlock_irqrestore(&port->rx_lock, flags);
 
     if ( fn != NULL )
-        (*fn)(c & 0x7f, regs);
+        fn(c & 0x7f);
 }
 
 void serial_tx_interrupt(struct serial_port *port, struct cpu_user_regs *regs)
diff --git a/xen/drivers/char/xen_pv_console.c b/xen/drivers/char/xen_pv_console.c
index 1536bdaf52..c4c5623971 100644
--- a/xen/drivers/char/xen_pv_console.c
+++ b/xen/drivers/char/xen_pv_console.c
@@ -118,7 +118,7 @@ size_t pv_console_rx(struct cpu_user_regs *regs)
     {
         c = cons_ring->in[MASK_XENCONS_IDX(cons++, cons_ring->in)];
         if ( cons_rx_handler )
-            cons_rx_handler(c, regs);
+            cons_rx_handler(c);
         recv++;
     }
 
diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
index 7548bb7324..92979e37e2 100644
--- a/xen/include/xen/serial.h
+++ b/xen/include/xen/serial.h
@@ -15,7 +15,7 @@
 struct cpu_user_regs;
 
 /* Register a character-receive hook on the specified COM port. */
-typedef void (*serial_rx_fn)(char c, struct cpu_user_regs *regs);
+typedef void (*serial_rx_fn)(char c);
 void serial_set_rx_handler(int handle, serial_rx_fn fn);
 
 /* Number of characters we buffer for a polling receiver. */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:22:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:22:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684378.1064210 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd79v-0003zm-F6; Thu, 22 Feb 2024 11:22:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684378.1064210; Thu, 22 Feb 2024 11:22:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd79v-0003ze-Ca; Thu, 22 Feb 2024 11:22:35 +0000
Received: by outflank-mailman (input) for mailman id 684378;
 Thu, 22 Feb 2024 11:22:34 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd79u-0003zV-FK
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd79u-0005A8-Ec
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd79u-0003lp-DT
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:34 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=i/RF/W22bw3rRGevmD2Cz3k/fhWkYEf90D1JxvSau60=; b=Fyqbb9YQ7uvnmHrslO3qb9Rxvs
	X/bvD3zOLAM1IvfTi28QPPG3KTypjTZy7712v7Hm7/oh4k0YEq31a+leqzNs0/xOT+2k2rcFmUPDi
	Ai4RaZhrWGpwLLYVIZakMa3v+vrsgppPXjPzvQnxpTrINoHzRYoclGO79MM4SOoIQTJE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] PV-shim: drop pv_console_rx()'s regs parameter
Message-Id: <E1rd79u-0003lp-DT@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:22:34 +0000

commit e1e0579afa0840e01ca2bfb1cbc8a4aaadce7794
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 12:13:33 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 12:13:33 2024 +0100

    PV-shim: drop pv_console_rx()'s regs parameter
    
    It's not needed anymore. This is in preparation of dropping the register
    parameters from IRQ handler functions.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/guest/xen/xen.c      | 2 +-
 xen/drivers/char/xen_pv_console.c | 2 +-
 xen/include/xen/pv_console.h      | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c
index 44a689d439..ec66fc84d1 100644
--- a/xen/arch/x86/guest/xen/xen.c
+++ b/xen/arch/x86/guest/xen/xen.c
@@ -181,7 +181,7 @@ static void cf_check xen_evtchn_upcall(struct cpu_user_regs *regs)
             port += l1 * BITS_PER_LONG;
 
             if ( pv_console && port == pv_console_evtchn() )
-                pv_console_rx(regs);
+                pv_console_rx();
             else if ( pv_shim )
                 pv_shim_inject_evtchn(port);
         }
diff --git a/xen/drivers/char/xen_pv_console.c b/xen/drivers/char/xen_pv_console.c
index c4c5623971..25c349c22f 100644
--- a/xen/drivers/char/xen_pv_console.c
+++ b/xen/drivers/char/xen_pv_console.c
@@ -94,7 +94,7 @@ evtchn_port_t pv_console_evtchn(void)
     return cons_evtchn;
 }
 
-size_t pv_console_rx(struct cpu_user_regs *regs)
+size_t pv_console_rx(void)
 {
     char c;
     XENCONS_RING_IDX cons, prod;
diff --git a/xen/include/xen/pv_console.h b/xen/include/xen/pv_console.h
index 55b20323fb..2133aa71cb 100644
--- a/xen/include/xen/pv_console.h
+++ b/xen/include/xen/pv_console.h
@@ -9,7 +9,7 @@ void pv_console_init(void);
 void pv_console_set_rx_handler(serial_rx_fn fn);
 void pv_console_init_postirq(void);
 void pv_console_puts(const char *buf, size_t nr);
-size_t pv_console_rx(struct cpu_user_regs *regs);
+size_t pv_console_rx(void);
 evtchn_port_t pv_console_evtchn(void);
 
 #else
@@ -18,7 +18,7 @@ static inline void pv_console_init(void) {}
 static inline void pv_console_set_rx_handler(serial_rx_fn fn) { }
 static inline void pv_console_init_postirq(void) { }
 static inline void pv_console_puts(const char *buf, size_t nr) { }
-static inline size_t pv_console_rx(struct cpu_user_regs *regs) { return 0; }
+static inline size_t pv_console_rx(void) { return 0; }
 
 #endif /* !CONFIG_XEN_GUEST */
 #endif /* __XEN_PV_CONSOLE_H__ */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:22:45 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:22:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684379.1064215 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd7A5-000440-I2; Thu, 22 Feb 2024 11:22:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684379.1064215; Thu, 22 Feb 2024 11:22:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd7A5-00043s-FL; Thu, 22 Feb 2024 11:22:45 +0000
Received: by outflank-mailman (input) for mailman id 684379;
 Thu, 22 Feb 2024 11:22:44 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd7A4-00043a-KY
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:44 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd7A4-0005AF-Jo
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:44 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd7A4-0003mK-H6
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:44 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=6Seq4ExWRcaz+Qo0JPh/xXWDJlQcozdAUfl8WnDDC9E=; b=iavWs6PQ4C87o8x3Z2zHPVv4h8
	K9fqXa7SxYz9jUUUSUMQ/aJpS8kAuTIB+PeHSGX6Nqs2sYZkTeR6qwLPRXwu7L6J0plxb0PqqYfKO
	8A/mMm4pIiw+16zQq0CYu3GX2M25541d4ESf+qkidXG6OReoLZsMJ1JA5JZDSKjFgExg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] serial: drop serial_[rt]x_interrupt()'s regs parameter
Message-Id: <E1rd7A4-0003mK-H6@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:22:44 +0000

commit b31e753fe799b226b5e9d500f96588a8657d4a66
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 12:14:19 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 12:14:19 2024 +0100

    serial: drop serial_[rt]x_interrupt()'s regs parameter
    
    They're simply not needed anymore.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/drivers/char/cadence-uart.c    | 2 +-
 xen/drivers/char/ehci-dbgp.c       | 4 ++--
 xen/drivers/char/exynos4210-uart.c | 4 ++--
 xen/drivers/char/imx-lpuart.c      | 4 ++--
 xen/drivers/char/meson-uart.c      | 4 ++--
 xen/drivers/char/mvebu-uart.c      | 4 ++--
 xen/drivers/char/ns16550.c         | 8 ++++----
 xen/drivers/char/omap-uart.c       | 4 ++--
 xen/drivers/char/pl011.c           | 4 ++--
 xen/drivers/char/scif-uart.c       | 4 ++--
 xen/drivers/char/serial.c          | 4 ++--
 xen/drivers/char/xhci-dbc.c        | 5 +++--
 xen/include/xen/serial.h           | 6 ++----
 13 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/xen/drivers/char/cadence-uart.c b/xen/drivers/char/cadence-uart.c
index c38d7ed143..0b670c64ed 100644
--- a/xen/drivers/char/cadence-uart.c
+++ b/xen/drivers/char/cadence-uart.c
@@ -51,7 +51,7 @@ static void cuart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
         /* ACK.  */
         if ( status & UART_SR_INTR_RTRIG )
         {
-            serial_rx_interrupt(port, regs);
+            serial_rx_interrupt(port);
             cuart_write(uart, R_UART_CISR, UART_SR_INTR_RTRIG);
         }
     } while ( status & UART_SR_INTR_RTRIG );
diff --git a/xen/drivers/char/ehci-dbgp.c b/xen/drivers/char/ehci-dbgp.c
index 1497fe7c84..2bb55418a7 100644
--- a/xen/drivers/char/ehci-dbgp.c
+++ b/xen/drivers/char/ehci-dbgp.c
@@ -1273,10 +1273,10 @@ static void cf_check _ehci_dbgp_poll(struct cpu_user_regs *regs)
     old_regs = set_irq_regs(regs);
 
     if ( dbgp->in.chunk )
-        serial_rx_interrupt(port, regs);
+        serial_rx_interrupt(port);
 
     if ( empty )
-        serial_tx_interrupt(port, regs);
+        serial_tx_interrupt(port);
 
     set_irq_regs(old_regs);
 
diff --git a/xen/drivers/char/exynos4210-uart.c b/xen/drivers/char/exynos4210-uart.c
index 2503392ccd..5c53860df6 100644
--- a/xen/drivers/char/exynos4210-uart.c
+++ b/xen/drivers/char/exynos4210-uart.c
@@ -81,7 +81,7 @@ static void exynos4210_uart_interrupt(int irq, void *data, struct cpu_user_regs
         if ( status & (UINTM_RXD | UINTM_ERROR) )
         {
             /* uart->regs[UINTM] |= RXD|ERROR; */
-            serial_rx_interrupt(port, regs);
+            serial_rx_interrupt(port);
             /* uart->regs[UINTM] &= ~(RXD|ERROR); */
             exynos4210_write(uart, UINTP, UINTM_RXD | UINTM_ERROR);
         }
@@ -89,7 +89,7 @@ static void exynos4210_uart_interrupt(int irq, void *data, struct cpu_user_regs
         if ( status & (UINTM_TXD | UINTM_MODEM) )
         {
             /* uart->regs[UINTM] |= TXD|MODEM; */
-            serial_tx_interrupt(port, regs);
+            serial_tx_interrupt(port);
             /* uart->regs[UINTM] &= ~(TXD|MODEM); */
             exynos4210_write(uart, UINTP, UINTM_TXD | UINTM_MODEM);
         }
diff --git a/xen/drivers/char/imx-lpuart.c b/xen/drivers/char/imx-lpuart.c
index 77f70c2719..f5b341e20b 100644
--- a/xen/drivers/char/imx-lpuart.c
+++ b/xen/drivers/char/imx-lpuart.c
@@ -48,10 +48,10 @@ static void imx_lpuart_interrupt(int irq, void *data,
     rxcnt = imx_lpuart_read(uart, UARTWATER) >> UARTWATER_RXCNT_OFF;
 
     if ( (sts & UARTSTAT_RDRF) || (rxcnt > 0) )
-	    serial_rx_interrupt(port, regs);
+	    serial_rx_interrupt(port);
 
     if ( sts & UARTSTAT_TDRE )
-	    serial_tx_interrupt(port, regs);
+	    serial_tx_interrupt(port);
 
     imx_lpuart_write(uart, UARTSTAT, sts);
 }
diff --git a/xen/drivers/char/meson-uart.c b/xen/drivers/char/meson-uart.c
index c627328122..640c29dd05 100644
--- a/xen/drivers/char/meson-uart.c
+++ b/xen/drivers/char/meson-uart.c
@@ -69,10 +69,10 @@ static void meson_uart_interrupt(int irq, void *data,
     uint32_t st = readl(uart->regs + AML_UART_STATUS_REG);
 
     if ( !(st & AML_UART_RX_FIFO_EMPTY) )
-        serial_rx_interrupt(port, regs);
+        serial_rx_interrupt(port);
 
     if ( !(st & AML_UART_TX_FIFO_FULL) )
-        serial_tx_interrupt(port, regs);
+        serial_tx_interrupt(port);
 }
 
 static void __init meson_uart_init_preirq(struct serial_port *port)
diff --git a/xen/drivers/char/mvebu-uart.c b/xen/drivers/char/mvebu-uart.c
index cc55173513..57c1259224 100644
--- a/xen/drivers/char/mvebu-uart.c
+++ b/xen/drivers/char/mvebu-uart.c
@@ -76,10 +76,10 @@ static void mvebu3700_uart_interrupt(int irq, void *data,
 
     if ( st & (STATUS_RX_RDY | STATUS_OVR_ERR | STATUS_FRM_ERR |
                STATUS_BRK_DET) )
-        serial_rx_interrupt(port, regs);
+        serial_rx_interrupt(port);
 
     if ( st & STATUS_TX_RDY )
-        serial_tx_interrupt(port, regs);
+        serial_tx_interrupt(port);
 }
 
 static void __init mvebu3700_uart_init_preirq(struct serial_port *port)
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index 664d490571..91f0624d74 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -188,9 +188,9 @@ static void cf_check ns16550_interrupt(
         u8 lsr = ns_read_reg(uart, UART_LSR);
 
         if ( (lsr & uart->lsr_mask) == uart->lsr_mask )
-            serial_tx_interrupt(port, regs);
+            serial_tx_interrupt(port);
         if ( lsr & UART_LSR_DR )
-            serial_rx_interrupt(port, regs);
+            serial_rx_interrupt(port);
 
         /* A "busy-detect" condition is observed on Allwinner/sunxi UART
          * after LCR is written during setup. It needs to be cleared at
@@ -224,11 +224,11 @@ static void cf_check __ns16550_poll(struct cpu_user_regs *regs)
         if ( ns16550_ioport_invalid(uart) )
             goto out;
 
-        serial_rx_interrupt(port, regs);
+        serial_rx_interrupt(port);
     }
 
     if ( ( ns_read_reg(uart, UART_LSR) & uart->lsr_mask ) == uart->lsr_mask )
-        serial_tx_interrupt(port, regs);
+        serial_tx_interrupt(port);
 
 out:
     set_irq_regs(old_regs);
diff --git a/xen/drivers/char/omap-uart.c b/xen/drivers/char/omap-uart.c
index 8e643cb039..fb842b1707 100644
--- a/xen/drivers/char/omap-uart.c
+++ b/xen/drivers/char/omap-uart.c
@@ -70,9 +70,9 @@ static void omap_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
     {
         lsr = omap_read(uart, UART_LSR) & 0xff;
 	if ( lsr & UART_LSR_THRE )
-            serial_tx_interrupt(port, regs);
+            serial_tx_interrupt(port);
 	if ( lsr & UART_LSR_DR )
-            serial_rx_interrupt(port, regs);
+            serial_rx_interrupt(port);
 
         if ( port->txbufc == port->txbufp ) {
             reg = omap_read(uart, UART_IER);
diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
index 513b373b2e..cb7c4affa5 100644
--- a/xen/drivers/char/pl011.c
+++ b/xen/drivers/char/pl011.c
@@ -95,7 +95,7 @@ static void pl011_interrupt(int irq, void *data, struct cpu_user_regs *regs)
             pl011_write(uart, ICR, status & ~(TXI|RTI|RXI));
 
             if ( status & (RTI|RXI) )
-                serial_rx_interrupt(port, regs);
+                serial_rx_interrupt(port);
 
             /* TODO
                 if ( status & (DSRMI|DCDMI|CTSMI|RIMI) )
@@ -103,7 +103,7 @@ static void pl011_interrupt(int irq, void *data, struct cpu_user_regs *regs)
             */
 
             if ( status & (TXI) )
-                serial_tx_interrupt(port, regs);
+                serial_tx_interrupt(port);
 
             status = pl011_intr_status(uart);
         } while (status != 0);
diff --git a/xen/drivers/char/scif-uart.c b/xen/drivers/char/scif-uart.c
index 1b28ba90e9..d5de8931b2 100644
--- a/xen/drivers/char/scif-uart.c
+++ b/xen/drivers/char/scif-uart.c
@@ -119,11 +119,11 @@ static void scif_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
     {
         /* TX Interrupt */
         if ( status & SCFSR_TDFE )
-            serial_tx_interrupt(port, regs);
+            serial_tx_interrupt(port);
 
         /* RX Interrupt */
         if ( status & (SCFSR_RDF | SCFSR_DR) )
-            serial_rx_interrupt(port, regs);
+            serial_rx_interrupt(port);
 
         /* Error Interrupt */
         if ( status & params->error_mask )
diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
index 0b30326843..f28d8557c0 100644
--- a/xen/drivers/char/serial.c
+++ b/xen/drivers/char/serial.c
@@ -45,7 +45,7 @@ static inline void serial_stop_tx(struct serial_port *port)
         port->driver->stop_tx(port);
 }
 
-void serial_rx_interrupt(struct serial_port *port, struct cpu_user_regs *regs)
+void serial_rx_interrupt(struct serial_port *port)
 {
     char c;
     serial_rx_fn fn = NULL;
@@ -71,7 +71,7 @@ void serial_rx_interrupt(struct serial_port *port, struct cpu_user_regs *regs)
         fn(c & 0x7f);
 }
 
-void serial_tx_interrupt(struct serial_port *port, struct cpu_user_regs *regs)
+void serial_tx_interrupt(struct serial_port *port)
 {
     int i, n;
     unsigned long flags;
diff --git a/xen/drivers/char/xhci-dbc.c b/xen/drivers/char/xhci-dbc.c
index 60b781f872..3bf389be7d 100644
--- a/xen/drivers/char/xhci-dbc.c
+++ b/xen/drivers/char/xhci-dbc.c
@@ -1176,9 +1176,10 @@ static void cf_check dbc_uart_poll(void *data)
     }
 
     while ( dbc_work_ring_size(&dbc->dbc_iwork) )
-        serial_rx_interrupt(port, guest_cpu_user_regs());
+        serial_rx_interrupt(port);
+
+    serial_tx_interrupt(port);
 
-    serial_tx_interrupt(port, guest_cpu_user_regs());
     set_timer(&uart->timer, NOW() + MICROSECS(DBC_POLL_INTERVAL));
 }
 
diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
index 92979e37e2..3d21207a3d 100644
--- a/xen/include/xen/serial.h
+++ b/xen/include/xen/serial.h
@@ -12,8 +12,6 @@
 #include <xen/init.h>
 #include <xen/spinlock.h>
 
-struct cpu_user_regs;
-
 /* Register a character-receive hook on the specified COM port. */
 typedef void (*serial_rx_fn)(char c);
 void serial_set_rx_handler(int handle, serial_rx_fn fn);
@@ -145,8 +143,8 @@ void serial_register_uart(int idx, struct uart_driver *driver, void *uart);
 /* Place the serial port into asynchronous transmit mode. */
 void serial_async_transmit(struct serial_port *port);
 /* Process work in interrupt context. */
-void serial_rx_interrupt(struct serial_port *port, struct cpu_user_regs *regs);
-void serial_tx_interrupt(struct serial_port *port, struct cpu_user_regs *regs);
+void serial_rx_interrupt(struct serial_port *port);
+void serial_tx_interrupt(struct serial_port *port);
 
 /*
  * Initialisers for individual uart drivers.
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:22:55 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:22:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684380.1064219 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd7AF-00046O-JU; Thu, 22 Feb 2024 11:22:55 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684380.1064219; Thu, 22 Feb 2024 11:22:55 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd7AF-00046G-Gs; Thu, 22 Feb 2024 11:22:55 +0000
Received: by outflank-mailman (input) for mailman id 684380;
 Thu, 22 Feb 2024 11:22:54 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd7AE-000467-QE
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:54 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd7AE-0005AM-Nh
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:54 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd7AE-0003mq-Mx
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:22:54 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=y0eXB3Q6E3lrjU23yZyvzmruztVgz4Vk58vM31Fx8UE=; b=wWLK0DYGjx+aFg8CvV/AtX9ToG
	tyyrFw7Yvz1R0KkyuDSIR80sqjYcuxfI1qFhdSTFJIx2pnGX1t+6SR53iDjHHucGIsNLb7+8CW4V/
	dCoMAZODikbftXDKfDUzn+dO61CiQ7UNZSeZ/RzlweC5W5JW9LUmpKlJTcuHTL833H04=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] IRQ: drop regs parameter from handler functions
Message-Id: <E1rd7AE-0003mq-Mx@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:22:54 +0000

commit 4da40a267a236d785d70ce6de88bb86846b64ccc
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 12:15:20 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 12:15:20 2024 +0100

    IRQ: drop regs parameter from handler functions
    
    It's simply not needed anymore. Note how Linux made this change many
    years ago already, in 2.6.19 (late 2006, see [1]).
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    
    [1] https://git.kernel.org/torvalds/c/7d12e780e003f93433d49ce78cfedf4b4c52adc5
---
 xen/arch/arm/gic.c                       |  2 +-
 xen/arch/arm/irq.c                       |  5 ++---
 xen/arch/arm/time.c                      |  4 ++--
 xen/arch/x86/hpet.c                      |  3 +--
 xen/arch/x86/irq.c                       |  4 ++--
 xen/arch/x86/time.c                      |  3 +--
 xen/common/irq.c                         |  2 +-
 xen/drivers/char/cadence-uart.c          |  2 +-
 xen/drivers/char/exynos4210-uart.c       |  2 +-
 xen/drivers/char/imx-lpuart.c            |  3 +--
 xen/drivers/char/meson-uart.c            |  3 +--
 xen/drivers/char/mvebu-uart.c            |  3 +--
 xen/drivers/char/ns16550.c               |  3 +--
 xen/drivers/char/omap-uart.c             |  2 +-
 xen/drivers/char/pl011.c                 |  2 +-
 xen/drivers/char/scif-uart.c             |  2 +-
 xen/drivers/passthrough/amd/iommu_init.c |  3 +--
 xen/drivers/passthrough/arm/ipmmu-vmsa.c |  2 +-
 xen/drivers/passthrough/arm/smmu-v3.c    | 14 +++++---------
 xen/drivers/passthrough/arm/smmu.c       |  6 ++----
 xen/drivers/passthrough/vtd/iommu.c      |  3 +--
 xen/include/xen/irq.h                    |  7 +++----
 22 files changed, 32 insertions(+), 48 deletions(-)

diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index b5a9c8266c..44c40e86de 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -397,7 +397,7 @@ void gic_interrupt(struct cpu_user_regs *regs, int is_fiq)
     } while (1);
 }
 
-static void maintenance_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs)
+static void maintenance_interrupt(int irq, void *dev_id)
 {
     /*
      * This is a dummy interrupt handler.
diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index ae69fb4aeb..6ac952f43b 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -182,8 +182,7 @@ void irq_set_affinity(struct irq_desc *desc, const cpumask_t *mask)
 }
 
 int request_irq(unsigned int irq, unsigned int irqflags,
-                void (*handler)(int irq, void *dev_id,
-                                struct cpu_user_regs *regs),
+                void (*handler)(int irq, void *dev_id),
                 const char *devname, void *dev_id)
 {
     struct irqaction *action;
@@ -276,7 +275,7 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq)
 
     do
     {
-        action->handler(irq, action->dev_id, regs);
+        action->handler(irq, action->dev_id);
         action = action->next;
     } while ( action );
 
diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
index 09cae8138e..e74d30d258 100644
--- a/xen/arch/arm/time.c
+++ b/xen/arch/arm/time.c
@@ -241,7 +241,7 @@ int reprogram_timer(s_time_t timeout)
 }
 
 /* Handle the firing timer */
-static void htimer_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs)
+static void htimer_interrupt(int irq, void *dev_id)
 {
     if ( unlikely(!(READ_SYSREG(CNTHP_CTL_EL2) & CNTx_CTL_PENDING)) )
         return;
@@ -255,7 +255,7 @@ static void htimer_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs)
     WRITE_SYSREG(0, CNTHP_CTL_EL2);
 }
 
-static void vtimer_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs)
+static void vtimer_interrupt(int irq, void *dev_id)
 {
     /*
      * Edge-triggered interrupts can be used for the virtual timer. Even
diff --git a/xen/arch/x86/hpet.c b/xen/arch/x86/hpet.c
index d982b0f6b2..d9e9c8ffa3 100644
--- a/xen/arch/x86/hpet.c
+++ b/xen/arch/x86/hpet.c
@@ -237,8 +237,7 @@ again:
     }
 }
 
-static void cf_check hpet_interrupt_handler(
-    int irq, void *data, struct cpu_user_regs *regs)
+static void cf_check hpet_interrupt_handler(int irq, void *data)
 {
     struct hpet_event_channel *ch = data;
 
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index bbae7751e4..689d7e46ab 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -962,7 +962,7 @@ static int __init cf_check irq_ratelimit_init(void)
 __initcall(irq_ratelimit_init);
 
 int __init request_irq(unsigned int irq, unsigned int irqflags,
-        void (*handler)(int irq, void *dev_id, struct cpu_user_regs *regs),
+        void (*handler)(int irq, void *dev_id),
         const char * devname, void *dev_id)
 {
     struct irqaction * action;
@@ -2009,7 +2009,7 @@ void do_IRQ(struct cpu_user_regs *regs)
         spin_unlock_irq(&desc->lock);
 
         tsc_in = tb_init_done ? get_cycles() : 0;
-        action->handler(irq, action->dev_id, regs);
+        action->handler(irq, action->dev_id);
         TRACE_3D(TRC_HW_IRQ_HANDLED, irq, tsc_in, get_cycles());
 
         spin_lock_irq(&desc->lock);
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index 34ddb9633f..6087004789 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -198,8 +198,7 @@ static void smp_send_timer_broadcast_ipi(void)
     }
 }
 
-static void cf_check timer_interrupt(
-    int irq, void *dev_id, struct cpu_user_regs *regs)
+static void cf_check timer_interrupt(int irq, void *dev_id)
 {
     ASSERT(local_irq_is_enabled());
 
diff --git a/xen/common/irq.c b/xen/common/irq.c
index 236cf171e2..04f14f7d1a 100644
--- a/xen/common/irq.c
+++ b/xen/common/irq.c
@@ -29,7 +29,7 @@ int init_one_irq_desc(struct irq_desc *desc)
     return err;
 }
 
-void cf_check no_action(int cpl, void *dev_id, struct cpu_user_regs *regs)
+void cf_check no_action(int cpl, void *dev_id)
 {
 }
 
diff --git a/xen/drivers/char/cadence-uart.c b/xen/drivers/char/cadence-uart.c
index 0b670c64ed..3618fa88d8 100644
--- a/xen/drivers/char/cadence-uart.c
+++ b/xen/drivers/char/cadence-uart.c
@@ -40,7 +40,7 @@ static struct cuart {
 #define cuart_read(uart, off)           readl((uart)->regs + (off))
 #define cuart_write(uart, off,val)      writel((val), (uart)->regs + (off))
 
-static void cuart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
+static void cuart_interrupt(int irq, void *data)
 {
     struct serial_port *port = data;
     struct cuart *uart = port->uart;
diff --git a/xen/drivers/char/exynos4210-uart.c b/xen/drivers/char/exynos4210-uart.c
index 5c53860df6..b29fd75c5a 100644
--- a/xen/drivers/char/exynos4210-uart.c
+++ b/xen/drivers/char/exynos4210-uart.c
@@ -45,7 +45,7 @@ static struct exynos4210_uart {
 #define exynos4210_read(uart, off)          readl((uart)->regs + off)
 #define exynos4210_write(uart, off, val)    writel(val, (uart->regs) + off)
 
-static void exynos4210_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
+static void exynos4210_uart_interrupt(int irq, void *data)
 {
     struct serial_port *port = data;
     struct exynos4210_uart *uart = port->uart;
diff --git a/xen/drivers/char/imx-lpuart.c b/xen/drivers/char/imx-lpuart.c
index f5b341e20b..522680a25c 100644
--- a/xen/drivers/char/imx-lpuart.c
+++ b/xen/drivers/char/imx-lpuart.c
@@ -37,8 +37,7 @@ static struct imx_lpuart {
     struct vuart_info vuart;
 } imx8_com;
 
-static void imx_lpuart_interrupt(int irq, void *data,
-                                 struct cpu_user_regs *regs)
+static void imx_lpuart_interrupt(int irq, void *data)
 {
     struct serial_port *port = data;
     struct imx_lpuart *uart = port->uart;
diff --git a/xen/drivers/char/meson-uart.c b/xen/drivers/char/meson-uart.c
index 640c29dd05..694381986d 100644
--- a/xen/drivers/char/meson-uart.c
+++ b/xen/drivers/char/meson-uart.c
@@ -61,8 +61,7 @@ static struct meson_uart {
     struct vuart_info vuart;
 } meson_com;
 
-static void meson_uart_interrupt(int irq, void *data,
-                                 struct cpu_user_regs *regs)
+static void meson_uart_interrupt(int irq, void *data)
 {
     struct serial_port *port = data;
     struct meson_uart *uart = port->uart;
diff --git a/xen/drivers/char/mvebu-uart.c b/xen/drivers/char/mvebu-uart.c
index 57c1259224..1913fe8b5f 100644
--- a/xen/drivers/char/mvebu-uart.c
+++ b/xen/drivers/char/mvebu-uart.c
@@ -67,8 +67,7 @@ static struct mvebu3700_uart {
 #define mvebu3700_read(uart, off)           readl((uart)->regs + (off))
 #define mvebu3700_write(uart, off, val)     writel(val, (uart)->regs + (off))
 
-static void mvebu3700_uart_interrupt(int irq, void *data,
-                                     struct cpu_user_regs *regs)
+static void mvebu3700_uart_interrupt(int irq, void *data)
 {
     struct serial_port *port = data;
     struct mvebu3700_uart *uart = port->uart;
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index 91f0624d74..a126e4a808 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -175,8 +175,7 @@ static void handle_dw_usr_busy_quirk(struct ns16550 *uart)
     }
 }
 
-static void cf_check ns16550_interrupt(
-    int irq, void *dev_id, struct cpu_user_regs *regs)
+static void cf_check ns16550_interrupt(int irq, void *dev_id)
 {
     struct serial_port *port = dev_id;
     struct ns16550 *uart = port->uart;
diff --git a/xen/drivers/char/omap-uart.c b/xen/drivers/char/omap-uart.c
index fb842b1707..e4f5be2289 100644
--- a/xen/drivers/char/omap-uart.c
+++ b/xen/drivers/char/omap-uart.c
@@ -59,7 +59,7 @@ static struct omap_uart {
     struct vuart_info vuart;
 } omap_com = {0};
 
-static void omap_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
+static void omap_uart_interrupt(int irq, void *data)
 {
     struct serial_port *port = data;
     struct omap_uart *uart = port->uart;
diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
index cb7c4affa5..7260a988ca 100644
--- a/xen/drivers/char/pl011.c
+++ b/xen/drivers/char/pl011.c
@@ -82,7 +82,7 @@ static unsigned int pl011_intr_status(struct pl011 *uart)
     return (pl011_read(uart, RIS) & pl011_read(uart, IMSC));
 }
 
-static void pl011_interrupt(int irq, void *data, struct cpu_user_regs *regs)
+static void pl011_interrupt(int irq, void *data)
 {
     struct serial_port *port = data;
     struct pl011 *uart = port->uart;
diff --git a/xen/drivers/char/scif-uart.c b/xen/drivers/char/scif-uart.c
index d5de8931b2..b7f86f882c 100644
--- a/xen/drivers/char/scif-uart.c
+++ b/xen/drivers/char/scif-uart.c
@@ -102,7 +102,7 @@ static const struct port_params port_params[NR_PORTS] =
     },
 };
 
-static void scif_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
+static void scif_uart_interrupt(int irq, void *data)
 {
     struct serial_port *port = data;
     struct scif_uart *uart = port->uart;
diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthrough/amd/iommu_init.c
index 25e62f20ae..b32da1a28d 100644
--- a/xen/drivers/passthrough/amd/iommu_init.c
+++ b/xen/drivers/passthrough/amd/iommu_init.c
@@ -718,8 +718,7 @@ static void cf_check do_amd_iommu_irq(void *unused)
 
 static DECLARE_SOFTIRQ_TASKLET(amd_iommu_irq_tasklet, do_amd_iommu_irq, NULL);
 
-static void cf_check iommu_interrupt_handler(
-    int irq, void *dev_id, struct cpu_user_regs *regs)
+static void cf_check iommu_interrupt_handler(int irq, void *dev_id)
 {
     unsigned long flags;
     struct amd_iommu *iommu = dev_id;
diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c b/xen/drivers/passthrough/arm/ipmmu-vmsa.c
index b5c84c51a2..da011413c5 100644
--- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c
+++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c
@@ -642,7 +642,7 @@ static void ipmmu_domain_irq(struct ipmmu_vmsa_domain *domain)
                         domain->d, status, iova);
 }
 
-static void ipmmu_irq(int irq, void *dev, struct cpu_user_regs *regs)
+static void ipmmu_irq(int irq, void *dev)
 {
     struct ipmmu_vmsa_device *mmu = dev;
     unsigned int i;
diff --git a/xen/drivers/passthrough/arm/smmu-v3.c b/xen/drivers/passthrough/arm/smmu-v3.c
index bca5866b35..c3ac6d17d1 100644
--- a/xen/drivers/passthrough/arm/smmu-v3.c
+++ b/xen/drivers/passthrough/arm/smmu-v3.c
@@ -880,8 +880,7 @@ static void arm_smmu_priq_tasklet(void *dev)
 
 static int arm_smmu_device_disable(struct arm_smmu_device *smmu);
 
-static void arm_smmu_gerror_handler(int irq, void *dev,
-				struct cpu_user_regs *regs)
+static void arm_smmu_gerror_handler(int irq, void *dev)
 {
 	u32 gerror, gerrorn, active;
 	struct arm_smmu_device *smmu = dev;
@@ -926,12 +925,11 @@ static void arm_smmu_gerror_handler(int irq, void *dev,
 	writel(gerror, smmu->base + ARM_SMMU_GERRORN);
 }
 
-static void arm_smmu_combined_irq_handler(int irq, void *dev,
-				struct cpu_user_regs *regs)
+static void arm_smmu_combined_irq_handler(int irq, void *dev)
 {
 	struct arm_smmu_device *smmu = dev;
 
-	arm_smmu_gerror_handler(irq, dev, regs);
+	arm_smmu_gerror_handler(irq, dev);
 
 	tasklet_schedule(&(smmu->combined_irq_tasklet));
 }
@@ -945,16 +943,14 @@ static void arm_smmu_combined_irq_tasklet(void *dev)
 		arm_smmu_priq_tasklet(dev);
 }
 
-static void arm_smmu_evtq_irq_tasklet(int irq, void *dev,
-				struct cpu_user_regs *regs)
+static void arm_smmu_evtq_irq_tasklet(int irq, void *dev)
 {
 	struct arm_smmu_device *smmu = dev;
 
 	tasklet_schedule(&(smmu->evtq_irq_tasklet));
 }
 
-static void arm_smmu_priq_irq_tasklet(int irq, void *dev,
-				struct cpu_user_regs *regs)
+static void arm_smmu_priq_irq_tasklet(int irq, void *dev)
 {
 	struct arm_smmu_device *smmu = dev;
 
diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c
index 4a272c8779..625ed0e419 100644
--- a/xen/drivers/passthrough/arm/smmu.c
+++ b/xen/drivers/passthrough/arm/smmu.c
@@ -1097,16 +1097,14 @@ static irqreturn_t arm_smmu_global_fault(int irq, void *dev)
 }
 
 /* Xen: Interrupt handlers wrapper */
-static void arm_smmu_context_fault_xen(int irq, void *dev,
-				       struct cpu_user_regs *regs)
+static void arm_smmu_context_fault_xen(int irq, void *dev)
 {
 	arm_smmu_context_fault(irq, dev);
 }
 
 #define arm_smmu_context_fault arm_smmu_context_fault_xen
 
-static void arm_smmu_global_fault_xen(int irq, void *dev,
-				      struct cpu_user_regs *regs)
+static void arm_smmu_global_fault_xen(int irq, void *dev)
 {
 	arm_smmu_global_fault(irq, dev);
 }
diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index 54c4c0f9b9..c7110af7c9 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1117,8 +1117,7 @@ static void cf_check do_iommu_page_fault(void *unused)
         __do_iommu_page_fault(drhd->iommu);
 }
 
-static void cf_check iommu_page_fault(
-    int irq, void *dev_id, struct cpu_user_regs *regs)
+static void cf_check iommu_page_fault(int irq, void *dev_id)
 {
     /*
      * Just flag the tasklet as runnable. This is fine, according to VT-d
diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h
index 76da442942..72c24c6f04 100644
--- a/xen/include/xen/irq.h
+++ b/xen/include/xen/irq.h
@@ -18,7 +18,7 @@
     ASSERT(!in_irq() && (local_irq_is_enabled() || num_online_cpus() <= 1))
 
 struct irqaction {
-    void (*handler)(int irq, void *dev_id, struct cpu_user_regs *regs);
+    void (*handler)(int irq, void *dev_id);
     const char *name;
     void *dev_id;
     bool free_on_release;
@@ -119,12 +119,11 @@ extern int setup_irq(unsigned int irq, unsigned int irqflags,
                      struct irqaction *new);
 extern void release_irq(unsigned int irq, const void *dev_id);
 extern int request_irq(unsigned int irq, unsigned int irqflags,
-               void (*handler)(int irq, void *dev_id,
-                     struct cpu_user_regs *regs),
+               void (*handler)(int irq, void *dev_id),
                const char *devname, void *dev_id);
 
 extern hw_irq_controller no_irq_type;
-void cf_check no_action(int cpl, void *dev_id, struct cpu_user_regs *regs);
+void cf_check no_action(int cpl, void *dev_id);
 unsigned int cf_check irq_startup_none(struct irq_desc *desc);
 void cf_check irq_actor_none(struct irq_desc *desc);
 #define irq_shutdown_none irq_actor_none
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:23:05 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:23:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684381.1064223 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd7AP-00049d-MQ; Thu, 22 Feb 2024 11:23:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684381.1064223; Thu, 22 Feb 2024 11:23:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd7AP-00049V-Jk; Thu, 22 Feb 2024 11:23:05 +0000
Received: by outflank-mailman (input) for mailman id 684381;
 Thu, 22 Feb 2024 11:23:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd7AO-00049L-Tu
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:23:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd7AO-0005B2-RJ
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:23:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd7AO-0003nO-QP
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:23:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=USPeAwLUiP7ZQUEBtDGj6pK56xt6hn+IRvHzRnPR+y0=; b=RL2hFlcuiITeI/ni8yC5mMnbn0
	DldekTdGohhMHcysv0izk8zPpH3fxBJVR3n0rSywhmS7jjr+Ucmb0yrHSEnNvvgAC3hDH6NV1qRI8
	gou9pqMEKxVQjVHOX/iyLTYoWCsC0a4fuiXUix9kJpzR4223lAPZQKp2n7LD8d5vAUTE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/APIC: drop regs parameter from direct vector handler functions
Message-Id: <E1rd7AO-0003nO-QP@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:23:04 +0000

commit f75b051f785af35dc7db030b005dc2ac962b573b
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 12:16:17 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 12:16:17 2024 +0100

    x86/APIC: drop regs parameter from direct vector handler functions
    
    The only place it was needed is in the spurious handler, and there we
    can use get_irq_regs() instead.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/apic.c                 | 10 +++++-----
 xen/arch/x86/cpu/mcheck/mce_intel.c |  4 ++--
 xen/arch/x86/guest/xen/xen.c        |  2 +-
 xen/arch/x86/hvm/vmx/vmx.c          |  4 ++--
 xen/arch/x86/include/asm/irq.h      | 14 ++++++--------
 xen/arch/x86/irq.c                  | 12 +++++-------
 xen/arch/x86/smp.c                  |  6 +++---
 7 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c
index a69ac90405..592b78e11e 100644
--- a/xen/arch/x86/apic.c
+++ b/xen/arch/x86/apic.c
@@ -1322,7 +1322,7 @@ int reprogram_timer(s_time_t timeout)
     return apic_tmict || !timeout;
 }
 
-static void cf_check apic_timer_interrupt(struct cpu_user_regs *regs)
+static void cf_check apic_timer_interrupt(void)
 {
     ack_APIC_irq();
     perfc_incr(apic_timer);
@@ -1341,7 +1341,7 @@ void smp_send_state_dump(unsigned int cpu)
 /*
  * Spurious interrupts should _never_ happen with our APIC/SMP architecture.
  */
-static void cf_check spurious_interrupt(struct cpu_user_regs *regs)
+static void cf_check spurious_interrupt(void)
 {
     /*
      * Check if this is a vectored interrupt (most likely, as this is probably
@@ -1355,7 +1355,7 @@ static void cf_check spurious_interrupt(struct cpu_user_regs *regs)
         is_spurious = !nmi_check_continuation();
         if (this_cpu(state_dump_pending)) {
             this_cpu(state_dump_pending) = false;
-            dump_execstate(regs);
+            dump_execstate(get_irq_regs());
             is_spurious = false;
         }
 
@@ -1372,7 +1372,7 @@ static void cf_check spurious_interrupt(struct cpu_user_regs *regs)
  * This interrupt should never happen with our APIC/SMP architecture
  */
 
-static void cf_check error_interrupt(struct cpu_user_regs *regs)
+static void cf_check error_interrupt(void)
 {
     static const char *const esr_fields[] = {
         ", Send CS error",
@@ -1407,7 +1407,7 @@ static void cf_check error_interrupt(struct cpu_user_regs *regs)
  * This interrupt handles performance counters interrupt
  */
 
-static void cf_check pmu_interrupt(struct cpu_user_regs *regs)
+static void cf_check pmu_interrupt(void)
 {
     ack_APIC_irq();
     vpmu_do_interrupt();
diff --git a/xen/arch/x86/cpu/mcheck/mce_intel.c b/xen/arch/x86/cpu/mcheck/mce_intel.c
index 7f9b87f973..3f5199b531 100644
--- a/xen/arch/x86/cpu/mcheck/mce_intel.c
+++ b/xen/arch/x86/cpu/mcheck/mce_intel.c
@@ -58,7 +58,7 @@ bool __read_mostly lmce_support;
 #define MCE_RING                0x1
 static DEFINE_PER_CPU(int, last_state);
 
-static void cf_check intel_thermal_interrupt(struct cpu_user_regs *regs)
+static void cf_check intel_thermal_interrupt(void)
 {
     uint64_t msr_content;
     unsigned int cpu = smp_processor_id();
@@ -642,7 +642,7 @@ static void cpu_mcheck_disable(void)
         clear_cmci();
 }
 
-static void cf_check cmci_interrupt(struct cpu_user_regs *regs)
+static void cf_check cmci_interrupt(void)
 {
     mctelem_cookie_t mctc;
     struct mca_summary bs;
diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c
index ec66fc84d1..d9768cc952 100644
--- a/xen/arch/x86/guest/xen/xen.c
+++ b/xen/arch/x86/guest/xen/xen.c
@@ -158,7 +158,7 @@ static void __init init_memmap(void)
     }
 }
 
-static void cf_check xen_evtchn_upcall(struct cpu_user_regs *regs)
+static void cf_check xen_evtchn_upcall(void)
 {
     struct vcpu_info *vcpu_info = this_cpu(vcpu_info);
     unsigned long pending;
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 48376cc327..9c803494c7 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2782,7 +2782,7 @@ static struct hvm_function_table __initdata_cf_clobber vmx_function_table = {
 };
 
 /* Handle VT-d posted-interrupt when VCPU is blocked. */
-static void cf_check pi_wakeup_interrupt(struct cpu_user_regs *regs)
+static void cf_check pi_wakeup_interrupt(void)
 {
     struct vmx_vcpu *vmx, *tmp;
     spinlock_t *lock = &per_cpu(vmx_pi_blocking, smp_processor_id()).lock;
@@ -2814,7 +2814,7 @@ static void cf_check pi_wakeup_interrupt(struct cpu_user_regs *regs)
 }
 
 /* Handle VT-d posted-interrupt when VCPU is running. */
-static void cf_check pi_notification_interrupt(struct cpu_user_regs *regs)
+static void cf_check pi_notification_interrupt(void)
 {
     ack_APIC_irq();
     this_cpu(irq_count)++;
diff --git a/xen/arch/x86/include/asm/irq.h b/xen/arch/x86/include/asm/irq.h
index 6a93dc41d2..082a3d6bbc 100644
--- a/xen/arch/x86/include/asm/irq.h
+++ b/xen/arch/x86/include/asm/irq.h
@@ -72,17 +72,15 @@ extern int opt_irq_vector_map;
 
 #define platform_legacy_irq(irq)	((irq) < 16)
 
-void cf_check event_check_interrupt(struct cpu_user_regs *regs);
-void cf_check invalidate_interrupt(struct cpu_user_regs *regs);
-void cf_check call_function_interrupt(struct cpu_user_regs *regs);
-void cf_check irq_move_cleanup_interrupt(struct cpu_user_regs *regs);
+void cf_check event_check_interrupt(void);
+void cf_check invalidate_interrupt(void);
+void cf_check call_function_interrupt(void);
+void cf_check irq_move_cleanup_interrupt(void);
 
 uint8_t alloc_hipriority_vector(void);
 
-void set_direct_apic_vector(
-    uint8_t vector, void (*handler)(struct cpu_user_regs *regs));
-void alloc_direct_apic_vector(
-    uint8_t *vector, void (*handler)(struct cpu_user_regs *regs));
+void set_direct_apic_vector(uint8_t vector, void (*handler)(void));
+void alloc_direct_apic_vector(uint8_t *vector, void (*handler)(void));
 
 void do_IRQ(struct cpu_user_regs *regs);
 
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index 689d7e46ab..810de06fd3 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -743,7 +743,7 @@ void move_native_irq(struct irq_desc *desc)
     desc->handler->enable(desc);
 }
 
-void cf_check irq_move_cleanup_interrupt(struct cpu_user_regs *regs)
+void cf_check irq_move_cleanup_interrupt(void)
 {
     unsigned vector, me;
 
@@ -913,16 +913,14 @@ uint8_t alloc_hipriority_vector(void)
     return next++;
 }
 
-static void (*direct_apic_vector[X86_NR_VECTORS])(struct cpu_user_regs *regs);
-void set_direct_apic_vector(
-    uint8_t vector, void (*handler)(struct cpu_user_regs *regs))
+static void (*direct_apic_vector[X86_NR_VECTORS])(void);
+void set_direct_apic_vector(uint8_t vector, void (*handler)(void))
 {
     BUG_ON(direct_apic_vector[vector] != NULL);
     direct_apic_vector[vector] = handler;
 }
 
-void alloc_direct_apic_vector(
-    uint8_t *vector, void (*handler)(struct cpu_user_regs *regs))
+void alloc_direct_apic_vector(uint8_t *vector, void (*handler)(void))
 {
     static DEFINE_SPINLOCK(lock);
 
@@ -1907,7 +1905,7 @@ void do_IRQ(struct cpu_user_regs *regs)
     if ( irq < 0 )
     {
         if ( direct_apic_vector[vector] )
-            direct_apic_vector[vector](regs);
+            direct_apic_vector[vector]();
         else
         {
             const char *kind = ", LAPIC";
diff --git a/xen/arch/x86/smp.c b/xen/arch/x86/smp.c
index 3a331cbdbc..7443ad2033 100644
--- a/xen/arch/x86/smp.c
+++ b/xen/arch/x86/smp.c
@@ -245,7 +245,7 @@ static cpumask_t flush_cpumask;
 static const void *flush_va;
 static unsigned int flush_flags;
 
-void cf_check invalidate_interrupt(struct cpu_user_regs *regs)
+void cf_check invalidate_interrupt(void)
 {
     unsigned int flags = flush_flags;
     ack_APIC_irq();
@@ -387,14 +387,14 @@ void smp_send_nmi_allbutself(void)
     send_IPI_mask(&cpu_online_map, APIC_DM_NMI);
 }
 
-void cf_check event_check_interrupt(struct cpu_user_regs *regs)
+void cf_check event_check_interrupt(void)
 {
     ack_APIC_irq();
     perfc_incr(ipis);
     this_cpu(irq_count)++;
 }
 
-void cf_check call_function_interrupt(struct cpu_user_regs *regs)
+void cf_check call_function_interrupt(void)
 {
     ack_APIC_irq();
     perfc_incr(ipis);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 11:23:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 11:23:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684382.1064227 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd7AZ-0004D6-Pl; Thu, 22 Feb 2024 11:23:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684382.1064227; Thu, 22 Feb 2024 11:23:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rd7AZ-0004Cv-LZ; Thu, 22 Feb 2024 11:23:15 +0000
Received: by outflank-mailman (input) for mailman id 684382;
 Thu, 22 Feb 2024 11:23:15 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd7AY-0004Bz-VX
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:23:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd7AY-0005BC-Ur
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:23:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rd7AY-0003o6-U0
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 11:23:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=hSI0YwhYbgphmRwz+ESVmAd4kkHuf6Tm+QafL2et7uY=; b=ETC4tAn0xrevmsCein2vL5jB6S
	GshBIPq9wd6iv2FRLFoO5Bu6R+tUWd1JCwPdo1caBJ/6hEsRA7JYHnZCXyRCXv3oblVxYRBmq/Qrn
	6LNLj6K4CazbbgybgZoNgwi90w+2IJemZ45rTzJsqfRVtT1YW6C3sm+XK7G+LkueaSQU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] consolidate do_bug_frame() / bug_fn_t
Message-Id: <E1rd7AY-0003o6-U0@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 11:23:14 +0000

commit 8c5e4ce14509ca85b3f5faa298a766b8ffdd4f85
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 12:16:55 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 12:16:55 2024 +0100

    consolidate do_bug_frame() / bug_fn_t
    
    The type not being used in do_bug_frame() is suspicious. Apparently
    that's solely because the type uses a pointer-to-const parameter,
    when so far run_in_exception_handler() wanted functions taking pointer-
    to-non-const. Expand use of const, in turn requiring common code's
    do_bug_frame() as well as [gs]et_irq_regs() to also gain const. This
    then brings the former function also closer to the common one, with
    Arm's use of vaddr_t remaining as a difference.
    
    While there also replace the bogus use of hard tabs in [gs]et_irq_regs()
    (I clearly didn't mean to put it in like this).
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/irq.c                   |  2 +-
 xen/arch/x86/include/asm/processor.h |  3 +--
 xen/arch/x86/irq.c                   |  2 +-
 xen/arch/x86/traps.c                 |  7 +------
 xen/common/bug.c                     |  8 ++------
 xen/common/irq.c                     |  2 +-
 xen/common/keyhandler.c              |  2 +-
 xen/drivers/char/ehci-dbgp.c         |  4 ++--
 xen/drivers/char/ns16550.c           |  4 ++--
 xen/include/xen/bug.h                |  5 ++---
 xen/include/xen/irq.h                | 17 +++++++++--------
 xen/include/xen/kernel.h             |  3 +--
 xen/include/xen/lib.h                |  2 +-
 13 files changed, 25 insertions(+), 36 deletions(-)

diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index 6ac952f43b..bcce80a4d6 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -220,7 +220,7 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq)
 {
     struct irq_desc *desc = irq_to_desc(irq);
     struct irqaction *action;
-    struct cpu_user_regs *old_regs = set_irq_regs(regs);
+    const struct cpu_user_regs *old_regs = set_irq_regs(regs);
 
     perfc_incr(irqs);
 
diff --git a/xen/arch/x86/include/asm/processor.h b/xen/arch/x86/include/asm/processor.h
index b227cdee8e..c26ef9090c 100644
--- a/xen/arch/x86/include/asm/processor.h
+++ b/xen/arch/x86/include/asm/processor.h
@@ -409,8 +409,7 @@ static always_inline void rep_nop(void)
 void show_code(const struct cpu_user_regs *regs);
 void show_stack_overflow(unsigned int cpu, const struct cpu_user_regs *regs);
 void show_registers(const struct cpu_user_regs *regs);
-#define dump_execution_state() \
-    run_in_exception_handler(show_execution_state_nonconst)
+#define dump_execution_state() run_in_exception_handler(show_execution_state)
 void show_page_walk(unsigned long addr);
 void noreturn fatal_trap(const struct cpu_user_regs *regs, bool show_remote);
 
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index 810de06fd3..7458b89ab3 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -1896,7 +1896,7 @@ void do_IRQ(struct cpu_user_regs *regs)
     struct irq_desc  *desc;
     unsigned int      vector = (uint8_t)regs->entry_vector;
     int               irq = this_cpu(vector_irq)[vector];
-    struct cpu_user_regs *old_regs = set_irq_regs(regs);
+    const struct cpu_user_regs *old_regs = set_irq_regs(regs);
 
     perfc_incr(irqs);
     this_cpu(irq_count)++;
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 5f4bcc0537..ff37d97133 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -643,7 +643,7 @@ void show_stack_overflow(unsigned int cpu, const struct cpu_user_regs *regs)
     printk("\n");
 }
 
-void show_execution_state(const struct cpu_user_regs *regs)
+void cf_check show_execution_state(const struct cpu_user_regs *regs)
 {
     /* Prevent interleaving of output. */
     unsigned long flags = console_lock_recursive_irqsave();
@@ -655,11 +655,6 @@ void show_execution_state(const struct cpu_user_regs *regs)
     console_unlock_recursive_irqrestore(flags);
 }
 
-void cf_check show_execution_state_nonconst(struct cpu_user_regs *regs)
-{
-    show_execution_state(regs);
-}
-
 void vcpu_show_execution_state(struct vcpu *v)
 {
     unsigned long flags = 0;
diff --git a/xen/common/bug.c b/xen/common/bug.c
index 5fbe703a81..c43e7c4397 100644
--- a/xen/common/bug.c
+++ b/xen/common/bug.c
@@ -10,7 +10,7 @@
  * Returns a negative value in case of an error otherwise
  * BUGFRAME_{run_fn, warn, bug, assert}
  */
-int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc)
+int do_bug_frame(const struct cpu_user_regs *regs, unsigned long pc)
 {
     const struct bug_frame *bug = NULL;
     const struct virtual_region *region;
@@ -44,14 +44,10 @@ int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc)
 
     if ( id == BUGFRAME_run_fn )
     {
-        void (*fn)(struct cpu_user_regs *) = bug_ptr(bug);
+        bug_fn_t *fn = bug_ptr(bug);
 
         fn(regs);
 
-        /* Re-enforce consistent types, because of the casts involved. */
-        if ( false )
-            run_in_exception_handler(fn);
-
         return id;
     }
 
diff --git a/xen/common/irq.c b/xen/common/irq.c
index 04f14f7d1a..7225b46374 100644
--- a/xen/common/irq.c
+++ b/xen/common/irq.c
@@ -1,7 +1,7 @@
 #include <xen/irq.h>
 #include <xen/errno.h>
 
-DEFINE_PER_CPU(struct cpu_user_regs *, irq_regs);
+DEFINE_PER_CPU(const struct cpu_user_regs *, irq_regs);
 
 int init_one_irq_desc(struct irq_desc *desc)
 {
diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c
index 9c23a540e5..127ca50696 100644
--- a/xen/common/keyhandler.c
+++ b/xen/common/keyhandler.c
@@ -135,7 +135,7 @@ static void cf_check show_handlers(unsigned char key)
 
 static cpumask_t dump_execstate_mask;
 
-void cf_check dump_execstate(struct cpu_user_regs *regs)
+void cf_check dump_execstate(const struct cpu_user_regs *regs)
 {
     unsigned int cpu = smp_processor_id();
 
diff --git a/xen/drivers/char/ehci-dbgp.c b/xen/drivers/char/ehci-dbgp.c
index 2bb55418a7..1ad3c6bebf 100644
--- a/xen/drivers/char/ehci-dbgp.c
+++ b/xen/drivers/char/ehci-dbgp.c
@@ -1246,14 +1246,14 @@ static int cf_check ehci_dbgp_getc(struct serial_port *port, char *pc)
 /* Safe: ehci_dbgp_poll() runs as timer handler, so not reentrant. */
 static struct serial_port *poll_port;
 
-static void cf_check _ehci_dbgp_poll(struct cpu_user_regs *regs)
+static void cf_check _ehci_dbgp_poll(const struct cpu_user_regs *regs)
 {
     struct serial_port *port = poll_port;
     struct ehci_dbgp *dbgp = port->uart;
     unsigned long flags;
     unsigned int timeout = MICROSECS(DBGP_CHECK_INTERVAL);
     bool empty = false;
-    struct cpu_user_regs *old_regs;
+    const struct cpu_user_regs *old_regs;
 
     if ( !dbgp->ehci_debug )
         return;
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index a126e4a808..8f76bbe676 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -206,11 +206,11 @@ static void cf_check ns16550_interrupt(int irq, void *dev_id)
 /* Safe: ns16550_poll() runs as softirq so not reentrant on a given CPU. */
 static DEFINE_PER_CPU(struct serial_port *, poll_port);
 
-static void cf_check __ns16550_poll(struct cpu_user_regs *regs)
+static void cf_check __ns16550_poll(const struct cpu_user_regs *regs)
 {
     struct serial_port *port = this_cpu(poll_port);
     struct ns16550 *uart = port->uart;
-    struct cpu_user_regs *old_regs;
+    const struct cpu_user_regs *old_regs;
 
     if ( uart->intr_works )
         return; /* Interrupts work - no more polling */
diff --git a/xen/include/xen/bug.h b/xen/include/xen/bug.h
index 4bd0be5088..a11d4239f8 100644
--- a/xen/include/xen/bug.h
+++ b/xen/include/xen/bug.h
@@ -101,8 +101,7 @@ typedef void bug_fn_t(const struct cpu_user_regs *regs);
 
 #ifndef run_in_exception_handler
 
-static void always_inline run_in_exception_handler(
-    void (*fn)(struct cpu_user_regs *regs))
+static void always_inline run_in_exception_handler(bug_fn_t *fn)
 {
     BUG_FRAME(BUGFRAME_run_fn, 0, fn, 0, NULL);
 }
@@ -133,7 +132,7 @@ static void always_inline run_in_exception_handler(
  * Returns a negative value in case of an error otherwise
  * BUGFRAME_{run_fn, warn, bug, assert}
  */
-int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc);
+int do_bug_frame(const struct cpu_user_regs *regs, unsigned long pc);
 
 #endif /* CONFIG_GENERIC_BUG_FRAME */
 
diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h
index 72c24c6f04..89f7a8317a 100644
--- a/xen/include/xen/irq.h
+++ b/xen/include/xen/irq.h
@@ -134,21 +134,22 @@ void cf_check irq_actor_none(struct irq_desc *desc);
  * Per-cpu interrupted context register state - the inner-most interrupt frame
  * on the stack.
  */
-DECLARE_PER_CPU(struct cpu_user_regs *, irq_regs);
+DECLARE_PER_CPU(const struct cpu_user_regs *, irq_regs);
 
-static inline struct cpu_user_regs *get_irq_regs(void)
+static inline const struct cpu_user_regs *get_irq_regs(void)
 {
-	return this_cpu(irq_regs);
+    return this_cpu(irq_regs);
 }
 
-static inline struct cpu_user_regs *set_irq_regs(struct cpu_user_regs *new_regs)
+static inline const struct cpu_user_regs *set_irq_regs(
+    const struct cpu_user_regs *new_regs)
 {
-	struct cpu_user_regs *old_regs, **pp_regs = &this_cpu(irq_regs);
+    const struct cpu_user_regs *old_regs, **pp_regs = &this_cpu(irq_regs);
 
-	old_regs = *pp_regs;
-	*pp_regs = new_regs;
+    old_regs = *pp_regs;
+    *pp_regs = new_regs;
 
-	return old_regs;
+    return old_regs;
 }
 
 struct domain;
diff --git a/xen/include/xen/kernel.h b/xen/include/xen/kernel.h
index 6bbd4a2827..bb6b0f3891 100644
--- a/xen/include/xen/kernel.h
+++ b/xen/include/xen/kernel.h
@@ -110,8 +110,7 @@ extern const unsigned int xen_config_data_size;
 struct cpu_user_regs;
 struct vcpu;
 
-void show_execution_state(const struct cpu_user_regs *regs);
-void cf_check show_execution_state_nonconst(struct cpu_user_regs *regs);
+void cf_check show_execution_state(const struct cpu_user_regs *regs);
 void vcpu_show_execution_state(struct vcpu *v);
 
 #endif /* _LINUX_KERNEL_H */
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index 1793be5b6b..abee6c20d7 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -173,7 +173,7 @@ extern char *print_tainted(char *str);
 extern void add_taint(unsigned int taint);
 
 struct cpu_user_regs;
-void cf_check dump_execstate(struct cpu_user_regs *regs);
+void cf_check dump_execstate(const struct cpu_user_regs *regs);
 
 void init_constructors(void);
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 16:11:11 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 16:11:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684480.1064351 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdBf7-0005zf-FG; Thu, 22 Feb 2024 16:11:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684480.1064351; Thu, 22 Feb 2024 16:11:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdBf7-0005zX-CO; Thu, 22 Feb 2024 16:11:05 +0000
Received: by outflank-mailman (input) for mailman id 684480;
 Thu, 22 Feb 2024 16:11:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdBf6-0005zR-9m
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 16:11:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdBf6-0002A0-6w
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 16:11:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdBf6-0006oO-2V
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 16:11:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=frMwo1NiS+AVwfHXltCxgo0gF9rWJjbyW6WKXWKJE+Y=; b=XMTrOvQdWbo5+FS/UCYweTnNP9
	9RltkLe2KD5TUUOmXBxkGA1cNw7bl3n2APxO19UqAIjQgUnaDlbCFevfl+VXwlo8OpmDIHubXokwD
	O7Q/evlpSf/Rh0HC3Mp3NcBm5lmNEGb+0xUOiuTcneIn+91LVBGRTISdWgCLRE+y23tc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen-analysis.py: Use named group for tag regex
Message-Id: <E1rdBf6-0006oO-2V@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 16:11:04 +0000

commit ddd6696fc6f1b2efe92c6edebb9b31726d105867
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Wed Jan 31 11:02:39 2024 +0000
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu Feb 22 16:08:06 2024 +0000

    xen-analysis.py: Use named group for tag regex
    
    Use named group for the regex matching a tag identifier, this
    is done to ease retrieving the matching group instead of using
    an index.
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 xen/scripts/xen_analysis/cppcheck_analysis.py |  4 ++--
 xen/scripts/xen_analysis/tag_database.py      | 24 ++++++++++++------------
 xen/scripts/xen_analysis/utils.py             |  2 +-
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/xen/scripts/xen_analysis/cppcheck_analysis.py b/xen/scripts/xen_analysis/cppcheck_analysis.py
index e54848aa53..919eb153ce 100644
--- a/xen/scripts/xen_analysis/cppcheck_analysis.py
+++ b/xen/scripts/xen_analysis/cppcheck_analysis.py
@@ -41,7 +41,7 @@ def __generate_suppression_list(out_file):
     # The following lambda function will return a file if it contains lines with
     # a comment containing "cppcheck-suppress[*]" on a single line.
     grep_action = lambda x: utils.grep(x,
-                    r'^[ \t]*/\* cppcheck-suppress\[(.*)\] \*/$')
+                    r'^[ \t]*/\* cppcheck-suppress\[(?P<id>.*)\] \*/$')
     # Look for a list of .h files that matches the condition above
     headers = utils.recursive_find_file(settings.xen_dir, r'.*\.h$',
                                         grep_action)
@@ -97,7 +97,7 @@ def __generate_suppression_list(out_file):
                         if (not comment_section) and comment_line_starts:
                             comment_section = True
                         if (len(line.strip()) != 0) and (not comment_section):
-                            cppcheck_violation_id = entry["matches"][line_num][0]
+                            cppcheck_violation_id = entry["matches"][line_num]['id']
                             break
                         if comment_section and comment_line_stops:
                             comment_section = False
diff --git a/xen/scripts/xen_analysis/tag_database.py b/xen/scripts/xen_analysis/tag_database.py
index ca374bbb62..abba163aec 100644
--- a/xen/scripts/xen_analysis/tag_database.py
+++ b/xen/scripts/xen_analysis/tag_database.py
@@ -18,11 +18,12 @@ tool_syntax = {
 
 
 def get_xen_tag_index_type_regex(tool):
-    return r'^SAF-(\d+)-(safe|false-positive-' + tool + ')$'
+    return rf'^SAF-(?P<id>\d+)-(?P<type>safe|false-positive-{tool})$'
 
 
 def get_xen_tag_comment_regex(tool):
-    return r'^[ \t]*/\* +(SAF-\d+-(?:safe|false-positive-' + tool + ')).*\*/$'
+    tag=rf'(?P<tag>SAF-\d+-(?:safe|false-positive-{tool}))'
+    return rf'^[ \t]*/\* +{tag}.*\*/$'
 
 
 # Returns a data structure containing dictionaries for safe and false-positive-*
@@ -60,12 +61,11 @@ def load_tag_database(tool, input_files, data_struct = None, schema = "safe"):
         if proprietary_id != "":
             comment=tool_syntax[tool].replace("VID",proprietary_id)
             # Regex to capture the index of the Xen tag and the schema
-            xen_tag = re.compile(get_xen_tag_index_type_regex(tool))\
-                            .match(entry["id"])
-            if xen_tag and xen_tag.group(1) and xen_tag.group(2):
+            xen_tag = re.match(get_xen_tag_index_type_regex(tool), entry["id"])
+            if xen_tag and xen_tag.group('id') and xen_tag.group('type'):
                 # Save in safe or false-positive-* the key {#id: "comment"}
-                id_number = int(xen_tag.group(1))
-                key = xen_tag.group(2)
+                id_number = int(xen_tag.group('id'))
+                key = xen_tag.group('type')
                 ret[key][id_number] = "/* {} */\n".format(comment)
             else:
                 raise TagDatabaseError(
@@ -95,11 +95,11 @@ def substitute_tags(tool, input_file, grep_struct, subs_rules):
             # information access the subs_rules dictionary to see if there is
             # a match
             for line_number in grep_struct["matches"]:
-                xen_tag = grep_struct["matches"][line_number][0]
-                xen_tag_regex_obj = re.compile(
-                            get_xen_tag_index_type_regex(tool)).match(xen_tag)
-                id_number = int(xen_tag_regex_obj.group(1))
-                key = xen_tag_regex_obj.group(2)
+                xen_tag = grep_struct["matches"][line_number]['tag']
+                xen_tag_regex_obj = re.match(get_xen_tag_index_type_regex(tool),
+                                             xen_tag)
+                id_number = int(xen_tag_regex_obj.group('id'))
+                key = xen_tag_regex_obj.group('type')
                 if id_number in subs_rules[key]:
                     parsed_content[line_number-1] = subs_rules[key][id_number]
 
diff --git a/xen/scripts/xen_analysis/utils.py b/xen/scripts/xen_analysis/utils.py
index 1193e3f463..eef48eeb7e 100644
--- a/xen/scripts/xen_analysis/utils.py
+++ b/xen/scripts/xen_analysis/utils.py
@@ -12,7 +12,7 @@ def grep(filepath, regex):
             for line in f:
                 match = regObj.match(line)
                 if match:
-                    res["matches"][line_number] = match.groups()
+                    res["matches"][line_number] = match
                 line_number = line_number + 1
     except Exception as e:
         print("WARNING: Can't open {}: {}".format(filepath, e))
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 16:11:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 16:11:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684481.1064355 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdBfH-00061W-GZ; Thu, 22 Feb 2024 16:11:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684481.1064355; Thu, 22 Feb 2024 16:11:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdBfH-00061O-Ds; Thu, 22 Feb 2024 16:11:15 +0000
Received: by outflank-mailman (input) for mailman id 684481;
 Thu, 22 Feb 2024 16:11:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdBfG-00061G-Cf
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 16:11:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdBfG-0002AH-Bt
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 16:11:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdBfG-0006pJ-97
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 16:11:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=95AC91TFDAlE22YdUIbgbAdG19iG8v8hPFtRuatLAgA=; b=WXtt4MeWnjiXf80iyacmKY4OWY
	k4cxEuP2PFdDR0eFiF9gxgtVw2rlW9yXbfVxRYQvJPDhIeWkvBCMUms0xDumcf/ZhhReGfBAKO2Xw
	XAoyJiIWxsJARaX6XLqdmAhFHCrCeTQNLHCenSfsbpcAFcMV/Hnlh+T0DWNNhcnEqZZc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen-analysis.py: Substitute only the comment instead of the line
Message-Id: <E1rdBfG-0006pJ-97@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 16:11:14 +0000

commit d064b429b670998e1e4a5ab73ac34d67cf44b083
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Wed Jan 31 11:02:40 2024 +0000
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu Feb 22 16:08:22 2024 +0000

    xen-analysis.py: Substitute only the comment instead of the line
    
    Change the code in tag_database.py to substitute only the SAF-*
    comment instead of replacing the line.
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 xen/scripts/xen_analysis/tag_database.py | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/xen/scripts/xen_analysis/tag_database.py b/xen/scripts/xen_analysis/tag_database.py
index abba163aec..dc0558a46e 100644
--- a/xen/scripts/xen_analysis/tag_database.py
+++ b/xen/scripts/xen_analysis/tag_database.py
@@ -16,14 +16,18 @@ tool_syntax = {
     "eclair":"-E> hide VID 1 \"\""
 }
 
+def get_xen_tag_regex(tool):
+    return rf'(?P<tag>SAF-(?P<id>\d+)-(?P<type>safe|false-positive-{tool}))'
+
 
 def get_xen_tag_index_type_regex(tool):
-    return rf'^SAF-(?P<id>\d+)-(?P<type>safe|false-positive-{tool})$'
+    return rf'^{get_xen_tag_regex(tool)}$'
 
 
 def get_xen_tag_comment_regex(tool):
-    tag=rf'(?P<tag>SAF-\d+-(?:safe|false-positive-{tool}))'
-    return rf'^[ \t]*/\* +{tag}.*\*/$'
+    before_comment = r'(?P<before>[ \t]*)'
+    comment = rf'(?P<comment>/\* +{get_xen_tag_regex(tool)}.*\*/)'
+    return rf'^(?P<full_line>{before_comment}{comment})$'
 
 
 # Returns a data structure containing dictionaries for safe and false-positive-*
@@ -66,7 +70,7 @@ def load_tag_database(tool, input_files, data_struct = None, schema = "safe"):
                 # Save in safe or false-positive-* the key {#id: "comment"}
                 id_number = int(xen_tag.group('id'))
                 key = xen_tag.group('type')
-                ret[key][id_number] = "/* {} */\n".format(comment)
+                ret[key][id_number] = "/* {} */".format(comment)
             else:
                 raise TagDatabaseError(
                         "Error in database file, entry {} has unexpected "
@@ -101,7 +105,11 @@ def substitute_tags(tool, input_file, grep_struct, subs_rules):
                 id_number = int(xen_tag_regex_obj.group('id'))
                 key = xen_tag_regex_obj.group('type')
                 if id_number in subs_rules[key]:
-                    parsed_content[line_number-1] = subs_rules[key][id_number]
+                    comment_in = grep_struct["matches"][line_number]['comment']
+                    comment_out = subs_rules[key][id_number]
+                    parsed_content[line_number-1] = re.sub(
+                        re.escape(comment_in), comment_out,
+                        parsed_content[line_number-1])
 
             outfile.writelines(parsed_content)
     except Exception as e:
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 22 16:11:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 22 Feb 2024 16:11:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684482.1064359 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdBfR-000647-I8; Thu, 22 Feb 2024 16:11:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684482.1064359; Thu, 22 Feb 2024 16:11:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdBfR-000640-FP; Thu, 22 Feb 2024 16:11:25 +0000
Received: by outflank-mailman (input) for mailman id 684482;
 Thu, 22 Feb 2024 16:11:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdBfQ-00063s-JJ
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 16:11:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdBfQ-0002AO-Gl
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 16:11:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdBfQ-0006pz-E4
 for xen-changelog@lists.xenproject.org; Thu, 22 Feb 2024 16:11:24 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=f/8qXtS+J6rMDR+/TEMgXLnILzYEoxVKaoofwvX1qEc=; b=2LSA5SaxplXJjQ9LFeR2LR7HSw
	owxgbCIyHh7vS9hkZ0wJL2LDnUbiqrg7UfKPseq4AbvMo11DjM7Y1HDhauv+O3kBResb04XwcjoDE
	jOLwa/LP+Ahbyk9cYzM8wumC1qpRZFnfnHvVYYgSTWPUuXwGzkQkj08c+h3V5DLAFMJk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen-analysis.py: Accept deviation comment at the end of the line
Message-Id: <E1rdBfQ-0006pz-E4@xenbits.xenproject.org>
Date: Thu, 22 Feb 2024 16:11:24 +0000

commit 812bdc99f4c5d05d20b6fac03b90920c0dbf9a2b
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Wed Jan 31 11:02:41 2024 +0000
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu Feb 22 16:08:25 2024 +0000

    xen-analysis.py: Accept deviation comment at the end of the line
    
    Implement the in-code suppression comment at the end of the line.
    Now it is possible to add a Xen deviaiton comment with the syntax
    described in the docs at the end of the line affected by the
    violation, to deviate it.
    
    Eclair natively supports it, so the translation for the tool will
    be straighforward, but the other tool needs to translate an
    occurrence of the tag into a suppressino comment at the end of the
    previous line, this will have a corner case where the line number
    1 of the file can't be deviated in this way for such tools.
    
    Updated documentation.
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 docs/misra/documenting-violations.rst         | 10 ++++++++++
 xen/scripts/xen_analysis/cppcheck_analysis.py |  2 +-
 xen/scripts/xen_analysis/generic_analysis.py  | 14 +++++++++-----
 xen/scripts/xen_analysis/tag_database.py      | 25 ++++++++++++++++++++++++-
 4 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/docs/misra/documenting-violations.rst b/docs/misra/documenting-violations.rst
index 0d02a8e6f9..8f1cbd83b8 100644
--- a/docs/misra/documenting-violations.rst
+++ b/docs/misra/documenting-violations.rst
@@ -210,3 +210,13 @@ will be an entry like the following and the violation id will be in the column
 
 Given the violation id "misra-c2012-20.7", the procedure above can be followed
 to justify this finding.
+
+Another way to justify the above violation is to put the in-code comment tag
+at the end of the affected line::
+
+| extern char _start[], _end[], start[]; /* SAF-1-safe [...] */
+
+This way of deviating violations needs however to be used only when placing the
+tag above the line can't be done. This option suffers from some limitation on
+cppcheck and coverity tool that don't support natively the suppression comment
+at the end of the line.
diff --git a/xen/scripts/xen_analysis/cppcheck_analysis.py b/xen/scripts/xen_analysis/cppcheck_analysis.py
index 919eb153ce..850335c998 100644
--- a/xen/scripts/xen_analysis/cppcheck_analysis.py
+++ b/xen/scripts/xen_analysis/cppcheck_analysis.py
@@ -41,7 +41,7 @@ def __generate_suppression_list(out_file):
     # The following lambda function will return a file if it contains lines with
     # a comment containing "cppcheck-suppress[*]" on a single line.
     grep_action = lambda x: utils.grep(x,
-                    r'^[ \t]*/\* cppcheck-suppress\[(?P<id>.*)\] \*/$')
+                    r'^.*/\* cppcheck-suppress\[(?P<id>.*)\] \*/$')
     # Look for a list of .h files that matches the condition above
     headers = utils.recursive_find_file(settings.xen_dir, r'.*\.h$',
                                         grep_action)
diff --git a/xen/scripts/xen_analysis/generic_analysis.py b/xen/scripts/xen_analysis/generic_analysis.py
index 94122aebac..9e0cfc1bbc 100644
--- a/xen/scripts/xen_analysis/generic_analysis.py
+++ b/xen/scripts/xen_analysis/generic_analysis.py
@@ -52,11 +52,15 @@ def parse_xen_tags():
         os.rename(file, bkp_file)
         time_bkp_file = os.stat(bkp_file)
         # Create <file> from <file>.safparse but with the Xen tag parsed
-        tag_database.substitute_tags(settings.analysis_tool, bkp_file, entry,
-                                     subs_list)
-        # Set timestamp for file equal to bkp_file, so that if the file is
-        # modified during the process by the user, we can catch it
-        os.utime(file, (time_bkp_file.st_atime, time_bkp_file.st_mtime))
+        try:
+            tag_database.substitute_tags(settings.analysis_tool, bkp_file, entry,
+                                         subs_list)
+        except Exception as e:
+            raise ParseTagPhaseError("{}".format(e))
+        finally:
+            # Set timestamp for file equal to bkp_file, so that if the file is
+            # modified during the process by the user, we can catch it
+            os.utime(file, (time_bkp_file.st_atime, time_bkp_file.st_mtime))
 
 
 def build_xen():
diff --git a/xen/scripts/xen_analysis/tag_database.py b/xen/scripts/xen_analysis/tag_database.py
index dc0558a46e..57746ca0dd 100644
--- a/xen/scripts/xen_analysis/tag_database.py
+++ b/xen/scripts/xen_analysis/tag_database.py
@@ -25,7 +25,7 @@ def get_xen_tag_index_type_regex(tool):
 
 
 def get_xen_tag_comment_regex(tool):
-    before_comment = r'(?P<before>[ \t]*)'
+    before_comment = r'(?P<before>.*)'
     comment = rf'(?P<comment>/\* +{get_xen_tag_regex(tool)}.*\*/)'
     return rf'^(?P<full_line>{before_comment}{comment})$'
 
@@ -106,7 +106,30 @@ def substitute_tags(tool, input_file, grep_struct, subs_rules):
                 key = xen_tag_regex_obj.group('type')
                 if id_number in subs_rules[key]:
                     comment_in = grep_struct["matches"][line_number]['comment']
+                    before = grep_struct["matches"][line_number]['before']
                     comment_out = subs_rules[key][id_number]
+                    if before != '' and not re.match(r'^[ \t]+$', before):
+                        # The comment is at the end of some line with some code
+                        if tool == "eclair":
+                            # Eclair supports comment at the end of the line, so
+                            # the only thing to do is use the right syntax in
+                            # the comment, the default version of it is
+                            # deviating the current line and the next one
+                            comment_out = re.sub(r'\d+ ""', '0 ""', comment_out)
+                        else:
+                            # Other tool does not support deviating the same
+                            # line of the comment, so we use a trick and we use
+                            # the comment at the end of the previous line
+                            if line_number-2 < 0:
+                                raise TagDatabaseError(
+                                    "The comment {} using the tool '{}' can't "
+                                    "stay at the end of the line 1."
+                                    .format(comment_in, tool)
+                                )
+                            parsed_content[line_number-2] = \
+                                parsed_content[line_number-2].replace("\n",
+                                    comment_out + '\n')
+                            comment_out = ''
                     parsed_content[line_number-1] = re.sub(
                         re.escape(comment_in), comment_out,
                         parsed_content[line_number-1])
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 04:55:09 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 04:55:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684614.1064576 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNaR-00013D-KJ; Fri, 23 Feb 2024 04:55:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684614.1064576; Fri, 23 Feb 2024 04:55:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNaR-000135-Hl; Fri, 23 Feb 2024 04:55:03 +0000
Received: by outflank-mailman (input) for mailman id 684614;
 Fri, 23 Feb 2024 04:55:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNaQ-00012u-9F
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNaQ-00006l-6H
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNaQ-0004mI-5N
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=VJmNiMxmVGuzA2z6I2CU+cSJrJ72thoyFYG+q59oBXI=; b=agKq3k4ldtMG/hggTyiwfs1U6W
	K2hztBp63uqoSAibrJBYvcmynZHLtlO9Qtl/75TuTu94vbipRrLaVmZtQF9/UsMzNAg9y3m9sv+QX
	aDr13IaTFcCodQwvDZDDdBNru+j4dH+3vescy2/tuWSpJE3UCfPxWWdwR5g1uBLQWxao=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] libxl: Disable relocating memory for qemu-xen in stubdomain too
Message-Id: <E1rdNaQ-0004mI-5N@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 04:55:02 +0000

commit 97883aa269f6745a6ded232be3a855abb1297e0d
Author:     Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
AuthorDate: Thu Feb 22 11:48:22 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:48:22 2024 +0100

    libxl: Disable relocating memory for qemu-xen in stubdomain too
    
    According to comments (and experiments) qemu-xen cannot handle memory
    reolcation done by hvmloader. The code was already disabled when running
    qemu-xen in dom0 (see libxl__spawn_local_dm()), but it was missed when
    adding qemu-xen support to stubdomain. Adjust libxl__spawn_stub_dm() to
    be consistent in this regard.
    
    Reported-by: Neowutran <xen@neowutran.ovh>
    Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libs/light/libxl_dm.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
index 14b593110f..ed620a9d8e 100644
--- a/tools/libs/light/libxl_dm.c
+++ b/tools/libs/light/libxl_dm.c
@@ -2432,6 +2432,16 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
                         "%s",
                         libxl_bios_type_to_string(guest_config->b_info.u.hvm.bios));
     }
+    /* Disable relocating memory to make the MMIO hole larger
+     * unless we're running qemu-traditional and vNUMA is not
+     * configured. */
+    libxl__xs_printf(gc, XBT_NULL,
+                     libxl__sprintf(gc, "%s/hvmloader/allow-memory-relocate",
+                                    libxl__xs_get_dompath(gc, guest_domid)),
+                     "%d",
+                     guest_config->b_info.device_model_version
+                        == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL &&
+                     !libxl__vnuma_configured(&guest_config->b_info));
     ret = xc_domain_set_target(ctx->xch, dm_domid, guest_domid);
     if (ret<0) {
         LOGED(ERROR, guest_domid, "setting target domain %d -> %d",
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 04:55:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 04:55:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684615.1064580 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNaa-00015W-MI; Fri, 23 Feb 2024 04:55:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684615.1064580; Fri, 23 Feb 2024 04:55:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNaa-00015O-JF; Fri, 23 Feb 2024 04:55:12 +0000
Received: by outflank-mailman (input) for mailman id 684615;
 Fri, 23 Feb 2024 04:55:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNaa-00015G-AR
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNaa-00007V-9K
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNaa-0004mh-8W
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=WFAynt4NLcaVi5+bZlNM+/mb4NRRzsymyvihH32ujTo=; b=6b1L2RYkzaTSC8Ao9pwMNUhthl
	KWhCITlfQQychDjCnXNT3yAdysdu7qT1jCfxDN+tx8R8OPxMqXx2oJJM1SJIGNx5WMBmGBn9UkcEs
	5gUpxbSgdRDYTmxZWEimDsg30iBuuC6pioHj9WK09nrbAhR9VTV+Lg3EmzXGeFNqOMU0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] gnttab: fully ignore zero-size copy requests
Message-Id: <E1rdNaa-0004mh-8W@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 04:55:12 +0000

commit a4a790f4327fd80cf4615c11cd146291b0dcc5fc
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 11:49:10 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:49:10 2024 +0100

    gnttab: fully ignore zero-size copy requests
    
    Along the line with observations in the context of XSA-448, no field in
    struct gnttab_copy_ptr is relevant when no data is to be copied, much
    like e.g. the pointers passed to memcpy() are irrelevant (and would
    never be "validated") when the passed length is zero.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/common/grant_table.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/common/grant_table.c b/xen/common/grant_table.c
index 5721eab225..37b178a67b 100644
--- a/xen/common/grant_table.c
+++ b/xen/common/grant_table.c
@@ -3061,6 +3061,9 @@ static int gnttab_copy_one(const struct gnttab_copy *op,
 {
     int rc;
 
+    if ( unlikely(!op->len) )
+        return GNTST_okay;
+
     if ( !src->domain || op->source.domid != src->ptr.domid ||
          !dest->domain || op->dest.domid != dest->ptr.domid )
     {
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 04:55:22 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 04:55:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684616.1064584 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNak-00017Z-NK; Fri, 23 Feb 2024 04:55:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684616.1064584; Fri, 23 Feb 2024 04:55:22 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNak-00017S-Kr; Fri, 23 Feb 2024 04:55:22 +0000
Received: by outflank-mailman (input) for mailman id 684616;
 Fri, 23 Feb 2024 04:55:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNak-00017M-D3
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNak-00007f-CF
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNak-0004nF-BS
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Qqj4SjGxVrhBhFwqQ/lI8UJVtKIMIUXZ6rPAPnvc9IQ=; b=UQxD3W8kRRbxXHCGQYasUs5nPv
	gnAu3ZXTOLgkW9KvDZPlhBfyto7kU95OFImKsL5ux417WMsOS3DewlnDZTR/v+s5rQei1Bo8AqqTf
	0j7jKjeZc4Fw5h22O+5qY71gb7wSmgtc2i8v57cJqAhqAIrm4lrbxQ20wl8xufgH6dbk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/riscv: use some asm-generic headers
Message-Id: <E1rdNak-0004nF-BS@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 04:55:22 +0000

commit 512f88a92d4cf01d84a6da2ae4e72cd8800f4694
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Thu Feb 22 11:50:47 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:50:47 2024 +0100

    xen/riscv: use some asm-generic headers
    
    Some headers are the same as asm-generic verions of them
    so use them instead of arch-specific headers.
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/riscv/include/asm/Makefile | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/xen/arch/riscv/include/asm/Makefile b/xen/arch/riscv/include/asm/Makefile
new file mode 100644
index 0000000000..ced02e26ed
--- /dev/null
+++ b/xen/arch/riscv/include/asm/Makefile
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0-only
+generic-y += altp2m.h
+generic-y += device.h
+generic-y += div64.h
+generic-y += hardirq.h
+generic-y += hypercall.h
+generic-y += iocap.h
+generic-y += paging.h
+generic-y += percpu.h
+generic-y += random.h
+generic-y += softirq.h
+generic-y += vm_event.h
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 04:55:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 04:55:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684617.1064588 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNav-0001BS-Qh; Fri, 23 Feb 2024 04:55:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684617.1064588; Fri, 23 Feb 2024 04:55:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNav-0001BK-O7; Fri, 23 Feb 2024 04:55:33 +0000
Received: by outflank-mailman (input) for mailman id 684617;
 Fri, 23 Feb 2024 04:55:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNau-0001BC-GU
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNau-00007o-Ff
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNau-0004ne-Eb
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=983W5ETPK5RBNxzJOhecMaafZy4Q8HjIfh5+IriufUk=; b=4fEUXhiWUmow6J5jWHkNbr15Cj
	5vY9J033mURX5vlzR/kXOUQOJKlLNlalfKVSFZzMrdapHM5LKhqcFD3RrPGMCukku0AqhvbJODWYw
	/Vox+ZCDNnuVVafSJ24SyggMJ/ls7bqrnEehqi79TngfwhTlZ5yBR4jKN0TgWAcWttMs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] Constify some parameters
Message-Id: <E1rdNau-0004ne-Eb@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 04:55:32 +0000

commit d9fe1d743fd764cd11e4db8e540d2527adc7b701
Author:     Frediano Ziglio <frediano.ziglio@cloud.com>
AuthorDate: Thu Feb 22 11:51:19 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:51:19 2024 +0100

    Constify some parameters
    
    Make clear they are not changed in the functions.
    
    Signed-off-by: Frediano Ziglio <frediano.ziglio@cloud.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Daniel P. Smith <dpsmith@apertussolutions.com> # XSM
    Acked-by: George Dunlap <george.dunlap@cloud.com> # sched
---
 xen/arch/x86/pv/callback.c | 4 ++--
 xen/common/sched/compat.c  | 2 +-
 xen/common/sched/core.c    | 2 +-
 xen/xsm/flask/flask_op.c   | 8 ++++----
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/pv/callback.c b/xen/arch/x86/pv/callback.c
index 17829304fe..caec4fb16f 100644
--- a/xen/arch/x86/pv/callback.c
+++ b/xen/arch/x86/pv/callback.c
@@ -48,7 +48,7 @@ static void unregister_guest_nmi_callback(void)
     memset(t, 0, sizeof(*t));
 }
 
-static long register_guest_callback(struct callback_register *reg)
+static long register_guest_callback(const struct callback_register *reg)
 {
     long ret = 0;
     struct vcpu *curr = current;
@@ -102,7 +102,7 @@ static long register_guest_callback(struct callback_register *reg)
     return ret;
 }
 
-static long unregister_guest_callback(struct callback_unregister *unreg)
+static long unregister_guest_callback(const struct callback_unregister *unreg)
 {
     long ret;
 
diff --git a/xen/common/sched/compat.c b/xen/common/sched/compat.c
index dd97593630..a02204ec9a 100644
--- a/xen/common/sched/compat.c
+++ b/xen/common/sched/compat.c
@@ -26,7 +26,7 @@ CHECK_sched_shutdown;
 CHECK_sched_remote_shutdown;
 #undef xen_sched_remote_shutdown
 
-static int compat_poll(struct compat_sched_poll *compat)
+static int compat_poll(const struct compat_sched_poll *compat)
 {
     struct sched_poll native;
 
diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index d177c675c8..c5db373972 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -1431,7 +1431,7 @@ static void vcpu_block_enable_events(void)
     vcpu_block();
 }
 
-static long do_poll(struct sched_poll *sched_poll)
+static long do_poll(const struct sched_poll *sched_poll)
 {
     struct vcpu   *v = current;
     struct domain *d = v->domain;
diff --git a/xen/xsm/flask/flask_op.c b/xen/xsm/flask/flask_op.c
index b866e8d05f..ea7dd10dc8 100644
--- a/xen/xsm/flask/flask_op.c
+++ b/xen/xsm/flask/flask_op.c
@@ -469,7 +469,7 @@ static int flask_security_load(struct xen_flask_load *load)
     return ret;
 }
 
-static int flask_devicetree_label(struct xen_flask_devicetree_label *arg)
+static int flask_devicetree_label(const struct xen_flask_devicetree_label *arg)
 {
     int rv;
     char *buf;
@@ -492,7 +492,7 @@ static int flask_devicetree_label(struct xen_flask_devicetree_label *arg)
 
 #ifndef COMPAT
 
-static int flask_ocontext_del(struct xen_flask_ocontext *arg)
+static int flask_ocontext_del(const struct xen_flask_ocontext *arg)
 {
     int rv;
 
@@ -506,7 +506,7 @@ static int flask_ocontext_del(struct xen_flask_ocontext *arg)
     return security_ocontext_del(arg->ocon, arg->low, arg->high);
 }
 
-static int flask_ocontext_add(struct xen_flask_ocontext *arg)
+static int flask_ocontext_add(const struct xen_flask_ocontext *arg)
 {
     int rv;
 
@@ -550,7 +550,7 @@ static int flask_get_peer_sid(struct xen_flask_peersid *arg)
     return rv;
 }
 
-static int flask_relabel_domain(struct xen_flask_relabel *arg)
+static int flask_relabel_domain(const struct xen_flask_relabel *arg)
 {
     int rc;
     struct domain *d;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 04:55:43 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 04:55:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684618.1064592 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNb5-0001EU-SH; Fri, 23 Feb 2024 04:55:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684618.1064592; Fri, 23 Feb 2024 04:55:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNb5-0001EM-PX; Fri, 23 Feb 2024 04:55:43 +0000
Received: by outflank-mailman (input) for mailman id 684618;
 Fri, 23 Feb 2024 04:55:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNb4-0001E9-JN
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNb4-00007x-If
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNb4-0004oO-Hm
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=eDXB7mDWC20dJ1E6JqSBjXCvCJtR9Nbt/KgoP0kT9Uw=; b=dnHPCfMhM5A9cOW0iX3DXiIxrF
	b3z9STTuR22AG3mD3PDYvirS40nix9M4ycu4N2ZzC4/YbFoXEzu6kl4xIy2g0nlS5KSPdFmS5U5qM
	29fx48YxPwSWgYprZ5nB7E1clOba0SCRT5gks/BTUMJvvwVWHCmEZhjIRBL3jwEfsRwY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/9pfsd: add missing va_end() in fill_data()
Message-Id: <E1rdNb4-0004oO-Hm@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 04:55:42 +0000

commit bb1619ed4f2edcc7140b6a130b42a553da78fa10
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 22 11:51:56 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:51:56 2024 +0100

    tools/9pfsd: add missing va_end() in fill_data()
    
    In xen-9pfsd fill_data() va_end() needs to be called before returning.
    
    Coverity Id CID 1592145
    
    Fixes: bcec59cf7ff4 ("tools/xen-9pfsd: add 9pfs version request support")
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/9pfsd/io.c | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/tools/9pfsd/io.c b/tools/9pfsd/io.c
index ebc4102713..adb887c7d9 100644
--- a/tools/9pfsd/io.c
+++ b/tools/9pfsd/io.c
@@ -445,7 +445,7 @@ static int fill_data(struct ring *ring, const char *fmt, ...)
             if ( !*f || array_sz )
                 fmt_err(fmt);
             if ( !chk_data(ring, data, sizeof(uint16_t)) )
-                return pars;
+                goto out;
             array_sz = get_unaligned((uint16_t *)data);
             data += sizeof(uint16_t);
             *(unsigned int *)par = array_sz;
@@ -455,10 +455,10 @@ static int fill_data(struct ring *ring, const char *fmt, ...)
 
         case 'b':
             if ( !chk_data(ring, data, sizeof(uint8_t)) )
-                return pars;
+                goto out;
             if ( !fill_data_elem(&par, array, &array_sz, sizeof(uint8_t),
                                  data) )
-                return pars;
+                goto out;
             data += sizeof(uint8_t);
             break;
 
@@ -466,48 +466,48 @@ static int fill_data(struct ring *ring, const char *fmt, ...)
             if ( array_sz )
                 fmt_err(fmt);
             if ( !chk_data(ring, data, sizeof(uint32_t)) )
-                return pars;
+                goto out;
             len = get_unaligned((uint32_t *)data);
             data += sizeof(uint32_t);
             *(unsigned int *)par = len;
             par = va_arg(ap, void *);
             if ( !chk_data(ring, data, len) )
-                return pars;
+                goto out;
             memcpy(par, data, len);
             data += len;
             break;
 
         case 'L':
             if ( !chk_data(ring, data, sizeof(uint64_t)) )
-                return pars;
+                goto out;
             if ( !fill_data_elem(&par, array, &array_sz, sizeof(uint64_t),
                                  data) )
-                return pars;
+                goto out;
             data += sizeof(uint64_t);
             break;
 
         case 'S':
             if ( !chk_data(ring, data, sizeof(uint16_t)) )
-                return pars;
+                goto out;
             len = get_unaligned((uint16_t *)data);
             data += sizeof(uint16_t);
             if ( !chk_data(ring, data, len) )
-                return pars;
+                goto out;
             str_off = add_string(ring, data, len);
             if ( str_off == ~0 )
-                return pars;
+                goto out;
             if ( !fill_data_elem(&par, array, &array_sz, sizeof(unsigned int),
                                  &str_off) )
-                return pars;
+                goto out;
             data += len;
             break;
 
         case 'U':
             if ( !chk_data(ring, data, sizeof(uint32_t)) )
-                return pars;
+                goto out;
             if ( !fill_data_elem(&par, array, &array_sz, sizeof(uint32_t),
                                  data) )
-                return pars;
+                goto out;
             data += sizeof(uint32_t);
             break;
 
@@ -520,6 +520,9 @@ static int fill_data(struct ring *ring, const char *fmt, ...)
         pars++;
     }
 
+ out:
+    va_end(ap);
+
     return pars;
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 04:55:53 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 04:55:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684619.1064596 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNbF-0001HM-Tf; Fri, 23 Feb 2024 04:55:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684619.1064596; Fri, 23 Feb 2024 04:55:53 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNbF-0001HE-R0; Fri, 23 Feb 2024 04:55:53 +0000
Received: by outflank-mailman (input) for mailman id 684619;
 Fri, 23 Feb 2024 04:55:52 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNbE-0001H8-MN
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:52 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNbE-00008D-Lb
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNbE-0004op-Kj
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:55:52 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=2Bo+4wfL1SYWgnMQlc31VXPDsiYGpVuuj5g9ilqu1Uo=; b=UmyKlMJTJbnzJZbOHleqiU+hCI
	a337Vi9HSWjE1XU7IKvaT3RnHScuON3K/sDLXX7Kkq49QRRR8aU2BPJvKMIjqLOqxOfUn6kvHht8a
	ZdHzGCnV7hGO4jY+Sxr9fLuWGE56VkKj3ZmkMCu5vmbLO8FiptlSIWBOL7Fb3W+eGt3o=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] build: make sure build fails when running kconfig fails
Message-Id: <E1rdNbE-0004op-Kj@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 04:55:52 +0000

commit d34e5fa2e8db19f23081f46a3e710bb122130691
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 11:52:47 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:52:47 2024 +0100

    build: make sure build fails when running kconfig fails
    
    Because of using "-include", failure to (re)build auto.conf (with
    auto.conf.cmd produced as a secondary target) won't stop make from
    continuing the build. Arrange for it being possible to drop the - from
    Rules.mk, requiring that the include be skipped for tools-only targets.
    Note that relying on the inclusion in those cases wouldn't be correct
    anyway, as it might be a stale file (yet to be rebuilt) which would be
    included, while during initial build, the file would be absent
    altogether.
    
    Fixes: 8d4c17a90b0a ("xen/build: silence make warnings about missing auto.conf*")
    Reported-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 xen/Makefile | 1 +
 xen/Rules.mk | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/xen/Makefile b/xen/Makefile
index 767e47d6c7..b6c39fc6ae 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -375,6 +375,7 @@ $(KCONFIG_CONFIG): tools_fixdep
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
+	$(Q)rm -f include/config/auto.conf
 	$(Q)$(MAKE) $(build)=tools/kconfig syncconfig
 
 ifeq ($(CONFIG_DEBUG),y)
diff --git a/xen/Rules.mk b/xen/Rules.mk
index 8af3dd7277..d759cccee3 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -15,7 +15,9 @@ srcdir := $(srctree)/$(src)
 PHONY := __build
 __build:
 
--include $(objtree)/include/config/auto.conf
+ifneq ($(firstword $(subst /, ,$(obj))),tools)
+include $(objtree)/include/config/auto.conf
+endif
 
 include $(XEN_ROOT)/Config.mk
 include $(srctree)/scripts/Kbuild.include
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 04:56:03 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 04:56:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684620.1064600 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNbP-0001KC-V1; Fri, 23 Feb 2024 04:56:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684620.1064600; Fri, 23 Feb 2024 04:56:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNbP-0001K4-SU; Fri, 23 Feb 2024 04:56:03 +0000
Received: by outflank-mailman (input) for mailman id 684620;
 Fri, 23 Feb 2024 04:56:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNbO-0001Js-PQ
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:56:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNbO-00008g-Og
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:56:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNbO-0004q1-Nc
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:56:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=dIHIu2coVeLsuEiBAz5U+C3tBdPBODsKCdthKPTdaSk=; b=sS4r7q5dxKEIDn8gIU9siXuU+y
	sOSZm0pQHGx+1BKlU1Tk+DsUl2DRARfpfrg2IgJ/pJRkWvzBL68L32rxSrmEe4+XRoNbsotTiwCHg
	s6a8ASIBFzO1CkF4fhlmHmCGo6P3Gu1nuk00kcfDraKgZuuBCrf+h89J1iG9beahZi30=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/uaccess: add attribute noreturn to __{get,put}_user_bad()
Message-Id: <E1rdNbO-0004q1-Nc@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 04:56:02 +0000

commit 54557ee9b4ad8f2ed708c3dd222ee0db74d4c83b
Author:     Federico Serafini <federico.serafini@bugseng.com>
AuthorDate: Thu Feb 22 11:53:23 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:53:23 2024 +0100

    x86/uaccess: add attribute noreturn to __{get,put}_user_bad()
    
    __get_user_bad() and __put_user_bad() are undefined symbols used
    to assert the unreachability of a program point:
    a call to one of such functions is optimized away if it is considered
    unreachable by the compiler. Otherwise, a linker error is reported.
    
    In accordance with the purpose of such constructs:
    1) add the attribute noreturn to __get_user_bad() and __put_user_bad();
    2) change return type of __get_user_bad() to void (returning long is a
       leftover from the past).
    
    Point (1) meets the requirements to deviate MISRA C:2012 Rule 16.3
    ("An unconditional break statement shall terminate every switch
    clause") since functions with noreturn attribute are considered
    as allowed terminals for switch clauses.
    
    Point (2) addresses several violations of MISRA C:2012 Rule 17.7
    ("The value returned by a function having non-void return type
    shall be used").
    
    While there also zap "extern".
    
    No functional change.
    
    Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/include/asm/uaccess.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/include/asm/uaccess.h b/xen/arch/x86/include/asm/uaccess.h
index 7443519d5b..55bc6932fd 100644
--- a/xen/arch/x86/include/asm/uaccess.h
+++ b/xen/arch/x86/include/asm/uaccess.h
@@ -21,8 +21,8 @@ unsigned int copy_from_guest_ll(void *to, const void __user *from, unsigned int
 unsigned int copy_to_unsafe_ll(void *to, const void *from, unsigned int n);
 unsigned int copy_from_unsafe_ll(void *to, const void *from, unsigned int n);
 
-extern long __get_user_bad(void);
-extern void __put_user_bad(void);
+void noreturn __get_user_bad(void);
+void noreturn __put_user_bad(void);
 
 #define UA_KEEP(args...) args
 #define UA_DROP(args...)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 04:56:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 04:56:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684622.1064603 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNba-0001Mx-06; Fri, 23 Feb 2024 04:56:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684622.1064603; Fri, 23 Feb 2024 04:56:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNbZ-0001Mq-Tv; Fri, 23 Feb 2024 04:56:13 +0000
Received: by outflank-mailman (input) for mailman id 684622;
 Fri, 23 Feb 2024 04:56:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNbY-0001Mi-UL
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:56:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNbY-00009G-Ro
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:56:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNbY-0004qS-R7
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:56:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=16x142aeo8A+zsZZQi00Fbi7yNONIrCGl+sFKt1vUbU=; b=lyHxefZbnGpgRfKHzQaPrSarJa
	guxOw6EZnjpuRCC2ItLyYMjsj3pQk2xvptAGE6p1Y6zpzin1Bs+4PeeeAv3cP3q60Gu2RQn+4aWNZ
	NjXl180bZGfi1DI8VGcnTeNrmbLmDDB2jdudfPfI7LE2Bxam1n0j7p5Vdchdg8hgS6ME=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86emul: add missing EVEX.R' checks
Message-Id: <E1rdNbY-0004qS-R7@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 04:56:12 +0000

commit cb319824bfa8d3c9ea0410cc71daaedc3e11aa2a
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 11:54:07 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:54:07 2024 +0100

    x86emul: add missing EVEX.R' checks
    
    EVEX.R' is not ignored in 64-bit code when encoding a GPR or mask
    register. While for mask registers suitable checks are in place (there
    also covering EVEX.R), they were missing for the few cases where in
    EVEX-encoded instructions ModR/M.reg encodes a GPR. While for VPEXTRW
    the bit is replaced before an emulation stub is invoked, for
    VCVT{,T}{S,D,H}2{,U}SI this actually would have led to #UD from inside
    an emulation stub, in turn raising #UD to the guest, but accompanied by
    log messages indicating something's wrong in Xen nevertheless.
    
    Fixes: 001bd91ad864 ("x86emul: support AVX512{F,BW,DQ} extract insns")
    Fixes: baf4a376f550 ("x86emul: support AVX512F legacy-equivalent scalar int/FP conversion insns")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/x86_emulate/x86_emulate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index ed710596dc..2d5c1de8ec 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -3686,7 +3686,8 @@ x86_emulate(
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x2d): /* vcvts{s,d}2si xmm/mem,reg */
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x78): /* vcvtts{s,d}2usi xmm/mem,reg */
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x79): /* vcvts{s,d}2usi xmm/mem,reg */
-        generate_exception_if((evex.reg != 0xf || !evex.RX || evex.opmsk ||
+        generate_exception_if((evex.reg != 0xf || !evex.RX || !evex.R ||
+                               evex.opmsk ||
                                (ea.type != OP_REG && evex.brs)),
                               X86_EXC_UD);
         host_and_vcpu_must_have(avx512f);
@@ -7327,7 +7328,7 @@ x86_emulate(
         goto pextr;
 
     case X86EMUL_OPC_EVEX_66(0x0f, 0xc5):   /* vpextrw $imm8,xmm,reg */
-        generate_exception_if(ea.type != OP_REG, X86_EXC_UD);
+        generate_exception_if(ea.type != OP_REG || !evex.R, X86_EXC_UD);
         /* Convert to alternative encoding: We want to use a memory operand. */
         evex.opcx = ext_0f3a;
         b = 0x15;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 04:56:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 04:56:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684623.1064609 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNbk-0001Pu-2J; Fri, 23 Feb 2024 04:56:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684623.1064609; Fri, 23 Feb 2024 04:56:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdNbj-0001Pm-VS; Fri, 23 Feb 2024 04:56:23 +0000
Received: by outflank-mailman (input) for mailman id 684623;
 Fri, 23 Feb 2024 04:56:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNbi-0001PW-VM
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:56:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNbi-00009P-Ul
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:56:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdNbi-0004qu-Tr
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 04:56:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=sERHovk//JBAFAJULi5Qi5JbkpBUJGUpOYS9yXJnRYc=; b=VchNqasVLtDnaNvU+0CteQCcrO
	76X0YAVcVTZeZHVDRDIfGMaVsGcf4OyOu3JPqqrnqx10cHptjMlqIpikAwllMpNJy9gQoi2F2+/WP
	NXR8VvoOfNWDudzQpFiQxCknxgKPQeliq3n3YoGCdXWnah90ejKRMrKsA3VIJfTTArTw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86emul: make run32 test harness goal work again
Message-Id: <E1rdNbi-0004qu-Tr@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 04:56:22 +0000

commit 9ee7dc877b8754ce2fc82500feea52c04d4e6409
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 11:54:32 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 11:54:32 2024 +0100

    x86emul: make run32 test harness goal work again
    
    When re-working library call wrapping the sed invocation didn't account
    for all sources living in the parent directory when building the 32-bit
    harness binary.
    
    Fixes: 6fba45ca3be1 ("x86emul: rework wrapping of libc functions in test and fuzzing harnesses")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 tools/tests/x86_emulator/Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/tests/x86_emulator/Makefile b/tools/tests/x86_emulator/Makefile
index b45ad09c28..834b2112e7 100644
--- a/tools/tests/x86_emulator/Makefile
+++ b/tools/tests/x86_emulator/Makefile
@@ -255,7 +255,8 @@ OBJS := x86-emulate.o cpuid.o test_x86_emulator.o evex-disp8.o predicates.o wrap
 OBJS += x86_emulate/0f01.o x86_emulate/0fae.o x86_emulate/0fc7.o
 OBJS += x86_emulate/blk.o x86_emulate/decode.o x86_emulate/fpu.o x86_emulate/util.o
 
-WRAPPED := $(shell sed -n 's,^ *WRAP(\([[:alnum:]_]*\));,\1,p' x86-emulate.h)
+WRAPPED := $(shell sed -n 's,^ *WRAP(\([[:alnum:]_]*\));,\1,p' \
+                       $(firstword $(wildcard ../x86-emulate.h) x86-emulate.h))
 
 $(TARGET): $(OBJS)
 	$(HOSTCC) $(HOSTCFLAGS) $(addprefix -Wl$(comma)--wrap=,$(WRAPPED)) -o $@ $^
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 15:22:09 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 15:22:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684881.1065072 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXNC-0006D1-U2; Fri, 23 Feb 2024 15:22:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684881.1065072; Fri, 23 Feb 2024 15:22:02 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXNC-0006Cs-R6; Fri, 23 Feb 2024 15:22:02 +0000
Received: by outflank-mailman (input) for mailman id 684881;
 Fri, 23 Feb 2024 15:22:01 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXNB-0006Cm-SW
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:01 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXNB-0004fC-Q5
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXNB-00040a-Lc
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=MMupgVkv1NoC1x310meeuX6lYa+wsq/NLEE6QgW5cvM=; b=viwA1wfSfu15bQStCb0cPRunPU
	kLytlCknLtkcH5bZCzbfSY0fHqICI9KlsVq6jIlp0O/xr/sfmkdbo3Qidizy35jmeTVAfAIMdRCcw
	utau56NLz9agW1V9jnQTzX6MKPGMj27beuPhxLI1ECiNVFUcU8JQRm67SqH/H7qF0s3o=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] serial: fake IRQ-regs context in poll handlers
Message-Id: <E1rdXNB-00040a-Lc@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 15:22:01 +0000

commit ba3c8373cd67845fd59877959dd3650ec6c557d7
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 12:10:38 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 12:10:38 2024 +0100

    serial: fake IRQ-regs context in poll handlers
    
    In preparation of dropping the register parameters from
    serial_[rt]x_interrupt() and in turn from IRQ handler functions,
    register state needs making available another way for the few key
    handlers which need it. Fake IRQ-like state.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/drivers/char/ehci-dbgp.c | 6 ++++++
 xen/drivers/char/ns16550.c   | 5 +++++
 2 files changed, 11 insertions(+)

diff --git a/xen/drivers/char/ehci-dbgp.c b/xen/drivers/char/ehci-dbgp.c
index bbf4e51c02..1497fe7c84 100644
--- a/xen/drivers/char/ehci-dbgp.c
+++ b/xen/drivers/char/ehci-dbgp.c
@@ -1253,6 +1253,7 @@ static void cf_check _ehci_dbgp_poll(struct cpu_user_regs *regs)
     unsigned long flags;
     unsigned int timeout = MICROSECS(DBGP_CHECK_INTERVAL);
     bool empty = false;
+    struct cpu_user_regs *old_regs;
 
     if ( !dbgp->ehci_debug )
         return;
@@ -1268,12 +1269,17 @@ static void cf_check _ehci_dbgp_poll(struct cpu_user_regs *regs)
         spin_unlock_irqrestore(&port->tx_lock, flags);
     }
 
+    /* Mimic interrupt context. */
+    old_regs = set_irq_regs(regs);
+
     if ( dbgp->in.chunk )
         serial_rx_interrupt(port, regs);
 
     if ( empty )
         serial_tx_interrupt(port, regs);
 
+    set_irq_regs(old_regs);
+
     if ( spin_trylock_irqsave(&port->tx_lock, flags) )
     {
         if ( dbgp->state == dbgp_idle && !dbgp->in.chunk &&
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index 97bf098534..664d490571 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -211,10 +211,14 @@ static void cf_check __ns16550_poll(struct cpu_user_regs *regs)
 {
     struct serial_port *port = this_cpu(poll_port);
     struct ns16550 *uart = port->uart;
+    struct cpu_user_regs *old_regs;
 
     if ( uart->intr_works )
         return; /* Interrupts work - no more polling */
 
+    /* Mimic interrupt context. */
+    old_regs = set_irq_regs(regs);
+
     while ( ns_read_reg(uart, UART_LSR) & UART_LSR_DR )
     {
         if ( ns16550_ioport_invalid(uart) )
@@ -227,6 +231,7 @@ static void cf_check __ns16550_poll(struct cpu_user_regs *regs)
         serial_tx_interrupt(port, regs);
 
 out:
+    set_irq_regs(old_regs);
     set_timer(&uart->timer, NOW() + MILLISECS(uart->timeout_ms));
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 15:22:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 15:22:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684882.1065077 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXNN-0006Em-0P; Fri, 23 Feb 2024 15:22:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684882.1065077; Fri, 23 Feb 2024 15:22:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXNM-0006Ee-SZ; Fri, 23 Feb 2024 15:22:12 +0000
Received: by outflank-mailman (input) for mailman id 684882;
 Fri, 23 Feb 2024 15:22:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXNL-0006EU-Vo
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:11 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXNL-0004fH-V5
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXNL-00041P-SJ
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:11 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=b3zNCgRV8YqGEgwq2whODLVLb18QDAriK+f+ANYnF+A=; b=v0DgcU7ewGa4XUMFBqtrkEPj7J
	hRqowgy2P4LkqbSlKGaX7zvlMMspJd2g0Ua8OhrjYTOGgpoUFyUI/fh9M0wKUB6Dj0c8eEXcKTXPd
	ugO4//QssStfFcQ4+wuumeAifKewSTsM0S8bZzWGevNTdM5BbtWHh3bfus3pvZbA+YW0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] keyhandler: drop regs parameter from handle_keyregs()
Message-Id: <E1rdXNL-00041P-SJ@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 15:22:11 +0000

commit feb338d843de4dd0cce78f6be68b3744e91d5567
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 12:11:47 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 12:11:47 2024 +0100

    keyhandler: drop regs parameter from handle_keyregs()
    
    In preparation for further removal of regs parameters, drop it here. In
    the two places where it's actually needed, retrieve IRQ context if
    available, or else guest context.
    
    Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/common/keyhandler.c      | 25 +++++++++++--------------
 xen/common/sysctl.c          |  2 +-
 xen/drivers/char/console.c   |  8 ++++----
 xen/include/xen/keyhandler.h |  5 ++---
 4 files changed, 18 insertions(+), 22 deletions(-)

diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c
index f131034d33..9c23a540e5 100644
--- a/xen/common/keyhandler.c
+++ b/xen/common/keyhandler.c
@@ -73,12 +73,12 @@ static struct keyhandler {
 
 static void cf_check keypress_action(void *unused)
 {
-    handle_keypress(keypress_key, NULL);
+    handle_keypress(keypress_key, true);
 }
 
 static DECLARE_TASKLET(keypress_tasklet, keypress_action, NULL);
 
-void handle_keypress(unsigned char key, struct cpu_user_regs *regs)
+void handle_keypress(unsigned char key, bool need_context)
 {
     struct keyhandler *h;
 
@@ -88,7 +88,7 @@ void handle_keypress(unsigned char key, struct cpu_user_regs *regs)
     if ( !in_irq() || h->irq_callback )
     {
         console_start_log_everything();
-        h->irq_callback ? h->irq_fn(key, regs) : h->fn(key);
+        h->irq_callback ? h->irq_fn(key, need_context) : h->fn(key);
         console_end_log_everything();
     }
     else
@@ -169,7 +169,7 @@ void cf_check dump_execstate(struct cpu_user_regs *regs)
 }
 
 static void cf_check dump_registers(
-    unsigned char key, struct cpu_user_regs *regs)
+    unsigned char key, bool need_context)
 {
     unsigned int cpu;
 
@@ -182,8 +182,8 @@ static void cf_check dump_registers(
     cpumask_copy(&dump_execstate_mask, &cpu_online_map);
 
     /* Get local execution state out immediately, in case we get stuck. */
-    if ( regs )
-        dump_execstate(regs);
+    if ( !need_context )
+        dump_execstate(get_irq_regs() ?: guest_cpu_user_regs());
     else
         run_in_exception_handler(dump_execstate);
 
@@ -245,8 +245,7 @@ static void cf_check dump_hwdom_registers(unsigned char key)
     }
 }
 
-static void cf_check reboot_machine(
-    unsigned char key, struct cpu_user_regs *regs)
+static void cf_check reboot_machine(unsigned char key, bool unused)
 {
     printk("'%c' pressed -> rebooting machine\n", key);
     machine_restart(0);
@@ -474,8 +473,7 @@ static void cf_check run_all_nonirq_keyhandlers(void *unused)
 static DECLARE_TASKLET(run_all_keyhandlers_tasklet,
                        run_all_nonirq_keyhandlers, NULL);
 
-static void cf_check run_all_keyhandlers(
-    unsigned char key, struct cpu_user_regs *regs)
+static void cf_check run_all_keyhandlers(unsigned char key, bool need_context)
 {
     struct keyhandler *h;
     unsigned int k;
@@ -491,7 +489,7 @@ static void cf_check run_all_keyhandlers(
         if ( !h->irq_fn || !h->diagnostic || !h->irq_callback )
             continue;
         printk("[%c: %s]\n", k, h->desc);
-        h->irq_fn(k, regs);
+        h->irq_fn(k, need_context);
     }
 
     watchdog_enable();
@@ -500,8 +498,7 @@ static void cf_check run_all_keyhandlers(
     tasklet_schedule(&run_all_keyhandlers_tasklet);
 }
 
-static void cf_check do_toggle_alt_key(
-    unsigned char key, struct cpu_user_regs *regs)
+static void cf_check do_toggle_alt_key(unsigned char key, bool unused)
 {
     alt_key_handling = !alt_key_handling;
     printk("'%c' pressed -> using %s key handling\n", key,
@@ -566,7 +563,7 @@ void keyhandler_crash_action(enum crash_reason reason)
         if ( *action == '+' )
             mdelay(10);
         else
-            handle_keypress(*action, NULL);
+            handle_keypress(*action, true);
         action++;
     }
 }
diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index 2906f3f294..d02f44fe3a 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -134,7 +134,7 @@ long do_sysctl(XEN_GUEST_HANDLE_PARAM(xen_sysctl_t) u_sysctl)
         {
             if ( copy_from_guest_offset(&c, op->u.debug_keys.keys, i, 1) )
                 goto out;
-            handle_keypress(c, guest_cpu_user_regs());
+            handle_keypress(c, false);
         }
         ret = 0;
         copyback = 0;
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index dce0226e87..6e66d0eff1 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -279,7 +279,7 @@ static int *__read_mostly upper_thresh_adj = &xenlog_upper_thresh;
 static int *__read_mostly lower_thresh_adj = &xenlog_lower_thresh;
 static const char *__read_mostly thresh_adj = "standard";
 
-static void cf_check do_toggle_guest(unsigned char key, struct cpu_user_regs *regs)
+static void cf_check do_toggle_guest(unsigned char key, bool unused)
 {
     if ( upper_thresh_adj == &xenlog_upper_thresh )
     {
@@ -306,13 +306,13 @@ static void do_adj_thresh(unsigned char key)
            loglvl_str(*upper_thresh_adj));
 }
 
-static void cf_check do_inc_thresh(unsigned char key, struct cpu_user_regs *regs)
+static void cf_check do_inc_thresh(unsigned char key, bool unused)
 {
     ++*lower_thresh_adj;
     do_adj_thresh(key);
 }
 
-static void cf_check do_dec_thresh(unsigned char key, struct cpu_user_regs *regs)
+static void cf_check do_dec_thresh(unsigned char key, bool unused)
 {
     if ( *lower_thresh_adj )
         --*lower_thresh_adj;
@@ -531,7 +531,7 @@ static void __serial_rx(char c, struct cpu_user_regs *regs)
     switch ( console_rx )
     {
     case 0:
-        return handle_keypress(c, regs);
+        return handle_keypress(c, false);
 
     case 1:
         /*
diff --git a/xen/include/xen/keyhandler.h b/xen/include/xen/keyhandler.h
index 5c6598af98..6fee878fdf 100644
--- a/xen/include/xen/keyhandler.h
+++ b/xen/include/xen/keyhandler.h
@@ -24,9 +24,8 @@ typedef void (keyhandler_fn_t)(unsigned char key);
  *
  * Called in hardirq context with interrupts disabled.
  */
-struct cpu_user_regs;
 typedef void (irq_keyhandler_fn_t)(unsigned char key,
-                                   struct cpu_user_regs *regs);
+                                   bool need_context);
 
 /* Initialize keytable with default handlers. */
 void initialize_keytable(void);
@@ -46,7 +45,7 @@ void register_irq_keyhandler(unsigned char key,
                              bool diagnostic);
 
 /* Inject a keypress into the key-handling subsystem. */
-extern void handle_keypress(unsigned char key, struct cpu_user_regs *regs);
+extern void handle_keypress(unsigned char key, bool need_context);
 
 enum crash_reason {
     CRASHREASON_PANIC,
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 15:22:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 15:22:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684883.1065079 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXNX-0006H7-10; Fri, 23 Feb 2024 15:22:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684883.1065079; Fri, 23 Feb 2024 15:22:22 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXNW-0006H0-UF; Fri, 23 Feb 2024 15:22:22 +0000
Received: by outflank-mailman (input) for mailman id 684883;
 Fri, 23 Feb 2024 15:22:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXNW-0006Gs-86
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXNW-0004fo-5R
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXNW-00043W-11
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=8cKvYEy1e3W36ZayUErASIiN78P3RN8lhD63yFnLkVE=; b=3QM5iLz9MjDBypoHSZ3EiDoun+
	uHgEHcmMCzrsNnO7lISBmslWOrqAx1QlkrqQ/qQVKxVPzfsxAIgiBVwtDSgHSViKbZTqnUh4N1DuQ
	diPOxwbyeKyf/DcyIJDytMxJKHuiK75N+HeW4itFxg5+72JaCmmUHch4EgiRKxyssZ5Q=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] serial: drop serial_rx_fn's regs parameter
Message-Id: <E1rdXNW-00043W-11@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 15:22:22 +0000

commit 4f09e5102740b3dd2d269ea04de93fd126f399d1
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 12:12:34 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 12:12:34 2024 +0100

    serial: drop serial_rx_fn's regs parameter
    
    It's simply not needed anymore.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/drivers/char/console.c        | 8 ++++----
 xen/drivers/char/serial.c         | 2 +-
 xen/drivers/char/xen_pv_console.c | 2 +-
 xen/include/xen/serial.h          | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 6e66d0eff1..d2cb0530b2 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -526,7 +526,7 @@ static void switch_serial_input(void)
     printk("\n");
 }
 
-static void __serial_rx(char c, struct cpu_user_regs *regs)
+static void __serial_rx(char c)
 {
     switch ( console_rx )
     {
@@ -578,7 +578,7 @@ static void __serial_rx(char c, struct cpu_user_regs *regs)
 #endif
 }
 
-static void cf_check serial_rx(char c, struct cpu_user_regs *regs)
+static void cf_check serial_rx(char c)
 {
     static int switch_code_count = 0;
 
@@ -594,10 +594,10 @@ static void cf_check serial_rx(char c, struct cpu_user_regs *regs)
     }
 
     for ( ; switch_code_count != 0; switch_code_count-- )
-        __serial_rx(switch_code, regs);
+        __serial_rx(switch_code);
 
     /* Finally process the just-received character. */
-    __serial_rx(c, regs);
+    __serial_rx(c);
 }
 
 static void cf_check notify_dom0_con_ring(void *unused)
diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
index 93e217d348..0b30326843 100644
--- a/xen/drivers/char/serial.c
+++ b/xen/drivers/char/serial.c
@@ -68,7 +68,7 @@ void serial_rx_interrupt(struct serial_port *port, struct cpu_user_regs *regs)
     spin_unlock_irqrestore(&port->rx_lock, flags);
 
     if ( fn != NULL )
-        (*fn)(c & 0x7f, regs);
+        fn(c & 0x7f);
 }
 
 void serial_tx_interrupt(struct serial_port *port, struct cpu_user_regs *regs)
diff --git a/xen/drivers/char/xen_pv_console.c b/xen/drivers/char/xen_pv_console.c
index 1536bdaf52..c4c5623971 100644
--- a/xen/drivers/char/xen_pv_console.c
+++ b/xen/drivers/char/xen_pv_console.c
@@ -118,7 +118,7 @@ size_t pv_console_rx(struct cpu_user_regs *regs)
     {
         c = cons_ring->in[MASK_XENCONS_IDX(cons++, cons_ring->in)];
         if ( cons_rx_handler )
-            cons_rx_handler(c, regs);
+            cons_rx_handler(c);
         recv++;
     }
 
diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
index 7548bb7324..92979e37e2 100644
--- a/xen/include/xen/serial.h
+++ b/xen/include/xen/serial.h
@@ -15,7 +15,7 @@
 struct cpu_user_regs;
 
 /* Register a character-receive hook on the specified COM port. */
-typedef void (*serial_rx_fn)(char c, struct cpu_user_regs *regs);
+typedef void (*serial_rx_fn)(char c);
 void serial_set_rx_handler(int handle, serial_rx_fn fn);
 
 /* Number of characters we buffer for a polling receiver. */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 15:22:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 15:22:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684884.1065083 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXNh-0006KG-29; Fri, 23 Feb 2024 15:22:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684884.1065083; Fri, 23 Feb 2024 15:22:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXNg-0006K8-Vo; Fri, 23 Feb 2024 15:22:32 +0000
Received: by outflank-mailman (input) for mailman id 684884;
 Fri, 23 Feb 2024 15:22:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXNg-0006K1-9D
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXNg-0004g4-8Q
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXNg-000449-7f
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=HXjEf0xqAT/u/JcfPa6h2ekrJrW4Bk4l26xcEkhmGK8=; b=qhyakC1ANakl6K7rHbviredDK5
	rHRvGeUQM8rSOoM4NtIxSB9IVdFeWixPV7pgvnNdH45yjoOg048Kt0x57iJqZ0R3TdKqkB1SrF6UR
	YRQJxuOuad5V6rwDYMpXeQbmzuxMFWkbBeoQSKlmCKd6JlwV8hRNajASVKsSbt+PV6b0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] PV-shim: drop pv_console_rx()'s regs parameter
Message-Id: <E1rdXNg-000449-7f@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 15:22:32 +0000

commit e1e0579afa0840e01ca2bfb1cbc8a4aaadce7794
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 12:13:33 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 12:13:33 2024 +0100

    PV-shim: drop pv_console_rx()'s regs parameter
    
    It's not needed anymore. This is in preparation of dropping the register
    parameters from IRQ handler functions.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/guest/xen/xen.c      | 2 +-
 xen/drivers/char/xen_pv_console.c | 2 +-
 xen/include/xen/pv_console.h      | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c
index 44a689d439..ec66fc84d1 100644
--- a/xen/arch/x86/guest/xen/xen.c
+++ b/xen/arch/x86/guest/xen/xen.c
@@ -181,7 +181,7 @@ static void cf_check xen_evtchn_upcall(struct cpu_user_regs *regs)
             port += l1 * BITS_PER_LONG;
 
             if ( pv_console && port == pv_console_evtchn() )
-                pv_console_rx(regs);
+                pv_console_rx();
             else if ( pv_shim )
                 pv_shim_inject_evtchn(port);
         }
diff --git a/xen/drivers/char/xen_pv_console.c b/xen/drivers/char/xen_pv_console.c
index c4c5623971..25c349c22f 100644
--- a/xen/drivers/char/xen_pv_console.c
+++ b/xen/drivers/char/xen_pv_console.c
@@ -94,7 +94,7 @@ evtchn_port_t pv_console_evtchn(void)
     return cons_evtchn;
 }
 
-size_t pv_console_rx(struct cpu_user_regs *regs)
+size_t pv_console_rx(void)
 {
     char c;
     XENCONS_RING_IDX cons, prod;
diff --git a/xen/include/xen/pv_console.h b/xen/include/xen/pv_console.h
index 55b20323fb..2133aa71cb 100644
--- a/xen/include/xen/pv_console.h
+++ b/xen/include/xen/pv_console.h
@@ -9,7 +9,7 @@ void pv_console_init(void);
 void pv_console_set_rx_handler(serial_rx_fn fn);
 void pv_console_init_postirq(void);
 void pv_console_puts(const char *buf, size_t nr);
-size_t pv_console_rx(struct cpu_user_regs *regs);
+size_t pv_console_rx(void);
 evtchn_port_t pv_console_evtchn(void);
 
 #else
@@ -18,7 +18,7 @@ static inline void pv_console_init(void) {}
 static inline void pv_console_set_rx_handler(serial_rx_fn fn) { }
 static inline void pv_console_init_postirq(void) { }
 static inline void pv_console_puts(const char *buf, size_t nr) { }
-static inline size_t pv_console_rx(struct cpu_user_regs *regs) { return 0; }
+static inline size_t pv_console_rx(void) { return 0; }
 
 #endif /* !CONFIG_XEN_GUEST */
 #endif /* __XEN_PV_CONSOLE_H__ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 15:22:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 15:22:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684885.1065088 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXNs-0006Mq-3k; Fri, 23 Feb 2024 15:22:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684885.1065088; Fri, 23 Feb 2024 15:22:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXNs-0006Mi-17; Fri, 23 Feb 2024 15:22:44 +0000
Received: by outflank-mailman (input) for mailman id 684885;
 Fri, 23 Feb 2024 15:22:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXNq-0006MZ-CV
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXNq-0004gF-Bh
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXNq-00044m-Av
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=v8Kwm+m4avq76rhHXoZpfe+4ScbwvbePMEZGTiKqSdg=; b=S7qX2HAjPuu8JQ62z+GqbUPQ22
	HlKXbRJvgAmS+1zbTGD0xVBadxOdvg98K/gF20hb7C9YD3w07RGamFvROglvOJuQVWP3nMKtEyvNA
	NX/I/kdyNHx4bI2VlUpiEsK7IR+u1OE48iBUJRjVaF8ru4xRAjQppSzsXyx9VTAOKwKw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] serial: drop serial_[rt]x_interrupt()'s regs parameter
Message-Id: <E1rdXNq-00044m-Av@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 15:22:42 +0000

commit b31e753fe799b226b5e9d500f96588a8657d4a66
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 12:14:19 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 12:14:19 2024 +0100

    serial: drop serial_[rt]x_interrupt()'s regs parameter
    
    They're simply not needed anymore.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/drivers/char/cadence-uart.c    | 2 +-
 xen/drivers/char/ehci-dbgp.c       | 4 ++--
 xen/drivers/char/exynos4210-uart.c | 4 ++--
 xen/drivers/char/imx-lpuart.c      | 4 ++--
 xen/drivers/char/meson-uart.c      | 4 ++--
 xen/drivers/char/mvebu-uart.c      | 4 ++--
 xen/drivers/char/ns16550.c         | 8 ++++----
 xen/drivers/char/omap-uart.c       | 4 ++--
 xen/drivers/char/pl011.c           | 4 ++--
 xen/drivers/char/scif-uart.c       | 4 ++--
 xen/drivers/char/serial.c          | 4 ++--
 xen/drivers/char/xhci-dbc.c        | 5 +++--
 xen/include/xen/serial.h           | 6 ++----
 13 files changed, 28 insertions(+), 29 deletions(-)

diff --git a/xen/drivers/char/cadence-uart.c b/xen/drivers/char/cadence-uart.c
index c38d7ed143..0b670c64ed 100644
--- a/xen/drivers/char/cadence-uart.c
+++ b/xen/drivers/char/cadence-uart.c
@@ -51,7 +51,7 @@ static void cuart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
         /* ACK.  */
         if ( status & UART_SR_INTR_RTRIG )
         {
-            serial_rx_interrupt(port, regs);
+            serial_rx_interrupt(port);
             cuart_write(uart, R_UART_CISR, UART_SR_INTR_RTRIG);
         }
     } while ( status & UART_SR_INTR_RTRIG );
diff --git a/xen/drivers/char/ehci-dbgp.c b/xen/drivers/char/ehci-dbgp.c
index 1497fe7c84..2bb55418a7 100644
--- a/xen/drivers/char/ehci-dbgp.c
+++ b/xen/drivers/char/ehci-dbgp.c
@@ -1273,10 +1273,10 @@ static void cf_check _ehci_dbgp_poll(struct cpu_user_regs *regs)
     old_regs = set_irq_regs(regs);
 
     if ( dbgp->in.chunk )
-        serial_rx_interrupt(port, regs);
+        serial_rx_interrupt(port);
 
     if ( empty )
-        serial_tx_interrupt(port, regs);
+        serial_tx_interrupt(port);
 
     set_irq_regs(old_regs);
 
diff --git a/xen/drivers/char/exynos4210-uart.c b/xen/drivers/char/exynos4210-uart.c
index 2503392ccd..5c53860df6 100644
--- a/xen/drivers/char/exynos4210-uart.c
+++ b/xen/drivers/char/exynos4210-uart.c
@@ -81,7 +81,7 @@ static void exynos4210_uart_interrupt(int irq, void *data, struct cpu_user_regs
         if ( status & (UINTM_RXD | UINTM_ERROR) )
         {
             /* uart->regs[UINTM] |= RXD|ERROR; */
-            serial_rx_interrupt(port, regs);
+            serial_rx_interrupt(port);
             /* uart->regs[UINTM] &= ~(RXD|ERROR); */
             exynos4210_write(uart, UINTP, UINTM_RXD | UINTM_ERROR);
         }
@@ -89,7 +89,7 @@ static void exynos4210_uart_interrupt(int irq, void *data, struct cpu_user_regs
         if ( status & (UINTM_TXD | UINTM_MODEM) )
         {
             /* uart->regs[UINTM] |= TXD|MODEM; */
-            serial_tx_interrupt(port, regs);
+            serial_tx_interrupt(port);
             /* uart->regs[UINTM] &= ~(TXD|MODEM); */
             exynos4210_write(uart, UINTP, UINTM_TXD | UINTM_MODEM);
         }
diff --git a/xen/drivers/char/imx-lpuart.c b/xen/drivers/char/imx-lpuart.c
index 77f70c2719..f5b341e20b 100644
--- a/xen/drivers/char/imx-lpuart.c
+++ b/xen/drivers/char/imx-lpuart.c
@@ -48,10 +48,10 @@ static void imx_lpuart_interrupt(int irq, void *data,
     rxcnt = imx_lpuart_read(uart, UARTWATER) >> UARTWATER_RXCNT_OFF;
 
     if ( (sts & UARTSTAT_RDRF) || (rxcnt > 0) )
-	    serial_rx_interrupt(port, regs);
+	    serial_rx_interrupt(port);
 
     if ( sts & UARTSTAT_TDRE )
-	    serial_tx_interrupt(port, regs);
+	    serial_tx_interrupt(port);
 
     imx_lpuart_write(uart, UARTSTAT, sts);
 }
diff --git a/xen/drivers/char/meson-uart.c b/xen/drivers/char/meson-uart.c
index c627328122..640c29dd05 100644
--- a/xen/drivers/char/meson-uart.c
+++ b/xen/drivers/char/meson-uart.c
@@ -69,10 +69,10 @@ static void meson_uart_interrupt(int irq, void *data,
     uint32_t st = readl(uart->regs + AML_UART_STATUS_REG);
 
     if ( !(st & AML_UART_RX_FIFO_EMPTY) )
-        serial_rx_interrupt(port, regs);
+        serial_rx_interrupt(port);
 
     if ( !(st & AML_UART_TX_FIFO_FULL) )
-        serial_tx_interrupt(port, regs);
+        serial_tx_interrupt(port);
 }
 
 static void __init meson_uart_init_preirq(struct serial_port *port)
diff --git a/xen/drivers/char/mvebu-uart.c b/xen/drivers/char/mvebu-uart.c
index cc55173513..57c1259224 100644
--- a/xen/drivers/char/mvebu-uart.c
+++ b/xen/drivers/char/mvebu-uart.c
@@ -76,10 +76,10 @@ static void mvebu3700_uart_interrupt(int irq, void *data,
 
     if ( st & (STATUS_RX_RDY | STATUS_OVR_ERR | STATUS_FRM_ERR |
                STATUS_BRK_DET) )
-        serial_rx_interrupt(port, regs);
+        serial_rx_interrupt(port);
 
     if ( st & STATUS_TX_RDY )
-        serial_tx_interrupt(port, regs);
+        serial_tx_interrupt(port);
 }
 
 static void __init mvebu3700_uart_init_preirq(struct serial_port *port)
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index 664d490571..91f0624d74 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -188,9 +188,9 @@ static void cf_check ns16550_interrupt(
         u8 lsr = ns_read_reg(uart, UART_LSR);
 
         if ( (lsr & uart->lsr_mask) == uart->lsr_mask )
-            serial_tx_interrupt(port, regs);
+            serial_tx_interrupt(port);
         if ( lsr & UART_LSR_DR )
-            serial_rx_interrupt(port, regs);
+            serial_rx_interrupt(port);
 
         /* A "busy-detect" condition is observed on Allwinner/sunxi UART
          * after LCR is written during setup. It needs to be cleared at
@@ -224,11 +224,11 @@ static void cf_check __ns16550_poll(struct cpu_user_regs *regs)
         if ( ns16550_ioport_invalid(uart) )
             goto out;
 
-        serial_rx_interrupt(port, regs);
+        serial_rx_interrupt(port);
     }
 
     if ( ( ns_read_reg(uart, UART_LSR) & uart->lsr_mask ) == uart->lsr_mask )
-        serial_tx_interrupt(port, regs);
+        serial_tx_interrupt(port);
 
 out:
     set_irq_regs(old_regs);
diff --git a/xen/drivers/char/omap-uart.c b/xen/drivers/char/omap-uart.c
index 8e643cb039..fb842b1707 100644
--- a/xen/drivers/char/omap-uart.c
+++ b/xen/drivers/char/omap-uart.c
@@ -70,9 +70,9 @@ static void omap_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
     {
         lsr = omap_read(uart, UART_LSR) & 0xff;
 	if ( lsr & UART_LSR_THRE )
-            serial_tx_interrupt(port, regs);
+            serial_tx_interrupt(port);
 	if ( lsr & UART_LSR_DR )
-            serial_rx_interrupt(port, regs);
+            serial_rx_interrupt(port);
 
         if ( port->txbufc == port->txbufp ) {
             reg = omap_read(uart, UART_IER);
diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
index 513b373b2e..cb7c4affa5 100644
--- a/xen/drivers/char/pl011.c
+++ b/xen/drivers/char/pl011.c
@@ -95,7 +95,7 @@ static void pl011_interrupt(int irq, void *data, struct cpu_user_regs *regs)
             pl011_write(uart, ICR, status & ~(TXI|RTI|RXI));
 
             if ( status & (RTI|RXI) )
-                serial_rx_interrupt(port, regs);
+                serial_rx_interrupt(port);
 
             /* TODO
                 if ( status & (DSRMI|DCDMI|CTSMI|RIMI) )
@@ -103,7 +103,7 @@ static void pl011_interrupt(int irq, void *data, struct cpu_user_regs *regs)
             */
 
             if ( status & (TXI) )
-                serial_tx_interrupt(port, regs);
+                serial_tx_interrupt(port);
 
             status = pl011_intr_status(uart);
         } while (status != 0);
diff --git a/xen/drivers/char/scif-uart.c b/xen/drivers/char/scif-uart.c
index 1b28ba90e9..d5de8931b2 100644
--- a/xen/drivers/char/scif-uart.c
+++ b/xen/drivers/char/scif-uart.c
@@ -119,11 +119,11 @@ static void scif_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
     {
         /* TX Interrupt */
         if ( status & SCFSR_TDFE )
-            serial_tx_interrupt(port, regs);
+            serial_tx_interrupt(port);
 
         /* RX Interrupt */
         if ( status & (SCFSR_RDF | SCFSR_DR) )
-            serial_rx_interrupt(port, regs);
+            serial_rx_interrupt(port);
 
         /* Error Interrupt */
         if ( status & params->error_mask )
diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c
index 0b30326843..f28d8557c0 100644
--- a/xen/drivers/char/serial.c
+++ b/xen/drivers/char/serial.c
@@ -45,7 +45,7 @@ static inline void serial_stop_tx(struct serial_port *port)
         port->driver->stop_tx(port);
 }
 
-void serial_rx_interrupt(struct serial_port *port, struct cpu_user_regs *regs)
+void serial_rx_interrupt(struct serial_port *port)
 {
     char c;
     serial_rx_fn fn = NULL;
@@ -71,7 +71,7 @@ void serial_rx_interrupt(struct serial_port *port, struct cpu_user_regs *regs)
         fn(c & 0x7f);
 }
 
-void serial_tx_interrupt(struct serial_port *port, struct cpu_user_regs *regs)
+void serial_tx_interrupt(struct serial_port *port)
 {
     int i, n;
     unsigned long flags;
diff --git a/xen/drivers/char/xhci-dbc.c b/xen/drivers/char/xhci-dbc.c
index 60b781f872..3bf389be7d 100644
--- a/xen/drivers/char/xhci-dbc.c
+++ b/xen/drivers/char/xhci-dbc.c
@@ -1176,9 +1176,10 @@ static void cf_check dbc_uart_poll(void *data)
     }
 
     while ( dbc_work_ring_size(&dbc->dbc_iwork) )
-        serial_rx_interrupt(port, guest_cpu_user_regs());
+        serial_rx_interrupt(port);
+
+    serial_tx_interrupt(port);
 
-    serial_tx_interrupt(port, guest_cpu_user_regs());
     set_timer(&uart->timer, NOW() + MICROSECS(DBC_POLL_INTERVAL));
 }
 
diff --git a/xen/include/xen/serial.h b/xen/include/xen/serial.h
index 92979e37e2..3d21207a3d 100644
--- a/xen/include/xen/serial.h
+++ b/xen/include/xen/serial.h
@@ -12,8 +12,6 @@
 #include <xen/init.h>
 #include <xen/spinlock.h>
 
-struct cpu_user_regs;
-
 /* Register a character-receive hook on the specified COM port. */
 typedef void (*serial_rx_fn)(char c);
 void serial_set_rx_handler(int handle, serial_rx_fn fn);
@@ -145,8 +143,8 @@ void serial_register_uart(int idx, struct uart_driver *driver, void *uart);
 /* Place the serial port into asynchronous transmit mode. */
 void serial_async_transmit(struct serial_port *port);
 /* Process work in interrupt context. */
-void serial_rx_interrupt(struct serial_port *port, struct cpu_user_regs *regs);
-void serial_tx_interrupt(struct serial_port *port, struct cpu_user_regs *regs);
+void serial_rx_interrupt(struct serial_port *port);
+void serial_tx_interrupt(struct serial_port *port);
 
 /*
  * Initialisers for individual uart drivers.
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 15:22:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 15:22:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684886.1065092 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXO2-0006QH-6s; Fri, 23 Feb 2024 15:22:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684886.1065092; Fri, 23 Feb 2024 15:22:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXO2-0006Q9-45; Fri, 23 Feb 2024 15:22:54 +0000
Received: by outflank-mailman (input) for mailman id 684886;
 Fri, 23 Feb 2024 15:22:52 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXO0-0006Pt-I2
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:52 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXO0-0004gM-HN
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXO0-00045J-Er
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:22:52 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Zr8vSA3xiBxzqqgPJ4tV4NYL57XU3Djm525kK1rZ44g=; b=AD4l2cJDPFwAyOp2T/2Rt3dECc
	6Hpmp9kslTd+XVF9OSG+FnjhvuuQPJtxD4TMSrUEK8POWhJVJqbQDYQW32pw/Tr6Rm/ZUhTppcs6U
	rGCUVv25FjjXeq4QuxjSjFCt0grTr6CzWv46sD3MvMb1qXzEAwzER43xedsptd7ime/s=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] IRQ: drop regs parameter from handler functions
Message-Id: <E1rdXO0-00045J-Er@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 15:22:52 +0000

commit 4da40a267a236d785d70ce6de88bb86846b64ccc
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 12:15:20 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 12:15:20 2024 +0100

    IRQ: drop regs parameter from handler functions
    
    It's simply not needed anymore. Note how Linux made this change many
    years ago already, in 2.6.19 (late 2006, see [1]).
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    
    [1] https://git.kernel.org/torvalds/c/7d12e780e003f93433d49ce78cfedf4b4c52adc5
---
 xen/arch/arm/gic.c                       |  2 +-
 xen/arch/arm/irq.c                       |  5 ++---
 xen/arch/arm/time.c                      |  4 ++--
 xen/arch/x86/hpet.c                      |  3 +--
 xen/arch/x86/irq.c                       |  4 ++--
 xen/arch/x86/time.c                      |  3 +--
 xen/common/irq.c                         |  2 +-
 xen/drivers/char/cadence-uart.c          |  2 +-
 xen/drivers/char/exynos4210-uart.c       |  2 +-
 xen/drivers/char/imx-lpuart.c            |  3 +--
 xen/drivers/char/meson-uart.c            |  3 +--
 xen/drivers/char/mvebu-uart.c            |  3 +--
 xen/drivers/char/ns16550.c               |  3 +--
 xen/drivers/char/omap-uart.c             |  2 +-
 xen/drivers/char/pl011.c                 |  2 +-
 xen/drivers/char/scif-uart.c             |  2 +-
 xen/drivers/passthrough/amd/iommu_init.c |  3 +--
 xen/drivers/passthrough/arm/ipmmu-vmsa.c |  2 +-
 xen/drivers/passthrough/arm/smmu-v3.c    | 14 +++++---------
 xen/drivers/passthrough/arm/smmu.c       |  6 ++----
 xen/drivers/passthrough/vtd/iommu.c      |  3 +--
 xen/include/xen/irq.h                    |  7 +++----
 22 files changed, 32 insertions(+), 48 deletions(-)

diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index b5a9c8266c..44c40e86de 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -397,7 +397,7 @@ void gic_interrupt(struct cpu_user_regs *regs, int is_fiq)
     } while (1);
 }
 
-static void maintenance_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs)
+static void maintenance_interrupt(int irq, void *dev_id)
 {
     /*
      * This is a dummy interrupt handler.
diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index ae69fb4aeb..6ac952f43b 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -182,8 +182,7 @@ void irq_set_affinity(struct irq_desc *desc, const cpumask_t *mask)
 }
 
 int request_irq(unsigned int irq, unsigned int irqflags,
-                void (*handler)(int irq, void *dev_id,
-                                struct cpu_user_regs *regs),
+                void (*handler)(int irq, void *dev_id),
                 const char *devname, void *dev_id)
 {
     struct irqaction *action;
@@ -276,7 +275,7 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq)
 
     do
     {
-        action->handler(irq, action->dev_id, regs);
+        action->handler(irq, action->dev_id);
         action = action->next;
     } while ( action );
 
diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
index 09cae8138e..e74d30d258 100644
--- a/xen/arch/arm/time.c
+++ b/xen/arch/arm/time.c
@@ -241,7 +241,7 @@ int reprogram_timer(s_time_t timeout)
 }
 
 /* Handle the firing timer */
-static void htimer_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs)
+static void htimer_interrupt(int irq, void *dev_id)
 {
     if ( unlikely(!(READ_SYSREG(CNTHP_CTL_EL2) & CNTx_CTL_PENDING)) )
         return;
@@ -255,7 +255,7 @@ static void htimer_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs)
     WRITE_SYSREG(0, CNTHP_CTL_EL2);
 }
 
-static void vtimer_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs)
+static void vtimer_interrupt(int irq, void *dev_id)
 {
     /*
      * Edge-triggered interrupts can be used for the virtual timer. Even
diff --git a/xen/arch/x86/hpet.c b/xen/arch/x86/hpet.c
index d982b0f6b2..d9e9c8ffa3 100644
--- a/xen/arch/x86/hpet.c
+++ b/xen/arch/x86/hpet.c
@@ -237,8 +237,7 @@ again:
     }
 }
 
-static void cf_check hpet_interrupt_handler(
-    int irq, void *data, struct cpu_user_regs *regs)
+static void cf_check hpet_interrupt_handler(int irq, void *data)
 {
     struct hpet_event_channel *ch = data;
 
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index bbae7751e4..689d7e46ab 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -962,7 +962,7 @@ static int __init cf_check irq_ratelimit_init(void)
 __initcall(irq_ratelimit_init);
 
 int __init request_irq(unsigned int irq, unsigned int irqflags,
-        void (*handler)(int irq, void *dev_id, struct cpu_user_regs *regs),
+        void (*handler)(int irq, void *dev_id),
         const char * devname, void *dev_id)
 {
     struct irqaction * action;
@@ -2009,7 +2009,7 @@ void do_IRQ(struct cpu_user_regs *regs)
         spin_unlock_irq(&desc->lock);
 
         tsc_in = tb_init_done ? get_cycles() : 0;
-        action->handler(irq, action->dev_id, regs);
+        action->handler(irq, action->dev_id);
         TRACE_3D(TRC_HW_IRQ_HANDLED, irq, tsc_in, get_cycles());
 
         spin_lock_irq(&desc->lock);
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index 34ddb9633f..6087004789 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -198,8 +198,7 @@ static void smp_send_timer_broadcast_ipi(void)
     }
 }
 
-static void cf_check timer_interrupt(
-    int irq, void *dev_id, struct cpu_user_regs *regs)
+static void cf_check timer_interrupt(int irq, void *dev_id)
 {
     ASSERT(local_irq_is_enabled());
 
diff --git a/xen/common/irq.c b/xen/common/irq.c
index 236cf171e2..04f14f7d1a 100644
--- a/xen/common/irq.c
+++ b/xen/common/irq.c
@@ -29,7 +29,7 @@ int init_one_irq_desc(struct irq_desc *desc)
     return err;
 }
 
-void cf_check no_action(int cpl, void *dev_id, struct cpu_user_regs *regs)
+void cf_check no_action(int cpl, void *dev_id)
 {
 }
 
diff --git a/xen/drivers/char/cadence-uart.c b/xen/drivers/char/cadence-uart.c
index 0b670c64ed..3618fa88d8 100644
--- a/xen/drivers/char/cadence-uart.c
+++ b/xen/drivers/char/cadence-uart.c
@@ -40,7 +40,7 @@ static struct cuart {
 #define cuart_read(uart, off)           readl((uart)->regs + (off))
 #define cuart_write(uart, off,val)      writel((val), (uart)->regs + (off))
 
-static void cuart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
+static void cuart_interrupt(int irq, void *data)
 {
     struct serial_port *port = data;
     struct cuart *uart = port->uart;
diff --git a/xen/drivers/char/exynos4210-uart.c b/xen/drivers/char/exynos4210-uart.c
index 5c53860df6..b29fd75c5a 100644
--- a/xen/drivers/char/exynos4210-uart.c
+++ b/xen/drivers/char/exynos4210-uart.c
@@ -45,7 +45,7 @@ static struct exynos4210_uart {
 #define exynos4210_read(uart, off)          readl((uart)->regs + off)
 #define exynos4210_write(uart, off, val)    writel(val, (uart->regs) + off)
 
-static void exynos4210_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
+static void exynos4210_uart_interrupt(int irq, void *data)
 {
     struct serial_port *port = data;
     struct exynos4210_uart *uart = port->uart;
diff --git a/xen/drivers/char/imx-lpuart.c b/xen/drivers/char/imx-lpuart.c
index f5b341e20b..522680a25c 100644
--- a/xen/drivers/char/imx-lpuart.c
+++ b/xen/drivers/char/imx-lpuart.c
@@ -37,8 +37,7 @@ static struct imx_lpuart {
     struct vuart_info vuart;
 } imx8_com;
 
-static void imx_lpuart_interrupt(int irq, void *data,
-                                 struct cpu_user_regs *regs)
+static void imx_lpuart_interrupt(int irq, void *data)
 {
     struct serial_port *port = data;
     struct imx_lpuart *uart = port->uart;
diff --git a/xen/drivers/char/meson-uart.c b/xen/drivers/char/meson-uart.c
index 640c29dd05..694381986d 100644
--- a/xen/drivers/char/meson-uart.c
+++ b/xen/drivers/char/meson-uart.c
@@ -61,8 +61,7 @@ static struct meson_uart {
     struct vuart_info vuart;
 } meson_com;
 
-static void meson_uart_interrupt(int irq, void *data,
-                                 struct cpu_user_regs *regs)
+static void meson_uart_interrupt(int irq, void *data)
 {
     struct serial_port *port = data;
     struct meson_uart *uart = port->uart;
diff --git a/xen/drivers/char/mvebu-uart.c b/xen/drivers/char/mvebu-uart.c
index 57c1259224..1913fe8b5f 100644
--- a/xen/drivers/char/mvebu-uart.c
+++ b/xen/drivers/char/mvebu-uart.c
@@ -67,8 +67,7 @@ static struct mvebu3700_uart {
 #define mvebu3700_read(uart, off)           readl((uart)->regs + (off))
 #define mvebu3700_write(uart, off, val)     writel(val, (uart)->regs + (off))
 
-static void mvebu3700_uart_interrupt(int irq, void *data,
-                                     struct cpu_user_regs *regs)
+static void mvebu3700_uart_interrupt(int irq, void *data)
 {
     struct serial_port *port = data;
     struct mvebu3700_uart *uart = port->uart;
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index 91f0624d74..a126e4a808 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -175,8 +175,7 @@ static void handle_dw_usr_busy_quirk(struct ns16550 *uart)
     }
 }
 
-static void cf_check ns16550_interrupt(
-    int irq, void *dev_id, struct cpu_user_regs *regs)
+static void cf_check ns16550_interrupt(int irq, void *dev_id)
 {
     struct serial_port *port = dev_id;
     struct ns16550 *uart = port->uart;
diff --git a/xen/drivers/char/omap-uart.c b/xen/drivers/char/omap-uart.c
index fb842b1707..e4f5be2289 100644
--- a/xen/drivers/char/omap-uart.c
+++ b/xen/drivers/char/omap-uart.c
@@ -59,7 +59,7 @@ static struct omap_uart {
     struct vuart_info vuart;
 } omap_com = {0};
 
-static void omap_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
+static void omap_uart_interrupt(int irq, void *data)
 {
     struct serial_port *port = data;
     struct omap_uart *uart = port->uart;
diff --git a/xen/drivers/char/pl011.c b/xen/drivers/char/pl011.c
index cb7c4affa5..7260a988ca 100644
--- a/xen/drivers/char/pl011.c
+++ b/xen/drivers/char/pl011.c
@@ -82,7 +82,7 @@ static unsigned int pl011_intr_status(struct pl011 *uart)
     return (pl011_read(uart, RIS) & pl011_read(uart, IMSC));
 }
 
-static void pl011_interrupt(int irq, void *data, struct cpu_user_regs *regs)
+static void pl011_interrupt(int irq, void *data)
 {
     struct serial_port *port = data;
     struct pl011 *uart = port->uart;
diff --git a/xen/drivers/char/scif-uart.c b/xen/drivers/char/scif-uart.c
index d5de8931b2..b7f86f882c 100644
--- a/xen/drivers/char/scif-uart.c
+++ b/xen/drivers/char/scif-uart.c
@@ -102,7 +102,7 @@ static const struct port_params port_params[NR_PORTS] =
     },
 };
 
-static void scif_uart_interrupt(int irq, void *data, struct cpu_user_regs *regs)
+static void scif_uart_interrupt(int irq, void *data)
 {
     struct serial_port *port = data;
     struct scif_uart *uart = port->uart;
diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthrough/amd/iommu_init.c
index 25e62f20ae..b32da1a28d 100644
--- a/xen/drivers/passthrough/amd/iommu_init.c
+++ b/xen/drivers/passthrough/amd/iommu_init.c
@@ -718,8 +718,7 @@ static void cf_check do_amd_iommu_irq(void *unused)
 
 static DECLARE_SOFTIRQ_TASKLET(amd_iommu_irq_tasklet, do_amd_iommu_irq, NULL);
 
-static void cf_check iommu_interrupt_handler(
-    int irq, void *dev_id, struct cpu_user_regs *regs)
+static void cf_check iommu_interrupt_handler(int irq, void *dev_id)
 {
     unsigned long flags;
     struct amd_iommu *iommu = dev_id;
diff --git a/xen/drivers/passthrough/arm/ipmmu-vmsa.c b/xen/drivers/passthrough/arm/ipmmu-vmsa.c
index b5c84c51a2..da011413c5 100644
--- a/xen/drivers/passthrough/arm/ipmmu-vmsa.c
+++ b/xen/drivers/passthrough/arm/ipmmu-vmsa.c
@@ -642,7 +642,7 @@ static void ipmmu_domain_irq(struct ipmmu_vmsa_domain *domain)
                         domain->d, status, iova);
 }
 
-static void ipmmu_irq(int irq, void *dev, struct cpu_user_regs *regs)
+static void ipmmu_irq(int irq, void *dev)
 {
     struct ipmmu_vmsa_device *mmu = dev;
     unsigned int i;
diff --git a/xen/drivers/passthrough/arm/smmu-v3.c b/xen/drivers/passthrough/arm/smmu-v3.c
index bca5866b35..c3ac6d17d1 100644
--- a/xen/drivers/passthrough/arm/smmu-v3.c
+++ b/xen/drivers/passthrough/arm/smmu-v3.c
@@ -880,8 +880,7 @@ static void arm_smmu_priq_tasklet(void *dev)
 
 static int arm_smmu_device_disable(struct arm_smmu_device *smmu);
 
-static void arm_smmu_gerror_handler(int irq, void *dev,
-				struct cpu_user_regs *regs)
+static void arm_smmu_gerror_handler(int irq, void *dev)
 {
 	u32 gerror, gerrorn, active;
 	struct arm_smmu_device *smmu = dev;
@@ -926,12 +925,11 @@ static void arm_smmu_gerror_handler(int irq, void *dev,
 	writel(gerror, smmu->base + ARM_SMMU_GERRORN);
 }
 
-static void arm_smmu_combined_irq_handler(int irq, void *dev,
-				struct cpu_user_regs *regs)
+static void arm_smmu_combined_irq_handler(int irq, void *dev)
 {
 	struct arm_smmu_device *smmu = dev;
 
-	arm_smmu_gerror_handler(irq, dev, regs);
+	arm_smmu_gerror_handler(irq, dev);
 
 	tasklet_schedule(&(smmu->combined_irq_tasklet));
 }
@@ -945,16 +943,14 @@ static void arm_smmu_combined_irq_tasklet(void *dev)
 		arm_smmu_priq_tasklet(dev);
 }
 
-static void arm_smmu_evtq_irq_tasklet(int irq, void *dev,
-				struct cpu_user_regs *regs)
+static void arm_smmu_evtq_irq_tasklet(int irq, void *dev)
 {
 	struct arm_smmu_device *smmu = dev;
 
 	tasklet_schedule(&(smmu->evtq_irq_tasklet));
 }
 
-static void arm_smmu_priq_irq_tasklet(int irq, void *dev,
-				struct cpu_user_regs *regs)
+static void arm_smmu_priq_irq_tasklet(int irq, void *dev)
 {
 	struct arm_smmu_device *smmu = dev;
 
diff --git a/xen/drivers/passthrough/arm/smmu.c b/xen/drivers/passthrough/arm/smmu.c
index 4a272c8779..625ed0e419 100644
--- a/xen/drivers/passthrough/arm/smmu.c
+++ b/xen/drivers/passthrough/arm/smmu.c
@@ -1097,16 +1097,14 @@ static irqreturn_t arm_smmu_global_fault(int irq, void *dev)
 }
 
 /* Xen: Interrupt handlers wrapper */
-static void arm_smmu_context_fault_xen(int irq, void *dev,
-				       struct cpu_user_regs *regs)
+static void arm_smmu_context_fault_xen(int irq, void *dev)
 {
 	arm_smmu_context_fault(irq, dev);
 }
 
 #define arm_smmu_context_fault arm_smmu_context_fault_xen
 
-static void arm_smmu_global_fault_xen(int irq, void *dev,
-				      struct cpu_user_regs *regs)
+static void arm_smmu_global_fault_xen(int irq, void *dev)
 {
 	arm_smmu_global_fault(irq, dev);
 }
diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index 54c4c0f9b9..c7110af7c9 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1117,8 +1117,7 @@ static void cf_check do_iommu_page_fault(void *unused)
         __do_iommu_page_fault(drhd->iommu);
 }
 
-static void cf_check iommu_page_fault(
-    int irq, void *dev_id, struct cpu_user_regs *regs)
+static void cf_check iommu_page_fault(int irq, void *dev_id)
 {
     /*
      * Just flag the tasklet as runnable. This is fine, according to VT-d
diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h
index 76da442942..72c24c6f04 100644
--- a/xen/include/xen/irq.h
+++ b/xen/include/xen/irq.h
@@ -18,7 +18,7 @@
     ASSERT(!in_irq() && (local_irq_is_enabled() || num_online_cpus() <= 1))
 
 struct irqaction {
-    void (*handler)(int irq, void *dev_id, struct cpu_user_regs *regs);
+    void (*handler)(int irq, void *dev_id);
     const char *name;
     void *dev_id;
     bool free_on_release;
@@ -119,12 +119,11 @@ extern int setup_irq(unsigned int irq, unsigned int irqflags,
                      struct irqaction *new);
 extern void release_irq(unsigned int irq, const void *dev_id);
 extern int request_irq(unsigned int irq, unsigned int irqflags,
-               void (*handler)(int irq, void *dev_id,
-                     struct cpu_user_regs *regs),
+               void (*handler)(int irq, void *dev_id),
                const char *devname, void *dev_id);
 
 extern hw_irq_controller no_irq_type;
-void cf_check no_action(int cpl, void *dev_id, struct cpu_user_regs *regs);
+void cf_check no_action(int cpl, void *dev_id);
 unsigned int cf_check irq_startup_none(struct irq_desc *desc);
 void cf_check irq_actor_none(struct irq_desc *desc);
 #define irq_shutdown_none irq_actor_none
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 15:23:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 15:23:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684887.1065095 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXOC-0006TE-8A; Fri, 23 Feb 2024 15:23:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684887.1065095; Fri, 23 Feb 2024 15:23:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXOC-0006T6-5a; Fri, 23 Feb 2024 15:23:04 +0000
Received: by outflank-mailman (input) for mailman id 684887;
 Fri, 23 Feb 2024 15:23:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXOA-0006Sy-Le
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:23:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXOA-0004gk-Ks
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:23:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXOA-00045w-Jz
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:23:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=k1icwnqGAj4VD08OCVWrQSydUGrXpZ8sK/9/KKy72oA=; b=Y9B2PwxzyvBPG3FZ0729boiS9I
	Yenbz3YjFdP8JXFSjCBVmeRwJ7vo06lnaJ+5y2RxzvtPmsAUV4BsGv3MYFmOjo0gnq+NlDgH9UidW
	bPUIc2CRaQ/lVmHnT+wXpqDk6V4Vo68nsDGDZSSA6xfVppRV7hoEjfB3rC4l+e5RN5mE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/APIC: drop regs parameter from direct vector handler functions
Message-Id: <E1rdXOA-00045w-Jz@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 15:23:02 +0000

commit f75b051f785af35dc7db030b005dc2ac962b573b
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 12:16:17 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 12:16:17 2024 +0100

    x86/APIC: drop regs parameter from direct vector handler functions
    
    The only place it was needed is in the spurious handler, and there we
    can use get_irq_regs() instead.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/apic.c                 | 10 +++++-----
 xen/arch/x86/cpu/mcheck/mce_intel.c |  4 ++--
 xen/arch/x86/guest/xen/xen.c        |  2 +-
 xen/arch/x86/hvm/vmx/vmx.c          |  4 ++--
 xen/arch/x86/include/asm/irq.h      | 14 ++++++--------
 xen/arch/x86/irq.c                  | 12 +++++-------
 xen/arch/x86/smp.c                  |  6 +++---
 7 files changed, 24 insertions(+), 28 deletions(-)

diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c
index a69ac90405..592b78e11e 100644
--- a/xen/arch/x86/apic.c
+++ b/xen/arch/x86/apic.c
@@ -1322,7 +1322,7 @@ int reprogram_timer(s_time_t timeout)
     return apic_tmict || !timeout;
 }
 
-static void cf_check apic_timer_interrupt(struct cpu_user_regs *regs)
+static void cf_check apic_timer_interrupt(void)
 {
     ack_APIC_irq();
     perfc_incr(apic_timer);
@@ -1341,7 +1341,7 @@ void smp_send_state_dump(unsigned int cpu)
 /*
  * Spurious interrupts should _never_ happen with our APIC/SMP architecture.
  */
-static void cf_check spurious_interrupt(struct cpu_user_regs *regs)
+static void cf_check spurious_interrupt(void)
 {
     /*
      * Check if this is a vectored interrupt (most likely, as this is probably
@@ -1355,7 +1355,7 @@ static void cf_check spurious_interrupt(struct cpu_user_regs *regs)
         is_spurious = !nmi_check_continuation();
         if (this_cpu(state_dump_pending)) {
             this_cpu(state_dump_pending) = false;
-            dump_execstate(regs);
+            dump_execstate(get_irq_regs());
             is_spurious = false;
         }
 
@@ -1372,7 +1372,7 @@ static void cf_check spurious_interrupt(struct cpu_user_regs *regs)
  * This interrupt should never happen with our APIC/SMP architecture
  */
 
-static void cf_check error_interrupt(struct cpu_user_regs *regs)
+static void cf_check error_interrupt(void)
 {
     static const char *const esr_fields[] = {
         ", Send CS error",
@@ -1407,7 +1407,7 @@ static void cf_check error_interrupt(struct cpu_user_regs *regs)
  * This interrupt handles performance counters interrupt
  */
 
-static void cf_check pmu_interrupt(struct cpu_user_regs *regs)
+static void cf_check pmu_interrupt(void)
 {
     ack_APIC_irq();
     vpmu_do_interrupt();
diff --git a/xen/arch/x86/cpu/mcheck/mce_intel.c b/xen/arch/x86/cpu/mcheck/mce_intel.c
index 7f9b87f973..3f5199b531 100644
--- a/xen/arch/x86/cpu/mcheck/mce_intel.c
+++ b/xen/arch/x86/cpu/mcheck/mce_intel.c
@@ -58,7 +58,7 @@ bool __read_mostly lmce_support;
 #define MCE_RING                0x1
 static DEFINE_PER_CPU(int, last_state);
 
-static void cf_check intel_thermal_interrupt(struct cpu_user_regs *regs)
+static void cf_check intel_thermal_interrupt(void)
 {
     uint64_t msr_content;
     unsigned int cpu = smp_processor_id();
@@ -642,7 +642,7 @@ static void cpu_mcheck_disable(void)
         clear_cmci();
 }
 
-static void cf_check cmci_interrupt(struct cpu_user_regs *regs)
+static void cf_check cmci_interrupt(void)
 {
     mctelem_cookie_t mctc;
     struct mca_summary bs;
diff --git a/xen/arch/x86/guest/xen/xen.c b/xen/arch/x86/guest/xen/xen.c
index ec66fc84d1..d9768cc952 100644
--- a/xen/arch/x86/guest/xen/xen.c
+++ b/xen/arch/x86/guest/xen/xen.c
@@ -158,7 +158,7 @@ static void __init init_memmap(void)
     }
 }
 
-static void cf_check xen_evtchn_upcall(struct cpu_user_regs *regs)
+static void cf_check xen_evtchn_upcall(void)
 {
     struct vcpu_info *vcpu_info = this_cpu(vcpu_info);
     unsigned long pending;
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 48376cc327..9c803494c7 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2782,7 +2782,7 @@ static struct hvm_function_table __initdata_cf_clobber vmx_function_table = {
 };
 
 /* Handle VT-d posted-interrupt when VCPU is blocked. */
-static void cf_check pi_wakeup_interrupt(struct cpu_user_regs *regs)
+static void cf_check pi_wakeup_interrupt(void)
 {
     struct vmx_vcpu *vmx, *tmp;
     spinlock_t *lock = &per_cpu(vmx_pi_blocking, smp_processor_id()).lock;
@@ -2814,7 +2814,7 @@ static void cf_check pi_wakeup_interrupt(struct cpu_user_regs *regs)
 }
 
 /* Handle VT-d posted-interrupt when VCPU is running. */
-static void cf_check pi_notification_interrupt(struct cpu_user_regs *regs)
+static void cf_check pi_notification_interrupt(void)
 {
     ack_APIC_irq();
     this_cpu(irq_count)++;
diff --git a/xen/arch/x86/include/asm/irq.h b/xen/arch/x86/include/asm/irq.h
index 6a93dc41d2..082a3d6bbc 100644
--- a/xen/arch/x86/include/asm/irq.h
+++ b/xen/arch/x86/include/asm/irq.h
@@ -72,17 +72,15 @@ extern int opt_irq_vector_map;
 
 #define platform_legacy_irq(irq)	((irq) < 16)
 
-void cf_check event_check_interrupt(struct cpu_user_regs *regs);
-void cf_check invalidate_interrupt(struct cpu_user_regs *regs);
-void cf_check call_function_interrupt(struct cpu_user_regs *regs);
-void cf_check irq_move_cleanup_interrupt(struct cpu_user_regs *regs);
+void cf_check event_check_interrupt(void);
+void cf_check invalidate_interrupt(void);
+void cf_check call_function_interrupt(void);
+void cf_check irq_move_cleanup_interrupt(void);
 
 uint8_t alloc_hipriority_vector(void);
 
-void set_direct_apic_vector(
-    uint8_t vector, void (*handler)(struct cpu_user_regs *regs));
-void alloc_direct_apic_vector(
-    uint8_t *vector, void (*handler)(struct cpu_user_regs *regs));
+void set_direct_apic_vector(uint8_t vector, void (*handler)(void));
+void alloc_direct_apic_vector(uint8_t *vector, void (*handler)(void));
 
 void do_IRQ(struct cpu_user_regs *regs);
 
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index 689d7e46ab..810de06fd3 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -743,7 +743,7 @@ void move_native_irq(struct irq_desc *desc)
     desc->handler->enable(desc);
 }
 
-void cf_check irq_move_cleanup_interrupt(struct cpu_user_regs *regs)
+void cf_check irq_move_cleanup_interrupt(void)
 {
     unsigned vector, me;
 
@@ -913,16 +913,14 @@ uint8_t alloc_hipriority_vector(void)
     return next++;
 }
 
-static void (*direct_apic_vector[X86_NR_VECTORS])(struct cpu_user_regs *regs);
-void set_direct_apic_vector(
-    uint8_t vector, void (*handler)(struct cpu_user_regs *regs))
+static void (*direct_apic_vector[X86_NR_VECTORS])(void);
+void set_direct_apic_vector(uint8_t vector, void (*handler)(void))
 {
     BUG_ON(direct_apic_vector[vector] != NULL);
     direct_apic_vector[vector] = handler;
 }
 
-void alloc_direct_apic_vector(
-    uint8_t *vector, void (*handler)(struct cpu_user_regs *regs))
+void alloc_direct_apic_vector(uint8_t *vector, void (*handler)(void))
 {
     static DEFINE_SPINLOCK(lock);
 
@@ -1907,7 +1905,7 @@ void do_IRQ(struct cpu_user_regs *regs)
     if ( irq < 0 )
     {
         if ( direct_apic_vector[vector] )
-            direct_apic_vector[vector](regs);
+            direct_apic_vector[vector]();
         else
         {
             const char *kind = ", LAPIC";
diff --git a/xen/arch/x86/smp.c b/xen/arch/x86/smp.c
index 3a331cbdbc..7443ad2033 100644
--- a/xen/arch/x86/smp.c
+++ b/xen/arch/x86/smp.c
@@ -245,7 +245,7 @@ static cpumask_t flush_cpumask;
 static const void *flush_va;
 static unsigned int flush_flags;
 
-void cf_check invalidate_interrupt(struct cpu_user_regs *regs)
+void cf_check invalidate_interrupt(void)
 {
     unsigned int flags = flush_flags;
     ack_APIC_irq();
@@ -387,14 +387,14 @@ void smp_send_nmi_allbutself(void)
     send_IPI_mask(&cpu_online_map, APIC_DM_NMI);
 }
 
-void cf_check event_check_interrupt(struct cpu_user_regs *regs)
+void cf_check event_check_interrupt(void)
 {
     ack_APIC_irq();
     perfc_incr(ipis);
     this_cpu(irq_count)++;
 }
 
-void cf_check call_function_interrupt(struct cpu_user_regs *regs)
+void cf_check call_function_interrupt(void)
 {
     ack_APIC_irq();
     perfc_incr(ipis);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 15:23:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 15:23:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684892.1065110 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXOL-0006kx-H7; Fri, 23 Feb 2024 15:23:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684892.1065110; Fri, 23 Feb 2024 15:23:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXOL-0006kp-EN; Fri, 23 Feb 2024 15:23:13 +0000
Received: by outflank-mailman (input) for mailman id 684892;
 Fri, 23 Feb 2024 15:23:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXOK-0006kP-PF
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:23:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXOK-0004h2-OS
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:23:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXOK-00046T-Nc
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:23:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=0j70s/nWeE/Orw9dcQbSWkEqnmB25S+H+bbdMx44poM=; b=B8xohfME+b75Z0QEJBp8Nk0xUo
	of9qLz5sl5E7Cl0fQws7+tAr4JCavkrYlRQrkaD9cS5O2cry3UJnmrDv96BiSlhUFls4t2tFr2zZv
	eAAVz1yz54v9XZ90KKaSDYarLlKgyGi/adz2cCwUeuR5qPMM55yysqUzd0KNYEk4qYtQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] consolidate do_bug_frame() / bug_fn_t
Message-Id: <E1rdXOK-00046T-Nc@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 15:23:12 +0000

commit 8c5e4ce14509ca85b3f5faa298a766b8ffdd4f85
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 22 12:16:55 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 22 12:16:55 2024 +0100

    consolidate do_bug_frame() / bug_fn_t
    
    The type not being used in do_bug_frame() is suspicious. Apparently
    that's solely because the type uses a pointer-to-const parameter,
    when so far run_in_exception_handler() wanted functions taking pointer-
    to-non-const. Expand use of const, in turn requiring common code's
    do_bug_frame() as well as [gs]et_irq_regs() to also gain const. This
    then brings the former function also closer to the common one, with
    Arm's use of vaddr_t remaining as a difference.
    
    While there also replace the bogus use of hard tabs in [gs]et_irq_regs()
    (I clearly didn't mean to put it in like this).
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/irq.c                   |  2 +-
 xen/arch/x86/include/asm/processor.h |  3 +--
 xen/arch/x86/irq.c                   |  2 +-
 xen/arch/x86/traps.c                 |  7 +------
 xen/common/bug.c                     |  8 ++------
 xen/common/irq.c                     |  2 +-
 xen/common/keyhandler.c              |  2 +-
 xen/drivers/char/ehci-dbgp.c         |  4 ++--
 xen/drivers/char/ns16550.c           |  4 ++--
 xen/include/xen/bug.h                |  5 ++---
 xen/include/xen/irq.h                | 17 +++++++++--------
 xen/include/xen/kernel.h             |  3 +--
 xen/include/xen/lib.h                |  2 +-
 13 files changed, 25 insertions(+), 36 deletions(-)

diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index 6ac952f43b..bcce80a4d6 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -220,7 +220,7 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq)
 {
     struct irq_desc *desc = irq_to_desc(irq);
     struct irqaction *action;
-    struct cpu_user_regs *old_regs = set_irq_regs(regs);
+    const struct cpu_user_regs *old_regs = set_irq_regs(regs);
 
     perfc_incr(irqs);
 
diff --git a/xen/arch/x86/include/asm/processor.h b/xen/arch/x86/include/asm/processor.h
index b227cdee8e..c26ef9090c 100644
--- a/xen/arch/x86/include/asm/processor.h
+++ b/xen/arch/x86/include/asm/processor.h
@@ -409,8 +409,7 @@ static always_inline void rep_nop(void)
 void show_code(const struct cpu_user_regs *regs);
 void show_stack_overflow(unsigned int cpu, const struct cpu_user_regs *regs);
 void show_registers(const struct cpu_user_regs *regs);
-#define dump_execution_state() \
-    run_in_exception_handler(show_execution_state_nonconst)
+#define dump_execution_state() run_in_exception_handler(show_execution_state)
 void show_page_walk(unsigned long addr);
 void noreturn fatal_trap(const struct cpu_user_regs *regs, bool show_remote);
 
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index 810de06fd3..7458b89ab3 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -1896,7 +1896,7 @@ void do_IRQ(struct cpu_user_regs *regs)
     struct irq_desc  *desc;
     unsigned int      vector = (uint8_t)regs->entry_vector;
     int               irq = this_cpu(vector_irq)[vector];
-    struct cpu_user_regs *old_regs = set_irq_regs(regs);
+    const struct cpu_user_regs *old_regs = set_irq_regs(regs);
 
     perfc_incr(irqs);
     this_cpu(irq_count)++;
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 5f4bcc0537..ff37d97133 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -643,7 +643,7 @@ void show_stack_overflow(unsigned int cpu, const struct cpu_user_regs *regs)
     printk("\n");
 }
 
-void show_execution_state(const struct cpu_user_regs *regs)
+void cf_check show_execution_state(const struct cpu_user_regs *regs)
 {
     /* Prevent interleaving of output. */
     unsigned long flags = console_lock_recursive_irqsave();
@@ -655,11 +655,6 @@ void show_execution_state(const struct cpu_user_regs *regs)
     console_unlock_recursive_irqrestore(flags);
 }
 
-void cf_check show_execution_state_nonconst(struct cpu_user_regs *regs)
-{
-    show_execution_state(regs);
-}
-
 void vcpu_show_execution_state(struct vcpu *v)
 {
     unsigned long flags = 0;
diff --git a/xen/common/bug.c b/xen/common/bug.c
index 5fbe703a81..c43e7c4397 100644
--- a/xen/common/bug.c
+++ b/xen/common/bug.c
@@ -10,7 +10,7 @@
  * Returns a negative value in case of an error otherwise
  * BUGFRAME_{run_fn, warn, bug, assert}
  */
-int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc)
+int do_bug_frame(const struct cpu_user_regs *regs, unsigned long pc)
 {
     const struct bug_frame *bug = NULL;
     const struct virtual_region *region;
@@ -44,14 +44,10 @@ int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc)
 
     if ( id == BUGFRAME_run_fn )
     {
-        void (*fn)(struct cpu_user_regs *) = bug_ptr(bug);
+        bug_fn_t *fn = bug_ptr(bug);
 
         fn(regs);
 
-        /* Re-enforce consistent types, because of the casts involved. */
-        if ( false )
-            run_in_exception_handler(fn);
-
         return id;
     }
 
diff --git a/xen/common/irq.c b/xen/common/irq.c
index 04f14f7d1a..7225b46374 100644
--- a/xen/common/irq.c
+++ b/xen/common/irq.c
@@ -1,7 +1,7 @@
 #include <xen/irq.h>
 #include <xen/errno.h>
 
-DEFINE_PER_CPU(struct cpu_user_regs *, irq_regs);
+DEFINE_PER_CPU(const struct cpu_user_regs *, irq_regs);
 
 int init_one_irq_desc(struct irq_desc *desc)
 {
diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c
index 9c23a540e5..127ca50696 100644
--- a/xen/common/keyhandler.c
+++ b/xen/common/keyhandler.c
@@ -135,7 +135,7 @@ static void cf_check show_handlers(unsigned char key)
 
 static cpumask_t dump_execstate_mask;
 
-void cf_check dump_execstate(struct cpu_user_regs *regs)
+void cf_check dump_execstate(const struct cpu_user_regs *regs)
 {
     unsigned int cpu = smp_processor_id();
 
diff --git a/xen/drivers/char/ehci-dbgp.c b/xen/drivers/char/ehci-dbgp.c
index 2bb55418a7..1ad3c6bebf 100644
--- a/xen/drivers/char/ehci-dbgp.c
+++ b/xen/drivers/char/ehci-dbgp.c
@@ -1246,14 +1246,14 @@ static int cf_check ehci_dbgp_getc(struct serial_port *port, char *pc)
 /* Safe: ehci_dbgp_poll() runs as timer handler, so not reentrant. */
 static struct serial_port *poll_port;
 
-static void cf_check _ehci_dbgp_poll(struct cpu_user_regs *regs)
+static void cf_check _ehci_dbgp_poll(const struct cpu_user_regs *regs)
 {
     struct serial_port *port = poll_port;
     struct ehci_dbgp *dbgp = port->uart;
     unsigned long flags;
     unsigned int timeout = MICROSECS(DBGP_CHECK_INTERVAL);
     bool empty = false;
-    struct cpu_user_regs *old_regs;
+    const struct cpu_user_regs *old_regs;
 
     if ( !dbgp->ehci_debug )
         return;
diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index a126e4a808..8f76bbe676 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -206,11 +206,11 @@ static void cf_check ns16550_interrupt(int irq, void *dev_id)
 /* Safe: ns16550_poll() runs as softirq so not reentrant on a given CPU. */
 static DEFINE_PER_CPU(struct serial_port *, poll_port);
 
-static void cf_check __ns16550_poll(struct cpu_user_regs *regs)
+static void cf_check __ns16550_poll(const struct cpu_user_regs *regs)
 {
     struct serial_port *port = this_cpu(poll_port);
     struct ns16550 *uart = port->uart;
-    struct cpu_user_regs *old_regs;
+    const struct cpu_user_regs *old_regs;
 
     if ( uart->intr_works )
         return; /* Interrupts work - no more polling */
diff --git a/xen/include/xen/bug.h b/xen/include/xen/bug.h
index 4bd0be5088..a11d4239f8 100644
--- a/xen/include/xen/bug.h
+++ b/xen/include/xen/bug.h
@@ -101,8 +101,7 @@ typedef void bug_fn_t(const struct cpu_user_regs *regs);
 
 #ifndef run_in_exception_handler
 
-static void always_inline run_in_exception_handler(
-    void (*fn)(struct cpu_user_regs *regs))
+static void always_inline run_in_exception_handler(bug_fn_t *fn)
 {
     BUG_FRAME(BUGFRAME_run_fn, 0, fn, 0, NULL);
 }
@@ -133,7 +132,7 @@ static void always_inline run_in_exception_handler(
  * Returns a negative value in case of an error otherwise
  * BUGFRAME_{run_fn, warn, bug, assert}
  */
-int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc);
+int do_bug_frame(const struct cpu_user_regs *regs, unsigned long pc);
 
 #endif /* CONFIG_GENERIC_BUG_FRAME */
 
diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h
index 72c24c6f04..89f7a8317a 100644
--- a/xen/include/xen/irq.h
+++ b/xen/include/xen/irq.h
@@ -134,21 +134,22 @@ void cf_check irq_actor_none(struct irq_desc *desc);
  * Per-cpu interrupted context register state - the inner-most interrupt frame
  * on the stack.
  */
-DECLARE_PER_CPU(struct cpu_user_regs *, irq_regs);
+DECLARE_PER_CPU(const struct cpu_user_regs *, irq_regs);
 
-static inline struct cpu_user_regs *get_irq_regs(void)
+static inline const struct cpu_user_regs *get_irq_regs(void)
 {
-	return this_cpu(irq_regs);
+    return this_cpu(irq_regs);
 }
 
-static inline struct cpu_user_regs *set_irq_regs(struct cpu_user_regs *new_regs)
+static inline const struct cpu_user_regs *set_irq_regs(
+    const struct cpu_user_regs *new_regs)
 {
-	struct cpu_user_regs *old_regs, **pp_regs = &this_cpu(irq_regs);
+    const struct cpu_user_regs *old_regs, **pp_regs = &this_cpu(irq_regs);
 
-	old_regs = *pp_regs;
-	*pp_regs = new_regs;
+    old_regs = *pp_regs;
+    *pp_regs = new_regs;
 
-	return old_regs;
+    return old_regs;
 }
 
 struct domain;
diff --git a/xen/include/xen/kernel.h b/xen/include/xen/kernel.h
index 6bbd4a2827..bb6b0f3891 100644
--- a/xen/include/xen/kernel.h
+++ b/xen/include/xen/kernel.h
@@ -110,8 +110,7 @@ extern const unsigned int xen_config_data_size;
 struct cpu_user_regs;
 struct vcpu;
 
-void show_execution_state(const struct cpu_user_regs *regs);
-void cf_check show_execution_state_nonconst(struct cpu_user_regs *regs);
+void cf_check show_execution_state(const struct cpu_user_regs *regs);
 void vcpu_show_execution_state(struct vcpu *v);
 
 #endif /* _LINUX_KERNEL_H */
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index 1793be5b6b..abee6c20d7 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -173,7 +173,7 @@ extern char *print_tainted(char *str);
 extern void add_taint(unsigned int taint);
 
 struct cpu_user_regs;
-void cf_check dump_execstate(struct cpu_user_regs *regs);
+void cf_check dump_execstate(const struct cpu_user_regs *regs);
 
 void init_constructors(void);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 15:23:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 15:23:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684893.1065113 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXOW-0006uL-Jm; Fri, 23 Feb 2024 15:23:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684893.1065113; Fri, 23 Feb 2024 15:23:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXOW-0006uE-HF; Fri, 23 Feb 2024 15:23:24 +0000
Received: by outflank-mailman (input) for mailman id 684893;
 Fri, 23 Feb 2024 15:23:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXOU-0006tO-S7
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:23:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXOU-0004hP-RQ
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:23:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXOU-00046w-Qf
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:23:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=70XmKsby/wmGni1ETES+WAZc+wkGHkwCURpqJ3y7Ov8=; b=zL32j/1KdfLty+otSbD47rCgP7
	GItva3ukYg/a/GJ9djj86ZW7lT/Fh3sqmQuaEmJFo+Z4M4xHuvI+XD4hK3aCZTicq1UmgC3lL/wuh
	5vTQ9G8MXL5uGQc5OKe4OtPW5lVeYdh92E0VUX2c3faMscXTwRmw+eW5ssWmvqv5k2vo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen-analysis.py: Use named group for tag regex
Message-Id: <E1rdXOU-00046w-Qf@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 15:23:22 +0000

commit ddd6696fc6f1b2efe92c6edebb9b31726d105867
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Wed Jan 31 11:02:39 2024 +0000
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu Feb 22 16:08:06 2024 +0000

    xen-analysis.py: Use named group for tag regex
    
    Use named group for the regex matching a tag identifier, this
    is done to ease retrieving the matching group instead of using
    an index.
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 xen/scripts/xen_analysis/cppcheck_analysis.py |  4 ++--
 xen/scripts/xen_analysis/tag_database.py      | 24 ++++++++++++------------
 xen/scripts/xen_analysis/utils.py             |  2 +-
 3 files changed, 15 insertions(+), 15 deletions(-)

diff --git a/xen/scripts/xen_analysis/cppcheck_analysis.py b/xen/scripts/xen_analysis/cppcheck_analysis.py
index e54848aa53..919eb153ce 100644
--- a/xen/scripts/xen_analysis/cppcheck_analysis.py
+++ b/xen/scripts/xen_analysis/cppcheck_analysis.py
@@ -41,7 +41,7 @@ def __generate_suppression_list(out_file):
     # The following lambda function will return a file if it contains lines with
     # a comment containing "cppcheck-suppress[*]" on a single line.
     grep_action = lambda x: utils.grep(x,
-                    r'^[ \t]*/\* cppcheck-suppress\[(.*)\] \*/$')
+                    r'^[ \t]*/\* cppcheck-suppress\[(?P<id>.*)\] \*/$')
     # Look for a list of .h files that matches the condition above
     headers = utils.recursive_find_file(settings.xen_dir, r'.*\.h$',
                                         grep_action)
@@ -97,7 +97,7 @@ def __generate_suppression_list(out_file):
                         if (not comment_section) and comment_line_starts:
                             comment_section = True
                         if (len(line.strip()) != 0) and (not comment_section):
-                            cppcheck_violation_id = entry["matches"][line_num][0]
+                            cppcheck_violation_id = entry["matches"][line_num]['id']
                             break
                         if comment_section and comment_line_stops:
                             comment_section = False
diff --git a/xen/scripts/xen_analysis/tag_database.py b/xen/scripts/xen_analysis/tag_database.py
index ca374bbb62..abba163aec 100644
--- a/xen/scripts/xen_analysis/tag_database.py
+++ b/xen/scripts/xen_analysis/tag_database.py
@@ -18,11 +18,12 @@ tool_syntax = {
 
 
 def get_xen_tag_index_type_regex(tool):
-    return r'^SAF-(\d+)-(safe|false-positive-' + tool + ')$'
+    return rf'^SAF-(?P<id>\d+)-(?P<type>safe|false-positive-{tool})$'
 
 
 def get_xen_tag_comment_regex(tool):
-    return r'^[ \t]*/\* +(SAF-\d+-(?:safe|false-positive-' + tool + ')).*\*/$'
+    tag=rf'(?P<tag>SAF-\d+-(?:safe|false-positive-{tool}))'
+    return rf'^[ \t]*/\* +{tag}.*\*/$'
 
 
 # Returns a data structure containing dictionaries for safe and false-positive-*
@@ -60,12 +61,11 @@ def load_tag_database(tool, input_files, data_struct = None, schema = "safe"):
         if proprietary_id != "":
             comment=tool_syntax[tool].replace("VID",proprietary_id)
             # Regex to capture the index of the Xen tag and the schema
-            xen_tag = re.compile(get_xen_tag_index_type_regex(tool))\
-                            .match(entry["id"])
-            if xen_tag and xen_tag.group(1) and xen_tag.group(2):
+            xen_tag = re.match(get_xen_tag_index_type_regex(tool), entry["id"])
+            if xen_tag and xen_tag.group('id') and xen_tag.group('type'):
                 # Save in safe or false-positive-* the key {#id: "comment"}
-                id_number = int(xen_tag.group(1))
-                key = xen_tag.group(2)
+                id_number = int(xen_tag.group('id'))
+                key = xen_tag.group('type')
                 ret[key][id_number] = "/* {} */\n".format(comment)
             else:
                 raise TagDatabaseError(
@@ -95,11 +95,11 @@ def substitute_tags(tool, input_file, grep_struct, subs_rules):
             # information access the subs_rules dictionary to see if there is
             # a match
             for line_number in grep_struct["matches"]:
-                xen_tag = grep_struct["matches"][line_number][0]
-                xen_tag_regex_obj = re.compile(
-                            get_xen_tag_index_type_regex(tool)).match(xen_tag)
-                id_number = int(xen_tag_regex_obj.group(1))
-                key = xen_tag_regex_obj.group(2)
+                xen_tag = grep_struct["matches"][line_number]['tag']
+                xen_tag_regex_obj = re.match(get_xen_tag_index_type_regex(tool),
+                                             xen_tag)
+                id_number = int(xen_tag_regex_obj.group('id'))
+                key = xen_tag_regex_obj.group('type')
                 if id_number in subs_rules[key]:
                     parsed_content[line_number-1] = subs_rules[key][id_number]
 
diff --git a/xen/scripts/xen_analysis/utils.py b/xen/scripts/xen_analysis/utils.py
index 1193e3f463..eef48eeb7e 100644
--- a/xen/scripts/xen_analysis/utils.py
+++ b/xen/scripts/xen_analysis/utils.py
@@ -12,7 +12,7 @@ def grep(filepath, regex):
             for line in f:
                 match = regObj.match(line)
                 if match:
-                    res["matches"][line_number] = match.groups()
+                    res["matches"][line_number] = match
                 line_number = line_number + 1
     except Exception as e:
         print("WARNING: Can't open {}: {}".format(filepath, e))
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 15:23:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 15:23:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684896.1065117 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXOg-000755-LW; Fri, 23 Feb 2024 15:23:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684896.1065117; Fri, 23 Feb 2024 15:23:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXOg-00074x-Ik; Fri, 23 Feb 2024 15:23:34 +0000
Received: by outflank-mailman (input) for mailman id 684896;
 Fri, 23 Feb 2024 15:23:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXOe-00074W-Uy
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:23:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXOe-0004ha-UG
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:23:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXOe-00047R-TV
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:23:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=WJjhboRfLmVFMC05dyILkXEuHFEuvWdE0BiFefFJmfM=; b=VBvGL1pYg476d0MEqMoqRDpKV6
	bzx5O83g3N+ezEX60ynbZCFxS09uanD9z18jG2bJYOvQT/YHThqSnKYRy59YUEVfITlKbaAQKwzsG
	I21rpGD4e1Tx9KSG7AG+ts/DPur7s0ojTzGAKhfk2s07r1wX+BUVGYQoEMxYOJX2e1qE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen-analysis.py: Substitute only the comment instead of the line
Message-Id: <E1rdXOe-00047R-TV@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 15:23:32 +0000

commit d064b429b670998e1e4a5ab73ac34d67cf44b083
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Wed Jan 31 11:02:40 2024 +0000
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu Feb 22 16:08:22 2024 +0000

    xen-analysis.py: Substitute only the comment instead of the line
    
    Change the code in tag_database.py to substitute only the SAF-*
    comment instead of replacing the line.
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 xen/scripts/xen_analysis/tag_database.py | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/xen/scripts/xen_analysis/tag_database.py b/xen/scripts/xen_analysis/tag_database.py
index abba163aec..dc0558a46e 100644
--- a/xen/scripts/xen_analysis/tag_database.py
+++ b/xen/scripts/xen_analysis/tag_database.py
@@ -16,14 +16,18 @@ tool_syntax = {
     "eclair":"-E> hide VID 1 \"\""
 }
 
+def get_xen_tag_regex(tool):
+    return rf'(?P<tag>SAF-(?P<id>\d+)-(?P<type>safe|false-positive-{tool}))'
+
 
 def get_xen_tag_index_type_regex(tool):
-    return rf'^SAF-(?P<id>\d+)-(?P<type>safe|false-positive-{tool})$'
+    return rf'^{get_xen_tag_regex(tool)}$'
 
 
 def get_xen_tag_comment_regex(tool):
-    tag=rf'(?P<tag>SAF-\d+-(?:safe|false-positive-{tool}))'
-    return rf'^[ \t]*/\* +{tag}.*\*/$'
+    before_comment = r'(?P<before>[ \t]*)'
+    comment = rf'(?P<comment>/\* +{get_xen_tag_regex(tool)}.*\*/)'
+    return rf'^(?P<full_line>{before_comment}{comment})$'
 
 
 # Returns a data structure containing dictionaries for safe and false-positive-*
@@ -66,7 +70,7 @@ def load_tag_database(tool, input_files, data_struct = None, schema = "safe"):
                 # Save in safe or false-positive-* the key {#id: "comment"}
                 id_number = int(xen_tag.group('id'))
                 key = xen_tag.group('type')
-                ret[key][id_number] = "/* {} */\n".format(comment)
+                ret[key][id_number] = "/* {} */".format(comment)
             else:
                 raise TagDatabaseError(
                         "Error in database file, entry {} has unexpected "
@@ -101,7 +105,11 @@ def substitute_tags(tool, input_file, grep_struct, subs_rules):
                 id_number = int(xen_tag_regex_obj.group('id'))
                 key = xen_tag_regex_obj.group('type')
                 if id_number in subs_rules[key]:
-                    parsed_content[line_number-1] = subs_rules[key][id_number]
+                    comment_in = grep_struct["matches"][line_number]['comment']
+                    comment_out = subs_rules[key][id_number]
+                    parsed_content[line_number-1] = re.sub(
+                        re.escape(comment_in), comment_out,
+                        parsed_content[line_number-1])
 
             outfile.writelines(parsed_content)
     except Exception as e:
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 15:23:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 15:23:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684898.1065122 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXOq-00079U-ND; Fri, 23 Feb 2024 15:23:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684898.1065122; Fri, 23 Feb 2024 15:23:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdXOq-00079M-KV; Fri, 23 Feb 2024 15:23:44 +0000
Received: by outflank-mailman (input) for mailman id 684898;
 Fri, 23 Feb 2024 15:23:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXOp-000792-3N
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:23:43 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXOp-0004hh-2Z
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:23:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdXOp-00047w-05
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 15:23:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=qWNw1j4XUtw2nw35Z1UZGghn7SEz1OjRUe3bSAk+yWA=; b=TV6ZkaEJbJmiWZqInNTxtPpDyD
	myDWQ4pafwhaZus6JKEc9jz+mcceEs41908h5cSZs0dmP8wVa9V497kN9pbaX0ZkHRf3vnkiQDudl
	RCUQqDapbWjBPxuWfveutMphDt5oS8ThoM1djRicpu8gN598xOHFZnAahQalb9vEZIWA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen-analysis.py: Accept deviation comment at the end of the line
Message-Id: <E1rdXOp-00047w-05@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 15:23:43 +0000

commit 812bdc99f4c5d05d20b6fac03b90920c0dbf9a2b
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Wed Jan 31 11:02:41 2024 +0000
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu Feb 22 16:08:25 2024 +0000

    xen-analysis.py: Accept deviation comment at the end of the line
    
    Implement the in-code suppression comment at the end of the line.
    Now it is possible to add a Xen deviaiton comment with the syntax
    described in the docs at the end of the line affected by the
    violation, to deviate it.
    
    Eclair natively supports it, so the translation for the tool will
    be straighforward, but the other tool needs to translate an
    occurrence of the tag into a suppressino comment at the end of the
    previous line, this will have a corner case where the line number
    1 of the file can't be deviated in this way for such tools.
    
    Updated documentation.
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 docs/misra/documenting-violations.rst         | 10 ++++++++++
 xen/scripts/xen_analysis/cppcheck_analysis.py |  2 +-
 xen/scripts/xen_analysis/generic_analysis.py  | 14 +++++++++-----
 xen/scripts/xen_analysis/tag_database.py      | 25 ++++++++++++++++++++++++-
 4 files changed, 44 insertions(+), 7 deletions(-)

diff --git a/docs/misra/documenting-violations.rst b/docs/misra/documenting-violations.rst
index 0d02a8e6f9..8f1cbd83b8 100644
--- a/docs/misra/documenting-violations.rst
+++ b/docs/misra/documenting-violations.rst
@@ -210,3 +210,13 @@ will be an entry like the following and the violation id will be in the column
 
 Given the violation id "misra-c2012-20.7", the procedure above can be followed
 to justify this finding.
+
+Another way to justify the above violation is to put the in-code comment tag
+at the end of the affected line::
+
+| extern char _start[], _end[], start[]; /* SAF-1-safe [...] */
+
+This way of deviating violations needs however to be used only when placing the
+tag above the line can't be done. This option suffers from some limitation on
+cppcheck and coverity tool that don't support natively the suppression comment
+at the end of the line.
diff --git a/xen/scripts/xen_analysis/cppcheck_analysis.py b/xen/scripts/xen_analysis/cppcheck_analysis.py
index 919eb153ce..850335c998 100644
--- a/xen/scripts/xen_analysis/cppcheck_analysis.py
+++ b/xen/scripts/xen_analysis/cppcheck_analysis.py
@@ -41,7 +41,7 @@ def __generate_suppression_list(out_file):
     # The following lambda function will return a file if it contains lines with
     # a comment containing "cppcheck-suppress[*]" on a single line.
     grep_action = lambda x: utils.grep(x,
-                    r'^[ \t]*/\* cppcheck-suppress\[(?P<id>.*)\] \*/$')
+                    r'^.*/\* cppcheck-suppress\[(?P<id>.*)\] \*/$')
     # Look for a list of .h files that matches the condition above
     headers = utils.recursive_find_file(settings.xen_dir, r'.*\.h$',
                                         grep_action)
diff --git a/xen/scripts/xen_analysis/generic_analysis.py b/xen/scripts/xen_analysis/generic_analysis.py
index 94122aebac..9e0cfc1bbc 100644
--- a/xen/scripts/xen_analysis/generic_analysis.py
+++ b/xen/scripts/xen_analysis/generic_analysis.py
@@ -52,11 +52,15 @@ def parse_xen_tags():
         os.rename(file, bkp_file)
         time_bkp_file = os.stat(bkp_file)
         # Create <file> from <file>.safparse but with the Xen tag parsed
-        tag_database.substitute_tags(settings.analysis_tool, bkp_file, entry,
-                                     subs_list)
-        # Set timestamp for file equal to bkp_file, so that if the file is
-        # modified during the process by the user, we can catch it
-        os.utime(file, (time_bkp_file.st_atime, time_bkp_file.st_mtime))
+        try:
+            tag_database.substitute_tags(settings.analysis_tool, bkp_file, entry,
+                                         subs_list)
+        except Exception as e:
+            raise ParseTagPhaseError("{}".format(e))
+        finally:
+            # Set timestamp for file equal to bkp_file, so that if the file is
+            # modified during the process by the user, we can catch it
+            os.utime(file, (time_bkp_file.st_atime, time_bkp_file.st_mtime))
 
 
 def build_xen():
diff --git a/xen/scripts/xen_analysis/tag_database.py b/xen/scripts/xen_analysis/tag_database.py
index dc0558a46e..57746ca0dd 100644
--- a/xen/scripts/xen_analysis/tag_database.py
+++ b/xen/scripts/xen_analysis/tag_database.py
@@ -25,7 +25,7 @@ def get_xen_tag_index_type_regex(tool):
 
 
 def get_xen_tag_comment_regex(tool):
-    before_comment = r'(?P<before>[ \t]*)'
+    before_comment = r'(?P<before>.*)'
     comment = rf'(?P<comment>/\* +{get_xen_tag_regex(tool)}.*\*/)'
     return rf'^(?P<full_line>{before_comment}{comment})$'
 
@@ -106,7 +106,30 @@ def substitute_tags(tool, input_file, grep_struct, subs_rules):
                 key = xen_tag_regex_obj.group('type')
                 if id_number in subs_rules[key]:
                     comment_in = grep_struct["matches"][line_number]['comment']
+                    before = grep_struct["matches"][line_number]['before']
                     comment_out = subs_rules[key][id_number]
+                    if before != '' and not re.match(r'^[ \t]+$', before):
+                        # The comment is at the end of some line with some code
+                        if tool == "eclair":
+                            # Eclair supports comment at the end of the line, so
+                            # the only thing to do is use the right syntax in
+                            # the comment, the default version of it is
+                            # deviating the current line and the next one
+                            comment_out = re.sub(r'\d+ ""', '0 ""', comment_out)
+                        else:
+                            # Other tool does not support deviating the same
+                            # line of the comment, so we use a trick and we use
+                            # the comment at the end of the previous line
+                            if line_number-2 < 0:
+                                raise TagDatabaseError(
+                                    "The comment {} using the tool '{}' can't "
+                                    "stay at the end of the line 1."
+                                    .format(comment_in, tool)
+                                )
+                            parsed_content[line_number-2] = \
+                                parsed_content[line_number-2].replace("\n",
+                                    comment_out + '\n')
+                            comment_out = ''
                     parsed_content[line_number-1] = re.sub(
                         re.escape(comment_in), comment_out,
                         parsed_content[line_number-1])
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 17:44:11 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 17:44:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684920.1065155 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZaf-0008Fq-37; Fri, 23 Feb 2024 17:44:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684920.1065155; Fri, 23 Feb 2024 17:44:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZaf-0008Fj-0g; Fri, 23 Feb 2024 17:44:05 +0000
Received: by outflank-mailman (input) for mailman id 684920;
 Fri, 23 Feb 2024 17:44:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZae-0008Fd-7J
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZae-0007qp-5Y
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZae-00022Y-2i
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=F+NzdKUTRe9ytpKOp+8GDbHaI+ebe9Ox4AMbrQIHhc4=; b=w7asT+4EBWCS0Y+txXeud9hzOi
	AldptxFWOTnaUW1zyovH4nnMqWlvN6VlFOxNBFpe25qYgr5mdYrRFMQ83Xz58LoGbarrTCYu16A+d
	FWR7TPBd8/NG3UgYo7gi84xbR7OYrHuWXdj4jO6gE4m0CLlDCz7RGakmdtyxPESrEIRw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/*/asm-offset: Fix bad copy&paste from x86
Message-Id: <E1rdZae-00022Y-2i@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 17:44:04 +0000

commit 98e79be5b60ac5f4fbcb064a9e11c30024929ff1
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon Jan 29 11:39:32 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    xen/*/asm-offset: Fix bad copy&paste from x86
    
    All architectures have copy&pasted bad logic from x86.
    
    OFFSET() having a trailing semi-colon within the macro expansion can be a
    problematic pattern.  It's benign in this case, but fix it anyway.
    
    Perform style fixes for the other macros, and tame the mess of BLANK()
    position to be consistent (one BLANK() after each block) so the intermediate
    form is legible too.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Shawn Anastasio <sanastasio@raptorengineering.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/arm32/asm-offsets.c     | 15 ++++++++-------
 xen/arch/arm/arm64/asm-offsets.c     | 14 ++++++++------
 xen/arch/ppc/ppc64/asm-offsets.c     |  9 ++++++---
 xen/arch/riscv/riscv64/asm-offsets.c | 10 +++++-----
 xen/arch/x86/x86_64/asm-offsets.c    |  9 +++++----
 5 files changed, 32 insertions(+), 25 deletions(-)

diff --git a/xen/arch/arm/arm32/asm-offsets.c b/xen/arch/arm/arm32/asm-offsets.c
index 05c692bb28..8bbb0f938e 100644
--- a/xen/arch/arm/arm32/asm-offsets.c
+++ b/xen/arch/arm/arm32/asm-offsets.c
@@ -14,12 +14,12 @@
 #include <asm/setup.h>
 
 #define DEFINE(_sym, _val)                                                 \
-    asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \
-                  : : "i" (_val) )
+    asm volatile ( "\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\""\
+                   :: "i" (_val) )
 #define BLANK()                                                            \
-    asm volatile ( "\n.ascii\"==><==\"" : : )
+    asm volatile ( "\n.ascii\"==><==\"" )
 #define OFFSET(_sym, _str, _mem)                                           \
-    DEFINE(_sym, offsetof(_str, _mem));
+    DEFINE(_sym, offsetof(_str, _mem))
 
 void __dummy__(void)
 {
@@ -62,18 +62,19 @@ void __dummy__(void)
    BLANK();
 
    DEFINE(CPUINFO_sizeof, sizeof(struct cpu_info));
+   BLANK();
 
    OFFSET(VCPU_arch_saved_context, struct vcpu, arch.saved_context);
-
    BLANK();
+
    DEFINE(PROCINFO_sizeof, sizeof(struct proc_info_list));
    OFFSET(PROCINFO_cpu_val, struct proc_info_list, cpu_val);
    OFFSET(PROCINFO_cpu_mask, struct proc_info_list, cpu_mask);
    OFFSET(PROCINFO_cpu_init, struct proc_info_list, cpu_init);
-
    BLANK();
-   OFFSET(INITINFO_stack, struct init_info, stack);
 
+   OFFSET(INITINFO_stack, struct init_info, stack);
+   BLANK();
 }
 
 /*
diff --git a/xen/arch/arm/arm64/asm-offsets.c b/xen/arch/arm/arm64/asm-offsets.c
index 7adb67a1b8..602ffa5b54 100644
--- a/xen/arch/arm/arm64/asm-offsets.c
+++ b/xen/arch/arm/arm64/asm-offsets.c
@@ -14,12 +14,12 @@
 #include <asm/smccc.h>
 
 #define DEFINE(_sym, _val)                                                 \
-    asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \
-                  : : "i" (_val) )
+    asm volatile ( "\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\""\
+                   :: "i" (_val) )
 #define BLANK()                                                            \
-    asm volatile ( "\n.ascii\"==><==\"" : : )
+    asm volatile ( "\n.ascii\"==><==\"" )
 #define OFFSET(_sym, _str, _mem)                                           \
-    DEFINE(_sym, offsetof(_str, _mem));
+    DEFINE(_sym, offsetof(_str, _mem))
 
 void __dummy__(void)
 {
@@ -48,13 +48,14 @@ void __dummy__(void)
 
    DEFINE(CPUINFO_sizeof, sizeof(struct cpu_info));
    OFFSET(CPUINFO_flags, struct cpu_info, flags);
+   BLANK();
 
    OFFSET(VCPU_arch_saved_context, struct vcpu, arch.saved_context);
-
    BLANK();
-   OFFSET(INITINFO_stack, struct init_info, stack);
 
+   OFFSET(INITINFO_stack, struct init_info, stack);
    BLANK();
+
    OFFSET(SMCCC_RES_a0, struct arm_smccc_res, a0);
    OFFSET(SMCCC_RES_a2, struct arm_smccc_res, a2);
    OFFSET(ARM_SMCCC_1_2_REGS_X0_OFFS, struct arm_smccc_1_2_regs, a0);
@@ -66,6 +67,7 @@ void __dummy__(void)
    OFFSET(ARM_SMCCC_1_2_REGS_X12_OFFS, struct arm_smccc_1_2_regs, a12);
    OFFSET(ARM_SMCCC_1_2_REGS_X14_OFFS, struct arm_smccc_1_2_regs, a14);
    OFFSET(ARM_SMCCC_1_2_REGS_X16_OFFS, struct arm_smccc_1_2_regs, a16);
+   BLANK();
 }
 
 /*
diff --git a/xen/arch/ppc/ppc64/asm-offsets.c b/xen/arch/ppc/ppc64/asm-offsets.c
index 634d7260e3..b95865092f 100644
--- a/xen/arch/ppc/ppc64/asm-offsets.c
+++ b/xen/arch/ppc/ppc64/asm-offsets.c
@@ -10,11 +10,11 @@
 
 #define DEFINE(_sym, _val)                                                  \
     asm volatile ( "\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \
-                   : : "i" (_val) )
+                   :: "i" (_val) )
 #define BLANK()                                                             \
-    asm volatile ( "\n.ascii\"==><==\"" : : )
+    asm volatile ( "\n.ascii\"==><==\"" )
 #define OFFSET(_sym, _str, _mem)                                            \
-    DEFINE(_sym, offsetof(_str, _mem));
+    DEFINE(_sym, offsetof(_str, _mem))
 
 /* base-2 logarithm */
 #define __L2(_x)  (((_x) & 0x00000002) ?   1 : 0)
@@ -29,6 +29,7 @@ void __dummy__(void)
 
     DEFINE(GPR_WIDTH, sizeof(unsigned long));
     DEFINE(FPR_WIDTH, sizeof(double));
+    BLANK();
 
     OFFSET(UREGS_gprs, struct cpu_user_regs, gprs);
     OFFSET(UREGS_r0, struct cpu_user_regs, gprs[0]);
@@ -48,9 +49,11 @@ void __dummy__(void)
     OFFSET(UREGS_fpscr, struct cpu_user_regs, fpscr);
     OFFSET(UREGS_entry_vector, struct cpu_user_regs, entry_vector);
     DEFINE(UREGS_sizeof, sizeof(struct cpu_user_regs));
+    BLANK();
 
     OFFSET(OPAL_base, struct opal, base);
     OFFSET(OPAL_entry, struct opal, entry);
+    BLANK();
 }
 
 /*
diff --git a/xen/arch/riscv/riscv64/asm-offsets.c b/xen/arch/riscv/riscv64/asm-offsets.c
index d632b75c2a..9f663b9510 100644
--- a/xen/arch/riscv/riscv64/asm-offsets.c
+++ b/xen/arch/riscv/riscv64/asm-offsets.c
@@ -4,16 +4,15 @@
 #include <xen/types.h>
 
 #define DEFINE(_sym, _val)                                                 \
-    asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \
-                  : : "i" (_val) )
+    asm volatile ( "\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\""\
+                   :: "i" (_val) )
 #define BLANK()                                                            \
-    asm volatile ( "\n.ascii\"==><==\"" : : )
+    asm volatile ( "\n.ascii\"==><==\"" )
 #define OFFSET(_sym, _str, _mem)                                           \
-    DEFINE(_sym, offsetof(_str, _mem));
+    DEFINE(_sym, offsetof(_str, _mem))
 
 void asm_offsets(void)
 {
-    BLANK();
     DEFINE(CPU_USER_REGS_SIZE, sizeof(struct cpu_user_regs));
     OFFSET(CPU_USER_REGS_ZERO, struct cpu_user_regs, zero);
     OFFSET(CPU_USER_REGS_RA, struct cpu_user_regs, ra);
@@ -50,4 +49,5 @@ void asm_offsets(void)
     OFFSET(CPU_USER_REGS_SEPC, struct cpu_user_regs, sepc);
     OFFSET(CPU_USER_REGS_SSTATUS, struct cpu_user_regs, sstatus);
     OFFSET(CPU_USER_REGS_PREGS, struct cpu_user_regs, pregs);
+    BLANK();
 }
diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c
index f9546ec60b..fee0edc61a 100644
--- a/xen/arch/x86/x86_64/asm-offsets.c
+++ b/xen/arch/x86/x86_64/asm-offsets.c
@@ -17,12 +17,12 @@
 #include <xen/multiboot2.h>
 
 #define DEFINE(_sym, _val)                                                 \
-    asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \
-                  : : "i" (_val) )
+    asm volatile ( "\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\""\
+                   :: "i" (_val) )
 #define BLANK()                                                            \
-    asm volatile ( "\n.ascii\"==><==\"" : : )
+    asm volatile ( "\n.ascii\"==><==\"" )
 #define OFFSET(_sym, _str, _mem)                                           \
-    DEFINE(_sym, offsetof(_str, _mem));
+    DEFINE(_sym, offsetof(_str, _mem))
 
 void __dummy__(void)
 {
@@ -180,4 +180,5 @@ void __dummy__(void)
     BLANK();
 
     OFFSET(DOMAIN_vm_assist, struct domain, vm_assist);
+    BLANK();
 }
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 17:44:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 17:44:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684921.1065159 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZap-0008Hx-62; Fri, 23 Feb 2024 17:44:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684921.1065159; Fri, 23 Feb 2024 17:44:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZap-0008Hp-3Q; Fri, 23 Feb 2024 17:44:15 +0000
Received: by outflank-mailman (input) for mailman id 684921;
 Fri, 23 Feb 2024 17:44:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZao-0008Hf-Bg
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZao-0007rl-AL
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZao-00023A-7v
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=iVEUiCphIH+Abk+0dqmwetmHlu5SMHqbPPaTz4Oh200=; b=5rVqOHNOJ1vb2fsh63nxRF6clh
	GXgqpRRyxGAOWaOVbxZ/1Zr5/WQCyVmaVT87rAp19GjUxGPGCRkb0a/AxcPvx082CCTZpElyoQmc4
	AjkPHCIsXk9tmMruRxdWTcHuhiRWVptnWJP/FxclDExc6X11RYxWBQ9bKeDnDwg/Z6CA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/altp2m: p2m_altp2m_get_or_propagate() should honor ap2m->default_access
Message-Id: <E1rdZao-00023A-7v@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 17:44:14 +0000

commit 7e5b662b289ac66ee347113f94c46c89d127e774
Author:     Petr Beneš <w1benny@gmail.com>
AuthorDate: Tue Feb 6 10:08:22 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    x86/altp2m: p2m_altp2m_get_or_propagate() should honor ap2m->default_access
    
    This patch addresses a behavior discrepancy in the handling of altp2m views,
    where upon the creation and subsequent EPT violation, the page access
    permissions were incorrectly inherited from the hostp2m instead of respecting
    the altp2m default_access.
    
    Previously, when a new altp2m view was established with restrictive
    default_access permissions and activated via xc_altp2m_switch_to_view(),
    it failed to trigger an event on the first access violation.  This behavior
    diverged from the intended mechanism, where the altp2m's default_access
    should dictate the initial permissions, ensuring proper event triggering on
    access violations.
    
    The correction involves modifying the handling mechanism to respect the
    altp2m view's default_access upon its activation, eliminating the need for
    setting memory access permissions for the entire altp2m range (e.g. within
    xen-access.c).  This change not only aligns the behavior with the expected
    access control logic but also results in a significant performance improvement
    by reducing the overhead associated with setting memory access permissions
    across the altp2m range.
    
    Signed-off-by: Petr Beneš <w1benny@gmail.com>
    Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
---
 tools/misc/xen-access.c | 14 --------------
 xen/arch/x86/mm/p2m.c   |  3 +++
 2 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/tools/misc/xen-access.c b/tools/misc/xen-access.c
index 4097eebe6f..6cf3b6a42c 100644
--- a/tools/misc/xen-access.c
+++ b/tools/misc/xen-access.c
@@ -517,9 +517,6 @@ int main(int argc, char *argv[])
     /* With altp2m we just create a new, restricted view of the memory */
     if ( memaccess && altp2m )
     {
-        xen_pfn_t gfn = 0;
-        unsigned long perm_set = 0;
-
         if( altp2m_write_no_gpt )
         {
             rc = xc_monitor_inguest_pagefault(xch, domain_id, 1);
@@ -551,17 +548,6 @@ int main(int argc, char *argv[])
         }
 
         DPRINTF("altp2m view created with id %u\n", altp2m_view_id);
-        DPRINTF("Setting altp2m mem_access permissions.. ");
-
-        for(; gfn < xenaccess->max_gpfn; ++gfn)
-        {
-            rc = xc_altp2m_set_mem_access( xch, domain_id, altp2m_view_id, gfn,
-                                           default_access);
-            if ( !rc )
-                perm_set++;
-        }
-
-        DPRINTF("done! Permissions set on %lu pages.\n", perm_set);
 
         rc = xc_altp2m_switch_to_view( xch, domain_id, altp2m_view_id );
         if ( rc < 0 )
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index d118d27ab9..4dd41193f5 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -1850,6 +1850,9 @@ bool p2m_altp2m_get_or_propagate(struct p2m_domain *ap2m, unsigned long gfn_l,
     amfn = _mfn(mfn_x(*mfn) & mask);
     gfn = _gfn(gfn_l & mask);
 
+    /* Override the altp2m entry with its default access. */
+    *p2ma = ap2m->default_access;
+
     rc = p2m_set_entry(ap2m, gfn, amfn, cur_order, *p2mt, *p2ma);
     p2m_unlock(ap2m);
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 17:44:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 17:44:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684922.1065164 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZaz-0008KM-7b; Fri, 23 Feb 2024 17:44:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684922.1065164; Fri, 23 Feb 2024 17:44:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZaz-0008KE-4u; Fri, 23 Feb 2024 17:44:25 +0000
Received: by outflank-mailman (input) for mailman id 684922;
 Fri, 23 Feb 2024 17:44:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZay-0008K8-H1
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZay-0007t5-FP
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZay-00024w-CT
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:24 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=LqMO1bi1eutHkRWj4LxtpPUiw936wMWujvbOypWZud4=; b=Y9IH8HnrIj1YDouvQNuGgmpcXN
	dsgRs/fztTDOVj82x0Fx30sYF4t2C7TBD2rXWqjUnuh5jXjEDkVcaC68s09yTz8JWm6RjFupthqa+
	YYmHpEP/cWaJFx/hAax/EOKo+0+KIBsqNLTK1lrjs1CmdGHRiLAkr4MOdiN69t10w650=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/oxenstored: Use Map instead of Hashtbl for quotas
Message-Id: <E1rdZay-00024w-CT@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 17:44:24 +0000

commit b6cf604207fd0a04451a48f2ce6d05fb66c612ab
Author:     Edwin Török <edwin.torok@cloud.com>
AuthorDate: Wed Jan 31 10:52:55 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools/oxenstored: Use Map instead of Hashtbl for quotas
    
    On a stress test running 1000 VMs flamegraphs have shown that
    `oxenstored` spends a large amount of time in `Hashtbl.copy` and the GC.
    
    Hashtable complexity:
     * read/write: O(1) average
     * copy: O(domains) -- copying the entire table
    
    Map complexity:
     * read/write: O(log n) worst case
     * copy: O(1) -- a word copy
    
    We always perform at least one 'copy' when processing each xenstore
    packet (regardless whether it is a readonly operation or inside a
    transaction or not), so the actual complexity per packet is:
      * Hashtbl: O(domains)
      * Map: O(log domains)
    
    Maps are the clear winner, and a better fit for the immutable xenstore
    tree.
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    Acked-by: Christian Lindig <christian.lindig@cloud.com>
---
 tools/ocaml/xenstored/quota.ml | 65 ++++++++++++++++++++++--------------------
 1 file changed, 34 insertions(+), 31 deletions(-)

diff --git a/tools/ocaml/xenstored/quota.ml b/tools/ocaml/xenstored/quota.ml
index 300d78a50b..f6e28ecc6a 100644
--- a/tools/ocaml/xenstored/quota.ml
+++ b/tools/ocaml/xenstored/quota.ml
@@ -23,66 +23,69 @@ let activate = ref true
 let maxent = ref (1000)
 let maxsize = ref (2048)
 
+module Domid = struct
+  type t = Xenctrl.domid
+  let compare (a:t) (b:t) = compare a b
+end
+
+module DomidMap = Map.Make(Domid)
+
 type t = {
   maxent: int;               (* max entities per domU *)
   maxsize: int;              (* max size of data store in one node *)
-  cur: (Xenctrl.domid, int) Hashtbl.t; (* current domains quota *)
+  mutable cur: int DomidMap.t; (* current domains quota *)
 }
 
 let to_string quota domid =
-  if Hashtbl.mem quota.cur domid
-  then Printf.sprintf "dom%i quota: %i/%i" domid (Hashtbl.find quota.cur domid) quota.maxent
-  else Printf.sprintf "dom%i quota: not set" domid
+  try
+    Printf.sprintf "dom%i quota: %i/%i" domid (DomidMap.find domid quota.cur) quota.maxent
+  with Not_found ->
+    Printf.sprintf "dom%i quota: not set" domid
 
 let create () =
-  { maxent = !maxent; maxsize = !maxsize; cur = Hashtbl.create 100; }
+  { maxent = !maxent; maxsize = !maxsize; cur = DomidMap.empty; }
 
-let copy quota = { quota with cur = (Hashtbl.copy quota.cur) }
+let copy quota = { quota with cur = quota.cur }
 
-let del quota id = Hashtbl.remove quota.cur id
+let del quota id = { quota with cur = DomidMap.remove id quota.cur }
 
 let _check quota id size =
   if size > quota.maxsize then (
     warn "domain %u err create entry: data too big %d" id size;
     raise Data_too_big
   );
-  if id > 0 && Hashtbl.mem quota.cur id then
-    let entry = Hashtbl.find quota.cur id in
+  if id > 0 then
+  try
+    let entry = DomidMap.find id quota.cur in
     if entry >= quota.maxent then (
       warn "domain %u cannot create entry: quota reached" id;
       raise Limit_reached
     )
+  with Not_found -> ()
 
 let check quota id size =
   if !activate then
     _check quota id size
 
-let get_entry quota id = Hashtbl.find quota.cur id
+let find_or_zero quota_cur id =
+  try DomidMap.find id quota_cur with Not_found -> 0
 
-let set_entry quota id nb =
-  if nb = 0
-  then Hashtbl.remove quota.cur id
-  else begin
-    if Hashtbl.mem quota.cur id then
-      Hashtbl.replace quota.cur id nb
-    else
-      Hashtbl.add quota.cur id nb
-  end
+let update_entry quota_cur id diff =
+  let nb = diff + find_or_zero quota_cur id in
+  if nb = 0 then DomidMap.remove id quota_cur
+  else DomidMap.add id nb quota_cur
 
 let del_entry quota id =
-  try
-    let nb = get_entry quota id in
-    set_entry quota id (nb - 1)
-  with Not_found -> ()
+  quota.cur <- update_entry quota.cur id (-1)
 
 let add_entry quota id =
-  let nb = try get_entry quota id with Not_found -> 0 in
-  set_entry quota id (nb + 1)
-
-let add quota diff =
-  Hashtbl.iter (fun id nb -> set_entry quota id (get_entry quota id + nb)) diff.cur
+  quota.cur <- update_entry quota.cur id (+1)
 
 let merge orig_quota mod_quota dest_quota =
-  Hashtbl.iter (fun id nb -> let diff = nb - (try get_entry orig_quota id with Not_found -> 0) in
-      if diff <> 0 then
-        set_entry dest_quota id ((try get_entry dest_quota id with Not_found -> 0) + diff)) mod_quota.cur
+  let fold_merge id nb dest =
+    match nb - find_or_zero orig_quota.cur id with
+    | 0 -> dest (* not modified *)
+    | diff -> update_entry dest id diff (* update with [x=x+diff] *)
+  in
+  dest_quota.cur <- DomidMap.fold fold_merge mod_quota.cur dest_quota.cur
+  (* dest_quota = dest_quota + (mod_quota - orig_quota) *)
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 17:44:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 17:44:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684923.1065169 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZb9-0008Mz-9O; Fri, 23 Feb 2024 17:44:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684923.1065169; Fri, 23 Feb 2024 17:44:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZb9-0008Mr-6R; Fri, 23 Feb 2024 17:44:35 +0000
Received: by outflank-mailman (input) for mailman id 684923;
 Fri, 23 Feb 2024 17:44:34 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZb8-0008Me-Jf
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZb8-0007tD-Iv
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZb8-00026J-Hd
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:34 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=+GQdyUJWgstS+tjrxuevgbRrgF0KaRp0GgJwxM6QeDg=; b=VqxmwkghlJcWlali/QWp/r1aCx
	+fyPClRU8Uh8GtLPD9dnRvdcsc84nTtmQhwfHE0B2tZC5zLhGngLtLq1jZ2+qAjQGy/oWNDhbMJWL
	ucf1nI15XfVDy+PNx37/JWAvXvH9KxcDVdGML500jBqSzwXYuSsw4xZX70NZ2TJhMYlg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/oxenstored: Make Quota.t pure
Message-Id: <E1rdZb8-00026J-Hd@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 17:44:34 +0000

commit 098d868e52ac0165b7f36e22b767ea70cef70054
Author:     Edwin Török <edwin.torok@cloud.com>
AuthorDate: Wed Jan 31 10:52:56 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools/oxenstored: Make Quota.t pure
    
    Now that we no longer have a hashtable inside we can make Quota.t pure, and
    push the mutable update to its callers.  Store.t already had a mutable Quota.t
    field.
    
    No functional change.
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    Acked-by: Christian Lindig <christian.lindig@cloud.com>
---
 tools/ocaml/xenstored/quota.ml |  8 ++++----
 tools/ocaml/xenstored/store.ml | 17 ++++++++++-------
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/tools/ocaml/xenstored/quota.ml b/tools/ocaml/xenstored/quota.ml
index f6e28ecc6a..1f652040d8 100644
--- a/tools/ocaml/xenstored/quota.ml
+++ b/tools/ocaml/xenstored/quota.ml
@@ -33,7 +33,7 @@ module DomidMap = Map.Make(Domid)
 type t = {
   maxent: int;               (* max entities per domU *)
   maxsize: int;              (* max size of data store in one node *)
-  mutable cur: int DomidMap.t; (* current domains quota *)
+  cur: int DomidMap.t; (* current domains quota *)
 }
 
 let to_string quota domid =
@@ -76,10 +76,10 @@ let update_entry quota_cur id diff =
   else DomidMap.add id nb quota_cur
 
 let del_entry quota id =
-  quota.cur <- update_entry quota.cur id (-1)
+  {quota with cur = update_entry quota.cur id (-1)}
 
 let add_entry quota id =
-  quota.cur <- update_entry quota.cur id (+1)
+  {quota with cur = update_entry quota.cur id (+1)}
 
 let merge orig_quota mod_quota dest_quota =
   let fold_merge id nb dest =
@@ -87,5 +87,5 @@ let merge orig_quota mod_quota dest_quota =
     | 0 -> dest (* not modified *)
     | diff -> update_entry dest id diff (* update with [x=x+diff] *)
   in
-  dest_quota.cur <- DomidMap.fold fold_merge mod_quota.cur dest_quota.cur
+  {dest_quota with cur = DomidMap.fold fold_merge mod_quota.cur dest_quota.cur}
   (* dest_quota = dest_quota + (mod_quota - orig_quota) *)
diff --git a/tools/ocaml/xenstored/store.ml b/tools/ocaml/xenstored/store.ml
index 38a4945372..9b8dd2812d 100644
--- a/tools/ocaml/xenstored/store.ml
+++ b/tools/ocaml/xenstored/store.ml
@@ -85,7 +85,9 @@ module Node = struct
       raise Define.Permission_denied;
     end
 
-  let rec recurse fct node = fct node; SymbolMap.iter (fun _ -> recurse fct) node.children
+  let rec recurse fct node acc =
+    let acc = fct node acc in
+    SymbolMap.fold (fun _ -> recurse fct) node.children acc
 
   (** [recurse_filter_map f tree] applies [f] on each node in the tree recursively,
       possibly removing some nodes.
@@ -408,7 +410,7 @@ let dump_buffer store = dump_store_buf store.root
 let set_node store path node orig_quota mod_quota =
   let root = Path.set_node store.root path node in
   store.root <- root;
-  Quota.merge orig_quota mod_quota store.quota
+  store.quota <- Quota.merge orig_quota mod_quota store.quota
 
 let write store perm path value =
   let node, existing = get_deepest_existing_node store path in
@@ -422,7 +424,7 @@ let write store perm path value =
   let root, node_created = path_write store perm path value in
   store.root <- root;
   if node_created
-  then Quota.add_entry store.quota owner
+  then store.quota <- Quota.add_entry store.quota owner
 
 let mkdir store perm path =
   let node, existing = get_deepest_existing_node store path in
@@ -431,7 +433,7 @@ let mkdir store perm path =
   if not (existing || (Perms.Connection.is_dom0 perm)) then Quota.check store.quota owner 0;
   store.root <- path_mkdir store perm path;
   if not existing then
-    Quota.add_entry store.quota owner
+    store.quota <- Quota.add_entry store.quota owner
 
 let rm store perm path =
   let rmed_node = Path.get_node store.root path in
@@ -439,7 +441,7 @@ let rm store perm path =
   | None -> raise Define.Doesnt_exist
   | Some rmed_node ->
     store.root <- path_rm store perm path;
-    Node.recurse (fun node -> Quota.del_entry store.quota (Node.get_owner node)) rmed_node
+    store.quota <- Node.recurse (fun node quota -> Quota.del_entry quota (Node.get_owner node)) rmed_node store.quota
 
 let setperms store perm path nperms =
   match Path.get_node store.root path with
@@ -450,8 +452,9 @@ let setperms store perm path nperms =
     if not ((old_owner = new_owner) || (Perms.Connection.is_dom0 perm)) then
       raise Define.Permission_denied;
     store.root <- path_setperms store perm path nperms;
-    Quota.del_entry store.quota old_owner;
-    Quota.add_entry store.quota new_owner
+    store.quota <-
+      let quota = Quota.del_entry store.quota old_owner in
+      Quota.add_entry quota new_owner
 
 let reset_permissions store domid =
   Logging.info "store|node" "Cleaning up xenstore ACLs for domid %d" domid;
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 17:44:45 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 17:44:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684924.1065172 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZbJ-0008QL-BR; Fri, 23 Feb 2024 17:44:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684924.1065172; Fri, 23 Feb 2024 17:44:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZbJ-0008QE-7v; Fri, 23 Feb 2024 17:44:45 +0000
Received: by outflank-mailman (input) for mailman id 684924;
 Fri, 23 Feb 2024 17:44:44 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZbI-0008Q4-Nf
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:44 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZbI-0007tO-Mo
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:44 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZbI-00027F-Lq
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:44 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=bDgDKoJS+DjmgcBqU2u6KjrV0YAfCtxGUWx535I+m4s=; b=USIovae6YWwSofh1wT2XDx6UwT
	xcVH+m6l3WklWpR0pYpdtGJ/Bw/j6RcrNJQXOrvFxf4MZvvGuMCvy1oBdVQ6JFiqD9hXg3OqG9fVF
	kZM0/7qyrmew+1NYobWTuTfhipa/jTHuibr1OiDzHVVwuRHQOspd9e2k0qfvH/3wQZvI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/libs/light: add backend type for 9pfs PV devices
Message-Id: <E1rdZbI-00027F-Lq@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 17:44:44 +0000

commit ab5a6b598651279ae9c47c22bbb0c072ad60d878
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 16 17:31:32 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools/libs/light: add backend type for 9pfs PV devices
    
    Make the backend type of 9pfs PV devices configurable. The default is
    "qemu" with the related Xenstore backend-side directory being "9pfs".
    
    Add another type "xen_9pfsd" with the related Xenstore backend-side
    directory "xen_9pfs".
    
    As additional security features it is possible to specify:
    - "max-space" for limiting the maximum space consumed on the filesystem
      in MBs
    - "max-files" for limiting the maximum number of files in the
      filesystem
    - "max-open-files" for limiting the maximum number of concurrent open
      files
    
    For convenience "auto-delete" is available to let the backend delete the
    oldest file of the guest in case otherwise "max-space" or "max-files"
    would be violated.
    
    The xen-9pfsd daemon will be started by libxenlight automatically when
    the first "xen_9pfs" device is being created.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: George Dunlap <george.dunlap@cloud.com> # Golang bits
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/golang/xenlight/helpers.gen.go      |  10 ++
 tools/golang/xenlight/types.gen.go        |  12 +++
 tools/include/libxl.h                     |   7 ++
 tools/libs/light/libxl_9pfs.c             | 157 +++++++++++++++++++++++++++++-
 tools/libs/light/libxl_create.c           |   4 +-
 tools/libs/light/libxl_dm.c               |   2 +-
 tools/libs/light/libxl_types.idl          |  11 +++
 tools/libs/light/libxl_types_internal.idl |   1 +
 8 files changed, 197 insertions(+), 7 deletions(-)

diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/helpers.gen.go
index acdf1c1820..78bdb08b15 100644
--- a/tools/golang/xenlight/helpers.gen.go
+++ b/tools/golang/xenlight/helpers.gen.go
@@ -2446,6 +2446,11 @@ x.Tag = C.GoString(xc.tag)
 x.Path = C.GoString(xc.path)
 x.SecurityModel = C.GoString(xc.security_model)
 x.Devid = Devid(xc.devid)
+x.Type = P9Type(xc._type)
+x.MaxSpace = int(xc.max_space)
+x.MaxFiles = int(xc.max_files)
+x.MaxOpenFiles = int(xc.max_open_files)
+x.AutoDelete = bool(xc.auto_delete)
 
  return nil}
 
@@ -2464,6 +2469,11 @@ xc.path = C.CString(x.Path)}
 if x.SecurityModel != "" {
 xc.security_model = C.CString(x.SecurityModel)}
 xc.devid = C.libxl_devid(x.Devid)
+xc._type = C.libxl_p9_type(x.Type)
+xc.max_space = C.int(x.MaxSpace)
+xc.max_files = C.int(x.MaxFiles)
+xc.max_open_files = C.int(x.MaxOpenFiles)
+xc.auto_delete = C.bool(x.AutoDelete)
 
  return nil
  }
diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/types.gen.go
index 76b4ed991b..ccfe18019e 100644
--- a/tools/golang/xenlight/types.gen.go
+++ b/tools/golang/xenlight/types.gen.go
@@ -122,6 +122,13 @@ NicTypeVifIoemu NicType = 1
 NicTypeVif NicType = 2
 )
 
+type P9Type int
+const(
+P9TypeUnknown P9Type = 0
+P9TypeQemu P9Type = 1
+P9TypeXen9Pfsd P9Type = 2
+)
+
 type ActionOnShutdown int
 const(
 ActionOnShutdownDestroy ActionOnShutdown = 1
@@ -890,6 +897,11 @@ Tag string
 Path string
 SecurityModel string
 Devid Devid
+Type P9Type
+MaxSpace int
+MaxFiles int
+MaxOpenFiles int
+AutoDelete bool
 }
 
 type DevicePvcallsif struct {
diff --git a/tools/include/libxl.h b/tools/include/libxl.h
index a370528ba1..f36c613b7d 100644
--- a/tools/include/libxl.h
+++ b/tools/include/libxl.h
@@ -622,6 +622,13 @@
  */
 #define LIBXL_HAVE_HVM_PIRQ 1
 
+/*
+ * LIBXL_HAVE_XEN_9PFS indicates the presence of the xen-9pfsd related
+ * fields in libxl_device_p9: type, max_space, max_files, max_open_files and
+ * auto_delete.
+ */
+#define LIBXL_HAVE_XEN_9PFS 1
+
 /*
  * libxl memory management
  *
diff --git a/tools/libs/light/libxl_9pfs.c b/tools/libs/light/libxl_9pfs.c
index 5ab0d3aa21..900c0d46a0 100644
--- a/tools/libs/light/libxl_9pfs.c
+++ b/tools/libs/light/libxl_9pfs.c
@@ -33,20 +33,171 @@ static int libxl__set_xenstore_p9(libxl__gc *gc, uint32_t domid,
 
     flexarray_append_pair(front, "tag", p9->tag);
 
+    if (p9->type == LIBXL_P9_TYPE_XEN_9PFSD) {
+        flexarray_append_pair(back, "max-space",
+                              GCSPRINTF("%u", p9->max_space));
+        flexarray_append_pair(back, "max-files",
+                              GCSPRINTF("%u", p9->max_files));
+        flexarray_append_pair(back, "max-open-files",
+                              GCSPRINTF("%u", p9->max_open_files));
+        flexarray_append_pair(back, "auto-delete",
+                              p9->auto_delete ? "1" : "0");
+    }
+
+    return 0;
+}
+
+static int libxl__device_from_p9(libxl__gc *gc, uint32_t domid,
+                                 libxl_device_p9 *type, libxl__device *device)
+{
+    device->backend_devid   = type->devid;
+    device->backend_domid   = type->backend_domid;
+    device->backend_kind    = type->type == LIBXL_P9_TYPE_QEMU
+                              ? LIBXL__DEVICE_KIND_9PFS
+                              : LIBXL__DEVICE_KIND_XEN_9PFS;
+    device->devid           = type->devid;
+    device->domid           = domid;
+    device->kind            = LIBXL__DEVICE_KIND_9PFS;
+
     return 0;
 }
 
-#define libxl__add_p9s NULL
+static int libxl__device_p9_dm_needed(void *e, unsigned domid)
+{
+    libxl_device_p9 *elem = e;
+
+    return elem->type == LIBXL_P9_TYPE_QEMU && elem->backend_domid == domid;
+}
+
+typedef struct libxl__aop9_state libxl__aop9_state;
+
+struct libxl__aop9_state {
+    libxl__spawn_state spawn;
+    libxl__ao_device *aodev;
+    libxl_device_p9 p9;
+    uint32_t domid;
+};
+
+static void xen9pfsd_confirm(libxl__egc *egc, libxl__spawn_state *spawn,
+                             const char *xsdata);
+static void xen9pfsd_failed(libxl__egc *egc, libxl__spawn_state *spawn, int rc);
+static void xen9pfsd_detached(libxl__egc *egc, libxl__spawn_state *spawn);
+static void xen9pfsd_spawn_outcome(libxl__egc *egc, libxl__aop9_state *aop9,
+                                   int rc);
+
+/*
+ * Spawn the xen-9pfsd daemon if needed.
+ * returns:
+ * < 0 if error
+ * 0 if no daemon needs to be spawned
+ * 1 if daemon was spawned
+ */
+static int xen9pfsd_spawn(libxl__egc *egc, uint32_t domid, libxl_device_p9 *p9,
+                         libxl__ao_device *aodev)
+{
+    STATE_AO_GC(aodev->ao);
+    struct libxl__aop9_state *aop9;
+    int rc;
+    char *args[] = { "xen-9pfsd", NULL };
+    char *path = GCSPRINTF("/local/domain/%u/libxl/xen-9pfs",
+                           p9->backend_domid);
+
+    if (p9->type != LIBXL_P9_TYPE_XEN_9PFSD ||
+        libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/state", path)))
+        return 0;
+
+    GCNEW(aop9);
+    aop9->aodev = aodev;
+    libxl_device_p9_copy(CTX, &aop9->p9, p9);
+    aop9->domid = domid;
+
+    aop9->spawn.ao = aodev->ao;
+    aop9->spawn.what = "xen-9pfs daemon";
+    aop9->spawn.xspath = GCSPRINTF("%s/state", path);
+    aop9->spawn.timeout_ms = LIBXL_DEVICE_MODEL_START_TIMEOUT * 1000;
+    aop9->spawn.pidpath = GCSPRINTF("%s/pid", path);
+    aop9->spawn.midproc_cb = libxl__spawn_record_pid;
+    aop9->spawn.confirm_cb = xen9pfsd_confirm;
+    aop9->spawn.failure_cb = xen9pfsd_failed;
+    aop9->spawn.detached_cb = xen9pfsd_detached;
+    rc = libxl__spawn_spawn(egc, &aop9->spawn);
+    if (rc < 0)
+        return rc;
+    if (!rc) {
+        setsid();
+        libxl__exec(gc, -1, -1, -1, LIBEXEC_BIN "/xen-9pfsd", args, NULL);
+    }
+
+    return 1;
+}
+
+static void xen9pfsd_confirm(libxl__egc *egc, libxl__spawn_state *spawn,
+                             const char *xsdata)
+{
+    STATE_AO_GC(spawn->ao);
+
+    if (!xsdata)
+        return;
+
+    if (strcmp(xsdata, "running"))
+        return;
+
+    libxl__spawn_initiate_detach(gc, spawn);
+}
+
+static void xen9pfsd_failed(libxl__egc *egc, libxl__spawn_state *spawn, int rc)
+{
+    libxl__aop9_state *aop9 = CONTAINER_OF(spawn, *aop9, spawn);
+
+    xen9pfsd_spawn_outcome(egc, aop9, rc);
+}
+
+static void xen9pfsd_detached(libxl__egc *egc, libxl__spawn_state *spawn)
+{
+    libxl__aop9_state *aop9 = CONTAINER_OF(spawn, *aop9, spawn);
+
+    xen9pfsd_spawn_outcome(egc, aop9, 0);
+}
+
+static void xen9pfsd_spawn_outcome(libxl__egc *egc, libxl__aop9_state *aop9,
+                                   int rc)
+{
+    aop9->aodev->rc = rc;
+    if (rc)
+        aop9->aodev->callback(egc, aop9->aodev);
+    else
+        libxl__device_add_async(egc, aop9->domid, &libxl__p9_devtype,
+                                &aop9->p9, aop9->aodev);
+}
+
+static void libxl__device_p9_add(libxl__egc *egc, uint32_t domid,
+                                 libxl_device_p9 *p9,
+                                 libxl__ao_device *aodev)
+{
+    int rc;
+
+    rc = xen9pfsd_spawn(egc, domid, p9, aodev);
+    if (rc == 1)
+        return;
+
+    if (rc == 0)
+        libxl__device_add_async(egc, domid, &libxl__p9_devtype, p9, aodev);
+
+    aodev->rc = rc;
+    if (rc)
+        aodev->callback(egc, aodev);
+}
+
 #define libxl_device_p9_list NULL
 #define libxl_device_p9_compare NULL
 
 static LIBXL_DEFINE_UPDATE_DEVID(p9)
-static LIBXL_DEFINE_DEVICE_FROM_TYPE(p9)
+static LIBXL_DEFINE_DEVICES_ADD(p9)
 
 LIBXL_DEFINE_DEVICE_REMOVE(p9)
 
 DEFINE_DEVICE_TYPE_STRUCT(p9, 9PFS, p9s,
-    .skip_attach = 1,
     .set_xenstore_config = (device_set_xenstore_config_fn_t)
                            libxl__set_xenstore_p9,
+    .dm_needed = libxl__device_p9_dm_needed,
 );
diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c
index 0008fac607..5546335973 100644
--- a/tools/libs/light/libxl_create.c
+++ b/tools/libs/light/libxl_create.c
@@ -1761,9 +1761,6 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
         libxl__device_console_dispose(&console);
     }
 
-    for (i = 0; i < d_config->num_p9s; i++)
-        libxl__device_add(gc, domid, &libxl__p9_devtype, &d_config->p9s[i]);
-
     for (i = 0; i < d_config->num_pvcallsifs; i++)
         libxl__device_add(gc, domid, &libxl__pvcallsif_devtype,
                           &d_config->pvcallsifs[i]);
@@ -1900,6 +1897,7 @@ const libxl__device_type *device_type_tbl[] = {
     &libxl__vdispl_devtype,
     &libxl__vsnd_devtype,
     &libxl__virtio_devtype,
+    &libxl__p9_devtype,
     NULL
 };
 
diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
index ed620a9d8e..dc4c2dfb9f 100644
--- a/tools/libs/light/libxl_dm.c
+++ b/tools/libs/light/libxl_dm.c
@@ -3771,7 +3771,7 @@ int libxl__need_xenpv_qemu(libxl__gc *gc, libxl_domain_config *d_config)
         goto out;
     }
 
-    if (d_config->num_vfbs > 0 || d_config->num_p9s > 0) {
+    if (d_config->num_vfbs > 0) {
         ret = 1;
         goto out;
     }
diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_types.idl
index 6d76f25528..470122e768 100644
--- a/tools/libs/light/libxl_types.idl
+++ b/tools/libs/light/libxl_types.idl
@@ -150,6 +150,12 @@ libxl_nic_type = Enumeration("nic_type", [
     (2, "VIF"),
     ])
 
+libxl_p9_type = Enumeration("p9_type", [
+    (0, "unknown"),
+    (1, "qemu"),
+    (2, "xen_9pfsd"),
+    ])
+
 libxl_action_on_shutdown = Enumeration("action_on_shutdown", [
     (1, "DESTROY"),
 
@@ -944,6 +950,11 @@ libxl_device_p9 = Struct("device_p9", [
     ("path",             string),
     ("security_model",   string),
     ("devid",            libxl_devid),
+    ("type",             libxl_p9_type),
+    ("max_space",        integer),
+    ("max_files",        integer),
+    ("max_open_files",   integer),
+    ("auto_delete",      bool),
 ])
 
 libxl_device_pvcallsif = Struct("device_pvcallsif", [
diff --git a/tools/libs/light/libxl_types_internal.idl b/tools/libs/light/libxl_types_internal.idl
index 56dccac153..0425e9b6b0 100644
--- a/tools/libs/light/libxl_types_internal.idl
+++ b/tools/libs/light/libxl_types_internal.idl
@@ -35,6 +35,7 @@ libxl__device_kind = Enumeration("device_kind", [
     (17, "VIRTIO_DISK"),
     (18, "VIRTIO"),
     (19, "VBD3"),
+    (20, "XEN_9PFS"),
     ])
 
 libxl__console_backend = Enumeration("console_backend", [
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 17:44:55 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 17:44:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684925.1065176 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZbT-0008Te-Dp; Fri, 23 Feb 2024 17:44:55 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684925.1065176; Fri, 23 Feb 2024 17:44:55 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZbT-0008TW-Ar; Fri, 23 Feb 2024 17:44:55 +0000
Received: by outflank-mailman (input) for mailman id 684925;
 Fri, 23 Feb 2024 17:44:54 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZbS-0008TO-Qy
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:54 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZbS-0007tZ-QB
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:54 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZbS-00028G-PJ
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:44:54 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=pLmlFWGiyifVYECgMC/ZTERblA4P96Njp+JhzpMTxFw=; b=Ap9TuK29rsyN/FUbRkW4Pj/LEJ
	4HnEbNfk6xXST/TxNERMkhA7+LVOE/E3/d0Lb0F/bI4Tjc8B0Jhz5X/koowzLccG4ujoMEbYw0uKv
	gIWyUwNyYySn6uHFK09rke5WlR4A4FIhAFDVpy+Ip0gEvc055ZxANFH3j7Z+w+7mpitE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xl: support new 9pfs backend xen_9pfsd
Message-Id: <E1rdZbS-00028G-PJ@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 17:44:54 +0000

commit 4287a71f9b9d6a7dc1e51ae89b5ae04e1ba49d7c
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 16 17:31:33 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools/xl: support new 9pfs backend xen_9pfsd
    
    Add support for the new 9pfs backend "xen_9pfsd". For this backend type
    the tag defaults to "Xen" and the host side path to
    "/var/log/xen/guests/<dom-name>".
    
    Do most of the default settings in libxl. Unfortunately the default
    path can't easily be set in libxl, as the domain name isn't available
    in the related 9pfs specific function.
    
    Settings the defaults in libxl requires to move the sanity checking
    of 9pfs parameters from xl to libxl, too.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 docs/man/xl.cfg.5.pod.in      | 36 ++++++++++++++++++++++++++++++++++--
 tools/libs/light/libxl_9pfs.c | 18 ++++++++++++++++++
 tools/xl/xl_parse.c           | 23 ++++++++++++++++++++---
 3 files changed, 72 insertions(+), 5 deletions(-)

diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
index ea8d41727d..039e057318 100644
--- a/docs/man/xl.cfg.5.pod.in
+++ b/docs/man/xl.cfg.5.pod.in
@@ -772,10 +772,16 @@ settings, from the following list:
 
 =over 4
 
+=item B<type=TYPE>
+
+The backendtype for the PV device. Supported values are B<qemu> and
+B<xen_9pfsd>.  The default is B<qemu>.
+
 =item B<tag=STRING>
 
 9pfs tag to identify the filesystem share. The tag is needed on the
-guest side to mount it.
+guest side to mount it. For the backendtype of B<xen_9pfsd> the tag defaults to
+"Xen".
 
 =item B<security_model="none">
 
@@ -785,12 +791,38 @@ squash or remap).
 
 =item B<path=STRING>
 
-Filesystem path on the backend to export.
+Filesystem path on the backend to export. For the backendtype of B<xen_9pfsd>
+the path defaults to "@XEN_LOG_DIR@/guests/<guest-name>".
 
 =item B<backend=domain-id>
 
 Specify the backend domain name or id, defaults to dom0.
 
+=item B<max-files=NUMBER>
+
+Specify the maximum number of files below B<path>. A value of 0 (which
+is the default) doesn't limit the number of files. Only valid for
+B<type=xen_9pfsd>.
+
+=item B<max-open-files=NUMBER>
+
+Specify the maximum number of concurrently opened files below B<path>.
+Multiple opens of the same file are counted individually. Only valid for
+B<type=xen_9pfsd>, which has a default of B<max-open-files=5>.
+
+=item B<max-space=NUMBER>
+
+Specify the maximum used disk space in MiB below B<path>. A value of 0 (which
+is the default) doesn't limit the usable disk space. Only valid for
+B<type=xen_9pfsd>.
+
+=item B<auto-delete=BOOLEAN>
+
+When set the backend will delete the oldest file which is currently not
+opened by the guest in case the disk space limit set via B<max-space> or the
+file limit set via B<max-files> is being reached. Only valid for
+B<type=xen_9pfsd>.
+
 =back
 
 =item B<pvcalls=[ "backend=domain-id", ... ]>
diff --git a/tools/libs/light/libxl_9pfs.c b/tools/libs/light/libxl_9pfs.c
index 900c0d46a0..ddeb4f20a7 100644
--- a/tools/libs/light/libxl_9pfs.c
+++ b/tools/libs/light/libxl_9pfs.c
@@ -20,6 +20,24 @@
 static int libxl__device_p9_setdefault(libxl__gc *gc, uint32_t domid,
                                        libxl_device_p9 *p9, bool hotplug)
 {
+    if (p9->type == LIBXL_P9_TYPE_UNKNOWN) {
+        p9->type = LIBXL_P9_TYPE_QEMU;
+    }
+    if (p9->type == LIBXL_P9_TYPE_QEMU &&
+        (p9->max_files || p9->max_open_files || p9->max_space ||
+         p9->auto_delete)) {
+        LOGD(ERROR, domid, "Illegal 9pfs parameter combination");
+        return ERROR_INVAL;
+    }
+    if (p9->type == LIBXL_P9_TYPE_XEN_9PFSD && !p9->tag) {
+        p9->tag = libxl__strdup(NOGC, "Xen");
+    }
+
+    if (!p9->path || !p9->security_model || !p9->tag) {
+        LOGD(ERROR, domid, "9pfs spec missing required field!");
+        return ERROR_INVAL;
+    }
+
     return libxl__resolve_domid(gc, p9->backend_domname, &p9->backend_domid);
 }
 
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 9b358f11b8..80ffe85f5e 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -2233,6 +2233,20 @@ void parse_config_data(const char *config_source,
                     replace_string(&p9->tag, value);
                 } else if (!strcmp(key, "backend")) {
                     replace_string(&p9->backend_domname, value);
+                } else if (!strcmp(key, "type")) {
+                    if (libxl_p9_type_from_string(value, &p9->type)) {
+                        fprintf(stderr, "failed to parse 9pfs type: %s\n",
+                                value);
+                        exit(1);
+                    }
+                } else if (!strcmp(key, "max-files")) {
+                    p9->max_files = parse_ulong(value);
+                } else if (!strcmp(key, "max-open-files")) {
+                    p9->max_open_files = parse_ulong(value);
+                } else if (!strcmp(key, "max-space")) {
+                    p9->max_space = parse_ulong(value);
+                } else if (!strcmp(key, "auto-delete")) {
+                    p9->auto_delete = strtoul(value, NULL, 0);
                 } else {
                     fprintf(stderr, "Unknown 9pfs parameter '%s'\n", key);
                     exit(1);
@@ -2243,9 +2257,12 @@ void parse_config_data(const char *config_source,
 
             libxl_string_list_dispose(&pairs);
 
-            if (!p9->path || !p9->security_model || !p9->tag) {
-                fprintf(stderr, "9pfs spec missing required field!\n");
-                exit(1);
+            if (p9->type == LIBXL_P9_TYPE_XEN_9PFSD && !p9->path) {
+                char *path;
+
+                xasprintf(&path, XEN_LOG_DIR "/guests/%s", c_info->name);
+                replace_string(&p9->path, path);
+                free(path);
             }
         }
     }
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 17:45:05 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 17:45:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684927.1065179 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZbd-00005J-F6; Fri, 23 Feb 2024 17:45:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684927.1065179; Fri, 23 Feb 2024 17:45:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZbd-00005C-CJ; Fri, 23 Feb 2024 17:45:05 +0000
Received: by outflank-mailman (input) for mailman id 684927;
 Fri, 23 Feb 2024 17:45:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZbc-000056-Tx
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZbc-0007uC-T7
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZbc-00029Q-SG
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=N1l2syvyc3aW3KXmiW8S19WC0y7vv2ndV7nxuiuej+w=; b=q1nKXYRdC/jJM2iz8bUpHmRTiq
	Xk4GlhzaVGPvXc3CQL2So1lYvmiO0EbyBHP7lhW9tAVITvpzgf4h/YQHU2PNFVQwGIQDVX+OuPS64
	K5GoEWBBqW+gGQzWjw7e3+KCXILZm8Msx/xY3A1j0DLYYQ+7u577Hw8orUbH2vXk3x8Y=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] stubdom: extend xenstore stubdom configs
Message-Id: <E1rdZbc-00029Q-SG@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 17:45:04 +0000

commit 0b761781c4de2e6637203d0f51273a5a1f8873df
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 16 17:31:34 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    stubdom: extend xenstore stubdom configs
    
    Extend the config files of the Xenstore stubdoms to include XENBUS
    and 9PFRONT items in order to support file based logging.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 stubdom/xenstore-minios.cfg    | 2 +-
 stubdom/xenstorepvh-minios.cfg | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/stubdom/xenstore-minios.cfg b/stubdom/xenstore-minios.cfg
index a41704bb6b..239da519b9 100644
--- a/stubdom/xenstore-minios.cfg
+++ b/stubdom/xenstore-minios.cfg
@@ -3,7 +3,7 @@ CONFIG_NETFRONT=n
 CONFIG_FBFRONT=n
 CONFIG_KBDFRONT=n
 CONFIG_CONSFRONT=n
-CONFIG_XENBUS=n
 CONFIG_LWIP=n
+CONFIG_9PFRONT=y
 CONFIG_BALLOON=y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
diff --git a/stubdom/xenstorepvh-minios.cfg b/stubdom/xenstorepvh-minios.cfg
index 6af51f5753..752b90d7d3 100644
--- a/stubdom/xenstorepvh-minios.cfg
+++ b/stubdom/xenstorepvh-minios.cfg
@@ -4,7 +4,7 @@ CONFIG_NETFRONT=n
 CONFIG_FBFRONT=n
 CONFIG_KBDFRONT=n
 CONFIG_CONSFRONT=n
-CONFIG_XENBUS=n
 CONFIG_LWIP=n
+CONFIG_9PFRONT=y
 CONFIG_BALLOON=y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 17:45:16 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 17:45:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684928.1065184 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZbo-000081-Gl; Fri, 23 Feb 2024 17:45:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684928.1065184; Fri, 23 Feb 2024 17:45:16 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZbo-00007l-Dr; Fri, 23 Feb 2024 17:45:16 +0000
Received: by outflank-mailman (input) for mailman id 684928;
 Fri, 23 Feb 2024 17:45:15 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZbn-00007Z-2x
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:15 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZbn-0007uP-0E
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:15 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZbm-0002AI-Vc
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=9ros3Po02Wz1f6kiqm4YW883pEGdeM67DvVBqkMbW48=; b=ySyw/v30UAORp7day2WhomlFHj
	KMxH0DLYl1Klp+KizHJfsRU3X5wtULPEgTt/EaeCULzR+NeDYzcWYWDMkQO2+EabOJgxrrwoj0Xf/
	F/tUclIsFuI/WlHVQ9DWid3sYcE9F6YAC5kha/Y2FjAYahRK42W0xZKR1kxTjMp6xH48=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools: add 9pfs device to xenstore-stubdom
Message-Id: <E1rdZbm-0002AI-Vc@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 17:45:14 +0000

commit e21d9dbf4457a8c1f42d6e4a2ef2d3fe7c62616b
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 16 17:31:35 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools: add 9pfs device to xenstore-stubdom
    
    Add a 9pfs device to Xenstore stubdom in order to allow it to do e.g.
    logging into a dom0 file.
    
    Use the following parameters for the new device:
    
    - tag = "Xen"
    - type = "xen_9pfsd"
    - path = "/var/lib/xen/xenstore"
    - security-model = "none"
    
    For now don't limit allowed file space or number of files.
    
    Add a new libxl function for adding it similar to the function for
    adding the console device.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/helpers/init-xenstore-domain.c |  7 +++++++
 tools/include/libxl.h                | 15 +++++++++++++++
 tools/libs/light/libxl_9pfs.c        | 16 ++++++++++++++++
 3 files changed, 38 insertions(+)

diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c
index 140ed610ae..1683438c5c 100644
--- a/tools/helpers/init-xenstore-domain.c
+++ b/tools/helpers/init-xenstore-domain.c
@@ -433,6 +433,12 @@ int main(int argc, char** argv)
     int rv, fd;
     char *maxmem_str = NULL;
     libxl_ctx *ctx;
+    libxl_device_p9 p9 = { .backend_domid = 0,
+                           .tag = "Xen",
+                           .path = XEN_LIB_DIR"/xenstore",
+                           .security_model = "none",
+                           .type = LIBXL_P9_TYPE_XEN_9PFSD,
+    };
 
     while ( (opt = getopt_long(argc, argv, "v", options, NULL)) != -1 )
     {
@@ -543,6 +549,7 @@ int main(int argc, char** argv)
     }
     libxl_console_add_xenstore(ctx, domid, 0, console_evtchn, console_gfn,
                                NULL);
+    libxl_device_9pfs_add(ctx, domid, &p9, NULL);
     libxl_ctx_free(ctx);
 
     fd = creat(XEN_RUN_DIR "/xenstored.pid", 0666);
diff --git a/tools/include/libxl.h b/tools/include/libxl.h
index f36c613b7d..62cb07dea6 100644
--- a/tools/include/libxl.h
+++ b/tools/include/libxl.h
@@ -590,6 +590,13 @@
  * libxl_console_add_xenstore() in libxl.
  */
 #define LIBXL_HAVE_CONSOLE_ADD_XENSTORE 1
+
+/*
+ * LIBXL_HAVE_P9_ADD indicates presence of the function
+ * libxl_device_9pfs_add() in libxl.
+ */
+#define LIBXL_HAVE_P9_ADD 1
+
 /*
  * libxl ABI compatibility
  *
@@ -2081,6 +2088,14 @@ int libxl_console_add_xenstore(libxl_ctx *ctx, uint32_t domid, uint32_t backend,
                                const libxl_asyncop_how *ao_how)
                                LIBXL_EXTERNAL_CALLERS_ONLY;
 
+/* libxl_device_9pfs_add writes the Xenstore entries for a domain's
+ * primary 9pfs device based on domid, and device parameters.
+ * If needed it will start the backend daemon.
+ */
+int libxl_device_9pfs_add(libxl_ctx *ctx, uint32_t domid, libxl_device_p9 *p9,
+                          const libxl_asyncop_how *ao_how)
+                          LIBXL_EXTERNAL_CALLERS_ONLY;
+
 /* May be called with info_r == NULL to check for domain's existence.
  * Returns ERROR_DOMAIN_NOTFOUND if domain does not exist (used to return
  * ERROR_INVAL for this scenario). */
diff --git a/tools/libs/light/libxl_9pfs.c b/tools/libs/light/libxl_9pfs.c
index ddeb4f20a7..48f894f070 100644
--- a/tools/libs/light/libxl_9pfs.c
+++ b/tools/libs/light/libxl_9pfs.c
@@ -206,6 +206,22 @@ static void libxl__device_p9_add(libxl__egc *egc, uint32_t domid,
         aodev->callback(egc, aodev);
 }
 
+int libxl_device_9pfs_add(libxl_ctx *ctx, uint32_t domid, libxl_device_p9 *p9,
+                          const libxl_asyncop_how *ao_how)
+{
+    AO_CREATE(ctx, domid, ao_how);
+    libxl__ao_device *aodev;
+
+    GCNEW(aodev);
+    libxl__prepare_ao_device(ao, aodev);
+    aodev->action = LIBXL__DEVICE_ACTION_ADD;
+    aodev->callback = device_addrm_aocomplete;
+
+    libxl__device_p9_add(egc, domid, p9, aodev);
+
+    return AO_INPROGRESS;
+}
+
 #define libxl_device_p9_list NULL
 #define libxl_device_p9_compare NULL
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 17:45:26 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 17:45:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684929.1065187 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZby-0000B6-IQ; Fri, 23 Feb 2024 17:45:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684929.1065187; Fri, 23 Feb 2024 17:45:26 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZby-0000Az-Fc; Fri, 23 Feb 2024 17:45:26 +0000
Received: by outflank-mailman (input) for mailman id 684929;
 Fri, 23 Feb 2024 17:45:25 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZbx-0000Ai-5z
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:25 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZbx-0007us-51
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:25 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZbx-0002BE-2S
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:25 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=qYpdOJnzwxxt+t3B10SzhzSG3hE4UHDFPJ7hLriofjg=; b=1BXXmlLBLa/j3nA10YjfsJnPxD
	O/E6wUdMKlZ6cx2xKyXLtSw7kT0mNy++qzZ4GmUyzZkf6PD3UwQtd9LbaP0AeecYZ0cVKTr8tcZed
	+h5sJj2iw1n78Jr+oengnPhFwa8PAKq2STM4n5S68QhW6y1mk8Cti9uBBDbubaGcd3kw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xenstored: mount 9pfs device in stubdom
Message-Id: <E1rdZbx-0002BE-2S@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 17:45:25 +0000

commit 297a2587e6b5ab2edbadce90cec0d5192625973c
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 16 17:31:36 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools/xenstored: mount 9pfs device in stubdom
    
    Mount the 9pfs device in stubdom enabling it to use files.
    
    This has to happen in a worker thread in order to allow the main thread
    handling the required Xenstore accesses in parallel.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstored/core.h   |  6 ++++++
 tools/xenstored/domain.c |  2 ++
 tools/xenstored/minios.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+)

diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index f6af086f01..fe0ee90581 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -36,6 +36,8 @@
 #include "list.h"
 #include "hashtable.h"
 
+#define XENSTORE_LIB_DIR	XEN_LIB_DIR "/xenstore"
+
 #ifndef O_CLOEXEC
 #define O_CLOEXEC 0
 /* O_CLOEXEC support is needed for Live Update in the daemon case. */
@@ -399,6 +401,10 @@ void handle_special_fds(void);
 int get_socket_fd(void);
 void set_socket_fd(int fd);
 
+#ifdef __MINIOS__
+void mount_9pfs(void);
+#endif
+
 /* Close stdin/stdout/stderr to complete daemonize */
 void finish_daemonize(void);
 
diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index 1a7d5e9756..64c8fd0cc3 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -1236,6 +1236,8 @@ void stubdom_init(void)
 		barf_perror("Failed to initialize stubdom");
 
 	xenevtchn_notify(xce_handle, stubdom->port);
+
+	mount_9pfs();
 #endif
 }
 
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index 22ac8defbd..562a9b4972 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -17,10 +17,20 @@
 */
 #include <sys/types.h>
 #include <sys/mman.h>
+#include <syslog.h>
+#include "talloc.h"
 #include "core.h"
 #include "utils.h"
 #include <xen/grant_table.h>
 #include <mini-os/lib.h>
+#include <mini-os/9pfront.h>
+#include <mini-os/sched.h>
+#include <mini-os/xenbus.h>
+#include <mini-os/xmalloc.h>
+
+#define P9_STATE_PATH	"device/9pfs/0/state"
+
+static void *p9_device;
 
 void finish_daemonize(void)
 {
@@ -74,3 +84,47 @@ int get_socket_fd(void)
 void set_socket_fd(int fd)
 {
 }
+
+static void mount_thread(void *p)
+{
+	xenbus_event_queue events = NULL;
+	char *err;
+	char *dummy;
+
+	err = xenbus_watch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs", &events);
+	if (err) {
+		log("error \"%s\" when setting watch on \"%s\"\n", err,
+		    P9_STATE_PATH);
+		free(err);
+		return;
+	}
+
+	for (;;) {
+		xenbus_wait_for_watch(&events);
+
+		/*
+		 * We only care for existence of the state node.
+		 * State changes are handled in init_9pfront().
+		 */
+		err = xenbus_read(XBT_NIL, P9_STATE_PATH, &dummy);
+		if (!err)
+			break;
+		free(err);
+	}
+
+	free(dummy);
+
+	err = xenbus_unwatch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs");
+	if (err) {
+		log("error \"%s\" when unwatching \"%s\", leaking watch\n",
+		    err, P9_STATE_PATH);
+		free(err);
+	}
+
+	p9_device = init_9pfront(0, XENSTORE_LIB_DIR);
+}
+
+void mount_9pfs(void)
+{
+	create_thread("mount-9pfs", mount_thread, NULL);
+}
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 17:45:36 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 17:45:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684930.1065193 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZc8-0000EF-LD; Fri, 23 Feb 2024 17:45:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684930.1065193; Fri, 23 Feb 2024 17:45:36 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZc8-0000E7-HG; Fri, 23 Feb 2024 17:45:36 +0000
Received: by outflank-mailman (input) for mailman id 684930;
 Fri, 23 Feb 2024 17:45:35 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZc7-0000Dr-8v
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:35 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZc7-0007uz-88
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:35 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZc7-0002Bu-7W
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:35 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=8nto6FTMqYODxkf0iuJTxQmze8KKPqbHVSz5EsuaAd4=; b=Na/zZyi05mPA5eRKmfTNOxCZ+Z
	mAi3EjZSApl2VIEKNLD76JF6AoRHUXyGKVg3N55OMIWBFdF41bthqAfl99ew22KaoxPlc1Y2vSfgd
	x04z0Al281AzWs1cf4IqlzCUQjQhjiMMorRGPNhTOanCZI3EQUoIcxq73ZqBlL5bEvag=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xenstored: add helpers for filename handling
Message-Id: <E1rdZc7-0002Bu-7W@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 17:45:35 +0000

commit 93892648ffaf78a682edef48ea2d108650b3b547
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 16 17:31:37 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools/xenstored: add helpers for filename handling
    
    Add some helpers for handling filenames which might need different
    implementations between stubdom and daemon environments:
    
    - expansion of relative filenames (those are not really defined today,
      just expand them to be relative to /var/lib/xen/xenstore)
    - expansion of xenstore_daemon_rundir() (used e.g. for saving the state
      file in case of live update - needs to be unchanged in the daemon
      case, but should result in /var/lib/xen/xenstore for stubdom)
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstored/core.c      | 15 +++++++++++++--
 tools/xenstored/core.h      |  5 ++++-
 tools/xenstored/lu_daemon.c |  4 ++--
 tools/xenstored/minios.c    |  5 +++++
 tools/xenstored/posix.c     |  8 +++++++-
 5 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index 48fc787ac1..bada1ad9a2 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -63,7 +63,7 @@ char **orig_argv;
 LIST_HEAD(connections);
 int tracefd = -1;
 bool keep_orphans = false;
-char *tracefile = NULL;
+const char *tracefile = NULL;
 static struct hashtable *nodes;
 unsigned int trace_flags = TRACE_OBJ | TRACE_IO;
 
@@ -137,6 +137,17 @@ void trace_destroy(const void *data, const char *type)
 		trace("obj: DESTROY %s %p\n", type, data);
 }
 
+/*
+ * Return an absolute filename.
+ * In case of a relative filename given as input, prepend XENSTORE_LIB_DIR.
+ */
+const char *absolute_filename(const void *ctx, const char *filename)
+{
+	if (filename[0] != '/')
+		return talloc_asprintf(ctx, XENSTORE_LIB_DIR "/%s", filename);
+	return talloc_strdup(ctx, filename);
+}
+
 void close_log(void)
 {
 	if (tracefd >= 0)
@@ -2759,7 +2770,7 @@ int main(int argc, char *argv[])
 #endif
 
 	if (tracefile)
-		tracefile = talloc_strdup(NULL, tracefile);
+		tracefile = absolute_filename(NULL, tracefile);
 
 #ifndef NO_LIVE_UPDATE
 	/* Read state in case of live update. */
diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index fe0ee90581..e58779e88c 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -341,7 +341,7 @@ void close_log(void);
 extern int orig_argc;
 extern char **orig_argv;
 
-extern char *tracefile;
+extern const char *tracefile;
 extern int tracefd;
 
 /* Trace flag values must be kept in sync with trace_switches[] contents. */
@@ -405,6 +405,9 @@ void set_socket_fd(int fd);
 void mount_9pfs(void);
 #endif
 
+const char *xenstore_rundir(void);
+const char *absolute_filename(const void *ctx, const char *filename);
+
 /* Close stdin/stdout/stderr to complete daemonize */
 void finish_daemonize(void);
 
diff --git a/tools/xenstored/lu_daemon.c b/tools/xenstored/lu_daemon.c
index 71bcabadd3..6351111ab0 100644
--- a/tools/xenstored/lu_daemon.c
+++ b/tools/xenstored/lu_daemon.c
@@ -24,7 +24,7 @@ void lu_get_dump_state(struct lu_dump_state *state)
 	state->size = 0;
 
 	state->filename = talloc_asprintf(NULL, "%s/state_dump",
-					  xenstore_daemon_rundir());
+					  xenstore_rundir());
 	if (!state->filename)
 		barf("Allocation failure");
 
@@ -65,7 +65,7 @@ FILE *lu_dump_open(const void *ctx)
 	int fd;
 
 	filename = talloc_asprintf(ctx, "%s/state_dump",
-				   xenstore_daemon_rundir());
+				   xenstore_rundir());
 	if (!filename)
 		return NULL;
 
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index 562a9b4972..e70386f8c7 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -128,3 +128,8 @@ void mount_9pfs(void)
 {
 	create_thread("mount-9pfs", mount_thread, NULL);
 }
+
+const char *xenstore_rundir(void)
+{
+	return XENSTORE_LIB_DIR;
+}
diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c
index 496329dfd1..d88c82d972 100644
--- a/tools/xenstored/posix.c
+++ b/tools/xenstored/posix.c
@@ -326,9 +326,10 @@ void early_init(bool live_update, bool dofork, const char *pidfile)
 {
 	reopen_log();
 
-	/* Make sure xenstored directory exists. */
+	/* Make sure xenstored directories exist. */
 	/* Errors ignored here, will be reported when we open files */
 	mkdir(xenstore_daemon_rundir(), 0755);
+	mkdir(XENSTORE_LIB_DIR, 0755);
 
 	if (dofork) {
 		openlog("xenstored", 0, LOG_DAEMON);
@@ -406,3 +407,8 @@ void set_socket_fd(int fd)
 {
 	sock = fd;
 }
+
+const char *xenstore_rundir(void)
+{
+	return xenstore_daemon_rundir();
+}
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 17:45:46 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 17:45:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684931.1065196 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZcI-0000Hn-Nb; Fri, 23 Feb 2024 17:45:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684931.1065196; Fri, 23 Feb 2024 17:45:46 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZcI-0000He-Ki; Fri, 23 Feb 2024 17:45:46 +0000
Received: by outflank-mailman (input) for mailman id 684931;
 Fri, 23 Feb 2024 17:45:45 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZcH-0000HN-Bn
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:45 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZcH-0007v9-At
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:45 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZcH-0002CN-AH
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:45 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=W0YZonuF9FjHjxpomEclIbORsI5ByYBB/1KHA+jxQFE=; b=QBPx9DT81QyZR/kq1WGbp05zZD
	/dPaiBPOCQlLZdTBLBeWzAIYA1UKlYSIXigF48Kj3zgfD0jT3plMODQex6DkxFJXIcJf3DU2WDfx7
	XhSxs6AdZlKqT8cg1bQ0K2cQtGG10vhLvRW3X9084dHClfM55GTV83nyvtILZqREjwtI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xenstored: support complete log capabilities in stubdom
Message-Id: <E1rdZcH-0002CN-AH@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 17:45:45 +0000

commit a76f8809f10f1764d4627844461906dac93e68df
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 16 17:31:38 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools/xenstored: support complete log capabilities in stubdom
    
    With 9pfs being fully available in Xenstore-stubdom now, there is no
    reason to not fully support all logging capabilities in stubdom.
    
    Open the logfile on stubdom only after the 9pfs file system has been
    mounted.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/hotplug/Linux/init.d/sysconfig.xencommons.in |  1 -
 tools/hotplug/Linux/launch-xenstore.in             |  1 +
 tools/xenstored/control.c                          | 30 +++++++++++-----------
 tools/xenstored/minios.c                           |  3 +++
 4 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
index 433e4849af..1bdd830d8a 100644
--- a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
+++ b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
@@ -58,7 +58,6 @@ XENSTORED_ARGS=
 ## Default: Not defined, tracing off
 #
 # Log xenstored messages
-# Only evaluated if XENSTORETYPE is "daemon".
 #XENSTORED_TRACE=[yes|on|1]
 
 ## Type: integer
diff --git a/tools/hotplug/Linux/launch-xenstore.in b/tools/hotplug/Linux/launch-xenstore.in
index e854ca1eb8..da4eeca7c5 100644
--- a/tools/hotplug/Linux/launch-xenstore.in
+++ b/tools/hotplug/Linux/launch-xenstore.in
@@ -98,6 +98,7 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF
 	[ -z "$XENSTORE_DOMAIN_SIZE" ] && XENSTORE_DOMAIN_SIZE=8
 	XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS --memory $XENSTORE_DOMAIN_SIZE"
 	[ -z "$XENSTORE_MAX_DOMAIN_SIZE" ] || XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS --maxmem $XENSTORE_MAX_DOMAIN_SIZE"
+	[ -z "$XENSTORED_TRACE" ] || XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS -T xenstored-trace.log"
 
 	echo -n Starting $XENSTORE_DOMAIN_KERNEL...
 	${LIBEXEC_BIN}/init-xenstore-domain $XENSTORE_DOMAIN_ARGS || exit 1
diff --git a/tools/xenstored/control.c b/tools/xenstored/control.c
index b2f64d674f..dae23a5ac0 100644
--- a/tools/xenstored/control.c
+++ b/tools/xenstored/control.c
@@ -201,19 +201,6 @@ static int do_control_quota_s(const void *ctx, struct connection *conn,
 	return EINVAL;
 }
 
-#ifdef __MINIOS__
-static int do_control_memreport(const void *ctx, struct connection *conn,
-				const char **vec, int num)
-{
-	if (num)
-		return EINVAL;
-
-	talloc_report_full(NULL, stdout);
-
-	send_ack(conn, XS_CONTROL);
-	return 0;
-}
-#else
 static int do_control_logfile(const void *ctx, struct connection *conn,
 			      const char **vec, int num)
 {
@@ -222,13 +209,26 @@ static int do_control_logfile(const void *ctx, struct connection *conn,
 
 	close_log();
 	talloc_free(tracefile);
-	tracefile = talloc_strdup(NULL, vec[0]);
+	tracefile = absolute_filename(NULL, vec[0]);
 	reopen_log();
 
 	send_ack(conn, XS_CONTROL);
 	return 0;
 }
 
+#ifdef __MINIOS__
+static int do_control_memreport(const void *ctx, struct connection *conn,
+				const char **vec, int num)
+{
+	if (num)
+		return EINVAL;
+
+	talloc_report_full(NULL, stdout);
+
+	send_ack(conn, XS_CONTROL);
+	return 0;
+}
+#else
 static int do_control_memreport(const void *ctx, struct connection *conn,
 				const char **vec, int num)
 {
@@ -309,10 +309,10 @@ static struct cmd_s cmds[] = {
 		"[-c <cmdline>] [-F] [-t <timeout>] <file>\n"
 		"    Default timeout is 60 seconds.", 5 },
 #endif
+	{ "logfile", do_control_logfile, "<file>" },
 #ifdef __MINIOS__
 	{ "memreport", do_control_memreport, "" },
 #else
-	{ "logfile", do_control_logfile, "<file>" },
 	{ "memreport", do_control_memreport, "[<file>]" },
 #endif
 	{ "print", do_control_print, "<string>" },
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index e70386f8c7..a229954cf4 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -122,6 +122,9 @@ static void mount_thread(void *p)
 	}
 
 	p9_device = init_9pfront(0, XENSTORE_LIB_DIR);
+
+	/* Start logging if selected. */
+	reopen_log();
 }
 
 void mount_9pfs(void)
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 17:45:56 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 17:45:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684933.1065200 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZcS-0000Kz-PG; Fri, 23 Feb 2024 17:45:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684933.1065200; Fri, 23 Feb 2024 17:45:56 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdZcS-0000Kn-ML; Fri, 23 Feb 2024 17:45:56 +0000
Received: by outflank-mailman (input) for mailman id 684933;
 Fri, 23 Feb 2024 17:45:55 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZcR-0000Kf-EO
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:55 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZcR-0007vI-De
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:55 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdZcR-0002D0-Cx
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 17:45:55 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Zvd3qKF02vcseUhCSt1XHMpBeVVb+accManKEzBgBvQ=; b=uTDUu22xIzIIRzmIQSuYlZIsay
	MhhSFzLgrnZuDYs9a2+I7ySW17R2zEbJGxSb6ekX9gcRrKYRZoQ9BnjK+io9nDAlHSc13lvzq7IBP
	j4T7+RaIFmnKfatjwGjdqmLuiNTh89vcKvJarNhalY441rw/uJl+q6ZHNCNfv+WsLM44=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xenstored: have a single do_control_memreport()
Message-Id: <E1rdZcR-0002D0-Cx@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 17:45:55 +0000

commit f5e1c527d0a0d09ca0cb1dcd8d4ab4a1a5261e91
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 16 17:31:39 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools/xenstored: have a single do_control_memreport()
    
    With 9pfs now available in Xenstore-stubdom, there is no reason to
    have distinct do_control_memreport() variants for the daemon and the
    stubdom implementations.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/xenstored/control.c | 27 +++++++--------------------
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/tools/xenstored/control.c b/tools/xenstored/control.c
index dae23a5ac0..9561289179 100644
--- a/tools/xenstored/control.c
+++ b/tools/xenstored/control.c
@@ -216,23 +216,11 @@ static int do_control_logfile(const void *ctx, struct connection *conn,
 	return 0;
 }
 
-#ifdef __MINIOS__
-static int do_control_memreport(const void *ctx, struct connection *conn,
-				const char **vec, int num)
-{
-	if (num)
-		return EINVAL;
-
-	talloc_report_full(NULL, stdout);
-
-	send_ack(conn, XS_CONTROL);
-	return 0;
-}
-#else
 static int do_control_memreport(const void *ctx, struct connection *conn,
 				const char **vec, int num)
 {
 	FILE *fp;
+	const char *filename;
 	int fd;
 
 	if (num > 1)
@@ -255,8 +243,12 @@ static int do_control_memreport(const void *ctx, struct connection *conn,
 			if (!fp)
 				close(fd);
 		}
-	} else
-		fp = fopen(vec[0], "a");
+	} else {
+		filename = absolute_filename(ctx, vec[0]);
+		if (!filename)
+			return ENOMEM;
+		fp = fopen(filename, "a");
+	}
 
 	if (!fp)
 		return EBADF;
@@ -267,7 +259,6 @@ static int do_control_memreport(const void *ctx, struct connection *conn,
 	send_ack(conn, XS_CONTROL);
 	return 0;
 }
-#endif
 
 static int do_control_print(const void *ctx, struct connection *conn,
 			    const char **vec, int num)
@@ -310,11 +301,7 @@ static struct cmd_s cmds[] = {
 		"    Default timeout is 60 seconds.", 5 },
 #endif
 	{ "logfile", do_control_logfile, "<file>" },
-#ifdef __MINIOS__
-	{ "memreport", do_control_memreport, "" },
-#else
 	{ "memreport", do_control_memreport, "[<file>]" },
-#endif
 	{ "print", do_control_print, "<string>" },
 	{ "quota", do_control_quota,
 		"[set <name> <val>|<domid>|max [-r]]" },
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri Feb 23 18:55:16 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 23 Feb 2024 18:55:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.684934.1065204 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdahN-0007kS-JA; Fri, 23 Feb 2024 18:55:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 684934.1065204; Fri, 23 Feb 2024 18:55:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rdahN-0007kK-Fx; Fri, 23 Feb 2024 18:55:05 +0000
Received: by outflank-mailman (input) for mailman id 684934;
 Fri, 23 Feb 2024 18:55:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdahM-0007kE-CI
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 18:55:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdahM-0000sd-8Z
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 18:55:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rdahM-0000U4-5c
 for xen-changelog@lists.xenproject.org; Fri, 23 Feb 2024 18:55:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=KNpZhDU8MbwVhVcyYAAVnBD4NpX+DBjxgNbfyGZcahA=; b=KAMyue5wnVBWQVSciHMAif8UHg
	RnF+V2ziDptfqZIF/0HbOJsOWpTVntX9P0xT7XrWp62PqdO0H4HVhl3q0q8UgkoCUV4PoITpea/zy
	pBFh9F9o8DFJjSLOXkbAkIjY5jX38OUk3YNi2rv4TVBQNZqJoHWtl/1M+zkX8z3DQxZg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] Revert stubdom+xenstore 9pfs changes
Message-Id: <E1rdahM-0000U4-5c@xenbits.xenproject.org>
Date: Fri, 23 Feb 2024 18:55:04 +0000

commit 92babc88f67ed0ef3dc575a8b9534040274678ee
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Feb 23 18:49:33 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 18:51:10 2024 +0000

    Revert stubdom+xenstore 9pfs changes
    
    to unblock CI.  It turns out there are still issues in some configurations.
    
    https://gitlab.com/xen-project/xen/-/pipelines/1188660609
    
    This reverts commit f5e1c527d0a0d09ca0cb1dcd8d4ab4a1a5261e91.
    This reverts commit a76f8809f10f1764d4627844461906dac93e68df.
    This reverts commit 93892648ffaf78a682edef48ea2d108650b3b547.
    This reverts commit 297a2587e6b5ab2edbadce90cec0d5192625973c.
    This reverts commit 0b761781c4de2e6637203d0f51273a5a1f8873df.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 stubdom/xenstore-minios.cfg                        |  2 +-
 stubdom/xenstorepvh-minios.cfg                     |  2 +-
 tools/hotplug/Linux/init.d/sysconfig.xencommons.in |  1 +
 tools/hotplug/Linux/launch-xenstore.in             |  1 -
 tools/xenstored/control.c                          | 29 +++++++---
 tools/xenstored/core.c                             | 15 +-----
 tools/xenstored/core.h                             | 11 +---
 tools/xenstored/domain.c                           |  2 -
 tools/xenstored/lu_daemon.c                        |  4 +-
 tools/xenstored/minios.c                           | 62 ----------------------
 tools/xenstored/posix.c                            |  8 +--
 11 files changed, 30 insertions(+), 107 deletions(-)

diff --git a/stubdom/xenstore-minios.cfg b/stubdom/xenstore-minios.cfg
index 239da519b9..a41704bb6b 100644
--- a/stubdom/xenstore-minios.cfg
+++ b/stubdom/xenstore-minios.cfg
@@ -3,7 +3,7 @@ CONFIG_NETFRONT=n
 CONFIG_FBFRONT=n
 CONFIG_KBDFRONT=n
 CONFIG_CONSFRONT=n
+CONFIG_XENBUS=n
 CONFIG_LWIP=n
-CONFIG_9PFRONT=y
 CONFIG_BALLOON=y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
diff --git a/stubdom/xenstorepvh-minios.cfg b/stubdom/xenstorepvh-minios.cfg
index 752b90d7d3..6af51f5753 100644
--- a/stubdom/xenstorepvh-minios.cfg
+++ b/stubdom/xenstorepvh-minios.cfg
@@ -4,7 +4,7 @@ CONFIG_NETFRONT=n
 CONFIG_FBFRONT=n
 CONFIG_KBDFRONT=n
 CONFIG_CONSFRONT=n
+CONFIG_XENBUS=n
 CONFIG_LWIP=n
-CONFIG_9PFRONT=y
 CONFIG_BALLOON=y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
diff --git a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
index 1bdd830d8a..433e4849af 100644
--- a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
+++ b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
@@ -58,6 +58,7 @@ XENSTORED_ARGS=
 ## Default: Not defined, tracing off
 #
 # Log xenstored messages
+# Only evaluated if XENSTORETYPE is "daemon".
 #XENSTORED_TRACE=[yes|on|1]
 
 ## Type: integer
diff --git a/tools/hotplug/Linux/launch-xenstore.in b/tools/hotplug/Linux/launch-xenstore.in
index da4eeca7c5..e854ca1eb8 100644
--- a/tools/hotplug/Linux/launch-xenstore.in
+++ b/tools/hotplug/Linux/launch-xenstore.in
@@ -98,7 +98,6 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF
 	[ -z "$XENSTORE_DOMAIN_SIZE" ] && XENSTORE_DOMAIN_SIZE=8
 	XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS --memory $XENSTORE_DOMAIN_SIZE"
 	[ -z "$XENSTORE_MAX_DOMAIN_SIZE" ] || XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS --maxmem $XENSTORE_MAX_DOMAIN_SIZE"
-	[ -z "$XENSTORED_TRACE" ] || XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS -T xenstored-trace.log"
 
 	echo -n Starting $XENSTORE_DOMAIN_KERNEL...
 	${LIBEXEC_BIN}/init-xenstore-domain $XENSTORE_DOMAIN_ARGS || exit 1
diff --git a/tools/xenstored/control.c b/tools/xenstored/control.c
index 9561289179..b2f64d674f 100644
--- a/tools/xenstored/control.c
+++ b/tools/xenstored/control.c
@@ -201,6 +201,19 @@ static int do_control_quota_s(const void *ctx, struct connection *conn,
 	return EINVAL;
 }
 
+#ifdef __MINIOS__
+static int do_control_memreport(const void *ctx, struct connection *conn,
+				const char **vec, int num)
+{
+	if (num)
+		return EINVAL;
+
+	talloc_report_full(NULL, stdout);
+
+	send_ack(conn, XS_CONTROL);
+	return 0;
+}
+#else
 static int do_control_logfile(const void *ctx, struct connection *conn,
 			      const char **vec, int num)
 {
@@ -209,7 +222,7 @@ static int do_control_logfile(const void *ctx, struct connection *conn,
 
 	close_log();
 	talloc_free(tracefile);
-	tracefile = absolute_filename(NULL, vec[0]);
+	tracefile = talloc_strdup(NULL, vec[0]);
 	reopen_log();
 
 	send_ack(conn, XS_CONTROL);
@@ -220,7 +233,6 @@ static int do_control_memreport(const void *ctx, struct connection *conn,
 				const char **vec, int num)
 {
 	FILE *fp;
-	const char *filename;
 	int fd;
 
 	if (num > 1)
@@ -243,12 +255,8 @@ static int do_control_memreport(const void *ctx, struct connection *conn,
 			if (!fp)
 				close(fd);
 		}
-	} else {
-		filename = absolute_filename(ctx, vec[0]);
-		if (!filename)
-			return ENOMEM;
-		fp = fopen(filename, "a");
-	}
+	} else
+		fp = fopen(vec[0], "a");
 
 	if (!fp)
 		return EBADF;
@@ -259,6 +267,7 @@ static int do_control_memreport(const void *ctx, struct connection *conn,
 	send_ack(conn, XS_CONTROL);
 	return 0;
 }
+#endif
 
 static int do_control_print(const void *ctx, struct connection *conn,
 			    const char **vec, int num)
@@ -300,8 +309,12 @@ static struct cmd_s cmds[] = {
 		"[-c <cmdline>] [-F] [-t <timeout>] <file>\n"
 		"    Default timeout is 60 seconds.", 5 },
 #endif
+#ifdef __MINIOS__
+	{ "memreport", do_control_memreport, "" },
+#else
 	{ "logfile", do_control_logfile, "<file>" },
 	{ "memreport", do_control_memreport, "[<file>]" },
+#endif
 	{ "print", do_control_print, "<string>" },
 	{ "quota", do_control_quota,
 		"[set <name> <val>|<domid>|max [-r]]" },
diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index bada1ad9a2..48fc787ac1 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -63,7 +63,7 @@ char **orig_argv;
 LIST_HEAD(connections);
 int tracefd = -1;
 bool keep_orphans = false;
-const char *tracefile = NULL;
+char *tracefile = NULL;
 static struct hashtable *nodes;
 unsigned int trace_flags = TRACE_OBJ | TRACE_IO;
 
@@ -137,17 +137,6 @@ void trace_destroy(const void *data, const char *type)
 		trace("obj: DESTROY %s %p\n", type, data);
 }
 
-/*
- * Return an absolute filename.
- * In case of a relative filename given as input, prepend XENSTORE_LIB_DIR.
- */
-const char *absolute_filename(const void *ctx, const char *filename)
-{
-	if (filename[0] != '/')
-		return talloc_asprintf(ctx, XENSTORE_LIB_DIR "/%s", filename);
-	return talloc_strdup(ctx, filename);
-}
-
 void close_log(void)
 {
 	if (tracefd >= 0)
@@ -2770,7 +2759,7 @@ int main(int argc, char *argv[])
 #endif
 
 	if (tracefile)
-		tracefile = absolute_filename(NULL, tracefile);
+		tracefile = talloc_strdup(NULL, tracefile);
 
 #ifndef NO_LIVE_UPDATE
 	/* Read state in case of live update. */
diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index e58779e88c..f6af086f01 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -36,8 +36,6 @@
 #include "list.h"
 #include "hashtable.h"
 
-#define XENSTORE_LIB_DIR	XEN_LIB_DIR "/xenstore"
-
 #ifndef O_CLOEXEC
 #define O_CLOEXEC 0
 /* O_CLOEXEC support is needed for Live Update in the daemon case. */
@@ -341,7 +339,7 @@ void close_log(void);
 extern int orig_argc;
 extern char **orig_argv;
 
-extern const char *tracefile;
+extern char *tracefile;
 extern int tracefd;
 
 /* Trace flag values must be kept in sync with trace_switches[] contents. */
@@ -401,13 +399,6 @@ void handle_special_fds(void);
 int get_socket_fd(void);
 void set_socket_fd(int fd);
 
-#ifdef __MINIOS__
-void mount_9pfs(void);
-#endif
-
-const char *xenstore_rundir(void);
-const char *absolute_filename(const void *ctx, const char *filename);
-
 /* Close stdin/stdout/stderr to complete daemonize */
 void finish_daemonize(void);
 
diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index 64c8fd0cc3..1a7d5e9756 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -1236,8 +1236,6 @@ void stubdom_init(void)
 		barf_perror("Failed to initialize stubdom");
 
 	xenevtchn_notify(xce_handle, stubdom->port);
-
-	mount_9pfs();
 #endif
 }
 
diff --git a/tools/xenstored/lu_daemon.c b/tools/xenstored/lu_daemon.c
index 6351111ab0..71bcabadd3 100644
--- a/tools/xenstored/lu_daemon.c
+++ b/tools/xenstored/lu_daemon.c
@@ -24,7 +24,7 @@ void lu_get_dump_state(struct lu_dump_state *state)
 	state->size = 0;
 
 	state->filename = talloc_asprintf(NULL, "%s/state_dump",
-					  xenstore_rundir());
+					  xenstore_daemon_rundir());
 	if (!state->filename)
 		barf("Allocation failure");
 
@@ -65,7 +65,7 @@ FILE *lu_dump_open(const void *ctx)
 	int fd;
 
 	filename = talloc_asprintf(ctx, "%s/state_dump",
-				   xenstore_rundir());
+				   xenstore_daemon_rundir());
 	if (!filename)
 		return NULL;
 
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index a229954cf4..22ac8defbd 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -17,20 +17,10 @@
 */
 #include <sys/types.h>
 #include <sys/mman.h>
-#include <syslog.h>
-#include "talloc.h"
 #include "core.h"
 #include "utils.h"
 #include <xen/grant_table.h>
 #include <mini-os/lib.h>
-#include <mini-os/9pfront.h>
-#include <mini-os/sched.h>
-#include <mini-os/xenbus.h>
-#include <mini-os/xmalloc.h>
-
-#define P9_STATE_PATH	"device/9pfs/0/state"
-
-static void *p9_device;
 
 void finish_daemonize(void)
 {
@@ -84,55 +74,3 @@ int get_socket_fd(void)
 void set_socket_fd(int fd)
 {
 }
-
-static void mount_thread(void *p)
-{
-	xenbus_event_queue events = NULL;
-	char *err;
-	char *dummy;
-
-	err = xenbus_watch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs", &events);
-	if (err) {
-		log("error \"%s\" when setting watch on \"%s\"\n", err,
-		    P9_STATE_PATH);
-		free(err);
-		return;
-	}
-
-	for (;;) {
-		xenbus_wait_for_watch(&events);
-
-		/*
-		 * We only care for existence of the state node.
-		 * State changes are handled in init_9pfront().
-		 */
-		err = xenbus_read(XBT_NIL, P9_STATE_PATH, &dummy);
-		if (!err)
-			break;
-		free(err);
-	}
-
-	free(dummy);
-
-	err = xenbus_unwatch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs");
-	if (err) {
-		log("error \"%s\" when unwatching \"%s\", leaking watch\n",
-		    err, P9_STATE_PATH);
-		free(err);
-	}
-
-	p9_device = init_9pfront(0, XENSTORE_LIB_DIR);
-
-	/* Start logging if selected. */
-	reopen_log();
-}
-
-void mount_9pfs(void)
-{
-	create_thread("mount-9pfs", mount_thread, NULL);
-}
-
-const char *xenstore_rundir(void)
-{
-	return XENSTORE_LIB_DIR;
-}
diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c
index d88c82d972..496329dfd1 100644
--- a/tools/xenstored/posix.c
+++ b/tools/xenstored/posix.c
@@ -326,10 +326,9 @@ void early_init(bool live_update, bool dofork, const char *pidfile)
 {
 	reopen_log();
 
-	/* Make sure xenstored directories exist. */
+	/* Make sure xenstored directory exists. */
 	/* Errors ignored here, will be reported when we open files */
 	mkdir(xenstore_daemon_rundir(), 0755);
-	mkdir(XENSTORE_LIB_DIR, 0755);
 
 	if (dofork) {
 		openlog("xenstored", 0, LOG_DAEMON);
@@ -407,8 +406,3 @@ void set_socket_fd(int fd)
 {
 	sock = fd;
 }
-
-const char *xenstore_rundir(void)
-{
-	return xenstore_daemon_rundir();
-}
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Sat Feb 24 23:44:11 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 24 Feb 2024 23:44:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685135.1065507 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1ga-0006Qc-09; Sat, 24 Feb 2024 23:44:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685135.1065507; Sat, 24 Feb 2024 23:44:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1gZ-0006QU-TU; Sat, 24 Feb 2024 23:44:03 +0000
Received: by outflank-mailman (input) for mailman id 685135;
 Sat, 24 Feb 2024 23:44:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1gY-0006QM-KH
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1gY-0000vC-If
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1gY-00085y-Fr
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=dk2ukBgm643XiUwXeXRypFDMhdNFPVA2T1aBVuw6Z+A=; b=U5UHnoSS4ZFoXovZsRHaQCMPRh
	JgKqq2Dvn3KBRRDhWya8DQNiBDQdDFxH9ex9KpaAWjrvvDZjLb7lV1hUhkxV3rWmc7DczPIU0n3M9
	X+7gTtIfLB4MQLI8ddF+rnQDgsIj6VCqdeE+T1E4ooS1aW7dUMWIDS4k91V/IryyRO20=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/*/asm-offset: Fix bad copy&paste from x86
Message-Id: <E1re1gY-00085y-Fr@xenbits.xenproject.org>
Date: Sat, 24 Feb 2024 23:44:02 +0000

commit 98e79be5b60ac5f4fbcb064a9e11c30024929ff1
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon Jan 29 11:39:32 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    xen/*/asm-offset: Fix bad copy&paste from x86
    
    All architectures have copy&pasted bad logic from x86.
    
    OFFSET() having a trailing semi-colon within the macro expansion can be a
    problematic pattern.  It's benign in this case, but fix it anyway.
    
    Perform style fixes for the other macros, and tame the mess of BLANK()
    position to be consistent (one BLANK() after each block) so the intermediate
    form is legible too.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Shawn Anastasio <sanastasio@raptorengineering.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/arm32/asm-offsets.c     | 15 ++++++++-------
 xen/arch/arm/arm64/asm-offsets.c     | 14 ++++++++------
 xen/arch/ppc/ppc64/asm-offsets.c     |  9 ++++++---
 xen/arch/riscv/riscv64/asm-offsets.c | 10 +++++-----
 xen/arch/x86/x86_64/asm-offsets.c    |  9 +++++----
 5 files changed, 32 insertions(+), 25 deletions(-)

diff --git a/xen/arch/arm/arm32/asm-offsets.c b/xen/arch/arm/arm32/asm-offsets.c
index 05c692bb28..8bbb0f938e 100644
--- a/xen/arch/arm/arm32/asm-offsets.c
+++ b/xen/arch/arm/arm32/asm-offsets.c
@@ -14,12 +14,12 @@
 #include <asm/setup.h>
 
 #define DEFINE(_sym, _val)                                                 \
-    asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \
-                  : : "i" (_val) )
+    asm volatile ( "\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\""\
+                   :: "i" (_val) )
 #define BLANK()                                                            \
-    asm volatile ( "\n.ascii\"==><==\"" : : )
+    asm volatile ( "\n.ascii\"==><==\"" )
 #define OFFSET(_sym, _str, _mem)                                           \
-    DEFINE(_sym, offsetof(_str, _mem));
+    DEFINE(_sym, offsetof(_str, _mem))
 
 void __dummy__(void)
 {
@@ -62,18 +62,19 @@ void __dummy__(void)
    BLANK();
 
    DEFINE(CPUINFO_sizeof, sizeof(struct cpu_info));
+   BLANK();
 
    OFFSET(VCPU_arch_saved_context, struct vcpu, arch.saved_context);
-
    BLANK();
+
    DEFINE(PROCINFO_sizeof, sizeof(struct proc_info_list));
    OFFSET(PROCINFO_cpu_val, struct proc_info_list, cpu_val);
    OFFSET(PROCINFO_cpu_mask, struct proc_info_list, cpu_mask);
    OFFSET(PROCINFO_cpu_init, struct proc_info_list, cpu_init);
-
    BLANK();
-   OFFSET(INITINFO_stack, struct init_info, stack);
 
+   OFFSET(INITINFO_stack, struct init_info, stack);
+   BLANK();
 }
 
 /*
diff --git a/xen/arch/arm/arm64/asm-offsets.c b/xen/arch/arm/arm64/asm-offsets.c
index 7adb67a1b8..602ffa5b54 100644
--- a/xen/arch/arm/arm64/asm-offsets.c
+++ b/xen/arch/arm/arm64/asm-offsets.c
@@ -14,12 +14,12 @@
 #include <asm/smccc.h>
 
 #define DEFINE(_sym, _val)                                                 \
-    asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \
-                  : : "i" (_val) )
+    asm volatile ( "\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\""\
+                   :: "i" (_val) )
 #define BLANK()                                                            \
-    asm volatile ( "\n.ascii\"==><==\"" : : )
+    asm volatile ( "\n.ascii\"==><==\"" )
 #define OFFSET(_sym, _str, _mem)                                           \
-    DEFINE(_sym, offsetof(_str, _mem));
+    DEFINE(_sym, offsetof(_str, _mem))
 
 void __dummy__(void)
 {
@@ -48,13 +48,14 @@ void __dummy__(void)
 
    DEFINE(CPUINFO_sizeof, sizeof(struct cpu_info));
    OFFSET(CPUINFO_flags, struct cpu_info, flags);
+   BLANK();
 
    OFFSET(VCPU_arch_saved_context, struct vcpu, arch.saved_context);
-
    BLANK();
-   OFFSET(INITINFO_stack, struct init_info, stack);
 
+   OFFSET(INITINFO_stack, struct init_info, stack);
    BLANK();
+
    OFFSET(SMCCC_RES_a0, struct arm_smccc_res, a0);
    OFFSET(SMCCC_RES_a2, struct arm_smccc_res, a2);
    OFFSET(ARM_SMCCC_1_2_REGS_X0_OFFS, struct arm_smccc_1_2_regs, a0);
@@ -66,6 +67,7 @@ void __dummy__(void)
    OFFSET(ARM_SMCCC_1_2_REGS_X12_OFFS, struct arm_smccc_1_2_regs, a12);
    OFFSET(ARM_SMCCC_1_2_REGS_X14_OFFS, struct arm_smccc_1_2_regs, a14);
    OFFSET(ARM_SMCCC_1_2_REGS_X16_OFFS, struct arm_smccc_1_2_regs, a16);
+   BLANK();
 }
 
 /*
diff --git a/xen/arch/ppc/ppc64/asm-offsets.c b/xen/arch/ppc/ppc64/asm-offsets.c
index 634d7260e3..b95865092f 100644
--- a/xen/arch/ppc/ppc64/asm-offsets.c
+++ b/xen/arch/ppc/ppc64/asm-offsets.c
@@ -10,11 +10,11 @@
 
 #define DEFINE(_sym, _val)                                                  \
     asm volatile ( "\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \
-                   : : "i" (_val) )
+                   :: "i" (_val) )
 #define BLANK()                                                             \
-    asm volatile ( "\n.ascii\"==><==\"" : : )
+    asm volatile ( "\n.ascii\"==><==\"" )
 #define OFFSET(_sym, _str, _mem)                                            \
-    DEFINE(_sym, offsetof(_str, _mem));
+    DEFINE(_sym, offsetof(_str, _mem))
 
 /* base-2 logarithm */
 #define __L2(_x)  (((_x) & 0x00000002) ?   1 : 0)
@@ -29,6 +29,7 @@ void __dummy__(void)
 
     DEFINE(GPR_WIDTH, sizeof(unsigned long));
     DEFINE(FPR_WIDTH, sizeof(double));
+    BLANK();
 
     OFFSET(UREGS_gprs, struct cpu_user_regs, gprs);
     OFFSET(UREGS_r0, struct cpu_user_regs, gprs[0]);
@@ -48,9 +49,11 @@ void __dummy__(void)
     OFFSET(UREGS_fpscr, struct cpu_user_regs, fpscr);
     OFFSET(UREGS_entry_vector, struct cpu_user_regs, entry_vector);
     DEFINE(UREGS_sizeof, sizeof(struct cpu_user_regs));
+    BLANK();
 
     OFFSET(OPAL_base, struct opal, base);
     OFFSET(OPAL_entry, struct opal, entry);
+    BLANK();
 }
 
 /*
diff --git a/xen/arch/riscv/riscv64/asm-offsets.c b/xen/arch/riscv/riscv64/asm-offsets.c
index d632b75c2a..9f663b9510 100644
--- a/xen/arch/riscv/riscv64/asm-offsets.c
+++ b/xen/arch/riscv/riscv64/asm-offsets.c
@@ -4,16 +4,15 @@
 #include <xen/types.h>
 
 #define DEFINE(_sym, _val)                                                 \
-    asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \
-                  : : "i" (_val) )
+    asm volatile ( "\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\""\
+                   :: "i" (_val) )
 #define BLANK()                                                            \
-    asm volatile ( "\n.ascii\"==><==\"" : : )
+    asm volatile ( "\n.ascii\"==><==\"" )
 #define OFFSET(_sym, _str, _mem)                                           \
-    DEFINE(_sym, offsetof(_str, _mem));
+    DEFINE(_sym, offsetof(_str, _mem))
 
 void asm_offsets(void)
 {
-    BLANK();
     DEFINE(CPU_USER_REGS_SIZE, sizeof(struct cpu_user_regs));
     OFFSET(CPU_USER_REGS_ZERO, struct cpu_user_regs, zero);
     OFFSET(CPU_USER_REGS_RA, struct cpu_user_regs, ra);
@@ -50,4 +49,5 @@ void asm_offsets(void)
     OFFSET(CPU_USER_REGS_SEPC, struct cpu_user_regs, sepc);
     OFFSET(CPU_USER_REGS_SSTATUS, struct cpu_user_regs, sstatus);
     OFFSET(CPU_USER_REGS_PREGS, struct cpu_user_regs, pregs);
+    BLANK();
 }
diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c
index f9546ec60b..fee0edc61a 100644
--- a/xen/arch/x86/x86_64/asm-offsets.c
+++ b/xen/arch/x86/x86_64/asm-offsets.c
@@ -17,12 +17,12 @@
 #include <xen/multiboot2.h>
 
 #define DEFINE(_sym, _val)                                                 \
-    asm volatile ("\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\"" \
-                  : : "i" (_val) )
+    asm volatile ( "\n.ascii\"==>#define " #_sym " %0 /* " #_val " */<==\""\
+                   :: "i" (_val) )
 #define BLANK()                                                            \
-    asm volatile ( "\n.ascii\"==><==\"" : : )
+    asm volatile ( "\n.ascii\"==><==\"" )
 #define OFFSET(_sym, _str, _mem)                                           \
-    DEFINE(_sym, offsetof(_str, _mem));
+    DEFINE(_sym, offsetof(_str, _mem))
 
 void __dummy__(void)
 {
@@ -180,4 +180,5 @@ void __dummy__(void)
     BLANK();
 
     OFFSET(DOMAIN_vm_assist, struct domain, vm_assist);
+    BLANK();
 }
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 24 23:44:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 24 Feb 2024 23:44:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685136.1065511 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1gk-0006T1-1X; Sat, 24 Feb 2024 23:44:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685136.1065511; Sat, 24 Feb 2024 23:44:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1gj-0006Su-Uz; Sat, 24 Feb 2024 23:44:13 +0000
Received: by outflank-mailman (input) for mailman id 685136;
 Sat, 24 Feb 2024 23:44:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1gi-0006Sk-Md
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1gi-0000vM-Lu
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1gi-00086u-Kx
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Ehl/35mfjyUtp/LAssNuCQCIWlclD95iie95U9piQoY=; b=mTsvSLGvnvXaz/oP58lZupnBvJ
	5mmDEW7viRuUxGJkIEBaKIqVBnfzCSizwPdtl66aXgXsI6XbWBnu47b1ayPMPhbCNI3C8jXdPTrIb
	QdLu1BKzO4tqhv+MGm1CwKKUwx3ureG+1+E0rWQZXJ4nkC7V3ABPkU3W/YUUwEUdAG5M=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/altp2m: p2m_altp2m_get_or_propagate() should honor ap2m->default_access
Message-Id: <E1re1gi-00086u-Kx@xenbits.xenproject.org>
Date: Sat, 24 Feb 2024 23:44:12 +0000

commit 7e5b662b289ac66ee347113f94c46c89d127e774
Author:     Petr Beneš <w1benny@gmail.com>
AuthorDate: Tue Feb 6 10:08:22 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    x86/altp2m: p2m_altp2m_get_or_propagate() should honor ap2m->default_access
    
    This patch addresses a behavior discrepancy in the handling of altp2m views,
    where upon the creation and subsequent EPT violation, the page access
    permissions were incorrectly inherited from the hostp2m instead of respecting
    the altp2m default_access.
    
    Previously, when a new altp2m view was established with restrictive
    default_access permissions and activated via xc_altp2m_switch_to_view(),
    it failed to trigger an event on the first access violation.  This behavior
    diverged from the intended mechanism, where the altp2m's default_access
    should dictate the initial permissions, ensuring proper event triggering on
    access violations.
    
    The correction involves modifying the handling mechanism to respect the
    altp2m view's default_access upon its activation, eliminating the need for
    setting memory access permissions for the entire altp2m range (e.g. within
    xen-access.c).  This change not only aligns the behavior with the expected
    access control logic but also results in a significant performance improvement
    by reducing the overhead associated with setting memory access permissions
    across the altp2m range.
    
    Signed-off-by: Petr Beneš <w1benny@gmail.com>
    Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
---
 tools/misc/xen-access.c | 14 --------------
 xen/arch/x86/mm/p2m.c   |  3 +++
 2 files changed, 3 insertions(+), 14 deletions(-)

diff --git a/tools/misc/xen-access.c b/tools/misc/xen-access.c
index 4097eebe6f..6cf3b6a42c 100644
--- a/tools/misc/xen-access.c
+++ b/tools/misc/xen-access.c
@@ -517,9 +517,6 @@ int main(int argc, char *argv[])
     /* With altp2m we just create a new, restricted view of the memory */
     if ( memaccess && altp2m )
     {
-        xen_pfn_t gfn = 0;
-        unsigned long perm_set = 0;
-
         if( altp2m_write_no_gpt )
         {
             rc = xc_monitor_inguest_pagefault(xch, domain_id, 1);
@@ -551,17 +548,6 @@ int main(int argc, char *argv[])
         }
 
         DPRINTF("altp2m view created with id %u\n", altp2m_view_id);
-        DPRINTF("Setting altp2m mem_access permissions.. ");
-
-        for(; gfn < xenaccess->max_gpfn; ++gfn)
-        {
-            rc = xc_altp2m_set_mem_access( xch, domain_id, altp2m_view_id, gfn,
-                                           default_access);
-            if ( !rc )
-                perm_set++;
-        }
-
-        DPRINTF("done! Permissions set on %lu pages.\n", perm_set);
 
         rc = xc_altp2m_switch_to_view( xch, domain_id, altp2m_view_id );
         if ( rc < 0 )
diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index d118d27ab9..4dd41193f5 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -1850,6 +1850,9 @@ bool p2m_altp2m_get_or_propagate(struct p2m_domain *ap2m, unsigned long gfn_l,
     amfn = _mfn(mfn_x(*mfn) & mask);
     gfn = _gfn(gfn_l & mask);
 
+    /* Override the altp2m entry with its default access. */
+    *p2ma = ap2m->default_access;
+
     rc = p2m_set_entry(ap2m, gfn, amfn, cur_order, *p2mt, *p2ma);
     p2m_unlock(ap2m);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 24 23:44:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 24 Feb 2024 23:44:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685137.1065515 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1gt-0006Vd-2q; Sat, 24 Feb 2024 23:44:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685137.1065515; Sat, 24 Feb 2024 23:44:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1gt-0006VV-0F; Sat, 24 Feb 2024 23:44:23 +0000
Received: by outflank-mailman (input) for mailman id 685137;
 Sat, 24 Feb 2024 23:44:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1gs-0006VP-Po
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1gs-0000xH-P5
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1gs-00087l-O3
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=5rwoKO1+EEkwOJDSWLz/I/d+lXcxoP8alTjzm2cNjLM=; b=PzT2IsaO5mpCa70XiZKlBV9DjW
	wVBDB2zD04Enz2O92RyPsFoG+vSlyXFTl3DrEg9+KEoXuzHt2beMfjXZ2bVGTmrAeuc/LuQKmHtdI
	b+d2rixEggByb29H6n9diDu3Fjez1y9l5pVFsrJhKHzzkZfKlimLVDxEaGHTXb/rv1Y0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/oxenstored: Use Map instead of Hashtbl for quotas
Message-Id: <E1re1gs-00087l-O3@xenbits.xenproject.org>
Date: Sat, 24 Feb 2024 23:44:22 +0000

commit b6cf604207fd0a04451a48f2ce6d05fb66c612ab
Author:     Edwin Török <edwin.torok@cloud.com>
AuthorDate: Wed Jan 31 10:52:55 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools/oxenstored: Use Map instead of Hashtbl for quotas
    
    On a stress test running 1000 VMs flamegraphs have shown that
    `oxenstored` spends a large amount of time in `Hashtbl.copy` and the GC.
    
    Hashtable complexity:
     * read/write: O(1) average
     * copy: O(domains) -- copying the entire table
    
    Map complexity:
     * read/write: O(log n) worst case
     * copy: O(1) -- a word copy
    
    We always perform at least one 'copy' when processing each xenstore
    packet (regardless whether it is a readonly operation or inside a
    transaction or not), so the actual complexity per packet is:
      * Hashtbl: O(domains)
      * Map: O(log domains)
    
    Maps are the clear winner, and a better fit for the immutable xenstore
    tree.
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    Acked-by: Christian Lindig <christian.lindig@cloud.com>
---
 tools/ocaml/xenstored/quota.ml | 65 ++++++++++++++++++++++--------------------
 1 file changed, 34 insertions(+), 31 deletions(-)

diff --git a/tools/ocaml/xenstored/quota.ml b/tools/ocaml/xenstored/quota.ml
index 300d78a50b..f6e28ecc6a 100644
--- a/tools/ocaml/xenstored/quota.ml
+++ b/tools/ocaml/xenstored/quota.ml
@@ -23,66 +23,69 @@ let activate = ref true
 let maxent = ref (1000)
 let maxsize = ref (2048)
 
+module Domid = struct
+  type t = Xenctrl.domid
+  let compare (a:t) (b:t) = compare a b
+end
+
+module DomidMap = Map.Make(Domid)
+
 type t = {
   maxent: int;               (* max entities per domU *)
   maxsize: int;              (* max size of data store in one node *)
-  cur: (Xenctrl.domid, int) Hashtbl.t; (* current domains quota *)
+  mutable cur: int DomidMap.t; (* current domains quota *)
 }
 
 let to_string quota domid =
-  if Hashtbl.mem quota.cur domid
-  then Printf.sprintf "dom%i quota: %i/%i" domid (Hashtbl.find quota.cur domid) quota.maxent
-  else Printf.sprintf "dom%i quota: not set" domid
+  try
+    Printf.sprintf "dom%i quota: %i/%i" domid (DomidMap.find domid quota.cur) quota.maxent
+  with Not_found ->
+    Printf.sprintf "dom%i quota: not set" domid
 
 let create () =
-  { maxent = !maxent; maxsize = !maxsize; cur = Hashtbl.create 100; }
+  { maxent = !maxent; maxsize = !maxsize; cur = DomidMap.empty; }
 
-let copy quota = { quota with cur = (Hashtbl.copy quota.cur) }
+let copy quota = { quota with cur = quota.cur }
 
-let del quota id = Hashtbl.remove quota.cur id
+let del quota id = { quota with cur = DomidMap.remove id quota.cur }
 
 let _check quota id size =
   if size > quota.maxsize then (
     warn "domain %u err create entry: data too big %d" id size;
     raise Data_too_big
   );
-  if id > 0 && Hashtbl.mem quota.cur id then
-    let entry = Hashtbl.find quota.cur id in
+  if id > 0 then
+  try
+    let entry = DomidMap.find id quota.cur in
     if entry >= quota.maxent then (
       warn "domain %u cannot create entry: quota reached" id;
       raise Limit_reached
     )
+  with Not_found -> ()
 
 let check quota id size =
   if !activate then
     _check quota id size
 
-let get_entry quota id = Hashtbl.find quota.cur id
+let find_or_zero quota_cur id =
+  try DomidMap.find id quota_cur with Not_found -> 0
 
-let set_entry quota id nb =
-  if nb = 0
-  then Hashtbl.remove quota.cur id
-  else begin
-    if Hashtbl.mem quota.cur id then
-      Hashtbl.replace quota.cur id nb
-    else
-      Hashtbl.add quota.cur id nb
-  end
+let update_entry quota_cur id diff =
+  let nb = diff + find_or_zero quota_cur id in
+  if nb = 0 then DomidMap.remove id quota_cur
+  else DomidMap.add id nb quota_cur
 
 let del_entry quota id =
-  try
-    let nb = get_entry quota id in
-    set_entry quota id (nb - 1)
-  with Not_found -> ()
+  quota.cur <- update_entry quota.cur id (-1)
 
 let add_entry quota id =
-  let nb = try get_entry quota id with Not_found -> 0 in
-  set_entry quota id (nb + 1)
-
-let add quota diff =
-  Hashtbl.iter (fun id nb -> set_entry quota id (get_entry quota id + nb)) diff.cur
+  quota.cur <- update_entry quota.cur id (+1)
 
 let merge orig_quota mod_quota dest_quota =
-  Hashtbl.iter (fun id nb -> let diff = nb - (try get_entry orig_quota id with Not_found -> 0) in
-      if diff <> 0 then
-        set_entry dest_quota id ((try get_entry dest_quota id with Not_found -> 0) + diff)) mod_quota.cur
+  let fold_merge id nb dest =
+    match nb - find_or_zero orig_quota.cur id with
+    | 0 -> dest (* not modified *)
+    | diff -> update_entry dest id diff (* update with [x=x+diff] *)
+  in
+  dest_quota.cur <- DomidMap.fold fold_merge mod_quota.cur dest_quota.cur
+  (* dest_quota = dest_quota + (mod_quota - orig_quota) *)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 24 23:44:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 24 Feb 2024 23:44:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685138.1065521 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1h4-0006Ym-5W; Sat, 24 Feb 2024 23:44:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685138.1065521; Sat, 24 Feb 2024 23:44:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1h4-0006YX-1w; Sat, 24 Feb 2024 23:44:34 +0000
Received: by outflank-mailman (input) for mailman id 685138;
 Sat, 24 Feb 2024 23:44:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1h2-0006YI-Th
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1h2-0000xR-SW
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1h2-00088N-RD
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=bJpplTQ+YDp1frix9FaEpvrlZPH6jISscBzhjSo34qk=; b=M5eHFwFFvux8pNo6RMKY49LgHV
	dv8AJ82JcKMDRGWdhxvj8Sn0LPxSsv93hUqNlCwVXfkUItNEA54NjjHjWkkNiHtrrO/BIMr/xCdNe
	4waD/26EqfH8Fy28Cpm10qPt1FYP+KJTZM4Hm+tK5t8b89h18G4rc8XfNd0Wze3qHGU8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/oxenstored: Make Quota.t pure
Message-Id: <E1re1h2-00088N-RD@xenbits.xenproject.org>
Date: Sat, 24 Feb 2024 23:44:32 +0000

commit 098d868e52ac0165b7f36e22b767ea70cef70054
Author:     Edwin Török <edwin.torok@cloud.com>
AuthorDate: Wed Jan 31 10:52:56 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools/oxenstored: Make Quota.t pure
    
    Now that we no longer have a hashtable inside we can make Quota.t pure, and
    push the mutable update to its callers.  Store.t already had a mutable Quota.t
    field.
    
    No functional change.
    
    Signed-off-by: Edwin Török <edwin.torok@cloud.com>
    Acked-by: Christian Lindig <christian.lindig@cloud.com>
---
 tools/ocaml/xenstored/quota.ml |  8 ++++----
 tools/ocaml/xenstored/store.ml | 17 ++++++++++-------
 2 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/tools/ocaml/xenstored/quota.ml b/tools/ocaml/xenstored/quota.ml
index f6e28ecc6a..1f652040d8 100644
--- a/tools/ocaml/xenstored/quota.ml
+++ b/tools/ocaml/xenstored/quota.ml
@@ -33,7 +33,7 @@ module DomidMap = Map.Make(Domid)
 type t = {
   maxent: int;               (* max entities per domU *)
   maxsize: int;              (* max size of data store in one node *)
-  mutable cur: int DomidMap.t; (* current domains quota *)
+  cur: int DomidMap.t; (* current domains quota *)
 }
 
 let to_string quota domid =
@@ -76,10 +76,10 @@ let update_entry quota_cur id diff =
   else DomidMap.add id nb quota_cur
 
 let del_entry quota id =
-  quota.cur <- update_entry quota.cur id (-1)
+  {quota with cur = update_entry quota.cur id (-1)}
 
 let add_entry quota id =
-  quota.cur <- update_entry quota.cur id (+1)
+  {quota with cur = update_entry quota.cur id (+1)}
 
 let merge orig_quota mod_quota dest_quota =
   let fold_merge id nb dest =
@@ -87,5 +87,5 @@ let merge orig_quota mod_quota dest_quota =
     | 0 -> dest (* not modified *)
     | diff -> update_entry dest id diff (* update with [x=x+diff] *)
   in
-  dest_quota.cur <- DomidMap.fold fold_merge mod_quota.cur dest_quota.cur
+  {dest_quota with cur = DomidMap.fold fold_merge mod_quota.cur dest_quota.cur}
   (* dest_quota = dest_quota + (mod_quota - orig_quota) *)
diff --git a/tools/ocaml/xenstored/store.ml b/tools/ocaml/xenstored/store.ml
index 38a4945372..9b8dd2812d 100644
--- a/tools/ocaml/xenstored/store.ml
+++ b/tools/ocaml/xenstored/store.ml
@@ -85,7 +85,9 @@ module Node = struct
       raise Define.Permission_denied;
     end
 
-  let rec recurse fct node = fct node; SymbolMap.iter (fun _ -> recurse fct) node.children
+  let rec recurse fct node acc =
+    let acc = fct node acc in
+    SymbolMap.fold (fun _ -> recurse fct) node.children acc
 
   (** [recurse_filter_map f tree] applies [f] on each node in the tree recursively,
       possibly removing some nodes.
@@ -408,7 +410,7 @@ let dump_buffer store = dump_store_buf store.root
 let set_node store path node orig_quota mod_quota =
   let root = Path.set_node store.root path node in
   store.root <- root;
-  Quota.merge orig_quota mod_quota store.quota
+  store.quota <- Quota.merge orig_quota mod_quota store.quota
 
 let write store perm path value =
   let node, existing = get_deepest_existing_node store path in
@@ -422,7 +424,7 @@ let write store perm path value =
   let root, node_created = path_write store perm path value in
   store.root <- root;
   if node_created
-  then Quota.add_entry store.quota owner
+  then store.quota <- Quota.add_entry store.quota owner
 
 let mkdir store perm path =
   let node, existing = get_deepest_existing_node store path in
@@ -431,7 +433,7 @@ let mkdir store perm path =
   if not (existing || (Perms.Connection.is_dom0 perm)) then Quota.check store.quota owner 0;
   store.root <- path_mkdir store perm path;
   if not existing then
-    Quota.add_entry store.quota owner
+    store.quota <- Quota.add_entry store.quota owner
 
 let rm store perm path =
   let rmed_node = Path.get_node store.root path in
@@ -439,7 +441,7 @@ let rm store perm path =
   | None -> raise Define.Doesnt_exist
   | Some rmed_node ->
     store.root <- path_rm store perm path;
-    Node.recurse (fun node -> Quota.del_entry store.quota (Node.get_owner node)) rmed_node
+    store.quota <- Node.recurse (fun node quota -> Quota.del_entry quota (Node.get_owner node)) rmed_node store.quota
 
 let setperms store perm path nperms =
   match Path.get_node store.root path with
@@ -450,8 +452,9 @@ let setperms store perm path nperms =
     if not ((old_owner = new_owner) || (Perms.Connection.is_dom0 perm)) then
       raise Define.Permission_denied;
     store.root <- path_setperms store perm path nperms;
-    Quota.del_entry store.quota old_owner;
-    Quota.add_entry store.quota new_owner
+    store.quota <-
+      let quota = Quota.del_entry store.quota old_owner in
+      Quota.add_entry quota new_owner
 
 let reset_permissions store domid =
   Logging.info "store|node" "Cleaning up xenstore ACLs for domid %d" domid;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 24 23:44:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 24 Feb 2024 23:44:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685139.1065523 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1hE-0006bb-6J; Sat, 24 Feb 2024 23:44:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685139.1065523; Sat, 24 Feb 2024 23:44:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1hE-0006bU-3O; Sat, 24 Feb 2024 23:44:44 +0000
Received: by outflank-mailman (input) for mailman id 685139;
 Sat, 24 Feb 2024 23:44:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1hD-0006bG-0p
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:43 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1hD-0000xt-01
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1hC-00088t-VR
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=rs3QOCLMN9DtBU6UplMomVu3SwGjgF0rGIC7PpGoFaQ=; b=uoNp1xOY2/4w+v8iqg71jBm/B5
	HuOu9UFi7D6aqRIW3qtOL70cGWisdtVCThDEKZ6fQAFvR0V0mvjSFjqYEuNwAsJloH02Z2kfGZUtI
	u5DN+K7tzx5ZBtHQZDq4yXEd0sxpYhfPrIbyZI/mSbGrfl2udsnF8Nm4CwijpTpc+7M8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/libs/light: add backend type for 9pfs PV devices
Message-Id: <E1re1hC-00088t-VR@xenbits.xenproject.org>
Date: Sat, 24 Feb 2024 23:44:42 +0000

commit ab5a6b598651279ae9c47c22bbb0c072ad60d878
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 16 17:31:32 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools/libs/light: add backend type for 9pfs PV devices
    
    Make the backend type of 9pfs PV devices configurable. The default is
    "qemu" with the related Xenstore backend-side directory being "9pfs".
    
    Add another type "xen_9pfsd" with the related Xenstore backend-side
    directory "xen_9pfs".
    
    As additional security features it is possible to specify:
    - "max-space" for limiting the maximum space consumed on the filesystem
      in MBs
    - "max-files" for limiting the maximum number of files in the
      filesystem
    - "max-open-files" for limiting the maximum number of concurrent open
      files
    
    For convenience "auto-delete" is available to let the backend delete the
    oldest file of the guest in case otherwise "max-space" or "max-files"
    would be violated.
    
    The xen-9pfsd daemon will be started by libxenlight automatically when
    the first "xen_9pfs" device is being created.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: George Dunlap <george.dunlap@cloud.com> # Golang bits
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/golang/xenlight/helpers.gen.go      |  10 ++
 tools/golang/xenlight/types.gen.go        |  12 +++
 tools/include/libxl.h                     |   7 ++
 tools/libs/light/libxl_9pfs.c             | 157 +++++++++++++++++++++++++++++-
 tools/libs/light/libxl_create.c           |   4 +-
 tools/libs/light/libxl_dm.c               |   2 +-
 tools/libs/light/libxl_types.idl          |  11 +++
 tools/libs/light/libxl_types_internal.idl |   1 +
 8 files changed, 197 insertions(+), 7 deletions(-)

diff --git a/tools/golang/xenlight/helpers.gen.go b/tools/golang/xenlight/helpers.gen.go
index acdf1c1820..78bdb08b15 100644
--- a/tools/golang/xenlight/helpers.gen.go
+++ b/tools/golang/xenlight/helpers.gen.go
@@ -2446,6 +2446,11 @@ x.Tag = C.GoString(xc.tag)
 x.Path = C.GoString(xc.path)
 x.SecurityModel = C.GoString(xc.security_model)
 x.Devid = Devid(xc.devid)
+x.Type = P9Type(xc._type)
+x.MaxSpace = int(xc.max_space)
+x.MaxFiles = int(xc.max_files)
+x.MaxOpenFiles = int(xc.max_open_files)
+x.AutoDelete = bool(xc.auto_delete)
 
  return nil}
 
@@ -2464,6 +2469,11 @@ xc.path = C.CString(x.Path)}
 if x.SecurityModel != "" {
 xc.security_model = C.CString(x.SecurityModel)}
 xc.devid = C.libxl_devid(x.Devid)
+xc._type = C.libxl_p9_type(x.Type)
+xc.max_space = C.int(x.MaxSpace)
+xc.max_files = C.int(x.MaxFiles)
+xc.max_open_files = C.int(x.MaxOpenFiles)
+xc.auto_delete = C.bool(x.AutoDelete)
 
  return nil
  }
diff --git a/tools/golang/xenlight/types.gen.go b/tools/golang/xenlight/types.gen.go
index 76b4ed991b..ccfe18019e 100644
--- a/tools/golang/xenlight/types.gen.go
+++ b/tools/golang/xenlight/types.gen.go
@@ -122,6 +122,13 @@ NicTypeVifIoemu NicType = 1
 NicTypeVif NicType = 2
 )
 
+type P9Type int
+const(
+P9TypeUnknown P9Type = 0
+P9TypeQemu P9Type = 1
+P9TypeXen9Pfsd P9Type = 2
+)
+
 type ActionOnShutdown int
 const(
 ActionOnShutdownDestroy ActionOnShutdown = 1
@@ -890,6 +897,11 @@ Tag string
 Path string
 SecurityModel string
 Devid Devid
+Type P9Type
+MaxSpace int
+MaxFiles int
+MaxOpenFiles int
+AutoDelete bool
 }
 
 type DevicePvcallsif struct {
diff --git a/tools/include/libxl.h b/tools/include/libxl.h
index a370528ba1..f36c613b7d 100644
--- a/tools/include/libxl.h
+++ b/tools/include/libxl.h
@@ -622,6 +622,13 @@
  */
 #define LIBXL_HAVE_HVM_PIRQ 1
 
+/*
+ * LIBXL_HAVE_XEN_9PFS indicates the presence of the xen-9pfsd related
+ * fields in libxl_device_p9: type, max_space, max_files, max_open_files and
+ * auto_delete.
+ */
+#define LIBXL_HAVE_XEN_9PFS 1
+
 /*
  * libxl memory management
  *
diff --git a/tools/libs/light/libxl_9pfs.c b/tools/libs/light/libxl_9pfs.c
index 5ab0d3aa21..900c0d46a0 100644
--- a/tools/libs/light/libxl_9pfs.c
+++ b/tools/libs/light/libxl_9pfs.c
@@ -33,20 +33,171 @@ static int libxl__set_xenstore_p9(libxl__gc *gc, uint32_t domid,
 
     flexarray_append_pair(front, "tag", p9->tag);
 
+    if (p9->type == LIBXL_P9_TYPE_XEN_9PFSD) {
+        flexarray_append_pair(back, "max-space",
+                              GCSPRINTF("%u", p9->max_space));
+        flexarray_append_pair(back, "max-files",
+                              GCSPRINTF("%u", p9->max_files));
+        flexarray_append_pair(back, "max-open-files",
+                              GCSPRINTF("%u", p9->max_open_files));
+        flexarray_append_pair(back, "auto-delete",
+                              p9->auto_delete ? "1" : "0");
+    }
+
+    return 0;
+}
+
+static int libxl__device_from_p9(libxl__gc *gc, uint32_t domid,
+                                 libxl_device_p9 *type, libxl__device *device)
+{
+    device->backend_devid   = type->devid;
+    device->backend_domid   = type->backend_domid;
+    device->backend_kind    = type->type == LIBXL_P9_TYPE_QEMU
+                              ? LIBXL__DEVICE_KIND_9PFS
+                              : LIBXL__DEVICE_KIND_XEN_9PFS;
+    device->devid           = type->devid;
+    device->domid           = domid;
+    device->kind            = LIBXL__DEVICE_KIND_9PFS;
+
     return 0;
 }
 
-#define libxl__add_p9s NULL
+static int libxl__device_p9_dm_needed(void *e, unsigned domid)
+{
+    libxl_device_p9 *elem = e;
+
+    return elem->type == LIBXL_P9_TYPE_QEMU && elem->backend_domid == domid;
+}
+
+typedef struct libxl__aop9_state libxl__aop9_state;
+
+struct libxl__aop9_state {
+    libxl__spawn_state spawn;
+    libxl__ao_device *aodev;
+    libxl_device_p9 p9;
+    uint32_t domid;
+};
+
+static void xen9pfsd_confirm(libxl__egc *egc, libxl__spawn_state *spawn,
+                             const char *xsdata);
+static void xen9pfsd_failed(libxl__egc *egc, libxl__spawn_state *spawn, int rc);
+static void xen9pfsd_detached(libxl__egc *egc, libxl__spawn_state *spawn);
+static void xen9pfsd_spawn_outcome(libxl__egc *egc, libxl__aop9_state *aop9,
+                                   int rc);
+
+/*
+ * Spawn the xen-9pfsd daemon if needed.
+ * returns:
+ * < 0 if error
+ * 0 if no daemon needs to be spawned
+ * 1 if daemon was spawned
+ */
+static int xen9pfsd_spawn(libxl__egc *egc, uint32_t domid, libxl_device_p9 *p9,
+                         libxl__ao_device *aodev)
+{
+    STATE_AO_GC(aodev->ao);
+    struct libxl__aop9_state *aop9;
+    int rc;
+    char *args[] = { "xen-9pfsd", NULL };
+    char *path = GCSPRINTF("/local/domain/%u/libxl/xen-9pfs",
+                           p9->backend_domid);
+
+    if (p9->type != LIBXL_P9_TYPE_XEN_9PFSD ||
+        libxl__xs_read(gc, XBT_NULL, GCSPRINTF("%s/state", path)))
+        return 0;
+
+    GCNEW(aop9);
+    aop9->aodev = aodev;
+    libxl_device_p9_copy(CTX, &aop9->p9, p9);
+    aop9->domid = domid;
+
+    aop9->spawn.ao = aodev->ao;
+    aop9->spawn.what = "xen-9pfs daemon";
+    aop9->spawn.xspath = GCSPRINTF("%s/state", path);
+    aop9->spawn.timeout_ms = LIBXL_DEVICE_MODEL_START_TIMEOUT * 1000;
+    aop9->spawn.pidpath = GCSPRINTF("%s/pid", path);
+    aop9->spawn.midproc_cb = libxl__spawn_record_pid;
+    aop9->spawn.confirm_cb = xen9pfsd_confirm;
+    aop9->spawn.failure_cb = xen9pfsd_failed;
+    aop9->spawn.detached_cb = xen9pfsd_detached;
+    rc = libxl__spawn_spawn(egc, &aop9->spawn);
+    if (rc < 0)
+        return rc;
+    if (!rc) {
+        setsid();
+        libxl__exec(gc, -1, -1, -1, LIBEXEC_BIN "/xen-9pfsd", args, NULL);
+    }
+
+    return 1;
+}
+
+static void xen9pfsd_confirm(libxl__egc *egc, libxl__spawn_state *spawn,
+                             const char *xsdata)
+{
+    STATE_AO_GC(spawn->ao);
+
+    if (!xsdata)
+        return;
+
+    if (strcmp(xsdata, "running"))
+        return;
+
+    libxl__spawn_initiate_detach(gc, spawn);
+}
+
+static void xen9pfsd_failed(libxl__egc *egc, libxl__spawn_state *spawn, int rc)
+{
+    libxl__aop9_state *aop9 = CONTAINER_OF(spawn, *aop9, spawn);
+
+    xen9pfsd_spawn_outcome(egc, aop9, rc);
+}
+
+static void xen9pfsd_detached(libxl__egc *egc, libxl__spawn_state *spawn)
+{
+    libxl__aop9_state *aop9 = CONTAINER_OF(spawn, *aop9, spawn);
+
+    xen9pfsd_spawn_outcome(egc, aop9, 0);
+}
+
+static void xen9pfsd_spawn_outcome(libxl__egc *egc, libxl__aop9_state *aop9,
+                                   int rc)
+{
+    aop9->aodev->rc = rc;
+    if (rc)
+        aop9->aodev->callback(egc, aop9->aodev);
+    else
+        libxl__device_add_async(egc, aop9->domid, &libxl__p9_devtype,
+                                &aop9->p9, aop9->aodev);
+}
+
+static void libxl__device_p9_add(libxl__egc *egc, uint32_t domid,
+                                 libxl_device_p9 *p9,
+                                 libxl__ao_device *aodev)
+{
+    int rc;
+
+    rc = xen9pfsd_spawn(egc, domid, p9, aodev);
+    if (rc == 1)
+        return;
+
+    if (rc == 0)
+        libxl__device_add_async(egc, domid, &libxl__p9_devtype, p9, aodev);
+
+    aodev->rc = rc;
+    if (rc)
+        aodev->callback(egc, aodev);
+}
+
 #define libxl_device_p9_list NULL
 #define libxl_device_p9_compare NULL
 
 static LIBXL_DEFINE_UPDATE_DEVID(p9)
-static LIBXL_DEFINE_DEVICE_FROM_TYPE(p9)
+static LIBXL_DEFINE_DEVICES_ADD(p9)
 
 LIBXL_DEFINE_DEVICE_REMOVE(p9)
 
 DEFINE_DEVICE_TYPE_STRUCT(p9, 9PFS, p9s,
-    .skip_attach = 1,
     .set_xenstore_config = (device_set_xenstore_config_fn_t)
                            libxl__set_xenstore_p9,
+    .dm_needed = libxl__device_p9_dm_needed,
 );
diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c
index 0008fac607..5546335973 100644
--- a/tools/libs/light/libxl_create.c
+++ b/tools/libs/light/libxl_create.c
@@ -1761,9 +1761,6 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev,
         libxl__device_console_dispose(&console);
     }
 
-    for (i = 0; i < d_config->num_p9s; i++)
-        libxl__device_add(gc, domid, &libxl__p9_devtype, &d_config->p9s[i]);
-
     for (i = 0; i < d_config->num_pvcallsifs; i++)
         libxl__device_add(gc, domid, &libxl__pvcallsif_devtype,
                           &d_config->pvcallsifs[i]);
@@ -1900,6 +1897,7 @@ const libxl__device_type *device_type_tbl[] = {
     &libxl__vdispl_devtype,
     &libxl__vsnd_devtype,
     &libxl__virtio_devtype,
+    &libxl__p9_devtype,
     NULL
 };
 
diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
index ed620a9d8e..dc4c2dfb9f 100644
--- a/tools/libs/light/libxl_dm.c
+++ b/tools/libs/light/libxl_dm.c
@@ -3771,7 +3771,7 @@ int libxl__need_xenpv_qemu(libxl__gc *gc, libxl_domain_config *d_config)
         goto out;
     }
 
-    if (d_config->num_vfbs > 0 || d_config->num_p9s > 0) {
+    if (d_config->num_vfbs > 0) {
         ret = 1;
         goto out;
     }
diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_types.idl
index 6d76f25528..470122e768 100644
--- a/tools/libs/light/libxl_types.idl
+++ b/tools/libs/light/libxl_types.idl
@@ -150,6 +150,12 @@ libxl_nic_type = Enumeration("nic_type", [
     (2, "VIF"),
     ])
 
+libxl_p9_type = Enumeration("p9_type", [
+    (0, "unknown"),
+    (1, "qemu"),
+    (2, "xen_9pfsd"),
+    ])
+
 libxl_action_on_shutdown = Enumeration("action_on_shutdown", [
     (1, "DESTROY"),
 
@@ -944,6 +950,11 @@ libxl_device_p9 = Struct("device_p9", [
     ("path",             string),
     ("security_model",   string),
     ("devid",            libxl_devid),
+    ("type",             libxl_p9_type),
+    ("max_space",        integer),
+    ("max_files",        integer),
+    ("max_open_files",   integer),
+    ("auto_delete",      bool),
 ])
 
 libxl_device_pvcallsif = Struct("device_pvcallsif", [
diff --git a/tools/libs/light/libxl_types_internal.idl b/tools/libs/light/libxl_types_internal.idl
index 56dccac153..0425e9b6b0 100644
--- a/tools/libs/light/libxl_types_internal.idl
+++ b/tools/libs/light/libxl_types_internal.idl
@@ -35,6 +35,7 @@ libxl__device_kind = Enumeration("device_kind", [
     (17, "VIRTIO_DISK"),
     (18, "VIRTIO"),
     (19, "VBD3"),
+    (20, "XEN_9PFS"),
     ])
 
 libxl__console_backend = Enumeration("console_backend", [
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 24 23:44:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 24 Feb 2024 23:44:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685140.1065527 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1hO-0006f9-9F; Sat, 24 Feb 2024 23:44:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685140.1065527; Sat, 24 Feb 2024 23:44:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1hO-0006f1-6Y; Sat, 24 Feb 2024 23:44:54 +0000
Received: by outflank-mailman (input) for mailman id 685140;
 Sat, 24 Feb 2024 23:44:53 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1hN-0006ep-41
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:53 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1hN-0000y2-3I
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:53 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1hN-00089K-2S
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:44:53 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=SqQr6kliR8OG/WroU5C8fewfCyowFX8ashEaXYkkWxo=; b=cAcbIZEmRlVyQ91elc10HSkwY7
	gLCLN/4EB4vQhRw03JCNdcz9YiGUy2CdgzruSGML4W6Qwrx8tB9CvkSr1QZQW1Q+QjjiPu+y6AlLY
	wJSEbMbaR+eMyJk3A49Wla+9/qfatAiu+dZz+AKxusLhoXlj4YPF9M445g3Za0qtrbrQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xl: support new 9pfs backend xen_9pfsd
Message-Id: <E1re1hN-00089K-2S@xenbits.xenproject.org>
Date: Sat, 24 Feb 2024 23:44:53 +0000

commit 4287a71f9b9d6a7dc1e51ae89b5ae04e1ba49d7c
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 16 17:31:33 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools/xl: support new 9pfs backend xen_9pfsd
    
    Add support for the new 9pfs backend "xen_9pfsd". For this backend type
    the tag defaults to "Xen" and the host side path to
    "/var/log/xen/guests/<dom-name>".
    
    Do most of the default settings in libxl. Unfortunately the default
    path can't easily be set in libxl, as the domain name isn't available
    in the related 9pfs specific function.
    
    Settings the defaults in libxl requires to move the sanity checking
    of 9pfs parameters from xl to libxl, too.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 docs/man/xl.cfg.5.pod.in      | 36 ++++++++++++++++++++++++++++++++++--
 tools/libs/light/libxl_9pfs.c | 18 ++++++++++++++++++
 tools/xl/xl_parse.c           | 23 ++++++++++++++++++++---
 3 files changed, 72 insertions(+), 5 deletions(-)

diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
index ea8d41727d..039e057318 100644
--- a/docs/man/xl.cfg.5.pod.in
+++ b/docs/man/xl.cfg.5.pod.in
@@ -772,10 +772,16 @@ settings, from the following list:
 
 =over 4
 
+=item B<type=TYPE>
+
+The backendtype for the PV device. Supported values are B<qemu> and
+B<xen_9pfsd>.  The default is B<qemu>.
+
 =item B<tag=STRING>
 
 9pfs tag to identify the filesystem share. The tag is needed on the
-guest side to mount it.
+guest side to mount it. For the backendtype of B<xen_9pfsd> the tag defaults to
+"Xen".
 
 =item B<security_model="none">
 
@@ -785,12 +791,38 @@ squash or remap).
 
 =item B<path=STRING>
 
-Filesystem path on the backend to export.
+Filesystem path on the backend to export. For the backendtype of B<xen_9pfsd>
+the path defaults to "@XEN_LOG_DIR@/guests/<guest-name>".
 
 =item B<backend=domain-id>
 
 Specify the backend domain name or id, defaults to dom0.
 
+=item B<max-files=NUMBER>
+
+Specify the maximum number of files below B<path>. A value of 0 (which
+is the default) doesn't limit the number of files. Only valid for
+B<type=xen_9pfsd>.
+
+=item B<max-open-files=NUMBER>
+
+Specify the maximum number of concurrently opened files below B<path>.
+Multiple opens of the same file are counted individually. Only valid for
+B<type=xen_9pfsd>, which has a default of B<max-open-files=5>.
+
+=item B<max-space=NUMBER>
+
+Specify the maximum used disk space in MiB below B<path>. A value of 0 (which
+is the default) doesn't limit the usable disk space. Only valid for
+B<type=xen_9pfsd>.
+
+=item B<auto-delete=BOOLEAN>
+
+When set the backend will delete the oldest file which is currently not
+opened by the guest in case the disk space limit set via B<max-space> or the
+file limit set via B<max-files> is being reached. Only valid for
+B<type=xen_9pfsd>.
+
 =back
 
 =item B<pvcalls=[ "backend=domain-id", ... ]>
diff --git a/tools/libs/light/libxl_9pfs.c b/tools/libs/light/libxl_9pfs.c
index 900c0d46a0..ddeb4f20a7 100644
--- a/tools/libs/light/libxl_9pfs.c
+++ b/tools/libs/light/libxl_9pfs.c
@@ -20,6 +20,24 @@
 static int libxl__device_p9_setdefault(libxl__gc *gc, uint32_t domid,
                                        libxl_device_p9 *p9, bool hotplug)
 {
+    if (p9->type == LIBXL_P9_TYPE_UNKNOWN) {
+        p9->type = LIBXL_P9_TYPE_QEMU;
+    }
+    if (p9->type == LIBXL_P9_TYPE_QEMU &&
+        (p9->max_files || p9->max_open_files || p9->max_space ||
+         p9->auto_delete)) {
+        LOGD(ERROR, domid, "Illegal 9pfs parameter combination");
+        return ERROR_INVAL;
+    }
+    if (p9->type == LIBXL_P9_TYPE_XEN_9PFSD && !p9->tag) {
+        p9->tag = libxl__strdup(NOGC, "Xen");
+    }
+
+    if (!p9->path || !p9->security_model || !p9->tag) {
+        LOGD(ERROR, domid, "9pfs spec missing required field!");
+        return ERROR_INVAL;
+    }
+
     return libxl__resolve_domid(gc, p9->backend_domname, &p9->backend_domid);
 }
 
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 9b358f11b8..80ffe85f5e 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -2233,6 +2233,20 @@ void parse_config_data(const char *config_source,
                     replace_string(&p9->tag, value);
                 } else if (!strcmp(key, "backend")) {
                     replace_string(&p9->backend_domname, value);
+                } else if (!strcmp(key, "type")) {
+                    if (libxl_p9_type_from_string(value, &p9->type)) {
+                        fprintf(stderr, "failed to parse 9pfs type: %s\n",
+                                value);
+                        exit(1);
+                    }
+                } else if (!strcmp(key, "max-files")) {
+                    p9->max_files = parse_ulong(value);
+                } else if (!strcmp(key, "max-open-files")) {
+                    p9->max_open_files = parse_ulong(value);
+                } else if (!strcmp(key, "max-space")) {
+                    p9->max_space = parse_ulong(value);
+                } else if (!strcmp(key, "auto-delete")) {
+                    p9->auto_delete = strtoul(value, NULL, 0);
                 } else {
                     fprintf(stderr, "Unknown 9pfs parameter '%s'\n", key);
                     exit(1);
@@ -2243,9 +2257,12 @@ void parse_config_data(const char *config_source,
 
             libxl_string_list_dispose(&pairs);
 
-            if (!p9->path || !p9->security_model || !p9->tag) {
-                fprintf(stderr, "9pfs spec missing required field!\n");
-                exit(1);
+            if (p9->type == LIBXL_P9_TYPE_XEN_9PFSD && !p9->path) {
+                char *path;
+
+                xasprintf(&path, XEN_LOG_DIR "/guests/%s", c_info->name);
+                replace_string(&p9->path, path);
+                free(path);
             }
         }
     }
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 24 23:45:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 24 Feb 2024 23:45:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685141.1065533 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1hY-0006hx-C5; Sat, 24 Feb 2024 23:45:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685141.1065533; Sat, 24 Feb 2024 23:45:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1hY-0006hn-7y; Sat, 24 Feb 2024 23:45:04 +0000
Received: by outflank-mailman (input) for mailman id 685141;
 Sat, 24 Feb 2024 23:45:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1hX-0006he-75
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1hX-0000yh-6O
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1hX-0008PG-5W
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Ui/yL6693BDmHR9FUCoIC1W6p7yNH2lH++zwpNbb6i8=; b=LQ2lLxHVJbItiB48GqYpW6KxjD
	hAF2GnbYotPEd8KJmVf3yRJZ0otpaGjFw4k2cdSaaNO4M+yoxTqDdhNr6yZE472vp/zIOEQaalYxG
	HJfjys19iqQg5uQ4iagQSulnmNYuflW4otlLqMGp+ahXmEP5I6feRnL9WPAhCa4PDnMM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] stubdom: extend xenstore stubdom configs
Message-Id: <E1re1hX-0008PG-5W@xenbits.xenproject.org>
Date: Sat, 24 Feb 2024 23:45:03 +0000

commit 0b761781c4de2e6637203d0f51273a5a1f8873df
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 16 17:31:34 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    stubdom: extend xenstore stubdom configs
    
    Extend the config files of the Xenstore stubdoms to include XENBUS
    and 9PFRONT items in order to support file based logging.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 stubdom/xenstore-minios.cfg    | 2 +-
 stubdom/xenstorepvh-minios.cfg | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/stubdom/xenstore-minios.cfg b/stubdom/xenstore-minios.cfg
index a41704bb6b..239da519b9 100644
--- a/stubdom/xenstore-minios.cfg
+++ b/stubdom/xenstore-minios.cfg
@@ -3,7 +3,7 @@ CONFIG_NETFRONT=n
 CONFIG_FBFRONT=n
 CONFIG_KBDFRONT=n
 CONFIG_CONSFRONT=n
-CONFIG_XENBUS=n
 CONFIG_LWIP=n
+CONFIG_9PFRONT=y
 CONFIG_BALLOON=y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
diff --git a/stubdom/xenstorepvh-minios.cfg b/stubdom/xenstorepvh-minios.cfg
index 6af51f5753..752b90d7d3 100644
--- a/stubdom/xenstorepvh-minios.cfg
+++ b/stubdom/xenstorepvh-minios.cfg
@@ -4,7 +4,7 @@ CONFIG_NETFRONT=n
 CONFIG_FBFRONT=n
 CONFIG_KBDFRONT=n
 CONFIG_CONSFRONT=n
-CONFIG_XENBUS=n
 CONFIG_LWIP=n
+CONFIG_9PFRONT=y
 CONFIG_BALLOON=y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 24 23:45:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 24 Feb 2024 23:45:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685142.1065535 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1hi-0006kY-CV; Sat, 24 Feb 2024 23:45:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685142.1065535; Sat, 24 Feb 2024 23:45:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1hi-0006kQ-9Z; Sat, 24 Feb 2024 23:45:14 +0000
Received: by outflank-mailman (input) for mailman id 685142;
 Sat, 24 Feb 2024 23:45:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1hh-0006kE-AH
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1hh-0000yx-9c
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1hh-0008VT-8l
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=awuMzxyhoJIbRhELI8Ox3H32i6Tlmaj/+/UFO7/x3kI=; b=QQ6qsILdWXIdjLIYWa8Ksw3+de
	CmysYHqJS67FNfykm/nccc81py+1iFY4mEMOunusXCaiKFJEXCmFXPWhPt52H+4uChqMdCd8tZgHj
	Ct5Pmn3vksPgaHwodpVt18KjtS+yMaPZKowNGfg96DuFBywpvf67bToxwKCD03aYzZ7M=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools: add 9pfs device to xenstore-stubdom
Message-Id: <E1re1hh-0008VT-8l@xenbits.xenproject.org>
Date: Sat, 24 Feb 2024 23:45:13 +0000

commit e21d9dbf4457a8c1f42d6e4a2ef2d3fe7c62616b
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 16 17:31:35 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools: add 9pfs device to xenstore-stubdom
    
    Add a 9pfs device to Xenstore stubdom in order to allow it to do e.g.
    logging into a dom0 file.
    
    Use the following parameters for the new device:
    
    - tag = "Xen"
    - type = "xen_9pfsd"
    - path = "/var/lib/xen/xenstore"
    - security-model = "none"
    
    For now don't limit allowed file space or number of files.
    
    Add a new libxl function for adding it similar to the function for
    adding the console device.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/helpers/init-xenstore-domain.c |  7 +++++++
 tools/include/libxl.h                | 15 +++++++++++++++
 tools/libs/light/libxl_9pfs.c        | 16 ++++++++++++++++
 3 files changed, 38 insertions(+)

diff --git a/tools/helpers/init-xenstore-domain.c b/tools/helpers/init-xenstore-domain.c
index 140ed610ae..1683438c5c 100644
--- a/tools/helpers/init-xenstore-domain.c
+++ b/tools/helpers/init-xenstore-domain.c
@@ -433,6 +433,12 @@ int main(int argc, char** argv)
     int rv, fd;
     char *maxmem_str = NULL;
     libxl_ctx *ctx;
+    libxl_device_p9 p9 = { .backend_domid = 0,
+                           .tag = "Xen",
+                           .path = XEN_LIB_DIR"/xenstore",
+                           .security_model = "none",
+                           .type = LIBXL_P9_TYPE_XEN_9PFSD,
+    };
 
     while ( (opt = getopt_long(argc, argv, "v", options, NULL)) != -1 )
     {
@@ -543,6 +549,7 @@ int main(int argc, char** argv)
     }
     libxl_console_add_xenstore(ctx, domid, 0, console_evtchn, console_gfn,
                                NULL);
+    libxl_device_9pfs_add(ctx, domid, &p9, NULL);
     libxl_ctx_free(ctx);
 
     fd = creat(XEN_RUN_DIR "/xenstored.pid", 0666);
diff --git a/tools/include/libxl.h b/tools/include/libxl.h
index f36c613b7d..62cb07dea6 100644
--- a/tools/include/libxl.h
+++ b/tools/include/libxl.h
@@ -590,6 +590,13 @@
  * libxl_console_add_xenstore() in libxl.
  */
 #define LIBXL_HAVE_CONSOLE_ADD_XENSTORE 1
+
+/*
+ * LIBXL_HAVE_P9_ADD indicates presence of the function
+ * libxl_device_9pfs_add() in libxl.
+ */
+#define LIBXL_HAVE_P9_ADD 1
+
 /*
  * libxl ABI compatibility
  *
@@ -2081,6 +2088,14 @@ int libxl_console_add_xenstore(libxl_ctx *ctx, uint32_t domid, uint32_t backend,
                                const libxl_asyncop_how *ao_how)
                                LIBXL_EXTERNAL_CALLERS_ONLY;
 
+/* libxl_device_9pfs_add writes the Xenstore entries for a domain's
+ * primary 9pfs device based on domid, and device parameters.
+ * If needed it will start the backend daemon.
+ */
+int libxl_device_9pfs_add(libxl_ctx *ctx, uint32_t domid, libxl_device_p9 *p9,
+                          const libxl_asyncop_how *ao_how)
+                          LIBXL_EXTERNAL_CALLERS_ONLY;
+
 /* May be called with info_r == NULL to check for domain's existence.
  * Returns ERROR_DOMAIN_NOTFOUND if domain does not exist (used to return
  * ERROR_INVAL for this scenario). */
diff --git a/tools/libs/light/libxl_9pfs.c b/tools/libs/light/libxl_9pfs.c
index ddeb4f20a7..48f894f070 100644
--- a/tools/libs/light/libxl_9pfs.c
+++ b/tools/libs/light/libxl_9pfs.c
@@ -206,6 +206,22 @@ static void libxl__device_p9_add(libxl__egc *egc, uint32_t domid,
         aodev->callback(egc, aodev);
 }
 
+int libxl_device_9pfs_add(libxl_ctx *ctx, uint32_t domid, libxl_device_p9 *p9,
+                          const libxl_asyncop_how *ao_how)
+{
+    AO_CREATE(ctx, domid, ao_how);
+    libxl__ao_device *aodev;
+
+    GCNEW(aodev);
+    libxl__prepare_ao_device(ao, aodev);
+    aodev->action = LIBXL__DEVICE_ACTION_ADD;
+    aodev->callback = device_addrm_aocomplete;
+
+    libxl__device_p9_add(egc, domid, p9, aodev);
+
+    return AO_INPROGRESS;
+}
+
 #define libxl_device_p9_list NULL
 #define libxl_device_p9_compare NULL
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 24 23:45:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 24 Feb 2024 23:45:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685143.1065539 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1hs-0006oU-Dt; Sat, 24 Feb 2024 23:45:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685143.1065539; Sat, 24 Feb 2024 23:45:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1hs-0006oM-B8; Sat, 24 Feb 2024 23:45:24 +0000
Received: by outflank-mailman (input) for mailman id 685143;
 Sat, 24 Feb 2024 23:45:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1hr-0006oB-Dr
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1hr-0000z4-DC
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1hr-0008Vv-Bw
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=j8yw1MbAxXERviUUrKgcXBstYN1DqiIyEIv24YQ6CqA=; b=JktfgCT9kvZsNbH4Bjm4VoWjeI
	XS+tAEwc8G0ciIQC+0Yd2hqQ8F9Lxy0O6zuaD6C+Au9CR1PO0/cuhZrdEUvy6mY0UeqoKqxb/E9xR
	qilJgH13ru+bDRJM+o+DN6HjmDLwrPLokVdMCgMluyJpYxPCcifnlUIymotY9K9+k8jw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xenstored: mount 9pfs device in stubdom
Message-Id: <E1re1hr-0008Vv-Bw@xenbits.xenproject.org>
Date: Sat, 24 Feb 2024 23:45:23 +0000

commit 297a2587e6b5ab2edbadce90cec0d5192625973c
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 16 17:31:36 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools/xenstored: mount 9pfs device in stubdom
    
    Mount the 9pfs device in stubdom enabling it to use files.
    
    This has to happen in a worker thread in order to allow the main thread
    handling the required Xenstore accesses in parallel.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstored/core.h   |  6 ++++++
 tools/xenstored/domain.c |  2 ++
 tools/xenstored/minios.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+)

diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index f6af086f01..fe0ee90581 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -36,6 +36,8 @@
 #include "list.h"
 #include "hashtable.h"
 
+#define XENSTORE_LIB_DIR	XEN_LIB_DIR "/xenstore"
+
 #ifndef O_CLOEXEC
 #define O_CLOEXEC 0
 /* O_CLOEXEC support is needed for Live Update in the daemon case. */
@@ -399,6 +401,10 @@ void handle_special_fds(void);
 int get_socket_fd(void);
 void set_socket_fd(int fd);
 
+#ifdef __MINIOS__
+void mount_9pfs(void);
+#endif
+
 /* Close stdin/stdout/stderr to complete daemonize */
 void finish_daemonize(void);
 
diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index 1a7d5e9756..64c8fd0cc3 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -1236,6 +1236,8 @@ void stubdom_init(void)
 		barf_perror("Failed to initialize stubdom");
 
 	xenevtchn_notify(xce_handle, stubdom->port);
+
+	mount_9pfs();
 #endif
 }
 
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index 22ac8defbd..562a9b4972 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -17,10 +17,20 @@
 */
 #include <sys/types.h>
 #include <sys/mman.h>
+#include <syslog.h>
+#include "talloc.h"
 #include "core.h"
 #include "utils.h"
 #include <xen/grant_table.h>
 #include <mini-os/lib.h>
+#include <mini-os/9pfront.h>
+#include <mini-os/sched.h>
+#include <mini-os/xenbus.h>
+#include <mini-os/xmalloc.h>
+
+#define P9_STATE_PATH	"device/9pfs/0/state"
+
+static void *p9_device;
 
 void finish_daemonize(void)
 {
@@ -74,3 +84,47 @@ int get_socket_fd(void)
 void set_socket_fd(int fd)
 {
 }
+
+static void mount_thread(void *p)
+{
+	xenbus_event_queue events = NULL;
+	char *err;
+	char *dummy;
+
+	err = xenbus_watch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs", &events);
+	if (err) {
+		log("error \"%s\" when setting watch on \"%s\"\n", err,
+		    P9_STATE_PATH);
+		free(err);
+		return;
+	}
+
+	for (;;) {
+		xenbus_wait_for_watch(&events);
+
+		/*
+		 * We only care for existence of the state node.
+		 * State changes are handled in init_9pfront().
+		 */
+		err = xenbus_read(XBT_NIL, P9_STATE_PATH, &dummy);
+		if (!err)
+			break;
+		free(err);
+	}
+
+	free(dummy);
+
+	err = xenbus_unwatch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs");
+	if (err) {
+		log("error \"%s\" when unwatching \"%s\", leaking watch\n",
+		    err, P9_STATE_PATH);
+		free(err);
+	}
+
+	p9_device = init_9pfront(0, XENSTORE_LIB_DIR);
+}
+
+void mount_9pfs(void)
+{
+	create_thread("mount-9pfs", mount_thread, NULL);
+}
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 24 23:45:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 24 Feb 2024 23:45:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685144.1065543 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1i2-0006rI-FS; Sat, 24 Feb 2024 23:45:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685144.1065543; Sat, 24 Feb 2024 23:45:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1i2-0006rA-CW; Sat, 24 Feb 2024 23:45:34 +0000
Received: by outflank-mailman (input) for mailman id 685144;
 Sat, 24 Feb 2024 23:45:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1i1-0006r4-H8
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1i1-0000zF-GQ
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1i1-0008WK-Fc
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=/OXvrD0IExQobbvteDXrL2IoKjJC39yLlyDsYecQLDU=; b=JiP38Lqfr9mflCinITW/EX0/Fl
	7Z9xMj770MEm3/XmzBxHikl+9vc4BSgBOJDm9DOsRotKR4j/BkJkZkIlU+zlCrXKyRbrsylnyeCdH
	SKgevdwiNsJFELp/mfphti1cKoFjOKVtc+tUKItTaKhW+oqYw3xuFpzOFWd/1bnRl+Ck=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xenstored: add helpers for filename handling
Message-Id: <E1re1i1-0008WK-Fc@xenbits.xenproject.org>
Date: Sat, 24 Feb 2024 23:45:33 +0000

commit 93892648ffaf78a682edef48ea2d108650b3b547
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 16 17:31:37 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools/xenstored: add helpers for filename handling
    
    Add some helpers for handling filenames which might need different
    implementations between stubdom and daemon environments:
    
    - expansion of relative filenames (those are not really defined today,
      just expand them to be relative to /var/lib/xen/xenstore)
    - expansion of xenstore_daemon_rundir() (used e.g. for saving the state
      file in case of live update - needs to be unchanged in the daemon
      case, but should result in /var/lib/xen/xenstore for stubdom)
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstored/core.c      | 15 +++++++++++++--
 tools/xenstored/core.h      |  5 ++++-
 tools/xenstored/lu_daemon.c |  4 ++--
 tools/xenstored/minios.c    |  5 +++++
 tools/xenstored/posix.c     |  8 +++++++-
 5 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index 48fc787ac1..bada1ad9a2 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -63,7 +63,7 @@ char **orig_argv;
 LIST_HEAD(connections);
 int tracefd = -1;
 bool keep_orphans = false;
-char *tracefile = NULL;
+const char *tracefile = NULL;
 static struct hashtable *nodes;
 unsigned int trace_flags = TRACE_OBJ | TRACE_IO;
 
@@ -137,6 +137,17 @@ void trace_destroy(const void *data, const char *type)
 		trace("obj: DESTROY %s %p\n", type, data);
 }
 
+/*
+ * Return an absolute filename.
+ * In case of a relative filename given as input, prepend XENSTORE_LIB_DIR.
+ */
+const char *absolute_filename(const void *ctx, const char *filename)
+{
+	if (filename[0] != '/')
+		return talloc_asprintf(ctx, XENSTORE_LIB_DIR "/%s", filename);
+	return talloc_strdup(ctx, filename);
+}
+
 void close_log(void)
 {
 	if (tracefd >= 0)
@@ -2759,7 +2770,7 @@ int main(int argc, char *argv[])
 #endif
 
 	if (tracefile)
-		tracefile = talloc_strdup(NULL, tracefile);
+		tracefile = absolute_filename(NULL, tracefile);
 
 #ifndef NO_LIVE_UPDATE
 	/* Read state in case of live update. */
diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index fe0ee90581..e58779e88c 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -341,7 +341,7 @@ void close_log(void);
 extern int orig_argc;
 extern char **orig_argv;
 
-extern char *tracefile;
+extern const char *tracefile;
 extern int tracefd;
 
 /* Trace flag values must be kept in sync with trace_switches[] contents. */
@@ -405,6 +405,9 @@ void set_socket_fd(int fd);
 void mount_9pfs(void);
 #endif
 
+const char *xenstore_rundir(void);
+const char *absolute_filename(const void *ctx, const char *filename);
+
 /* Close stdin/stdout/stderr to complete daemonize */
 void finish_daemonize(void);
 
diff --git a/tools/xenstored/lu_daemon.c b/tools/xenstored/lu_daemon.c
index 71bcabadd3..6351111ab0 100644
--- a/tools/xenstored/lu_daemon.c
+++ b/tools/xenstored/lu_daemon.c
@@ -24,7 +24,7 @@ void lu_get_dump_state(struct lu_dump_state *state)
 	state->size = 0;
 
 	state->filename = talloc_asprintf(NULL, "%s/state_dump",
-					  xenstore_daemon_rundir());
+					  xenstore_rundir());
 	if (!state->filename)
 		barf("Allocation failure");
 
@@ -65,7 +65,7 @@ FILE *lu_dump_open(const void *ctx)
 	int fd;
 
 	filename = talloc_asprintf(ctx, "%s/state_dump",
-				   xenstore_daemon_rundir());
+				   xenstore_rundir());
 	if (!filename)
 		return NULL;
 
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index 562a9b4972..e70386f8c7 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -128,3 +128,8 @@ void mount_9pfs(void)
 {
 	create_thread("mount-9pfs", mount_thread, NULL);
 }
+
+const char *xenstore_rundir(void)
+{
+	return XENSTORE_LIB_DIR;
+}
diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c
index 496329dfd1..d88c82d972 100644
--- a/tools/xenstored/posix.c
+++ b/tools/xenstored/posix.c
@@ -326,9 +326,10 @@ void early_init(bool live_update, bool dofork, const char *pidfile)
 {
 	reopen_log();
 
-	/* Make sure xenstored directory exists. */
+	/* Make sure xenstored directories exist. */
 	/* Errors ignored here, will be reported when we open files */
 	mkdir(xenstore_daemon_rundir(), 0755);
+	mkdir(XENSTORE_LIB_DIR, 0755);
 
 	if (dofork) {
 		openlog("xenstored", 0, LOG_DAEMON);
@@ -406,3 +407,8 @@ void set_socket_fd(int fd)
 {
 	sock = fd;
 }
+
+const char *xenstore_rundir(void)
+{
+	return xenstore_daemon_rundir();
+}
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 24 23:45:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 24 Feb 2024 23:45:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685145.1065546 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1iC-0006us-Hx; Sat, 24 Feb 2024 23:45:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685145.1065546; Sat, 24 Feb 2024 23:45:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1iC-0006ul-FQ; Sat, 24 Feb 2024 23:45:44 +0000
Received: by outflank-mailman (input) for mailman id 685145;
 Sat, 24 Feb 2024 23:45:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1iB-0006uU-K6
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:43 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1iB-0000zf-JN
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1iB-000057-Ia
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=KkOGez76798cKz/l6sYYyGKjATLt3+tGLTes1MO2tIw=; b=lNz9LL0X6PRxHZfQS7m3HXpxne
	51WkPueoKmuVD7s9isvNrpSGWBjZxkiwPoXYxOJxcJe48764efu9uewmZiA9N4opa2EfBI4QT3Xva
	mR8DptVQkv5CMhp3h9oGAdltDwmzWFD105F3xz87ShbVMEUV1EceQgPu7vg8mZasqtV8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xenstored: support complete log capabilities in stubdom
Message-Id: <E1re1iB-000057-Ia@xenbits.xenproject.org>
Date: Sat, 24 Feb 2024 23:45:43 +0000

commit a76f8809f10f1764d4627844461906dac93e68df
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 16 17:31:38 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools/xenstored: support complete log capabilities in stubdom
    
    With 9pfs being fully available in Xenstore-stubdom now, there is no
    reason to not fully support all logging capabilities in stubdom.
    
    Open the logfile on stubdom only after the 9pfs file system has been
    mounted.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/hotplug/Linux/init.d/sysconfig.xencommons.in |  1 -
 tools/hotplug/Linux/launch-xenstore.in             |  1 +
 tools/xenstored/control.c                          | 30 +++++++++++-----------
 tools/xenstored/minios.c                           |  3 +++
 4 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
index 433e4849af..1bdd830d8a 100644
--- a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
+++ b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
@@ -58,7 +58,6 @@ XENSTORED_ARGS=
 ## Default: Not defined, tracing off
 #
 # Log xenstored messages
-# Only evaluated if XENSTORETYPE is "daemon".
 #XENSTORED_TRACE=[yes|on|1]
 
 ## Type: integer
diff --git a/tools/hotplug/Linux/launch-xenstore.in b/tools/hotplug/Linux/launch-xenstore.in
index e854ca1eb8..da4eeca7c5 100644
--- a/tools/hotplug/Linux/launch-xenstore.in
+++ b/tools/hotplug/Linux/launch-xenstore.in
@@ -98,6 +98,7 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF
 	[ -z "$XENSTORE_DOMAIN_SIZE" ] && XENSTORE_DOMAIN_SIZE=8
 	XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS --memory $XENSTORE_DOMAIN_SIZE"
 	[ -z "$XENSTORE_MAX_DOMAIN_SIZE" ] || XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS --maxmem $XENSTORE_MAX_DOMAIN_SIZE"
+	[ -z "$XENSTORED_TRACE" ] || XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS -T xenstored-trace.log"
 
 	echo -n Starting $XENSTORE_DOMAIN_KERNEL...
 	${LIBEXEC_BIN}/init-xenstore-domain $XENSTORE_DOMAIN_ARGS || exit 1
diff --git a/tools/xenstored/control.c b/tools/xenstored/control.c
index b2f64d674f..dae23a5ac0 100644
--- a/tools/xenstored/control.c
+++ b/tools/xenstored/control.c
@@ -201,19 +201,6 @@ static int do_control_quota_s(const void *ctx, struct connection *conn,
 	return EINVAL;
 }
 
-#ifdef __MINIOS__
-static int do_control_memreport(const void *ctx, struct connection *conn,
-				const char **vec, int num)
-{
-	if (num)
-		return EINVAL;
-
-	talloc_report_full(NULL, stdout);
-
-	send_ack(conn, XS_CONTROL);
-	return 0;
-}
-#else
 static int do_control_logfile(const void *ctx, struct connection *conn,
 			      const char **vec, int num)
 {
@@ -222,13 +209,26 @@ static int do_control_logfile(const void *ctx, struct connection *conn,
 
 	close_log();
 	talloc_free(tracefile);
-	tracefile = talloc_strdup(NULL, vec[0]);
+	tracefile = absolute_filename(NULL, vec[0]);
 	reopen_log();
 
 	send_ack(conn, XS_CONTROL);
 	return 0;
 }
 
+#ifdef __MINIOS__
+static int do_control_memreport(const void *ctx, struct connection *conn,
+				const char **vec, int num)
+{
+	if (num)
+		return EINVAL;
+
+	talloc_report_full(NULL, stdout);
+
+	send_ack(conn, XS_CONTROL);
+	return 0;
+}
+#else
 static int do_control_memreport(const void *ctx, struct connection *conn,
 				const char **vec, int num)
 {
@@ -309,10 +309,10 @@ static struct cmd_s cmds[] = {
 		"[-c <cmdline>] [-F] [-t <timeout>] <file>\n"
 		"    Default timeout is 60 seconds.", 5 },
 #endif
+	{ "logfile", do_control_logfile, "<file>" },
 #ifdef __MINIOS__
 	{ "memreport", do_control_memreport, "" },
 #else
-	{ "logfile", do_control_logfile, "<file>" },
 	{ "memreport", do_control_memreport, "[<file>]" },
 #endif
 	{ "print", do_control_print, "<string>" },
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index e70386f8c7..a229954cf4 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -122,6 +122,9 @@ static void mount_thread(void *p)
 	}
 
 	p9_device = init_9pfront(0, XENSTORE_LIB_DIR);
+
+	/* Start logging if selected. */
+	reopen_log();
 }
 
 void mount_9pfs(void)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 24 23:45:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 24 Feb 2024 23:45:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685146.1065550 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1iM-0006xM-JJ; Sat, 24 Feb 2024 23:45:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685146.1065550; Sat, 24 Feb 2024 23:45:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1iM-0006xF-Gq; Sat, 24 Feb 2024 23:45:54 +0000
Received: by outflank-mailman (input) for mailman id 685146;
 Sat, 24 Feb 2024 23:45:53 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1iL-0006x3-NI
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:53 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1iL-0000zq-Md
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:53 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1iL-00005c-La
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:45:53 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=RwRFJzbCY/svj6Mu/5Z5ESnLQKdDxJlQtpqxE4H0Q6g=; b=SxxsntQQPwDeXxDAyUplRXah8n
	qHyMe8LGmwsosfpYkGBNpdP0nx9yfoWfMPKSVKXrYvXbcHyATfbYpACiX6Ey7I39l1wy4WSbUzCkB
	MXKG3xlDBoaw5rcVKFC4lEQjOYstALadwqPJQ+jlsHBc5wTwvnVYl7PGv6yGjo7JrGzc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xenstored: have a single do_control_memreport()
Message-Id: <E1re1iL-00005c-La@xenbits.xenproject.org>
Date: Sat, 24 Feb 2024 23:45:53 +0000

commit f5e1c527d0a0d09ca0cb1dcd8d4ab4a1a5261e91
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri Feb 16 17:31:39 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 17:43:06 2024 +0000

    tools/xenstored: have a single do_control_memreport()
    
    With 9pfs now available in Xenstore-stubdom, there is no reason to
    have distinct do_control_memreport() variants for the daemon and the
    stubdom implementations.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/xenstored/control.c | 27 +++++++--------------------
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/tools/xenstored/control.c b/tools/xenstored/control.c
index dae23a5ac0..9561289179 100644
--- a/tools/xenstored/control.c
+++ b/tools/xenstored/control.c
@@ -216,23 +216,11 @@ static int do_control_logfile(const void *ctx, struct connection *conn,
 	return 0;
 }
 
-#ifdef __MINIOS__
-static int do_control_memreport(const void *ctx, struct connection *conn,
-				const char **vec, int num)
-{
-	if (num)
-		return EINVAL;
-
-	talloc_report_full(NULL, stdout);
-
-	send_ack(conn, XS_CONTROL);
-	return 0;
-}
-#else
 static int do_control_memreport(const void *ctx, struct connection *conn,
 				const char **vec, int num)
 {
 	FILE *fp;
+	const char *filename;
 	int fd;
 
 	if (num > 1)
@@ -255,8 +243,12 @@ static int do_control_memreport(const void *ctx, struct connection *conn,
 			if (!fp)
 				close(fd);
 		}
-	} else
-		fp = fopen(vec[0], "a");
+	} else {
+		filename = absolute_filename(ctx, vec[0]);
+		if (!filename)
+			return ENOMEM;
+		fp = fopen(filename, "a");
+	}
 
 	if (!fp)
 		return EBADF;
@@ -267,7 +259,6 @@ static int do_control_memreport(const void *ctx, struct connection *conn,
 	send_ack(conn, XS_CONTROL);
 	return 0;
 }
-#endif
 
 static int do_control_print(const void *ctx, struct connection *conn,
 			    const char **vec, int num)
@@ -310,11 +301,7 @@ static struct cmd_s cmds[] = {
 		"    Default timeout is 60 seconds.", 5 },
 #endif
 	{ "logfile", do_control_logfile, "<file>" },
-#ifdef __MINIOS__
-	{ "memreport", do_control_memreport, "" },
-#else
 	{ "memreport", do_control_memreport, "[<file>]" },
-#endif
 	{ "print", do_control_print, "<string>" },
 	{ "quota", do_control_quota,
 		"[set <name> <val>|<domid>|max [-r]]" },
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Feb 24 23:46:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 24 Feb 2024 23:46:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685147.1065555 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1iW-000706-LY; Sat, 24 Feb 2024 23:46:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685147.1065555; Sat, 24 Feb 2024 23:46:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1re1iW-0006zw-IO; Sat, 24 Feb 2024 23:46:04 +0000
Received: by outflank-mailman (input) for mailman id 685147;
 Sat, 24 Feb 2024 23:46:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1iV-0006zm-QY
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:46:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1iV-00010G-Po
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:46:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1re1iV-00006w-P3
 for xen-changelog@lists.xenproject.org; Sat, 24 Feb 2024 23:46:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=9g17gl0Uk9TVROBvzpsJVDamTIYlNfGu1fs1I7sVqwI=; b=nNrMkQ0+x5yGvswLZdX0+Rs/P5
	Kqbte041imQNGBWrIyzT25uvqW4OUSHmYr4b1Nlt5lWID2F3jj+LU87U+Xs7bBAZYbqKUf62W5s5o
	MQRUyf1nYApITYdAVuSNNvjzLFeXRb4WqwjNBCBV6isqReaGOHTbQ9EIb2BaxT63TMM0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] Revert stubdom+xenstore 9pfs changes
Message-Id: <E1re1iV-00006w-P3@xenbits.xenproject.org>
Date: Sat, 24 Feb 2024 23:46:03 +0000

commit 92babc88f67ed0ef3dc575a8b9534040274678ee
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Feb 23 18:49:33 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Feb 23 18:51:10 2024 +0000

    Revert stubdom+xenstore 9pfs changes
    
    to unblock CI.  It turns out there are still issues in some configurations.
    
    https://gitlab.com/xen-project/xen/-/pipelines/1188660609
    
    This reverts commit f5e1c527d0a0d09ca0cb1dcd8d4ab4a1a5261e91.
    This reverts commit a76f8809f10f1764d4627844461906dac93e68df.
    This reverts commit 93892648ffaf78a682edef48ea2d108650b3b547.
    This reverts commit 297a2587e6b5ab2edbadce90cec0d5192625973c.
    This reverts commit 0b761781c4de2e6637203d0f51273a5a1f8873df.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 stubdom/xenstore-minios.cfg                        |  2 +-
 stubdom/xenstorepvh-minios.cfg                     |  2 +-
 tools/hotplug/Linux/init.d/sysconfig.xencommons.in |  1 +
 tools/hotplug/Linux/launch-xenstore.in             |  1 -
 tools/xenstored/control.c                          | 29 +++++++---
 tools/xenstored/core.c                             | 15 +-----
 tools/xenstored/core.h                             | 11 +---
 tools/xenstored/domain.c                           |  2 -
 tools/xenstored/lu_daemon.c                        |  4 +-
 tools/xenstored/minios.c                           | 62 ----------------------
 tools/xenstored/posix.c                            |  8 +--
 11 files changed, 30 insertions(+), 107 deletions(-)

diff --git a/stubdom/xenstore-minios.cfg b/stubdom/xenstore-minios.cfg
index 239da519b9..a41704bb6b 100644
--- a/stubdom/xenstore-minios.cfg
+++ b/stubdom/xenstore-minios.cfg
@@ -3,7 +3,7 @@ CONFIG_NETFRONT=n
 CONFIG_FBFRONT=n
 CONFIG_KBDFRONT=n
 CONFIG_CONSFRONT=n
+CONFIG_XENBUS=n
 CONFIG_LWIP=n
-CONFIG_9PFRONT=y
 CONFIG_BALLOON=y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
diff --git a/stubdom/xenstorepvh-minios.cfg b/stubdom/xenstorepvh-minios.cfg
index 752b90d7d3..6af51f5753 100644
--- a/stubdom/xenstorepvh-minios.cfg
+++ b/stubdom/xenstorepvh-minios.cfg
@@ -4,7 +4,7 @@ CONFIG_NETFRONT=n
 CONFIG_FBFRONT=n
 CONFIG_KBDFRONT=n
 CONFIG_CONSFRONT=n
+CONFIG_XENBUS=n
 CONFIG_LWIP=n
-CONFIG_9PFRONT=y
 CONFIG_BALLOON=y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
diff --git a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
index 1bdd830d8a..433e4849af 100644
--- a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
+++ b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
@@ -58,6 +58,7 @@ XENSTORED_ARGS=
 ## Default: Not defined, tracing off
 #
 # Log xenstored messages
+# Only evaluated if XENSTORETYPE is "daemon".
 #XENSTORED_TRACE=[yes|on|1]
 
 ## Type: integer
diff --git a/tools/hotplug/Linux/launch-xenstore.in b/tools/hotplug/Linux/launch-xenstore.in
index da4eeca7c5..e854ca1eb8 100644
--- a/tools/hotplug/Linux/launch-xenstore.in
+++ b/tools/hotplug/Linux/launch-xenstore.in
@@ -98,7 +98,6 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF
 	[ -z "$XENSTORE_DOMAIN_SIZE" ] && XENSTORE_DOMAIN_SIZE=8
 	XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS --memory $XENSTORE_DOMAIN_SIZE"
 	[ -z "$XENSTORE_MAX_DOMAIN_SIZE" ] || XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS --maxmem $XENSTORE_MAX_DOMAIN_SIZE"
-	[ -z "$XENSTORED_TRACE" ] || XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS -T xenstored-trace.log"
 
 	echo -n Starting $XENSTORE_DOMAIN_KERNEL...
 	${LIBEXEC_BIN}/init-xenstore-domain $XENSTORE_DOMAIN_ARGS || exit 1
diff --git a/tools/xenstored/control.c b/tools/xenstored/control.c
index 9561289179..b2f64d674f 100644
--- a/tools/xenstored/control.c
+++ b/tools/xenstored/control.c
@@ -201,6 +201,19 @@ static int do_control_quota_s(const void *ctx, struct connection *conn,
 	return EINVAL;
 }
 
+#ifdef __MINIOS__
+static int do_control_memreport(const void *ctx, struct connection *conn,
+				const char **vec, int num)
+{
+	if (num)
+		return EINVAL;
+
+	talloc_report_full(NULL, stdout);
+
+	send_ack(conn, XS_CONTROL);
+	return 0;
+}
+#else
 static int do_control_logfile(const void *ctx, struct connection *conn,
 			      const char **vec, int num)
 {
@@ -209,7 +222,7 @@ static int do_control_logfile(const void *ctx, struct connection *conn,
 
 	close_log();
 	talloc_free(tracefile);
-	tracefile = absolute_filename(NULL, vec[0]);
+	tracefile = talloc_strdup(NULL, vec[0]);
 	reopen_log();
 
 	send_ack(conn, XS_CONTROL);
@@ -220,7 +233,6 @@ static int do_control_memreport(const void *ctx, struct connection *conn,
 				const char **vec, int num)
 {
 	FILE *fp;
-	const char *filename;
 	int fd;
 
 	if (num > 1)
@@ -243,12 +255,8 @@ static int do_control_memreport(const void *ctx, struct connection *conn,
 			if (!fp)
 				close(fd);
 		}
-	} else {
-		filename = absolute_filename(ctx, vec[0]);
-		if (!filename)
-			return ENOMEM;
-		fp = fopen(filename, "a");
-	}
+	} else
+		fp = fopen(vec[0], "a");
 
 	if (!fp)
 		return EBADF;
@@ -259,6 +267,7 @@ static int do_control_memreport(const void *ctx, struct connection *conn,
 	send_ack(conn, XS_CONTROL);
 	return 0;
 }
+#endif
 
 static int do_control_print(const void *ctx, struct connection *conn,
 			    const char **vec, int num)
@@ -300,8 +309,12 @@ static struct cmd_s cmds[] = {
 		"[-c <cmdline>] [-F] [-t <timeout>] <file>\n"
 		"    Default timeout is 60 seconds.", 5 },
 #endif
+#ifdef __MINIOS__
+	{ "memreport", do_control_memreport, "" },
+#else
 	{ "logfile", do_control_logfile, "<file>" },
 	{ "memreport", do_control_memreport, "[<file>]" },
+#endif
 	{ "print", do_control_print, "<string>" },
 	{ "quota", do_control_quota,
 		"[set <name> <val>|<domid>|max [-r]]" },
diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index bada1ad9a2..48fc787ac1 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -63,7 +63,7 @@ char **orig_argv;
 LIST_HEAD(connections);
 int tracefd = -1;
 bool keep_orphans = false;
-const char *tracefile = NULL;
+char *tracefile = NULL;
 static struct hashtable *nodes;
 unsigned int trace_flags = TRACE_OBJ | TRACE_IO;
 
@@ -137,17 +137,6 @@ void trace_destroy(const void *data, const char *type)
 		trace("obj: DESTROY %s %p\n", type, data);
 }
 
-/*
- * Return an absolute filename.
- * In case of a relative filename given as input, prepend XENSTORE_LIB_DIR.
- */
-const char *absolute_filename(const void *ctx, const char *filename)
-{
-	if (filename[0] != '/')
-		return talloc_asprintf(ctx, XENSTORE_LIB_DIR "/%s", filename);
-	return talloc_strdup(ctx, filename);
-}
-
 void close_log(void)
 {
 	if (tracefd >= 0)
@@ -2770,7 +2759,7 @@ int main(int argc, char *argv[])
 #endif
 
 	if (tracefile)
-		tracefile = absolute_filename(NULL, tracefile);
+		tracefile = talloc_strdup(NULL, tracefile);
 
 #ifndef NO_LIVE_UPDATE
 	/* Read state in case of live update. */
diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index e58779e88c..f6af086f01 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -36,8 +36,6 @@
 #include "list.h"
 #include "hashtable.h"
 
-#define XENSTORE_LIB_DIR	XEN_LIB_DIR "/xenstore"
-
 #ifndef O_CLOEXEC
 #define O_CLOEXEC 0
 /* O_CLOEXEC support is needed for Live Update in the daemon case. */
@@ -341,7 +339,7 @@ void close_log(void);
 extern int orig_argc;
 extern char **orig_argv;
 
-extern const char *tracefile;
+extern char *tracefile;
 extern int tracefd;
 
 /* Trace flag values must be kept in sync with trace_switches[] contents. */
@@ -401,13 +399,6 @@ void handle_special_fds(void);
 int get_socket_fd(void);
 void set_socket_fd(int fd);
 
-#ifdef __MINIOS__
-void mount_9pfs(void);
-#endif
-
-const char *xenstore_rundir(void);
-const char *absolute_filename(const void *ctx, const char *filename);
-
 /* Close stdin/stdout/stderr to complete daemonize */
 void finish_daemonize(void);
 
diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index 64c8fd0cc3..1a7d5e9756 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -1236,8 +1236,6 @@ void stubdom_init(void)
 		barf_perror("Failed to initialize stubdom");
 
 	xenevtchn_notify(xce_handle, stubdom->port);
-
-	mount_9pfs();
 #endif
 }
 
diff --git a/tools/xenstored/lu_daemon.c b/tools/xenstored/lu_daemon.c
index 6351111ab0..71bcabadd3 100644
--- a/tools/xenstored/lu_daemon.c
+++ b/tools/xenstored/lu_daemon.c
@@ -24,7 +24,7 @@ void lu_get_dump_state(struct lu_dump_state *state)
 	state->size = 0;
 
 	state->filename = talloc_asprintf(NULL, "%s/state_dump",
-					  xenstore_rundir());
+					  xenstore_daemon_rundir());
 	if (!state->filename)
 		barf("Allocation failure");
 
@@ -65,7 +65,7 @@ FILE *lu_dump_open(const void *ctx)
 	int fd;
 
 	filename = talloc_asprintf(ctx, "%s/state_dump",
-				   xenstore_rundir());
+				   xenstore_daemon_rundir());
 	if (!filename)
 		return NULL;
 
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index a229954cf4..22ac8defbd 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -17,20 +17,10 @@
 */
 #include <sys/types.h>
 #include <sys/mman.h>
-#include <syslog.h>
-#include "talloc.h"
 #include "core.h"
 #include "utils.h"
 #include <xen/grant_table.h>
 #include <mini-os/lib.h>
-#include <mini-os/9pfront.h>
-#include <mini-os/sched.h>
-#include <mini-os/xenbus.h>
-#include <mini-os/xmalloc.h>
-
-#define P9_STATE_PATH	"device/9pfs/0/state"
-
-static void *p9_device;
 
 void finish_daemonize(void)
 {
@@ -84,55 +74,3 @@ int get_socket_fd(void)
 void set_socket_fd(int fd)
 {
 }
-
-static void mount_thread(void *p)
-{
-	xenbus_event_queue events = NULL;
-	char *err;
-	char *dummy;
-
-	err = xenbus_watch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs", &events);
-	if (err) {
-		log("error \"%s\" when setting watch on \"%s\"\n", err,
-		    P9_STATE_PATH);
-		free(err);
-		return;
-	}
-
-	for (;;) {
-		xenbus_wait_for_watch(&events);
-
-		/*
-		 * We only care for existence of the state node.
-		 * State changes are handled in init_9pfront().
-		 */
-		err = xenbus_read(XBT_NIL, P9_STATE_PATH, &dummy);
-		if (!err)
-			break;
-		free(err);
-	}
-
-	free(dummy);
-
-	err = xenbus_unwatch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs");
-	if (err) {
-		log("error \"%s\" when unwatching \"%s\", leaking watch\n",
-		    err, P9_STATE_PATH);
-		free(err);
-	}
-
-	p9_device = init_9pfront(0, XENSTORE_LIB_DIR);
-
-	/* Start logging if selected. */
-	reopen_log();
-}
-
-void mount_9pfs(void)
-{
-	create_thread("mount-9pfs", mount_thread, NULL);
-}
-
-const char *xenstore_rundir(void)
-{
-	return XENSTORE_LIB_DIR;
-}
diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c
index d88c82d972..496329dfd1 100644
--- a/tools/xenstored/posix.c
+++ b/tools/xenstored/posix.c
@@ -326,10 +326,9 @@ void early_init(bool live_update, bool dofork, const char *pidfile)
 {
 	reopen_log();
 
-	/* Make sure xenstored directories exist. */
+	/* Make sure xenstored directory exists. */
 	/* Errors ignored here, will be reported when we open files */
 	mkdir(xenstore_daemon_rundir(), 0755);
-	mkdir(XENSTORE_LIB_DIR, 0755);
 
 	if (dofork) {
 		openlog("xenstored", 0, LOG_DAEMON);
@@ -407,8 +406,3 @@ void set_socket_fd(int fd)
 {
 	sock = fd;
 }
-
-const char *xenstore_rundir(void)
-{
-	return xenstore_daemon_rundir();
-}
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 09:22:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 09:22:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685375.1065949 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reXBV-0003nn-MV; Mon, 26 Feb 2024 09:22:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685375.1065949; Mon, 26 Feb 2024 09:22:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reXBV-0003nf-Jx; Mon, 26 Feb 2024 09:22:05 +0000
Received: by outflank-mailman (input) for mailman id 685375;
 Mon, 26 Feb 2024 09:22:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXBT-0003nZ-WB
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXBT-0008Ij-Sm
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXBT-0008Cs-QL
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=jE3OtW58PZ2+RgQUSSf1OoLSXBjkGNI6EpimDHj16kA=; b=5JsgxvxhlH4qcIMBDjqgCp/1Dd
	gpbzG/yVbjCyFhl0z2D8ix/KJSbqZsbHavNaOu4qOtm8uS7sK4ngKIUuRZxzlM4gy3RFbcpB2vO6n
	Kl8hXyl4ghs3f7ae6DQJzAg1WGy0vTjbibrF0BmNXCLr0+8dwiB3nnXePt8aPLNLS2rw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/livepatch: fix norevert test hook setup typo
Message-Id: <E1reXBT-0008Cs-QL@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 09:22:03 +0000

commit f0622dd4fd6ae6ddb523a45d89ed9b8f3a9a8f36
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon Feb 26 10:13:46 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 10:13:46 2024 +0100

    xen/livepatch: fix norevert test hook setup typo
    
    The test code has a typo in using LIVEPATCH_APPLY_HOOK() instead of
    LIVEPATCH_REVERT_HOOK().
    
    Fixes: 6047104c3ccc ('livepatch: Add per-function applied/reverted state tracking marker')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 xen/test/livepatch/xen_action_hooks_norevert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/test/livepatch/xen_action_hooks_norevert.c b/xen/test/livepatch/xen_action_hooks_norevert.c
index 3e21ade6ab..c173855192 100644
--- a/xen/test/livepatch/xen_action_hooks_norevert.c
+++ b/xen/test/livepatch/xen_action_hooks_norevert.c
@@ -120,7 +120,7 @@ static void post_revert_hook(livepatch_payload_t *payload)
     printk(KERN_DEBUG "%s: Hook done.\n", __func__);
 }
 
-LIVEPATCH_APPLY_HOOK(revert_hook);
+LIVEPATCH_REVERT_HOOK(revert_hook);
 
 LIVEPATCH_PREAPPLY_HOOK(pre_apply_hook);
 LIVEPATCH_POSTAPPLY_HOOK(post_apply_hook);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 09:22:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 09:22:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685376.1065953 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reXBf-0003ph-O2; Mon, 26 Feb 2024 09:22:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685376.1065953; Mon, 26 Feb 2024 09:22:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reXBf-0003pZ-LO; Mon, 26 Feb 2024 09:22:15 +0000
Received: by outflank-mailman (input) for mailman id 685376;
 Mon, 26 Feb 2024 09:22:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXBe-0003pJ-2F
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXBe-0008Ir-1N
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXBd-0008F3-Uu
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=rlw/oukS/Zu1JUoW4fOgFGfT+OnbrqDzh7WqhLGaduk=; b=zSN11cHJa9JnFq8KQEww8s0Ree
	pTml8wIXv4EzSwHkD+0X5kczkCm3jI5NNCoMs2gjigps2CrpL5TKn7vB5MK9kG5P1vK+DEec6UWdp
	2RXRruXt/fQagS47RvbDsqhu7zuMDEeHqvSoZsDe+cMn2E17V5IEKMnCRnUpD2j1Hxp4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/hpet: use an atomic add instead of a cmpxchg loop
Message-Id: <E1reXBd-0008F3-Uu@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 09:22:13 +0000

commit f49fb70d3d4c1729fce825f0fda6863ac3ec00e0
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Feb 26 10:16:56 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 10:16:56 2024 +0100

    x86/hpet: use an atomic add instead of a cmpxchg loop
    
    The usage of a cmpxchg loop in hpet_get_channel() is unnecessary, as the same
    can be achieved with an atomic increment, which is both simpler to read, and
    avoid any need for a loop.
    
    Note there can be a small divergence in the channel returned if next_channel
    overflows, but returned channel will always be in the [0, num_hpets_used)
    range, and that's fine for the purpose of balancing HPET channels across CPUs.
    
    Signed-of-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/x86/hpet.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/xen/arch/x86/hpet.c b/xen/arch/x86/hpet.c
index d9e9c8ffa3..0759eae055 100644
--- a/xen/arch/x86/hpet.c
+++ b/xen/arch/x86/hpet.c
@@ -457,11 +457,7 @@ static struct hpet_event_channel *hpet_get_channel(unsigned int cpu)
     if ( num_hpets_used >= nr_cpu_ids )
         return &hpet_events[cpu];
 
-    do {
-        next = next_channel;
-        if ( (i = next + 1) == num_hpets_used )
-            i = 0;
-    } while ( cmpxchg(&next_channel, next, i) != next );
+    next = arch_fetch_and_add(&next_channel, 1) % num_hpets_used;
 
     /* try unused channel first */
     for ( i = next; i < next + num_hpets_used; i++ )
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 09:22:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 09:22:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685377.1065957 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reXBo-0003sB-PS; Mon, 26 Feb 2024 09:22:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685377.1065957; Mon, 26 Feb 2024 09:22:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reXBo-0003s3-Mj; Mon, 26 Feb 2024 09:22:24 +0000
Received: by outflank-mailman (input) for mailman id 685377;
 Mon, 26 Feb 2024 09:22:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXBo-0003rv-5D
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXBo-0008J3-4U
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXBo-0008Fc-3W
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:24 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=UUsS75/16gX8S3vgWj1jHoYNafWRS/rp8ToigEfL5Mk=; b=e5UBJq/Hy5rmF68iHr5c7TaV3R
	naeWmnOfZs0wQIiuMuHjSIFXRHTuhCVTHNdB6aNxXWaX+Ao4sOBuXxo/3d8m5qYap2TJhvP5L+cAW
	2VqGnOZuSmXrJGi9oLRx81Lw+vPyTYE0yE3AZvVAKep0M8/KEdyc9KcOs0uOMSTrhx+U=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/consoled: drop return value from consoled_guest_rx/tx
Message-Id: <E1reXBo-0008Fc-3W@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 09:22:24 +0000

commit 001d7fdb5512d4298d92f20cf30dd49939754403
Author:     Nicola Vetrini <nicola.vetrini@bugseng.com>
AuthorDate: Mon Feb 26 10:17:17 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 10:17:17 2024 +0100

    xen/consoled: drop return value from consoled_guest_rx/tx
    
    These functions never saw a usage of their return value since
    they were introduced, so it can be dropped since their usages
    violate MISRA C Rule 17.7:
    "The value returned by a function having non-void return type shall be used".
    
    No functional change.
    
    Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
 xen/drivers/char/consoled.c | 17 +++++------------
 xen/include/xen/consoled.h  |  4 ++--
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/xen/drivers/char/consoled.c b/xen/drivers/char/consoled.c
index 222e018442..b415b632ce 100644
--- a/xen/drivers/char/consoled.c
+++ b/xen/drivers/char/consoled.c
@@ -43,13 +43,13 @@ struct xencons_interface *consoled_get_ring_addr(void)
 static char buf[BUF_SZ + 1];
 
 /* Receives characters from a domain's PV console */
-size_t consoled_guest_rx(void)
+void consoled_guest_rx(void)
 {
-    size_t recv = 0, idx = 0;
+    size_t idx = 0;
     XENCONS_RING_IDX cons, prod;
 
     if ( !cons_ring )
-        return 0;
+        return;
 
     spin_lock(&rx_lock);
 
@@ -73,7 +73,6 @@ size_t consoled_guest_rx(void)
         char c = cons_ring->out[MASK_XENCONS_IDX(cons++, cons_ring->out)];
 
         buf[idx++] = c;
-        recv++;
 
         if ( idx >= BUF_SZ )
         {
@@ -92,18 +91,15 @@ size_t consoled_guest_rx(void)
 
  out:
     spin_unlock(&rx_lock);
-
-    return recv;
 }
 
 /* Sends a character into a domain's PV console */
-size_t consoled_guest_tx(char c)
+void consoled_guest_tx(char c)
 {
-    size_t sent = 0;
     XENCONS_RING_IDX cons, prod;
 
     if ( !cons_ring )
-        return 0;
+        return;
 
     cons = ACCESS_ONCE(cons_ring->in_cons);
     prod = cons_ring->in_prod;
@@ -121,7 +117,6 @@ size_t consoled_guest_tx(char c)
         goto notify;
 
     cons_ring->in[MASK_XENCONS_IDX(prod++, cons_ring->in)] = c;
-    sent++;
 
     /* Write to the ring before updating the pointer */
     smp_wmb();
@@ -130,8 +125,6 @@ size_t consoled_guest_tx(char c)
  notify:
     /* Always notify the guest: prevents receive path from getting stuck. */
     pv_shim_inject_evtchn(pv_console_evtchn());
-
-    return sent;
 }
 
 /*
diff --git a/xen/include/xen/consoled.h b/xen/include/xen/consoled.h
index 2b30516b3a..bd7ab6329e 100644
--- a/xen/include/xen/consoled.h
+++ b/xen/include/xen/consoled.h
@@ -5,8 +5,8 @@
 
 void consoled_set_ring_addr(struct xencons_interface *ring);
 struct xencons_interface *consoled_get_ring_addr(void);
-size_t consoled_guest_rx(void);
-size_t consoled_guest_tx(char c);
+void consoled_guest_rx(void);
+void consoled_guest_tx(char c);
 
 #endif /* __XEN_CONSOLED_H__ */
 /*
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 09:22:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 09:22:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685378.1065961 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reXBy-0003uv-Qt; Mon, 26 Feb 2024 09:22:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685378.1065961; Mon, 26 Feb 2024 09:22:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reXBy-0003up-OD; Mon, 26 Feb 2024 09:22:34 +0000
Received: by outflank-mailman (input) for mailman id 685378;
 Mon, 26 Feb 2024 09:22:34 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXBy-0003ub-87
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXBy-0008JG-7O
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXBy-0008GE-6Z
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:34 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=i1nNF0/dRzc+Q0nw6bH7SaPzwb/BG+uskWdjV84IAik=; b=6EYKYj5dor6isB4o2iwjfqir1j
	zIgFNFcjk18Y7eibSQifGYFsyPj+vVo77CfyvcathCyrki4xY9F/i7QqXELp84XHwLxYS+B8DVWQp
	p37w1UWq5Jb6Du+VSOf0RRSdpCszbrFGC5EW8btINkdmIPRb8OiVbmDIOBX+6bwQ6Oh4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/cmdline: fix printf format specifier in no_config_param()
Message-Id: <E1reXBy-0008GE-6Z@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 09:22:34 +0000

commit ef101f525173cf51dc70f4c77862f6f10a8ddccf
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon Feb 26 10:17:40 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 10:17:40 2024 +0100

    xen/cmdline: fix printf format specifier in no_config_param()
    
    '*' sets the width field, which is the minimum number of characters to output,
    but what we want in no_config_param() is the precision instead, which is '.*'
    as it imposes a maximum limit on the output.
    
    Fixes: 68d757df8dd2 ('x86/pv: Options to disable and/or compile out 32bit PV support')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/include/xen/param.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/include/xen/param.h b/xen/include/xen/param.h
index 9170455cde..6442a92aff 100644
--- a/xen/include/xen/param.h
+++ b/xen/include/xen/param.h
@@ -191,7 +191,7 @@ static inline void no_config_param(const char *cfg, const char *param,
 {
     int len = e ? ({ ASSERT(e >= s); e - s; }) : strlen(s);
 
-    printk(XENLOG_INFO "CONFIG_%s disabled - ignoring '%s=%*s' setting\n",
+    printk(XENLOG_INFO "CONFIG_%s disabled - ignoring '%s=%.*s' setting\n",
            cfg, param, len, s);
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 09:22:45 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 09:22:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685379.1065965 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reXC9-0003yI-SS; Mon, 26 Feb 2024 09:22:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685379.1065965; Mon, 26 Feb 2024 09:22:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reXC9-0003yA-Pj; Mon, 26 Feb 2024 09:22:45 +0000
Received: by outflank-mailman (input) for mailman id 685379;
 Mon, 26 Feb 2024 09:22:45 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXC9-0003y4-6U
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:45 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXC8-0008JR-AR
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:44 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXC8-0008Gq-9U
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:44 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=QRFSh3vQbd8aKeKykled19WzF1Fcu1Ywtj/LixS0c5k=; b=Cut9fuRkW5HKhCPGkwUmzAlLjW
	pD8oGi6xTxGqFtUw4F9sTs9SNvaIk/Ij6p79a1wUxdcBjHbeHEjzNQ+QCRj9i/nZVaVBI6PRbEpo3
	lIWHdN23XqVWMUqT3O1LfXSEOHyJUL8LiDdFdn0bYA2sF5hOSqqXYzrkzEhkx4fHW7YA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/altcall: use a union as register type for function parameters on clang
Message-Id: <E1reXC8-0008Gq-9U@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 09:22:44 +0000

commit 2ce562b2a413cbdb2e1128989ed1722290a27c4e
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon Feb 26 10:18:01 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 10:18:01 2024 +0100

    x86/altcall: use a union as register type for function parameters on clang
    
    The current code for alternative calls uses the caller parameter types as the
    types for the register variables that serve as function parameters:
    
    uint8_t foo;
    [...]
    alternative_call(myfunc, foo);
    
    Would expand roughly into:
    
    register unint8_t a1_ asm("rdi") = foo;
    register unsigned long a2_ asm("rsi");
    [...]
    asm volatile ("call *%c[addr](%%rip)"...);
    
    However with -O2 clang will generate incorrect code, given the following
    example:
    
    unsigned int func(uint8_t t)
    {
        return t;
    }
    
    static void bar(uint8_t b)
    {
        int ret_;
        register uint8_t di asm("rdi") = b;
        register unsigned long si asm("rsi");
        register unsigned long dx asm("rdx");
        register unsigned long cx asm("rcx");
        register unsigned long r8 asm("r8");
        register unsigned long r9 asm("r9");
        register unsigned long r10 asm("r10");
        register unsigned long r11 asm("r11");
    
        asm volatile ( "call %c[addr]"
                       : "+r" (di), "=r" (si), "=r" (dx),
                         "=r" (cx), "=r" (r8), "=r" (r9),
                         "=r" (r10), "=r" (r11), "=a" (ret_)
                       : [addr] "i" (&(func)), "g" (func)
                       : "memory" );
    }
    
    void foo(unsigned int a)
    {
        bar(a);
    }
    
    Clang generates the following assembly code:
    
    func:                                   # @func
            movl    %edi, %eax
            retq
    foo:                                    # @foo
            callq   func
            retq
    
    Note the truncation of the unsigned int parameter 'a' of foo() to uint8_t when
    passed into bar() is lost.  clang doesn't zero extend the parameters in the
    callee when required, as the psABI mandates.
    
    The above can be worked around by using a union when defining the register
    variables, so that `di` becomes:
    
    register union {
        uint8_t e;
        unsigned long r;
    } di asm("rdi") = { .e = b };
    
    Which results in following code generated for `foo()`:
    
    foo:                                    # @foo
            movzbl  %dil, %edi
            callq   func
            retq
    
    So the truncation is not longer lost.  Apply such workaround only when built
    with clang.
    
    Reported-by: Matthew Grooms <mgrooms@shrew.net>
    Link: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277200
    Link: https://github.com/llvm/llvm-project/issues/12579
    Link: https://github.com/llvm/llvm-project/issues/82598
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/include/asm/alternative.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/xen/arch/x86/include/asm/alternative.h b/xen/arch/x86/include/asm/alternative.h
index a1cd6a9fe5..3c14db5078 100644
--- a/xen/arch/x86/include/asm/alternative.h
+++ b/xen/arch/x86/include/asm/alternative.h
@@ -167,9 +167,34 @@ extern void alternative_branches(void);
 #define ALT_CALL_arg5 "r8"
 #define ALT_CALL_arg6 "r9"
 
+#ifdef CONFIG_CC_IS_CLANG
+/*
+ * Use a union with an unsigned long in order to prevent clang from
+ * skipping a possible truncation of the value.  By using the union any
+ * truncation is carried before the call instruction, in turn covering
+ * for ABI-non-compliance in that the necessary clipping / extension of
+ * the value is supposed to be carried out in the callee.
+ *
+ * Note this behavior is not mandated by the standard, and hence could
+ * stop being a viable workaround, or worse, could cause a different set
+ * of code-generation issues in future clang versions.
+ *
+ * This has been reported upstream:
+ * https://github.com/llvm/llvm-project/issues/12579
+ * https://github.com/llvm/llvm-project/issues/82598
+ */
+#define ALT_CALL_ARG(arg, n)                                            \
+    register union {                                                    \
+        typeof(arg) e;                                                  \
+        unsigned long r;                                                \
+    } a ## n ## _ asm ( ALT_CALL_arg ## n ) = {                         \
+        .e = ({ BUILD_BUG_ON(sizeof(arg) > sizeof(void *)); (arg); })   \
+    }
+#else
 #define ALT_CALL_ARG(arg, n) \
     register typeof(arg) a ## n ## _ asm ( ALT_CALL_arg ## n ) = \
         ({ BUILD_BUG_ON(sizeof(arg) > sizeof(void *)); (arg); })
+#endif
 #define ALT_CALL_NO_ARG(n) \
     register unsigned long a ## n ## _ asm ( ALT_CALL_arg ## n )
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 09:22:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 09:22:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685380.1065968 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reXCI-00040r-Tw; Mon, 26 Feb 2024 09:22:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685380.1065968; Mon, 26 Feb 2024 09:22:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reXCI-00040j-RB; Mon, 26 Feb 2024 09:22:54 +0000
Received: by outflank-mailman (input) for mailman id 685380;
 Mon, 26 Feb 2024 09:22:54 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXCI-00040b-Gb
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:54 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXCI-0008JZ-E4
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:54 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reXCI-0008HV-DC
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 09:22:54 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=OhqNEkiHb7o7rNeiNUpG7+heMtkvIJGPWwCudpYiSbA=; b=tdU5TzNFDo4xCLBTtgZPyYtPpM
	C+J6D9ARavuFVw7klYDecF0Xy7+011M2fNKkUIuRfi1FL5lvwXSoskJUzJcBWVPQqGPHhkor1+JmR
	FmBwg4QjX4eV8OC1y6lihQBv2UpCJFvaSYMpwjaP8YuiR2u7IlWFIdsthMBSEnIb6nos=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen: move BUG_ON(), WARN_ON(), ASSERT(), ASSERT_UNREACHABLE() to xen/bug.h
Message-Id: <E1reXCI-0008HV-DC@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 09:22:54 +0000

commit 8de3afc0b402bc17f65093a53e5870862707a8c7
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Mon Feb 26 10:19:08 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 10:19:08 2024 +0100

    xen: move BUG_ON(), WARN_ON(), ASSERT(), ASSERT_UNREACHABLE() to xen/bug.h
    
    Move the macros mentioned in the commit subject to their appropriate
    locations.
    Additionally, eliminate the dependency of xen/lib.h from xen/bug.h and
    include "xen/bug.h" in files where xen/bug.h macros are utilized.
    
    Most of the changes were made because a file requires macros from xen/bug.h,
    except for some files for Arm which require definitions of BUG_OPCODE,
    BUG_INSTR, BUG_FN_REG.
    
    xen/lib.h was added to list-sort.c ( otherwise compilation errors related
    to {d}printk occur during compilation of list-sort.c. ) as xen/lib.h was
    removed from xen/list.h. Since nothing in xen/list.h depends on xen/lib.h
    functionality and only xen/bug.h is needed.
    
    cpufeature.h requires the inclusion of <xen/cache.h>;
    otherwise, the following error will occur:
    ld: common/monitor.o:/build/xen/./arch/x86/include/asm/cpufeature.h:41:
    multiple definitions of `__cacheline_aligned';
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    Acked-by: Daniel P. Smith <dpsmith@apertussolutions.com>
---
 xen/arch/arm/arm32/insn.c                |  3 ++-
 xen/arch/arm/arm64/cpufeature.c          |  1 +
 xen/arch/arm/arm64/insn.c                |  1 +
 xen/arch/arm/cpufeature.c                |  1 +
 xen/arch/arm/include/asm/arm32/cmpxchg.h |  1 +
 xen/arch/arm/include/asm/arm64/cmpxchg.h |  2 ++
 xen/arch/arm/include/asm/regs.h          |  2 +-
 xen/arch/arm/include/asm/vgic.h          |  1 +
 xen/arch/ppc/include/asm/time.h          |  2 +-
 xen/arch/x86/bitops.c                    |  2 +-
 xen/arch/x86/include/asm/cpufeature.h    |  1 +
 xen/arch/x86/include/asm/system.h        |  2 +-
 xen/arch/x86/include/asm/x86_64/page.h   |  2 ++
 xen/arch/x86/x86_emulate/private.h       |  1 +
 xen/common/efi/common-stub.c             |  2 +-
 xen/common/version.c                     |  1 +
 xen/include/public/hvm/save.h            |  2 +-
 xen/include/xen/bug.h                    | 19 +++++++++++++++++++
 xen/include/xen/cpumask.h                |  1 +
 xen/include/xen/device_tree.h            |  1 +
 xen/include/xen/lib.h                    | 19 -------------------
 xen/include/xen/list.h                   |  2 +-
 xen/include/xen/livepatch.h              |  2 ++
 xen/include/xen/mm.h                     |  1 +
 xen/include/xen/param.h                  |  1 +
 xen/lib/list-sort.c                      |  1 +
 xen/xsm/flask/ss/ebitmap.h               |  1 +
 27 files changed, 48 insertions(+), 27 deletions(-)

diff --git a/xen/arch/arm/arm32/insn.c b/xen/arch/arm/arm32/insn.c
index 49953a042a..2a62bb9cce 100644
--- a/xen/arch/arm/arm32/insn.c
+++ b/xen/arch/arm/arm32/insn.c
@@ -13,8 +13,9 @@
   * You should have received a copy of the GNU General Public License
   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
   */
-#include <xen/lib.h>
 #include <xen/bitops.h>
+#include <xen/bug.h>
+#include <xen/lib.h>
 #include <xen/sizes.h>
 #include <asm/insn.h>
 
diff --git a/xen/arch/arm/arm64/cpufeature.c b/xen/arch/arm/arm64/cpufeature.c
index b4656ff4d8..864413d9cc 100644
--- a/xen/arch/arm/arm64/cpufeature.c
+++ b/xen/arch/arm/arm64/cpufeature.c
@@ -69,6 +69,7 @@
  *   KVM guests.
  */
 
+#include <xen/bug.h>
 #include <xen/types.h>
 #include <xen/kernel.h>
 #include <asm/sysregs.h>
diff --git a/xen/arch/arm/arm64/insn.c b/xen/arch/arm/arm64/insn.c
index 22f2bdebd5..773c3749d1 100644
--- a/xen/arch/arm/arm64/insn.c
+++ b/xen/arch/arm/arm64/insn.c
@@ -18,6 +18,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
+#include <xen/bug.h>
 #include <xen/types.h>
 #include <xen/lib.h>
 #include <xen/errno.h>
diff --git a/xen/arch/arm/cpufeature.c b/xen/arch/arm/cpufeature.c
index f43d5cb338..ef77473bf8 100644
--- a/xen/arch/arm/cpufeature.c
+++ b/xen/arch/arm/cpufeature.c
@@ -5,6 +5,7 @@
  * Copyright (C) 2015 ARM Ltd.
  */
 
+#include <xen/bug.h>
 #include <xen/types.h>
 #include <xen/init.h>
 #include <xen/smp.h>
diff --git a/xen/arch/arm/include/asm/arm32/cmpxchg.h b/xen/arch/arm/include/asm/arm32/cmpxchg.h
index 37b2d64eb6..8455eb7cc3 100644
--- a/xen/arch/arm/include/asm/arm32/cmpxchg.h
+++ b/xen/arch/arm/include/asm/arm32/cmpxchg.h
@@ -1,6 +1,7 @@
 #ifndef __ASM_ARM32_CMPXCHG_H
 #define __ASM_ARM32_CMPXCHG_H
 
+#include <xen/bug.h>
 #include <xen/prefetch.h>
 
 extern void __bad_xchg(volatile void *ptr, int size);
diff --git a/xen/arch/arm/include/asm/arm64/cmpxchg.h b/xen/arch/arm/include/asm/arm64/cmpxchg.h
index 031fa6d92a..f160e8e7bc 100644
--- a/xen/arch/arm/include/asm/arm64/cmpxchg.h
+++ b/xen/arch/arm/include/asm/arm64/cmpxchg.h
@@ -1,6 +1,8 @@
 #ifndef __ASM_ARM64_CMPXCHG_H
 #define __ASM_ARM64_CMPXCHG_H
 
+#include <xen/bug.h>
+
 extern void __bad_xchg(volatile void *ptr, int size);
 
 static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
diff --git a/xen/arch/arm/include/asm/regs.h b/xen/arch/arm/include/asm/regs.h
index f998aedff5..0d9f239a77 100644
--- a/xen/arch/arm/include/asm/regs.h
+++ b/xen/arch/arm/include/asm/regs.h
@@ -5,7 +5,7 @@
 
 #ifndef __ASSEMBLY__
 
-#include <xen/lib.h>
+#include <xen/bug.h>
 #include <xen/types.h>
 #include <public/xen.h>
 #include <asm/current.h>
diff --git a/xen/arch/arm/include/asm/vgic.h b/xen/arch/arm/include/asm/vgic.h
index 922779ce14..79b73a0dbb 100644
--- a/xen/arch/arm/include/asm/vgic.h
+++ b/xen/arch/arm/include/asm/vgic.h
@@ -22,6 +22,7 @@
 #include <asm/new_vgic.h>
 #else
 
+#include <xen/bug.h>
 #include <xen/radix-tree.h>
 #include <xen/rbtree.h>
 
diff --git a/xen/arch/ppc/include/asm/time.h b/xen/arch/ppc/include/asm/time.h
index aa9dda82a3..f23eec173e 100644
--- a/xen/arch/ppc/include/asm/time.h
+++ b/xen/arch/ppc/include/asm/time.h
@@ -2,7 +2,7 @@
 #ifndef __ASM_PPC_TIME_H__
 #define __ASM_PPC_TIME_H__
 
-#include <xen/lib.h>
+#include <xen/bug.h>
 #include <asm/processor.h>
 #include <asm/regs.h>
 
diff --git a/xen/arch/x86/bitops.c b/xen/arch/x86/bitops.c
index f6ee71512c..720ab32362 100644
--- a/xen/arch/x86/bitops.c
+++ b/xen/arch/x86/bitops.c
@@ -1,6 +1,6 @@
 
 #include <xen/bitops.h>
-#include <xen/lib.h>
+#include <xen/bug.h>
 
 unsigned int __find_first_bit(
     const unsigned long *addr, unsigned int size)
diff --git a/xen/arch/x86/include/asm/cpufeature.h b/xen/arch/x86/include/asm/cpufeature.h
index 896483a900..be16492c68 100644
--- a/xen/arch/x86/include/asm/cpufeature.h
+++ b/xen/arch/x86/include/asm/cpufeature.h
@@ -6,6 +6,7 @@
 #ifndef __ASM_I386_CPUFEATURE_H
 #define __ASM_I386_CPUFEATURE_H
 
+#include <xen/cache.h>
 #include <xen/const.h>
 #include <asm/cpuid.h>
 
diff --git a/xen/arch/x86/include/asm/system.h b/xen/arch/x86/include/asm/system.h
index 6e40a03cb3..debf6bfa17 100644
--- a/xen/arch/x86/include/asm/system.h
+++ b/xen/arch/x86/include/asm/system.h
@@ -1,8 +1,8 @@
 #ifndef __ASM_SYSTEM_H
 #define __ASM_SYSTEM_H
 
-#include <xen/lib.h>
 #include <xen/bitops.h>
+#include <xen/bug.h>
 #include <asm/cpufeature.h>
 #include <asm/x86-defns.h>
 
diff --git a/xen/arch/x86/include/asm/x86_64/page.h b/xen/arch/x86/include/asm/x86_64/page.h
index f49e10475f..19ca64d792 100644
--- a/xen/arch/x86/include/asm/x86_64/page.h
+++ b/xen/arch/x86/include/asm/x86_64/page.h
@@ -19,6 +19,8 @@ static inline unsigned long canonicalise_addr(unsigned long addr)
         return addr & ~CANONICAL_MASK;
 }
 
+#include <xen/bug.h>
+
 #include <xen/types.h>
 
 #include <xen/pdx.h>
diff --git a/xen/arch/x86/x86_emulate/private.h b/xen/arch/x86/x86_emulate/private.h
index 33f2870508..0fa26ba00a 100644
--- a/xen/arch/x86/x86_emulate/private.h
+++ b/xen/arch/x86/x86_emulate/private.h
@@ -8,6 +8,7 @@
 
 #ifdef __XEN__
 
+# include <xen/bug.h>
 # include <xen/kernel.h>
 # include <asm/endbr.h>
 # include <asm/msr-index.h>
diff --git a/xen/common/efi/common-stub.c b/xen/common/efi/common-stub.c
index 5a91fe28cc..77f138a6c5 100644
--- a/xen/common/efi/common-stub.c
+++ b/xen/common/efi/common-stub.c
@@ -1,6 +1,6 @@
+#include <xen/bug.h>
 #include <xen/efi.h>
 #include <xen/errno.h>
-#include <xen/lib.h>
 
 bool efi_enabled(unsigned int feature)
 {
diff --git a/xen/common/version.c b/xen/common/version.c
index e807ef4de0..80869430fc 100644
--- a/xen/common/version.c
+++ b/xen/common/version.c
@@ -1,3 +1,4 @@
+#include <xen/bug.h>
 #include <xen/compile.h>
 #include <xen/init.h>
 #include <xen/errno.h>
diff --git a/xen/include/public/hvm/save.h b/xen/include/public/hvm/save.h
index 31b5cd163b..72e16ab5bc 100644
--- a/xen/include/public/hvm/save.h
+++ b/xen/include/public/hvm/save.h
@@ -51,7 +51,7 @@ struct hvm_save_descriptor {
     struct __HVM_SAVE_TYPE_##_x { _type t; char c[_code]; char cpt[2];};  \
     struct __HVM_SAVE_TYPE_COMPAT_##_x { _ctype t; }
 
-# include <xen/lib.h> /* BUG() */
+# include <xen/bug.h> /* BUG() */
 # define DECLARE_HVM_SAVE_TYPE(_x, _code, _type)                         \
     static inline int __HVM_SAVE_FIX_COMPAT_##_x(void *h, uint32_t size) \
         { BUG(); return -1; }                                            \
diff --git a/xen/include/xen/bug.h b/xen/include/xen/bug.h
index a11d4239f8..2c45c462fc 100644
--- a/xen/include/xen/bug.h
+++ b/xen/include/xen/bug.h
@@ -16,6 +16,7 @@
 
 #ifndef __ASSEMBLY__
 
+#include <xen/compiler.h>
 #include <xen/macros.h>
 #include <xen/types.h>
 
@@ -126,6 +127,24 @@ static void always_inline run_in_exception_handler(bug_fn_t *fn)
 } while ( false )
 #endif
 
+#define BUG_ON(p)  do { if (unlikely(p)) BUG();  } while (0)
+#define WARN_ON(p)  ({                  \
+    bool ret_warn_on_ = (p);            \
+                                        \
+    if ( unlikely(ret_warn_on_) )       \
+        WARN();                         \
+    unlikely(ret_warn_on_);             \
+})
+
+#ifndef NDEBUG
+#define ASSERT(p) \
+    do { if ( unlikely(!(p)) ) assert_failed(#p); } while (0)
+#define ASSERT_UNREACHABLE() assert_failed("unreachable")
+#else
+#define ASSERT(p) do { if ( 0 && (p) ) {} } while (0)
+#define ASSERT_UNREACHABLE() do { } while (0)
+#endif
+
 #ifdef CONFIG_GENERIC_BUG_FRAME
 
 /*
diff --git a/xen/include/xen/cpumask.h b/xen/include/xen/cpumask.h
index 145e140481..b713bb69a9 100644
--- a/xen/include/xen/cpumask.h
+++ b/xen/include/xen/cpumask.h
@@ -56,6 +56,7 @@
  */
 
 #include <xen/bitmap.h>
+#include <xen/bug.h>
 #include <xen/kernel.h>
 #include <xen/random.h>
 
diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index 94a836cb4e..6fe2fa8b21 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -14,6 +14,7 @@
 #include <asm/device.h>
 #include <public/xen.h>
 #include <public/device_tree_defs.h>
+#include <xen/bug.h>
 #include <xen/kernel.h>
 #include <xen/string.h>
 #include <xen/types.h>
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index abee6c20d7..394319c818 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -5,31 +5,12 @@
 
 #ifndef __ASSEMBLY__
 
-#include <xen/bug.h>
 #include <xen/inttypes.h>
 #include <xen/stdarg.h>
 #include <xen/types.h>
 #include <xen/xmalloc.h>
 #include <xen/string.h>
 
-#define BUG_ON(p)  do { if (unlikely(p)) BUG();  } while (0)
-#define WARN_ON(p)  ({                  \
-    bool ret_warn_on_ = (p);            \
-                                        \
-    if ( unlikely(ret_warn_on_) )       \
-        WARN();                         \
-    unlikely(ret_warn_on_);             \
-})
-
-#ifndef NDEBUG
-#define ASSERT(p) \
-    do { if ( unlikely(!(p)) ) assert_failed(#p); } while (0)
-#define ASSERT_UNREACHABLE() assert_failed("unreachable")
-#else
-#define ASSERT(p) do { if ( 0 && (p) ) {} } while (0)
-#define ASSERT_UNREACHABLE() do { } while (0)
-#endif
-
 #define __ACCESS_ONCE(x) ({                             \
             (void)(typeof(x))0; /* Scalar typecheck. */ \
             (volatile typeof(x) *)&(x); })
diff --git a/xen/include/xen/list.h b/xen/include/xen/list.h
index dc5a8c461b..b5eab3a1eb 100644
--- a/xen/include/xen/list.h
+++ b/xen/include/xen/list.h
@@ -7,7 +7,7 @@
 #ifndef __XEN_LIST_H__
 #define __XEN_LIST_H__
 
-#include <xen/lib.h>
+#include <xen/bug.h>
 #include <asm/system.h>
 
 /*
diff --git a/xen/include/xen/livepatch.h b/xen/include/xen/livepatch.h
index 45df4bba4f..ad0eae28bd 100644
--- a/xen/include/xen/livepatch.h
+++ b/xen/include/xen/livepatch.h
@@ -18,6 +18,8 @@ struct xen_sysctl_livepatch_op;
 
 #ifdef CONFIG_LIVEPATCH
 
+#include <xen/lib.h>
+
 /*
  * We use alternative and exception table code - which by default are __init
  * only, however we need them during runtime. These macros allows us to build
diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
index 3d9b2d05a5..bb29b352ec 100644
--- a/xen/include/xen/mm.h
+++ b/xen/include/xen/mm.h
@@ -61,6 +61,7 @@
 #ifndef __XEN_MM_H__
 #define __XEN_MM_H__
 
+#include <xen/bug.h>
 #include <xen/compiler.h>
 #include <xen/mm-frame.h>
 #include <xen/types.h>
diff --git a/xen/include/xen/param.h b/xen/include/xen/param.h
index 6442a92aff..13607e0e50 100644
--- a/xen/include/xen/param.h
+++ b/xen/include/xen/param.h
@@ -1,6 +1,7 @@
 #ifndef _XEN_PARAM_H
 #define _XEN_PARAM_H
 
+#include <xen/bug.h>
 #include <xen/hypfs.h>
 #include <xen/init.h>
 #include <xen/lib.h>
diff --git a/xen/lib/list-sort.c b/xen/lib/list-sort.c
index de1af2ef8b..251764804c 100644
--- a/xen/lib/list-sort.c
+++ b/xen/lib/list-sort.c
@@ -15,6 +15,7 @@
  * this program; If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <xen/lib.h>
 #include <xen/list.h>
 #include <xen/list_sort.h>
 
diff --git a/xen/xsm/flask/ss/ebitmap.h b/xen/xsm/flask/ss/ebitmap.h
index bb43de891d..7b2da8179a 100644
--- a/xen/xsm/flask/ss/ebitmap.h
+++ b/xen/xsm/flask/ss/ebitmap.h
@@ -15,6 +15,7 @@
 #define _SS_EBITMAP_H_
 
 #include <xen/bitmap.h>
+#include <xen/bug.h>
 
 #define EBITMAP_UNIT_NUMS	((32 - sizeof(void *) - sizeof(u32))	\
 					/ sizeof(unsigned long))
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 15:11:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 15:11:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685606.1066597 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1recdE-00070M-LX; Mon, 26 Feb 2024 15:11:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685606.1066597; Mon, 26 Feb 2024 15:11:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1recdE-00070F-J4; Mon, 26 Feb 2024 15:11:04 +0000
Received: by outflank-mailman (input) for mailman id 685606;
 Mon, 26 Feb 2024 15:11:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1recdD-000707-EV
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 15:11:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1recdD-0006fL-C0
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 15:11:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1recdD-00051d-8u
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 15:11:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Az1TO0Tt31oKWXEMFaB8dGN2ebRFX6jO2cw5Tr7PjYo=; b=5JYt7leG6V0Mbjax2hp5wcJEa2
	a7/wlIyir71Yu/Cx15Dx58/rFN3TIQWAkWSG2wOE4ABvZVciZsSG98WL0yf7py19EPVhChIidp6bD
	sTFpR1AoREibKBxtT16NrS7nCv6fqYB3VLq+uX3lgSVvBd3mvNu1QxtuzmUtbQqDy23U=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/HVM: limit upcall vector related verbosity
Message-Id: <E1recdD-00051d-8u@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 15:11:03 +0000

commit 164daecb1834b1de5f5943abf2a0806d49470986
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Feb 26 16:03:44 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 16:03:44 2024 +0100

    x86/HVM: limit upcall vector related verbosity
    
    Avoid logging all-identical messages for every vCPU, but make sure to
    log unusual events like the vector differing from vCPU 0's (note that
    the respective condition also makes sure vCPU 0 itself will have the
    vector setting logged), or it changing after it was once set. (Arguably
    a downside is that some vCPU not having its vector set would no longer
    be recognizable from the logs. But I think that's tolerable as
    sufficiently unlikely outside of people actively fiddling with related
    code.)
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/hvm/hvm.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 0cb822a41c..87d33d116b 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4125,7 +4125,15 @@ static int hvmop_set_evtchn_upcall_vector(
     if ( (v = domain_vcpu(d, op.vcpu)) == NULL )
         return -ENOENT;
 
-    printk(XENLOG_G_INFO "%pv: upcall vector %02x\n", v, op.vector);
+    /*
+     * Avoid logging all-identical messages for every vCPU, but make sure to
+     * log unusual events like the vector differing from vCPU 0's, or it
+     * changing after it was once set
+     */
+    if ( op.vector != d->vcpu[0]->arch.hvm.evtchn_upcall_vector ||
+         (v->arch.hvm.evtchn_upcall_vector &&
+          op.vector != v->arch.hvm.evtchn_upcall_vector) )
+        printk(XENLOG_G_INFO "%pv: upcall vector %02x\n", v, op.vector);
 
     v->arch.hvm.evtchn_upcall_vector = op.vector;
     hvm_assert_evtchn_irq(v);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 15:11:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 15:11:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685607.1066601 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1recdO-00074y-Mz; Mon, 26 Feb 2024 15:11:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685607.1066601; Mon, 26 Feb 2024 15:11:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1recdO-00074r-KY; Mon, 26 Feb 2024 15:11:14 +0000
Received: by outflank-mailman (input) for mailman id 685607;
 Mon, 26 Feb 2024 15:11:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1recdN-00073O-Hq
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 15:11:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1recdN-0006ft-FE
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 15:11:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1recdN-00052K-EG
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 15:11:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=DWshcjlr/PncepDSf/MZFOH+qdj/vLjESnngGwzkgr0=; b=gDEE3AdRc0vDl0/7QqI3VvwPx+
	cqMlyXe31j7j+innQ5n9eIp7fFouvp83pEbQBJ0NoP/WlqntBGmJQPSnKKJi+UQ5DsG5MYWt7vRaU
	tOSE4V/7rcJdIMVk+GmhXRkxzIofZyLgcrSF9JSZB/BlBGIHimAVXWniAWuk3Jsf7qUs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86: Dom0 "broken ELF" reporting adjustments
Message-Id: <E1recdN-00052K-EG@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 15:11:13 +0000

commit 56a9641359a6fb6033d776212ff896d17a37c9bb
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Feb 26 16:04:45 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 16:04:45 2024 +0100

    x86: Dom0 "broken ELF" reporting adjustments
    
    elf_load_binary() isn't the primary source of brokenness being
    indicated. Therefore make the respective PVH log message there
    conditional (much like PV has it), and add another instance when
    elf_xen_parse() failed (again matching behavior in the PV case).
    
    Make the PV side match the (new) use of %pd here.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/hvm/dom0_build.c | 5 ++++-
 xen/arch/x86/pv/dom0_build.c  | 3 +--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
index e59f6657d9..0ceda4140b 100644
--- a/xen/arch/x86/hvm/dom0_build.c
+++ b/xen/arch/x86/hvm/dom0_build.c
@@ -570,6 +570,8 @@ static int __init pvh_load_kernel(struct domain *d, const module_t *image,
     if ( (rc = elf_xen_parse(&elf, &parms, true)) != 0 )
     {
         printk("Unable to parse kernel for ELFNOTES\n");
+        if ( elf_check_broken(&elf) )
+            printk("%pd kernel: broken ELF: %s\n", d, elf_check_broken(&elf));
         return rc;
     }
 
@@ -588,7 +590,8 @@ static int __init pvh_load_kernel(struct domain *d, const module_t *image,
     if ( rc < 0 )
     {
         printk("Failed to load kernel: %d\n", rc);
-        printk("Xen dom0 kernel broken ELF: %s\n", elf_check_broken(&elf));
+        if ( elf_check_broken(&elf) )
+            printk("%pd kernel: broken ELF: %s\n", d, elf_check_broken(&elf));
         return rc;
     }
 
diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c
index 16d08c6796..d8043fa58a 100644
--- a/xen/arch/x86/pv/dom0_build.c
+++ b/xen/arch/x86/pv/dom0_build.c
@@ -1044,8 +1044,7 @@ int __init dom0_construct_pv(struct domain *d,
 
 out:
     if ( elf_check_broken(&elf) )
-        printk(XENLOG_WARNING "Dom0 kernel broken ELF: %s\n",
-               elf_check_broken(&elf));
+        printk("%pd kernel: broken ELF: %s\n", d, elf_check_broken(&elf));
 
     return rc;
 }
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 15:11:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 15:11:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685610.1066607 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1recdY-0007Ap-Pr; Mon, 26 Feb 2024 15:11:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685610.1066607; Mon, 26 Feb 2024 15:11:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1recdY-0007Ai-M3; Mon, 26 Feb 2024 15:11:24 +0000
Received: by outflank-mailman (input) for mailman id 685610;
 Mon, 26 Feb 2024 15:11:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1recdX-0007AV-KX
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 15:11:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1recdX-0006gB-IE
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 15:11:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1recdX-00052u-HO
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 15:11:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=0t4hk0MKQV1M7fsQbv5gPzOJHdgzkhGX2vedyTfft3Q=; b=k5P+vqfbQ4H2uNdGUUMpPmKo+X
	pVs5U9HCwRi9mZhVKEMVPP0EaK12j6GkYPdNC0xmwM2XOpYAa7i1yj6FfFoJdyuKRM5bwC9HUmf0o
	H5WJBSKoxpsMZ5yiXKsbY3MKmuKHcobSeVrUAPhqQoBiRu/+idrTE9wcvxPoHBE6ju7U=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] automation: Rework "build-each-commit-gcc" test
Message-Id: <E1recdX-00052u-HO@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 15:11:23 +0000

commit 21051291ad8851cac973c7ee70f5928967022c7e
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Tue Feb 20 14:07:33 2024 +0000
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 16:05:59 2024 +0100

    automation: Rework "build-each-commit-gcc" test
    
    Current issues with this test are:
    - when the job timeout, the log file is lost as there is no chance to
      run the `mv` command.
    - GitLab job log is limited in size, so one usually have to download
      the artifacts, which may be missing.
    
    Use $GITLAB_CI to detect when the script is run as part of a GitLab
    pipeline. GitLab will add "GITLAB_CI=true" in the environment
    variables.
    
    When run as part of $GITLAB_CI, ignore "dirty" worktree to allow to
    write "build-each-commit-gcc.log", which can then be grabbed as
    artifacts, even when the job timeout. The `git clean` command is
    changed to keep those build logs.
    
    When run as part of $GITLAB_CI, we will also store the build output in
    a log file instead of writing it to stdout, because GitLab's job log
    is limited. But we will write the log to stdout in case of error, so
    we can find out more quickly why there's been an error.
    
    This patch also make use of a GitLab feature, "log sections", which we
    will collapse by default. One section per commit been built.
    
    There's a bit of colour added to the logs.
    
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 automation/gitlab-ci/build-each-commit.sh |  2 +-
 automation/gitlab-ci/test.yaml            |  4 +--
 automation/scripts/build-test.sh          | 55 +++++++++++++++++++++++++++----
 3 files changed, 50 insertions(+), 11 deletions(-)

diff --git a/automation/gitlab-ci/build-each-commit.sh b/automation/gitlab-ci/build-each-commit.sh
index 19e337b468..08fddecbbe 100755
--- a/automation/gitlab-ci/build-each-commit.sh
+++ b/automation/gitlab-ci/build-each-commit.sh
@@ -15,4 +15,4 @@ fi
 echo "Building ${BASE}..${TIP}"
 
 NON_SYMBOLIC_REF=1 ./automation/scripts/build-test.sh ${BASE} ${TIP} \
-    bash -c "git clean -ffdx && ./automation/scripts/build"
+    bash -c "git clean -ffdx -e '/build-*.log' && ./automation/scripts/build"
diff --git a/automation/gitlab-ci/test.yaml b/automation/gitlab-ci/test.yaml
index 6aabdb9d15..8b7b2e4da9 100644
--- a/automation/gitlab-ci/test.yaml
+++ b/automation/gitlab-ci/test.yaml
@@ -134,9 +134,7 @@ build-each-commit-gcc:
     XEN_TARGET_ARCH: x86_64
     CC: gcc
   script:
-    - BASE=${BASE_SHA:-${CI_COMMIT_BEFORE_SHA}} TIP=${TIP_SHA:-${CI_COMMIT_SHA}} ./automation/gitlab-ci/build-each-commit.sh 2>&1 | tee ../build-each-commit-gcc.log
-  after_script:
-    - mv ../build-each-commit-gcc.log .
+    - BASE=${BASE_SHA:-${CI_COMMIT_BEFORE_SHA}} TIP=${TIP_SHA:-${CI_COMMIT_SHA}} ./automation/gitlab-ci/build-each-commit.sh 2>&1 | tee build-each-commit-gcc.log
   artifacts:
     paths:
       - '*.log'
diff --git a/automation/scripts/build-test.sh b/automation/scripts/build-test.sh
index da643adc01..355d4bf7f6 100755
--- a/automation/scripts/build-test.sh
+++ b/automation/scripts/build-test.sh
@@ -9,6 +9,37 @@
 # Set NON_SYMBOLIC_REF=1 if you want to use this script in detached HEAD state.
 # This is currently used by automated test system.
 
+# Colors with ANSI escape sequences
+txt_info='[32m'
+txt_err='[31m'
+txt_clr='[0m'
+
+# $GITLAB_CI should be "true" or "false".
+if [ "$GITLAB_CI" != true ]; then
+    GITLAB_CI=false
+fi
+
+gitlab_log_section() {
+    if $GITLAB_CI; then
+        echo -n "[0Ksection_$1:$(date +%s):$2
[0K"
+    fi
+    if [ $# -ge 3 ]; then
+        echo "$3"
+    fi
+}
+log_section_last=
+log_section_start() {
+    log_section_last="${1%\[collapsed=true\]}"
+    gitlab_log_section 'start' "$1" "${txt_info}$2${txt_clr}"
+}
+log_section_end() {
+    if [ "$log_section_last" ]; then
+        gitlab_log_section 'end' "$log_section_last"
+        log_section_last=
+    fi
+}
+
+
 if test $# -lt 2 ; then
     echo "Usage:"
     echo " $0 <BASE> <TIP> [CMD]"
@@ -19,10 +50,12 @@ fi
 
 pushd `git rev-parse --show-toplevel`
 
-status=`git status -s`
-if test -n "$status"; then
-    echo "Tree is dirty, aborted"
-    exit 1
+if ! $GITLAB_CI; then
+    status=`git status -s`
+    if test -n "$status"; then
+        echo "Tree is dirty, aborted"
+        exit 1
+    fi
 fi
 
 BASE=$1; shift
@@ -40,26 +73,34 @@ fi
 
 ret=1
 while read num rev; do
-    echo "Testing $num $rev"
+    log_section_start "commit_$rev[collapsed=true]" "Testing #$num $(git log -1 --abbrev=12 --format=tformat:'%h ("%s")' $rev)"
 
     git checkout $rev
     ret=$?
     if test $ret -ne 0; then
-        echo "Failed to checkout $num $rev with $ret"
+        log_section_end
+        echo "${txt_err}Failed to checkout $num $rev with $ret${txt_clr}"
         break
     fi
 
     if test $# -eq 0 ; then
         git clean -fdx && ./configure && make -j4
+    elif $GITLAB_CI; then
+        "$@" > "build-$num.log" 2>&1
     else
         "$@"
     fi
     ret=$?
     if test $ret -ne 0; then
-        echo "Failed at $num $rev with $ret"
+        if $GITLAB_CI; then
+            cat "build-$num.log"
+        fi
+        log_section_end
+        echo "${txt_err}Failed at $num $rev with $ret${txt_clr}"
         break
     fi
     echo
+    log_section_end
 done < <(git rev-list $BASE..$TIP | nl -ba | tac)
 
 echo "Restoring original HEAD"
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 15:11:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 15:11:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685611.1066609 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1recdi-0007G9-Q6; Mon, 26 Feb 2024 15:11:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685611.1066609; Mon, 26 Feb 2024 15:11:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1recdi-0007G1-Nc; Mon, 26 Feb 2024 15:11:34 +0000
Received: by outflank-mailman (input) for mailman id 685611;
 Mon, 26 Feb 2024 15:11:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1recdh-0007Fp-M2
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 15:11:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1recdh-0006gN-LI
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 15:11:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1recdh-00053Y-Kd
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 15:11:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Pz1uMZTC2PSqc3SImmYXD5jm0/tOsJg2N/fnSCuT2FU=; b=ZLRqvGg3ZSmR5wpxQ99cD/FhPx
	U5EnjxAGqmE8YUUo6M1FxNFZQABGD3LdJpwL5TlUMNVqk0j98O5KCTPOLH+edy6yKKpMRuYlmTZMy
	o1+pcmzuSB4iqF/OM0fcRkfL0GbvGLhiJn8DV45wTZ3hl10nVkk8spg3ynphCxw4P5/U=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/spec: fix BRANCH_HARDEN option to only be set when build-enabled
Message-Id: <E1recdh-00053Y-Kd@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 15:11:33 +0000

commit 60e00f77a5cc671d30c5ef3318f5b8e9b74e4aa3
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon Feb 26 16:06:42 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 16:06:42 2024 +0100

    x86/spec: fix BRANCH_HARDEN option to only be set when build-enabled
    
    The current logic to handle the BRANCH_HARDEN option will report it as enabled
    even when build-time disabled. Fix this by only allowing the option to be set
    when support for it is built into Xen.
    
    Fixes: 2d6f36daa086 ('x86/nospec: Introduce CONFIG_SPECULATIVE_HARDEN_BRANCH')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/spec_ctrl.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 421fe3f640..503f1c7a37 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -50,7 +50,8 @@ static int8_t __initdata opt_psfd = -1;
 int8_t __ro_after_init opt_ibpb_ctxt_switch = -1;
 int8_t __read_mostly opt_eager_fpu = -1;
 int8_t __read_mostly opt_l1d_flush = -1;
-static bool __initdata opt_branch_harden = true;
+static bool __initdata opt_branch_harden =
+    IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH);
 
 bool __initdata bsp_delay_spec_ctrl;
 uint8_t __read_mostly default_xen_spec_ctrl;
@@ -268,7 +269,16 @@ static int __init cf_check parse_spec_ctrl(const char *s)
         else if ( (val = parse_boolean("l1d-flush", s, ss)) >= 0 )
             opt_l1d_flush = val;
         else if ( (val = parse_boolean("branch-harden", s, ss)) >= 0 )
-            opt_branch_harden = val;
+        {
+            if ( IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH) )
+                opt_branch_harden = val;
+            else
+            {
+                no_config_param("SPECULATIVE_HARDEN_BRANCH", "spec-ctrl", s,
+                                ss);
+                rc = -EINVAL;
+            }
+        }
         else if ( (val = parse_boolean("srb-lock", s, ss)) >= 0 )
             opt_srb_lock = val;
         else if ( (val = parse_boolean("unpriv-mmio", s, ss)) >= 0 )
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 16:00:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 16:00:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685626.1066624 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1redOe-00089h-UH; Mon, 26 Feb 2024 16:00:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685626.1066624; Mon, 26 Feb 2024 16:00:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1redOe-00089E-Qk; Mon, 26 Feb 2024 16:00:04 +0000
Received: by outflank-mailman (input) for mailman id 685626;
 Mon, 26 Feb 2024 16:00:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1redOd-0007wf-Lj
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 16:00:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1redOd-00080K-I1
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 16:00:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1redOd-0007nP-GJ
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 16:00:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=sE7w+GuRks2+qVfXX6vbF6Of0k5sSI0Vb2CwMxisE4M=; b=FeIlF2+6yp6eyIio8ENSJlN/eM
	I1j6y044AcgKCUuhXx8rCBnSDYYXZ8809of3I7id4NSj1KksSmVn6vlPT5aYLk45bsWERIhjO3pMt
	iQPN5FFqOMZIBxn+xejRYA19plqEPg/LA0ltzLSgf5RW+PaJAWlcBKyZHaocJs1eDOj4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/hvm: Convert hap_capabilities into a bitfield
Message-Id: <E1redOd-0007nP-GJ@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 16:00:03 +0000

commit 5cd5e3070b50d4330cf116ec769b2169ccaccb6d
Author:     George Dunlap <george.dunlap@cloud.com>
AuthorDate: Mon Jan 15 17:05:09 2024 +0000
Commit:     George Dunlap <george.dunlap@cloud.com>
CommitDate: Mon Feb 26 15:57:56 2024 +0000

    xen/hvm: Convert hap_capabilities into a bitfield
    
    hvm_function_table is an internal structure; rather than manually
    |-ing and &-ing bits, just make it a boolean bitfield and let the
    compiler do all the work.  This makes everything easier to read, and
    presumably allows the compiler more flexibility in producing efficient
    code.
    
    No functional change intended.
    
    Signed-off-by: George Dunlap <george.dunlap@cloud.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/hvm/hvm.c             |  8 ++++----
 xen/arch/x86/hvm/svm/svm.c         |  4 ++--
 xen/arch/x86/hvm/vmx/vmcs.c        |  4 ++--
 xen/arch/x86/hvm/vmx/vmx.c         |  8 ++------
 xen/arch/x86/include/asm/hvm/hvm.h | 19 +++++++------------
 5 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 87d33d116b..2965c62e94 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -174,17 +174,17 @@ static int __init cf_check hvm_enable(void)
     {
         printk("HVM: Hardware Assisted Paging (HAP) detected\n");
         printk("HVM: HAP page sizes: 4kB");
-        if ( fns->hap_capabilities & HVM_HAP_SUPERPAGE_2MB )
+        if ( fns->caps.hap_superpage_2mb )
         {
             printk(", 2MB%s", opt_hap_2mb ? "" : " [disabled]");
             if ( !opt_hap_2mb )
-                hvm_funcs.hap_capabilities &= ~HVM_HAP_SUPERPAGE_2MB;
+                hvm_funcs.caps.hap_superpage_2mb = false;
         }
-        if ( fns->hap_capabilities & HVM_HAP_SUPERPAGE_1GB )
+        if ( fns->caps.hap_superpage_1gb )
         {
             printk(", 1GB%s", opt_hap_1gb ? "" : " [disabled]");
             if ( !opt_hap_1gb )
-                hvm_funcs.hap_capabilities &= ~HVM_HAP_SUPERPAGE_1GB;
+                hvm_funcs.caps.hap_superpage_1gb = false;
         }
         printk("\n");
     }
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 65f437e958..5741287355 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -2581,8 +2581,8 @@ const struct hvm_function_table * __init start_svm(void)
         printk(" - none\n");
 
     svm_function_table.hap_supported = !!cpu_has_svm_npt;
-    svm_function_table.hap_capabilities = HVM_HAP_SUPERPAGE_2MB |
-        (cpu_has_page1gb ? HVM_HAP_SUPERPAGE_1GB : 0);
+    svm_function_table.caps.hap_superpage_2mb = true;
+    svm_function_table.caps.hap_superpage_1gb = cpu_has_page1gb;
 
     return &svm_function_table;
 }
diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
index 9e016634ab..0de2caab76 100644
--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -113,8 +113,8 @@ static int cf_check parse_ept_param_runtime(const char *s)
     int val;
 
     if ( !cpu_has_vmx_ept || !hvm_funcs.hap_supported ||
-         !(hvm_funcs.hap_capabilities &
-           (HVM_HAP_SUPERPAGE_2MB | HVM_HAP_SUPERPAGE_1GB)) )
+         !(hvm_funcs.caps.hap_superpage_2mb ||
+           hvm_funcs.caps.hap_superpage_1gb) )
     {
         printk("VMX: EPT not available, or not in use - ignoring\n");
         return 0;
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 9c803494c7..10376674b4 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2995,12 +2995,8 @@ const struct hvm_function_table * __init start_vmx(void)
         vmx_function_table.hap_supported = 1;
         vmx_function_table.altp2m_supported = 1;
 
-        vmx_function_table.hap_capabilities = 0;
-
-        if ( cpu_has_vmx_ept_2mb )
-            vmx_function_table.hap_capabilities |= HVM_HAP_SUPERPAGE_2MB;
-        if ( cpu_has_vmx_ept_1gb )
-            vmx_function_table.hap_capabilities |= HVM_HAP_SUPERPAGE_1GB;
+        vmx_function_table.caps.hap_superpage_2mb = cpu_has_vmx_ept_2mb;
+        vmx_function_table.caps.hap_superpage_1gb = cpu_has_vmx_ept_1gb;
 
         setup_ept_dump();
     }
diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/hvm/hvm.h
index 985c1c14c6..4e9bd0ba47 100644
--- a/xen/arch/x86/include/asm/hvm/hvm.h
+++ b/xen/arch/x86/include/asm/hvm/hvm.h
@@ -61,14 +61,6 @@ enum hvm_intblk {
 #define HVM_INTR_SHADOW_SMI    0x00000004
 #define HVM_INTR_SHADOW_NMI    0x00000008
 
-/*
- * HAP super page capabilities:
- * bit0: if 2MB super page is allowed?
- * bit1: if 1GB super page is allowed?
- */
-#define HVM_HAP_SUPERPAGE_2MB   0x00000001
-#define HVM_HAP_SUPERPAGE_1GB   0x00000002
-
 #define HVM_EVENT_VECTOR_UNSET    (-1)
 #define HVM_EVENT_VECTOR_UPDATING (-2)
 
@@ -104,8 +96,11 @@ struct hvm_function_table {
     /* Hardware virtual interrupt delivery enable? */
     bool virtual_intr_delivery_enabled;
 
-    /* Indicate HAP capabilities. */
-    unsigned int hap_capabilities;
+    struct {
+        /* Indicate HAP capabilities. */
+        bool hap_superpage_1gb:1,
+             hap_superpage_2mb:1;
+    } caps;
 
     /*
      * Initialise/destroy HVM domain/vcpu resources
@@ -402,8 +397,8 @@ int hvm_get_param(struct domain *d, uint32_t index, uint64_t *value);
     (hvm_paging_enabled(v) && ((v)->arch.hvm.guest_cr[4] & X86_CR4_PKS))
 
 /* Can we use superpages in the HAP p2m table? */
-#define hap_has_1gb (!!(hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_1GB))
-#define hap_has_2mb (!!(hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_2MB))
+#define hap_has_1gb hvm_funcs.caps.hap_superpage_1gb
+#define hap_has_2mb hvm_funcs.caps.hap_superpage_2mb
 
 #define hvm_long_mode_active(v) (!!((v)->arch.hvm.guest_efer & EFER_LMA))
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 16:00:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 16:00:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685627.1066627 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1redOo-0008Tn-V3; Mon, 26 Feb 2024 16:00:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685627.1066627; Mon, 26 Feb 2024 16:00:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1redOo-0008Tg-SQ; Mon, 26 Feb 2024 16:00:14 +0000
Received: by outflank-mailman (input) for mailman id 685627;
 Mon, 26 Feb 2024 16:00:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1redOn-0008TY-Nv
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 16:00:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1redOn-00085q-LI
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 16:00:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1redOn-0007on-KM
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 16:00:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=2ziKjFAZfKYMOb/TPrlAHeodYsPwopqcFvpzJwOzEJc=; b=lQaPGr+N7TukZnD2Ko3q60gAPy
	PhqIZSZl/mjUpMI6062goj4ouzpg9VoWlJTq2gOdNCnXuBsDl3bT1nHyNc3x6MCAunTJl6AX/poq4
	YqPSZfneedcPjCIfbZDqzTm9Z88vtuPdxQDpSyzLWcjDRRQ301Vs441EsSEN2nSs05jk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] svm: Improve type of cpu_has_svm_feature
Message-Id: <E1redOn-0007on-KM@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 16:00:13 +0000

commit 42b8e78b3751270d0ec7dadc9cfcac5421e42e50
Author:     George Dunlap <george.dunlap@cloud.com>
AuthorDate: Mon Feb 5 21:42:59 2024 +0000
Commit:     George Dunlap <george.dunlap@cloud.com>
CommitDate: Mon Feb 26 15:57:56 2024 +0000

    svm: Improve type of cpu_has_svm_feature
    
    The "effective type" of the cpu_has_svm_feature macro is effectively
    an unsigned log with one bit set (or not); at least one place someone
    felt compelled to do a !! to make sure that they got a boolean out of
    it.
    
    Ideally the whole of this would be folded into the cpufeature.h
    infrastructure.  But for now, duplicate the more type-safe static
    inlines in that file, and remove the !!.
    
    Signed-off-by: George Dunlap <george.dunlap@cloud.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/hvm/svm/svm.c             | 2 +-
 xen/arch/x86/include/asm/hvm/svm/svm.h | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 5741287355..40bc1ffbc6 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -2580,7 +2580,7 @@ const struct hvm_function_table * __init start_svm(void)
     if ( !printed )
         printk(" - none\n");
 
-    svm_function_table.hap_supported = !!cpu_has_svm_npt;
+    svm_function_table.hap_supported = cpu_has_svm_npt;
     svm_function_table.caps.hap_superpage_2mb = true;
     svm_function_table.caps.hap_superpage_1gb = cpu_has_page1gb;
 
diff --git a/xen/arch/x86/include/asm/hvm/svm/svm.h b/xen/arch/x86/include/asm/hvm/svm/svm.h
index 687d35be40..4eeeb25da9 100644
--- a/xen/arch/x86/include/asm/hvm/svm/svm.h
+++ b/xen/arch/x86/include/asm/hvm/svm/svm.h
@@ -38,7 +38,10 @@ extern u32 svm_feature_flags;
 #define SVM_FEATURE_SSS           19 /* NPT Supervisor Shadow Stacks */
 #define SVM_FEATURE_SPEC_CTRL     20 /* MSR_SPEC_CTRL virtualisation */
 
-#define cpu_has_svm_feature(f) (svm_feature_flags & (1u << (f)))
+static inline bool cpu_has_svm_feature(unsigned int feat)
+{
+    return svm_feature_flags & (1u << feat);
+}
 #define cpu_has_svm_npt       cpu_has_svm_feature(SVM_FEATURE_NPT)
 #define cpu_has_svm_lbrv      cpu_has_svm_feature(SVM_FEATURE_LBRV)
 #define cpu_has_svm_svml      cpu_has_svm_feature(SVM_FEATURE_SVML)
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 16:00:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 16:00:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685628.1066632 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1redOz-0000GW-22; Mon, 26 Feb 2024 16:00:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685628.1066632; Mon, 26 Feb 2024 16:00:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1redOy-0000GO-VY; Mon, 26 Feb 2024 16:00:24 +0000
Received: by outflank-mailman (input) for mailman id 685628;
 Mon, 26 Feb 2024 16:00:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1redOx-0000Er-Rf
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 16:00:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1redOx-000861-Qn
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 16:00:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1redOx-0007pY-O6
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 16:00:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=VF0XJi7QDeUV99+56dpvu87ruyhNPv3itzBvSzU7w8U=; b=oKbMUpzi38sdSkOkU13tszWv78
	BIQ5OhjCRYDEoWWFp0E4J8JL3kQKlMyH7SC3Bn1kwqZWmyIqr7ugJq3/fJ0rWC8d5BQALz9xigOC6
	McoR217lArPDJcjLAHaUrSJrfkU2d2i8wS4TWVNieh0Zcmpra4uAq4/HgVwSrtM55kaI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/hvm: Move other hvm_function_table booleans into the caps bitfield
Message-Id: <E1redOx-0007pY-O6@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 16:00:23 +0000

commit 2beef32b42b4454bd02bf735b3e414dad6e04962
Author:     George Dunlap <george.dunlap@cloud.com>
AuthorDate: Wed Jan 17 15:48:35 2024 +0000
Commit:     George Dunlap <george.dunlap@cloud.com>
CommitDate: Mon Feb 26 15:57:56 2024 +0000

    xen/hvm: Move other hvm_function_table booleans into the caps bitfield
    
    Moving them all together has several advantages:
     * Collects them all in one part of the struct
     * The `caps` field means that we can drop the "_supported" suffix, as it's
       clear what is meant.
    
    While here, replace some 0/1 values with false/true.
    
    Signed-off-by: George Dunlap <george.dunlap@cloud.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/hvm/hvm.c             |  6 +++---
 xen/arch/x86/hvm/svm/svm.c         |  2 +-
 xen/arch/x86/hvm/vlapic.c          |  4 ++--
 xen/arch/x86/hvm/vmx/vmcs.c        |  2 +-
 xen/arch/x86/hvm/vmx/vmx.c         |  8 ++++----
 xen/arch/x86/include/asm/hvm/hvm.h | 28 +++++++++++++---------------
 6 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 2965c62e94..c75959588c 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -136,7 +136,7 @@ static struct notifier_block cpu_nfb = {
 
 static bool __init hap_supported(struct hvm_function_table *fns)
 {
-    if ( !fns->hap_supported )
+    if ( !fns->caps.hap )
     {
         printk("HVM: Hardware Assisted Paging (HAP) not detected\n");
         return false;
@@ -144,7 +144,7 @@ static bool __init hap_supported(struct hvm_function_table *fns)
 
     if ( !opt_hap_enabled )
     {
-        fns->hap_supported = 0;
+        fns->caps.hap = false;
         printk("HVM: Hardware Assisted Paging (HAP) detected but disabled\n");
         return false;
     }
@@ -190,7 +190,7 @@ static int __init cf_check hvm_enable(void)
     }
 
     if ( !opt_altp2m_enabled )
-        hvm_funcs.altp2m_supported = 0;
+        hvm_funcs.caps.altp2m = false;
 
     if ( opt_hvm_fep )
         warning_add(warning_hvm_fep);
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 40bc1ffbc6..b551eac807 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -2580,7 +2580,7 @@ const struct hvm_function_table * __init start_svm(void)
     if ( !printed )
         printk(" - none\n");
 
-    svm_function_table.hap_supported = cpu_has_svm_npt;
+    svm_function_table.caps.hap = cpu_has_svm_npt;
     svm_function_table.caps.hap_superpage_2mb = true;
     svm_function_table.caps.hap_superpage_1gb = cpu_has_page1gb;
 
diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c
index 71a4b954b0..dcbcf4a1fe 100644
--- a/xen/arch/x86/hvm/vlapic.c
+++ b/xen/arch/x86/hvm/vlapic.c
@@ -1326,7 +1326,7 @@ int vlapic_has_pending_irq(struct vcpu *v)
     if ( irr == -1 )
         return -1;
 
-    if ( hvm_funcs.virtual_intr_delivery_enabled &&
+    if ( hvm_funcs.caps.virtual_intr_delivery &&
          !nestedhvm_vcpu_in_guestmode(v) )
         return irr;
 
@@ -1361,7 +1361,7 @@ int vlapic_ack_pending_irq(struct vcpu *v, int vector, bool force_ack)
     int isr;
 
     if ( !force_ack &&
-         hvm_funcs.virtual_intr_delivery_enabled )
+         hvm_funcs.caps.virtual_intr_delivery )
         return 1;
 
     /* If there's no chance of using APIC assist then bail now. */
diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
index 0de2caab76..6b4f004a3d 100644
--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -112,7 +112,7 @@ static int cf_check parse_ept_param_runtime(const char *s)
     struct domain *d;
     int val;
 
-    if ( !cpu_has_vmx_ept || !hvm_funcs.hap_supported ||
+    if ( !cpu_has_vmx_ept || !hvm_funcs.caps.hap ||
          !(hvm_funcs.caps.hap_superpage_2mb ||
            hvm_funcs.caps.hap_superpage_1gb) )
     {
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 10376674b4..8b27d83c12 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2969,7 +2969,7 @@ const struct hvm_function_table * __init start_vmx(void)
         return NULL;
     }
 
-    vmx_function_table.singlestep_supported = cpu_has_monitor_trap_flag;
+    vmx_function_table.caps.singlestep = cpu_has_monitor_trap_flag;
 
     if ( cpu_has_vmx_dt_exiting )
         vmx_function_table.set_descriptor_access_exiting =
@@ -2992,8 +2992,8 @@ const struct hvm_function_table * __init start_vmx(void)
                 printk("VMX: Disabling executable EPT superpages due to CVE-2018-12207\n");
         }
 
-        vmx_function_table.hap_supported = 1;
-        vmx_function_table.altp2m_supported = 1;
+        vmx_function_table.caps.hap = true;
+        vmx_function_table.caps.altp2m = true;
 
         vmx_function_table.caps.hap_superpage_2mb = cpu_has_vmx_ept_2mb;
         vmx_function_table.caps.hap_superpage_1gb = cpu_has_vmx_ept_1gb;
@@ -3006,7 +3006,7 @@ const struct hvm_function_table * __init start_vmx(void)
         vmx_function_table.update_eoi_exit_bitmap = vmx_update_eoi_exit_bitmap;
         vmx_function_table.process_isr = vmx_process_isr;
         vmx_function_table.handle_eoi = vmx_handle_eoi;
-        vmx_function_table.virtual_intr_delivery_enabled = true;
+        vmx_function_table.caps.virtual_intr_delivery = true;
     }
 
     if ( cpu_has_vmx_posted_intr_processing )
diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/hvm/hvm.h
index 4e9bd0ba47..87a6935d97 100644
--- a/xen/arch/x86/include/asm/hvm/hvm.h
+++ b/xen/arch/x86/include/asm/hvm/hvm.h
@@ -86,20 +86,18 @@ struct hvm_vcpu_nonreg_state {
 struct hvm_function_table {
     const char *name;
 
-    /* Support Hardware-Assisted Paging? */
-    bool hap_supported;
-
-    /* Necessary hardware support for alternate p2m's? */
-    bool altp2m_supported;
-    bool singlestep_supported;
-
-    /* Hardware virtual interrupt delivery enable? */
-    bool virtual_intr_delivery_enabled;
-
     struct {
         /* Indicate HAP capabilities. */
-        bool hap_superpage_1gb:1,
-             hap_superpage_2mb:1;
+        bool hap:1,
+             hap_superpage_1gb:1,
+             hap_superpage_2mb:1,
+
+             /* Altp2m capabilities */
+             altp2m:1,
+             singlestep:1,
+            
+             /* Hardware virtual interrupt delivery enable? */
+             virtual_intr_delivery:1;
     } caps;
 
     /*
@@ -642,18 +640,18 @@ static inline void hvm_enable_msr_interception(struct domain *d, uint32_t msr)
 
 static inline bool hvm_is_singlestep_supported(void)
 {
-    return hvm_funcs.singlestep_supported;
+    return hvm_funcs.caps.singlestep;
 }
 
 static inline bool hvm_hap_supported(void)
 {
-    return hvm_funcs.hap_supported;
+    return hvm_funcs.caps.hap;
 }
 
 /* returns true if hardware supports alternate p2m's */
 static inline bool hvm_altp2m_supported(void)
 {
-    return hvm_funcs.altp2m_supported;
+    return hvm_funcs.caps.altp2m;
 }
 
 /* updates the current hardware p2m */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 16:00:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 16:00:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685629.1066635 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1redP9-0000Lr-3A; Mon, 26 Feb 2024 16:00:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685629.1066635; Mon, 26 Feb 2024 16:00:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1redP9-0000Lk-0j; Mon, 26 Feb 2024 16:00:35 +0000
Received: by outflank-mailman (input) for mailman id 685629;
 Mon, 26 Feb 2024 16:00:34 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1redP8-0000KB-0G
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 16:00:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1redP7-000868-To
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 16:00:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1redP7-0007px-Sy
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 16:00:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=zdXsUYwhgeexfYMBYOJUTHePPGs2yA1+C6ErXH0bAiM=; b=xNfy8fjHlOfVCZ6kV8ybEOjXbd
	SKVqWj9u060drgTQhdnZGpvo/UdhditOnP/7/2qIor9bWltPZTZvk1K9SBEgALl517SQM78i0gmI5
	J21tg02s6klPm2Tb+d3BMl5kaA8gnKxxtUVr2WR9ewdtGDt3MKq0swBnfVlbVAqb/1lI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] nestedsvm: Remove bogus debug message from nestedsvm_check_intercepts
Message-Id: <E1redP7-0007px-Sy@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 16:00:33 +0000

commit 03fb5f503cb5faa0556b23d594496719ced6a11b
Author:     George Dunlap <george.dunlap@cloud.com>
AuthorDate: Mon Jan 22 15:32:25 2024 +0000
Commit:     George Dunlap <george.dunlap@cloud.com>
CommitDate: Mon Feb 26 15:57:56 2024 +0000

    nestedsvm: Remove bogus debug message from nestedsvm_check_intercepts
    
    Changeset ef3e8db8068 ("x86/hvm: Corrections and improvements to
    unhandled vmexit logging") introduced a printk to the default path of
    the switch statement in nestedsvm_check_intercepts(), complaining of
    an unknown exit reason.
    
    Unfortunately, the "core" switch statement which is meant to handle
    all vmexit reasons is in nsvm_vmcb_guest_intercepts_exitcode(); the
    switch statement in nestedsvm_check_intercepts() is only meant to
    superimpose on top of that some special-casing for how to interaction
    between L1 and L0 vmexits.
    
    Remove the printk, and add a comment to prevent future confusion.
    
    Fixes: ef3e8db8068 ("x86/hvm: Corrections and improvements to unhandled vmexit logging")
    
    Signed-off-by: George Dunlap <george.dunlap@cloud.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/hvm/svm/nestedsvm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c
index ee9602f5c8..e4e01add8c 100644
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -1294,6 +1294,10 @@ nestedsvm_check_intercepts(struct vcpu *v, struct cpu_user_regs *regs,
     ASSERT(vcpu_nestedhvm(v).nv_vmexit_pending == 0);
     is_intercepted = nsvm_vmcb_guest_intercepts_exitcode(v, regs, exitcode);
 
+    /* 
+     * Handle specific interactions between things the guest and host
+     * may both want to intercept
+     */
     switch ( exitcode )
     {
     case VMEXIT_INVALID:
@@ -1349,8 +1353,6 @@ nestedsvm_check_intercepts(struct vcpu *v, struct cpu_user_regs *regs,
         /* Always let the guest handle VMMCALL/VMCALL */
         return NESTEDHVM_VMEXIT_INJECT;
     default:
-        gprintk(XENLOG_ERR, "Unexpected nested vmexit: reason %#"PRIx64"\n",
-                exitcode);
         break;
     }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 21:44:17 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 21:44:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685796.1067100 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reilY-0002it-TE; Mon, 26 Feb 2024 21:44:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685796.1067100; Mon, 26 Feb 2024 21:44:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reilY-0002il-QY; Mon, 26 Feb 2024 21:44:04 +0000
Received: by outflank-mailman (input) for mailman id 685796;
 Mon, 26 Feb 2024 21:44:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reilX-0002id-VQ
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 21:44:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reilX-0006ho-Oi
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 21:44:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reilX-0000vb-Ls
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 21:44:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=hkgRKVfmbW9zjVyIpJ0k5rzhylWAaELi/m4QWXJO0E4=; b=lT0fue894su3XO4EKuwv3BlX11
	U9vopHfu1qpjdkxUbTypoeLxcQ0QKIdTo47OQQa/XfrRPa2HNpd54viREshKEawUxoWPXu4WVYXVk
	CbwvupaTDzMSJeYarQgg4NxRzdWiUg00/zl3mHguTPM7EHX3CC2Y8kB2tk4q6ftL8zCk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] docs/sphinx: Start an FAQ, and add Kconfig/CET details
Message-Id: <E1reilX-0000vb-Ls@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 21:44:03 +0000

commit 6f1b2808760874d3912d3b9a02aec9433d08f35c
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Feb 7 12:06:25 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Feb 26 18:20:27 2024 +0000

    docs/sphinx: Start an FAQ, and add Kconfig/CET details
    
    This is long overdue, and we need to start somewhere.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 docs/faq.rst      | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 docs/glossary.rst | 15 ++++++++++++
 docs/index.rst    |  1 +
 3 files changed, 87 insertions(+)

diff --git a/docs/faq.rst b/docs/faq.rst
new file mode 100644
index 0000000000..a56b607814
--- /dev/null
+++ b/docs/faq.rst
@@ -0,0 +1,71 @@
+.. SPDX-License-Identifier: CC-BY-4.0
+
+Frequently Asked Questions
+==========================
+
+How do I...
+-----------
+
+... check whether a Kconfig option is active?
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+  Kconfig is a build time configuration system, combining inherent knowledge,
+  the capabilities of the toolchain, and explicit user choice to form a
+  configuration of a build of Xen.
+
+  A file, by default ``.config``, is produced by the build identifying the
+  configuration used.  Kconfig symbols all start with ``CONFIG_``, and come in
+  a variety of types including strings, integers and booleans.  Booleans are
+  the most common, and when active are expressed with ``...=y``.  e.g.::
+
+    xen.git/xen$ grep CONFIG_FOO .config
+    CONFIG_FOO_BOOLEAN=y
+    CONFIG_FOO_STRING="lorem ipsum"
+    CONFIG_FOO_INTEGER=42
+
+  Symbols which are either absent, or expressed as ``... is not set`` are
+  disabled.  e.g.::
+
+    xen.git/xen$ grep CONFIG_BAR .config
+    # CONFIG_BAR is not set
+
+  Builds of Xen configured with ``CONFIG_HYPFS_CONFIG=y`` embed their own
+  ``.config`` at build time, and can provide it to the :term:`control domain`
+  upon requested.  e.g.::
+
+    [root@host ~]# xenhypfs cat /buildinfo/config | grep -e FOO -e BAR
+    CONFIG_FOO=y
+    # CONFIG_BAR is not set
+
+
+... tell if CET is active?
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+  Control-flow Enforcement Technology support was added to Xen 4.14.  It is
+  build time conditional, dependent on both having a new-enough toolchain and
+  an explicit Kconfig option, and also requires capable hardware.  See
+  :term:`CET`.
+
+  For CET-SS, Shadow Stacks, the minimum toolchain requirements are ``binutils
+  >= 2.29`` or ``LLVM >= 6``.  No specific compiler support is required.
+  Check for ``CONFIG_XEN_SHSTK`` being active.
+
+  For CET-IBT, Indirect Branch Tracking, the minimum toolchain requirements
+  are ``GCC >= 9`` and ``binutils >= 2.29``.  Xen relies on a compiler feature
+  which is specific to GCC at the time of writing.  Check for
+  ``CONFIG_XEN_IBT`` being active.
+
+  If a capable Xen is booted on capable hardware, and CET is not disabled by
+  command line option or errata, Xen will print some details early on boot
+  about which CET facilities have been turned on::
+
+    ...
+    (XEN) CPU Vendor: Intel, Family 6 (0x6), Model 143 (0x8f), Stepping 8 (raw 000806f8)
+    (XEN) Enabling Supervisor Shadow Stacks
+    (XEN) Enabling Indirect Branch Tracking
+    (XEN)   - IBT disabled in UEFI Runtime Services
+    (XEN) EFI RAM map:
+    ...
+
+  This can be obtained from the control domain with ``xl dmesg``, but remember
+  to confirm that the console ring hasn't wrapped.
diff --git a/docs/glossary.rst b/docs/glossary.rst
index 8ddbdab160..6adeec77e1 100644
--- a/docs/glossary.rst
+++ b/docs/glossary.rst
@@ -28,6 +28,21 @@ Glossary
      single instance of Xen, used as the identifier in various APIs, and is
      typically allocated sequentially from 0.
 
+   CET
+     Control-flow Enforcement Technology is a facility in x86 CPUs for
+     defending against memory safety vulnerabilities.  It is formed of two
+     independent features:
+
+     * CET-SS, Shadow Stacks, are designed to protect against Return Oriented
+       Programming (ROP) attacks.
+
+     * CET-IBT, Indirect Branch Tracking, is designed to protect against Call
+       or Jump Oriented Programming (COP/JOP) attacks.
+
+     Intel support CET-SS and CET-IBT from the Tiger Lake (Client, 2020) and
+     Sapphire Rapids (Server, 2023) CPUs.  AMD support only CET-SS, starting
+     with Zen3 (Both client and server, 2020) CPUs.
+
    guest
      The term 'guest' has two different meanings, depending on context, and
      should not be confused with :term:`domain`.
diff --git a/docs/index.rst b/docs/index.rst
index 22fdde8059..ab051a0f38 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -72,4 +72,5 @@ Miscellanea
 
 .. toctree::
 
+   faq
    glossary
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 21:44:17 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 21:44:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685797.1067104 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reili-0002kJ-Uh; Mon, 26 Feb 2024 21:44:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685797.1067104; Mon, 26 Feb 2024 21:44:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reili-0002kB-S8; Mon, 26 Feb 2024 21:44:14 +0000
Received: by outflank-mailman (input) for mailman id 685797;
 Mon, 26 Feb 2024 21:44:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reilh-0002jz-US
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 21:44:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reilh-0006iC-Te
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 21:44:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reilh-0000wH-Qt
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 21:44:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=UH2T+oSj+c3hJl+YiiI6LgQ50+7//Cq6l6yjEjsIYDw=; b=UW8x3NRUGUA9HGy7FNteaGuONy
	BtRYYCXCd9t/aRgSNFVKQrD+GfBOVCuzRBcImzv5EAH84+JUcEB7vJJDjMbc+NYt4gRuvYvwwFJ1b
	1QwgpLFnpPfY4UkkqQP4c7BHvyjnLz1NdzDBbPXYbD524coCqihzT3fRLLKWfAly96H0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/entry: Adjustments to "reduce assembly code size of entry points"
Message-Id: <E1reilh-0000wH-Qt@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 21:44:13 +0000

commit 7d3c91377d121b31b9d602f8d44abdcb66b0cbe5
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Feb 20 20:53:15 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Feb 26 18:20:27 2024 +0000

    x86/entry: Adjustments to "reduce assembly code size of entry points"
    
    Some retroactive review, for if I'd got to the patch in time.
    
     * The new ASM-friendly BUILD_BUG_ON() should be in a header file.
     * entry_int82() wants the movl->movb treatment too.
    
    Fixes: c144b9e32427 ("x86: Reduce assembly code size of entry points")
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/include/asm/asm_defns.h | 8 ++++++++
 xen/arch/x86/x86_64/compat/entry.S   | 2 +-
 xen/arch/x86/x86_64/entry.S          | 8 --------
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/include/asm/asm_defns.h b/xen/arch/x86/include/asm/asm_defns.h
index a9a6c21c76..cf9573705d 100644
--- a/xen/arch/x86/include/asm/asm_defns.h
+++ b/xen/arch/x86/include/asm/asm_defns.h
@@ -82,6 +82,14 @@ register unsigned long current_stack_pointer asm("rsp");
 
 #ifdef __ASSEMBLY__
 
+.macro BUILD_BUG_ON condstr cond:vararg
+        .if \cond
+        .error "Condition \"\condstr\" not satisfied"
+        .endif
+.endm
+/* preprocessor macro to make error message more user friendly */
+#define BUILD_BUG_ON(cond) BUILD_BUG_ON #cond cond
+
 #ifdef HAVE_AS_QUOTED_SYM
 #define SUBSECTION_LBL(tag)                        \
         .ifndef .L.tag;                            \
diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compat/entry.S
index d4f0e48040..93fbbeb4ae 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -15,7 +15,7 @@ FUNC(entry_int82)
         ENDBR64
         ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
         pushq $0
-        movl  $HYPERCALL_VECTOR, 4(%rsp)
+        movb  $HYPERCALL_VECTOR, 4(%rsp)
         SAVE_ALL compat=1 /* DPL1 gate, restricted to 32bit PV guests only. */
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index a7bd8f0ca5..f8938b0b42 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -22,14 +22,6 @@
 #endif
 .endm
 
-.macro BUILD_BUG_ON condstr cond:vararg
-        .if \cond
-        .error "Condition \"\condstr\" not satisfied"
-        .endif
-.endm
-/* preprocessor macro to make error message more user friendly */
-#define BUILD_BUG_ON(cond) BUILD_BUG_ON #cond cond
-
 #ifdef CONFIG_PV
 /* %rbx: struct vcpu */
 FUNC_LOCAL(switch_to_kernel)
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 21:44:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 21:44:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685798.1067108 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reilt-0002mn-07; Mon, 26 Feb 2024 21:44:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685798.1067108; Mon, 26 Feb 2024 21:44:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reils-0002mf-Tj; Mon, 26 Feb 2024 21:44:24 +0000
Received: by outflank-mailman (input) for mailman id 685798;
 Mon, 26 Feb 2024 21:44:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reils-0002mR-35
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 21:44:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reils-0006jz-2I
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 21:44:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reilr-0000wn-Vj
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 21:44:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=XQyxTbFUzc935COHo4DGqRU9Usp9E0tY9FBbEvC1QAw=; b=7MgCPPNjrq7gi9Zylr6rMofHJx
	06gikm2c1JPrsKtUZTNYF+EHw1gz/z6o8U5gLVFmEEepd+XrXUEZSGSy8d2ddI8oDZ016GOFPC3u2
	IzFkT+qg2Puyab77EUxFvrzLWX+3T5wsmX5/DO/rmtsG+4QvqLTWab1bgEqF9Z4DZ2W4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/entry: Simplify expressions in compat_restore_all_guest()
Message-Id: <E1reilr-0000wn-Vj@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 21:44:23 +0000

commit 0603a0c0923c278e2073c4aa00684c6269df317e
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Feb 20 20:54:10 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Feb 26 18:20:27 2024 +0000

    x86/entry: Simplify expressions in compat_restore_all_guest()
    
    compat_restore_all_guest() already has SPEC_CTRL_EXIT_TO_PV with a documented
    requirement for %rsp to be both regs and cpuinfo.
    
    Use the now-normal annotations and simplify the expressions which happen to be
    a subtraction of 0.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/x86_64/compat/entry.S | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compat/entry.S
index 93fbbeb4ae..727ab65290 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -117,19 +117,19 @@ compat_process_trap:
         jmp   compat_test_all_events
 END(compat_test_all_events)
 
-/* %rbx: struct vcpu, interrupts disabled */
+/* %rbx: struct vcpu, interrupts disabled, %rsp=regs/cpuinfo */
 FUNC(compat_restore_all_guest)
         ASSERT_INTERRUPTS_DISABLED
         mov   $~(X86_EFLAGS_IOPL | X86_EFLAGS_VM), %r11d
         and   UREGS_eflags(%rsp),%r11d
 
-.macro alt_cr4_pv32
+.macro alt_cr4_pv32 /* %rsp=regs/cpuinfo */
         testb $3,UREGS_cs(%rsp)
         jpe   2f
-        mov   CPUINFO_cr4-CPUINFO_guest_cpu_user_regs(%rsp), %rax
+        mov   CPUINFO_cr4(%rsp), %rax
         and   $~XEN_CR4_PV32_BITS, %rax
 1:
-        mov   %rax, CPUINFO_cr4-CPUINFO_guest_cpu_user_regs(%rsp)
+        mov   %rax, CPUINFO_cr4(%rsp)
         mov   %rax, %cr4
         /*
          * An NMI or MCE may have occurred between the previous two
@@ -141,7 +141,7 @@ FUNC(compat_restore_all_guest)
          * loop to cause a live lock: If NMIs/MCEs occurred at that
          * high a rate, we'd be live locked anyway.
          */
-        cmp   %rax, CPUINFO_cr4-CPUINFO_guest_cpu_user_regs(%rsp)
+        cmp   %rax, CPUINFO_cr4(%rsp)
         jne   1b
 2:
 .endm
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 21:44:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 21:44:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685799.1067112 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reim3-0002qP-1c; Mon, 26 Feb 2024 21:44:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685799.1067112; Mon, 26 Feb 2024 21:44:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reim2-0002qG-VE; Mon, 26 Feb 2024 21:44:34 +0000
Received: by outflank-mailman (input) for mailman id 685799;
 Mon, 26 Feb 2024 21:44:34 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reim2-0002q6-8B
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 21:44:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reim2-0006k7-70
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 21:44:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reim2-0000xC-4N
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 21:44:34 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=7m7npY76WB80Vr0ZpavFH3YWEiKvWvFOxCKJkARtH+I=; b=e15EswZyUXKHxIMDGbCT5EK6Cl
	UjvBN0lmOF33SajGdntjET5uHPglwqjG6nQ+uLxVi727zJMuUZVTCWz2UZulVZ/fjtfu3qfQLmWuB
	IdXAh8KEPtXixp9vA+MlpOIZA3RLiNYj6d1+erSMNgVhq8X5fnpBEYkkkhct2uCHV+og=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/entry: Introduce EFRAME_* constants
Message-Id: <E1reim2-0000xC-4N@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 21:44:34 +0000

commit 37541208f119a9c552c6c6c3246ea61be0d44035
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Sat Jan 27 17:52:09 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Feb 26 18:20:27 2024 +0000

    x86/entry: Introduce EFRAME_* constants
    
    restore_all_guest() does a lot of manipulation of the stack after popping the
    GPRs, and uses raw %rsp displacements to do so.  Also, almost all entrypaths
    use raw %rsp displacements prior to pushing GPRs.
    
    Provide better mnemonics, to aid readability and reduce the chance of errors
    when editing.
    
    No functional change.  The resulting binary is identical.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/x86_64/asm-offsets.c  | 17 ++++++++++
 xen/arch/x86/x86_64/compat/entry.S |  2 +-
 xen/arch/x86/x86_64/entry.S        | 68 +++++++++++++++++++-------------------
 3 files changed, 52 insertions(+), 35 deletions(-)

diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c
index fee0edc61a..02242a9b73 100644
--- a/xen/arch/x86/x86_64/asm-offsets.c
+++ b/xen/arch/x86/x86_64/asm-offsets.c
@@ -51,6 +51,23 @@ void __dummy__(void)
     OFFSET(UREGS_kernel_sizeof, struct cpu_user_regs, es);
     BLANK();
 
+    /*
+     * EFRAME_* is for the entry/exit logic where %rsp is pointing at
+     * UREGS_error_code and GPRs are still/already guest values.
+     */
+#define OFFSET_EF(sym, mem)                                             \
+    DEFINE(sym, offsetof(struct cpu_user_regs, mem) -                   \
+                offsetof(struct cpu_user_regs, error_code))
+
+    OFFSET_EF(EFRAME_entry_vector,    entry_vector);
+    OFFSET_EF(EFRAME_rip,             rip);
+    OFFSET_EF(EFRAME_cs,              cs);
+    OFFSET_EF(EFRAME_eflags,          eflags);
+    OFFSET_EF(EFRAME_rsp,             rsp);
+    BLANK();
+
+#undef OFFSET_EF
+
     OFFSET(VCPU_processor, struct vcpu, processor);
     OFFSET(VCPU_domain, struct vcpu, domain);
     OFFSET(VCPU_vcpu_info, struct vcpu, vcpu_info_area.map);
diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compat/entry.S
index 727ab65290..2f8fe5ebfb 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -15,7 +15,7 @@ FUNC(entry_int82)
         ENDBR64
         ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
         pushq $0
-        movb  $HYPERCALL_VECTOR, 4(%rsp)
+        movb  $HYPERCALL_VECTOR, EFRAME_entry_vector(%rsp)
         SAVE_ALL compat=1 /* DPL1 gate, restricted to 32bit PV guests only. */
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index f8938b0b42..1b846f3aaf 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -188,15 +188,15 @@ FUNC_LOCAL(restore_all_guest)
 
         RESTORE_ALL
         BUILD_BUG_ON(TRAP_syscall & 0xff)
-        testb $TRAP_syscall >> 8, 4+1(%rsp)
+        testb $TRAP_syscall >> 8, EFRAME_entry_vector + 1(%rsp)
         jz    iret_exit_to_guest
 
-        movq  24(%rsp),%r11           # RFLAGS
+        mov   EFRAME_eflags(%rsp), %r11
         andq  $~(X86_EFLAGS_IOPL | X86_EFLAGS_VM), %r11
         orq   $X86_EFLAGS_IF,%r11
 
         /* Don't use SYSRET path if the return address is not canonical. */
-        movq  8(%rsp),%rcx
+        mov   EFRAME_rip(%rsp), %rcx
         sarq  $47,%rcx
         incl  %ecx
         cmpl  $1,%ecx
@@ -211,19 +211,19 @@ FUNC_LOCAL(restore_all_guest)
         ALTERNATIVE "", rag_clrssbsy, X86_FEATURE_XEN_SHSTK
 #endif
 
-        movq  8(%rsp), %rcx           # RIP
-        cmpw  $FLAT_USER_CS32,16(%rsp)# CS
-        movq  32(%rsp),%rsp           # RSP
+        mov   EFRAME_rip(%rsp), %rcx
+        cmpw  $FLAT_USER_CS32, EFRAME_cs(%rsp)
+        mov   EFRAME_rsp(%rsp), %rsp
         je    1f
         sysretq
 1:      sysretl
 
 LABEL_LOCAL(.Lrestore_rcx_iret_exit_to_guest)
-        movq  8(%rsp), %rcx           # RIP
+        mov   EFRAME_rip(%rsp), %rcx
 /* No special register assumptions. */
 iret_exit_to_guest:
-        andl  $~(X86_EFLAGS_IOPL | X86_EFLAGS_VM), 24(%rsp)
-        orl   $X86_EFLAGS_IF,24(%rsp)
+        andl  $~(X86_EFLAGS_IOPL | X86_EFLAGS_VM), EFRAME_eflags(%rsp)
+        orl   $X86_EFLAGS_IF, EFRAME_eflags(%rsp)
         addq  $8,%rsp
 .Lft0:  iretq
         _ASM_PRE_EXTABLE(.Lft0, handle_exception)
@@ -256,7 +256,7 @@ FUNC(lstar_enter)
         pushq %rcx
         pushq $0
         BUILD_BUG_ON(TRAP_syscall & 0xff)
-        movb  $TRAP_syscall >> 8, 4+1(%rsp)
+        movb  $TRAP_syscall >> 8, EFRAME_entry_vector + 1(%rsp)
         SAVE_ALL
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
@@ -295,7 +295,7 @@ FUNC(cstar_enter)
         pushq %rcx
         pushq $0
         BUILD_BUG_ON(TRAP_syscall & 0xff)
-        movb  $TRAP_syscall >> 8, 4+1(%rsp)
+        movb  $TRAP_syscall >> 8, EFRAME_entry_vector + 1(%rsp)
         SAVE_ALL
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
@@ -338,7 +338,7 @@ LABEL(sysenter_eflags_saved, 0)
         pushq $0 /* null rip */
         pushq $0
         BUILD_BUG_ON(TRAP_syscall & 0xff)
-        movb  $TRAP_syscall >> 8, 4+1(%rsp)
+        movb  $TRAP_syscall >> 8, EFRAME_entry_vector + 1(%rsp)
         SAVE_ALL
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
@@ -393,7 +393,7 @@ FUNC(entry_int80)
         ENDBR64
         ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
         pushq $0
-        movb  $0x80, 4(%rsp)
+        movb  $0x80, EFRAME_entry_vector(%rsp)
         SAVE_ALL
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
@@ -658,7 +658,7 @@ END(ret_from_intr)
         .section .init.text, "ax", @progbits
 FUNC(early_page_fault)
         ENDBR64
-        movb  $X86_EXC_PF, 4(%rsp)
+        movb  $X86_EXC_PF, EFRAME_entry_vector(%rsp)
         SAVE_ALL
         movq  %rsp, %rdi
         call  do_early_page_fault
@@ -727,7 +727,7 @@ END(common_interrupt)
 
 FUNC(entry_PF)
         ENDBR64
-        movb  $X86_EXC_PF, 4(%rsp)
+        movb  $X86_EXC_PF, EFRAME_entry_vector(%rsp)
 END(entry_PF)
 /* No special register assumptions. */
 FUNC(handle_exception, 0)
@@ -911,98 +911,98 @@ END(entry_DE)
 FUNC(entry_MF)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_MF, 4(%rsp)
+        movb  $X86_EXC_MF, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_MF)
 
 FUNC(entry_XM)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_XM, 4(%rsp)
+        movb  $X86_EXC_XM, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_XM)
 
 FUNC(entry_NM)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_NM, 4(%rsp)
+        movb  $X86_EXC_NM, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_NM)
 
 FUNC(entry_DB)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_DB, 4(%rsp)
+        movb  $X86_EXC_DB, EFRAME_entry_vector(%rsp)
         jmp   handle_ist_exception
 END(entry_DB)
 
 FUNC(entry_BP)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_BP, 4(%rsp)
+        movb  $X86_EXC_BP, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_BP)
 
 FUNC(entry_OF)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_OF, 4(%rsp)
+        movb  $X86_EXC_OF, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_OF)
 
 FUNC(entry_BR)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_BR, 4(%rsp)
+        movb  $X86_EXC_BR, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_BR)
 
 FUNC(entry_UD)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_UD, 4(%rsp)
+        movb  $X86_EXC_UD, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_UD)
 
 FUNC(entry_TS)
         ENDBR64
-        movb  $X86_EXC_TS, 4(%rsp)
+        movb  $X86_EXC_TS, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_TS)
 
 FUNC(entry_NP)
         ENDBR64
-        movb  $X86_EXC_NP, 4(%rsp)
+        movb  $X86_EXC_NP, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_NP)
 
 FUNC(entry_SS)
         ENDBR64
-        movb  $X86_EXC_SS, 4(%rsp)
+        movb  $X86_EXC_SS, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_SS)
 
 FUNC(entry_GP)
         ENDBR64
-        movb  $X86_EXC_GP, 4(%rsp)
+        movb  $X86_EXC_GP, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_GP)
 
 FUNC(entry_AC)
         ENDBR64
-        movb  $X86_EXC_AC, 4(%rsp)
+        movb  $X86_EXC_AC, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_AC)
 
 FUNC(entry_CP)
         ENDBR64
-        movb  $X86_EXC_CP, 4(%rsp)
+        movb  $X86_EXC_CP, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_CP)
 
 FUNC(entry_DF)
         ENDBR64
-        movb  $X86_EXC_DF, 4(%rsp)
+        movb  $X86_EXC_DF, EFRAME_entry_vector(%rsp)
         /* Set AC to reduce chance of further SMAP faults */
         ALTERNATIVE "", stac, X86_FEATURE_XEN_SMAP
         SAVE_ALL
@@ -1028,7 +1028,7 @@ END(entry_DF)
 FUNC(entry_NMI)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_NMI, 4(%rsp)
+        movb  $X86_EXC_NMI, EFRAME_entry_vector(%rsp)
 END(entry_NMI)
 
 FUNC(handle_ist_exception)
@@ -1164,7 +1164,7 @@ END(handle_ist_exception)
 FUNC(entry_MC)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_MC, 4(%rsp)
+        movb  $X86_EXC_MC, EFRAME_entry_vector(%rsp)
         jmp   handle_ist_exception
 END(entry_MC)
 
@@ -1203,7 +1203,7 @@ FUNC_LOCAL(autogen_stubs, 0) /* Automatically generated stubs. */
 1:
         ENDBR64
         pushq $0
-        movb  $vec,4(%rsp)
+        movb  $vec, EFRAME_entry_vector(%rsp)
         jmp   common_interrupt
 
         entrypoint 1b
@@ -1217,7 +1217,7 @@ FUNC_LOCAL(autogen_stubs, 0) /* Automatically generated stubs. */
         test  $8,%spl        /* 64bit exception frames are 16 byte aligned, but the word */
         jz    2f             /* size is 8 bytes.  Check whether the processor gave us an */
         pushq $0             /* error code, and insert an empty one if not.              */
-2:      movb  $vec,4(%rsp)
+2:      movb  $vec, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 
         entrypoint 1b
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 22:55:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 22:55:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685813.1067146 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rejsF-0003vS-Fb; Mon, 26 Feb 2024 22:55:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685813.1067146; Mon, 26 Feb 2024 22:55:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rejsF-0003vK-D9; Mon, 26 Feb 2024 22:55:03 +0000
Received: by outflank-mailman (input) for mailman id 685813;
 Mon, 26 Feb 2024 22:55:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejsE-0003v9-3v
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejsE-0008BN-14
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejsD-0004ak-VW
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=CS8tz+M6AYtFXvRWUhLC6gRqbC5+6wxcfrlkw1XtKLE=; b=4djhps7czlT70w/xOU7cg8WjBM
	MLrG06R23sKUoAQEieFTQs10sVNkeDrEsHnYV3uzXAhwM5Rbb/M87nvwDNok3jGpwAeviE10qDe8w
	4d6vOwnpHsEhQceyEExcnx16EalLONJ7z/RT9Yj6/MrsqmZqCpIdovHbLe26WxLvsogk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/livepatch: fix norevert test hook setup typo
Message-Id: <E1rejsD-0004ak-VW@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 22:55:01 +0000

commit f0622dd4fd6ae6ddb523a45d89ed9b8f3a9a8f36
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon Feb 26 10:13:46 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 10:13:46 2024 +0100

    xen/livepatch: fix norevert test hook setup typo
    
    The test code has a typo in using LIVEPATCH_APPLY_HOOK() instead of
    LIVEPATCH_REVERT_HOOK().
    
    Fixes: 6047104c3ccc ('livepatch: Add per-function applied/reverted state tracking marker')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 xen/test/livepatch/xen_action_hooks_norevert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/test/livepatch/xen_action_hooks_norevert.c b/xen/test/livepatch/xen_action_hooks_norevert.c
index 3e21ade6ab..c173855192 100644
--- a/xen/test/livepatch/xen_action_hooks_norevert.c
+++ b/xen/test/livepatch/xen_action_hooks_norevert.c
@@ -120,7 +120,7 @@ static void post_revert_hook(livepatch_payload_t *payload)
     printk(KERN_DEBUG "%s: Hook done.\n", __func__);
 }
 
-LIVEPATCH_APPLY_HOOK(revert_hook);
+LIVEPATCH_REVERT_HOOK(revert_hook);
 
 LIVEPATCH_PREAPPLY_HOOK(pre_apply_hook);
 LIVEPATCH_POSTAPPLY_HOOK(post_apply_hook);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 22:55:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 22:55:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685814.1067150 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rejsP-0003xN-H6; Mon, 26 Feb 2024 22:55:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685814.1067150; Mon, 26 Feb 2024 22:55:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rejsP-0003xG-EZ; Mon, 26 Feb 2024 22:55:13 +0000
Received: by outflank-mailman (input) for mailman id 685814;
 Mon, 26 Feb 2024 22:55:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejsO-0003x4-5N
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejsO-0008Bw-4I
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejsO-0004bB-3S
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=fyClxZiTwdVAhA/9OvYbC1ZG6wpL45ltHYl4CzkuyMY=; b=2hu+Y0Ph0XzmkunzjrzBm3Wvq2
	8e5n+0weExdEEZ/9HovPl+ndkZ2ILsM6H61rd0vCqcI0qlQAPfv1kBXHWp0/0j0fgnyoybz5pEvsl
	4XrVK81CSEDl5F0K0HYI935AqIrBzVgA+cmYFVGY3GzuW7YOd1aOj9MKRhPYbpl664og=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/hpet: use an atomic add instead of a cmpxchg loop
Message-Id: <E1rejsO-0004bB-3S@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 22:55:12 +0000

commit f49fb70d3d4c1729fce825f0fda6863ac3ec00e0
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Feb 26 10:16:56 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 10:16:56 2024 +0100

    x86/hpet: use an atomic add instead of a cmpxchg loop
    
    The usage of a cmpxchg loop in hpet_get_channel() is unnecessary, as the same
    can be achieved with an atomic increment, which is both simpler to read, and
    avoid any need for a loop.
    
    Note there can be a small divergence in the channel returned if next_channel
    overflows, but returned channel will always be in the [0, num_hpets_used)
    range, and that's fine for the purpose of balancing HPET channels across CPUs.
    
    Signed-of-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/x86/hpet.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/xen/arch/x86/hpet.c b/xen/arch/x86/hpet.c
index d9e9c8ffa3..0759eae055 100644
--- a/xen/arch/x86/hpet.c
+++ b/xen/arch/x86/hpet.c
@@ -457,11 +457,7 @@ static struct hpet_event_channel *hpet_get_channel(unsigned int cpu)
     if ( num_hpets_used >= nr_cpu_ids )
         return &hpet_events[cpu];
 
-    do {
-        next = next_channel;
-        if ( (i = next + 1) == num_hpets_used )
-            i = 0;
-    } while ( cmpxchg(&next_channel, next, i) != next );
+    next = arch_fetch_and_add(&next_channel, 1) % num_hpets_used;
 
     /* try unused channel first */
     for ( i = next; i < next + num_hpets_used; i++ )
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 22:55:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 22:55:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685815.1067154 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rejsZ-0003zy-Ik; Mon, 26 Feb 2024 22:55:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685815.1067154; Mon, 26 Feb 2024 22:55:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rejsZ-0003zr-G7; Mon, 26 Feb 2024 22:55:23 +0000
Received: by outflank-mailman (input) for mailman id 685815;
 Mon, 26 Feb 2024 22:55:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejsY-0003zk-8M
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejsY-0008C4-7e
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejsY-0004bd-6N
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=7PXQEf2Cw7aV7wASIjsp8/TZsUFmZm/PdlVBB/qoOmU=; b=P+FyDUjrMpjTEBJaaa/0jy2OjM
	rl6Ts/5ZQWMNL1O3DUPOPHAtSbdm0LLyQOmMBhcZUph1k32Dw4Q9U0Qy6LaD07+NAecqyGZMwZX0T
	CfNwiUltK/kAWv2xI80PrubQDqMCNNerz0qfE309BBRYdxE2mpl1LJu5iotEu8QZJwqw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/consoled: drop return value from consoled_guest_rx/tx
Message-Id: <E1rejsY-0004bd-6N@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 22:55:22 +0000

commit 001d7fdb5512d4298d92f20cf30dd49939754403
Author:     Nicola Vetrini <nicola.vetrini@bugseng.com>
AuthorDate: Mon Feb 26 10:17:17 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 10:17:17 2024 +0100

    xen/consoled: drop return value from consoled_guest_rx/tx
    
    These functions never saw a usage of their return value since
    they were introduced, so it can be dropped since their usages
    violate MISRA C Rule 17.7:
    "The value returned by a function having non-void return type shall be used".
    
    No functional change.
    
    Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
 xen/drivers/char/consoled.c | 17 +++++------------
 xen/include/xen/consoled.h  |  4 ++--
 2 files changed, 7 insertions(+), 14 deletions(-)

diff --git a/xen/drivers/char/consoled.c b/xen/drivers/char/consoled.c
index 222e018442..b415b632ce 100644
--- a/xen/drivers/char/consoled.c
+++ b/xen/drivers/char/consoled.c
@@ -43,13 +43,13 @@ struct xencons_interface *consoled_get_ring_addr(void)
 static char buf[BUF_SZ + 1];
 
 /* Receives characters from a domain's PV console */
-size_t consoled_guest_rx(void)
+void consoled_guest_rx(void)
 {
-    size_t recv = 0, idx = 0;
+    size_t idx = 0;
     XENCONS_RING_IDX cons, prod;
 
     if ( !cons_ring )
-        return 0;
+        return;
 
     spin_lock(&rx_lock);
 
@@ -73,7 +73,6 @@ size_t consoled_guest_rx(void)
         char c = cons_ring->out[MASK_XENCONS_IDX(cons++, cons_ring->out)];
 
         buf[idx++] = c;
-        recv++;
 
         if ( idx >= BUF_SZ )
         {
@@ -92,18 +91,15 @@ size_t consoled_guest_rx(void)
 
  out:
     spin_unlock(&rx_lock);
-
-    return recv;
 }
 
 /* Sends a character into a domain's PV console */
-size_t consoled_guest_tx(char c)
+void consoled_guest_tx(char c)
 {
-    size_t sent = 0;
     XENCONS_RING_IDX cons, prod;
 
     if ( !cons_ring )
-        return 0;
+        return;
 
     cons = ACCESS_ONCE(cons_ring->in_cons);
     prod = cons_ring->in_prod;
@@ -121,7 +117,6 @@ size_t consoled_guest_tx(char c)
         goto notify;
 
     cons_ring->in[MASK_XENCONS_IDX(prod++, cons_ring->in)] = c;
-    sent++;
 
     /* Write to the ring before updating the pointer */
     smp_wmb();
@@ -130,8 +125,6 @@ size_t consoled_guest_tx(char c)
  notify:
     /* Always notify the guest: prevents receive path from getting stuck. */
     pv_shim_inject_evtchn(pv_console_evtchn());
-
-    return sent;
 }
 
 /*
diff --git a/xen/include/xen/consoled.h b/xen/include/xen/consoled.h
index 2b30516b3a..bd7ab6329e 100644
--- a/xen/include/xen/consoled.h
+++ b/xen/include/xen/consoled.h
@@ -5,8 +5,8 @@
 
 void consoled_set_ring_addr(struct xencons_interface *ring);
 struct xencons_interface *consoled_get_ring_addr(void);
-size_t consoled_guest_rx(void);
-size_t consoled_guest_tx(char c);
+void consoled_guest_rx(void);
+void consoled_guest_tx(char c);
 
 #endif /* __XEN_CONSOLED_H__ */
 /*
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 22:55:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 22:55:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685816.1067158 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rejsj-00042z-Kf; Mon, 26 Feb 2024 22:55:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685816.1067158; Mon, 26 Feb 2024 22:55:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rejsj-00042p-Hl; Mon, 26 Feb 2024 22:55:33 +0000
Received: by outflank-mailman (input) for mailman id 685816;
 Mon, 26 Feb 2024 22:55:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejsi-00042a-BS
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejsi-0008CN-Ag
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejsi-0004c6-9l
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=JzfLsQ2IDu8NzHeBGpnCkKc6GL9x58afCjlcyF8HEGs=; b=lVTqhgiQXz0z3bk8OL7X/pHAP7
	UGgX2feafjTqJH9F6DP03V8v4Fcb7XesD54ry/1C9l/YSfBQ+UkpBdhjoL1ICXjddKO4dSqMu0xcK
	lgBDKFVu/Ophqc/LZm99RKqSyRHJpW0nHd7U6Aksl9t9NOHuWuSUU6bkfObucz3VakR8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/cmdline: fix printf format specifier in no_config_param()
Message-Id: <E1rejsi-0004c6-9l@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 22:55:32 +0000

commit ef101f525173cf51dc70f4c77862f6f10a8ddccf
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon Feb 26 10:17:40 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 10:17:40 2024 +0100

    xen/cmdline: fix printf format specifier in no_config_param()
    
    '*' sets the width field, which is the minimum number of characters to output,
    but what we want in no_config_param() is the precision instead, which is '.*'
    as it imposes a maximum limit on the output.
    
    Fixes: 68d757df8dd2 ('x86/pv: Options to disable and/or compile out 32bit PV support')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/include/xen/param.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/include/xen/param.h b/xen/include/xen/param.h
index 9170455cde..6442a92aff 100644
--- a/xen/include/xen/param.h
+++ b/xen/include/xen/param.h
@@ -191,7 +191,7 @@ static inline void no_config_param(const char *cfg, const char *param,
 {
     int len = e ? ({ ASSERT(e >= s); e - s; }) : strlen(s);
 
-    printk(XENLOG_INFO "CONFIG_%s disabled - ignoring '%s=%*s' setting\n",
+    printk(XENLOG_INFO "CONFIG_%s disabled - ignoring '%s=%.*s' setting\n",
            cfg, param, len, s);
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 22:55:43 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 22:55:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685817.1067162 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rejst-00045g-MB; Mon, 26 Feb 2024 22:55:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685817.1067162; Mon, 26 Feb 2024 22:55:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rejst-00045Y-JB; Mon, 26 Feb 2024 22:55:43 +0000
Received: by outflank-mailman (input) for mailman id 685817;
 Mon, 26 Feb 2024 22:55:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejss-00045Q-Es
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejss-0008CW-E7
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejss-0004cX-Cn
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=HbWSANjoTgWfGLigEJ6f26HOJ0ZdpQ2ujzIZrNtS86Q=; b=2lbfRbEzaStDQz+dfJLxSSaYO+
	RTOHA2d1k5vs1B8/Fw7i5xxp3kOc0jXuCV58Dq0+C3+TVqBOFhwsmIym4XAb4hbBmmL6FDPuOzWct
	Jb1lNkPZjOed5YdbYshjFTlsg9IHJJEchCmLLsScNSjGOP8JPqKgtXebUqL13o+iRdqs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/altcall: use a union as register type for function parameters on clang
Message-Id: <E1rejss-0004cX-Cn@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 22:55:42 +0000

commit 2ce562b2a413cbdb2e1128989ed1722290a27c4e
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon Feb 26 10:18:01 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 10:18:01 2024 +0100

    x86/altcall: use a union as register type for function parameters on clang
    
    The current code for alternative calls uses the caller parameter types as the
    types for the register variables that serve as function parameters:
    
    uint8_t foo;
    [...]
    alternative_call(myfunc, foo);
    
    Would expand roughly into:
    
    register unint8_t a1_ asm("rdi") = foo;
    register unsigned long a2_ asm("rsi");
    [...]
    asm volatile ("call *%c[addr](%%rip)"...);
    
    However with -O2 clang will generate incorrect code, given the following
    example:
    
    unsigned int func(uint8_t t)
    {
        return t;
    }
    
    static void bar(uint8_t b)
    {
        int ret_;
        register uint8_t di asm("rdi") = b;
        register unsigned long si asm("rsi");
        register unsigned long dx asm("rdx");
        register unsigned long cx asm("rcx");
        register unsigned long r8 asm("r8");
        register unsigned long r9 asm("r9");
        register unsigned long r10 asm("r10");
        register unsigned long r11 asm("r11");
    
        asm volatile ( "call %c[addr]"
                       : "+r" (di), "=r" (si), "=r" (dx),
                         "=r" (cx), "=r" (r8), "=r" (r9),
                         "=r" (r10), "=r" (r11), "=a" (ret_)
                       : [addr] "i" (&(func)), "g" (func)
                       : "memory" );
    }
    
    void foo(unsigned int a)
    {
        bar(a);
    }
    
    Clang generates the following assembly code:
    
    func:                                   # @func
            movl    %edi, %eax
            retq
    foo:                                    # @foo
            callq   func
            retq
    
    Note the truncation of the unsigned int parameter 'a' of foo() to uint8_t when
    passed into bar() is lost.  clang doesn't zero extend the parameters in the
    callee when required, as the psABI mandates.
    
    The above can be worked around by using a union when defining the register
    variables, so that `di` becomes:
    
    register union {
        uint8_t e;
        unsigned long r;
    } di asm("rdi") = { .e = b };
    
    Which results in following code generated for `foo()`:
    
    foo:                                    # @foo
            movzbl  %dil, %edi
            callq   func
            retq
    
    So the truncation is not longer lost.  Apply such workaround only when built
    with clang.
    
    Reported-by: Matthew Grooms <mgrooms@shrew.net>
    Link: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277200
    Link: https://github.com/llvm/llvm-project/issues/12579
    Link: https://github.com/llvm/llvm-project/issues/82598
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/include/asm/alternative.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/xen/arch/x86/include/asm/alternative.h b/xen/arch/x86/include/asm/alternative.h
index a1cd6a9fe5..3c14db5078 100644
--- a/xen/arch/x86/include/asm/alternative.h
+++ b/xen/arch/x86/include/asm/alternative.h
@@ -167,9 +167,34 @@ extern void alternative_branches(void);
 #define ALT_CALL_arg5 "r8"
 #define ALT_CALL_arg6 "r9"
 
+#ifdef CONFIG_CC_IS_CLANG
+/*
+ * Use a union with an unsigned long in order to prevent clang from
+ * skipping a possible truncation of the value.  By using the union any
+ * truncation is carried before the call instruction, in turn covering
+ * for ABI-non-compliance in that the necessary clipping / extension of
+ * the value is supposed to be carried out in the callee.
+ *
+ * Note this behavior is not mandated by the standard, and hence could
+ * stop being a viable workaround, or worse, could cause a different set
+ * of code-generation issues in future clang versions.
+ *
+ * This has been reported upstream:
+ * https://github.com/llvm/llvm-project/issues/12579
+ * https://github.com/llvm/llvm-project/issues/82598
+ */
+#define ALT_CALL_ARG(arg, n)                                            \
+    register union {                                                    \
+        typeof(arg) e;                                                  \
+        unsigned long r;                                                \
+    } a ## n ## _ asm ( ALT_CALL_arg ## n ) = {                         \
+        .e = ({ BUILD_BUG_ON(sizeof(arg) > sizeof(void *)); (arg); })   \
+    }
+#else
 #define ALT_CALL_ARG(arg, n) \
     register typeof(arg) a ## n ## _ asm ( ALT_CALL_arg ## n ) = \
         ({ BUILD_BUG_ON(sizeof(arg) > sizeof(void *)); (arg); })
+#endif
 #define ALT_CALL_NO_ARG(n) \
     register unsigned long a ## n ## _ asm ( ALT_CALL_arg ## n )
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Mon Feb 26 22:55:53 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 26 Feb 2024 22:55:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685818.1067166 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rejt3-00048L-Ny; Mon, 26 Feb 2024 22:55:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685818.1067166; Mon, 26 Feb 2024 22:55:53 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rejt3-00048E-Kf; Mon, 26 Feb 2024 22:55:53 +0000
Received: by outflank-mailman (input) for mailman id 685818;
 Mon, 26 Feb 2024 22:55:52 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejt2-000487-Il
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:52 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejt2-0008Cn-Hw
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rejt2-0004d0-Gu
 for xen-changelog@lists.xenproject.org; Mon, 26 Feb 2024 22:55:52 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=qcBvrng14RaDA25QOBadcaGQmSELpXA9oaYQtDWWvX4=; b=Y0odC5/WhHgyKtPD4FjsXTHzX+
	owg44OYdsdmIdwNUlFR3do+ZtHwVuRUogMbgSLeqiO7ZDyjvdrQaWv9/z7fbnvzZRkL4ngLvCTBVc
	DJYQcDbtZuvGsalOKca+Y10c/vjk3pb1m9CETPClgOOnX52pGC547nRM5s6j/7CT0TtM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen: move BUG_ON(), WARN_ON(), ASSERT(), ASSERT_UNREACHABLE() to xen/bug.h
Message-Id: <E1rejt2-0004d0-Gu@xenbits.xenproject.org>
Date: Mon, 26 Feb 2024 22:55:52 +0000

commit 8de3afc0b402bc17f65093a53e5870862707a8c7
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Mon Feb 26 10:19:08 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 10:19:08 2024 +0100

    xen: move BUG_ON(), WARN_ON(), ASSERT(), ASSERT_UNREACHABLE() to xen/bug.h
    
    Move the macros mentioned in the commit subject to their appropriate
    locations.
    Additionally, eliminate the dependency of xen/lib.h from xen/bug.h and
    include "xen/bug.h" in files where xen/bug.h macros are utilized.
    
    Most of the changes were made because a file requires macros from xen/bug.h,
    except for some files for Arm which require definitions of BUG_OPCODE,
    BUG_INSTR, BUG_FN_REG.
    
    xen/lib.h was added to list-sort.c ( otherwise compilation errors related
    to {d}printk occur during compilation of list-sort.c. ) as xen/lib.h was
    removed from xen/list.h. Since nothing in xen/list.h depends on xen/lib.h
    functionality and only xen/bug.h is needed.
    
    cpufeature.h requires the inclusion of <xen/cache.h>;
    otherwise, the following error will occur:
    ld: common/monitor.o:/build/xen/./arch/x86/include/asm/cpufeature.h:41:
    multiple definitions of `__cacheline_aligned';
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    Acked-by: Daniel P. Smith <dpsmith@apertussolutions.com>
---
 xen/arch/arm/arm32/insn.c                |  3 ++-
 xen/arch/arm/arm64/cpufeature.c          |  1 +
 xen/arch/arm/arm64/insn.c                |  1 +
 xen/arch/arm/cpufeature.c                |  1 +
 xen/arch/arm/include/asm/arm32/cmpxchg.h |  1 +
 xen/arch/arm/include/asm/arm64/cmpxchg.h |  2 ++
 xen/arch/arm/include/asm/regs.h          |  2 +-
 xen/arch/arm/include/asm/vgic.h          |  1 +
 xen/arch/ppc/include/asm/time.h          |  2 +-
 xen/arch/x86/bitops.c                    |  2 +-
 xen/arch/x86/include/asm/cpufeature.h    |  1 +
 xen/arch/x86/include/asm/system.h        |  2 +-
 xen/arch/x86/include/asm/x86_64/page.h   |  2 ++
 xen/arch/x86/x86_emulate/private.h       |  1 +
 xen/common/efi/common-stub.c             |  2 +-
 xen/common/version.c                     |  1 +
 xen/include/public/hvm/save.h            |  2 +-
 xen/include/xen/bug.h                    | 19 +++++++++++++++++++
 xen/include/xen/cpumask.h                |  1 +
 xen/include/xen/device_tree.h            |  1 +
 xen/include/xen/lib.h                    | 19 -------------------
 xen/include/xen/list.h                   |  2 +-
 xen/include/xen/livepatch.h              |  2 ++
 xen/include/xen/mm.h                     |  1 +
 xen/include/xen/param.h                  |  1 +
 xen/lib/list-sort.c                      |  1 +
 xen/xsm/flask/ss/ebitmap.h               |  1 +
 27 files changed, 48 insertions(+), 27 deletions(-)

diff --git a/xen/arch/arm/arm32/insn.c b/xen/arch/arm/arm32/insn.c
index 49953a042a..2a62bb9cce 100644
--- a/xen/arch/arm/arm32/insn.c
+++ b/xen/arch/arm/arm32/insn.c
@@ -13,8 +13,9 @@
   * You should have received a copy of the GNU General Public License
   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
   */
-#include <xen/lib.h>
 #include <xen/bitops.h>
+#include <xen/bug.h>
+#include <xen/lib.h>
 #include <xen/sizes.h>
 #include <asm/insn.h>
 
diff --git a/xen/arch/arm/arm64/cpufeature.c b/xen/arch/arm/arm64/cpufeature.c
index b4656ff4d8..864413d9cc 100644
--- a/xen/arch/arm/arm64/cpufeature.c
+++ b/xen/arch/arm/arm64/cpufeature.c
@@ -69,6 +69,7 @@
  *   KVM guests.
  */
 
+#include <xen/bug.h>
 #include <xen/types.h>
 #include <xen/kernel.h>
 #include <asm/sysregs.h>
diff --git a/xen/arch/arm/arm64/insn.c b/xen/arch/arm/arm64/insn.c
index 22f2bdebd5..773c3749d1 100644
--- a/xen/arch/arm/arm64/insn.c
+++ b/xen/arch/arm/arm64/insn.c
@@ -18,6 +18,7 @@
  * You should have received a copy of the GNU General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
+#include <xen/bug.h>
 #include <xen/types.h>
 #include <xen/lib.h>
 #include <xen/errno.h>
diff --git a/xen/arch/arm/cpufeature.c b/xen/arch/arm/cpufeature.c
index f43d5cb338..ef77473bf8 100644
--- a/xen/arch/arm/cpufeature.c
+++ b/xen/arch/arm/cpufeature.c
@@ -5,6 +5,7 @@
  * Copyright (C) 2015 ARM Ltd.
  */
 
+#include <xen/bug.h>
 #include <xen/types.h>
 #include <xen/init.h>
 #include <xen/smp.h>
diff --git a/xen/arch/arm/include/asm/arm32/cmpxchg.h b/xen/arch/arm/include/asm/arm32/cmpxchg.h
index 37b2d64eb6..8455eb7cc3 100644
--- a/xen/arch/arm/include/asm/arm32/cmpxchg.h
+++ b/xen/arch/arm/include/asm/arm32/cmpxchg.h
@@ -1,6 +1,7 @@
 #ifndef __ASM_ARM32_CMPXCHG_H
 #define __ASM_ARM32_CMPXCHG_H
 
+#include <xen/bug.h>
 #include <xen/prefetch.h>
 
 extern void __bad_xchg(volatile void *ptr, int size);
diff --git a/xen/arch/arm/include/asm/arm64/cmpxchg.h b/xen/arch/arm/include/asm/arm64/cmpxchg.h
index 031fa6d92a..f160e8e7bc 100644
--- a/xen/arch/arm/include/asm/arm64/cmpxchg.h
+++ b/xen/arch/arm/include/asm/arm64/cmpxchg.h
@@ -1,6 +1,8 @@
 #ifndef __ASM_ARM64_CMPXCHG_H
 #define __ASM_ARM64_CMPXCHG_H
 
+#include <xen/bug.h>
+
 extern void __bad_xchg(volatile void *ptr, int size);
 
 static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size)
diff --git a/xen/arch/arm/include/asm/regs.h b/xen/arch/arm/include/asm/regs.h
index f998aedff5..0d9f239a77 100644
--- a/xen/arch/arm/include/asm/regs.h
+++ b/xen/arch/arm/include/asm/regs.h
@@ -5,7 +5,7 @@
 
 #ifndef __ASSEMBLY__
 
-#include <xen/lib.h>
+#include <xen/bug.h>
 #include <xen/types.h>
 #include <public/xen.h>
 #include <asm/current.h>
diff --git a/xen/arch/arm/include/asm/vgic.h b/xen/arch/arm/include/asm/vgic.h
index 922779ce14..79b73a0dbb 100644
--- a/xen/arch/arm/include/asm/vgic.h
+++ b/xen/arch/arm/include/asm/vgic.h
@@ -22,6 +22,7 @@
 #include <asm/new_vgic.h>
 #else
 
+#include <xen/bug.h>
 #include <xen/radix-tree.h>
 #include <xen/rbtree.h>
 
diff --git a/xen/arch/ppc/include/asm/time.h b/xen/arch/ppc/include/asm/time.h
index aa9dda82a3..f23eec173e 100644
--- a/xen/arch/ppc/include/asm/time.h
+++ b/xen/arch/ppc/include/asm/time.h
@@ -2,7 +2,7 @@
 #ifndef __ASM_PPC_TIME_H__
 #define __ASM_PPC_TIME_H__
 
-#include <xen/lib.h>
+#include <xen/bug.h>
 #include <asm/processor.h>
 #include <asm/regs.h>
 
diff --git a/xen/arch/x86/bitops.c b/xen/arch/x86/bitops.c
index f6ee71512c..720ab32362 100644
--- a/xen/arch/x86/bitops.c
+++ b/xen/arch/x86/bitops.c
@@ -1,6 +1,6 @@
 
 #include <xen/bitops.h>
-#include <xen/lib.h>
+#include <xen/bug.h>
 
 unsigned int __find_first_bit(
     const unsigned long *addr, unsigned int size)
diff --git a/xen/arch/x86/include/asm/cpufeature.h b/xen/arch/x86/include/asm/cpufeature.h
index 896483a900..be16492c68 100644
--- a/xen/arch/x86/include/asm/cpufeature.h
+++ b/xen/arch/x86/include/asm/cpufeature.h
@@ -6,6 +6,7 @@
 #ifndef __ASM_I386_CPUFEATURE_H
 #define __ASM_I386_CPUFEATURE_H
 
+#include <xen/cache.h>
 #include <xen/const.h>
 #include <asm/cpuid.h>
 
diff --git a/xen/arch/x86/include/asm/system.h b/xen/arch/x86/include/asm/system.h
index 6e40a03cb3..debf6bfa17 100644
--- a/xen/arch/x86/include/asm/system.h
+++ b/xen/arch/x86/include/asm/system.h
@@ -1,8 +1,8 @@
 #ifndef __ASM_SYSTEM_H
 #define __ASM_SYSTEM_H
 
-#include <xen/lib.h>
 #include <xen/bitops.h>
+#include <xen/bug.h>
 #include <asm/cpufeature.h>
 #include <asm/x86-defns.h>
 
diff --git a/xen/arch/x86/include/asm/x86_64/page.h b/xen/arch/x86/include/asm/x86_64/page.h
index f49e10475f..19ca64d792 100644
--- a/xen/arch/x86/include/asm/x86_64/page.h
+++ b/xen/arch/x86/include/asm/x86_64/page.h
@@ -19,6 +19,8 @@ static inline unsigned long canonicalise_addr(unsigned long addr)
         return addr & ~CANONICAL_MASK;
 }
 
+#include <xen/bug.h>
+
 #include <xen/types.h>
 
 #include <xen/pdx.h>
diff --git a/xen/arch/x86/x86_emulate/private.h b/xen/arch/x86/x86_emulate/private.h
index 33f2870508..0fa26ba00a 100644
--- a/xen/arch/x86/x86_emulate/private.h
+++ b/xen/arch/x86/x86_emulate/private.h
@@ -8,6 +8,7 @@
 
 #ifdef __XEN__
 
+# include <xen/bug.h>
 # include <xen/kernel.h>
 # include <asm/endbr.h>
 # include <asm/msr-index.h>
diff --git a/xen/common/efi/common-stub.c b/xen/common/efi/common-stub.c
index 5a91fe28cc..77f138a6c5 100644
--- a/xen/common/efi/common-stub.c
+++ b/xen/common/efi/common-stub.c
@@ -1,6 +1,6 @@
+#include <xen/bug.h>
 #include <xen/efi.h>
 #include <xen/errno.h>
-#include <xen/lib.h>
 
 bool efi_enabled(unsigned int feature)
 {
diff --git a/xen/common/version.c b/xen/common/version.c
index e807ef4de0..80869430fc 100644
--- a/xen/common/version.c
+++ b/xen/common/version.c
@@ -1,3 +1,4 @@
+#include <xen/bug.h>
 #include <xen/compile.h>
 #include <xen/init.h>
 #include <xen/errno.h>
diff --git a/xen/include/public/hvm/save.h b/xen/include/public/hvm/save.h
index 31b5cd163b..72e16ab5bc 100644
--- a/xen/include/public/hvm/save.h
+++ b/xen/include/public/hvm/save.h
@@ -51,7 +51,7 @@ struct hvm_save_descriptor {
     struct __HVM_SAVE_TYPE_##_x { _type t; char c[_code]; char cpt[2];};  \
     struct __HVM_SAVE_TYPE_COMPAT_##_x { _ctype t; }
 
-# include <xen/lib.h> /* BUG() */
+# include <xen/bug.h> /* BUG() */
 # define DECLARE_HVM_SAVE_TYPE(_x, _code, _type)                         \
     static inline int __HVM_SAVE_FIX_COMPAT_##_x(void *h, uint32_t size) \
         { BUG(); return -1; }                                            \
diff --git a/xen/include/xen/bug.h b/xen/include/xen/bug.h
index a11d4239f8..2c45c462fc 100644
--- a/xen/include/xen/bug.h
+++ b/xen/include/xen/bug.h
@@ -16,6 +16,7 @@
 
 #ifndef __ASSEMBLY__
 
+#include <xen/compiler.h>
 #include <xen/macros.h>
 #include <xen/types.h>
 
@@ -126,6 +127,24 @@ static void always_inline run_in_exception_handler(bug_fn_t *fn)
 } while ( false )
 #endif
 
+#define BUG_ON(p)  do { if (unlikely(p)) BUG();  } while (0)
+#define WARN_ON(p)  ({                  \
+    bool ret_warn_on_ = (p);            \
+                                        \
+    if ( unlikely(ret_warn_on_) )       \
+        WARN();                         \
+    unlikely(ret_warn_on_);             \
+})
+
+#ifndef NDEBUG
+#define ASSERT(p) \
+    do { if ( unlikely(!(p)) ) assert_failed(#p); } while (0)
+#define ASSERT_UNREACHABLE() assert_failed("unreachable")
+#else
+#define ASSERT(p) do { if ( 0 && (p) ) {} } while (0)
+#define ASSERT_UNREACHABLE() do { } while (0)
+#endif
+
 #ifdef CONFIG_GENERIC_BUG_FRAME
 
 /*
diff --git a/xen/include/xen/cpumask.h b/xen/include/xen/cpumask.h
index 145e140481..b713bb69a9 100644
--- a/xen/include/xen/cpumask.h
+++ b/xen/include/xen/cpumask.h
@@ -56,6 +56,7 @@
  */
 
 #include <xen/bitmap.h>
+#include <xen/bug.h>
 #include <xen/kernel.h>
 #include <xen/random.h>
 
diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index 94a836cb4e..6fe2fa8b21 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -14,6 +14,7 @@
 #include <asm/device.h>
 #include <public/xen.h>
 #include <public/device_tree_defs.h>
+#include <xen/bug.h>
 #include <xen/kernel.h>
 #include <xen/string.h>
 #include <xen/types.h>
diff --git a/xen/include/xen/lib.h b/xen/include/xen/lib.h
index abee6c20d7..394319c818 100644
--- a/xen/include/xen/lib.h
+++ b/xen/include/xen/lib.h
@@ -5,31 +5,12 @@
 
 #ifndef __ASSEMBLY__
 
-#include <xen/bug.h>
 #include <xen/inttypes.h>
 #include <xen/stdarg.h>
 #include <xen/types.h>
 #include <xen/xmalloc.h>
 #include <xen/string.h>
 
-#define BUG_ON(p)  do { if (unlikely(p)) BUG();  } while (0)
-#define WARN_ON(p)  ({                  \
-    bool ret_warn_on_ = (p);            \
-                                        \
-    if ( unlikely(ret_warn_on_) )       \
-        WARN();                         \
-    unlikely(ret_warn_on_);             \
-})
-
-#ifndef NDEBUG
-#define ASSERT(p) \
-    do { if ( unlikely(!(p)) ) assert_failed(#p); } while (0)
-#define ASSERT_UNREACHABLE() assert_failed("unreachable")
-#else
-#define ASSERT(p) do { if ( 0 && (p) ) {} } while (0)
-#define ASSERT_UNREACHABLE() do { } while (0)
-#endif
-
 #define __ACCESS_ONCE(x) ({                             \
             (void)(typeof(x))0; /* Scalar typecheck. */ \
             (volatile typeof(x) *)&(x); })
diff --git a/xen/include/xen/list.h b/xen/include/xen/list.h
index dc5a8c461b..b5eab3a1eb 100644
--- a/xen/include/xen/list.h
+++ b/xen/include/xen/list.h
@@ -7,7 +7,7 @@
 #ifndef __XEN_LIST_H__
 #define __XEN_LIST_H__
 
-#include <xen/lib.h>
+#include <xen/bug.h>
 #include <asm/system.h>
 
 /*
diff --git a/xen/include/xen/livepatch.h b/xen/include/xen/livepatch.h
index 45df4bba4f..ad0eae28bd 100644
--- a/xen/include/xen/livepatch.h
+++ b/xen/include/xen/livepatch.h
@@ -18,6 +18,8 @@ struct xen_sysctl_livepatch_op;
 
 #ifdef CONFIG_LIVEPATCH
 
+#include <xen/lib.h>
+
 /*
  * We use alternative and exception table code - which by default are __init
  * only, however we need them during runtime. These macros allows us to build
diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h
index 3d9b2d05a5..bb29b352ec 100644
--- a/xen/include/xen/mm.h
+++ b/xen/include/xen/mm.h
@@ -61,6 +61,7 @@
 #ifndef __XEN_MM_H__
 #define __XEN_MM_H__
 
+#include <xen/bug.h>
 #include <xen/compiler.h>
 #include <xen/mm-frame.h>
 #include <xen/types.h>
diff --git a/xen/include/xen/param.h b/xen/include/xen/param.h
index 6442a92aff..13607e0e50 100644
--- a/xen/include/xen/param.h
+++ b/xen/include/xen/param.h
@@ -1,6 +1,7 @@
 #ifndef _XEN_PARAM_H
 #define _XEN_PARAM_H
 
+#include <xen/bug.h>
 #include <xen/hypfs.h>
 #include <xen/init.h>
 #include <xen/lib.h>
diff --git a/xen/lib/list-sort.c b/xen/lib/list-sort.c
index de1af2ef8b..251764804c 100644
--- a/xen/lib/list-sort.c
+++ b/xen/lib/list-sort.c
@@ -15,6 +15,7 @@
  * this program; If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <xen/lib.h>
 #include <xen/list.h>
 #include <xen/list_sort.h>
 
diff --git a/xen/xsm/flask/ss/ebitmap.h b/xen/xsm/flask/ss/ebitmap.h
index bb43de891d..7b2da8179a 100644
--- a/xen/xsm/flask/ss/ebitmap.h
+++ b/xen/xsm/flask/ss/ebitmap.h
@@ -15,6 +15,7 @@
 #define _SS_EBITMAP_H_
 
 #include <xen/bitmap.h>
+#include <xen/bug.h>
 
 #define EBITMAP_UNIT_NUMS	((32 - sizeof(void *) - sizeof(u32))	\
 					/ sizeof(unsigned long))
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 09:22:17 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 09:22:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685917.1067360 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1retf3-0000yy-8X; Tue, 27 Feb 2024 09:22:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685917.1067360; Tue, 27 Feb 2024 09:22:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1retf3-0000yq-5Z; Tue, 27 Feb 2024 09:22:05 +0000
Received: by outflank-mailman (input) for mailman id 685917;
 Tue, 27 Feb 2024 09:22:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1retf1-0000yi-8D
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:22:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1retf1-0004Cd-6R
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:22:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1retf1-0003Pl-5R
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:22:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ZvpvVgD3MiI0KozEEnTY/dc2LED+IFLm57rDrMtv+M8=; b=EggafpEF2d32So7nZrjSKSlO9x
	GXc+tivv6WTxYkyY5e5kbFtW76LE250cvBNU0ScY9c6bjrbzzBjN6x+qk6HuAxXqBsXPxqXotUgft
	s43jants68jPcyJQU/IcuOYA9ae8Y7IxP0qi2+s6SLiVw4AK2OMSzoVzg6jMS9r9vjQ0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] automation: remove bin86/dev86 from tumbleweed image
Message-Id: <E1retf1-0003Pl-5R@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 09:22:03 +0000

commit 150e7a4e79d3d60e8e7c988c1367a0c1d7830693
Author:     Olaf Hering <olaf@aepfle.de>
AuthorDate: Tue Feb 27 10:16:35 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 10:16:35 2024 +0100

    automation: remove bin86/dev86 from tumbleweed image
    
    https://build.opensuse.org/request/show/1126240
    
    Signed-off-by: Olaf Hering <olaf@aepfle.de>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 automation/build/suse/opensuse-tumbleweed.dockerfile | 2 --
 1 file changed, 2 deletions(-)

diff --git a/automation/build/suse/opensuse-tumbleweed.dockerfile b/automation/build/suse/opensuse-tumbleweed.dockerfile
index 38f6fda2ff..f00e03eda7 100644
--- a/automation/build/suse/opensuse-tumbleweed.dockerfile
+++ b/automation/build/suse/opensuse-tumbleweed.dockerfile
@@ -11,13 +11,11 @@ RUN zypper ref && zypper dup -y --no-recommends
 RUN zypper install -y --no-recommends \
         acpica \
         bc \
-        bin86 \
         bison \
         bzip2 \
         checkpolicy \
         clang \
         cmake \
-        dev86 \
         diffutils \
         discount \
         flex \
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 09:22:17 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 09:22:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685918.1067364 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1retfD-00010T-9k; Tue, 27 Feb 2024 09:22:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685918.1067364; Tue, 27 Feb 2024 09:22:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1retfD-00010M-6z; Tue, 27 Feb 2024 09:22:15 +0000
Received: by outflank-mailman (input) for mailman id 685918;
 Tue, 27 Feb 2024 09:22:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1retfB-00010C-Cn
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:22:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1retfB-0004Ch-BE
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:22:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1retfB-0003Rr-8T
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:22:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=CqW4ShWUNTzOs+nfGEBMhmiqcnPZgcV8zBPfBXQDB7s=; b=iBchCIPLaLbV9DRVCJH8C9TODP
	qfslr5ZaKwcleMNVwoxJ4aOwquRPQul1hFFMWQ3SI9A6teRafUy1DWFiQwPgeZ9WDmva9lPFhX9TG
	cNTWTA1r7eUGkahCUFP71fm86LbxEvK3DlJ7CqKxVjqhXTHuaSnzwyFnOTLONHE0QtT8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/ppc: address violations of MISRA C:2012 Rule 11.8
Message-Id: <E1retfB-0003Rr-8T@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 09:22:13 +0000

commit 84b9617c039f566f43af4a7448bd34d160cbd112
Author:     Maria Celeste Cesario <maria.celeste.cesario@bugseng.com>
AuthorDate: Tue Feb 27 10:16:52 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 10:16:52 2024 +0100

    xen/ppc: address violations of MISRA C:2012 Rule 11.8
    
    The xen sources contain violations of MISRA C:2012 Rule 11.8 whose
    headline states:
    "A conversion shall not remove any const, volatile or _Atomic qualification
    from the type pointed to by a pointer".
    
    Fix violation by adding missing const qualifier in cast.
    
    Signed-off-by: Maria Celeste Cesario <maria.celeste.cesario@bugseng.com>
    Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Acked-by: Shawn Anastasio <sanastasio@raptorengineering.com>
---
 xen/arch/ppc/include/asm/atomic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/ppc/include/asm/atomic.h b/xen/arch/ppc/include/asm/atomic.h
index 64168aa3f1..fe778579fb 100644
--- a/xen/arch/ppc/include/asm/atomic.h
+++ b/xen/arch/ppc/include/asm/atomic.h
@@ -16,7 +16,7 @@
 
 static inline int atomic_read(const atomic_t *v)
 {
-    return *(volatile int *)&v->counter;
+    return *(const volatile int *)&v->counter;
 }
 
 static inline int _atomic_read(atomic_t v)
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 09:22:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 09:22:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685919.1067368 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1retfN-00012k-BJ; Tue, 27 Feb 2024 09:22:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685919.1067368; Tue, 27 Feb 2024 09:22:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1retfN-00012d-8X; Tue, 27 Feb 2024 09:22:25 +0000
Received: by outflank-mailman (input) for mailman id 685919;
 Tue, 27 Feb 2024 09:22:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1retfL-00012T-Ff
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:22:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1retfL-0004DH-Et
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:22:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1retfL-0003Sl-Db
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:22:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=jOZIOSHS7H2NNuGZ/K5/4LblgdhG9cdVrSg032vmRps=; b=wjjBqtv6Xp877KEdJgPvOmoDP5
	EbrYFJVnsn9gLoC4x3fclA/9kjhOMtra8qzjxDV0cXCjgraMeIubFV71fZ1ZTtr147j7wGPiPTDTm
	WCwVOd0F2d+FmJZWMR3N+k/WXbkpyM4ZoMYKF3h1fPgGqS1yeCyQuLfLnyrJOCUW7vYk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen: introduce Kconfig function alignment option
Message-Id: <E1retfL-0003Sl-Db@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 09:22:23 +0000

commit ca7c872c70cb58f1e4b59f8eb619ffa0ecc1ed87
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 10:17:59 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 10:17:59 2024 +0100

    xen: introduce Kconfig function alignment option
    
    And use it to replace CODE_ALIGN in assembly.  This allows to generalize the
    way the code alignment gets set across all architectures.
    
    No functional change intended.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Michal Orzel <michal.orzel@amd.com>
    Acked-by: Shawn Anastasio <sanastasio@raptorengineering.com>
---
 xen/Kconfig                         | 17 +++++++++++++++++
 xen/arch/arm/Kconfig                |  1 +
 xen/arch/arm/include/asm/config.h   |  3 +--
 xen/arch/ppc/Kconfig                |  1 +
 xen/arch/ppc/include/asm/config.h   |  5 -----
 xen/arch/riscv/Kconfig              |  1 +
 xen/arch/riscv/include/asm/config.h |  1 -
 xen/arch/x86/Kconfig                |  1 +
 xen/arch/x86/include/asm/config.h   |  3 +--
 xen/include/xen/linkage.h           |  6 +++---
 10 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/xen/Kconfig b/xen/Kconfig
index 134e6e68ad..1e1b041fd5 100644
--- a/xen/Kconfig
+++ b/xen/Kconfig
@@ -37,6 +37,23 @@ config CC_HAS_VISIBILITY_ATTRIBUTE
 config CC_SPLIT_SECTIONS
 	bool
 
+# Set code alignment.
+#
+# Allow setting on a boolean basis, and then convert such selection to an
+# integer for the build system and code to consume more easily.
+config FUNCTION_ALIGNMENT_4B
+	bool
+config FUNCTION_ALIGNMENT_8B
+	bool
+config FUNCTION_ALIGNMENT_16B
+	bool
+config FUNCTION_ALIGNMENT
+	int
+	default 16 if FUNCTION_ALIGNMENT_16B
+	default  8 if  FUNCTION_ALIGNMENT_8B
+	default  4 if  FUNCTION_ALIGNMENT_4B
+	default  0
+
 source "arch/$(SRCARCH)/Kconfig"
 
 config DEFCONFIG_LIST
diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index 72af329564..40f834bb71 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -11,6 +11,7 @@ config ARM_64
 
 config ARM
 	def_bool y
+	select FUNCTION_ALIGNMENT_4B
 	select HAS_ALTERNATIVE
 	select HAS_DEVICE_TREE
 	select HAS_PASSTHROUGH
diff --git a/xen/arch/arm/include/asm/config.h b/xen/arch/arm/include/asm/config.h
index 3b6d829197..a2e22b659d 100644
--- a/xen/arch/arm/include/asm/config.h
+++ b/xen/arch/arm/include/asm/config.h
@@ -53,8 +53,7 @@
 
 /* Linkage for ARM */
 #ifdef __ASSEMBLY__
-#define CODE_ALIGN 4
-#define ALIGN .balign CODE_ALIGN
+#define ALIGN .balign CONFIG_FUNCTION_ALIGNMENT
 #define ENTRY(name)                             \
   .globl name;                                  \
   ALIGN;                                        \
diff --git a/xen/arch/ppc/Kconfig b/xen/arch/ppc/Kconfig
index ab116ffb2a..f6a77a8200 100644
--- a/xen/arch/ppc/Kconfig
+++ b/xen/arch/ppc/Kconfig
@@ -1,5 +1,6 @@
 config PPC
 	def_bool y
+	select FUNCTION_ALIGNMENT_4B
 	select HAS_DEVICE_TREE
 
 config PPC64
diff --git a/xen/arch/ppc/include/asm/config.h b/xen/arch/ppc/include/asm/config.h
index e5d201e16c..148fb3074d 100644
--- a/xen/arch/ppc/include/asm/config.h
+++ b/xen/arch/ppc/include/asm/config.h
@@ -30,11 +30,6 @@
 #define OPT_CONSOLE_STR "dtuart"
 #define INVALID_VCPU_ID MAX_VIRT_CPUS
 
-/* Linkage for PPC */
-#ifdef __ASSEMBLY__
-#define CODE_ALIGN 4
-#endif
-
 #define XEN_VIRT_START _AC(0xc000000000000000, UL)
 
 /* Fixed address for start of the section containing exception vectors */
diff --git a/xen/arch/riscv/Kconfig b/xen/arch/riscv/Kconfig
index f382b36f6c..b4b354a778 100644
--- a/xen/arch/riscv/Kconfig
+++ b/xen/arch/riscv/Kconfig
@@ -1,5 +1,6 @@
 config RISCV
 	def_bool y
+	select FUNCTION_ALIGNMENT_16B
 
 config RISCV_64
 	def_bool y
diff --git a/xen/arch/riscv/include/asm/config.h b/xen/arch/riscv/include/asm/config.h
index 2c7f2b1ff9..c5f93e6a01 100644
--- a/xen/arch/riscv/include/asm/config.h
+++ b/xen/arch/riscv/include/asm/config.h
@@ -132,7 +132,6 @@
 
 /* Linkage for RISCV */
 #ifdef __ASSEMBLY__
-#define CODE_ALIGN 16
 #define CODE_FILL /* empty */
 #endif
 
diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
index 1acdffc51c..01c6bea480 100644
--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -11,6 +11,7 @@ config X86
 	select ARCH_MAP_DOMAIN_PAGE
 	select ARCH_SUPPORTS_INT128
 	imply CORE_PARKING
+	select FUNCTION_ALIGNMENT_16B
 	select GENERIC_BUG_FRAME
 	select HAS_ALTERNATIVE
 	select HAS_COMPAT
diff --git a/xen/arch/x86/include/asm/config.h b/xen/arch/x86/include/asm/config.h
index 660246d1da..ab7288cb36 100644
--- a/xen/arch/x86/include/asm/config.h
+++ b/xen/arch/x86/include/asm/config.h
@@ -43,9 +43,8 @@
 
 /* Linkage for x86 */
 #ifdef __ASSEMBLY__
-#define CODE_ALIGN 16
 #define CODE_FILL 0x90
-#define ALIGN .align CODE_ALIGN, CODE_FILL
+#define ALIGN .align CONFIG_FUNCTION_ALIGNMENT, CODE_FILL
 #define ENTRY(name)                             \
   ALIGN;                                        \
   GLOBAL(name)
diff --git a/xen/include/xen/linkage.h b/xen/include/xen/linkage.h
index 0997e16810..478b1d7287 100644
--- a/xen/include/xen/linkage.h
+++ b/xen/include/xen/linkage.h
@@ -5,7 +5,6 @@
 
 #include <xen/macros.h>
 
-/* CODE_ALIGN needs to be specified by every architecture. */
 #ifndef CODE_FILL
 # define CODE_FILL ~0
 #endif
@@ -41,9 +40,10 @@
  */
 #define count_args_exp(args...) count_args(args)
 #if count_args_exp(CODE_FILL)
-# define DO_CODE_ALIGN(align...) LASTARG(CODE_ALIGN, ## align), CODE_FILL
+# define DO_CODE_ALIGN(align...) LASTARG(CONFIG_FUNCTION_ALIGNMENT, ## align), \
+                                 CODE_FILL
 #else
-# define DO_CODE_ALIGN(align...) LASTARG(CODE_ALIGN, ## align)
+# define DO_CODE_ALIGN(align...) LASTARG(CONFIG_FUNCTION_ALIGNMENT, ## align)
 #endif
 
 #define FUNC(name, align...) \
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 09:44:06 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 09:44:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685927.1067382 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reu0J-0004Ap-2K; Tue, 27 Feb 2024 09:44:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685927.1067382; Tue, 27 Feb 2024 09:44:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reu0I-0004Ah-Vl; Tue, 27 Feb 2024 09:44:02 +0000
Received: by outflank-mailman (input) for mailman id 685927;
 Tue, 27 Feb 2024 09:44:01 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu0H-0004Ab-Pk
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:01 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu0H-0004aw-NK
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu0H-0004c9-MH
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=JUc45QGj7a98CV/4Kk8jrIucZadTIZA33SYTb0oZ37M=; b=5Gt0FyvnY+R3KnCDxHYSEeaQYp
	vI9v2d0eVKMIZClSHNqPWO5JnuiUShJNEKrO4kIYp6pqwCajJ3t2AlSrQXQ/mRQE6zLq2RoNScuRK
	MEEIONcEwct6WcaRmGX561GFQaUPM4gyitROSMjBXgcWtXvDoZ1hehxkdA8IGQLj4ggU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/HVM: limit upcall vector related verbosity
Message-Id: <E1reu0H-0004c9-MH@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 09:44:01 +0000

commit 164daecb1834b1de5f5943abf2a0806d49470986
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Feb 26 16:03:44 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 16:03:44 2024 +0100

    x86/HVM: limit upcall vector related verbosity
    
    Avoid logging all-identical messages for every vCPU, but make sure to
    log unusual events like the vector differing from vCPU 0's (note that
    the respective condition also makes sure vCPU 0 itself will have the
    vector setting logged), or it changing after it was once set. (Arguably
    a downside is that some vCPU not having its vector set would no longer
    be recognizable from the logs. But I think that's tolerable as
    sufficiently unlikely outside of people actively fiddling with related
    code.)
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/hvm/hvm.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 0cb822a41c..87d33d116b 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4125,7 +4125,15 @@ static int hvmop_set_evtchn_upcall_vector(
     if ( (v = domain_vcpu(d, op.vcpu)) == NULL )
         return -ENOENT;
 
-    printk(XENLOG_G_INFO "%pv: upcall vector %02x\n", v, op.vector);
+    /*
+     * Avoid logging all-identical messages for every vCPU, but make sure to
+     * log unusual events like the vector differing from vCPU 0's, or it
+     * changing after it was once set
+     */
+    if ( op.vector != d->vcpu[0]->arch.hvm.evtchn_upcall_vector ||
+         (v->arch.hvm.evtchn_upcall_vector &&
+          op.vector != v->arch.hvm.evtchn_upcall_vector) )
+        printk(XENLOG_G_INFO "%pv: upcall vector %02x\n", v, op.vector);
 
     v->arch.hvm.evtchn_upcall_vector = op.vector;
     hvm_assert_evtchn_irq(v);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 09:44:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 09:44:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685928.1067386 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reu0T-0004Cj-3a; Tue, 27 Feb 2024 09:44:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685928.1067386; Tue, 27 Feb 2024 09:44:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reu0T-0004Cb-10; Tue, 27 Feb 2024 09:44:13 +0000
Received: by outflank-mailman (input) for mailman id 685928;
 Tue, 27 Feb 2024 09:44:11 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu0R-0004CV-Td
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:11 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu0R-0004bL-SR
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu0R-0004dW-PT
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:11 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=VKoCLWG64Y1xpi+4yLSQYhbMlhVbRQthQG2BF5ccWMI=; b=Bf6mhyN9x0jWDynH+KV+Zrq2MT
	kgHvg7UwsJI/HBFA+nT1EKVcb/j3KJ+vpWGak3tQkcRIE5XBhA3xJ+kuQ+0nltaGxt+ft9VK8e59E
	qJLEyiQPhalJ1cj4s/shkN6ed4AUG9q8lnK/EREo/AINGVDz+Ny3p2/wU/BeiLI4wl/c=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86: Dom0 "broken ELF" reporting adjustments
Message-Id: <E1reu0R-0004dW-PT@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 09:44:11 +0000

commit 56a9641359a6fb6033d776212ff896d17a37c9bb
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Feb 26 16:04:45 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 16:04:45 2024 +0100

    x86: Dom0 "broken ELF" reporting adjustments
    
    elf_load_binary() isn't the primary source of brokenness being
    indicated. Therefore make the respective PVH log message there
    conditional (much like PV has it), and add another instance when
    elf_xen_parse() failed (again matching behavior in the PV case).
    
    Make the PV side match the (new) use of %pd here.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/hvm/dom0_build.c | 5 ++++-
 xen/arch/x86/pv/dom0_build.c  | 3 +--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/hvm/dom0_build.c b/xen/arch/x86/hvm/dom0_build.c
index e59f6657d9..0ceda4140b 100644
--- a/xen/arch/x86/hvm/dom0_build.c
+++ b/xen/arch/x86/hvm/dom0_build.c
@@ -570,6 +570,8 @@ static int __init pvh_load_kernel(struct domain *d, const module_t *image,
     if ( (rc = elf_xen_parse(&elf, &parms, true)) != 0 )
     {
         printk("Unable to parse kernel for ELFNOTES\n");
+        if ( elf_check_broken(&elf) )
+            printk("%pd kernel: broken ELF: %s\n", d, elf_check_broken(&elf));
         return rc;
     }
 
@@ -588,7 +590,8 @@ static int __init pvh_load_kernel(struct domain *d, const module_t *image,
     if ( rc < 0 )
     {
         printk("Failed to load kernel: %d\n", rc);
-        printk("Xen dom0 kernel broken ELF: %s\n", elf_check_broken(&elf));
+        if ( elf_check_broken(&elf) )
+            printk("%pd kernel: broken ELF: %s\n", d, elf_check_broken(&elf));
         return rc;
     }
 
diff --git a/xen/arch/x86/pv/dom0_build.c b/xen/arch/x86/pv/dom0_build.c
index 16d08c6796..d8043fa58a 100644
--- a/xen/arch/x86/pv/dom0_build.c
+++ b/xen/arch/x86/pv/dom0_build.c
@@ -1044,8 +1044,7 @@ int __init dom0_construct_pv(struct domain *d,
 
 out:
     if ( elf_check_broken(&elf) )
-        printk(XENLOG_WARNING "Dom0 kernel broken ELF: %s\n",
-               elf_check_broken(&elf));
+        printk("%pd kernel: broken ELF: %s\n", d, elf_check_broken(&elf));
 
     return rc;
 }
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 09:44:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 09:44:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685929.1067390 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reu0d-0004FI-5E; Tue, 27 Feb 2024 09:44:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685929.1067390; Tue, 27 Feb 2024 09:44:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reu0d-0004FA-2S; Tue, 27 Feb 2024 09:44:23 +0000
Received: by outflank-mailman (input) for mailman id 685929;
 Tue, 27 Feb 2024 09:44:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu0c-0004Ex-03
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu0b-0004dI-VX
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:21 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu0b-0004eY-UW
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:21 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=+iuH8HxZYSrt1PkdVD0cmI53qqhUGllfok0EpOC6mgI=; b=E29u1cpsi06wovDeeQvFNTRMbW
	NvY8XL29LMZGZysdqTKy2IFLZfQqjn13ZkqGUOkcpqiIrUS/KJFIoLmg9Xt/7MCiJ6bSGSpqyGkzb
	VkzIgqYzwNLwTW0Y7KSVzCBiDkSOGR3h4BIyBF+yewqiJV9gqzicaFpMLwmqVJzhBxiY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] automation: Rework "build-each-commit-gcc" test
Message-Id: <E1reu0b-0004eY-UW@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 09:44:21 +0000

commit 21051291ad8851cac973c7ee70f5928967022c7e
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Tue Feb 20 14:07:33 2024 +0000
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 16:05:59 2024 +0100

    automation: Rework "build-each-commit-gcc" test
    
    Current issues with this test are:
    - when the job timeout, the log file is lost as there is no chance to
      run the `mv` command.
    - GitLab job log is limited in size, so one usually have to download
      the artifacts, which may be missing.
    
    Use $GITLAB_CI to detect when the script is run as part of a GitLab
    pipeline. GitLab will add "GITLAB_CI=true" in the environment
    variables.
    
    When run as part of $GITLAB_CI, ignore "dirty" worktree to allow to
    write "build-each-commit-gcc.log", which can then be grabbed as
    artifacts, even when the job timeout. The `git clean` command is
    changed to keep those build logs.
    
    When run as part of $GITLAB_CI, we will also store the build output in
    a log file instead of writing it to stdout, because GitLab's job log
    is limited. But we will write the log to stdout in case of error, so
    we can find out more quickly why there's been an error.
    
    This patch also make use of a GitLab feature, "log sections", which we
    will collapse by default. One section per commit been built.
    
    There's a bit of colour added to the logs.
    
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 automation/gitlab-ci/build-each-commit.sh |  2 +-
 automation/gitlab-ci/test.yaml            |  4 +--
 automation/scripts/build-test.sh          | 55 +++++++++++++++++++++++++++----
 3 files changed, 50 insertions(+), 11 deletions(-)

diff --git a/automation/gitlab-ci/build-each-commit.sh b/automation/gitlab-ci/build-each-commit.sh
index 19e337b468..08fddecbbe 100755
--- a/automation/gitlab-ci/build-each-commit.sh
+++ b/automation/gitlab-ci/build-each-commit.sh
@@ -15,4 +15,4 @@ fi
 echo "Building ${BASE}..${TIP}"
 
 NON_SYMBOLIC_REF=1 ./automation/scripts/build-test.sh ${BASE} ${TIP} \
-    bash -c "git clean -ffdx && ./automation/scripts/build"
+    bash -c "git clean -ffdx -e '/build-*.log' && ./automation/scripts/build"
diff --git a/automation/gitlab-ci/test.yaml b/automation/gitlab-ci/test.yaml
index 6aabdb9d15..8b7b2e4da9 100644
--- a/automation/gitlab-ci/test.yaml
+++ b/automation/gitlab-ci/test.yaml
@@ -134,9 +134,7 @@ build-each-commit-gcc:
     XEN_TARGET_ARCH: x86_64
     CC: gcc
   script:
-    - BASE=${BASE_SHA:-${CI_COMMIT_BEFORE_SHA}} TIP=${TIP_SHA:-${CI_COMMIT_SHA}} ./automation/gitlab-ci/build-each-commit.sh 2>&1 | tee ../build-each-commit-gcc.log
-  after_script:
-    - mv ../build-each-commit-gcc.log .
+    - BASE=${BASE_SHA:-${CI_COMMIT_BEFORE_SHA}} TIP=${TIP_SHA:-${CI_COMMIT_SHA}} ./automation/gitlab-ci/build-each-commit.sh 2>&1 | tee build-each-commit-gcc.log
   artifacts:
     paths:
       - '*.log'
diff --git a/automation/scripts/build-test.sh b/automation/scripts/build-test.sh
index da643adc01..355d4bf7f6 100755
--- a/automation/scripts/build-test.sh
+++ b/automation/scripts/build-test.sh
@@ -9,6 +9,37 @@
 # Set NON_SYMBOLIC_REF=1 if you want to use this script in detached HEAD state.
 # This is currently used by automated test system.
 
+# Colors with ANSI escape sequences
+txt_info='[32m'
+txt_err='[31m'
+txt_clr='[0m'
+
+# $GITLAB_CI should be "true" or "false".
+if [ "$GITLAB_CI" != true ]; then
+    GITLAB_CI=false
+fi
+
+gitlab_log_section() {
+    if $GITLAB_CI; then
+        echo -n "[0Ksection_$1:$(date +%s):$2
[0K"
+    fi
+    if [ $# -ge 3 ]; then
+        echo "$3"
+    fi
+}
+log_section_last=
+log_section_start() {
+    log_section_last="${1%\[collapsed=true\]}"
+    gitlab_log_section 'start' "$1" "${txt_info}$2${txt_clr}"
+}
+log_section_end() {
+    if [ "$log_section_last" ]; then
+        gitlab_log_section 'end' "$log_section_last"
+        log_section_last=
+    fi
+}
+
+
 if test $# -lt 2 ; then
     echo "Usage:"
     echo " $0 <BASE> <TIP> [CMD]"
@@ -19,10 +50,12 @@ fi
 
 pushd `git rev-parse --show-toplevel`
 
-status=`git status -s`
-if test -n "$status"; then
-    echo "Tree is dirty, aborted"
-    exit 1
+if ! $GITLAB_CI; then
+    status=`git status -s`
+    if test -n "$status"; then
+        echo "Tree is dirty, aborted"
+        exit 1
+    fi
 fi
 
 BASE=$1; shift
@@ -40,26 +73,34 @@ fi
 
 ret=1
 while read num rev; do
-    echo "Testing $num $rev"
+    log_section_start "commit_$rev[collapsed=true]" "Testing #$num $(git log -1 --abbrev=12 --format=tformat:'%h ("%s")' $rev)"
 
     git checkout $rev
     ret=$?
     if test $ret -ne 0; then
-        echo "Failed to checkout $num $rev with $ret"
+        log_section_end
+        echo "${txt_err}Failed to checkout $num $rev with $ret${txt_clr}"
         break
     fi
 
     if test $# -eq 0 ; then
         git clean -fdx && ./configure && make -j4
+    elif $GITLAB_CI; then
+        "$@" > "build-$num.log" 2>&1
     else
         "$@"
     fi
     ret=$?
     if test $ret -ne 0; then
-        echo "Failed at $num $rev with $ret"
+        if $GITLAB_CI; then
+            cat "build-$num.log"
+        fi
+        log_section_end
+        echo "${txt_err}Failed at $num $rev with $ret${txt_clr}"
         break
     fi
     echo
+    log_section_end
 done < <(git rev-list $BASE..$TIP | nl -ba | tac)
 
 echo "Restoring original HEAD"
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 09:44:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 09:44:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685930.1067393 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reu0n-0004Iu-7u; Tue, 27 Feb 2024 09:44:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685930.1067393; Tue, 27 Feb 2024 09:44:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reu0n-0004Im-5B; Tue, 27 Feb 2024 09:44:33 +0000
Received: by outflank-mailman (input) for mailman id 685930;
 Tue, 27 Feb 2024 09:44:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu0m-0004IZ-32
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu0m-0004dQ-2J
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu0m-0004fB-1Q
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=EqJ9CPtJFd6vjuPeMTBbVHX+NRb9sy+IaKBVXn6LFfU=; b=lX9zUl5pdg2gJCBgf6WWhBQDN5
	F2LT4l26lYx0LI6MqSiCevEHQfDmB91iEi45LzMhl7oEpOzeeU10qWnytqgmNK/xYpzQyDADRUrEO
	DF7yCmhtuG8PgPzeJHVCq+4kZaznGIFEdtkWCAuMu1Lcie8F7/vWVOexBAwDdyrRFglk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/spec: fix BRANCH_HARDEN option to only be set when build-enabled
Message-Id: <E1reu0m-0004fB-1Q@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 09:44:32 +0000

commit 60e00f77a5cc671d30c5ef3318f5b8e9b74e4aa3
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon Feb 26 16:06:42 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Feb 26 16:06:42 2024 +0100

    x86/spec: fix BRANCH_HARDEN option to only be set when build-enabled
    
    The current logic to handle the BRANCH_HARDEN option will report it as enabled
    even when build-time disabled. Fix this by only allowing the option to be set
    when support for it is built into Xen.
    
    Fixes: 2d6f36daa086 ('x86/nospec: Introduce CONFIG_SPECULATIVE_HARDEN_BRANCH')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/spec_ctrl.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 421fe3f640..503f1c7a37 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -50,7 +50,8 @@ static int8_t __initdata opt_psfd = -1;
 int8_t __ro_after_init opt_ibpb_ctxt_switch = -1;
 int8_t __read_mostly opt_eager_fpu = -1;
 int8_t __read_mostly opt_l1d_flush = -1;
-static bool __initdata opt_branch_harden = true;
+static bool __initdata opt_branch_harden =
+    IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH);
 
 bool __initdata bsp_delay_spec_ctrl;
 uint8_t __read_mostly default_xen_spec_ctrl;
@@ -268,7 +269,16 @@ static int __init cf_check parse_spec_ctrl(const char *s)
         else if ( (val = parse_boolean("l1d-flush", s, ss)) >= 0 )
             opt_l1d_flush = val;
         else if ( (val = parse_boolean("branch-harden", s, ss)) >= 0 )
-            opt_branch_harden = val;
+        {
+            if ( IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH) )
+                opt_branch_harden = val;
+            else
+            {
+                no_config_param("SPECULATIVE_HARDEN_BRANCH", "spec-ctrl", s,
+                                ss);
+                rc = -EINVAL;
+            }
+        }
         else if ( (val = parse_boolean("srb-lock", s, ss)) >= 0 )
             opt_srb_lock = val;
         else if ( (val = parse_boolean("unpriv-mmio", s, ss)) >= 0 )
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 09:44:43 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 09:44:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685931.1067398 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reu0x-0004Lp-9Z; Tue, 27 Feb 2024 09:44:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685931.1067398; Tue, 27 Feb 2024 09:44:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reu0x-0004Lh-6j; Tue, 27 Feb 2024 09:44:43 +0000
Received: by outflank-mailman (input) for mailman id 685931;
 Tue, 27 Feb 2024 09:44:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu0w-0004Lb-6U
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu0w-0004dZ-5t
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu0w-0004fe-55
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=0wDVJiulhUubyjqNnuUk+Admv9pTDYY1AKssOgb3JNQ=; b=ml5b1J5TS9ZiENTP++JWjcwBBW
	Iz/dEw1KBBjWY6h4JPeBX4LDQYjJFqZyu2eEx+cyQDOGVJXKl82RW7/MbTqTklOYcelrBkdxvYmyE
	7/YM4r/dkCceOv61AUk2v+trVLS5VMV/Jho5hHiQbs8jwREHMHjHhA7cjXI9KNirce3k=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/hvm: Convert hap_capabilities into a bitfield
Message-Id: <E1reu0w-0004fe-55@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 09:44:42 +0000

commit 5cd5e3070b50d4330cf116ec769b2169ccaccb6d
Author:     George Dunlap <george.dunlap@cloud.com>
AuthorDate: Mon Jan 15 17:05:09 2024 +0000
Commit:     George Dunlap <george.dunlap@cloud.com>
CommitDate: Mon Feb 26 15:57:56 2024 +0000

    xen/hvm: Convert hap_capabilities into a bitfield
    
    hvm_function_table is an internal structure; rather than manually
    |-ing and &-ing bits, just make it a boolean bitfield and let the
    compiler do all the work.  This makes everything easier to read, and
    presumably allows the compiler more flexibility in producing efficient
    code.
    
    No functional change intended.
    
    Signed-off-by: George Dunlap <george.dunlap@cloud.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/hvm/hvm.c             |  8 ++++----
 xen/arch/x86/hvm/svm/svm.c         |  4 ++--
 xen/arch/x86/hvm/vmx/vmcs.c        |  4 ++--
 xen/arch/x86/hvm/vmx/vmx.c         |  8 ++------
 xen/arch/x86/include/asm/hvm/hvm.h | 19 +++++++------------
 5 files changed, 17 insertions(+), 26 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 87d33d116b..2965c62e94 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -174,17 +174,17 @@ static int __init cf_check hvm_enable(void)
     {
         printk("HVM: Hardware Assisted Paging (HAP) detected\n");
         printk("HVM: HAP page sizes: 4kB");
-        if ( fns->hap_capabilities & HVM_HAP_SUPERPAGE_2MB )
+        if ( fns->caps.hap_superpage_2mb )
         {
             printk(", 2MB%s", opt_hap_2mb ? "" : " [disabled]");
             if ( !opt_hap_2mb )
-                hvm_funcs.hap_capabilities &= ~HVM_HAP_SUPERPAGE_2MB;
+                hvm_funcs.caps.hap_superpage_2mb = false;
         }
-        if ( fns->hap_capabilities & HVM_HAP_SUPERPAGE_1GB )
+        if ( fns->caps.hap_superpage_1gb )
         {
             printk(", 1GB%s", opt_hap_1gb ? "" : " [disabled]");
             if ( !opt_hap_1gb )
-                hvm_funcs.hap_capabilities &= ~HVM_HAP_SUPERPAGE_1GB;
+                hvm_funcs.caps.hap_superpage_1gb = false;
         }
         printk("\n");
     }
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 65f437e958..5741287355 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -2581,8 +2581,8 @@ const struct hvm_function_table * __init start_svm(void)
         printk(" - none\n");
 
     svm_function_table.hap_supported = !!cpu_has_svm_npt;
-    svm_function_table.hap_capabilities = HVM_HAP_SUPERPAGE_2MB |
-        (cpu_has_page1gb ? HVM_HAP_SUPERPAGE_1GB : 0);
+    svm_function_table.caps.hap_superpage_2mb = true;
+    svm_function_table.caps.hap_superpage_1gb = cpu_has_page1gb;
 
     return &svm_function_table;
 }
diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
index 9e016634ab..0de2caab76 100644
--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -113,8 +113,8 @@ static int cf_check parse_ept_param_runtime(const char *s)
     int val;
 
     if ( !cpu_has_vmx_ept || !hvm_funcs.hap_supported ||
-         !(hvm_funcs.hap_capabilities &
-           (HVM_HAP_SUPERPAGE_2MB | HVM_HAP_SUPERPAGE_1GB)) )
+         !(hvm_funcs.caps.hap_superpage_2mb ||
+           hvm_funcs.caps.hap_superpage_1gb) )
     {
         printk("VMX: EPT not available, or not in use - ignoring\n");
         return 0;
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 9c803494c7..10376674b4 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2995,12 +2995,8 @@ const struct hvm_function_table * __init start_vmx(void)
         vmx_function_table.hap_supported = 1;
         vmx_function_table.altp2m_supported = 1;
 
-        vmx_function_table.hap_capabilities = 0;
-
-        if ( cpu_has_vmx_ept_2mb )
-            vmx_function_table.hap_capabilities |= HVM_HAP_SUPERPAGE_2MB;
-        if ( cpu_has_vmx_ept_1gb )
-            vmx_function_table.hap_capabilities |= HVM_HAP_SUPERPAGE_1GB;
+        vmx_function_table.caps.hap_superpage_2mb = cpu_has_vmx_ept_2mb;
+        vmx_function_table.caps.hap_superpage_1gb = cpu_has_vmx_ept_1gb;
 
         setup_ept_dump();
     }
diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/hvm/hvm.h
index 985c1c14c6..4e9bd0ba47 100644
--- a/xen/arch/x86/include/asm/hvm/hvm.h
+++ b/xen/arch/x86/include/asm/hvm/hvm.h
@@ -61,14 +61,6 @@ enum hvm_intblk {
 #define HVM_INTR_SHADOW_SMI    0x00000004
 #define HVM_INTR_SHADOW_NMI    0x00000008
 
-/*
- * HAP super page capabilities:
- * bit0: if 2MB super page is allowed?
- * bit1: if 1GB super page is allowed?
- */
-#define HVM_HAP_SUPERPAGE_2MB   0x00000001
-#define HVM_HAP_SUPERPAGE_1GB   0x00000002
-
 #define HVM_EVENT_VECTOR_UNSET    (-1)
 #define HVM_EVENT_VECTOR_UPDATING (-2)
 
@@ -104,8 +96,11 @@ struct hvm_function_table {
     /* Hardware virtual interrupt delivery enable? */
     bool virtual_intr_delivery_enabled;
 
-    /* Indicate HAP capabilities. */
-    unsigned int hap_capabilities;
+    struct {
+        /* Indicate HAP capabilities. */
+        bool hap_superpage_1gb:1,
+             hap_superpage_2mb:1;
+    } caps;
 
     /*
      * Initialise/destroy HVM domain/vcpu resources
@@ -402,8 +397,8 @@ int hvm_get_param(struct domain *d, uint32_t index, uint64_t *value);
     (hvm_paging_enabled(v) && ((v)->arch.hvm.guest_cr[4] & X86_CR4_PKS))
 
 /* Can we use superpages in the HAP p2m table? */
-#define hap_has_1gb (!!(hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_1GB))
-#define hap_has_2mb (!!(hvm_funcs.hap_capabilities & HVM_HAP_SUPERPAGE_2MB))
+#define hap_has_1gb hvm_funcs.caps.hap_superpage_1gb
+#define hap_has_2mb hvm_funcs.caps.hap_superpage_2mb
 
 #define hvm_long_mode_active(v) (!!((v)->arch.hvm.guest_efer & EFER_LMA))
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 09:44:53 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 09:44:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685932.1067402 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reu17-0004OC-Ai; Tue, 27 Feb 2024 09:44:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685932.1067402; Tue, 27 Feb 2024 09:44:53 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reu17-0004O4-89; Tue, 27 Feb 2024 09:44:53 +0000
Received: by outflank-mailman (input) for mailman id 685932;
 Tue, 27 Feb 2024 09:44:52 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu16-0004Nt-9d
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:52 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu16-0004dm-8r
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu16-0004gC-88
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:44:52 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=kWOV5dhjkaxs8PC2w2I7ugNN7wFHqNwP/RtFMlGCyJA=; b=QmGLj8DnieqgvHLL/z05heg/OF
	20OudSy8H6/nP9JF8VdduQmuvI7CqdsrZmEOCwA6qi9iviUevq9YmvKEIHNCNPRVL3LxQnL7nhS8D
	j8dzWFIRwKGsdKovUk31m0Ws8BhJjfLH5J62Ei0e0tgrF3Bilp1/i6/8Mbeg3Woz7brA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] svm: Improve type of cpu_has_svm_feature
Message-Id: <E1reu16-0004gC-88@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 09:44:52 +0000

commit 42b8e78b3751270d0ec7dadc9cfcac5421e42e50
Author:     George Dunlap <george.dunlap@cloud.com>
AuthorDate: Mon Feb 5 21:42:59 2024 +0000
Commit:     George Dunlap <george.dunlap@cloud.com>
CommitDate: Mon Feb 26 15:57:56 2024 +0000

    svm: Improve type of cpu_has_svm_feature
    
    The "effective type" of the cpu_has_svm_feature macro is effectively
    an unsigned log with one bit set (or not); at least one place someone
    felt compelled to do a !! to make sure that they got a boolean out of
    it.
    
    Ideally the whole of this would be folded into the cpufeature.h
    infrastructure.  But for now, duplicate the more type-safe static
    inlines in that file, and remove the !!.
    
    Signed-off-by: George Dunlap <george.dunlap@cloud.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/hvm/svm/svm.c             | 2 +-
 xen/arch/x86/include/asm/hvm/svm/svm.h | 5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 5741287355..40bc1ffbc6 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -2580,7 +2580,7 @@ const struct hvm_function_table * __init start_svm(void)
     if ( !printed )
         printk(" - none\n");
 
-    svm_function_table.hap_supported = !!cpu_has_svm_npt;
+    svm_function_table.hap_supported = cpu_has_svm_npt;
     svm_function_table.caps.hap_superpage_2mb = true;
     svm_function_table.caps.hap_superpage_1gb = cpu_has_page1gb;
 
diff --git a/xen/arch/x86/include/asm/hvm/svm/svm.h b/xen/arch/x86/include/asm/hvm/svm/svm.h
index 687d35be40..4eeeb25da9 100644
--- a/xen/arch/x86/include/asm/hvm/svm/svm.h
+++ b/xen/arch/x86/include/asm/hvm/svm/svm.h
@@ -38,7 +38,10 @@ extern u32 svm_feature_flags;
 #define SVM_FEATURE_SSS           19 /* NPT Supervisor Shadow Stacks */
 #define SVM_FEATURE_SPEC_CTRL     20 /* MSR_SPEC_CTRL virtualisation */
 
-#define cpu_has_svm_feature(f) (svm_feature_flags & (1u << (f)))
+static inline bool cpu_has_svm_feature(unsigned int feat)
+{
+    return svm_feature_flags & (1u << feat);
+}
 #define cpu_has_svm_npt       cpu_has_svm_feature(SVM_FEATURE_NPT)
 #define cpu_has_svm_lbrv      cpu_has_svm_feature(SVM_FEATURE_LBRV)
 #define cpu_has_svm_svml      cpu_has_svm_feature(SVM_FEATURE_SVML)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 09:45:03 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 09:45:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685933.1067405 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reu1H-0004Qu-Cc; Tue, 27 Feb 2024 09:45:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685933.1067405; Tue, 27 Feb 2024 09:45:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reu1H-0004Ql-9d; Tue, 27 Feb 2024 09:45:03 +0000
Received: by outflank-mailman (input) for mailman id 685933;
 Tue, 27 Feb 2024 09:45:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu1G-0004QP-G0
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:45:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu1G-0004eN-DO
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:45:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu1G-0004gs-Bf
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:45:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=0H9P+34U6j//qE15lVOjKZdjxdl86PFW6YnWFHieYLU=; b=6+AJupSybURx4Pkqg1DXk4jq8X
	ZZkL2cTBiaE9RwagJ4IAR5T2lrY4MHGq7KECQXnTlNKkgxoCCsI7Wh5AV0JgLvfVJrREmAlALzJFx
	oUxekYfMfAwwoAsiAK8e3JJ0+GRUbqlvWJlACAJs6VWS8p0nWf0hm09g08lc00flGlkY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/hvm: Move other hvm_function_table booleans into the caps bitfield
Message-Id: <E1reu1G-0004gs-Bf@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 09:45:02 +0000

commit 2beef32b42b4454bd02bf735b3e414dad6e04962
Author:     George Dunlap <george.dunlap@cloud.com>
AuthorDate: Wed Jan 17 15:48:35 2024 +0000
Commit:     George Dunlap <george.dunlap@cloud.com>
CommitDate: Mon Feb 26 15:57:56 2024 +0000

    xen/hvm: Move other hvm_function_table booleans into the caps bitfield
    
    Moving them all together has several advantages:
     * Collects them all in one part of the struct
     * The `caps` field means that we can drop the "_supported" suffix, as it's
       clear what is meant.
    
    While here, replace some 0/1 values with false/true.
    
    Signed-off-by: George Dunlap <george.dunlap@cloud.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/hvm/hvm.c             |  6 +++---
 xen/arch/x86/hvm/svm/svm.c         |  2 +-
 xen/arch/x86/hvm/vlapic.c          |  4 ++--
 xen/arch/x86/hvm/vmx/vmcs.c        |  2 +-
 xen/arch/x86/hvm/vmx/vmx.c         |  8 ++++----
 xen/arch/x86/include/asm/hvm/hvm.h | 28 +++++++++++++---------------
 6 files changed, 24 insertions(+), 26 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 2965c62e94..c75959588c 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -136,7 +136,7 @@ static struct notifier_block cpu_nfb = {
 
 static bool __init hap_supported(struct hvm_function_table *fns)
 {
-    if ( !fns->hap_supported )
+    if ( !fns->caps.hap )
     {
         printk("HVM: Hardware Assisted Paging (HAP) not detected\n");
         return false;
@@ -144,7 +144,7 @@ static bool __init hap_supported(struct hvm_function_table *fns)
 
     if ( !opt_hap_enabled )
     {
-        fns->hap_supported = 0;
+        fns->caps.hap = false;
         printk("HVM: Hardware Assisted Paging (HAP) detected but disabled\n");
         return false;
     }
@@ -190,7 +190,7 @@ static int __init cf_check hvm_enable(void)
     }
 
     if ( !opt_altp2m_enabled )
-        hvm_funcs.altp2m_supported = 0;
+        hvm_funcs.caps.altp2m = false;
 
     if ( opt_hvm_fep )
         warning_add(warning_hvm_fep);
diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 40bc1ffbc6..b551eac807 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -2580,7 +2580,7 @@ const struct hvm_function_table * __init start_svm(void)
     if ( !printed )
         printk(" - none\n");
 
-    svm_function_table.hap_supported = cpu_has_svm_npt;
+    svm_function_table.caps.hap = cpu_has_svm_npt;
     svm_function_table.caps.hap_superpage_2mb = true;
     svm_function_table.caps.hap_superpage_1gb = cpu_has_page1gb;
 
diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c
index 71a4b954b0..dcbcf4a1fe 100644
--- a/xen/arch/x86/hvm/vlapic.c
+++ b/xen/arch/x86/hvm/vlapic.c
@@ -1326,7 +1326,7 @@ int vlapic_has_pending_irq(struct vcpu *v)
     if ( irr == -1 )
         return -1;
 
-    if ( hvm_funcs.virtual_intr_delivery_enabled &&
+    if ( hvm_funcs.caps.virtual_intr_delivery &&
          !nestedhvm_vcpu_in_guestmode(v) )
         return irr;
 
@@ -1361,7 +1361,7 @@ int vlapic_ack_pending_irq(struct vcpu *v, int vector, bool force_ack)
     int isr;
 
     if ( !force_ack &&
-         hvm_funcs.virtual_intr_delivery_enabled )
+         hvm_funcs.caps.virtual_intr_delivery )
         return 1;
 
     /* If there's no chance of using APIC assist then bail now. */
diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
index 0de2caab76..6b4f004a3d 100644
--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -112,7 +112,7 @@ static int cf_check parse_ept_param_runtime(const char *s)
     struct domain *d;
     int val;
 
-    if ( !cpu_has_vmx_ept || !hvm_funcs.hap_supported ||
+    if ( !cpu_has_vmx_ept || !hvm_funcs.caps.hap ||
          !(hvm_funcs.caps.hap_superpage_2mb ||
            hvm_funcs.caps.hap_superpage_1gb) )
     {
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 10376674b4..8b27d83c12 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2969,7 +2969,7 @@ const struct hvm_function_table * __init start_vmx(void)
         return NULL;
     }
 
-    vmx_function_table.singlestep_supported = cpu_has_monitor_trap_flag;
+    vmx_function_table.caps.singlestep = cpu_has_monitor_trap_flag;
 
     if ( cpu_has_vmx_dt_exiting )
         vmx_function_table.set_descriptor_access_exiting =
@@ -2992,8 +2992,8 @@ const struct hvm_function_table * __init start_vmx(void)
                 printk("VMX: Disabling executable EPT superpages due to CVE-2018-12207\n");
         }
 
-        vmx_function_table.hap_supported = 1;
-        vmx_function_table.altp2m_supported = 1;
+        vmx_function_table.caps.hap = true;
+        vmx_function_table.caps.altp2m = true;
 
         vmx_function_table.caps.hap_superpage_2mb = cpu_has_vmx_ept_2mb;
         vmx_function_table.caps.hap_superpage_1gb = cpu_has_vmx_ept_1gb;
@@ -3006,7 +3006,7 @@ const struct hvm_function_table * __init start_vmx(void)
         vmx_function_table.update_eoi_exit_bitmap = vmx_update_eoi_exit_bitmap;
         vmx_function_table.process_isr = vmx_process_isr;
         vmx_function_table.handle_eoi = vmx_handle_eoi;
-        vmx_function_table.virtual_intr_delivery_enabled = true;
+        vmx_function_table.caps.virtual_intr_delivery = true;
     }
 
     if ( cpu_has_vmx_posted_intr_processing )
diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/hvm/hvm.h
index 4e9bd0ba47..87a6935d97 100644
--- a/xen/arch/x86/include/asm/hvm/hvm.h
+++ b/xen/arch/x86/include/asm/hvm/hvm.h
@@ -86,20 +86,18 @@ struct hvm_vcpu_nonreg_state {
 struct hvm_function_table {
     const char *name;
 
-    /* Support Hardware-Assisted Paging? */
-    bool hap_supported;
-
-    /* Necessary hardware support for alternate p2m's? */
-    bool altp2m_supported;
-    bool singlestep_supported;
-
-    /* Hardware virtual interrupt delivery enable? */
-    bool virtual_intr_delivery_enabled;
-
     struct {
         /* Indicate HAP capabilities. */
-        bool hap_superpage_1gb:1,
-             hap_superpage_2mb:1;
+        bool hap:1,
+             hap_superpage_1gb:1,
+             hap_superpage_2mb:1,
+
+             /* Altp2m capabilities */
+             altp2m:1,
+             singlestep:1,
+            
+             /* Hardware virtual interrupt delivery enable? */
+             virtual_intr_delivery:1;
     } caps;
 
     /*
@@ -642,18 +640,18 @@ static inline void hvm_enable_msr_interception(struct domain *d, uint32_t msr)
 
 static inline bool hvm_is_singlestep_supported(void)
 {
-    return hvm_funcs.singlestep_supported;
+    return hvm_funcs.caps.singlestep;
 }
 
 static inline bool hvm_hap_supported(void)
 {
-    return hvm_funcs.hap_supported;
+    return hvm_funcs.caps.hap;
 }
 
 /* returns true if hardware supports alternate p2m's */
 static inline bool hvm_altp2m_supported(void)
 {
-    return hvm_funcs.altp2m_supported;
+    return hvm_funcs.caps.altp2m;
 }
 
 /* updates the current hardware p2m */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 09:45:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 09:45:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.685937.1067421 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reu1R-0004l4-NL; Tue, 27 Feb 2024 09:45:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 685937.1067421; Tue, 27 Feb 2024 09:45:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1reu1R-0004kw-KS; Tue, 27 Feb 2024 09:45:13 +0000
Received: by outflank-mailman (input) for mailman id 685937;
 Tue, 27 Feb 2024 09:45:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu1Q-0004kY-H6
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:45:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu1Q-0004ef-GM
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:45:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1reu1Q-0004ha-FY
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 09:45:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=x2gImFKY2IB0937tDLOCowd3grRUmmC6eKMFJbF83ew=; b=A3+wB6JETE+0GaSeOKTHfcbrwR
	Lr5JPrCOzyX+pddSoS7M1B1qiYE8iBLDYstqr3iDTKicr6qmxdHgR5LEyCkLaA5chxL/PbRzhnABD
	Lde3RBnRaaIAEntuC6yZq034OJ4azFzFwxZ1iTyiSUHRAV2QKNqp2IU3saaXS+7+EP0g=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] nestedsvm: Remove bogus debug message from nestedsvm_check_intercepts
Message-Id: <E1reu1Q-0004ha-FY@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 09:45:12 +0000

commit 03fb5f503cb5faa0556b23d594496719ced6a11b
Author:     George Dunlap <george.dunlap@cloud.com>
AuthorDate: Mon Jan 22 15:32:25 2024 +0000
Commit:     George Dunlap <george.dunlap@cloud.com>
CommitDate: Mon Feb 26 15:57:56 2024 +0000

    nestedsvm: Remove bogus debug message from nestedsvm_check_intercepts
    
    Changeset ef3e8db8068 ("x86/hvm: Corrections and improvements to
    unhandled vmexit logging") introduced a printk to the default path of
    the switch statement in nestedsvm_check_intercepts(), complaining of
    an unknown exit reason.
    
    Unfortunately, the "core" switch statement which is meant to handle
    all vmexit reasons is in nsvm_vmcb_guest_intercepts_exitcode(); the
    switch statement in nestedsvm_check_intercepts() is only meant to
    superimpose on top of that some special-casing for how to interaction
    between L1 and L0 vmexits.
    
    Remove the printk, and add a comment to prevent future confusion.
    
    Fixes: ef3e8db8068 ("x86/hvm: Corrections and improvements to unhandled vmexit logging")
    
    Signed-off-by: George Dunlap <george.dunlap@cloud.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/hvm/svm/nestedsvm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/hvm/svm/nestedsvm.c b/xen/arch/x86/hvm/svm/nestedsvm.c
index ee9602f5c8..e4e01add8c 100644
--- a/xen/arch/x86/hvm/svm/nestedsvm.c
+++ b/xen/arch/x86/hvm/svm/nestedsvm.c
@@ -1294,6 +1294,10 @@ nestedsvm_check_intercepts(struct vcpu *v, struct cpu_user_regs *regs,
     ASSERT(vcpu_nestedhvm(v).nv_vmexit_pending == 0);
     is_intercepted = nsvm_vmcb_guest_intercepts_exitcode(v, regs, exitcode);
 
+    /* 
+     * Handle specific interactions between things the guest and host
+     * may both want to intercept
+     */
     switch ( exitcode )
     {
     case VMEXIT_INVALID:
@@ -1349,8 +1353,6 @@ nestedsvm_check_intercepts(struct vcpu *v, struct cpu_user_regs *regs,
         /* Always let the guest handle VMMCALL/VMCALL */
         return NESTEDHVM_VMEXIT_INJECT;
     default:
-        gprintk(XENLOG_ERR, "Unexpected nested vmexit: reason %#"PRIx64"\n",
-                exitcode);
         break;
     }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 11:22:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 11:22:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686014.1067523 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1revXB-0006hM-Jy; Tue, 27 Feb 2024 11:22:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686014.1067523; Tue, 27 Feb 2024 11:22:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1revXB-0006hE-HB; Tue, 27 Feb 2024 11:22:05 +0000
Received: by outflank-mailman (input) for mailman id 686014;
 Tue, 27 Feb 2024 11:22:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1revX9-0006h6-PA
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 11:22:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1revX9-0006d2-Me
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 11:22:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1revX9-0001mX-Lc
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 11:22:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=3O11K05r0I4RSgmOVB9kbhbWrNomYQ6Y4LAMFa007FQ=; b=NSoz729Av4iHto6viTMkWOigfV
	chJ+V8bmxl6D6zm8tsjSO80INXQJjr2SQsrGm7f3nFyUjM4K4udGWhzqYfRq8n1wqJbFL2cdRnadl
	2I/aKvVEioRoWAxcQqUK+qO1buQI/TX5O4SKK3Y/yWH1R+D/zwZ4601BTjgoUPfUXsMc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/arm: ffa: reclaim shared memory on guest destroy
Message-Id: <E1revX9-0001mX-Lc@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 11:22:03 +0000

commit 7356bb5e47d3cfccc3e19264227749cc4756ebdb
Author:     Jens Wiklander <jens.wiklander@linaro.org>
AuthorDate: Tue Feb 13 12:13:36 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Tue Feb 27 11:12:06 2024 +0000

    xen/arm: ffa: reclaim shared memory on guest destroy
    
    When an FF-A enabled guest is destroyed it may leave behind memory
    shared with SPs. This memory must be reclaimed before it's reused or an
    SP may make changes to memory used by a new unrelated guest. So when the
    domain is teared down add FF-A requests to reclaim all remaining shared
    memory.
    
    SPs in the secure world are notified using VM_DESTROYED that a guest has
    been destroyed. An SP is supposed to relinquish all shared memory to allow
    reclaiming the memory. The relinquish operation may need to be delayed if
    the shared memory is for instance part of a DMA operation.
    
    The domain reference counter is increased when the first FF-A shared
    memory is registered and the counter is decreased again when the last
    shared memory is reclaimed. If FF-A shared memory registrations remain
    at the end of of ffa_domain_teardown() a timer is set to try to reclaim
    the shared memory every second until the memory is reclaimed.
    
    A few minor style fixes with a removed empty line here and an added new
    line there.
    
    Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
---
 xen/arch/arm/tee/ffa.c | 295 ++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 245 insertions(+), 50 deletions(-)

diff --git a/xen/arch/arm/tee/ffa.c b/xen/arch/arm/tee/ffa.c
index 0793c1c758..9a05dcede1 100644
--- a/xen/arch/arm/tee/ffa.c
+++ b/xen/arch/arm/tee/ffa.c
@@ -54,6 +54,7 @@
 #include <xen/mm.h>
 #include <xen/sched.h>
 #include <xen/sizes.h>
+#include <xen/timer.h>
 #include <xen/types.h>
 
 #include <asm/event.h>
@@ -144,6 +145,12 @@
  */
 #define FFA_MAX_SHM_COUNT               32
 
+/*
+ * The time we wait until trying to tear down a domain again if it was
+ * blocked initially.
+ */
+#define FFA_CTX_TEARDOWN_DELAY          SECONDS(1)
+
 /* FF-A-1.1-REL0 section 10.9.2 Memory region handle, page 167 */
 #define FFA_HANDLE_HYP_FLAG             BIT(63, ULL)
 #define FFA_HANDLE_INVALID              0xffffffffffffffffULL
@@ -384,11 +391,6 @@ struct ffa_ctx {
     unsigned int page_count;
     /* FF-A version used by the guest */
     uint32_t guest_vers;
-    /*
-     * Number of SPs that we have sent a VM created signal to, used in
-     * ffa_domain_teardown() to know which SPs need to be signalled.
-     */
-    uint16_t create_signal_count;
     bool rx_is_free;
     /* Used shared memory objects, struct ffa_shm_mem */
     struct list_head shm_list;
@@ -402,6 +404,15 @@ struct ffa_ctx {
     spinlock_t tx_lock;
     spinlock_t rx_lock;
     spinlock_t lock;
+    /* Used if domain can't be torn down immediately */
+    struct domain *teardown_d;
+    struct list_head teardown_list;
+    s_time_t teardown_expire;
+    /*
+     * Used for ffa_domain_teardown() to keep track of which SPs should be
+     * notified that this guest is being destroyed.
+     */
+    unsigned long vm_destroy_bitmap[];
 };
 
 struct ffa_shm_mem {
@@ -436,6 +447,12 @@ static void *ffa_tx __read_mostly;
 static DEFINE_SPINLOCK(ffa_rx_buffer_lock);
 static DEFINE_SPINLOCK(ffa_tx_buffer_lock);
 
+
+/* Used to track domains that could not be torn down immediately. */
+static struct timer ffa_teardown_timer;
+static struct list_head ffa_teardown_head;
+static DEFINE_SPINLOCK(ffa_teardown_lock);
+
 static bool ffa_get_version(uint32_t *vers)
 {
     const struct arm_smccc_1_2_regs arg = {
@@ -853,7 +870,6 @@ static int32_t handle_partition_info_get(uint32_t w1, uint32_t w2, uint32_t w3,
             goto out_rx_release;
         }
 
-
         memcpy(ctx->rx, ffa_rx, sz);
     }
     ctx->rx_is_free = false;
@@ -992,53 +1008,83 @@ static void put_shm_pages(struct ffa_shm_mem *shm)
     }
 }
 
-static bool inc_ctx_shm_count(struct ffa_ctx *ctx)
+static bool inc_ctx_shm_count(struct domain *d, struct ffa_ctx *ctx)
 {
     bool ret = true;
 
     spin_lock(&ctx->lock);
-    if (ctx->shm_count >= FFA_MAX_SHM_COUNT)
+
+    if ( ctx->shm_count >= FFA_MAX_SHM_COUNT )
+    {
         ret = false;
+    }
     else
+    {
+        /*
+         * If this is the first shm added, increase the domain reference
+         * counter as we need to keep domain around a bit longer to reclaim
+         * the shared memory in the teardown path.
+         */
+        if ( !ctx->shm_count )
+            get_knownalive_domain(d);
+
         ctx->shm_count++;
+    }
+
     spin_unlock(&ctx->lock);
 
     return ret;
 }
 
-static void dec_ctx_shm_count(struct ffa_ctx *ctx)
+static void dec_ctx_shm_count(struct domain *d, struct ffa_ctx *ctx)
 {
+    bool drop_ref;
+
     spin_lock(&ctx->lock);
+
     ASSERT(ctx->shm_count > 0);
     ctx->shm_count--;
+
+    /*
+     * If this was the last shm removed, let go of the domain reference we
+     * took in inc_ctx_shm_count() above.
+     */
+    drop_ref = !ctx->shm_count;
+
     spin_unlock(&ctx->lock);
+
+    if ( drop_ref )
+        put_domain(d);
 }
 
-static struct ffa_shm_mem *alloc_ffa_shm_mem(struct ffa_ctx *ctx,
+static struct ffa_shm_mem *alloc_ffa_shm_mem(struct domain *d,
                                              unsigned int page_count)
 {
+    struct ffa_ctx *ctx = d->arch.tee;
     struct ffa_shm_mem *shm;
 
     if ( page_count >= FFA_MAX_SHM_PAGE_COUNT )
         return NULL;
-    if ( !inc_ctx_shm_count(ctx) )
+    if ( !inc_ctx_shm_count(d, ctx) )
         return NULL;
 
     shm = xzalloc_flex_struct(struct ffa_shm_mem, pages, page_count);
     if ( shm )
         shm->page_count = page_count;
     else
-        dec_ctx_shm_count(ctx);
+        dec_ctx_shm_count(d, ctx);
 
     return shm;
 }
 
-static void free_ffa_shm_mem(struct ffa_ctx *ctx, struct ffa_shm_mem *shm)
+static void free_ffa_shm_mem(struct domain *d, struct ffa_shm_mem *shm)
 {
+    struct ffa_ctx *ctx = d->arch.tee;
+
     if ( !shm )
         return;
 
-    dec_ctx_shm_count(ctx);
+    dec_ctx_shm_count(d, ctx);
     put_shm_pages(shm);
     xfree(shm);
 }
@@ -1306,7 +1352,7 @@ static void handle_mem_share(struct cpu_user_regs *regs)
         goto out_unlock;
     }
 
-    shm = alloc_ffa_shm_mem(ctx, page_count);
+    shm = alloc_ffa_shm_mem(d, page_count);
     if ( !shm )
     {
         ret = FFA_RET_NO_MEMORY;
@@ -1350,7 +1396,7 @@ static void handle_mem_share(struct cpu_user_regs *regs)
 
 out:
     if ( ret )
-        free_ffa_shm_mem(ctx, shm);
+        free_ffa_shm_mem(d, shm);
 out_unlock:
     spin_unlock(&ctx->tx_lock);
 
@@ -1401,7 +1447,7 @@ static int handle_mem_reclaim(uint64_t handle, uint32_t flags)
     }
     else
     {
-        free_ffa_shm_mem(ctx, shm);
+        free_ffa_shm_mem(d, shm);
     }
 
     return ret;
@@ -1486,6 +1532,41 @@ static bool ffa_handle_call(struct cpu_user_regs *regs)
     }
 }
 
+static bool is_in_subscr_list(const uint16_t *subscr, uint16_t start,
+                              uint16_t end, uint16_t sp_id)
+{
+    unsigned int n;
+
+    for ( n = start; n < end; n++ )
+    {
+        if ( subscr[n] == sp_id )
+            return true;
+    }
+
+    return false;
+}
+
+static void vm_destroy_bitmap_init(struct ffa_ctx *ctx,
+                                   unsigned int create_signal_count)
+{
+    unsigned int n;
+
+    for ( n = 0; n < subscr_vm_destroyed_count; n++ )
+    {
+        /*
+         * Skip SPs subscribed to the VM created event that never was
+         * notified of the VM creation due to an error during
+         * ffa_domain_init().
+         */
+        if ( is_in_subscr_list(subscr_vm_created, create_signal_count,
+                               subscr_vm_created_count,
+                               subscr_vm_destroyed[n]) )
+            continue;
+
+        set_bit(n, ctx->vm_destroy_bitmap);
+    }
+}
+
 static int ffa_domain_init(struct domain *d)
 {
     struct ffa_ctx *ctx;
@@ -1501,11 +1582,14 @@ static int ffa_domain_init(struct domain *d)
     if ( d->domain_id >= UINT16_MAX)
         return -ERANGE;
 
-    ctx = xzalloc(struct ffa_ctx);
+    ctx = xzalloc_flex_struct(struct ffa_ctx, vm_destroy_bitmap,
+                              BITS_TO_LONGS(subscr_vm_destroyed_count));
     if ( !ctx )
         return -ENOMEM;
 
     d->arch.tee = ctx;
+    ctx->teardown_d = d;
+    INIT_LIST_HEAD(&ctx->shm_list);
 
     for ( n = 0; n < subscr_vm_created_count; n++ )
     {
@@ -1515,65 +1599,173 @@ static int ffa_domain_init(struct domain *d)
         {
             printk(XENLOG_ERR "ffa: Failed to report creation of vm_id %u to  %u: res %d\n",
                    get_vm_id(d), subscr_vm_created[n], res);
-            ctx->create_signal_count = n;
-            return -EIO;
+            break;
         }
     }
-    ctx->create_signal_count = subscr_vm_created_count;
-
-    INIT_LIST_HEAD(&ctx->shm_list);
+    vm_destroy_bitmap_init(ctx, n);
+    if ( n != subscr_vm_created_count )
+        return -EIO;
 
     return 0;
 }
 
-static bool is_in_subscr_list(const uint16_t *subscr, uint16_t start,
-                              uint16_t end, uint16_t sp_id)
+static void send_vm_destroyed(struct domain *d)
 {
+    struct ffa_ctx *ctx = d->arch.tee;
     unsigned int n;
+    int32_t res;
 
-    for ( n = start; n < end; n++ )
+    for ( n = 0; n < subscr_vm_destroyed_count; n++ )
     {
-        if ( subscr[n] == sp_id )
-            return true;
-    }
+        if ( !test_bit(n, ctx->vm_destroy_bitmap) )
+            continue;
 
-    return false;
+        res = ffa_direct_req_send_vm(subscr_vm_destroyed[n], get_vm_id(d),
+                                     FFA_MSG_SEND_VM_DESTROYED);
+
+        if ( res )
+        {
+            printk(XENLOG_ERR "%pd: ffa: Failed to report destruction of vm_id %u to %u: res %d\n",
+                   d, get_vm_id(d), subscr_vm_destroyed[n], res);
+        }
+
+        /*
+         * For these two error codes the hypervisor is expected to resend
+         * the destruction message. For the rest it is expected that the
+         * error is permanent and that is doesn't help to resend the
+         * destruction message.
+         */
+        if ( res != FFA_RET_INTERRUPTED && res != FFA_RET_RETRY )
+            clear_bit(n, ctx->vm_destroy_bitmap);
+    }
 }
 
-/* This function is supposed to undo what ffa_domain_init() has done */
-static int ffa_domain_teardown(struct domain *d)
+static void reclaim_shms(struct domain *d)
 {
     struct ffa_ctx *ctx = d->arch.tee;
-    unsigned int n;
+    struct ffa_shm_mem *shm, *tmp;
     int32_t res;
 
-    if ( !ctx )
-        return 0;
+    list_for_each_entry_safe(shm, tmp, &ctx->shm_list, list)
+    {
+        register_t handle_hi;
+        register_t handle_lo;
+
+        uint64_to_regpair(&handle_hi, &handle_lo, shm->handle);
+        res = ffa_mem_reclaim(handle_lo, handle_hi, 0);
+        switch ( res ) {
+        case FFA_RET_OK:
+            printk(XENLOG_G_DEBUG "%pd: ffa: Reclaimed handle %#lx\n",
+                   d, shm->handle);
+            list_del(&shm->list);
+            free_ffa_shm_mem(d, shm);
+            break;
+        case FFA_RET_DENIED:
+            /*
+             * A temporary error that may get resolved a bit later, it's
+             * worth retrying.
+             */
+            printk(XENLOG_G_INFO "%pd: ffa: Failed to reclaim handle %#lx : %d\n",
+                   d, shm->handle, res);
+            break; /* We will retry later */
+        default:
+            /*
+             * The rest of the error codes are not expected and are assumed
+             * to be of a permanent nature. It not in our control to handle
+             * the error properly so the object in this case is to try to
+             * minimize the damage.
+             *
+             * FFA_RET_NO_MEMORY might be a temporary error as it it could
+             * succeed if retried later, but treat it as permanent for now.
+             */
+            printk(XENLOG_G_INFO "%pd: ffa: Permanent failure to reclaim handle %#lx : %d\n",
+                   d, shm->handle, res);
 
-    for ( n = 0; n < subscr_vm_destroyed_count; n++ )
+            /*
+             * Remove the shm from the list and free it, but don't drop
+             * references. This results in having the shared physical pages
+             * permanently allocate and also keeps the domain as a zombie
+             * domain.
+             */
+            list_del(&shm->list);
+            xfree(shm);
+            break;
+        }
+    }
+}
+
+static void ffa_domain_teardown_continue(struct ffa_ctx *ctx, bool first_time)
+{
+    struct ffa_ctx *next_ctx = NULL;
+
+    send_vm_destroyed(ctx->teardown_d);
+    reclaim_shms(ctx->teardown_d);
+
+    if ( ctx->shm_count ||
+         !bitmap_empty(ctx->vm_destroy_bitmap, subscr_vm_destroyed_count) )
+    {
+        printk(XENLOG_G_INFO "%pd: ffa: Remaining cleanup, retrying\n", ctx->teardown_d);
+
+        ctx->teardown_expire = NOW() + FFA_CTX_TEARDOWN_DELAY;
+
+        spin_lock(&ffa_teardown_lock);
+        list_add_tail(&ctx->teardown_list, &ffa_teardown_head);
+        /* Need to set a new timer for the next ctx in line */
+        next_ctx = list_first_entry(&ffa_teardown_head, struct ffa_ctx,
+                                    teardown_list);
+        spin_unlock(&ffa_teardown_lock);
+    }
+    else
     {
         /*
-         * Skip SPs subscribed to the VM created event that never was
-         * notified of the VM creation due to an error during
-         * ffa_domain_init().
+         * domain_destroy() might have been called (via put_domain() in
+         * reclaim_shms()), so we can't touch the domain structure anymore.
          */
-        if ( is_in_subscr_list(subscr_vm_created, ctx->create_signal_count,
-                               subscr_vm_created_count,
-                               subscr_vm_destroyed[n]) )
-            continue;
-
-        res = ffa_direct_req_send_vm(subscr_vm_destroyed[n], get_vm_id(d),
-                                     FFA_MSG_SEND_VM_DESTROYED);
+        xfree(ctx);
 
-        if ( res )
-            printk(XENLOG_ERR "ffa: Failed to report destruction of vm_id %u to  %u: res %d\n",
-                   get_vm_id(d), subscr_vm_destroyed[n], res);
+        /* Only check if there has been a change to the teardown queue */
+        if ( !first_time )
+        {
+            spin_lock(&ffa_teardown_lock);
+            next_ctx = list_first_entry_or_null(&ffa_teardown_head,
+                                                struct ffa_ctx, teardown_list);
+            spin_unlock(&ffa_teardown_lock);
+        }
     }
 
+    if ( next_ctx )
+        set_timer(&ffa_teardown_timer, next_ctx->teardown_expire);
+}
+
+static void ffa_teardown_timer_callback(void *arg)
+{
+    struct ffa_ctx *ctx;
+
+    spin_lock(&ffa_teardown_lock);
+    ctx = list_first_entry_or_null(&ffa_teardown_head, struct ffa_ctx,
+                                   teardown_list);
+    if ( ctx )
+        list_del(&ctx->teardown_list);
+    spin_unlock(&ffa_teardown_lock);
+
+    if ( ctx )
+        ffa_domain_teardown_continue(ctx, false /* !first_time */);
+    else
+        printk(XENLOG_G_ERR "%s: teardown list is empty\n", __func__);
+}
+
+/* This function is supposed to undo what ffa_domain_init() has done */
+static int ffa_domain_teardown(struct domain *d)
+{
+    struct ffa_ctx *ctx = d->arch.tee;
+
+    if ( !ctx )
+        return 0;
+
     if ( ctx->rx )
         rxtx_unmap(ctx);
 
-    XFREE(d->arch.tee);
+    ffa_domain_teardown_continue(ctx, true /* first_time */);
 
     return 0;
 }
@@ -1739,6 +1931,9 @@ static bool ffa_probe(void)
     if ( !init_sps() )
         goto err_free_ffa_tx;
 
+    INIT_LIST_HEAD(&ffa_teardown_head);
+    init_timer(&ffa_teardown_timer, ffa_teardown_timer_callback, NULL, 0);
+
     return true;
 
 err_free_ffa_tx:
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 12:55:09 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 12:55:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686125.1067668 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rewzB-0000fF-Fl; Tue, 27 Feb 2024 12:55:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686125.1067668; Tue, 27 Feb 2024 12:55:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rewzB-0000f8-DM; Tue, 27 Feb 2024 12:55:05 +0000
Received: by outflank-mailman (input) for mailman id 686125;
 Tue, 27 Feb 2024 12:55:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rewzA-0000f0-30
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 12:55:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rewzA-0008T9-2E
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 12:55:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rewzA-00018n-1P
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 12:55:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=+FzPvCEDWuvF+Yv2LrvqY9o+rNdLxS60ahJb1ALx9GY=; b=Rxn/Kcb9o1YEbuU/mNcc7wT/Oa
	gT37ZBya3ZlNlYl7wbid4JOk0mXaEF4l8G+T7kIQhdwDYMqQpy2sll5Mtg4e8TBTtXj0ttvM4dU8Y
	wsRvxcWxXlxWHaws2LoI0ncDuCg7tQdSw4/1s3Nkd7EXKvn5EntG5ygMJDTvGBSVMdX0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86: document how stub exception recovery works
Message-Id: <E1rewzA-00018n-1P@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 12:55:04 +0000

commit 28154a245c2b8191854b7cafac6a69ffad4afcf3
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Feb 27 13:48:48 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:48:48 2024 +0100

    x86: document how stub exception recovery works
    
    Describe how it is meant to work, even if one aspect of it will only be
    taken care of subsequently.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/extable.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index 1555b9408f..474a1893f8 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -94,6 +94,22 @@ search_exception_table(const struct cpu_user_regs *regs)
     if ( region && region->ex )
         return search_one_extable(region->ex, region->ex_end, regs->rip);
 
+    /*
+     * Emulation stubs (which are per-CPU) are constructed with a RET at the
+     * end, and are CALLed by the invoking code.
+     *
+     * An exception in the stubs may occur anywhere, so we first match any
+     * %rip in the correct stub, with a sanity check on %rsp too.  But, an
+     * entry in ex_table[] needs to be compile-time constant, so we register
+     * the fixup address using the invoking CALL's return address.
+     *
+     * To recover, we:
+     * 1) Emulate a pseudo-RET to get out of the stub.  We POP the return
+     *    address off the stack(s), use it to look up the fixup address, and
+     *    JMP there, then
+     * 2) Emulate a PUSH of 'token' onto the data stack to pass information
+     *    about the exception back to the invoking code.
+     */
     if ( regs->rip >= stub + STUB_BUF_SIZE / 2 &&
          regs->rip < stub + STUB_BUF_SIZE &&
          regs->rsp > (unsigned long)regs &&
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 12:55:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 12:55:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686126.1067672 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rewzK-0000hE-HV; Tue, 27 Feb 2024 12:55:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686126.1067672; Tue, 27 Feb 2024 12:55:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rewzK-0000h8-Ep; Tue, 27 Feb 2024 12:55:14 +0000
Received: by outflank-mailman (input) for mailman id 686126;
 Tue, 27 Feb 2024 12:55:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rewzK-0000h0-7t
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 12:55:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rewzK-0008TN-5K
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 12:55:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rewzK-0001A0-4W
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 12:55:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=h4RwZFSFXOBjeTPtxMTIhYUCEooIkjfnXq16vXDfb8I=; b=5EGJ6YBwneTSM9Kanb3eifZNMu
	GpXpkZ5bGBrTuXl0OVDaXP7uPj1f9ZeBNII+PWJjhoTGXhkO8yRh7UPE3CVzsloxB8+2rpeUVfkpF
	eM784Ybdom8wY8/0S2OBJWcUaVhtDjOgmPFMoQaOTVvml7HdLHvG5Ls6drAXy6Zz/VR8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86: account for shadow stack in exception-from-stub recovery
Message-Id: <E1rewzK-0001A0-4W@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 12:55:14 +0000

commit 91f5f7a9154919a765c3933521760acffeddbf28
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 13:49:22 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:49:22 2024 +0100

    x86: account for shadow stack in exception-from-stub recovery
    
    Dealing with exceptions raised from within emulation stubs involves
    discarding return address (replaced by exception related information).
    Such discarding of course also requires removing the corresponding entry
    from the shadow stack.
    
    Also amend the comment in fixup_exception_return(), to further clarify
    why use of ptr[1] can't be an out-of-bounds access.
    
    While touching do_invalid_op() also add a missing fall-through
    annotation.
    
    This is CVE-2023-46841 / XSA-451.
    
    Fixes: 209fb9919b50 ("x86/extable: Adjust extable handling to be shadow stack compatible")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/extable.c             | 20 +++++++-----
 xen/arch/x86/include/asm/uaccess.h |  3 +-
 xen/arch/x86/traps.c               | 62 +++++++++++++++++++++++++++++++++++---
 3 files changed, 71 insertions(+), 14 deletions(-)

diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index 474a1893f8..fe6c5dbfc7 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -86,13 +86,16 @@ search_one_extable(const struct exception_table_entry *first,
 }
 
 unsigned long
-search_exception_table(const struct cpu_user_regs *regs)
+search_exception_table(const struct cpu_user_regs *regs, unsigned long *stub_ra)
 {
     const struct virtual_region *region = find_text_region(regs->rip);
     unsigned long stub = this_cpu(stubs.addr);
 
     if ( region && region->ex )
+    {
+        *stub_ra = 0;
         return search_one_extable(region->ex, region->ex_end, regs->rip);
+    }
 
     /*
      * Emulation stubs (which are per-CPU) are constructed with a RET at the
@@ -115,13 +118,13 @@ search_exception_table(const struct cpu_user_regs *regs)
          regs->rsp > (unsigned long)regs &&
          regs->rsp < (unsigned long)get_cpu_info() )
     {
-        unsigned long retptr = *(unsigned long *)regs->rsp;
+        unsigned long retaddr = *(unsigned long *)regs->rsp, fixup;
 
-        region = find_text_region(retptr);
-        retptr = region && region->ex
-                 ? search_one_extable(region->ex, region->ex_end, retptr)
-                 : 0;
-        if ( retptr )
+        region = find_text_region(retaddr);
+        fixup = region && region->ex
+                ? search_one_extable(region->ex, region->ex_end, retaddr)
+                : 0;
+        if ( fixup )
         {
             /*
              * Put trap number and error code on the stack (in place of the
@@ -133,7 +136,8 @@ search_exception_table(const struct cpu_user_regs *regs)
             };
 
             *(unsigned long *)regs->rsp = token.raw;
-            return retptr;
+            *stub_ra = retaddr;
+            return fixup;
         }
     }
 
diff --git a/xen/arch/x86/include/asm/uaccess.h b/xen/arch/x86/include/asm/uaccess.h
index 55bc6932fd..48b684c19d 100644
--- a/xen/arch/x86/include/asm/uaccess.h
+++ b/xen/arch/x86/include/asm/uaccess.h
@@ -421,7 +421,8 @@ union stub_exception_token {
     unsigned long raw;
 };
 
-extern unsigned long search_exception_table(const struct cpu_user_regs *regs);
+extern unsigned long search_exception_table(const struct cpu_user_regs *regs,
+                                            unsigned long *stub_ra);
 extern void sort_exception_tables(void);
 extern void sort_exception_table(struct exception_table_entry *start,
                                  const struct exception_table_entry *stop);
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index ff37d97133..d554c9d41e 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -833,7 +833,7 @@ void asmlinkage do_unhandled_trap(struct cpu_user_regs *regs)
 }
 
 static void fixup_exception_return(struct cpu_user_regs *regs,
-                                   unsigned long fixup)
+                                   unsigned long fixup, unsigned long stub_ra)
 {
     if ( IS_ENABLED(CONFIG_XEN_SHSTK) )
     {
@@ -850,7 +850,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
             /*
              * Search for %rip.  The shstk currently looks like this:
              *
-             *   ...  [Likely pointed to by SSP]
+             *   tok  [Supervisor token, == &tok | BUSY, only with FRED inactive]
+             *   ...  [Pointed to by SSP for most exceptions, empty in IST cases]
              *   %cs  [== regs->cs]
              *   %rip [== regs->rip]
              *   SSP  [Likely points to 3 slots higher, above %cs]
@@ -868,7 +869,56 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
              */
             if ( ptr[0] == regs->rip && ptr[1] == regs->cs )
             {
+                unsigned long primary_shstk =
+                    (ssp & ~(STACK_SIZE - 1)) +
+                    (PRIMARY_SHSTK_SLOT + 1) * PAGE_SIZE - 8;
+
                 wrss(fixup, ptr);
+
+                if ( !stub_ra )
+                    goto shstk_done;
+
+                /*
+                 * Stub recovery ought to happen only when the outer context
+                 * was on the main shadow stack.  We need to also "pop" the
+                 * stub's return address from the interrupted context's shadow
+                 * stack.  That is,
+                 * - if we're still on the main stack, we need to move the
+                 *   entire stack (up to and including the exception frame)
+                 *   up by one slot, incrementing the original SSP in the
+                 *   exception frame,
+                 * - if we're on an IST stack, we need to increment the
+                 *   original SSP.
+                 */
+                BUG_ON((ptr[-1] ^ primary_shstk) >> PAGE_SHIFT);
+
+                if ( (ssp ^ primary_shstk) >> PAGE_SHIFT )
+                {
+                    /*
+                     * We're on an IST stack.  First make sure the two return
+                     * addresses actually match.  Then increment the interrupted
+                     * context's SSP.
+                     */
+                    BUG_ON(stub_ra != *(unsigned long*)ptr[-1]);
+                    wrss(ptr[-1] + 8, &ptr[-1]);
+                    goto shstk_done;
+                }
+
+                /* Make sure the two return addresses actually match. */
+                BUG_ON(stub_ra != ptr[2]);
+
+                /* Move exception frame, updating SSP there. */
+                wrss(ptr[1], &ptr[2]); /* %cs */
+                wrss(ptr[0], &ptr[1]); /* %rip */
+                wrss(ptr[-1] + 8, &ptr[0]); /* SSP */
+
+                /* Move all newer entries. */
+                while ( --ptr != _p(ssp) )
+                    wrss(ptr[-1], &ptr[0]);
+
+                /* Finally account for our own stack having shifted up. */
+                asm volatile ( "incsspd %0" :: "r" (2) );
+
                 goto shstk_done;
             }
         }
@@ -889,7 +939,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
 
 static bool extable_fixup(struct cpu_user_regs *regs, bool print)
 {
-    unsigned long fixup = search_exception_table(regs);
+    unsigned long stub_ra = 0;
+    unsigned long fixup = search_exception_table(regs, &stub_ra);
 
     if ( unlikely(fixup == 0) )
         return false;
@@ -903,7 +954,7 @@ static bool extable_fixup(struct cpu_user_regs *regs, bool print)
                vector_name(regs->entry_vector), regs->error_code,
                _p(regs->rip), _p(regs->rip), _p(fixup));
 
-    fixup_exception_return(regs, fixup);
+    fixup_exception_return(regs, fixup, stub_ra);
     this_cpu(last_extable_addr) = regs->rip;
 
     return true;
@@ -1166,7 +1217,8 @@ void asmlinkage do_invalid_op(struct cpu_user_regs *regs)
     {
     case BUGFRAME_run_fn:
     case BUGFRAME_warn:
-        fixup_exception_return(regs, (unsigned long)eip);
+        fixup_exception_return(regs, (unsigned long)eip, 0);
+        fallthrough;
     case BUGFRAME_bug:
     case BUGFRAME_assert:
         return;
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 12:55:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 12:55:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686127.1067677 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rewzV-0000jx-JB; Tue, 27 Feb 2024 12:55:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686127.1067677; Tue, 27 Feb 2024 12:55:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rewzV-0000jp-GN; Tue, 27 Feb 2024 12:55:25 +0000
Received: by outflank-mailman (input) for mailman id 686127;
 Tue, 27 Feb 2024 12:55:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rewzU-0000jc-At
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 12:55:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rewzU-0008Tn-A2
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 12:55:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rewzU-0001Al-7X
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 12:55:24 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ooBtptko5CQqE6jkPwwWvZ4GsksJnc935ZKuC16FPs4=; b=OkYsEbx1C5J2d3L5V2rRHb4jrI
	nfRr4Jr9Dn/GE6CMRQhexhTSVqKxpXSqDztbNPyPGeRq0oEDOHDa+/f6Qopl77YaXWe0VDz3ZCcgy
	ej8lr597fnJaDW/TD9HuR1MFj120vp5H5PfzW0aNJTpJxeXjQY9Znubi27BRat++Kiqs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86: re-run exception-from-stub recovery selftests with CET-SS enabled
Message-Id: <E1rewzU-0001Al-7X@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 12:55:24 +0000

commit cfe3ad67127b86e1b1c06993b86422673a51b050
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 13:49:52 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:49:52 2024 +0100

    x86: re-run exception-from-stub recovery selftests with CET-SS enabled
    
    On the BSP, shadow stacks are enabled only relatively late in the
    booting process. They in particular aren't active yet when initcalls are
    run. Keep the testing there, but invoke that testing a 2nd time when
    shadow stacks are active, to make sure we won't regress that case after
    addressing XSA-451.
    
    While touching this code, switch the guard from NDEBUG to CONFIG_DEBUG,
    such that IS_ENABLED() can validly be used at the new call site.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/extable.c           | 8 +++++---
 xen/arch/x86/include/asm/setup.h | 2 ++
 xen/arch/x86/setup.c             | 4 ++++
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index fe6c5dbfc7..8415cd1fa2 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -144,10 +144,11 @@ search_exception_table(const struct cpu_user_regs *regs, unsigned long *stub_ra)
     return 0;
 }
 
-#ifndef NDEBUG
+#ifdef CONFIG_DEBUG
+#include <asm/setup.h>
 #include <asm/traps.h>
 
-static int __init cf_check stub_selftest(void)
+int __init cf_check stub_selftest(void)
 {
     static const struct {
         uint8_t opc[8];
@@ -171,7 +172,8 @@ static int __init cf_check stub_selftest(void)
     unsigned int i;
     bool fail = false;
 
-    printk("Running stub recovery selftests...\n");
+    printk("%s stub recovery selftests...\n",
+           system_state < SYS_STATE_active ? "Running" : "Re-running");
 
     for ( i = 0; i < ARRAY_SIZE(tests); ++i )
     {
diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h
index 1ced1299c7..1849e60cd6 100644
--- a/xen/arch/x86/include/asm/setup.h
+++ b/xen/arch/x86/include/asm/setup.h
@@ -38,6 +38,8 @@ void *bootstrap_map(const module_t *mod);
 
 int remove_xen_ranges(struct rangeset *r);
 
+int cf_check stub_selftest(void);
+
 extern uint8_t kbd_shift_flags;
 
 #ifdef NDEBUG
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index a0d99f8324..e487591fe0 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -740,6 +740,10 @@ static void noreturn init_done(void)
 
     system_state = SYS_STATE_active;
 
+    /* Re-run stub recovery self-tests with CET-SS active. */
+    if ( IS_ENABLED(CONFIG_DEBUG) && cpu_has_xen_shstk )
+        stub_selftest();
+
     domain_unpause_by_systemcontroller(dom0);
 
     /* MUST be done prior to removing .init data. */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:11:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:11:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686132.1067691 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexEf-0004Nw-VN; Tue, 27 Feb 2024 13:11:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686132.1067691; Tue, 27 Feb 2024 13:11:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexEf-0004No-SD; Tue, 27 Feb 2024 13:11:05 +0000
Received: by outflank-mailman (input) for mailman id 686132;
 Tue, 27 Feb 2024 13:11:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexEe-0004Me-On
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexEe-0000LH-LN
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexEe-0002TH-KG
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=cxH0wk6wBzK5vdLJd5QJbXN4XJajkZI2g/VO4mhaDdU=; b=eSwRkq3BuQQ8aH+VKuh1PippUA
	gfRn9FdFu7qLaeKTDbaZLReXKbl5fIe4S+Yk1pERM7veTMlnm0KDOjj+21o1p74hM8kXJVvpU1Njs
	v2RmGfmPfpUmre5T0xfAYJ5EfwMYNwBMbcdr5nQGaYuY4ZZh9vI4WO3YThXcj6A1lJhE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.18] tools/xentop: fix sorting bug for some columns
Message-Id: <E1rexEe-0002TH-KG@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:11:04 +0000

commit 184d723e7a5d1c021d297e14d19fe5344eac7a56
Author:     Cyril Rébert (zithro) <slack@rabbit.lu>
AuthorDate: Tue Feb 27 13:53:42 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:53:42 2024 +0100

    tools/xentop: fix sorting bug for some columns
    
    Sort doesn't work on columns VBD_OO, VBD_RD, VBD_WR and VBD_RSECT.
    Fix by adjusting variables names in compare functions.
    Bug fix only. No functional change.
    
    Fixes: 91c3e3dc91d6 ("tools/xentop: Display '-' when stats are not available.")
    Signed-off-by: Cyril Rébert (zithro) <slack@rabbit.lu>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    master commit: 29f17d837421f13c0e0010802de1b2d51d2ded4a
    master date: 2024-02-05 17:58:23 +0000
---
 tools/xentop/xentop.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/xentop/xentop.c b/tools/xentop/xentop.c
index 950e8935c4..545bd5e96d 100644
--- a/tools/xentop/xentop.c
+++ b/tools/xentop/xentop.c
@@ -684,7 +684,7 @@ static int compare_vbd_oo(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_oo = 0, dom2_vbd_oo = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_OO, &dom1_vbd_oo);
-	tot_vbd_reqs(domain1, FIELD_VBD_OO, &dom2_vbd_oo);
+	tot_vbd_reqs(domain2, FIELD_VBD_OO, &dom2_vbd_oo);
 
 	return -compare(dom1_vbd_oo, dom2_vbd_oo);
 }
@@ -711,9 +711,9 @@ static int compare_vbd_rd(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_rd = 0, dom2_vbd_rd = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_RD, &dom1_vbd_rd);
-	tot_vbd_reqs(domain1, FIELD_VBD_RD, &dom2_vbd_rd);
+	tot_vbd_reqs(domain2, FIELD_VBD_RD, &dom2_vbd_rd);
 
-	return -compare(dom1_vbd_rd, dom1_vbd_rd);
+	return -compare(dom1_vbd_rd, dom2_vbd_rd);
 }
 
 /* Prints number of total VBD READ requests statistic */
@@ -738,7 +738,7 @@ static int compare_vbd_wr(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_wr = 0, dom2_vbd_wr = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_WR, &dom1_vbd_wr);
-	tot_vbd_reqs(domain1, FIELD_VBD_WR, &dom2_vbd_wr);
+	tot_vbd_reqs(domain2, FIELD_VBD_WR, &dom2_vbd_wr);
 
 	return -compare(dom1_vbd_wr, dom2_vbd_wr);
 }
@@ -765,7 +765,7 @@ static int compare_vbd_rsect(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_rsect = 0, dom2_vbd_rsect = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_RSECT, &dom1_vbd_rsect);
-	tot_vbd_reqs(domain1, FIELD_VBD_RSECT, &dom2_vbd_rsect);
+	tot_vbd_reqs(domain2, FIELD_VBD_RSECT, &dom2_vbd_rsect);
 
 	return -compare(dom1_vbd_rsect, dom2_vbd_rsect);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:11:16 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:11:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686133.1067695 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexEp-0004UY-W8; Tue, 27 Feb 2024 13:11:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686133.1067695; Tue, 27 Feb 2024 13:11:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexEp-0004UR-Ti; Tue, 27 Feb 2024 13:11:15 +0000
Received: by outflank-mailman (input) for mailman id 686133;
 Tue, 27 Feb 2024 13:11:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexEo-0004T2-QD
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexEo-0000LU-Oz
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexEo-0002Tx-Nc
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=lOTZhQ7YraQHoqOD4Uq1jmuAR4Qqu6mEa7ybvBQz3ok=; b=tQS1YZS9AC0l8qUi1vzYweXEmr
	slVeNdZP84wcxZMBfdWLQr5cq3wsR0iOUPGUf4CYozQbhz5ha/fJSPU87pTLlu7xSGz6nKBA2IDzY
	d+KXjTTiYKL/eEPTNlA9Va++UBG8vInzJpToohdOol/jqpj79hB1vHwUgWffKQrDc5nY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.18] amd-vi: fix IVMD memory type checks
Message-Id: <E1rexEo-0002Tx-Nc@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:11:14 +0000

commit fa9950a527a70971bf9279be62d445cf9c83aedf
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 13:54:04 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:54:04 2024 +0100

    amd-vi: fix IVMD memory type checks
    
    The current code that parses the IVMD blocks is relaxed with regard to the
    restriction that such unity regions should always fall into memory ranges
    marked as reserved in the memory map.
    
    However the type checks for the IVMD addresses are inverted, and as a result
    IVMD ranges falling into RAM areas are accepted.  Note that having such ranges
    in the first place is a firmware bug, as IVMD should always fall into reserved
    ranges.
    
    Fixes: ed6c77ebf0c1 ('AMD/IOMMU: check / convert IVMD ranges for being / to be reserved')
    Reported-by: Ox <oxjo@proton.me>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Tested-by: oxjo <oxjo@proton.me>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: 83afa313583019d9f159c122cecf867735d27ec5
    master date: 2024-02-06 11:56:13 +0100
---
 xen/drivers/passthrough/amd/iommu_acpi.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_acpi.c b/xen/drivers/passthrough/amd/iommu_acpi.c
index 699d33f429..96d8879e7b 100644
--- a/xen/drivers/passthrough/amd/iommu_acpi.c
+++ b/xen/drivers/passthrough/amd/iommu_acpi.c
@@ -426,9 +426,14 @@ static int __init parse_ivmd_block(const struct acpi_ivrs_memory *ivmd_block)
                 return -EIO;
             }
 
-            /* Types which won't be handed out are considered good enough. */
-            if ( !(type & (RAM_TYPE_RESERVED | RAM_TYPE_ACPI |
-                           RAM_TYPE_UNUSABLE)) )
+            /*
+             * Types which aren't RAM are considered good enough.
+             * Note that a page being partially RESERVED, ACPI or UNUSABLE will
+             * force Xen into assuming the whole page as having that type in
+             * practice.
+             */
+            if ( type & (RAM_TYPE_RESERVED | RAM_TYPE_ACPI |
+                         RAM_TYPE_UNUSABLE) )
                 continue;
 
             AMD_IOMMU_ERROR("IVMD: page at %lx can't be converted\n", addr);
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:11:26 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:11:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686134.1067698 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexF0-0004Yx-1K; Tue, 27 Feb 2024 13:11:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686134.1067698; Tue, 27 Feb 2024 13:11:26 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexEz-0004Yq-V9; Tue, 27 Feb 2024 13:11:25 +0000
Received: by outflank-mailman (input) for mailman id 686134;
 Tue, 27 Feb 2024 13:11:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexEy-0004Yc-Sb
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexEy-0000Lz-Rn
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexEy-0002US-R1
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:24 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=UmzYbVqnw5865L9Qkf0tcw7B8CzRiHI4vE70etP3p9E=; b=hAoF4t8OcqX3vKcALn60b001F3
	/BQpTe8TzwMYr3uwItLfm2si8TNjqu20AjrlOHPZLCqbB+GPhN6StuH2ZR2o/sIcU6in7Qt6VpK+S
	H9RtdEse/F9eZvk+HdVvAO6t2p5MyEiTzf+10fCiaX4aNLGv7zRivI9PCsdEoA74oxJs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.18] block-common: Fix same_vm for no targets
Message-Id: <E1rexEy-0002US-R1@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:11:24 +0000

commit 16475909baa2bcfda3ebc07ced5e5cd0ca8172d6
Author:     Jason Andryuk <jandryuk@gmail.com>
AuthorDate: Tue Feb 27 13:55:03 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:55:03 2024 +0100

    block-common: Fix same_vm for no targets
    
    same_vm is broken when the two main domains do not have targets.  otvm
    and targetvm are both missing, which means they get set to -1 and then
    converted to empty strings:
    
    ++10697+ local targetvm=-1
    ++10697+ local otvm=-1
    ++10697+ otvm=
    ++10697+ othervm=/vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4
    ++10697+ targetvm=
    ++10697+ local frontend_uuid=/vm/844dea4e-44f8-4e3e-8145-325132a31ca5
    
    The final comparison returns true since the two empty strings match:
    
    ++10697+ '[' /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = /vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o '' = /vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = '' -o '' = '' ']'
    
    Replace -1 with distinct strings indicating the lack of a value and
    remove the collescing to empty stings.  The strings themselves will no
    longer match, and that is correct.
    
    ++12364+ '[' /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = /vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o 'No target' = /vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = 'No other target' -o 'No target' = 'No other target' ']'
    
    Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    master commit: e8f1bb803fdf44db708991593568a9e3e6b3d130
    master date: 2024-02-07 13:46:52 +0100
---
 tools/hotplug/Linux/block-common.sh | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tools/hotplug/Linux/block-common.sh b/tools/hotplug/Linux/block-common.sh
index f86a88c4eb..5c80237d99 100644
--- a/tools/hotplug/Linux/block-common.sh
+++ b/tools/hotplug/Linux/block-common.sh
@@ -112,14 +112,12 @@ same_vm()
                   "$FRONTEND_UUID")
   local target=$(xenstore_read_default  "/local/domain/$FRONTEND_ID/target"   \
                  "-1")
-  local targetvm=$(xenstore_read_default "/local/domain/$target/vm" "-1")
+  local targetvm=$(xenstore_read_default "/local/domain/$target/vm" "No Target")
   local otarget=$(xenstore_read_default  "/local/domain/$otherdom/target"   \
                  "-1")
   local otvm=$(xenstore_read_default  "/local/domain/$otarget/vm"   \
-                 "-1")
-  otvm=${otvm%-1}
-  othervm=${othervm%-1}
-  targetvm=${targetvm%-1}
+                 "No Other Target")
+
   local frontend_uuid=${FRONTEND_UUID%-1}
   
   [ "$frontend_uuid" = "$othervm" -o "$targetvm" = "$othervm" -o \
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:11:36 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:11:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686135.1067703 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexFA-0004ee-4H; Tue, 27 Feb 2024 13:11:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686135.1067703; Tue, 27 Feb 2024 13:11:36 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexFA-0004eW-1a; Tue, 27 Feb 2024 13:11:36 +0000
Received: by outflank-mailman (input) for mailman id 686135;
 Tue, 27 Feb 2024 13:11:35 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexF8-0004eP-VU
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexF8-0000M8-Uo
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexF8-0002Ux-U1
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:34 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=cdXXX+/4tx9949CXWfdA7gpRThlDhhCf8vX4mpi0aLI=; b=uKw4IGQmCdu9pslITZkFnoxe10
	TqMtdStNzBZUuaICDuPBMviT2uB3+SW9kEAKEdMBoYK1dvmHvEGyaqTnwQzDMPsxfjSWe+2u6YjbH
	xQPhKqFQf+VKPkop7uHC3GL1dkYHTMIIkpYL1cQxtGtXx+wDKl1c1XmkxYUt7gX1lYsU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.18] x86/hvm: Fix fast singlestep state persistence
Message-Id: <E1rexF8-0002Ux-U1@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:11:34 +0000

commit b51fd78aed865033413178f5953147effedc7ce0
Author:     Petr Beneš <w1benny@gmail.com>
AuthorDate: Tue Feb 27 13:55:25 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:55:25 2024 +0100

    x86/hvm: Fix fast singlestep state persistence
    
    This patch addresses an issue where the fast singlestep setting would persist
    despite xc_domain_debug_control being called with XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF.
    Specifically, if fast singlestep was enabled in a VMI session and that session
    stopped before the MTF trap occurred, the fast singlestep setting remained
    active even though MTF itself was disabled.  This led to a situation where, upon
    starting a new VMI session, the first event to trigger an EPT violation would
    cause the corresponding EPT event callback to be skipped due to the lingering
    fast singlestep setting.
    
    The fix ensures that the fast singlestep setting is properly reset when
    disabling single step debugging operations.
    
    Signed-off-by: Petr Beneš <w1benny@gmail.com>
    Reviewed-by: Tamas K Lengyel <tamas@tklengyel.com>
    master commit: 897def94b56175ce569673a05909d2f223e1e749
    master date: 2024-02-12 09:37:58 +0100
---
 xen/arch/x86/hvm/hvm.c | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 482eebbabf..a70b351373 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -5167,26 +5167,40 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
 
 int hvm_debug_op(struct vcpu *v, int32_t op)
 {
-    int rc;
+    int rc = 0;
 
     switch ( op )
     {
         case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON:
         case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF:
-            rc = -EOPNOTSUPP;
             if ( !cpu_has_monitor_trap_flag )
-                break;
-            rc = 0;
-            vcpu_pause(v);
-            v->arch.hvm.single_step =
-                (op == XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON);
-            vcpu_unpause(v); /* guest will latch new state */
+                return -EOPNOTSUPP;
             break;
         default:
-            rc = -ENOSYS;
-            break;
+            return -ENOSYS;
+    }
+
+    vcpu_pause(v);
+
+    switch ( op )
+    {
+    case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON:
+        v->arch.hvm.single_step = true;
+        break;
+
+    case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF:
+        v->arch.hvm.single_step = false;
+        v->arch.hvm.fast_single_step.enabled = false;
+        v->arch.hvm.fast_single_step.p2midx = 0;
+        break;
+
+    default: /* Excluded above */
+        ASSERT_UNREACHABLE();
+        return -ENOSYS;
     }
 
+    vcpu_unpause(v); /* guest will latch new state */
+
     return rc;
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:11:46 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:11:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686136.1067708 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexFK-0004mJ-6g; Tue, 27 Feb 2024 13:11:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686136.1067708; Tue, 27 Feb 2024 13:11:46 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexFK-0004m9-31; Tue, 27 Feb 2024 13:11:46 +0000
Received: by outflank-mailman (input) for mailman id 686136;
 Tue, 27 Feb 2024 13:11:45 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexFJ-0004ly-2g
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:45 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexFJ-0000MH-1x
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:45 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexFJ-0002Vr-11
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:45 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=1y/UM+QhRgHMUEf91e20VLsq8cN8DnwoWRJ5ocXvc8A=; b=61pS7CcE+nrs67y7DGYTlpSLv3
	LusfVpgx3awY47w8xHsLUF/3Jr7NeB1oyYAdfAHONnCGJS+LUmVHZ/9v+vo7uBo1htLIFkND3bRW4
	djuOhU1LE4tdnnmdAyHdvNjnoSXjL2bIKIpqyBKnQ5fxQKzABqvKpJiIVqCNDvbgtdJE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.18] x86/HVM: tidy state on hvmemul_map_linear_addr()'s error path
Message-Id: <E1rexFJ-0002Vr-11@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:11:45 +0000

commit 59e6ad6597dc9930c966b20485a9d0b369ff71a5
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 13:55:56 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:55:56 2024 +0100

    x86/HVM: tidy state on hvmemul_map_linear_addr()'s error path
    
    While in the vast majority of cases failure of the function will not
    be followed by re-invocation with the same emulation context, a few
    very specific insns - involving multiple independent writes, e.g. ENTER
    and PUSHA - exist where this can happen. Since failure of the function
    only signals to the caller that it ought to try an MMIO write instead,
    such failure also cannot be assumed to result in wholesale failure of
    emulation of the current insn. Instead we have to maintain internal
    state such that another invocation of the function with the same
    emulation context remains possible. To achieve that we need to reset MFN
    slots after putting page references on the error path.
    
    Note that all of this affects debugging code only, in causing an
    assertion to trigger (higher up in the function). There's otherwise no
    misbehavior - such a "leftover" slot would simply be overwritten by new
    contents in a release build.
    
    Also extend the related unmap() assertion, to further check for MFN 0.
    
    Fixes: 8cbd4fb0b7ea ("x86/hvm: implement hvmemul_write() using real mappings")
    Reported-by: Manuel Andreas <manuel.andreas@tum.de>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Paul Durrant <paul@xen.org>
    master commit: e72f951df407bc3be82faac64d8733a270036ba1
    master date: 2024-02-13 09:36:14 +0100
---
 xen/arch/x86/hvm/emulate.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 254716c766..865aa08bbc 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -696,7 +696,12 @@ static void *hvmemul_map_linear_addr(
  out:
     /* Drop all held references. */
     while ( mfn-- > hvmemul_ctxt->mfn )
+    {
         put_page(mfn_to_page(*mfn));
+#ifndef NDEBUG /* Clean slot for a subsequent map()'s error checking. */
+        *mfn = _mfn(0);
+#endif
+    }
 
     return err;
 }
@@ -718,7 +723,7 @@ static void hvmemul_unmap_linear_addr(
 
     for ( i = 0; i < nr_frames; i++ )
     {
-        ASSERT(mfn_valid(*mfn));
+        ASSERT(mfn_x(*mfn) && mfn_valid(*mfn));
         paging_mark_dirty(currd, *mfn);
         put_page(mfn_to_page(*mfn));
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:11:56 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:11:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686137.1067710 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexFU-0004sE-7a; Tue, 27 Feb 2024 13:11:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686137.1067710; Tue, 27 Feb 2024 13:11:56 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexFU-0004s7-4b; Tue, 27 Feb 2024 13:11:56 +0000
Received: by outflank-mailman (input) for mailman id 686137;
 Tue, 27 Feb 2024 13:11:55 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexFT-0004s0-5o
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:55 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexFT-0000MR-53
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:55 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexFT-0002WI-4C
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:11:55 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=vvgU4CszYyxWJLwNMBvJyZ/Adqn5KVv+UbO2JgBW80Q=; b=d1D3pByKHRU5Be8crsSpK4qyeF
	4UdZEFDzwZRdTaiFhJtynOTvHQ4orJUO+XngqpdHw/CqaiLj1b83VwGYsEiUeYWudZGAmkfjj22Yz
	dU/SwJor0uhQRu6xA2ib1y7btJKZRG/x5PsE/Njesx+98dmajM9PkrQ8Xstp4DGLda6o=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.18] build: Replace `which` with `command -v`
Message-Id: <E1rexFT-0002WI-4C@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:11:55 +0000

commit 006764b871db75d5d025500a079ad246d1d418a1
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Tue Feb 27 13:56:25 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:56:25 2024 +0100

    build: Replace `which` with `command -v`
    
    The `which` command is not standard, may not exist on the build host,
    or may not behave as expected by the build system. It is recommended
    to use `command -v` to find out if a command exist and have its path,
    and it's part of a POSIX shell standard (at least, it seems to be
    mandatory since IEEE Std 1003.1-2008, but was optional before).
    
    Fixes: c8a8645f1efe ("xen/build: Automatically locate a suitable python interpreter")
    Fixes: 3b47bcdb6d38 ("xen/build: Use a distro version of figlet")
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Tested-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: f93629b18b528a5ab1b1092949c5420069c7226c
    master date: 2024-02-19 12:45:48 +0100
---
 xen/Makefile | 4 ++--
 xen/build.mk | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/Makefile b/xen/Makefile
index a92709b43e..59d368e4d8 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -25,8 +25,8 @@ export XEN_BUILD_HOST	:= $(shell hostname)
 endif
 
 # Best effort attempt to find a python interpreter, defaulting to Python 3 if
-# available.  Fall back to just `python` if `which` is nowhere to be found.
-PYTHON_INTERPRETER	:= $(word 1,$(shell which python3 python python2 2>/dev/null) python)
+# available.  Fall back to just `python`.
+PYTHON_INTERPRETER	:= $(word 1,$(shell command -v python3 || command -v python || command -v python2) python)
 export PYTHON		?= $(PYTHON_INTERPRETER)
 
 export CHECKPOLICY	?= checkpolicy
diff --git a/xen/build.mk b/xen/build.mk
index 26dd5a8e87..0f490ca71b 100644
--- a/xen/build.mk
+++ b/xen/build.mk
@@ -1,6 +1,6 @@
 quiet_cmd_banner = BANNER  $@
 define cmd_banner
-    if which figlet >/dev/null 2>&1 ; then \
+    if command -v figlet >/dev/null 2>&1 ; then \
 	echo " Xen $(XEN_FULLVERSION)" | figlet -f $< > $@.tmp; \
     else \
 	echo " Xen $(XEN_FULLVERSION)" > $@.tmp; \
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:12:06 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:12:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686138.1067715 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexFe-0004zz-8m; Tue, 27 Feb 2024 13:12:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686138.1067715; Tue, 27 Feb 2024 13:12:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexFe-0004zr-61; Tue, 27 Feb 2024 13:12:06 +0000
Received: by outflank-mailman (input) for mailman id 686138;
 Tue, 27 Feb 2024 13:12:05 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexFd-0004zi-8f
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:05 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexFd-0000Mn-7y
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexFd-0002Xj-7H
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:05 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=aG0+diENkK3a+2DYsXVbu9O6yqPwGFU12dJTj60cYqk=; b=uhPMjIeOpc3Z1Qz7F0M9XHJlE4
	kuw/WqxUUo39ockxrBJMm3RSFdtViFPhU4lUaqKc4MCWnCaG7FA/e3nvtvJeaF6B1QQqoGdgKYqHJ
	LukfwlIy/y6+nmMpySSBCxpWmMvt4ff7z4m/xKZNfdAQVN4LA/iF2QRsH9USbWaNYQTU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.18] libxl: Disable relocating memory for qemu-xen in stubdomain too
Message-Id: <E1rexFd-0002Xj-7H@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:12:05 +0000

commit 489c2b9ba173376e978c0ef3de416a2f09452e85
Author:     Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
AuthorDate: Tue Feb 27 13:57:07 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:57:07 2024 +0100

    libxl: Disable relocating memory for qemu-xen in stubdomain too
    
    According to comments (and experiments) qemu-xen cannot handle memory
    reolcation done by hvmloader. The code was already disabled when running
    qemu-xen in dom0 (see libxl__spawn_local_dm()), but it was missed when
    adding qemu-xen support to stubdomain. Adjust libxl__spawn_stub_dm() to
    be consistent in this regard.
    
    Reported-by: Neowutran <xen@neowutran.ovh>
    Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    master commit: 97883aa269f6745a6ded232be3a855abb1297e0d
    master date: 2024-02-22 11:48:22 +0100
---
 tools/libs/light/libxl_dm.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
index 14b593110f..ed620a9d8e 100644
--- a/tools/libs/light/libxl_dm.c
+++ b/tools/libs/light/libxl_dm.c
@@ -2432,6 +2432,16 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
                         "%s",
                         libxl_bios_type_to_string(guest_config->b_info.u.hvm.bios));
     }
+    /* Disable relocating memory to make the MMIO hole larger
+     * unless we're running qemu-traditional and vNUMA is not
+     * configured. */
+    libxl__xs_printf(gc, XBT_NULL,
+                     libxl__sprintf(gc, "%s/hvmloader/allow-memory-relocate",
+                                    libxl__xs_get_dompath(gc, guest_domid)),
+                     "%d",
+                     guest_config->b_info.device_model_version
+                        == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL &&
+                     !libxl__vnuma_configured(&guest_config->b_info));
     ret = xc_domain_set_target(ctx->xch, dm_domid, guest_domid);
     if (ret<0) {
         LOGED(ERROR, guest_domid, "setting target domain %d -> %d",
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:12:16 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:12:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686139.1067719 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexFo-00052l-AD; Tue, 27 Feb 2024 13:12:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686139.1067719; Tue, 27 Feb 2024 13:12:16 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexFo-00052e-7P; Tue, 27 Feb 2024 13:12:16 +0000
Received: by outflank-mailman (input) for mailman id 686139;
 Tue, 27 Feb 2024 13:12:15 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexFn-00052U-Bg
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:15 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexFn-0000Mu-Ao
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:15 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexFn-0002a8-A4
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:15 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=4xsED8OD+Pyc8/2OETQCYbvPPCH0v1cxYXLt2YHJgZQ=; b=m2qp8BcaPz8rJqMdu0jaywgd6e
	a0jy3ERnT27/OeXawjih+UNbb2CtfyE6jwhiNRJcHUZOhDUo3bx/pdWjZ62EmRV5/jyICMcqOAGwe
	aXsduGHpnsc16DO1zWLjuRiPA3SDw7q3cLmtZVee9bPlynjss0b6a3g6Ha1XvK+DlejQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.18] build: make sure build fails when running kconfig fails
Message-Id: <E1rexFn-0002a8-A4@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:12:15 +0000

commit 5fda82641461a5234ab9bf0575423dfb8bfc5657
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 13:57:31 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:57:31 2024 +0100

    build: make sure build fails when running kconfig fails
    
    Because of using "-include", failure to (re)build auto.conf (with
    auto.conf.cmd produced as a secondary target) won't stop make from
    continuing the build. Arrange for it being possible to drop the - from
    Rules.mk, requiring that the include be skipped for tools-only targets.
    Note that relying on the inclusion in those cases wouldn't be correct
    anyway, as it might be a stale file (yet to be rebuilt) which would be
    included, while during initial build, the file would be absent
    altogether.
    
    Fixes: 8d4c17a90b0a ("xen/build: silence make warnings about missing auto.conf*")
    Reported-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    master commit: d34e5fa2e8db19f23081f46a3e710bb122130691
    master date: 2024-02-22 11:52:47 +0100
---
 xen/Makefile | 1 +
 xen/Rules.mk | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/xen/Makefile b/xen/Makefile
index 59d368e4d8..fdf9fd3f22 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -374,6 +374,7 @@ $(KCONFIG_CONFIG): tools_fixdep
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
+	$(Q)rm -f include/config/auto.conf
 	$(Q)$(MAKE) $(build)=tools/kconfig syncconfig
 
 ifeq ($(CONFIG_DEBUG),y)
diff --git a/xen/Rules.mk b/xen/Rules.mk
index 8af3dd7277..d759cccee3 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -15,7 +15,9 @@ srcdir := $(srctree)/$(src)
 PHONY := __build
 __build:
 
--include $(objtree)/include/config/auto.conf
+ifneq ($(firstword $(subst /, ,$(obj))),tools)
+include $(objtree)/include/config/auto.conf
+endif
 
 include $(XEN_ROOT)/Config.mk
 include $(srctree)/scripts/Kbuild.include
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:12:26 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:12:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686140.1067723 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexFy-00056U-BR; Tue, 27 Feb 2024 13:12:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686140.1067723; Tue, 27 Feb 2024 13:12:26 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexFy-00056N-93; Tue, 27 Feb 2024 13:12:26 +0000
Received: by outflank-mailman (input) for mailman id 686140;
 Tue, 27 Feb 2024 13:12:25 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexFx-00056D-Eo
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:25 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexFx-0000NN-E6
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:25 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexFx-0002aj-DL
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:25 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ktrCVI2jnV8cWOgkmhu7XXNZMf6YKKbO9jFJbAL57m0=; b=vmorFgmhVeD0zFInKj9S4bPZqK
	7d/95wxrw2nGklpqJ4C7CSA7jEe4pB6YTTaDyLvg3sgQyImc+O3RZ7+DngpnqtfqCDksINHDyKw8F
	92Sl87s7TLBtIqboeX/nCQwS8DcuN9EsQR0Srk+WBogF9SSNDuhYOumgd1bBSyzcpQRk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.18] x86emul: add missing EVEX.R' checks
Message-Id: <E1rexFx-0002aj-DL@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:12:25 +0000

commit a751d1321f6e1491d6ec2134d59eefa9f9752b86
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 13:57:50 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:57:50 2024 +0100

    x86emul: add missing EVEX.R' checks
    
    EVEX.R' is not ignored in 64-bit code when encoding a GPR or mask
    register. While for mask registers suitable checks are in place (there
    also covering EVEX.R), they were missing for the few cases where in
    EVEX-encoded instructions ModR/M.reg encodes a GPR. While for VPEXTRW
    the bit is replaced before an emulation stub is invoked, for
    VCVT{,T}{S,D,H}2{,U}SI this actually would have led to #UD from inside
    an emulation stub, in turn raising #UD to the guest, but accompanied by
    log messages indicating something's wrong in Xen nevertheless.
    
    Fixes: 001bd91ad864 ("x86emul: support AVX512{F,BW,DQ} extract insns")
    Fixes: baf4a376f550 ("x86emul: support AVX512F legacy-equivalent scalar int/FP conversion insns")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: cb319824bfa8d3c9ea0410cc71daaedc3e11aa2a
    master date: 2024-02-22 11:54:07 +0100
---
 xen/arch/x86/x86_emulate/x86_emulate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index cf780da501..d6b60f0539 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -3686,7 +3686,8 @@ x86_emulate(
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x2d): /* vcvts{s,d}2si xmm/mem,reg */
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x78): /* vcvtts{s,d}2usi xmm/mem,reg */
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x79): /* vcvts{s,d}2usi xmm/mem,reg */
-        generate_exception_if((evex.reg != 0xf || !evex.RX || evex.opmsk ||
+        generate_exception_if((evex.reg != 0xf || !evex.RX || !evex.R ||
+                               evex.opmsk ||
                                (ea.type != OP_REG && evex.brs)),
                               X86_EXC_UD);
         host_and_vcpu_must_have(avx512f);
@@ -7295,7 +7296,7 @@ x86_emulate(
         goto pextr;
 
     case X86EMUL_OPC_EVEX_66(0x0f, 0xc5):   /* vpextrw $imm8,xmm,reg */
-        generate_exception_if(ea.type != OP_REG, X86_EXC_UD);
+        generate_exception_if(ea.type != OP_REG || !evex.R, X86_EXC_UD);
         /* Convert to alternative encoding: We want to use a memory operand. */
         evex.opcx = ext_0f3a;
         b = 0x15;
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:12:36 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:12:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686141.1067727 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexG8-0005Bn-DA; Tue, 27 Feb 2024 13:12:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686141.1067727; Tue, 27 Feb 2024 13:12:36 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexG8-0005Bf-AU; Tue, 27 Feb 2024 13:12:36 +0000
Received: by outflank-mailman (input) for mailman id 686141;
 Tue, 27 Feb 2024 13:12:35 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexG7-0005BV-Hj
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:35 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexG7-0000Nd-Gt
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:35 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexG7-0002bC-GC
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:35 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=FRdbGHBpVLl7EpsAgeymdCB3wTdbbxWupZcwjvbjj9I=; b=p715XwPQXBdYJMl3hwKycPPh7P
	jLgOY0ZNb0wv3oIpU8yKpI6VxAGnbutOd4SqQTf8484IdpTr1LUrK+a6EFq6ULePjcX93JLE1P2Lf
	julA8xEc2uxQMMamsQB7wDj1GBUaOsVOdup6Dw+jiZO3odXSnnn1N1WU0RV57Hd0adLs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.18] xen/livepatch: fix norevert test hook setup typo
Message-Id: <E1rexG7-0002bC-GC@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:12:35 +0000

commit 33a0368d3beb82ddb0cf7ed398b047325bb7be1c
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 13:58:21 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:58:21 2024 +0100

    xen/livepatch: fix norevert test hook setup typo
    
    The test code has a typo in using LIVEPATCH_APPLY_HOOK() instead of
    LIVEPATCH_REVERT_HOOK().
    
    Fixes: 6047104c3ccc ('livepatch: Add per-function applied/reverted state tracking marker')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
    master commit: f0622dd4fd6ae6ddb523a45d89ed9b8f3a9a8f36
    master date: 2024-02-26 10:13:46 +0100
---
 xen/test/livepatch/xen_action_hooks_norevert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/test/livepatch/xen_action_hooks_norevert.c b/xen/test/livepatch/xen_action_hooks_norevert.c
index 3e21ade6ab..c173855192 100644
--- a/xen/test/livepatch/xen_action_hooks_norevert.c
+++ b/xen/test/livepatch/xen_action_hooks_norevert.c
@@ -120,7 +120,7 @@ static void post_revert_hook(livepatch_payload_t *payload)
     printk(KERN_DEBUG "%s: Hook done.\n", __func__);
 }
 
-LIVEPATCH_APPLY_HOOK(revert_hook);
+LIVEPATCH_REVERT_HOOK(revert_hook);
 
 LIVEPATCH_PREAPPLY_HOOK(pre_apply_hook);
 LIVEPATCH_POSTAPPLY_HOOK(post_apply_hook);
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:12:47 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:12:47 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686142.1067730 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexGJ-0005T7-Fw; Tue, 27 Feb 2024 13:12:47 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686142.1067730; Tue, 27 Feb 2024 13:12:47 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexGJ-0005Sy-DE; Tue, 27 Feb 2024 13:12:47 +0000
Received: by outflank-mailman (input) for mailman id 686142;
 Tue, 27 Feb 2024 13:12:45 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexGH-0005Se-KV
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:45 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexGH-0000Nk-Jo
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:45 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexGH-0002bg-Iz
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:45 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ZsMdBAf/KPNaTBFrN5fiaEM9a5HGQXkm2i/CYsKJuzU=; b=F9xtXv8Mpf5FWswVT54o2t9rd8
	9E+DklY0AtgjzwytwvxEdgi9WE3g5fJxg4+30bKmmWvSeAw9PZaLhcSLRNAFf+HQmz+2tVGM/ze0S
	NtY18+rh7a5z6chLUinv0c1bgu9kUSEr4l7sHq/CZP7PcmRaaC269UpWXp+YNdv1M4wo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.18] xen/cmdline: fix printf format specifier in no_config_param()
Message-Id: <E1rexGH-0002bg-Iz@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:12:45 +0000

commit f6e5ab5fa7257783fdbbaabf6010d8d97656c11f
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 13:58:36 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:58:36 2024 +0100

    xen/cmdline: fix printf format specifier in no_config_param()
    
    '*' sets the width field, which is the minimum number of characters to output,
    but what we want in no_config_param() is the precision instead, which is '.*'
    as it imposes a maximum limit on the output.
    
    Fixes: 68d757df8dd2 ('x86/pv: Options to disable and/or compile out 32bit PV support')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: ef101f525173cf51dc70f4c77862f6f10a8ddccf
    master date: 2024-02-26 10:17:40 +0100
---
 xen/include/xen/param.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/include/xen/param.h b/xen/include/xen/param.h
index 93c3fe7cb7..e02e49635c 100644
--- a/xen/include/xen/param.h
+++ b/xen/include/xen/param.h
@@ -191,7 +191,7 @@ static inline void no_config_param(const char *cfg, const char *param,
 {
     int len = e ? ({ ASSERT(e >= s); e - s; }) : strlen(s);
 
-    printk(XENLOG_INFO "CONFIG_%s disabled - ignoring '%s=%*s' setting\n",
+    printk(XENLOG_INFO "CONFIG_%s disabled - ignoring '%s=%.*s' setting\n",
            cfg, param, len, s);
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:12:57 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:12:57 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686143.1067735 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexGT-0005cX-Hb; Tue, 27 Feb 2024 13:12:57 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686143.1067735; Tue, 27 Feb 2024 13:12:57 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexGT-0005cQ-Eg; Tue, 27 Feb 2024 13:12:57 +0000
Received: by outflank-mailman (input) for mailman id 686143;
 Tue, 27 Feb 2024 13:12:55 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexGR-0005b5-NW
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:55 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexGR-0000Nv-Mi
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:55 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexGR-0002cM-Lu
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:12:55 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=eM7MdKDy2qgVk85zC+ecNHcZ2vLgjGHcwa9kScvnN7Y=; b=5h7c1y6Rix1ZCHIatCFnLHjTZI
	BxX9ifcFR1387gg5xmAQJGjoLM81HDCAzWmEzxg6Agl62akakTRPphnFDhMYqoFL1kUHv6Fxios0O
	dYm9zI14jspNJz0Os/vdH2wyud/d8fEkKMqk62FGaJk9b/0hai6OqcSmA7Msho4C1gt4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.18] x86/altcall: use a union as register type for function parameters on clang
Message-Id: <E1rexGR-0002cM-Lu@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:12:55 +0000

commit 19fd9ff9981732995b1028f9e7e406061b723651
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 13:59:05 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:59:05 2024 +0100

    x86/altcall: use a union as register type for function parameters on clang
    
    The current code for alternative calls uses the caller parameter types as the
    types for the register variables that serve as function parameters:
    
    uint8_t foo;
    [...]
    alternative_call(myfunc, foo);
    
    Would expand roughly into:
    
    register unint8_t a1_ asm("rdi") = foo;
    register unsigned long a2_ asm("rsi");
    [...]
    asm volatile ("call *%c[addr](%%rip)"...);
    
    However with -O2 clang will generate incorrect code, given the following
    example:
    
    unsigned int func(uint8_t t)
    {
        return t;
    }
    
    static void bar(uint8_t b)
    {
        int ret_;
        register uint8_t di asm("rdi") = b;
        register unsigned long si asm("rsi");
        register unsigned long dx asm("rdx");
        register unsigned long cx asm("rcx");
        register unsigned long r8 asm("r8");
        register unsigned long r9 asm("r9");
        register unsigned long r10 asm("r10");
        register unsigned long r11 asm("r11");
    
        asm volatile ( "call %c[addr]"
                       : "+r" (di), "=r" (si), "=r" (dx),
                         "=r" (cx), "=r" (r8), "=r" (r9),
                         "=r" (r10), "=r" (r11), "=a" (ret_)
                       : [addr] "i" (&(func)), "g" (func)
                       : "memory" );
    }
    
    void foo(unsigned int a)
    {
        bar(a);
    }
    
    Clang generates the following assembly code:
    
    func:                                   # @func
            movl    %edi, %eax
            retq
    foo:                                    # @foo
            callq   func
            retq
    
    Note the truncation of the unsigned int parameter 'a' of foo() to uint8_t when
    passed into bar() is lost.  clang doesn't zero extend the parameters in the
    callee when required, as the psABI mandates.
    
    The above can be worked around by using a union when defining the register
    variables, so that `di` becomes:
    
    register union {
        uint8_t e;
        unsigned long r;
    } di asm("rdi") = { .e = b };
    
    Which results in following code generated for `foo()`:
    
    foo:                                    # @foo
            movzbl  %dil, %edi
            callq   func
            retq
    
    So the truncation is not longer lost.  Apply such workaround only when built
    with clang.
    
    Reported-by: Matthew Grooms <mgrooms@shrew.net>
    Link: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277200
    Link: https://github.com/llvm/llvm-project/issues/12579
    Link: https://github.com/llvm/llvm-project/issues/82598
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    master commit: 2ce562b2a413cbdb2e1128989ed1722290a27c4e
    master date: 2024-02-26 10:18:01 +0100
---
 xen/arch/x86/include/asm/alternative.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/xen/arch/x86/include/asm/alternative.h b/xen/arch/x86/include/asm/alternative.h
index a1cd6a9fe5..3c14db5078 100644
--- a/xen/arch/x86/include/asm/alternative.h
+++ b/xen/arch/x86/include/asm/alternative.h
@@ -167,9 +167,34 @@ extern void alternative_branches(void);
 #define ALT_CALL_arg5 "r8"
 #define ALT_CALL_arg6 "r9"
 
+#ifdef CONFIG_CC_IS_CLANG
+/*
+ * Use a union with an unsigned long in order to prevent clang from
+ * skipping a possible truncation of the value.  By using the union any
+ * truncation is carried before the call instruction, in turn covering
+ * for ABI-non-compliance in that the necessary clipping / extension of
+ * the value is supposed to be carried out in the callee.
+ *
+ * Note this behavior is not mandated by the standard, and hence could
+ * stop being a viable workaround, or worse, could cause a different set
+ * of code-generation issues in future clang versions.
+ *
+ * This has been reported upstream:
+ * https://github.com/llvm/llvm-project/issues/12579
+ * https://github.com/llvm/llvm-project/issues/82598
+ */
+#define ALT_CALL_ARG(arg, n)                                            \
+    register union {                                                    \
+        typeof(arg) e;                                                  \
+        unsigned long r;                                                \
+    } a ## n ## _ asm ( ALT_CALL_arg ## n ) = {                         \
+        .e = ({ BUILD_BUG_ON(sizeof(arg) > sizeof(void *)); (arg); })   \
+    }
+#else
 #define ALT_CALL_ARG(arg, n) \
     register typeof(arg) a ## n ## _ asm ( ALT_CALL_arg ## n ) = \
         ({ BUILD_BUG_ON(sizeof(arg) > sizeof(void *)); (arg); })
+#endif
 #define ALT_CALL_NO_ARG(n) \
     register unsigned long a ## n ## _ asm ( ALT_CALL_arg ## n )
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:13:07 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:13:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686144.1067739 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexGd-0005kP-JH; Tue, 27 Feb 2024 13:13:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686144.1067739; Tue, 27 Feb 2024 13:13:07 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexGd-0005kH-GK; Tue, 27 Feb 2024 13:13:07 +0000
Received: by outflank-mailman (input) for mailman id 686144;
 Tue, 27 Feb 2024 13:13:05 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexGb-0005ij-QM
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:13:05 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexGb-0000OK-Pa
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:13:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexGb-0002dd-Os
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:13:05 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Q26Gq/nVGWej9lZz02WdvmKAPzRxMASpv9VghnTpIIo=; b=Lzwau9FqcejW7kOkwqPJfFmU+G
	EOU53Ixtu7TZWsQu37iSVdPzk1lJXaGhmClQzGk0HzxKUe9HMTb0KkdEQboGeEagwkypS4EItFI5d
	gzqHRDvBsBjwZ6VseO1u35llRBYJuveRRjAE16IAMwNlRCTeCj5/zZfvSgGvBOX7C3e4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.18] x86/spec: fix BRANCH_HARDEN option to only be set when build-enabled
Message-Id: <E1rexGb-0002dd-Os@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:13:05 +0000

commit 4d47dca20dcfdca2340c8cda6f50dcdcafb1c054
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 13:59:42 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:59:42 2024 +0100

    x86/spec: fix BRANCH_HARDEN option to only be set when build-enabled
    
    The current logic to handle the BRANCH_HARDEN option will report it as enabled
    even when build-time disabled. Fix this by only allowing the option to be set
    when support for it is built into Xen.
    
    Fixes: 2d6f36daa086 ('x86/nospec: Introduce CONFIG_SPECULATIVE_HARDEN_BRANCH')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: 60e00f77a5cc671d30c5ef3318f5b8e9b74e4aa3
    master date: 2024-02-26 16:06:42 +0100
---
 xen/arch/x86/spec_ctrl.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index a8d8af22f6..01ba59cff7 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -50,7 +50,8 @@ static int8_t __initdata opt_psfd = -1;
 int8_t __ro_after_init opt_ibpb_ctxt_switch = -1;
 int8_t __read_mostly opt_eager_fpu = -1;
 int8_t __read_mostly opt_l1d_flush = -1;
-static bool __initdata opt_branch_harden = true;
+static bool __initdata opt_branch_harden =
+    IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH);
 
 bool __initdata bsp_delay_spec_ctrl;
 uint8_t __read_mostly default_xen_spec_ctrl;
@@ -268,7 +269,16 @@ static int __init cf_check parse_spec_ctrl(const char *s)
         else if ( (val = parse_boolean("l1d-flush", s, ss)) >= 0 )
             opt_l1d_flush = val;
         else if ( (val = parse_boolean("branch-harden", s, ss)) >= 0 )
-            opt_branch_harden = val;
+        {
+            if ( IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH) )
+                opt_branch_harden = val;
+            else
+            {
+                no_config_param("SPECULATIVE_HARDEN_BRANCH", "spec-ctrl", s,
+                                ss);
+                rc = -EINVAL;
+            }
+        }
         else if ( (val = parse_boolean("srb-lock", s, ss)) >= 0 )
             opt_srb_lock = val;
         else if ( (val = parse_boolean("unpriv-mmio", s, ss)) >= 0 )
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:13:17 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:13:17 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686145.1067742 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexGn-0005og-KT; Tue, 27 Feb 2024 13:13:17 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686145.1067742; Tue, 27 Feb 2024 13:13:17 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexGn-0005oY-Hp; Tue, 27 Feb 2024 13:13:17 +0000
Received: by outflank-mailman (input) for mailman id 686145;
 Tue, 27 Feb 2024 13:13:15 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexGl-0005ne-TJ
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:13:15 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexGl-0000OU-Sf
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:13:15 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexGl-0002eJ-Rp
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:13:15 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=bsNrvB+3PlyqFQudIx47gg5rivGPNLU/vHfm2kwUQrg=; b=WpzKa4xaTbnu+xYH4sccu+i2ro
	wvebG7CyUp55dJVSCE/shG0aot7IGJXit4q1FUhNPYW/alVA6oFANQ3SIF6GFvftm2V/EINulI5uv
	cFZueFanAqErIotRxbDb9qKczv6HuV3lJaqx8CGE3y7cJ6pHzN9b7165LLLZdZahtdX4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.18] x86: account for shadow stack in exception-from-stub recovery
Message-Id: <E1rexGl-0002eJ-Rp@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:13:15 +0000

commit 58bb8115104c9fca749ee4cfcd3579ac1ed644db
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 14:00:22 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:00:22 2024 +0100

    x86: account for shadow stack in exception-from-stub recovery
    
    Dealing with exceptions raised from within emulation stubs involves
    discarding return address (replaced by exception related information).
    Such discarding of course also requires removing the corresponding entry
    from the shadow stack.
    
    Also amend the comment in fixup_exception_return(), to further clarify
    why use of ptr[1] can't be an out-of-bounds access.
    
    While touching do_invalid_op() also add a missing fall-through
    annotation.
    
    This is CVE-2023-46841 / XSA-451.
    
    Fixes: 209fb9919b50 ("x86/extable: Adjust extable handling to be shadow stack compatible")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: 91f5f7a9154919a765c3933521760acffeddbf28
    master date: 2024-02-27 13:49:22 +0100
---
 xen/arch/x86/extable.c             | 20 +++++++-----
 xen/arch/x86/include/asm/uaccess.h |  3 +-
 xen/arch/x86/traps.c               | 62 +++++++++++++++++++++++++++++++++++---
 3 files changed, 71 insertions(+), 14 deletions(-)

diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index 74b14246e9..8ffcd346d7 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -86,26 +86,29 @@ search_one_extable(const struct exception_table_entry *first,
 }
 
 unsigned long
-search_exception_table(const struct cpu_user_regs *regs)
+search_exception_table(const struct cpu_user_regs *regs, unsigned long *stub_ra)
 {
     const struct virtual_region *region = find_text_region(regs->rip);
     unsigned long stub = this_cpu(stubs.addr);
 
     if ( region && region->ex )
+    {
+        *stub_ra = 0;
         return search_one_extable(region->ex, region->ex_end, regs->rip);
+    }
 
     if ( regs->rip >= stub + STUB_BUF_SIZE / 2 &&
          regs->rip < stub + STUB_BUF_SIZE &&
          regs->rsp > (unsigned long)regs &&
          regs->rsp < (unsigned long)get_cpu_info() )
     {
-        unsigned long retptr = *(unsigned long *)regs->rsp;
+        unsigned long retaddr = *(unsigned long *)regs->rsp, fixup;
 
-        region = find_text_region(retptr);
-        retptr = region && region->ex
-                 ? search_one_extable(region->ex, region->ex_end, retptr)
-                 : 0;
-        if ( retptr )
+        region = find_text_region(retaddr);
+        fixup = region && region->ex
+                ? search_one_extable(region->ex, region->ex_end, retaddr)
+                : 0;
+        if ( fixup )
         {
             /*
              * Put trap number and error code on the stack (in place of the
@@ -117,7 +120,8 @@ search_exception_table(const struct cpu_user_regs *regs)
             };
 
             *(unsigned long *)regs->rsp = token.raw;
-            return retptr;
+            *stub_ra = retaddr;
+            return fixup;
         }
     }
 
diff --git a/xen/arch/x86/include/asm/uaccess.h b/xen/arch/x86/include/asm/uaccess.h
index 684fccd95c..74bb222c03 100644
--- a/xen/arch/x86/include/asm/uaccess.h
+++ b/xen/arch/x86/include/asm/uaccess.h
@@ -421,7 +421,8 @@ union stub_exception_token {
     unsigned long raw;
 };
 
-extern unsigned long search_exception_table(const struct cpu_user_regs *regs);
+extern unsigned long search_exception_table(const struct cpu_user_regs *regs,
+                                            unsigned long *stub_ra);
 extern void sort_exception_tables(void);
 extern void sort_exception_table(struct exception_table_entry *start,
                                  const struct exception_table_entry *stop);
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index e1356f696a..45e1b277ea 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -845,7 +845,7 @@ void do_unhandled_trap(struct cpu_user_regs *regs)
 }
 
 static void fixup_exception_return(struct cpu_user_regs *regs,
-                                   unsigned long fixup)
+                                   unsigned long fixup, unsigned long stub_ra)
 {
     if ( IS_ENABLED(CONFIG_XEN_SHSTK) )
     {
@@ -862,7 +862,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
             /*
              * Search for %rip.  The shstk currently looks like this:
              *
-             *   ...  [Likely pointed to by SSP]
+             *   tok  [Supervisor token, == &tok | BUSY, only with FRED inactive]
+             *   ...  [Pointed to by SSP for most exceptions, empty in IST cases]
              *   %cs  [== regs->cs]
              *   %rip [== regs->rip]
              *   SSP  [Likely points to 3 slots higher, above %cs]
@@ -880,7 +881,56 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
              */
             if ( ptr[0] == regs->rip && ptr[1] == regs->cs )
             {
+                unsigned long primary_shstk =
+                    (ssp & ~(STACK_SIZE - 1)) +
+                    (PRIMARY_SHSTK_SLOT + 1) * PAGE_SIZE - 8;
+
                 wrss(fixup, ptr);
+
+                if ( !stub_ra )
+                    goto shstk_done;
+
+                /*
+                 * Stub recovery ought to happen only when the outer context
+                 * was on the main shadow stack.  We need to also "pop" the
+                 * stub's return address from the interrupted context's shadow
+                 * stack.  That is,
+                 * - if we're still on the main stack, we need to move the
+                 *   entire stack (up to and including the exception frame)
+                 *   up by one slot, incrementing the original SSP in the
+                 *   exception frame,
+                 * - if we're on an IST stack, we need to increment the
+                 *   original SSP.
+                 */
+                BUG_ON((ptr[-1] ^ primary_shstk) >> PAGE_SHIFT);
+
+                if ( (ssp ^ primary_shstk) >> PAGE_SHIFT )
+                {
+                    /*
+                     * We're on an IST stack.  First make sure the two return
+                     * addresses actually match.  Then increment the interrupted
+                     * context's SSP.
+                     */
+                    BUG_ON(stub_ra != *(unsigned long*)ptr[-1]);
+                    wrss(ptr[-1] + 8, &ptr[-1]);
+                    goto shstk_done;
+                }
+
+                /* Make sure the two return addresses actually match. */
+                BUG_ON(stub_ra != ptr[2]);
+
+                /* Move exception frame, updating SSP there. */
+                wrss(ptr[1], &ptr[2]); /* %cs */
+                wrss(ptr[0], &ptr[1]); /* %rip */
+                wrss(ptr[-1] + 8, &ptr[0]); /* SSP */
+
+                /* Move all newer entries. */
+                while ( --ptr != _p(ssp) )
+                    wrss(ptr[-1], &ptr[0]);
+
+                /* Finally account for our own stack having shifted up. */
+                asm volatile ( "incsspd %0" :: "r" (2) );
+
                 goto shstk_done;
             }
         }
@@ -901,7 +951,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
 
 static bool extable_fixup(struct cpu_user_regs *regs, bool print)
 {
-    unsigned long fixup = search_exception_table(regs);
+    unsigned long stub_ra = 0;
+    unsigned long fixup = search_exception_table(regs, &stub_ra);
 
     if ( unlikely(fixup == 0) )
         return false;
@@ -915,7 +966,7 @@ static bool extable_fixup(struct cpu_user_regs *regs, bool print)
                vector_name(regs->entry_vector), regs->error_code,
                _p(regs->rip), _p(regs->rip), _p(fixup));
 
-    fixup_exception_return(regs, fixup);
+    fixup_exception_return(regs, fixup, stub_ra);
     this_cpu(last_extable_addr) = regs->rip;
 
     return true;
@@ -1183,7 +1234,8 @@ void do_invalid_op(struct cpu_user_regs *regs)
     {
     case BUGFRAME_run_fn:
     case BUGFRAME_warn:
-        fixup_exception_return(regs, (unsigned long)eip);
+        fixup_exception_return(regs, (unsigned long)eip, 0);
+        fallthrough;
     case BUGFRAME_bug:
     case BUGFRAME_assert:
         return;
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:22:06 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:22:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686153.1067768 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexPI-0000Qm-R5; Tue, 27 Feb 2024 13:22:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686153.1067768; Tue, 27 Feb 2024 13:22:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexPI-0000Qc-Nn; Tue, 27 Feb 2024 13:22:04 +0000
Received: by outflank-mailman (input) for mailman id 686153;
 Tue, 27 Feb 2024 13:22:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexPI-0000QW-88
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexPI-0000Yk-3o
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexPI-0003RF-2r
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=I5fnFdM/KtmTPH6OvHC3iJ7Ses+FKhx7o/eFIgbrV+M=; b=4bC/f33fn6/1EViA3wgFicxyoK
	+cemsmQ+Z9lwyB8U4V8b/5QVRBK3cxDxWoAwME1U2tjefdMaf8GePh8yyRSytJuQnUhAQATdHQzpM
	aRk024ukGfwUUZp0Qfl7W++Ny7jYCXh0o/H7hMrxNJhDKg2+MjD8pgZRT+NbhNH3QTUI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.17] tools/xentop: fix sorting bug for some columns
Message-Id: <E1rexPI-0003RF-2r@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:22:04 +0000

commit 61da71968ea44964fd1dd2e449b053c77eb83139
Author:     Cyril Rébert (zithro) <slack@rabbit.lu>
AuthorDate: Tue Feb 27 14:06:53 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:06:53 2024 +0100

    tools/xentop: fix sorting bug for some columns
    
    Sort doesn't work on columns VBD_OO, VBD_RD, VBD_WR and VBD_RSECT.
    Fix by adjusting variables names in compare functions.
    Bug fix only. No functional change.
    
    Fixes: 91c3e3dc91d6 ("tools/xentop: Display '-' when stats are not available.")
    Signed-off-by: Cyril Rébert (zithro) <slack@rabbit.lu>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    master commit: 29f17d837421f13c0e0010802de1b2d51d2ded4a
    master date: 2024-02-05 17:58:23 +0000
---
 tools/xentop/xentop.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/xentop/xentop.c b/tools/xentop/xentop.c
index 950e8935c4..545bd5e96d 100644
--- a/tools/xentop/xentop.c
+++ b/tools/xentop/xentop.c
@@ -684,7 +684,7 @@ static int compare_vbd_oo(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_oo = 0, dom2_vbd_oo = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_OO, &dom1_vbd_oo);
-	tot_vbd_reqs(domain1, FIELD_VBD_OO, &dom2_vbd_oo);
+	tot_vbd_reqs(domain2, FIELD_VBD_OO, &dom2_vbd_oo);
 
 	return -compare(dom1_vbd_oo, dom2_vbd_oo);
 }
@@ -711,9 +711,9 @@ static int compare_vbd_rd(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_rd = 0, dom2_vbd_rd = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_RD, &dom1_vbd_rd);
-	tot_vbd_reqs(domain1, FIELD_VBD_RD, &dom2_vbd_rd);
+	tot_vbd_reqs(domain2, FIELD_VBD_RD, &dom2_vbd_rd);
 
-	return -compare(dom1_vbd_rd, dom1_vbd_rd);
+	return -compare(dom1_vbd_rd, dom2_vbd_rd);
 }
 
 /* Prints number of total VBD READ requests statistic */
@@ -738,7 +738,7 @@ static int compare_vbd_wr(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_wr = 0, dom2_vbd_wr = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_WR, &dom1_vbd_wr);
-	tot_vbd_reqs(domain1, FIELD_VBD_WR, &dom2_vbd_wr);
+	tot_vbd_reqs(domain2, FIELD_VBD_WR, &dom2_vbd_wr);
 
 	return -compare(dom1_vbd_wr, dom2_vbd_wr);
 }
@@ -765,7 +765,7 @@ static int compare_vbd_rsect(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_rsect = 0, dom2_vbd_rsect = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_RSECT, &dom1_vbd_rsect);
-	tot_vbd_reqs(domain1, FIELD_VBD_RSECT, &dom2_vbd_rsect);
+	tot_vbd_reqs(domain2, FIELD_VBD_RSECT, &dom2_vbd_rsect);
 
 	return -compare(dom1_vbd_rsect, dom2_vbd_rsect);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:22:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:22:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686154.1067771 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexPS-0000TV-TM; Tue, 27 Feb 2024 13:22:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686154.1067771; Tue, 27 Feb 2024 13:22:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexPS-0000TN-Qa; Tue, 27 Feb 2024 13:22:14 +0000
Received: by outflank-mailman (input) for mailman id 686154;
 Tue, 27 Feb 2024 13:22:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexPS-0000TH-9U
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexPS-0000Ys-6v
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexPS-0003Ti-5z
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=mkxN3ZuAyqGBbhyXCZ4FaUJKjDPy3LipPoytm7+Hd3k=; b=XxAbvOGvPrzI2Pq6u02vtZkfEd
	LsIsws6uWUMsul8FLOq1ZaWstl1NYv5Sk/Q4z/sie3V2JU31A7KvsqPa4GwdYEFNM6VRunbx0I6Fh
	qIQTMn7xWbP63xNQNv1iMFkqcl1RZcwekF3MMBy4+i1idBvelBZOvsmzS7C4xUZ/y8BE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.17] amd-vi: fix IVMD memory type checks
Message-Id: <E1rexPS-0003Ti-5z@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:22:14 +0000

commit 463aaf3fbf62d24e898ae0c2ba53d85ca0f94d3f
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 14:07:12 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:07:12 2024 +0100

    amd-vi: fix IVMD memory type checks
    
    The current code that parses the IVMD blocks is relaxed with regard to the
    restriction that such unity regions should always fall into memory ranges
    marked as reserved in the memory map.
    
    However the type checks for the IVMD addresses are inverted, and as a result
    IVMD ranges falling into RAM areas are accepted.  Note that having such ranges
    in the first place is a firmware bug, as IVMD should always fall into reserved
    ranges.
    
    Fixes: ed6c77ebf0c1 ('AMD/IOMMU: check / convert IVMD ranges for being / to be reserved')
    Reported-by: Ox <oxjo@proton.me>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Tested-by: oxjo <oxjo@proton.me>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: 83afa313583019d9f159c122cecf867735d27ec5
    master date: 2024-02-06 11:56:13 +0100
---
 xen/drivers/passthrough/amd/iommu_acpi.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_acpi.c b/xen/drivers/passthrough/amd/iommu_acpi.c
index 3b577c9b39..3a7045c39b 100644
--- a/xen/drivers/passthrough/amd/iommu_acpi.c
+++ b/xen/drivers/passthrough/amd/iommu_acpi.c
@@ -426,9 +426,14 @@ static int __init parse_ivmd_block(const struct acpi_ivrs_memory *ivmd_block)
                 return -EIO;
             }
 
-            /* Types which won't be handed out are considered good enough. */
-            if ( !(type & (RAM_TYPE_RESERVED | RAM_TYPE_ACPI |
-                           RAM_TYPE_UNUSABLE)) )
+            /*
+             * Types which aren't RAM are considered good enough.
+             * Note that a page being partially RESERVED, ACPI or UNUSABLE will
+             * force Xen into assuming the whole page as having that type in
+             * practice.
+             */
+            if ( type & (RAM_TYPE_RESERVED | RAM_TYPE_ACPI |
+                         RAM_TYPE_UNUSABLE) )
                 continue;
 
             AMD_IOMMU_ERROR("IVMD: page at %lx can't be converted\n", addr);
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:22:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:22:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686155.1067775 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexPc-0000W6-Uo; Tue, 27 Feb 2024 13:22:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686155.1067775; Tue, 27 Feb 2024 13:22:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexPc-0000Vz-S4; Tue, 27 Feb 2024 13:22:24 +0000
Received: by outflank-mailman (input) for mailman id 686155;
 Tue, 27 Feb 2024 13:22:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexPc-0000Vm-C9
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexPc-0000ZK-A8
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexPc-0003UJ-9B
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:24 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=keh4vrfXPucH3ngA8WH3a9M9LN5tu6RVynS2/UL4znc=; b=nA9klftWpJpX6XHMBtHaN602Kj
	8I84zgYILqEvoR+4yT2pqgL/AamwQ9PwtC6Yx9JjR9cykcitSAoydoSd6DH4gUntTyyU3VuAix1r7
	pI9LF4mYMK2efYVTnV4vj7GMNAH69kzW/NAryHr1ZyogpeJ68yhv2q1ZTbkTb6+BIeRg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.17] x86/hvm: Fix fast singlestep state persistence
Message-Id: <E1rexPc-0003UJ-9B@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:22:24 +0000

commit 415f770d23f9fcbc02436560fa6583dcd8e1343f
Author:     Petr Beneš <w1benny@gmail.com>
AuthorDate: Tue Feb 27 14:07:45 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:07:45 2024 +0100

    x86/hvm: Fix fast singlestep state persistence
    
    This patch addresses an issue where the fast singlestep setting would persist
    despite xc_domain_debug_control being called with XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF.
    Specifically, if fast singlestep was enabled in a VMI session and that session
    stopped before the MTF trap occurred, the fast singlestep setting remained
    active even though MTF itself was disabled.  This led to a situation where, upon
    starting a new VMI session, the first event to trigger an EPT violation would
    cause the corresponding EPT event callback to be skipped due to the lingering
    fast singlestep setting.
    
    The fix ensures that the fast singlestep setting is properly reset when
    disabling single step debugging operations.
    
    Signed-off-by: Petr Beneš <w1benny@gmail.com>
    Reviewed-by: Tamas K Lengyel <tamas@tklengyel.com>
    master commit: 897def94b56175ce569673a05909d2f223e1e749
    master date: 2024-02-12 09:37:58 +0100
---
 xen/arch/x86/hvm/hvm.c | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index d6c6ab8897..558dc3eddc 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -5153,26 +5153,40 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
 
 int hvm_debug_op(struct vcpu *v, int32_t op)
 {
-    int rc;
+    int rc = 0;
 
     switch ( op )
     {
         case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON:
         case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF:
-            rc = -EOPNOTSUPP;
             if ( !cpu_has_monitor_trap_flag )
-                break;
-            rc = 0;
-            vcpu_pause(v);
-            v->arch.hvm.single_step =
-                (op == XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON);
-            vcpu_unpause(v); /* guest will latch new state */
+                return -EOPNOTSUPP;
             break;
         default:
-            rc = -ENOSYS;
-            break;
+            return -ENOSYS;
+    }
+
+    vcpu_pause(v);
+
+    switch ( op )
+    {
+    case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON:
+        v->arch.hvm.single_step = true;
+        break;
+
+    case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF:
+        v->arch.hvm.single_step = false;
+        v->arch.hvm.fast_single_step.enabled = false;
+        v->arch.hvm.fast_single_step.p2midx = 0;
+        break;
+
+    default: /* Excluded above */
+        ASSERT_UNREACHABLE();
+        return -ENOSYS;
     }
 
+    vcpu_unpause(v); /* guest will latch new state */
+
     return rc;
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:22:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:22:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686156.1067779 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexPm-0000Yc-W4; Tue, 27 Feb 2024 13:22:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686156.1067779; Tue, 27 Feb 2024 13:22:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexPm-0000YT-TZ; Tue, 27 Feb 2024 13:22:34 +0000
Received: by outflank-mailman (input) for mailman id 686156;
 Tue, 27 Feb 2024 13:22:34 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexPm-0000YN-E0
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexPm-0000ZX-D8
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexPm-0003Uk-CI
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:34 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=jREnQzr9InwLhjwdy7j7dA03Pe3FhjRTNWby2V49uCE=; b=miFnnEfhCY/VNoCeTOiX68lpz9
	nsGNAr7HphzjtYG1saMSju+MhgE7ExXSqGlH9yk6FcaspQQpgUyYzPM17aTmu6kbBarew/0qxjH/D
	k5+XhCPG2kndQ4H8mjpdONqgJxWpnz4DgIaOb6/PfsMXO32TOBKPNygXWX5l+ds1djzg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.17] x86/HVM: tidy state on hvmemul_map_linear_addr()'s error path
Message-Id: <E1rexPm-0003Uk-CI@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:22:34 +0000

commit b3ae0e6201495216b12157bd8b2382b28fdd7dae
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 14:08:20 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:08:20 2024 +0100

    x86/HVM: tidy state on hvmemul_map_linear_addr()'s error path
    
    While in the vast majority of cases failure of the function will not
    be followed by re-invocation with the same emulation context, a few
    very specific insns - involving multiple independent writes, e.g. ENTER
    and PUSHA - exist where this can happen. Since failure of the function
    only signals to the caller that it ought to try an MMIO write instead,
    such failure also cannot be assumed to result in wholesale failure of
    emulation of the current insn. Instead we have to maintain internal
    state such that another invocation of the function with the same
    emulation context remains possible. To achieve that we need to reset MFN
    slots after putting page references on the error path.
    
    Note that all of this affects debugging code only, in causing an
    assertion to trigger (higher up in the function). There's otherwise no
    misbehavior - such a "leftover" slot would simply be overwritten by new
    contents in a release build.
    
    Also extend the related unmap() assertion, to further check for MFN 0.
    
    Fixes: 8cbd4fb0b7ea ("x86/hvm: implement hvmemul_write() using real mappings")
    Reported-by: Manuel Andreas <manuel.andreas@tum.de>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Paul Durrant <paul@xen.org>
    master commit: e72f951df407bc3be82faac64d8733a270036ba1
    master date: 2024-02-13 09:36:14 +0100
---
 xen/arch/x86/hvm/emulate.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 275451dd36..27928dc3f3 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -697,7 +697,12 @@ static void *hvmemul_map_linear_addr(
  out:
     /* Drop all held references. */
     while ( mfn-- > hvmemul_ctxt->mfn )
+    {
         put_page(mfn_to_page(*mfn));
+#ifndef NDEBUG /* Clean slot for a subsequent map()'s error checking. */
+        *mfn = _mfn(0);
+#endif
+    }
 
     return err;
 }
@@ -719,7 +724,7 @@ static void hvmemul_unmap_linear_addr(
 
     for ( i = 0; i < nr_frames; i++ )
     {
-        ASSERT(mfn_valid(*mfn));
+        ASSERT(mfn_x(*mfn) && mfn_valid(*mfn));
         paging_mark_dirty(currd, *mfn);
         put_page(mfn_to_page(*mfn));
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:22:46 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:22:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686157.1067783 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexPy-0000bA-1U; Tue, 27 Feb 2024 13:22:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686157.1067783; Tue, 27 Feb 2024 13:22:46 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexPx-0000b2-V6; Tue, 27 Feb 2024 13:22:45 +0000
Received: by outflank-mailman (input) for mailman id 686157;
 Tue, 27 Feb 2024 13:22:44 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexPw-0000as-Gr
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:44 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexPw-0000Ze-G1
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:44 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexPw-0003VZ-FF
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:44 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=NXq/oSOUAFA20zWO7YtiQfZK7CM7G1RfRnRDkKBtB/k=; b=I945Un5md9jfy1mP/wL/CFViqn
	oIcIB57qLbnbCj2FCzue0eMsRNPh+ennngITj0sgJDaki3gMjqAJzg33ZfByvIdsqziCChIS+2eeq
	zCyIjngB2UYqvn8bEXeClhjMk0cLkDMJn9qoqnX8/tWaCwav6MDnuEl3SB6c/THCrOgU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.17] build: Replace `which` with `command -v`
Message-Id: <E1rexPw-0003VZ-FF@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:22:44 +0000

commit 1330a5fe44ca91f98857b53fe8bbe06522d9db27
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Tue Feb 27 14:08:50 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:08:50 2024 +0100

    build: Replace `which` with `command -v`
    
    The `which` command is not standard, may not exist on the build host,
    or may not behave as expected by the build system. It is recommended
    to use `command -v` to find out if a command exist and have its path,
    and it's part of a POSIX shell standard (at least, it seems to be
    mandatory since IEEE Std 1003.1-2008, but was optional before).
    
    Fixes: c8a8645f1efe ("xen/build: Automatically locate a suitable python interpreter")
    Fixes: 3b47bcdb6d38 ("xen/build: Use a distro version of figlet")
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Tested-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: f93629b18b528a5ab1b1092949c5420069c7226c
    master date: 2024-02-19 12:45:48 +0100
---
 xen/Makefile | 4 ++--
 xen/build.mk | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/Makefile b/xen/Makefile
index dd0b004e1c..7ea13a6791 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -25,8 +25,8 @@ export XEN_BUILD_HOST	:= $(shell hostname)
 endif
 
 # Best effort attempt to find a python interpreter, defaulting to Python 3 if
-# available.  Fall back to just `python` if `which` is nowhere to be found.
-PYTHON_INTERPRETER	:= $(word 1,$(shell which python3 python python2 2>/dev/null) python)
+# available.  Fall back to just `python`.
+PYTHON_INTERPRETER	:= $(word 1,$(shell command -v python3 || command -v python || command -v python2) python)
 export PYTHON		?= $(PYTHON_INTERPRETER)
 
 export CHECKPOLICY	?= checkpolicy
diff --git a/xen/build.mk b/xen/build.mk
index 9ecb104f1e..b489f77b7c 100644
--- a/xen/build.mk
+++ b/xen/build.mk
@@ -1,6 +1,6 @@
 quiet_cmd_banner = BANNER  $@
 define cmd_banner
-    if which figlet >/dev/null 2>&1 ; then \
+    if command -v figlet >/dev/null 2>&1 ; then \
 	echo " Xen $(XEN_FULLVERSION)" | figlet -f $< > $@.tmp; \
     else \
 	echo " Xen $(XEN_FULLVERSION)" > $@.tmp; \
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:22:56 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:22:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686158.1067787 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexQ8-0000eD-2z; Tue, 27 Feb 2024 13:22:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686158.1067787; Tue, 27 Feb 2024 13:22:56 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexQ8-0000e5-0L; Tue, 27 Feb 2024 13:22:56 +0000
Received: by outflank-mailman (input) for mailman id 686158;
 Tue, 27 Feb 2024 13:22:54 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQ6-0000di-Jt
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:54 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQ6-0000Zo-J9
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:54 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQ6-0003W1-IF
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:22:54 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=jQxfVH3Js0p88CYA2d3cQToCbhLzwE19ywAkEIj78Uw=; b=D7uavIUm+tTXxG7hWDCQAZacgz
	HEzc2O+Voz6lBQpf7RthPHbdLISGf4cYn7CIZTciFZmUuC9lUU5r7zCWio1p3r6t4dsxrZfCtI60d
	Fimkn/MNvoV3nNDL01ku5ZBf2zhXKfW+QnOfuTFEJ0H+nHB8JBHnyrKLRhM4yD3il0pg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.17] libxl: Disable relocating memory for qemu-xen in stubdomain too
Message-Id: <E1rexQ6-0003W1-IF@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:22:54 +0000

commit b9745280736ee526374873aa3c4142596e2ba10b
Author:     Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
AuthorDate: Tue Feb 27 14:09:19 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:09:19 2024 +0100

    libxl: Disable relocating memory for qemu-xen in stubdomain too
    
    According to comments (and experiments) qemu-xen cannot handle memory
    reolcation done by hvmloader. The code was already disabled when running
    qemu-xen in dom0 (see libxl__spawn_local_dm()), but it was missed when
    adding qemu-xen support to stubdomain. Adjust libxl__spawn_stub_dm() to
    be consistent in this regard.
    
    Reported-by: Neowutran <xen@neowutran.ovh>
    Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    master commit: 97883aa269f6745a6ded232be3a855abb1297e0d
    master date: 2024-02-22 11:48:22 +0100
---
 tools/libs/light/libxl_dm.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
index 14b593110f..ed620a9d8e 100644
--- a/tools/libs/light/libxl_dm.c
+++ b/tools/libs/light/libxl_dm.c
@@ -2432,6 +2432,16 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
                         "%s",
                         libxl_bios_type_to_string(guest_config->b_info.u.hvm.bios));
     }
+    /* Disable relocating memory to make the MMIO hole larger
+     * unless we're running qemu-traditional and vNUMA is not
+     * configured. */
+    libxl__xs_printf(gc, XBT_NULL,
+                     libxl__sprintf(gc, "%s/hvmloader/allow-memory-relocate",
+                                    libxl__xs_get_dompath(gc, guest_domid)),
+                     "%d",
+                     guest_config->b_info.device_model_version
+                        == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL &&
+                     !libxl__vnuma_configured(&guest_config->b_info));
     ret = xc_domain_set_target(ctx->xch, dm_domid, guest_domid);
     if (ret<0) {
         LOGED(ERROR, guest_domid, "setting target domain %d -> %d",
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:23:06 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:23:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686159.1067790 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexQI-0000h5-4K; Tue, 27 Feb 2024 13:23:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686159.1067790; Tue, 27 Feb 2024 13:23:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexQI-0000gx-1m; Tue, 27 Feb 2024 13:23:06 +0000
Received: by outflank-mailman (input) for mailman id 686159;
 Tue, 27 Feb 2024 13:23:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQG-0000gn-Mb
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQG-0000aB-Lp
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQG-0003Wd-LD
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=phddro2Oth4yV4LuVGSYcjczttaFobvrA/19FkU3ClE=; b=5+YF4l1KHm5xxPuTAvwbHkFR5z
	uRvIFPvH333q7vvcYaAd3nVvrVCgiy9xAeJUDDDpxL2bjM48NPD4lKChNgDH/+AhcY5UAw3L4RA/o
	s3/5bNojOWJbst+iZmcB1IXuXj/6RyiPiwRC+Xh1oCE3HsCmhWIvFP5KrQSsYoRxiWjw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.17] build: make sure build fails when running kconfig fails
Message-Id: <E1rexQG-0003Wd-LD@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:23:04 +0000

commit ea869977271f93945451908be9b6117ffd1fb02d
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 14:09:37 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:09:37 2024 +0100

    build: make sure build fails when running kconfig fails
    
    Because of using "-include", failure to (re)build auto.conf (with
    auto.conf.cmd produced as a secondary target) won't stop make from
    continuing the build. Arrange for it being possible to drop the - from
    Rules.mk, requiring that the include be skipped for tools-only targets.
    Note that relying on the inclusion in those cases wouldn't be correct
    anyway, as it might be a stale file (yet to be rebuilt) which would be
    included, while during initial build, the file would be absent
    altogether.
    
    Fixes: 8d4c17a90b0a ("xen/build: silence make warnings about missing auto.conf*")
    Reported-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    master commit: d34e5fa2e8db19f23081f46a3e710bb122130691
    master date: 2024-02-22 11:52:47 +0100
---
 xen/Makefile | 1 +
 xen/Rules.mk | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/xen/Makefile b/xen/Makefile
index 7ea13a6791..bac3684a36 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -374,6 +374,7 @@ $(KCONFIG_CONFIG): tools_fixdep
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
+	$(Q)rm -f include/config/auto.conf
 	$(Q)$(MAKE) $(build)=tools/kconfig syncconfig
 
 ifeq ($(CONFIG_DEBUG),y)
diff --git a/xen/Rules.mk b/xen/Rules.mk
index 8af3dd7277..d759cccee3 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -15,7 +15,9 @@ srcdir := $(srctree)/$(src)
 PHONY := __build
 __build:
 
--include $(objtree)/include/config/auto.conf
+ifneq ($(firstword $(subst /, ,$(obj))),tools)
+include $(objtree)/include/config/auto.conf
+endif
 
 include $(XEN_ROOT)/Config.mk
 include $(srctree)/scripts/Kbuild.include
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:23:16 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:23:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686160.1067795 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexQS-0000kg-6Y; Tue, 27 Feb 2024 13:23:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686160.1067795; Tue, 27 Feb 2024 13:23:16 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexQS-0000kZ-3F; Tue, 27 Feb 2024 13:23:16 +0000
Received: by outflank-mailman (input) for mailman id 686160;
 Tue, 27 Feb 2024 13:23:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQQ-0000j6-Q4
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQQ-0000aL-PL
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQQ-0003XQ-OR
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=GpDuKMowioABqg4DXYzHBbGGD0WUdlVCL1D1Ega4Nic=; b=3/KMKPohoPGyNDW85dt4BGRZXh
	6jt27btlqNcg80GfPA07fZvd4ki2oidxC41d/Ik9AMBaCXvKHWJtkyvDF80tFJD2bP2PL+6WL7ZnZ
	IdE6rBG+ukrLG331UZkieDoX/tJJElX0bq7mLig2sGTgldfY9i3CYIyARkQrhPP/Sfkc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.17] x86emul: add missing EVEX.R' checks
Message-Id: <E1rexQQ-0003XQ-OR@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:23:14 +0000

commit 16f2e47eb1207d866f95cf694a60a7ceb8f96a36
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 14:09:55 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:09:55 2024 +0100

    x86emul: add missing EVEX.R' checks
    
    EVEX.R' is not ignored in 64-bit code when encoding a GPR or mask
    register. While for mask registers suitable checks are in place (there
    also covering EVEX.R), they were missing for the few cases where in
    EVEX-encoded instructions ModR/M.reg encodes a GPR. While for VPEXTRW
    the bit is replaced before an emulation stub is invoked, for
    VCVT{,T}{S,D,H}2{,U}SI this actually would have led to #UD from inside
    an emulation stub, in turn raising #UD to the guest, but accompanied by
    log messages indicating something's wrong in Xen nevertheless.
    
    Fixes: 001bd91ad864 ("x86emul: support AVX512{F,BW,DQ} extract insns")
    Fixes: baf4a376f550 ("x86emul: support AVX512F legacy-equivalent scalar int/FP conversion insns")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: cb319824bfa8d3c9ea0410cc71daaedc3e11aa2a
    master date: 2024-02-22 11:54:07 +0100
---
 xen/arch/x86/x86_emulate/x86_emulate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index 0c0336f737..995670cbc8 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -6829,7 +6829,8 @@ x86_emulate(
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x2d): /* vcvts{s,d}2si xmm/mem,reg */
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x78): /* vcvtts{s,d}2usi xmm/mem,reg */
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x79): /* vcvts{s,d}2usi xmm/mem,reg */
-        generate_exception_if((evex.reg != 0xf || !evex.RX || evex.opmsk ||
+        generate_exception_if((evex.reg != 0xf || !evex.RX || !evex.R ||
+                               evex.opmsk ||
                                (ea.type != OP_REG && evex.brs)),
                               EXC_UD);
         host_and_vcpu_must_have(avx512f);
@@ -10705,7 +10706,7 @@ x86_emulate(
         goto pextr;
 
     case X86EMUL_OPC_EVEX_66(0x0f, 0xc5):   /* vpextrw $imm8,xmm,reg */
-        generate_exception_if(ea.type != OP_REG, EXC_UD);
+        generate_exception_if(ea.type != OP_REG || !evex.R, EXC_UD);
         /* Convert to alternative encoding: We want to use a memory operand. */
         evex.opcx = ext_0f3a;
         b = 0x15;
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:23:26 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:23:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686161.1067799 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexQc-0000ny-90; Tue, 27 Feb 2024 13:23:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686161.1067799; Tue, 27 Feb 2024 13:23:26 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexQc-0000nq-6M; Tue, 27 Feb 2024 13:23:26 +0000
Received: by outflank-mailman (input) for mailman id 686161;
 Tue, 27 Feb 2024 13:23:25 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQa-0000ne-Uq
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQa-0000an-U2
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQa-0003Xr-RY
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:24 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=50JgR6vDEy2qIpLByIIX+76wr9ypQP6AjbE7HxegXoQ=; b=DicZB8K2IBVfyuzD6WTJWM2y7+
	7WQx4jA9fQAlMWz7R9iHcXBPkZ1k01OUfAwmfDtd6VGGN3ldQenQL4eES3ZKJ2V3hcD6pyyxiRaCn
	88navgM2oX7F0h2pa/E8SPvV8q7UJkN9kZxnsIsBgG9TMBtKJRA19Af1FExmeuRXYQSQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.17] xen/livepatch: fix norevert test hook setup typo
Message-Id: <E1rexQa-0003Xr-RY@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:23:24 +0000

commit f6b12792542e372f36a71ea4c2563e6dd6e4fa57
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 14:10:24 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:10:24 2024 +0100

    xen/livepatch: fix norevert test hook setup typo
    
    The test code has a typo in using LIVEPATCH_APPLY_HOOK() instead of
    LIVEPATCH_REVERT_HOOK().
    
    Fixes: 6047104c3ccc ('livepatch: Add per-function applied/reverted state tracking marker')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
    master commit: f0622dd4fd6ae6ddb523a45d89ed9b8f3a9a8f36
    master date: 2024-02-26 10:13:46 +0100
---
 xen/test/livepatch/xen_action_hooks_norevert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/test/livepatch/xen_action_hooks_norevert.c b/xen/test/livepatch/xen_action_hooks_norevert.c
index 3e21ade6ab..c173855192 100644
--- a/xen/test/livepatch/xen_action_hooks_norevert.c
+++ b/xen/test/livepatch/xen_action_hooks_norevert.c
@@ -120,7 +120,7 @@ static void post_revert_hook(livepatch_payload_t *payload)
     printk(KERN_DEBUG "%s: Hook done.\n", __func__);
 }
 
-LIVEPATCH_APPLY_HOOK(revert_hook);
+LIVEPATCH_REVERT_HOOK(revert_hook);
 
 LIVEPATCH_PREAPPLY_HOOK(pre_apply_hook);
 LIVEPATCH_POSTAPPLY_HOOK(post_apply_hook);
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:23:36 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:23:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686162.1067802 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexQm-0000rF-AI; Tue, 27 Feb 2024 13:23:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686162.1067802; Tue, 27 Feb 2024 13:23:36 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexQm-0000r7-7l; Tue, 27 Feb 2024 13:23:36 +0000
Received: by outflank-mailman (input) for mailman id 686162;
 Tue, 27 Feb 2024 13:23:35 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQl-0000qr-1Q
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:35 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQl-0000ax-0i
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:35 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQk-0003YI-W9
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:34 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=sMY6XHaQ7+4xdN1j6hedGCK2+iJdB1eNrSYjlFn1JdQ=; b=BLauEs7bLetBBqNXsEdJehyw0j
	9laRztQTfxLeFXi50i/3nkKq4bYLNnc5iIuFxANFdJawK6JiXkqRTzgnFd01qDCkJjRdGQYpoaEGI
	ey2q2D8P1lxoMPl3KT9tB/NCiL619h2ODHETfvfu2NU8FidbMSikKA2gFtrJeOKQULF4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.17] xen/cmdline: fix printf format specifier in no_config_param()
Message-Id: <E1rexQk-0003YI-W9@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:23:34 +0000

commit 229e8a72ee4cde5698aaf42cc59ae57446dce60f
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 14:10:39 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:10:39 2024 +0100

    xen/cmdline: fix printf format specifier in no_config_param()
    
    '*' sets the width field, which is the minimum number of characters to output,
    but what we want in no_config_param() is the precision instead, which is '.*'
    as it imposes a maximum limit on the output.
    
    Fixes: 68d757df8dd2 ('x86/pv: Options to disable and/or compile out 32bit PV support')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: ef101f525173cf51dc70f4c77862f6f10a8ddccf
    master date: 2024-02-26 10:17:40 +0100
---
 xen/include/xen/param.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/include/xen/param.h b/xen/include/xen/param.h
index 93c3fe7cb7..e02e49635c 100644
--- a/xen/include/xen/param.h
+++ b/xen/include/xen/param.h
@@ -191,7 +191,7 @@ static inline void no_config_param(const char *cfg, const char *param,
 {
     int len = e ? ({ ASSERT(e >= s); e - s; }) : strlen(s);
 
-    printk(XENLOG_INFO "CONFIG_%s disabled - ignoring '%s=%*s' setting\n",
+    printk(XENLOG_INFO "CONFIG_%s disabled - ignoring '%s=%.*s' setting\n",
            cfg, param, len, s);
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:23:46 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:23:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686163.1067806 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexQw-0000uF-Bx; Tue, 27 Feb 2024 13:23:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686163.1067806; Tue, 27 Feb 2024 13:23:46 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexQw-0000u7-9C; Tue, 27 Feb 2024 13:23:46 +0000
Received: by outflank-mailman (input) for mailman id 686163;
 Tue, 27 Feb 2024 13:23:45 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQv-0000tx-4J
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:45 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQv-0000b4-3Y
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:45 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexQv-0003Yj-2p
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:45 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=FtBtLpjgMoSC1NR/OLbfgTnQGV0OCyamj5nqL0+2YKk=; b=tn/CRgdERNPFjxPblKTmupRWi0
	fhreEzRa9a9VLR5tSzQauPCFx3kFSrKLNsXeW2gZaqMwN/ik4rrv0dPs182AodN6vEeN5tsR8mFrq
	vlG95hgprqwg+dOMhE88D/mk3dchgAAeA3U3Q+qJJSJaDnvvAHxzsTjQpMydxRdB02qw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.17] x86/altcall: use a union as register type for function parameters on clang
Message-Id: <E1rexQv-0003Yj-2p@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:23:45 +0000

commit 1aafe054e7d1efbf8e8482a9cdd4be5753b79e2f
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 14:11:04 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:11:04 2024 +0100

    x86/altcall: use a union as register type for function parameters on clang
    
    The current code for alternative calls uses the caller parameter types as the
    types for the register variables that serve as function parameters:
    
    uint8_t foo;
    [...]
    alternative_call(myfunc, foo);
    
    Would expand roughly into:
    
    register unint8_t a1_ asm("rdi") = foo;
    register unsigned long a2_ asm("rsi");
    [...]
    asm volatile ("call *%c[addr](%%rip)"...);
    
    However with -O2 clang will generate incorrect code, given the following
    example:
    
    unsigned int func(uint8_t t)
    {
        return t;
    }
    
    static void bar(uint8_t b)
    {
        int ret_;
        register uint8_t di asm("rdi") = b;
        register unsigned long si asm("rsi");
        register unsigned long dx asm("rdx");
        register unsigned long cx asm("rcx");
        register unsigned long r8 asm("r8");
        register unsigned long r9 asm("r9");
        register unsigned long r10 asm("r10");
        register unsigned long r11 asm("r11");
    
        asm volatile ( "call %c[addr]"
                       : "+r" (di), "=r" (si), "=r" (dx),
                         "=r" (cx), "=r" (r8), "=r" (r9),
                         "=r" (r10), "=r" (r11), "=a" (ret_)
                       : [addr] "i" (&(func)), "g" (func)
                       : "memory" );
    }
    
    void foo(unsigned int a)
    {
        bar(a);
    }
    
    Clang generates the following assembly code:
    
    func:                                   # @func
            movl    %edi, %eax
            retq
    foo:                                    # @foo
            callq   func
            retq
    
    Note the truncation of the unsigned int parameter 'a' of foo() to uint8_t when
    passed into bar() is lost.  clang doesn't zero extend the parameters in the
    callee when required, as the psABI mandates.
    
    The above can be worked around by using a union when defining the register
    variables, so that `di` becomes:
    
    register union {
        uint8_t e;
        unsigned long r;
    } di asm("rdi") = { .e = b };
    
    Which results in following code generated for `foo()`:
    
    foo:                                    # @foo
            movzbl  %dil, %edi
            callq   func
            retq
    
    So the truncation is not longer lost.  Apply such workaround only when built
    with clang.
    
    Reported-by: Matthew Grooms <mgrooms@shrew.net>
    Link: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277200
    Link: https://github.com/llvm/llvm-project/issues/12579
    Link: https://github.com/llvm/llvm-project/issues/82598
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    master commit: 2ce562b2a413cbdb2e1128989ed1722290a27c4e
    master date: 2024-02-26 10:18:01 +0100
---
 xen/arch/x86/include/asm/alternative.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/xen/arch/x86/include/asm/alternative.h b/xen/arch/x86/include/asm/alternative.h
index a7a82c2c03..bcb1dc94f4 100644
--- a/xen/arch/x86/include/asm/alternative.h
+++ b/xen/arch/x86/include/asm/alternative.h
@@ -167,9 +167,34 @@ extern void alternative_branches(void);
 #define ALT_CALL_arg5 "r8"
 #define ALT_CALL_arg6 "r9"
 
+#ifdef CONFIG_CC_IS_CLANG
+/*
+ * Use a union with an unsigned long in order to prevent clang from
+ * skipping a possible truncation of the value.  By using the union any
+ * truncation is carried before the call instruction, in turn covering
+ * for ABI-non-compliance in that the necessary clipping / extension of
+ * the value is supposed to be carried out in the callee.
+ *
+ * Note this behavior is not mandated by the standard, and hence could
+ * stop being a viable workaround, or worse, could cause a different set
+ * of code-generation issues in future clang versions.
+ *
+ * This has been reported upstream:
+ * https://github.com/llvm/llvm-project/issues/12579
+ * https://github.com/llvm/llvm-project/issues/82598
+ */
+#define ALT_CALL_ARG(arg, n)                                            \
+    register union {                                                    \
+        typeof(arg) e;                                                  \
+        unsigned long r;                                                \
+    } a ## n ## _ asm ( ALT_CALL_arg ## n ) = {                         \
+        .e = ({ BUILD_BUG_ON(sizeof(arg) > sizeof(void *)); (arg); })   \
+    }
+#else
 #define ALT_CALL_ARG(arg, n) \
     register typeof(arg) a ## n ## _ asm ( ALT_CALL_arg ## n ) = \
         ({ BUILD_BUG_ON(sizeof(arg) > sizeof(void *)); (arg); })
+#endif
 #define ALT_CALL_NO_ARG(n) \
     register unsigned long a ## n ## _ asm ( ALT_CALL_arg ## n )
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:23:56 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:23:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686164.1067811 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexR6-0000wr-DX; Tue, 27 Feb 2024 13:23:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686164.1067811; Tue, 27 Feb 2024 13:23:56 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexR6-0000wj-Ao; Tue, 27 Feb 2024 13:23:56 +0000
Received: by outflank-mailman (input) for mailman id 686164;
 Tue, 27 Feb 2024 13:23:55 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexR5-0000wX-7I
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:55 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexR5-0000bC-6T
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:55 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexR5-0003Z8-5j
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:23:55 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=kbXcd2HaDLthtyv/AfrWSWTcHl94feYp2Sry2oExEvs=; b=xZGJm77FTZCW/wa6HwQa5zFdRy
	73Cuc5/dtUzzAIXWfK7PTMmfqgHoyoAVi9QEvRITpLaNJunCHDm+5+LkBDDbZWUampRU9njFg2pkW
	CG5hJyzs19KwMcvMiq4O4mciVToK9y6/Gt/5ATtTVch0nzFco3N1mr8t6RWOn0/Ii8X8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.17] x86/spec: fix BRANCH_HARDEN option to only be set when build-enabled
Message-Id: <E1rexR5-0003Z8-5j@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:23:55 +0000

commit 91650010815f3da0834bc9781c4359350d1162a5
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 14:11:40 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:11:40 2024 +0100

    x86/spec: fix BRANCH_HARDEN option to only be set when build-enabled
    
    The current logic to handle the BRANCH_HARDEN option will report it as enabled
    even when build-time disabled. Fix this by only allowing the option to be set
    when support for it is built into Xen.
    
    Fixes: 2d6f36daa086 ('x86/nospec: Introduce CONFIG_SPECULATIVE_HARDEN_BRANCH')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: 60e00f77a5cc671d30c5ef3318f5b8e9b74e4aa3
    master date: 2024-02-26 16:06:42 +0100
---
 xen/arch/x86/spec_ctrl.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 56e07d7536..661716d695 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -62,7 +62,8 @@ int8_t __initdata opt_psfd = -1;
 int8_t __ro_after_init opt_ibpb_ctxt_switch = -1;
 int8_t __read_mostly opt_eager_fpu = -1;
 int8_t __read_mostly opt_l1d_flush = -1;
-static bool __initdata opt_branch_harden = true;
+static bool __initdata opt_branch_harden =
+    IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH);
 
 bool __initdata bsp_delay_spec_ctrl;
 uint8_t __read_mostly default_xen_spec_ctrl;
@@ -280,7 +281,16 @@ static int __init cf_check parse_spec_ctrl(const char *s)
         else if ( (val = parse_boolean("l1d-flush", s, ss)) >= 0 )
             opt_l1d_flush = val;
         else if ( (val = parse_boolean("branch-harden", s, ss)) >= 0 )
-            opt_branch_harden = val;
+        {
+            if ( IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH) )
+                opt_branch_harden = val;
+            else
+            {
+                no_config_param("SPECULATIVE_HARDEN_BRANCH", "spec-ctrl", s,
+                                ss);
+                rc = -EINVAL;
+            }
+        }
         else if ( (val = parse_boolean("srb-lock", s, ss)) >= 0 )
             opt_srb_lock = val;
         else if ( (val = parse_boolean("unpriv-mmio", s, ss)) >= 0 )
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:24:06 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:24:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686166.1067825 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexRG-0001Go-MP; Tue, 27 Feb 2024 13:24:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686166.1067825; Tue, 27 Feb 2024 13:24:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexRG-0001Ge-JW; Tue, 27 Feb 2024 13:24:06 +0000
Received: by outflank-mailman (input) for mailman id 686166;
 Tue, 27 Feb 2024 13:24:05 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexRF-0001G3-A4
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:24:05 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexRF-0000ba-9M
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:24:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexRF-0003a9-8g
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:24:05 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=x4eCFcA5mEwo/bucm8WWFFjTGpnDhDuxNca9vGc4hk8=; b=Aa3E4Ls8Ny8PtHgKyRuCgZro/U
	pxGQGOT+7/9t8T21LMBsQxq3I3wwSLFd9t6XHGgrdyQ2jTeoWlViSRWH/G1hMHOi6g58LEDUvYF6e
	fkTWrR/elwEUbsmaOwMkiM9/iDa6u9Dcpu8LCwt1123f/9v5VD8HqrEH5rQ5JXFcmMTI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.17] x86: account for shadow stack in exception-from-stub recovery
Message-Id: <E1rexRF-0003a9-8g@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:24:05 +0000

commit 49f77602373b58b7bbdb40cea2b49d2f88d4003d
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 14:12:11 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:12:11 2024 +0100

    x86: account for shadow stack in exception-from-stub recovery
    
    Dealing with exceptions raised from within emulation stubs involves
    discarding return address (replaced by exception related information).
    Such discarding of course also requires removing the corresponding entry
    from the shadow stack.
    
    Also amend the comment in fixup_exception_return(), to further clarify
    why use of ptr[1] can't be an out-of-bounds access.
    
    This is CVE-2023-46841 / XSA-451.
    
    Fixes: 209fb9919b50 ("x86/extable: Adjust extable handling to be shadow stack compatible")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: 91f5f7a9154919a765c3933521760acffeddbf28
    master date: 2024-02-27 13:49:22 +0100
---
 xen/arch/x86/extable.c             | 20 +++++++-----
 xen/arch/x86/include/asm/uaccess.h |  3 +-
 xen/arch/x86/traps.c               | 63 ++++++++++++++++++++++++++++++++++----
 3 files changed, 71 insertions(+), 15 deletions(-)

diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index 6758ba1dca..dd9583f2a5 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -86,26 +86,29 @@ search_one_extable(const struct exception_table_entry *first,
 }
 
 unsigned long
-search_exception_table(const struct cpu_user_regs *regs)
+search_exception_table(const struct cpu_user_regs *regs, unsigned long *stub_ra)
 {
     const struct virtual_region *region = find_text_region(regs->rip);
     unsigned long stub = this_cpu(stubs.addr);
 
     if ( region && region->ex )
+    {
+        *stub_ra = 0;
         return search_one_extable(region->ex, region->ex_end, regs->rip);
+    }
 
     if ( regs->rip >= stub + STUB_BUF_SIZE / 2 &&
          regs->rip < stub + STUB_BUF_SIZE &&
          regs->rsp > (unsigned long)regs &&
          regs->rsp < (unsigned long)get_cpu_info() )
     {
-        unsigned long retptr = *(unsigned long *)regs->rsp;
+        unsigned long retaddr = *(unsigned long *)regs->rsp, fixup;
 
-        region = find_text_region(retptr);
-        retptr = region && region->ex
-                 ? search_one_extable(region->ex, region->ex_end, retptr)
-                 : 0;
-        if ( retptr )
+        region = find_text_region(retaddr);
+        fixup = region && region->ex
+                ? search_one_extable(region->ex, region->ex_end, retaddr)
+                : 0;
+        if ( fixup )
         {
             /*
              * Put trap number and error code on the stack (in place of the
@@ -117,7 +120,8 @@ search_exception_table(const struct cpu_user_regs *regs)
             };
 
             *(unsigned long *)regs->rsp = token.raw;
-            return retptr;
+            *stub_ra = retaddr;
+            return fixup;
         }
     }
 
diff --git a/xen/arch/x86/include/asm/uaccess.h b/xen/arch/x86/include/asm/uaccess.h
index 684fccd95c..74bb222c03 100644
--- a/xen/arch/x86/include/asm/uaccess.h
+++ b/xen/arch/x86/include/asm/uaccess.h
@@ -421,7 +421,8 @@ union stub_exception_token {
     unsigned long raw;
 };
 
-extern unsigned long search_exception_table(const struct cpu_user_regs *regs);
+extern unsigned long search_exception_table(const struct cpu_user_regs *regs,
+                                            unsigned long *stub_ra);
 extern void sort_exception_tables(void);
 extern void sort_exception_table(struct exception_table_entry *start,
                                  const struct exception_table_entry *stop);
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 06c4f3868b..7599bee361 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -856,7 +856,7 @@ void do_unhandled_trap(struct cpu_user_regs *regs)
 }
 
 static void fixup_exception_return(struct cpu_user_regs *regs,
-                                   unsigned long fixup)
+                                   unsigned long fixup, unsigned long stub_ra)
 {
     if ( IS_ENABLED(CONFIG_XEN_SHSTK) )
     {
@@ -873,7 +873,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
             /*
              * Search for %rip.  The shstk currently looks like this:
              *
-             *   ...  [Likely pointed to by SSP]
+             *   tok  [Supervisor token, == &tok | BUSY, only with FRED inactive]
+             *   ...  [Pointed to by SSP for most exceptions, empty in IST cases]
              *   %cs  [== regs->cs]
              *   %rip [== regs->rip]
              *   SSP  [Likely points to 3 slots higher, above %cs]
@@ -891,7 +892,56 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
              */
             if ( ptr[0] == regs->rip && ptr[1] == regs->cs )
             {
+                unsigned long primary_shstk =
+                    (ssp & ~(STACK_SIZE - 1)) +
+                    (PRIMARY_SHSTK_SLOT + 1) * PAGE_SIZE - 8;
+
                 wrss(fixup, ptr);
+
+                if ( !stub_ra )
+                    goto shstk_done;
+
+                /*
+                 * Stub recovery ought to happen only when the outer context
+                 * was on the main shadow stack.  We need to also "pop" the
+                 * stub's return address from the interrupted context's shadow
+                 * stack.  That is,
+                 * - if we're still on the main stack, we need to move the
+                 *   entire stack (up to and including the exception frame)
+                 *   up by one slot, incrementing the original SSP in the
+                 *   exception frame,
+                 * - if we're on an IST stack, we need to increment the
+                 *   original SSP.
+                 */
+                BUG_ON((ptr[-1] ^ primary_shstk) >> PAGE_SHIFT);
+
+                if ( (ssp ^ primary_shstk) >> PAGE_SHIFT )
+                {
+                    /*
+                     * We're on an IST stack.  First make sure the two return
+                     * addresses actually match.  Then increment the interrupted
+                     * context's SSP.
+                     */
+                    BUG_ON(stub_ra != *(unsigned long*)ptr[-1]);
+                    wrss(ptr[-1] + 8, &ptr[-1]);
+                    goto shstk_done;
+                }
+
+                /* Make sure the two return addresses actually match. */
+                BUG_ON(stub_ra != ptr[2]);
+
+                /* Move exception frame, updating SSP there. */
+                wrss(ptr[1], &ptr[2]); /* %cs */
+                wrss(ptr[0], &ptr[1]); /* %rip */
+                wrss(ptr[-1] + 8, &ptr[0]); /* SSP */
+
+                /* Move all newer entries. */
+                while ( --ptr != _p(ssp) )
+                    wrss(ptr[-1], &ptr[0]);
+
+                /* Finally account for our own stack having shifted up. */
+                asm volatile ( "incsspd %0" :: "r" (2) );
+
                 goto shstk_done;
             }
         }
@@ -912,7 +962,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
 
 static bool extable_fixup(struct cpu_user_regs *regs, bool print)
 {
-    unsigned long fixup = search_exception_table(regs);
+    unsigned long stub_ra = 0;
+    unsigned long fixup = search_exception_table(regs, &stub_ra);
 
     if ( unlikely(fixup == 0) )
         return false;
@@ -926,7 +977,7 @@ static bool extable_fixup(struct cpu_user_regs *regs, bool print)
                vector_name(regs->entry_vector), regs->error_code,
                _p(regs->rip), _p(regs->rip), _p(fixup));
 
-    fixup_exception_return(regs, fixup);
+    fixup_exception_return(regs, fixup, stub_ra);
     this_cpu(last_extable_addr) = regs->rip;
 
     return true;
@@ -1214,7 +1265,7 @@ void do_invalid_op(struct cpu_user_regs *regs)
         void (*fn)(struct cpu_user_regs *) = bug_ptr(bug);
 
         fn(regs);
-        fixup_exception_return(regs, (unsigned long)eip);
+        fixup_exception_return(regs, (unsigned long)eip, 0);
         return;
     }
 
@@ -1235,7 +1286,7 @@ void do_invalid_op(struct cpu_user_regs *regs)
     case BUGFRAME_warn:
         printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno);
         show_execution_state(regs);
-        fixup_exception_return(regs, (unsigned long)eip);
+        fixup_exception_return(regs, (unsigned long)eip, 0);
         return;
 
     case BUGFRAME_bug:
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:24:16 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:24:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686167.1067829 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexRQ-0001Nl-O6; Tue, 27 Feb 2024 13:24:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686167.1067829; Tue, 27 Feb 2024 13:24:16 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexRQ-0001Nc-L4; Tue, 27 Feb 2024 13:24:16 +0000
Received: by outflank-mailman (input) for mailman id 686167;
 Tue, 27 Feb 2024 13:24:15 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexRP-0001NA-IB
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:24:15 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexRP-0000dJ-HN
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:24:15 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexRP-0003bP-GX
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:24:15 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=8GgCAxmM3YdixKAVD/Dln8DDLLfZIedI90Az4WJdEm8=; b=vhpBBCvGmzrdzQnNEnqE9M3WsA
	eUS+pUzcxky6KaJLgOqJoI5c2Kldv8hXS+Q2OI2Q467gpS/KtQchy/2D/bRhhhTKlq9ZMFS1TVJ+g
	ByEvTZ2IwNbeV4E1Q4m/JTftPhd+moVAj3SH5+74xYM6EPcCG9yrQmqzH4FG3W46uCxQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.16] x86: account for shadow stack in exception-from-stub recovery
Message-Id: <E1rexRP-0003bP-GX@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:24:15 +0000

commit ffd75b161de76e43fd54d751ab70d2fdf6e2e87d
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 14:13:21 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:13:21 2024 +0100

    x86: account for shadow stack in exception-from-stub recovery
    
    Dealing with exceptions raised from within emulation stubs involves
    discarding return address (replaced by exception related information).
    Such discarding of course also requires removing the corresponding entry
    from the shadow stack.
    
    Also amend the comment in fixup_exception_return(), to further clarify
    why use of ptr[1] can't be an out-of-bounds access.
    
    This is CVE-2023-46841 / XSA-451.
    
    Fixes: 209fb9919b50 ("x86/extable: Adjust extable handling to be shadow stack compatible")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: 91f5f7a9154919a765c3933521760acffeddbf28
    master date: 2024-02-27 13:49:22 +0100
---
 xen/arch/x86/extable.c        | 20 ++++++++------
 xen/arch/x86/traps.c          | 63 ++++++++++++++++++++++++++++++++++++++-----
 xen/include/asm-x86/uaccess.h |  3 ++-
 3 files changed, 71 insertions(+), 15 deletions(-)

diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index c18cf97875..f25f56b714 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -86,26 +86,29 @@ search_one_extable(const struct exception_table_entry *first,
 }
 
 unsigned long
-search_exception_table(const struct cpu_user_regs *regs)
+search_exception_table(const struct cpu_user_regs *regs, unsigned long *stub_ra)
 {
     const struct virtual_region *region = find_text_region(regs->rip);
     unsigned long stub = this_cpu(stubs.addr);
 
     if ( region && region->ex )
+    {
+        *stub_ra = 0;
         return search_one_extable(region->ex, region->ex_end, regs->rip);
+    }
 
     if ( regs->rip >= stub + STUB_BUF_SIZE / 2 &&
          regs->rip < stub + STUB_BUF_SIZE &&
          regs->rsp > (unsigned long)regs &&
          regs->rsp < (unsigned long)get_cpu_info() )
     {
-        unsigned long retptr = *(unsigned long *)regs->rsp;
+        unsigned long retaddr = *(unsigned long *)regs->rsp, fixup;
 
-        region = find_text_region(retptr);
-        retptr = region && region->ex
-                 ? search_one_extable(region->ex, region->ex_end, retptr)
-                 : 0;
-        if ( retptr )
+        region = find_text_region(retaddr);
+        fixup = region && region->ex
+                ? search_one_extable(region->ex, region->ex_end, retaddr)
+                : 0;
+        if ( fixup )
         {
             /*
              * Put trap number and error code on the stack (in place of the
@@ -117,7 +120,8 @@ search_exception_table(const struct cpu_user_regs *regs)
             };
 
             *(unsigned long *)regs->rsp = token.raw;
-            return retptr;
+            *stub_ra = retaddr;
+            return fixup;
         }
     }
 
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index a142a63dd8..d74dcc343b 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -895,7 +895,7 @@ static void do_reserved_trap(struct cpu_user_regs *regs)
 }
 
 static void fixup_exception_return(struct cpu_user_regs *regs,
-                                   unsigned long fixup)
+                                   unsigned long fixup, unsigned long stub_ra)
 {
     if ( IS_ENABLED(CONFIG_XEN_SHSTK) )
     {
@@ -912,7 +912,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
             /*
              * Search for %rip.  The shstk currently looks like this:
              *
-             *   ...  [Likely pointed to by SSP]
+             *   tok  [Supervisor token, == &tok | BUSY, only with FRED inactive]
+             *   ...  [Pointed to by SSP for most exceptions, empty in IST cases]
              *   %cs  [== regs->cs]
              *   %rip [== regs->rip]
              *   SSP  [Likely points to 3 slots higher, above %cs]
@@ -930,7 +931,56 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
              */
             if ( ptr[0] == regs->rip && ptr[1] == regs->cs )
             {
+                unsigned long primary_shstk =
+                    (ssp & ~(STACK_SIZE - 1)) +
+                    (PRIMARY_SHSTK_SLOT + 1) * PAGE_SIZE - 8;
+
                 wrss(fixup, ptr);
+
+                if ( !stub_ra )
+                    goto shstk_done;
+
+                /*
+                 * Stub recovery ought to happen only when the outer context
+                 * was on the main shadow stack.  We need to also "pop" the
+                 * stub's return address from the interrupted context's shadow
+                 * stack.  That is,
+                 * - if we're still on the main stack, we need to move the
+                 *   entire stack (up to and including the exception frame)
+                 *   up by one slot, incrementing the original SSP in the
+                 *   exception frame,
+                 * - if we're on an IST stack, we need to increment the
+                 *   original SSP.
+                 */
+                BUG_ON((ptr[-1] ^ primary_shstk) >> PAGE_SHIFT);
+
+                if ( (ssp ^ primary_shstk) >> PAGE_SHIFT )
+                {
+                    /*
+                     * We're on an IST stack.  First make sure the two return
+                     * addresses actually match.  Then increment the interrupted
+                     * context's SSP.
+                     */
+                    BUG_ON(stub_ra != *(unsigned long*)ptr[-1]);
+                    wrss(ptr[-1] + 8, &ptr[-1]);
+                    goto shstk_done;
+                }
+
+                /* Make sure the two return addresses actually match. */
+                BUG_ON(stub_ra != ptr[2]);
+
+                /* Move exception frame, updating SSP there. */
+                wrss(ptr[1], &ptr[2]); /* %cs */
+                wrss(ptr[0], &ptr[1]); /* %rip */
+                wrss(ptr[-1] + 8, &ptr[0]); /* SSP */
+
+                /* Move all newer entries. */
+                while ( --ptr != _p(ssp) )
+                    wrss(ptr[-1], &ptr[0]);
+
+                /* Finally account for our own stack having shifted up. */
+                asm volatile ( "incsspd %0" :: "r" (2) );
+
                 goto shstk_done;
             }
         }
@@ -951,7 +1001,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
 
 static bool extable_fixup(struct cpu_user_regs *regs, bool print)
 {
-    unsigned long fixup = search_exception_table(regs);
+    unsigned long stub_ra = 0;
+    unsigned long fixup = search_exception_table(regs, &stub_ra);
 
     if ( unlikely(fixup == 0) )
         return false;
@@ -965,7 +1016,7 @@ static bool extable_fixup(struct cpu_user_regs *regs, bool print)
                vec_name(regs->entry_vector), regs->error_code,
                _p(regs->rip), _p(regs->rip), _p(fixup));
 
-    fixup_exception_return(regs, fixup);
+    fixup_exception_return(regs, fixup, stub_ra);
     this_cpu(last_extable_addr) = regs->rip;
 
     return true;
@@ -1256,7 +1307,7 @@ void do_invalid_op(struct cpu_user_regs *regs)
         void (*fn)(struct cpu_user_regs *) = bug_ptr(bug);
 
         fn(regs);
-        fixup_exception_return(regs, (unsigned long)eip);
+        fixup_exception_return(regs, (unsigned long)eip, 0);
         return;
     }
 
@@ -1277,7 +1328,7 @@ void do_invalid_op(struct cpu_user_regs *regs)
     case BUGFRAME_warn:
         printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno);
         show_execution_state(regs);
-        fixup_exception_return(regs, (unsigned long)eip);
+        fixup_exception_return(regs, (unsigned long)eip, 0);
         return;
 
     case BUGFRAME_bug:
diff --git a/xen/include/asm-x86/uaccess.h b/xen/include/asm-x86/uaccess.h
index 684fccd95c..74bb222c03 100644
--- a/xen/include/asm-x86/uaccess.h
+++ b/xen/include/asm-x86/uaccess.h
@@ -421,7 +421,8 @@ union stub_exception_token {
     unsigned long raw;
 };
 
-extern unsigned long search_exception_table(const struct cpu_user_regs *regs);
+extern unsigned long search_exception_table(const struct cpu_user_regs *regs,
+                                            unsigned long *stub_ra);
 extern void sort_exception_tables(void);
 extern void sort_exception_table(struct exception_table_entry *start,
                                  const struct exception_table_entry *stop);
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.16


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 13:24:27 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 13:24:27 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686169.1067832 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexRb-0001Yu-RT; Tue, 27 Feb 2024 13:24:27 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686169.1067832; Tue, 27 Feb 2024 13:24:27 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rexRb-0001Yn-Oa; Tue, 27 Feb 2024 13:24:27 +0000
Received: by outflank-mailman (input) for mailman id 686169;
 Tue, 27 Feb 2024 13:24:25 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexRZ-0001XE-Q2
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:24:25 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexRZ-0000di-PA
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:24:25 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rexRZ-0003cD-OT
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 13:24:25 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Ifxd5cE0tF2bicg0gDjxiKALZUIAecf9q/IoPd3gX8A=; b=fd88HHff6T+dwXSHzw2rtwFuSC
	Zrhzybb1kPHWYr+5CeGckpDIHz3eAofreINsikQPOqvustIve9e+u/EBtEF+nkxIZuG1Y8GmGjuUM
	WT7yE6uz+nVmFRl29l3eEwwKEXoLR+uxG37gnBOILhCTfmwdfdJTd9DebLYfunTNcl8s=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.15] x86: account for shadow stack in exception-from-stub recovery
Message-Id: <E1rexRZ-0003cD-OT@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 13:24:25 +0000

commit 2484803074fc1f93942912a82e4906f9e441bf4e
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 14:14:24 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:14:24 2024 +0100

    x86: account for shadow stack in exception-from-stub recovery
    
    Dealing with exceptions raised from within emulation stubs involves
    discarding return address (replaced by exception related information).
    Such discarding of course also requires removing the corresponding entry
    from the shadow stack.
    
    Also amend the comment in fixup_exception_return(), to further clarify
    why use of ptr[1] can't be an out-of-bounds access.
    
    This is CVE-2023-46841 / XSA-451.
    
    Fixes: 209fb9919b50 ("x86/extable: Adjust extable handling to be shadow stack compatible")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: 91f5f7a9154919a765c3933521760acffeddbf28
    master date: 2024-02-27 13:49:22 +0100
---
 xen/arch/x86/extable.c        | 20 ++++++++------
 xen/arch/x86/traps.c          | 63 ++++++++++++++++++++++++++++++++++++++-----
 xen/include/asm-x86/uaccess.h |  3 ++-
 3 files changed, 71 insertions(+), 15 deletions(-)

diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index 0d30595ea1..fd26712574 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -85,26 +85,29 @@ search_one_extable(const struct exception_table_entry *first,
 }
 
 unsigned long
-search_exception_table(const struct cpu_user_regs *regs)
+search_exception_table(const struct cpu_user_regs *regs, unsigned long *stub_ra)
 {
     const struct virtual_region *region = find_text_region(regs->rip);
     unsigned long stub = this_cpu(stubs.addr);
 
     if ( region && region->ex )
+    {
+        *stub_ra = 0;
         return search_one_extable(region->ex, region->ex_end - 1, regs->rip);
+    }
 
     if ( regs->rip >= stub + STUB_BUF_SIZE / 2 &&
          regs->rip < stub + STUB_BUF_SIZE &&
          regs->rsp > (unsigned long)regs &&
          regs->rsp < (unsigned long)get_cpu_info() )
     {
-        unsigned long retptr = *(unsigned long *)regs->rsp;
+        unsigned long retaddr = *(unsigned long *)regs->rsp, fixup;
 
-        region = find_text_region(retptr);
-        retptr = region && region->ex
-                 ? search_one_extable(region->ex, region->ex_end - 1, retptr)
-                 : 0;
-        if ( retptr )
+        region = find_text_region(retaddr);
+        fixup = region && region->ex
+                ? search_one_extable(region->ex, region->ex_end - 1, retaddr)
+                : 0;
+        if ( fixup )
         {
             /*
              * Put trap number and error code on the stack (in place of the
@@ -116,7 +119,8 @@ search_exception_table(const struct cpu_user_regs *regs)
             };
 
             *(unsigned long *)regs->rsp = token.raw;
-            return retptr;
+            *stub_ra = retaddr;
+            return fixup;
         }
     }
 
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index df97ee6c4f..273d4c3128 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -783,7 +783,7 @@ static void do_reserved_trap(struct cpu_user_regs *regs)
 }
 
 static void fixup_exception_return(struct cpu_user_regs *regs,
-                                   unsigned long fixup)
+                                   unsigned long fixup, unsigned long stub_ra)
 {
     if ( IS_ENABLED(CONFIG_XEN_SHSTK) )
     {
@@ -800,7 +800,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
             /*
              * Search for %rip.  The shstk currently looks like this:
              *
-             *   ...  [Likely pointed to by SSP]
+             *   tok  [Supervisor token, == &tok | BUSY, only with FRED inactive]
+             *   ...  [Pointed to by SSP for most exceptions, empty in IST cases]
              *   %cs  [== regs->cs]
              *   %rip [== regs->rip]
              *   SSP  [Likely points to 3 slots higher, above %cs]
@@ -818,7 +819,56 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
              */
             if ( ptr[0] == regs->rip && ptr[1] == regs->cs )
             {
+                unsigned long primary_shstk =
+                    (ssp & ~(STACK_SIZE - 1)) +
+                    (PRIMARY_SHSTK_SLOT + 1) * PAGE_SIZE - 8;
+
                 wrss(fixup, ptr);
+
+                if ( !stub_ra )
+                    goto shstk_done;
+
+                /*
+                 * Stub recovery ought to happen only when the outer context
+                 * was on the main shadow stack.  We need to also "pop" the
+                 * stub's return address from the interrupted context's shadow
+                 * stack.  That is,
+                 * - if we're still on the main stack, we need to move the
+                 *   entire stack (up to and including the exception frame)
+                 *   up by one slot, incrementing the original SSP in the
+                 *   exception frame,
+                 * - if we're on an IST stack, we need to increment the
+                 *   original SSP.
+                 */
+                BUG_ON((ptr[-1] ^ primary_shstk) >> PAGE_SHIFT);
+
+                if ( (ssp ^ primary_shstk) >> PAGE_SHIFT )
+                {
+                    /*
+                     * We're on an IST stack.  First make sure the two return
+                     * addresses actually match.  Then increment the interrupted
+                     * context's SSP.
+                     */
+                    BUG_ON(stub_ra != *(unsigned long*)ptr[-1]);
+                    wrss(ptr[-1] + 8, &ptr[-1]);
+                    goto shstk_done;
+                }
+
+                /* Make sure the two return addresses actually match. */
+                BUG_ON(stub_ra != ptr[2]);
+
+                /* Move exception frame, updating SSP there. */
+                wrss(ptr[1], &ptr[2]); /* %cs */
+                wrss(ptr[0], &ptr[1]); /* %rip */
+                wrss(ptr[-1] + 8, &ptr[0]); /* SSP */
+
+                /* Move all newer entries. */
+                while ( --ptr != _p(ssp) )
+                    wrss(ptr[-1], &ptr[0]);
+
+                /* Finally account for our own stack having shifted up. */
+                asm volatile ( "incsspd %0" :: "r" (2) );
+
                 goto shstk_done;
             }
         }
@@ -839,7 +889,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
 
 static bool extable_fixup(struct cpu_user_regs *regs, bool print)
 {
-    unsigned long fixup = search_exception_table(regs);
+    unsigned long stub_ra = 0;
+    unsigned long fixup = search_exception_table(regs, &stub_ra);
 
     if ( unlikely(fixup == 0) )
         return false;
@@ -853,7 +904,7 @@ static bool extable_fixup(struct cpu_user_regs *regs, bool print)
                vec_name(regs->entry_vector), regs->error_code,
                _p(regs->rip), _p(regs->rip), _p(fixup));
 
-    fixup_exception_return(regs, fixup);
+    fixup_exception_return(regs, fixup, stub_ra);
     this_cpu(last_extable_addr) = regs->rip;
 
     return true;
@@ -1144,7 +1195,7 @@ void do_invalid_op(struct cpu_user_regs *regs)
         void (*fn)(struct cpu_user_regs *) = bug_ptr(bug);
 
         fn(regs);
-        fixup_exception_return(regs, (unsigned long)eip);
+        fixup_exception_return(regs, (unsigned long)eip, 0);
         return;
     }
 
@@ -1165,7 +1216,7 @@ void do_invalid_op(struct cpu_user_regs *regs)
     case BUGFRAME_warn:
         printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno);
         show_execution_state(regs);
-        fixup_exception_return(regs, (unsigned long)eip);
+        fixup_exception_return(regs, (unsigned long)eip, 0);
         return;
 
     case BUGFRAME_bug:
diff --git a/xen/include/asm-x86/uaccess.h b/xen/include/asm-x86/uaccess.h
index 684fccd95c..74bb222c03 100644
--- a/xen/include/asm-x86/uaccess.h
+++ b/xen/include/asm-x86/uaccess.h
@@ -421,7 +421,8 @@ union stub_exception_token {
     unsigned long raw;
 };
 
-extern unsigned long search_exception_table(const struct cpu_user_regs *regs);
+extern unsigned long search_exception_table(const struct cpu_user_regs *regs,
+                                            unsigned long *stub_ra);
 extern void sort_exception_tables(void);
 extern void sort_exception_table(struct exception_table_entry *start,
                                  const struct exception_table_entry *stop);
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.15


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 14:00:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 14:00:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686202.1067916 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey05-0005KY-87; Tue, 27 Feb 2024 14:00:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686202.1067916; Tue, 27 Feb 2024 14:00:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey05-0005KB-4i; Tue, 27 Feb 2024 14:00:05 +0000
Received: by outflank-mailman (input) for mailman id 686202;
 Tue, 27 Feb 2024 14:00:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey04-0005Ci-DJ
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey04-0001OM-An
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey04-0005jf-9d
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ZByT7hfFLrGmRuKMJTLSdYPa5oNZlSOzb5las1/elIU=; b=RchX/OArpcGvXPGqMJHmM9ZdxC
	+v61X83RL6QJRynLc0Mnf+/tlIvs87ESn9Y1XxUPAhbqdEhN9MQi1DRvBaMWl0tk3FKvwM3jcsiLy
	+FfShI3N6+bNMaB9TUbPh8dQFjjVDHKk4To24j7K8gJiEEatJ18h5IramhqoJt/baJgQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] vpci: use per-domain PCI lock to protect vpci structure
Message-Id: <E1rey04-0005jf-9d@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 14:00:04 +0000

commit 4f78438b45e2ee3620e578e30123c777ab864883
Author:     Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
AuthorDate: Tue Feb 27 14:53:15 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:53:15 2024 +0100

    vpci: use per-domain PCI lock to protect vpci structure
    
    Use the per-domain PCI read/write lock to protect the presence of the
    pci device vpci field. This lock can be used (and in a few cases is used
    right away) so that vpci removal can be performed while holding the lock
    in write mode. Previously such removal could race with vpci_read for
    example.
    
    When taking both d->pci_lock and pdev->vpci->lock, they should be
    taken in this exact order: d->pci_lock then pdev->vpci->lock to avoid
    possible deadlock situations.
    
    1. Per-domain's pci_lock is used to protect pdev->vpci structure
    from being removed.
    
    2. Writing the command register and ROM BAR register may trigger
    modify_bars to run, which in turn may access multiple pdevs while
    checking for the existing BAR's overlap. The overlapping check, if
    done under the read lock, requires vpci->lock to be acquired on both
    devices being compared, which may produce a deadlock. It is not
    possible to upgrade read lock to write lock in such a case. So, in
    order to prevent the deadlock, use d->pci_lock in write mode instead.
    
    All other code, which doesn't lead to pdev->vpci destruction and does
    not access multiple pdevs at the same time, can still use a
    combination of the read lock and pdev->vpci->lock.
    
    3. Drop const qualifier where the new rwlock is used and this is
    appropriate.
    
    4. Do not call process_pending_softirqs with any locks held. For that
    unlock prior the call and re-acquire the locks after. After
    re-acquiring the lock there is no need to check if pdev->vpci exists:
     - in apply_map because of the context it is called (no race condition
       possible)
     - for MSI/MSI-X debug code because it is called at the end of
       pdev->vpci access and no further access to pdev->vpci is made
    
    5. Use d->pci_lock around for_each_pdev and pci_get_pdev()
    while accessing pdevs in vpci code.
    
    6. Switch vPCI functions to use per-domain pci_lock for ensuring pdevs
    do not go away. The vPCI functions call several MSI-related functions
    which already have existing non-vPCI callers. Change those MSI-related
    functions to allow using either pcidevs_lock() or d->pci_lock for
    ensuring pdevs do not go away. Holding d->pci_lock in read mode is
    sufficient. Note that this pdev protection mechanism does not protect
    other state or critical sections. These MSI-related functions already
    have other race condition and state protection mechanims (e.g.
    d->event_lock and msixtbl RCU), so we deduce that the use of the global
    pcidevs_lock() is to ensure that pdevs do not go away.
    
    7. Introduce wrapper construct, pdev_list_is_read_locked(), for checking
    that pdevs do not go away. The purpose of this wrapper is to aid
    readability and document the intent of the pdev protection mechanism.
    
    8. When possible, the existing non-vPCI callers of these MSI-related
    functions haven't been switched to use the newly introduced per-domain
    pci_lock, and will continue to use the global pcidevs_lock(). This is
    done to reduce the risk of the new locking scheme introducing
    regressions. Those users will be adjusted in due time. One exception
    is where the pcidevs_lock() in allocate_and_map_msi_pirq() is moved to
    the caller, physdev_map_pirq(): this instance is switched to
    read_lock(&d->pci_lock) right away.
    
    Suggested-by: Roger Pau Monné <roger.pau@citrix.com>
    Suggested-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/hvm/vmsi.c       | 37 +++++++++++++++++++++---------
 xen/arch/x86/hvm/vmx/vmx.c    |  2 +-
 xen/arch/x86/irq.c            |  8 +++----
 xen/arch/x86/msi.c            | 20 +++++++++++------
 xen/arch/x86/physdev.c        |  2 ++
 xen/drivers/passthrough/pci.c |  9 ++++----
 xen/drivers/vpci/header.c     | 18 +++++++++++++++
 xen/drivers/vpci/msi.c        | 27 ++++++++++++++++++----
 xen/drivers/vpci/msix.c       | 52 +++++++++++++++++++++++++++++++++++++------
 xen/drivers/vpci/vpci.c       | 24 ++++++++++++++++++--
 xen/include/xen/pci.h         | 13 +++++++++++
 xen/include/xen/sched.h       |  3 ++-
 12 files changed, 174 insertions(+), 41 deletions(-)

diff --git a/xen/arch/x86/hvm/vmsi.c b/xen/arch/x86/hvm/vmsi.c
index 128f236362..adbac965f9 100644
--- a/xen/arch/x86/hvm/vmsi.c
+++ b/xen/arch/x86/hvm/vmsi.c
@@ -468,7 +468,7 @@ int msixtbl_pt_register(struct domain *d, struct pirq *pirq, uint64_t gtable)
     struct msixtbl_entry *entry, *new_entry;
     int r = -EINVAL;
 
-    ASSERT(pcidevs_locked());
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
     ASSERT(rw_is_write_locked(&d->event_lock));
 
     if ( !msixtbl_initialised(d) )
@@ -538,7 +538,7 @@ void msixtbl_pt_unregister(struct domain *d, struct pirq *pirq)
     struct pci_dev *pdev;
     struct msixtbl_entry *entry;
 
-    ASSERT(pcidevs_locked());
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
     ASSERT(rw_is_write_locked(&d->event_lock));
 
     if ( !msixtbl_initialised(d) )
@@ -684,7 +684,7 @@ static int vpci_msi_update(const struct pci_dev *pdev, uint32_t data,
 {
     unsigned int i;
 
-    ASSERT(pcidevs_locked());
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
 
     if ( (address & MSI_ADDR_BASE_MASK) != MSI_ADDR_HEADER )
     {
@@ -725,8 +725,8 @@ void vpci_msi_arch_update(struct vpci_msi *msi, const struct pci_dev *pdev)
     int rc;
 
     ASSERT(msi->arch.pirq != INVALID_PIRQ);
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
 
-    pcidevs_lock();
     for ( i = 0; i < msi->vectors && msi->arch.bound; i++ )
     {
         struct xen_domctl_bind_pt_irq unbind = {
@@ -745,7 +745,6 @@ void vpci_msi_arch_update(struct vpci_msi *msi, const struct pci_dev *pdev)
 
     msi->arch.bound = !vpci_msi_update(pdev, msi->data, msi->address,
                                        msi->vectors, msi->arch.pirq, msi->mask);
-    pcidevs_unlock();
 }
 
 static int vpci_msi_enable(const struct pci_dev *pdev, unsigned int nr,
@@ -778,15 +777,14 @@ int vpci_msi_arch_enable(struct vpci_msi *msi, const struct pci_dev *pdev,
     int rc;
 
     ASSERT(msi->arch.pirq == INVALID_PIRQ);
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
     rc = vpci_msi_enable(pdev, vectors, 0);
     if ( rc < 0 )
         return rc;
     msi->arch.pirq = rc;
 
-    pcidevs_lock();
     msi->arch.bound = !vpci_msi_update(pdev, msi->data, msi->address, vectors,
                                        msi->arch.pirq, msi->mask);
-    pcidevs_unlock();
 
     return 0;
 }
@@ -797,8 +795,8 @@ static void vpci_msi_disable(const struct pci_dev *pdev, int pirq,
     unsigned int i;
 
     ASSERT(pirq != INVALID_PIRQ);
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
 
-    pcidevs_lock();
     for ( i = 0; i < nr && bound; i++ )
     {
         struct xen_domctl_bind_pt_irq bind = {
@@ -814,7 +812,6 @@ static void vpci_msi_disable(const struct pci_dev *pdev, int pirq,
     write_lock(&pdev->domain->event_lock);
     unmap_domain_pirq(pdev->domain, pirq);
     write_unlock(&pdev->domain->event_lock);
-    pcidevs_unlock();
 }
 
 void vpci_msi_arch_disable(struct vpci_msi *msi, const struct pci_dev *pdev)
@@ -854,6 +851,7 @@ int vpci_msix_arch_enable_entry(struct vpci_msix_entry *entry,
     int rc;
 
     ASSERT(entry->arch.pirq == INVALID_PIRQ);
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
     rc = vpci_msi_enable(pdev, vmsix_entry_nr(pdev->vpci->msix, entry),
                          table_base);
     if ( rc < 0 )
@@ -861,7 +859,6 @@ int vpci_msix_arch_enable_entry(struct vpci_msix_entry *entry,
 
     entry->arch.pirq = rc;
 
-    pcidevs_lock();
     rc = vpci_msi_update(pdev, entry->data, entry->addr, 1, entry->arch.pirq,
                          entry->masked);
     if ( rc )
@@ -869,7 +866,6 @@ int vpci_msix_arch_enable_entry(struct vpci_msix_entry *entry,
         vpci_msi_disable(pdev, entry->arch.pirq, 1, false);
         entry->arch.pirq = INVALID_PIRQ;
     }
-    pcidevs_unlock();
 
     return rc;
 }
@@ -895,6 +891,15 @@ int vpci_msix_arch_print(const struct vpci_msix *msix)
 {
     unsigned int i;
 
+    /*
+     * Assert that pdev_list doesn't change. ASSERT_PDEV_LIST_IS_READ_LOCKED
+     * is not suitable here because it allows either pcidevs_lock() or
+     * pci_lock to be held, but here we rely on pci_lock being held, not
+     * pcidevs_lock() (see the transient lock dropping further down).
+     */
+    ASSERT(rw_is_locked(&msix->pdev->domain->pci_lock));
+    ASSERT(spin_is_locked(&msix->pdev->vpci->lock));
+
     for ( i = 0; i < msix->max_entries; i++ )
     {
         const struct vpci_msix_entry *entry = &msix->entries[i];
@@ -913,13 +918,23 @@ int vpci_msix_arch_print(const struct vpci_msix *msix)
             struct pci_dev *pdev = msix->pdev;
 
             spin_unlock(&msix->pdev->vpci->lock);
+            read_unlock(&pdev->domain->pci_lock);
             process_pending_softirqs();
+
+            if ( !read_trylock(&pdev->domain->pci_lock) )
+                return -EBUSY;
+
             /* NB: we assume that pdev cannot go away for an alive domain. */
             if ( !pdev->vpci || !spin_trylock(&pdev->vpci->lock) )
+            {
+                read_unlock(&pdev->domain->pci_lock);
                 return -EBUSY;
+            }
+
             if ( pdev->vpci->msix != msix )
             {
                 spin_unlock(&pdev->vpci->lock);
+                read_unlock(&pdev->domain->pci_lock);
                 return -EAGAIN;
             }
         }
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 8b27d83c12..23bdf0d195 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -413,7 +413,7 @@ static int cf_check vmx_pi_update_irte(const struct vcpu *v,
 
     spin_unlock_irq(&desc->lock);
 
-    ASSERT(pcidevs_locked());
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(msi_desc->dev->domain);
 
     return iommu_update_ire_from_msi(msi_desc, &msi_desc->msg);
 
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index 7458b89ab3..0487f734a5 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -2162,7 +2162,7 @@ int map_domain_pirq(
         struct pci_dev *pdev;
         unsigned int nr = 0;
 
-        ASSERT(pcidevs_locked());
+        ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
 
         ret = -ENODEV;
         if ( !cpu_has_apic )
@@ -2319,7 +2319,7 @@ int unmap_domain_pirq(struct domain *d, int pirq)
     if ( (pirq < 0) || (pirq >= d->nr_pirqs) )
         return -EINVAL;
 
-    ASSERT(pcidevs_locked());
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
     ASSERT(rw_is_write_locked(&d->event_lock));
 
     info = pirq_info(d, pirq);
@@ -2884,6 +2884,8 @@ int allocate_and_map_msi_pirq(struct domain *d, int index, int *pirq_p,
 {
     int irq, pirq, ret;
 
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
+
     switch ( type )
     {
     case MAP_PIRQ_TYPE_MSI:
@@ -2913,7 +2915,6 @@ int allocate_and_map_msi_pirq(struct domain *d, int index, int *pirq_p,
 
     msi->irq = irq;
 
-    pcidevs_lock();
     /* Verify or get pirq. */
     write_lock(&d->event_lock);
     pirq = allocate_pirq(d, index, *pirq_p, irq, type, &msi->entry_nr);
@@ -2929,7 +2930,6 @@ int allocate_and_map_msi_pirq(struct domain *d, int index, int *pirq_p,
 
  done:
     write_unlock(&d->event_lock);
-    pcidevs_unlock();
     if ( ret )
     {
         switch ( type )
diff --git a/xen/arch/x86/msi.c b/xen/arch/x86/msi.c
index 335c0868a2..e721aaf5c0 100644
--- a/xen/arch/x86/msi.c
+++ b/xen/arch/x86/msi.c
@@ -602,7 +602,7 @@ static int msi_capability_init(struct pci_dev *dev,
     unsigned int i, mpos;
     uint16_t control;
 
-    ASSERT(pcidevs_locked());
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(dev->domain);
     pos = pci_find_cap_offset(dev->sbdf, PCI_CAP_ID_MSI);
     if ( !pos )
         return -ENODEV;
@@ -771,7 +771,7 @@ static int msix_capability_init(struct pci_dev *dev,
     if ( !pos )
         return -ENODEV;
 
-    ASSERT(pcidevs_locked());
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(dev->domain);
 
     control = pci_conf_read16(dev->sbdf, msix_control_reg(pos));
     /*
@@ -988,11 +988,11 @@ static int __pci_enable_msi(struct pci_dev *pdev, struct msi_info *msi,
 {
     struct msi_desc *old_desc;
 
-    ASSERT(pcidevs_locked());
-
     if ( !pdev )
         return -ENODEV;
 
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
+
     old_desc = find_msi_entry(pdev, msi->irq, PCI_CAP_ID_MSI);
     if ( old_desc )
     {
@@ -1043,9 +1043,12 @@ static int __pci_enable_msix(struct pci_dev *pdev, struct msi_info *msi,
 {
     struct msi_desc *old_desc;
 
-    ASSERT(pcidevs_locked());
+    if ( !pdev )
+        return -ENODEV;
+
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
 
-    if ( !pdev || !pdev->msix )
+    if ( !pdev->msix )
         return -ENODEV;
 
     if ( msi->entry_nr >= pdev->msix->nr_entries )
@@ -1154,7 +1157,10 @@ int pci_prepare_msix(u16 seg, u8 bus, u8 devfn, bool off)
 int pci_enable_msi(struct pci_dev *pdev, struct msi_info *msi,
                    struct msi_desc **desc)
 {
-    ASSERT(pcidevs_locked());
+    if ( !pdev )
+        return -ENODEV;
+
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
 
     if ( !use_msi )
         return -EPERM;
diff --git a/xen/arch/x86/physdev.c b/xen/arch/x86/physdev.c
index 47c4da0af7..7efa17cf4c 100644
--- a/xen/arch/x86/physdev.c
+++ b/xen/arch/x86/physdev.c
@@ -123,7 +123,9 @@ int physdev_map_pirq(domid_t domid, int type, int *index, int *pirq_p,
 
     case MAP_PIRQ_TYPE_MSI:
     case MAP_PIRQ_TYPE_MULTI_MSI:
+        read_lock(&d->pci_lock);
         ret = allocate_and_map_msi_pirq(d, *index, pirq_p, type, msi);
+        read_unlock(&d->pci_lock);
         break;
 
     default:
diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 47c0eee7bd..c97dd4504a 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -750,7 +750,6 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
         pdev->domain = hardware_domain;
         write_lock(&hardware_domain->pci_lock);
         list_add(&pdev->domain_list, &hardware_domain->pdev_list);
-        write_unlock(&hardware_domain->pci_lock);
 
         /*
          * For devices not discovered by Xen during boot, add vPCI handlers
@@ -759,18 +758,18 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
         ret = vpci_add_handlers(pdev);
         if ( ret )
         {
-            printk(XENLOG_ERR "Setup of vPCI failed: %d\n", ret);
-            write_lock(&hardware_domain->pci_lock);
             list_del(&pdev->domain_list);
             write_unlock(&hardware_domain->pci_lock);
             pdev->domain = NULL;
+            printk(XENLOG_ERR "Setup of vPCI failed: %d\n", ret);
             goto out;
         }
+        write_unlock(&hardware_domain->pci_lock);
         ret = iommu_add_device(pdev);
         if ( ret )
         {
-            vpci_remove_device(pdev);
             write_lock(&hardware_domain->pci_lock);
+            vpci_remove_device(pdev);
             list_del(&pdev->domain_list);
             write_unlock(&hardware_domain->pci_lock);
             pdev->domain = NULL;
@@ -1146,7 +1145,9 @@ static void __hwdom_init setup_one_hwdom_device(const struct setup_hwdom *ctxt,
     } while ( devfn != pdev->devfn &&
               PCI_SLOT(devfn) == PCI_SLOT(pdev->devfn) );
 
+    write_lock(&ctxt->d->pci_lock);
     err = vpci_add_handlers(pdev);
+    write_unlock(&ctxt->d->pci_lock);
     if ( err )
         printk(XENLOG_ERR "setup of vPCI for d%d failed: %d\n",
                ctxt->d->domain_id, err);
diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 58195549d5..8f5850b8cf 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -173,6 +173,7 @@ bool vpci_process_pending(struct vcpu *v)
         if ( rc == -ERESTART )
             return true;
 
+        write_lock(&v->domain->pci_lock);
         spin_lock(&v->vpci.pdev->vpci->lock);
         /* Disable memory decoding unconditionally on failure. */
         modify_decoding(v->vpci.pdev,
@@ -191,6 +192,7 @@ bool vpci_process_pending(struct vcpu *v)
              * failure.
              */
             vpci_remove_device(v->vpci.pdev);
+        write_unlock(&v->domain->pci_lock);
     }
 
     return false;
@@ -202,8 +204,20 @@ static int __init apply_map(struct domain *d, const struct pci_dev *pdev,
     struct map_data data = { .d = d, .map = true };
     int rc;
 
+    ASSERT(rw_is_write_locked(&d->pci_lock));
+
     while ( (rc = rangeset_consume_ranges(mem, map_range, &data)) == -ERESTART )
+    {
+        /*
+         * It's safe to drop and reacquire the lock in this context
+         * without risking pdev disappearing because devices cannot be
+         * removed until the initial domain has been started.
+         */
+        write_unlock(&d->pci_lock);
         process_pending_softirqs();
+        write_lock(&d->pci_lock);
+    }
+
     rangeset_destroy(mem);
     if ( !rc )
         modify_decoding(pdev, cmd, false);
@@ -244,6 +258,8 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
     unsigned int i;
     int rc;
 
+    ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
+
     if ( !mem )
         return -ENOMEM;
 
@@ -524,6 +540,8 @@ static int cf_check init_header(struct pci_dev *pdev)
     int rc;
     bool mask_cap_list = false;
 
+    ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
+
     switch ( pci_conf_read8(pdev->sbdf, PCI_HEADER_TYPE) & 0x7f )
     {
     case PCI_HEADER_TYPE_NORMAL:
diff --git a/xen/drivers/vpci/msi.c b/xen/drivers/vpci/msi.c
index a253ccbd7d..d3aa5df089 100644
--- a/xen/drivers/vpci/msi.c
+++ b/xen/drivers/vpci/msi.c
@@ -263,7 +263,7 @@ REGISTER_VPCI_INIT(init_msi, VPCI_PRIORITY_LOW);
 
 void vpci_dump_msi(void)
 {
-    const struct domain *d;
+    struct domain *d;
 
     rcu_read_lock(&domlist_read_lock);
     for_each_domain ( d )
@@ -275,6 +275,9 @@ void vpci_dump_msi(void)
 
         printk("vPCI MSI/MSI-X d%d\n", d->domain_id);
 
+        if ( !read_trylock(&d->pci_lock) )
+            continue;
+
         for_each_pdev ( d, pdev )
         {
             const struct vpci_msi *msi;
@@ -313,17 +316,33 @@ void vpci_dump_msi(void)
                 {
                     /*
                      * On error vpci_msix_arch_print will always return without
-                     * holding the lock.
+                     * holding the locks.
                      */
                     printk("unable to print all MSI-X entries: %d\n", rc);
-                    process_pending_softirqs();
-                    continue;
+                    goto pdev_done;
                 }
             }
 
+            /*
+             * Unlock locks to process pending softirqs. This is
+             * potentially unsafe, as d->pdev_list can be changed in
+             * meantime.
+             */
             spin_unlock(&pdev->vpci->lock);
+            read_unlock(&d->pci_lock);
+
+        pdev_done:
             process_pending_softirqs();
+            if ( !read_trylock(&d->pci_lock) )
+            {
+                printk("unable to access other devices for the domain\n");
+                goto domain_done;
+            }
         }
+        read_unlock(&d->pci_lock);
+
+    domain_done:
+        ;
     }
     rcu_read_unlock(&domlist_read_lock);
 }
diff --git a/xen/drivers/vpci/msix.c b/xen/drivers/vpci/msix.c
index d1126a417d..58c16ebdf2 100644
--- a/xen/drivers/vpci/msix.c
+++ b/xen/drivers/vpci/msix.c
@@ -147,6 +147,8 @@ static struct vpci_msix *msix_find(const struct domain *d, unsigned long addr)
 {
     struct vpci_msix *msix;
 
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
+
     list_for_each_entry ( msix, &d->arch.hvm.msix_tables, next )
     {
         const struct vpci_bar *bars = msix->pdev->vpci->header.bars;
@@ -163,7 +165,13 @@ static struct vpci_msix *msix_find(const struct domain *d, unsigned long addr)
 
 static int cf_check msix_accept(struct vcpu *v, unsigned long addr)
 {
-    return !!msix_find(v->domain, addr);
+    int rc;
+
+    read_lock(&v->domain->pci_lock);
+    rc = !!msix_find(v->domain, addr);
+    read_unlock(&v->domain->pci_lock);
+
+    return rc;
 }
 
 static bool access_allowed(const struct pci_dev *pdev, unsigned long addr,
@@ -358,21 +366,35 @@ static int adjacent_read(const struct domain *d, const struct vpci_msix *msix,
 static int cf_check msix_read(
     struct vcpu *v, unsigned long addr, unsigned int len, unsigned long *data)
 {
-    const struct domain *d = v->domain;
-    struct vpci_msix *msix = msix_find(d, addr);
+    struct domain *d = v->domain;
+    struct vpci_msix *msix;
     const struct vpci_msix_entry *entry;
     unsigned int offset;
 
     *data = ~0UL;
 
+    read_lock(&d->pci_lock);
+
+    msix = msix_find(d, addr);
     if ( !msix )
+    {
+        read_unlock(&d->pci_lock);
         return X86EMUL_RETRY;
+    }
 
     if ( adjacent_handle(msix, addr) )
-        return adjacent_read(d, msix, addr, len, data);
+    {
+        int rc = adjacent_read(d, msix, addr, len, data);
+
+        read_unlock(&d->pci_lock);
+        return rc;
+    }
 
     if ( !access_allowed(msix->pdev, addr, len) )
+    {
+        read_unlock(&d->pci_lock);
         return X86EMUL_OKAY;
+    }
 
     spin_lock(&msix->pdev->vpci->lock);
     entry = get_entry(msix, addr);
@@ -404,6 +426,7 @@ static int cf_check msix_read(
         break;
     }
     spin_unlock(&msix->pdev->vpci->lock);
+    read_unlock(&d->pci_lock);
 
     return X86EMUL_OKAY;
 }
@@ -491,19 +514,33 @@ static int adjacent_write(const struct domain *d, const struct vpci_msix *msix,
 static int cf_check msix_write(
     struct vcpu *v, unsigned long addr, unsigned int len, unsigned long data)
 {
-    const struct domain *d = v->domain;
-    struct vpci_msix *msix = msix_find(d, addr);
+    struct domain *d = v->domain;
+    struct vpci_msix *msix;
     struct vpci_msix_entry *entry;
     unsigned int offset;
 
+    read_lock(&d->pci_lock);
+
+    msix = msix_find(d, addr);
     if ( !msix )
+    {
+        read_unlock(&d->pci_lock);
         return X86EMUL_RETRY;
+    }
 
     if ( adjacent_handle(msix, addr) )
-        return adjacent_write(d, msix, addr, len, data);
+    {
+        int rc = adjacent_write(d, msix, addr, len, data);
+
+        read_unlock(&d->pci_lock);
+        return rc;
+    }
 
     if ( !access_allowed(msix->pdev, addr, len) )
+    {
+        read_unlock(&d->pci_lock);
         return X86EMUL_OKAY;
+    }
 
     spin_lock(&msix->pdev->vpci->lock);
     entry = get_entry(msix, addr);
@@ -579,6 +616,7 @@ static int cf_check msix_write(
         break;
     }
     spin_unlock(&msix->pdev->vpci->lock);
+    read_unlock(&d->pci_lock);
 
     return X86EMUL_OKAY;
 }
diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index 72ef277c4f..475272b173 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -42,6 +42,8 @@ extern vpci_register_init_t *const __end_vpci_array[];
 
 void vpci_remove_device(struct pci_dev *pdev)
 {
+    ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
+
     if ( !has_vpci(pdev->domain) || !pdev->vpci )
         return;
 
@@ -77,6 +79,8 @@ int vpci_add_handlers(struct pci_dev *pdev)
     const unsigned long *ro_map;
     int rc = 0;
 
+    ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
+
     if ( !has_vpci(pdev->domain) )
         return 0;
 
@@ -361,7 +365,7 @@ static uint32_t merge_result(uint32_t data, uint32_t new, unsigned int size,
 
 uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg, unsigned int size)
 {
-    const struct domain *d = current->domain;
+    struct domain *d = current->domain;
     const struct pci_dev *pdev;
     const struct vpci_register *r;
     unsigned int data_offset = 0;
@@ -376,12 +380,18 @@ uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg, unsigned int size)
     /*
      * Find the PCI dev matching the address, which for hwdom also requires
      * consulting DomXEN.  Passthrough everything that's not trapped.
+     * If this is hwdom and the device is assigned to DomXEN, acquiring hwdom's
+     * pci_lock is sufficient.
      */
+    read_lock(&d->pci_lock);
     pdev = pci_get_pdev(d, sbdf);
     if ( !pdev && is_hardware_domain(d) )
         pdev = pci_get_pdev(dom_xen, sbdf);
     if ( !pdev || !pdev->vpci )
+    {
+        read_unlock(&d->pci_lock);
         return vpci_read_hw(sbdf, reg, size);
+    }
 
     spin_lock(&pdev->vpci->lock);
 
@@ -428,6 +438,7 @@ uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg, unsigned int size)
         ASSERT(data_offset < size);
     }
     spin_unlock(&pdev->vpci->lock);
+    read_unlock(&d->pci_lock);
 
     if ( data_offset < size )
     {
@@ -470,7 +481,7 @@ static void vpci_write_helper(const struct pci_dev *pdev,
 void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
                 uint32_t data)
 {
-    const struct domain *d = current->domain;
+    struct domain *d = current->domain;
     const struct pci_dev *pdev;
     const struct vpci_register *r;
     unsigned int data_offset = 0;
@@ -484,7 +495,13 @@ void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
     /*
      * Find the PCI dev matching the address, which for hwdom also requires
      * consulting DomXEN.  Passthrough everything that's not trapped.
+     * If this is hwdom and the device is assigned to DomXEN, acquiring hwdom's
+     * pci_lock is sufficient.
+     *
+     * TODO: We need to take pci_locks in exclusive mode only if we
+     * are modifying BARs, so there is a room for improvement.
      */
+    write_lock(&d->pci_lock);
     pdev = pci_get_pdev(d, sbdf);
     if ( !pdev && is_hardware_domain(d) )
         pdev = pci_get_pdev(dom_xen, sbdf);
@@ -493,6 +510,8 @@ void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
         /* Ignore writes to read-only devices, which have no ->vpci. */
         const unsigned long *ro_map = pci_get_ro_map(sbdf.seg);
 
+        write_unlock(&d->pci_lock);
+
         if ( !ro_map || !test_bit(sbdf.bdf, ro_map) )
             vpci_write_hw(sbdf, reg, size, data);
         return;
@@ -534,6 +553,7 @@ void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
         ASSERT(data_offset < size);
     }
     spin_unlock(&pdev->vpci->lock);
+    write_unlock(&d->pci_lock);
 
     if ( data_offset < size )
         /* Tailing gap, write the remaining. */
diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h
index aabc5465a7..1df1863b13 100644
--- a/xen/include/xen/pci.h
+++ b/xen/include/xen/pci.h
@@ -171,6 +171,19 @@ void pcidevs_lock(void);
 void pcidevs_unlock(void);
 bool __must_check pcidevs_locked(void);
 
+#ifndef NDEBUG
+/*
+ * Check to ensure there will be no changes to the entries in d->pdev_list (but
+ * not the contents of each entry).
+ * This check is not suitable for protecting other state or critical regions.
+ */
+#define ASSERT_PDEV_LIST_IS_READ_LOCKED(d)                               \
+        /* NB: d may be evaluated multiple times, or not at all */       \
+        ASSERT(pcidevs_locked() || ((d) && rw_is_locked(&(d)->pci_lock)))
+#else
+#define ASSERT_PDEV_LIST_IS_READ_LOCKED(d) ((void)(d))
+#endif
+
 bool pci_known_segment(u16 seg);
 bool pci_device_detect(u16 seg, u8 bus, u8 dev, u8 func);
 int scan_pci_devices(void);
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 9da91e0e62..37f5922f32 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -462,7 +462,8 @@ struct domain
 #ifdef CONFIG_HAS_PCI
     struct list_head pdev_list;
     /*
-     * pci_lock protects access to pdev_list.
+     * pci_lock protects access to pdev_list. pci_lock also protects pdev->vpci
+     * structure from being removed.
      *
      * Any user *reading* from pdev_list, or from devices stored in pdev_list,
      * should hold either pcidevs_lock() or pci_lock in read mode. Optionally,
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 14:00:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 14:00:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686203.1067921 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey0F-0005eQ-CD; Tue, 27 Feb 2024 14:00:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686203.1067921; Tue, 27 Feb 2024 14:00:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey0F-0005eI-9U; Tue, 27 Feb 2024 14:00:15 +0000
Received: by outflank-mailman (input) for mailman id 686203;
 Tue, 27 Feb 2024 14:00:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey0E-0005cw-Ex
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey0E-0001OY-EA
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey0E-0005ku-D1
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=GPtOLwVsIEijUsqsygr5Od27L8FsGppvMHmeLaz+EkA=; b=idPJGWa4N8mlf75WYrKk7FzxM1
	/YJD1cR3YMvEdIV4KKTuUCdoiSVMrp9k6uIMoldRK8EZBXfeTxH4ZuGLDzFQf3EuezdHY1hAZrNaW
	a3Bd23MRD6GOAEKdUwYZ+CBcoJ33or5rOqu0xdO0AoyJTjdX7h1b6qAsxPB04yijwvoc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] vpci: restrict unhandled read/write operations for guests
Message-Id: <E1rey0E-0005ku-D1@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 14:00:14 +0000

commit 80b0eb095aae5aef62cb529e93cba93f687b0b75
Author:     Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
AuthorDate: Tue Feb 27 14:53:50 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:53:50 2024 +0100

    vpci: restrict unhandled read/write operations for guests
    
    A guest would be able to read and write those registers which are not
    emulated and have no respective vPCI handlers, so it will be possible
    for it to access the hardware directly.
    In order to prevent a guest from reads and writes from/to the unhandled
    registers make sure only hardware domain can access the hardware directly
    and restrict guests from doing so.
    
    Suggested-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
---
 xen/drivers/vpci/vpci.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index 475272b173..d545dc633c 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -268,6 +268,10 @@ static uint32_t vpci_read_hw(pci_sbdf_t sbdf, unsigned int reg,
 {
     uint32_t data;
 
+    /* Guest domains are not allowed to read real hardware. */
+    if ( !is_hardware_domain(current->domain) )
+        return ~(uint32_t)0;
+
     switch ( size )
     {
     case 4:
@@ -311,6 +315,10 @@ static uint32_t vpci_read_hw(pci_sbdf_t sbdf, unsigned int reg,
 static void vpci_write_hw(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
                           uint32_t data)
 {
+    /* Guest domains are not allowed to write real hardware. */
+    if ( !is_hardware_domain(current->domain) )
+        return;
+
     switch ( size )
     {
     case 4:
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 14:00:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 14:00:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686204.1067925 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey0P-0005hy-Df; Tue, 27 Feb 2024 14:00:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686204.1067925; Tue, 27 Feb 2024 14:00:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey0P-0005hq-B0; Tue, 27 Feb 2024 14:00:25 +0000
Received: by outflank-mailman (input) for mailman id 686204;
 Tue, 27 Feb 2024 14:00:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey0O-0005hi-KS
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey0O-0001Oz-Hl
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey0O-0005lQ-GT
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:24 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=HD8sO/OvNywYIw7nYzrJ9kmqypbtrdUSID1MiY9Sa6k=; b=eieK+REszAuW7LFmhWEk9AzT5z
	+gw/gWOVQAUFOSr0MKv2iUjOCU8YOA+9UYiL1pJuCLpdqSD+280TSbt43BOl3BiUo1HnyFnU6O93v
	VfibNeQjOmQGkaTsO5jTvepgjG5lMTb3rwpHSlsyQrElaINrwN175FWoj6LLVQX/nD+4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] vpci: add hooks for PCI device assign/de-assign
Message-Id: <E1rey0O-0005lQ-GT@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 14:00:24 +0000

commit f20dde92594ad3fa7a9968cd7bd3d1f5c7c59008
Author:     Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
AuthorDate: Tue Feb 27 14:54:21 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:54:21 2024 +0100

    vpci: add hooks for PCI device assign/de-assign
    
    When a PCI device gets assigned/de-assigned we need to
    initialize/de-initialize vPCI state for the device.
    
    Also, rename vpci_add_handlers() to vpci_assign_device() and
    vpci_remove_device() to vpci_deassign_device() to better reflect role
    of the functions.
    
    Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/drivers/passthrough/pci.c | 28 ++++++++++++++++++++++++----
 xen/drivers/vpci/header.c     |  2 +-
 xen/drivers/vpci/vpci.c       |  6 +++---
 xen/include/xen/vpci.h        | 10 +++++-----
 4 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index c97dd4504a..4c0a836486 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -755,7 +755,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
          * For devices not discovered by Xen during boot, add vPCI handlers
          * when Dom0 first informs Xen about such devices.
          */
-        ret = vpci_add_handlers(pdev);
+        ret = vpci_assign_device(pdev);
         if ( ret )
         {
             list_del(&pdev->domain_list);
@@ -769,7 +769,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
         if ( ret )
         {
             write_lock(&hardware_domain->pci_lock);
-            vpci_remove_device(pdev);
+            vpci_deassign_device(pdev);
             list_del(&pdev->domain_list);
             write_unlock(&hardware_domain->pci_lock);
             pdev->domain = NULL;
@@ -817,7 +817,7 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn)
     list_for_each_entry ( pdev, &pseg->alldevs_list, alldevs_list )
         if ( pdev->bus == bus && pdev->devfn == devfn )
         {
-            vpci_remove_device(pdev);
+            vpci_deassign_device(pdev);
             pci_cleanup_msi(pdev);
             ret = iommu_remove_device(pdev);
             if ( pdev->domain )
@@ -875,6 +875,10 @@ static int deassign_device(struct domain *d, uint16_t seg, uint8_t bus,
             goto out;
     }
 
+    write_lock(&d->pci_lock);
+    vpci_deassign_device(pdev);
+    write_unlock(&d->pci_lock);
+
     devfn = pdev->devfn;
     ret = iommu_call(hd->platform_ops, reassign_device, d, target, devfn,
                      pci_to_dev(pdev));
@@ -886,6 +890,11 @@ static int deassign_device(struct domain *d, uint16_t seg, uint8_t bus,
 
     pdev->fault.count = 0;
 
+    write_lock(&target->pci_lock);
+    /* Re-assign back to hardware_domain */
+    ret = vpci_assign_device(pdev);
+    write_unlock(&target->pci_lock);
+
  out:
     if ( ret )
         printk(XENLOG_G_ERR "%pd: deassign (%pp) failed (%d)\n",
@@ -1146,7 +1155,7 @@ static void __hwdom_init setup_one_hwdom_device(const struct setup_hwdom *ctxt,
               PCI_SLOT(devfn) == PCI_SLOT(pdev->devfn) );
 
     write_lock(&ctxt->d->pci_lock);
-    err = vpci_add_handlers(pdev);
+    err = vpci_assign_device(pdev);
     write_unlock(&ctxt->d->pci_lock);
     if ( err )
         printk(XENLOG_ERR "setup of vPCI for d%d failed: %d\n",
@@ -1476,6 +1485,10 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)
     if ( pdev->broken && d != hardware_domain && d != dom_io )
         goto done;
 
+    write_lock(&pdev->domain->pci_lock);
+    vpci_deassign_device(pdev);
+    write_unlock(&pdev->domain->pci_lock);
+
     rc = pdev_msix_assign(d, pdev);
     if ( rc )
         goto done;
@@ -1501,6 +1514,13 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)
                         pci_to_dev(pdev), flag);
     }
 
+    if ( rc )
+        goto done;
+
+    write_lock(&d->pci_lock);
+    rc = vpci_assign_device(pdev);
+    write_unlock(&d->pci_lock);
+
  done:
     if ( rc )
     {
diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 8f5850b8cf..2f2d98ada0 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -191,7 +191,7 @@ bool vpci_process_pending(struct vcpu *v)
              * killed in order to avoid leaking stale p2m mappings on
              * failure.
              */
-            vpci_remove_device(v->vpci.pdev);
+            vpci_deassign_device(v->vpci.pdev);
         write_unlock(&v->domain->pci_lock);
     }
 
diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index d545dc633c..ff48373917 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -40,7 +40,7 @@ extern vpci_register_init_t *const __start_vpci_array[];
 extern vpci_register_init_t *const __end_vpci_array[];
 #define NUM_VPCI_INIT (__end_vpci_array - __start_vpci_array)
 
-void vpci_remove_device(struct pci_dev *pdev)
+void vpci_deassign_device(struct pci_dev *pdev)
 {
     ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
 
@@ -73,7 +73,7 @@ void vpci_remove_device(struct pci_dev *pdev)
     pdev->vpci = NULL;
 }
 
-int vpci_add_handlers(struct pci_dev *pdev)
+int vpci_assign_device(struct pci_dev *pdev)
 {
     unsigned int i;
     const unsigned long *ro_map;
@@ -107,7 +107,7 @@ int vpci_add_handlers(struct pci_dev *pdev)
     }
 
     if ( rc )
-        vpci_remove_device(pdev);
+        vpci_deassign_device(pdev);
 
     return rc;
 }
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index d20c301a3d..99fe76f08a 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -25,11 +25,11 @@ typedef int vpci_register_init_t(struct pci_dev *dev);
   static vpci_register_init_t *const x##_entry  \
                __used_section(".data.vpci." p) = x
 
-/* Add vPCI handlers to device. */
-int __must_check vpci_add_handlers(struct pci_dev *pdev);
+/* Assign vPCI to device by adding handlers. */
+int __must_check vpci_assign_device(struct pci_dev *pdev);
 
 /* Remove all handlers and free vpci related structures. */
-void vpci_remove_device(struct pci_dev *pdev);
+void vpci_deassign_device(struct pci_dev *pdev);
 
 /* Add/remove a register handler. */
 int __must_check vpci_add_register_mask(struct vpci *vpci,
@@ -255,12 +255,12 @@ bool vpci_ecam_read(pci_sbdf_t sbdf, unsigned int reg, unsigned int len,
 #else /* !CONFIG_HAS_VPCI */
 struct vpci_vcpu {};
 
-static inline int vpci_add_handlers(struct pci_dev *pdev)
+static inline int vpci_assign_device(struct pci_dev *pdev)
 {
     return 0;
 }
 
-static inline void vpci_remove_device(struct pci_dev *pdev) { }
+static inline void vpci_deassign_device(struct pci_dev *pdev) { }
 
 static inline void vpci_dump_msi(void) { }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 14:00:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 14:00:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686205.1067929 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey0Z-0005lv-FD; Tue, 27 Feb 2024 14:00:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686205.1067929; Tue, 27 Feb 2024 14:00:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey0Z-0005ln-CX; Tue, 27 Feb 2024 14:00:35 +0000
Received: by outflank-mailman (input) for mailman id 686205;
 Tue, 27 Feb 2024 14:00:34 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey0Y-0005lZ-Ll
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey0Y-0001PA-L0
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey0Y-0005m9-Jo
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:34 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=AIeYqi+BvAJ32vLo82grzT4mlQmUE/0AsXV+11aZxl4=; b=ZieuAGMqgId9LnJLIxvVA1ur4R
	qhx+6gP0xIsgXxp3JKS5WTKK/6uO1JrnIdmP0ty0KVTURBClh0eM7Yb4IMpunK5YCKIaUCrFyrLnI
	g9IrTLKFO0Pd3zWSZNAfKBEHcAuFWWM/sFfJjuoP6JGY8JWprGwLXar50JebvvSwoRWc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] vpci/header: rework exit path in init_header()
Message-Id: <E1rey0Y-0005m9-Jo@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 14:00:34 +0000

commit e2628261593b8a1688fa2aaa2049163284c0a918
Author:     Volodymyr Babchuk <volodymyr_babchuk@epam.com>
AuthorDate: Tue Feb 27 14:54:49 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:54:49 2024 +0100

    vpci/header: rework exit path in init_header()
    
    Introduce "fail" label in init_header() function to have the centralized
    error return path. This is the pre-requirement for the future changes
    in this function.
    
    This patch does not introduce functional changes.
    
    Suggested-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Acked-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
---
 xen/drivers/vpci/header.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 2f2d98ada0..803fe4bb99 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -656,10 +656,7 @@ static int cf_check init_header(struct pci_dev *pdev)
             rc = vpci_add_register(pdev->vpci, vpci_hw_read32, bar_write, reg,
                                    4, &bars[i]);
             if ( rc )
-            {
-                pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
-                return rc;
-            }
+                goto fail;
 
             continue;
         }
@@ -679,10 +676,7 @@ static int cf_check init_header(struct pci_dev *pdev)
         rc = pci_size_mem_bar(pdev->sbdf, reg, &addr, &size,
                               (i == num_bars - 1) ? PCI_BAR_LAST : 0);
         if ( rc < 0 )
-        {
-            pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
-            return rc;
-        }
+            goto fail;
 
         if ( size == 0 )
         {
@@ -697,10 +691,7 @@ static int cf_check init_header(struct pci_dev *pdev)
         rc = vpci_add_register(pdev->vpci, vpci_hw_read32, bar_write, reg, 4,
                                &bars[i]);
         if ( rc )
-        {
-            pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
-            return rc;
-        }
+            goto fail;
     }
 
     /* Check expansion ROM. */
@@ -722,6 +713,10 @@ static int cf_check init_header(struct pci_dev *pdev)
     }
 
     return (cmd & PCI_COMMAND_MEMORY) ? modify_bars(pdev, cmd, false) : 0;
+
+ fail:
+    pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
+    return rc;
 }
 REGISTER_VPCI_INIT(init_header, VPCI_PRIORITY_MIDDLE);
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 14:00:45 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 14:00:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686206.1067933 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey0j-0005pY-Gj; Tue, 27 Feb 2024 14:00:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686206.1067933; Tue, 27 Feb 2024 14:00:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey0j-0005pQ-Dz; Tue, 27 Feb 2024 14:00:45 +0000
Received: by outflank-mailman (input) for mailman id 686206;
 Tue, 27 Feb 2024 14:00:44 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey0i-0005pK-Qa
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:44 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey0i-0001PH-Pk
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:44 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey0i-0005mi-N7
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:44 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=162JbqZatWmOzrCeEeeggC0qSkB0oTAXgNqA1gMFTPs=; b=KoRElO4qMcUBQCcD3upKPaXNH3
	YKlZDHv/8UmkfnWtl3TFcDO7e/4yxcmu2T+zVFvElntZ59xatlTV9zKHcvyfWlgKwLKUYzd++T/5S
	yhRBptUgqyN8LW1EBwb7KDl8jvUrjXmHweXM7NKvXcgZzlMhanTeTmOaKlunsyoMzXww=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] vpci/header: implement guest BAR register handlers
Message-Id: <E1rey0i-0005mi-N7@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 14:00:44 +0000

commit 8c5bca70742cffda33c7f69f6a1c8df74397d562
Author:     Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
AuthorDate: Tue Feb 27 14:55:15 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:55:15 2024 +0100

    vpci/header: implement guest BAR register handlers
    
    Add relevant vpci register handlers when assigning PCI device to a domain
    and remove those when de-assigning. This allows having different
    handlers for different domains, e.g. hwdom and other guests.
    
    Emulate guest BAR register values: this allows creating a guest view
    of the registers and emulates size and properties probe as it is done
    during PCI device enumeration by the guest.
    
    All empty, IO and ROM BARs for guests are emulated by returning 0 on
    reads and ignoring writes: this BARs are special with this respect as
    their lower bits have special meaning, so returning default ~0 on read
    may confuse guest OS.
    
    Introduce is_hwdom convenience variable and convert an existing
    is_hardware_domain() check.
    
    Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
---
 xen/drivers/vpci/header.c | 109 +++++++++++++++++++++++++++++++++++++++++++---
 xen/include/xen/vpci.h    |   3 ++
 2 files changed, 106 insertions(+), 6 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 803fe4bb99..39e11e141b 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -478,6 +478,69 @@ static void cf_check bar_write(
     pci_conf_write32(pdev->sbdf, reg, val);
 }
 
+static void cf_check guest_mem_bar_write(const struct pci_dev *pdev,
+                                         unsigned int reg, uint32_t val,
+                                         void *data)
+{
+    struct vpci_bar *bar = data;
+    bool hi = false;
+    uint64_t guest_addr;
+
+    if ( bar->type == VPCI_BAR_MEM64_HI )
+    {
+        ASSERT(reg > PCI_BASE_ADDRESS_0);
+        bar--;
+        hi = true;
+    }
+    else
+    {
+        val &= PCI_BASE_ADDRESS_MEM_MASK;
+    }
+
+    guest_addr = bar->guest_addr;
+    guest_addr &= ~(0xffffffffULL << (hi ? 32 : 0));
+    guest_addr |= (uint64_t)val << (hi ? 32 : 0);
+
+    /* Allow guest to size BAR correctly */
+    guest_addr &= ~(bar->size - 1);
+
+    /*
+     * Xen only cares whether the BAR is mapped into the p2m, so allow BAR
+     * writes as long as the BAR is not mapped into the p2m.
+     */
+    if ( bar->enabled )
+    {
+        /* If the value written is the current one avoid printing a warning. */
+        if ( guest_addr != bar->guest_addr )
+            gprintk(XENLOG_WARNING,
+                    "%pp: ignored guest BAR %zu write while mapped\n",
+                    &pdev->sbdf, bar - pdev->vpci->header.bars + hi);
+        return;
+    }
+    bar->guest_addr = guest_addr;
+}
+
+static uint32_t cf_check guest_mem_bar_read(const struct pci_dev *pdev,
+                                            unsigned int reg, void *data)
+{
+    const struct vpci_bar *bar = data;
+    uint32_t reg_val;
+
+    if ( bar->type == VPCI_BAR_MEM64_HI )
+    {
+        ASSERT(reg > PCI_BASE_ADDRESS_0);
+        bar--;
+        return bar->guest_addr >> 32;
+    }
+
+    reg_val = bar->guest_addr;
+    reg_val |= bar->type == VPCI_BAR_MEM32 ? PCI_BASE_ADDRESS_MEM_TYPE_32 :
+                                             PCI_BASE_ADDRESS_MEM_TYPE_64;
+    reg_val |= bar->prefetchable ? PCI_BASE_ADDRESS_MEM_PREFETCH : 0;
+
+    return reg_val;
+}
+
 static void cf_check rom_write(
     const struct pci_dev *pdev, unsigned int reg, uint32_t val, void *data)
 {
@@ -539,6 +602,7 @@ static int cf_check init_header(struct pci_dev *pdev)
     struct vpci_bar *bars = header->bars;
     int rc;
     bool mask_cap_list = false;
+    bool is_hwdom = is_hardware_domain(pdev->domain);
 
     ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
 
@@ -564,7 +628,7 @@ static int cf_check init_header(struct pci_dev *pdev)
     if ( rc )
         return rc;
 
-    if ( !is_hardware_domain(pdev->domain) )
+    if ( !is_hwdom )
     {
         if ( pci_conf_read16(pdev->sbdf, PCI_STATUS) & PCI_STATUS_CAP_LIST )
         {
@@ -653,8 +717,11 @@ static int cf_check init_header(struct pci_dev *pdev)
         if ( i && bars[i - 1].type == VPCI_BAR_MEM64_LO )
         {
             bars[i].type = VPCI_BAR_MEM64_HI;
-            rc = vpci_add_register(pdev->vpci, vpci_hw_read32, bar_write, reg,
-                                   4, &bars[i]);
+            rc = vpci_add_register(pdev->vpci,
+                                   is_hwdom ? vpci_hw_read32
+                                            : guest_mem_bar_read,
+                                   is_hwdom ? bar_write : guest_mem_bar_write,
+                                   reg, 4, &bars[i]);
             if ( rc )
                 goto fail;
 
@@ -665,6 +732,14 @@ static int cf_check init_header(struct pci_dev *pdev)
         if ( (val & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO )
         {
             bars[i].type = VPCI_BAR_IO;
+            if ( !IS_ENABLED(CONFIG_X86) && !is_hwdom )
+            {
+                rc = vpci_add_register(pdev->vpci, vpci_read_val, NULL,
+                                       reg, 4, (void *)0);
+                if ( rc )
+                    goto fail;
+            }
+
             continue;
         }
         if ( (val & PCI_BASE_ADDRESS_MEM_TYPE_MASK) ==
@@ -681,6 +756,15 @@ static int cf_check init_header(struct pci_dev *pdev)
         if ( size == 0 )
         {
             bars[i].type = VPCI_BAR_EMPTY;
+
+            if ( !is_hwdom )
+            {
+                rc = vpci_add_register(pdev->vpci, vpci_read_val, NULL,
+                                       reg, 4, (void *)0);
+                if ( rc )
+                    goto fail;
+            }
+
             continue;
         }
 
@@ -688,14 +772,18 @@ static int cf_check init_header(struct pci_dev *pdev)
         bars[i].size = size;
         bars[i].prefetchable = val & PCI_BASE_ADDRESS_MEM_PREFETCH;
 
-        rc = vpci_add_register(pdev->vpci, vpci_hw_read32, bar_write, reg, 4,
-                               &bars[i]);
+        rc = vpci_add_register(pdev->vpci,
+                               is_hwdom ? vpci_hw_read32 : guest_mem_bar_read,
+                               is_hwdom ? bar_write : guest_mem_bar_write,
+                               reg, 4, &bars[i]);
         if ( rc )
             goto fail;
     }
 
     /* Check expansion ROM. */
-    rc = pci_size_mem_bar(pdev->sbdf, rom_reg, &addr, &size, PCI_BAR_ROM);
+    rc = is_hwdom ? pci_size_mem_bar(pdev->sbdf, rom_reg, &addr, &size,
+                                     PCI_BAR_ROM)
+                  : 0;
     if ( rc > 0 && size )
     {
         struct vpci_bar *rom = &header->bars[num_bars];
@@ -711,6 +799,15 @@ static int cf_check init_header(struct pci_dev *pdev)
         if ( rc )
             rom->type = VPCI_BAR_EMPTY;
     }
+    else if ( !is_hwdom )
+    {
+        /* TODO: Check expansion ROM, we do not handle ROM for guests for now */
+        header->bars[num_bars].type = VPCI_BAR_EMPTY;
+        rc = vpci_add_register(pdev->vpci, vpci_read_val, NULL,
+                               rom_reg, 4, (void *)0);
+        if ( rc )
+            goto fail;
+    }
 
     return (cmd & PCI_COMMAND_MEMORY) ? modify_bars(pdev, cmd, false) : 0;
 
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index 99fe76f08a..b0e38a5a1a 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -87,7 +87,10 @@ struct vpci {
     struct vpci_header {
         /* Information about the PCI BARs of this device. */
         struct vpci_bar {
+            /* Physical (host) address. */
             uint64_t addr;
+            /* Guest address. */
+            uint64_t guest_addr;
             uint64_t size;
             enum {
                 VPCI_BAR_EMPTY,
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 14:00:55 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 14:00:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686207.1067938 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey0t-0005t6-IW; Tue, 27 Feb 2024 14:00:55 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686207.1067938; Tue, 27 Feb 2024 14:00:55 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey0t-0005sy-FT; Tue, 27 Feb 2024 14:00:55 +0000
Received: by outflank-mailman (input) for mailman id 686207;
 Tue, 27 Feb 2024 14:00:54 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey0s-0005ss-Td
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:54 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey0s-0001PP-Sm
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:54 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey0s-0005nq-Rv
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:00:54 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=o7oUE0h/m/VEKenkLPSnRY3IEXMMI24WI+NPZRGwjcE=; b=mGeB3B+S6qWAI96bXM7O8+tfHS
	ljJ72ETLpcpfwc6uLUUlyEuGRVx0dVwIbflhHLGAQBRctZ54Cero4P1e09wWUD9DL//zZjVlnaX3s
	G4HDJ9FDjXDCEVlSdHCZz9w1uJfg1tFxOGIKcXE3IwOR6lyntkrVs4rmz2p4Ex6luGRQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] rangeset: add RANGESETF_no_print flag
Message-Id: <E1rey0s-0005nq-Rv@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 14:00:54 +0000

commit fe62abfcb28aaf83a9c74b3f4a64a6bb3cd6c998
Author:     Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
AuthorDate: Tue Feb 27 14:55:42 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:55:42 2024 +0100

    rangeset: add RANGESETF_no_print flag
    
    There are range sets which should not be printed, so introduce a flag
    which allows marking those as such. Implement relevant logic to skip
    such entries while printing.
    
    While at it also simplify the definition of the flags by directly
    defining those without helpers.
    
    Suggested-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
---
 xen/common/rangeset.c      | 5 ++++-
 xen/include/xen/rangeset.h | 5 +++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/xen/common/rangeset.c b/xen/common/rangeset.c
index 16a4c3b842..0ccd53caac 100644
--- a/xen/common/rangeset.c
+++ b/xen/common/rangeset.c
@@ -433,7 +433,7 @@ struct rangeset *rangeset_new(
     INIT_LIST_HEAD(&r->range_list);
     r->nr_ranges = -1;
 
-    BUG_ON(flags & ~RANGESETF_prettyprint_hex);
+    BUG_ON(flags & ~(RANGESETF_prettyprint_hex | RANGESETF_no_print));
     r->flags = flags;
 
     safe_strcpy(r->name, name ?: "(no name)");
@@ -575,6 +575,9 @@ void rangeset_domain_printk(
 
     list_for_each_entry ( r, &d->rangesets, rangeset_list )
     {
+        if ( r->flags & RANGESETF_no_print )
+            continue;
+
         printk("    ");
         rangeset_printk(r);
         printk("\n");
diff --git a/xen/include/xen/rangeset.h b/xen/include/xen/rangeset.h
index 8be0722787..87bd956962 100644
--- a/xen/include/xen/rangeset.h
+++ b/xen/include/xen/rangeset.h
@@ -49,8 +49,9 @@ void rangeset_limit(
 
 /* Flags for passing to rangeset_new(). */
  /* Pretty-print range limits in hexadecimal. */
-#define _RANGESETF_prettyprint_hex 0
-#define RANGESETF_prettyprint_hex  (1U << _RANGESETF_prettyprint_hex)
+#define RANGESETF_prettyprint_hex   (1U << 0)
+ /* Do not print entries marked with this flag. */
+#define RANGESETF_no_print          (1U << 1)
 
 bool __must_check rangeset_is_empty(
     const struct rangeset *r);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 14:01:06 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 14:01:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686208.1067942 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey14-0005y2-M9; Tue, 27 Feb 2024 14:01:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686208.1067942; Tue, 27 Feb 2024 14:01:06 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey14-0005xv-IX; Tue, 27 Feb 2024 14:01:06 +0000
Received: by outflank-mailman (input) for mailman id 686208;
 Tue, 27 Feb 2024 14:01:05 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey13-0005xf-25
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:05 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey13-0001Pl-1L
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey12-0005pa-Uv
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=nddbk1PpH/LmbSWf4K38EOV8oLNLBg7pHe8gWqChm9c=; b=RMzGKFtpEjZ4FhI+KrOWddrcwg
	MwkciESAl2VJMLU9VwCQFpgvLssLgWXN+D84hzuNJB2Bl0Dtnj954T/h2w85eYfAP3U5K/wEmJc1x
	SCo8X4HhFLMVXPVhw2Bqg6fMdQNndXjVWpqTWrpn5Pc/uSo51mcbaNlGunXojP7a6rnY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] rangeset: add rangeset_purge() function
Message-Id: <E1rey12-0005pa-Uv@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 14:01:04 +0000

commit 99eeb2eb0b69b65c58e67f669e02004d12ca24f0
Author:     Volodymyr Babchuk <volodymyr_babchuk@epam.com>
AuthorDate: Tue Feb 27 14:56:19 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:56:19 2024 +0100

    rangeset: add rangeset_purge() function
    
    This function can be used when user wants to remove all rangeset
    entries but do not want to destroy rangeset itself.
    
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/common/rangeset.c      | 16 ++++++++++++----
 xen/include/xen/rangeset.h |  3 ++-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/xen/common/rangeset.c b/xen/common/rangeset.c
index 0ccd53caac..b75590f907 100644
--- a/xen/common/rangeset.c
+++ b/xen/common/rangeset.c
@@ -448,11 +448,20 @@ struct rangeset *rangeset_new(
     return r;
 }
 
-void rangeset_destroy(
-    struct rangeset *r)
+void rangeset_purge(struct rangeset *r)
 {
     struct range *x;
 
+    if ( r == NULL )
+        return;
+
+    while ( (x = first_range(r)) != NULL )
+        destroy_range(r, x);
+}
+
+void rangeset_destroy(
+    struct rangeset *r)
+{
     if ( r == NULL )
         return;
 
@@ -463,8 +472,7 @@ void rangeset_destroy(
         spin_unlock(&r->domain->rangesets_lock);
     }
 
-    while ( (x = first_range(r)) != NULL )
-        destroy_range(r, x);
+    rangeset_purge(r);
 
     xfree(r);
 }
diff --git a/xen/include/xen/rangeset.h b/xen/include/xen/rangeset.h
index 87bd956962..96c9180825 100644
--- a/xen/include/xen/rangeset.h
+++ b/xen/include/xen/rangeset.h
@@ -56,7 +56,7 @@ void rangeset_limit(
 bool __must_check rangeset_is_empty(
     const struct rangeset *r);
 
-/* Add/claim/remove/query a numeric range. */
+/* Add/claim/remove/query/purge a numeric range. */
 int __must_check rangeset_add_range(
     struct rangeset *r, unsigned long s, unsigned long e);
 int __must_check rangeset_claim_range(struct rangeset *r, unsigned long size,
@@ -70,6 +70,7 @@ bool __must_check rangeset_overlaps_range(
 int rangeset_report_ranges(
     struct rangeset *r, unsigned long s, unsigned long e,
     int (*cb)(unsigned long s, unsigned long e, void *data), void *ctxt);
+void rangeset_purge(struct rangeset *r);
 
 /*
  * Note that the consume function can return an error value apart from
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 14:01:16 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 14:01:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686209.1067946 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey1E-00061Q-OH; Tue, 27 Feb 2024 14:01:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686209.1067946; Tue, 27 Feb 2024 14:01:16 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey1E-00061H-KF; Tue, 27 Feb 2024 14:01:16 +0000
Received: by outflank-mailman (input) for mailman id 686209;
 Tue, 27 Feb 2024 14:01:15 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey1D-000614-57
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:15 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey1D-0001Py-4D
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:15 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey1D-0005qU-3X
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:15 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=XOCyjDGKP//paI0c+t9j80fnu814Ky7Axb8i85kW9Tk=; b=kNHY/tV7nxXKQ3VpSlIRdKJAeu
	+2WusBFGIbR2kNONcJ0gmQJCf4HH7OAMspYnyVpOp4yUAl2I9erwE47KhSBQwhhzn/JkYHpJOh0/Y
	2HhO7an41hvPUAtehpjHFNgDBM8kxGAJtwwUK9mjQeekIcamEkR+2iNmzpJHyMDJqj68=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] vpci/header: handle p2m range sets per BAR
Message-Id: <E1rey1D-0005qU-3X@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 14:01:15 +0000

commit 622bdd9628221fa8aa20fff534c4f500973ee0ff
Author:     Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
AuthorDate: Tue Feb 27 14:56:48 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:56:48 2024 +0100

    vpci/header: handle p2m range sets per BAR
    
    Instead of handling a single range set, that contains all the memory
    regions of all the BARs and ROM, have them per BAR.
    As the range sets are now created when a PCI device is added and destroyed
    when it is removed so make them named and accounted.
    
    Note that rangesets were chosen here despite there being only up to
    3 separate ranges in each set (typically just 1). But rangeset per BAR
    was chosen for the ease of implementation and existing code re-usability.
    
    Also note that error handling of vpci_process_pending() is slightly
    modified, and that vPCI handlers are no longer removed if the creation
    of the mappings in vpci_process_pending() fails, as that's unlikely to
    lead to a functional device in any case.
    
    This is in preparation of making non-identity mappings in p2m for the MMIOs.
    
    Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
---
 xen/drivers/vpci/header.c | 257 ++++++++++++++++++++++++++++++++--------------
 xen/drivers/vpci/vpci.c   |   6 ++
 xen/include/xen/vpci.h    |   2 +-
 3 files changed, 185 insertions(+), 80 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 39e11e141b..feccd070dd 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -162,63 +162,107 @@ static void modify_decoding(const struct pci_dev *pdev, uint16_t cmd,
 
 bool vpci_process_pending(struct vcpu *v)
 {
-    if ( v->vpci.mem )
+    struct pci_dev *pdev = v->vpci.pdev;
+    struct map_data data = {
+        .d = v->domain,
+        .map = v->vpci.cmd & PCI_COMMAND_MEMORY,
+    };
+    struct vpci_header *header = NULL;
+    unsigned int i;
+
+    if ( !pdev )
+        return false;
+
+    read_lock(&v->domain->pci_lock);
+
+    if ( !pdev->vpci || (v->domain != pdev->domain) )
     {
-        struct map_data data = {
-            .d = v->domain,
-            .map = v->vpci.cmd & PCI_COMMAND_MEMORY,
-        };
-        int rc = rangeset_consume_ranges(v->vpci.mem, map_range, &data);
+        v->vpci.pdev = NULL;
+        read_unlock(&v->domain->pci_lock);
+        return false;
+    }
+
+    header = &pdev->vpci->header;
+    for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
+    {
+        struct vpci_bar *bar = &header->bars[i];
+        int rc;
+
+        if ( rangeset_is_empty(bar->mem) )
+            continue;
+
+        rc = rangeset_consume_ranges(bar->mem, map_range, &data);
 
         if ( rc == -ERESTART )
+        {
+            read_unlock(&v->domain->pci_lock);
             return true;
+        }
 
-        write_lock(&v->domain->pci_lock);
-        spin_lock(&v->vpci.pdev->vpci->lock);
-        /* Disable memory decoding unconditionally on failure. */
-        modify_decoding(v->vpci.pdev,
-                        rc ? v->vpci.cmd & ~PCI_COMMAND_MEMORY : v->vpci.cmd,
-                        !rc && v->vpci.rom_only);
-        spin_unlock(&v->vpci.pdev->vpci->lock);
-
-        rangeset_destroy(v->vpci.mem);
-        v->vpci.mem = NULL;
         if ( rc )
-            /*
-             * FIXME: in case of failure remove the device from the domain.
-             * Note that there might still be leftover mappings. While this is
-             * safe for Dom0, for DomUs the domain will likely need to be
-             * killed in order to avoid leaking stale p2m mappings on
-             * failure.
-             */
-            vpci_deassign_device(v->vpci.pdev);
-        write_unlock(&v->domain->pci_lock);
+        {
+            spin_lock(&pdev->vpci->lock);
+            /* Disable memory decoding unconditionally on failure. */
+            modify_decoding(pdev, v->vpci.cmd & ~PCI_COMMAND_MEMORY,
+                            false);
+            spin_unlock(&pdev->vpci->lock);
+
+            /* Clean all the rangesets */
+            for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
+                if ( !rangeset_is_empty(header->bars[i].mem) )
+                     rangeset_purge(header->bars[i].mem);
+
+            v->vpci.pdev = NULL;
+
+            read_unlock(&v->domain->pci_lock);
+
+            if ( !is_hardware_domain(v->domain) )
+                domain_crash(v->domain);
+
+            return false;
+        }
     }
+    v->vpci.pdev = NULL;
+
+    spin_lock(&pdev->vpci->lock);
+    modify_decoding(pdev, v->vpci.cmd, v->vpci.rom_only);
+    spin_unlock(&pdev->vpci->lock);
+
+    read_unlock(&v->domain->pci_lock);
 
     return false;
 }
 
 static int __init apply_map(struct domain *d, const struct pci_dev *pdev,
-                            struct rangeset *mem, uint16_t cmd)
+                            uint16_t cmd)
 {
     struct map_data data = { .d = d, .map = true };
-    int rc;
+    struct vpci_header *header = &pdev->vpci->header;
+    int rc = 0;
+    unsigned int i;
 
     ASSERT(rw_is_write_locked(&d->pci_lock));
 
-    while ( (rc = rangeset_consume_ranges(mem, map_range, &data)) == -ERESTART )
+    for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
     {
-        /*
-         * It's safe to drop and reacquire the lock in this context
-         * without risking pdev disappearing because devices cannot be
-         * removed until the initial domain has been started.
-         */
-        write_unlock(&d->pci_lock);
-        process_pending_softirqs();
-        write_lock(&d->pci_lock);
-    }
+        struct vpci_bar *bar = &header->bars[i];
 
-    rangeset_destroy(mem);
+        if ( rangeset_is_empty(bar->mem) )
+            continue;
+
+        while ( (rc = rangeset_consume_ranges(bar->mem, map_range,
+                                              &data)) == -ERESTART )
+        {
+            /*
+             * It's safe to drop and reacquire the lock in this context
+             * without risking pdev disappearing because devices cannot be
+             * removed until the initial domain has been started.
+             */
+            write_unlock(&d->pci_lock);
+            process_pending_softirqs();
+            write_lock(&d->pci_lock);
+        }
+    }
     if ( !rc )
         modify_decoding(pdev, cmd, false);
 
@@ -226,7 +270,7 @@ static int __init apply_map(struct domain *d, const struct pci_dev *pdev,
 }
 
 static void defer_map(struct domain *d, struct pci_dev *pdev,
-                      struct rangeset *mem, uint16_t cmd, bool rom_only)
+                      uint16_t cmd, bool rom_only)
 {
     struct vcpu *curr = current;
 
@@ -237,7 +281,6 @@ static void defer_map(struct domain *d, struct pci_dev *pdev,
      * started for the same device if the domain is not well-behaved.
      */
     curr->vpci.pdev = pdev;
-    curr->vpci.mem = mem;
     curr->vpci.cmd = cmd;
     curr->vpci.rom_only = rom_only;
     /*
@@ -251,33 +294,33 @@ static void defer_map(struct domain *d, struct pci_dev *pdev,
 static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
 {
     struct vpci_header *header = &pdev->vpci->header;
-    struct rangeset *mem = rangeset_new(NULL, NULL, 0);
     struct pci_dev *tmp, *dev = NULL;
     const struct domain *d;
     const struct vpci_msix *msix = pdev->vpci->msix;
-    unsigned int i;
+    unsigned int i, j;
     int rc;
 
     ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
 
-    if ( !mem )
-        return -ENOMEM;
-
     /*
-     * Create a rangeset that represents the current device BARs memory region
-     * and compare it against all the currently active BAR memory regions. If
-     * an overlap is found, subtract it from the region to be mapped/unmapped.
+     * Create a rangeset per BAR that represents the current device memory
+     * region and compare it against all the currently active BAR memory
+     * regions. If an overlap is found, subtract it from the region to be
+     * mapped/unmapped.
      *
-     * First fill the rangeset with all the BARs of this device or with the ROM
+     * First fill the rangesets with the BAR of this device or with the ROM
      * BAR only, depending on whether the guest is toggling the memory decode
      * bit of the command register, or the enable bit of the ROM BAR register.
      */
     for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
     {
-        const struct vpci_bar *bar = &header->bars[i];
+        struct vpci_bar *bar = &header->bars[i];
         unsigned long start = PFN_DOWN(bar->addr);
         unsigned long end = PFN_DOWN(bar->addr + bar->size - 1);
 
+        if ( !bar->mem )
+            continue;
+
         if ( !MAPPABLE_BAR(bar) ||
              (rom_only ? bar->type != VPCI_BAR_ROM
                        : (bar->type == VPCI_BAR_ROM && !header->rom_enabled)) ||
@@ -293,14 +336,31 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
             continue;
         }
 
-        rc = rangeset_add_range(mem, start, end);
+        rc = rangeset_add_range(bar->mem, start, end);
         if ( rc )
         {
             printk(XENLOG_G_WARNING "Failed to add [%lx, %lx]: %d\n",
                    start, end, rc);
-            rangeset_destroy(mem);
             return rc;
         }
+
+        /* Check for overlap with the already setup BAR ranges. */
+        for ( j = 0; j < i; j++ )
+        {
+            struct vpci_bar *prev_bar = &header->bars[j];
+
+            if ( rangeset_is_empty(prev_bar->mem) )
+                continue;
+
+            rc = rangeset_remove_range(prev_bar->mem, start, end);
+            if ( rc )
+            {
+                gprintk(XENLOG_WARNING,
+                       "%pp: failed to remove overlapping range [%lx, %lx]: %d\n",
+                        &pdev->sbdf, start, end, rc);
+                return rc;
+            }
+        }
     }
 
     /* Remove any MSIX regions if present. */
@@ -310,14 +370,21 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
         unsigned long end = PFN_DOWN(vmsix_table_addr(pdev->vpci, i) +
                                      vmsix_table_size(pdev->vpci, i) - 1);
 
-        rc = rangeset_remove_range(mem, start, end);
-        if ( rc )
+        for ( j = 0; j < ARRAY_SIZE(header->bars); j++ )
         {
-            printk(XENLOG_G_WARNING
-                   "Failed to remove MSIX table [%lx, %lx]: %d\n",
-                   start, end, rc);
-            rangeset_destroy(mem);
-            return rc;
+            const struct vpci_bar *bar = &header->bars[j];
+
+            if ( rangeset_is_empty(bar->mem) )
+                continue;
+
+            rc = rangeset_remove_range(bar->mem, start, end);
+            if ( rc )
+            {
+                gprintk(XENLOG_WARNING,
+                       "%pp: failed to remove MSIX table [%lx, %lx]: %d\n",
+                        &pdev->sbdf, start, end, rc);
+                return rc;
+            }
         }
     }
 
@@ -357,27 +424,37 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
 
             for ( i = 0; i < ARRAY_SIZE(tmp->vpci->header.bars); i++ )
             {
-                const struct vpci_bar *bar = &tmp->vpci->header.bars[i];
-                unsigned long start = PFN_DOWN(bar->addr);
-                unsigned long end = PFN_DOWN(bar->addr + bar->size - 1);
-
-                if ( !bar->enabled ||
-                     !rangeset_overlaps_range(mem, start, end) ||
-                     /*
-                      * If only the ROM enable bit is toggled check against
-                      * other BARs in the same device for overlaps, but not
-                      * against the same ROM BAR.
-                      */
-                     (rom_only && tmp == pdev && bar->type == VPCI_BAR_ROM) )
+                const struct vpci_bar *remote_bar = &tmp->vpci->header.bars[i];
+                unsigned long start = PFN_DOWN(remote_bar->addr);
+                unsigned long end = PFN_DOWN(remote_bar->addr +
+                                             remote_bar->size - 1);
+
+                if ( !remote_bar->enabled )
                     continue;
 
-                rc = rangeset_remove_range(mem, start, end);
-                if ( rc )
+                for ( j = 0; j < ARRAY_SIZE(header->bars); j++)
                 {
-                    printk(XENLOG_G_WARNING "Failed to remove [%lx, %lx]: %d\n",
-                           start, end, rc);
-                    rangeset_destroy(mem);
-                    return rc;
+                    const struct vpci_bar *bar = &header->bars[j];
+
+                    if ( !rangeset_overlaps_range(bar->mem, start, end) ||
+                         /*
+                          * If only the ROM enable bit is toggled check against
+                          * other BARs in the same device for overlaps, but not
+                          * against the same ROM BAR.
+                          */
+                         (rom_only &&
+                          tmp == pdev &&
+                          bar->type == VPCI_BAR_ROM) )
+                        continue;
+
+                    rc = rangeset_remove_range(bar->mem, start, end);
+                    if ( rc )
+                    {
+                        gprintk(XENLOG_WARNING,
+                                "%pp: failed to remove [%lx, %lx]: %d\n",
+                                &pdev->sbdf, start, end, rc);
+                        return rc;
+                    }
                 }
             }
         }
@@ -401,10 +478,10 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
          * will always be to establish mappings and process all the BARs.
          */
         ASSERT((cmd & PCI_COMMAND_MEMORY) && !rom_only);
-        return apply_map(pdev->domain, pdev, mem, cmd);
+        return apply_map(pdev->domain, pdev, cmd);
     }
 
-    defer_map(dev->domain, dev, mem, cmd, rom_only);
+    defer_map(dev->domain, dev, cmd, rom_only);
 
     return 0;
 }
@@ -593,6 +670,18 @@ static void cf_check rom_write(
         rom->addr = val & PCI_ROM_ADDRESS_MASK;
 }
 
+static int bar_add_rangeset(const struct pci_dev *pdev, struct vpci_bar *bar,
+                            unsigned int i)
+{
+    char str[32];
+
+    snprintf(str, sizeof(str), "%pp:BAR%u", &pdev->sbdf, i);
+
+    bar->mem = rangeset_new(pdev->domain, str, RANGESETF_no_print);
+
+    return !bar->mem ? -ENOMEM : 0;
+}
+
 static int cf_check init_header(struct pci_dev *pdev)
 {
     uint16_t cmd;
@@ -748,6 +837,10 @@ static int cf_check init_header(struct pci_dev *pdev)
         else
             bars[i].type = VPCI_BAR_MEM32;
 
+        rc = bar_add_rangeset(pdev, &bars[i], i);
+        if ( rc )
+            goto fail;
+
         rc = pci_size_mem_bar(pdev->sbdf, reg, &addr, &size,
                               (i == num_bars - 1) ? PCI_BAR_LAST : 0);
         if ( rc < 0 )
@@ -798,6 +891,12 @@ static int cf_check init_header(struct pci_dev *pdev)
                                4, rom);
         if ( rc )
             rom->type = VPCI_BAR_EMPTY;
+        else
+        {
+            rc = bar_add_rangeset(pdev, rom, num_bars);
+            if ( rc )
+                goto fail;
+        }
     }
     else if ( !is_hwdom )
     {
diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index ff48373917..260b72875e 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -42,6 +42,8 @@ extern vpci_register_init_t *const __end_vpci_array[];
 
 void vpci_deassign_device(struct pci_dev *pdev)
 {
+    unsigned int i;
+
     ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
 
     if ( !has_vpci(pdev->domain) || !pdev->vpci )
@@ -67,6 +69,10 @@ void vpci_deassign_device(struct pci_dev *pdev)
             if ( pdev->vpci->msix->table[i] )
                 iounmap(pdev->vpci->msix->table[i]);
     }
+
+    for ( i = 0; i < ARRAY_SIZE(pdev->vpci->header.bars); i++ )
+        rangeset_destroy(pdev->vpci->header.bars[i].mem);
+
     xfree(pdev->vpci->msix);
     xfree(pdev->vpci->msi);
     xfree(pdev->vpci);
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index b0e38a5a1a..817ee9ee73 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -92,6 +92,7 @@ struct vpci {
             /* Guest address. */
             uint64_t guest_addr;
             uint64_t size;
+            struct rangeset *mem;
             enum {
                 VPCI_BAR_EMPTY,
                 VPCI_BAR_IO,
@@ -176,7 +177,6 @@ struct vpci {
 
 struct vpci_vcpu {
     /* Per-vcpu structure to store state while {un}mapping of PCI BARs. */
-    struct rangeset *mem;
     struct pci_dev *pdev;
     uint16_t cmd;
     bool rom_only : 1;
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 14:01:26 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 14:01:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686210.1067949 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey1O-00064k-PL; Tue, 27 Feb 2024 14:01:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686210.1067949; Tue, 27 Feb 2024 14:01:26 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey1O-00064d-MB; Tue, 27 Feb 2024 14:01:26 +0000
Received: by outflank-mailman (input) for mailman id 686210;
 Tue, 27 Feb 2024 14:01:25 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey1N-00063U-7w
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:25 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey1N-0001QR-77
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:25 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey1N-0005rM-6P
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:25 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ny9LX/P3UmExtbZ73iy3mcf2bbXkNjl3q+8pdppTNW4=; b=bjHV4iaZ7qEbf2pw1eeM3GBbcw
	QGep/H0FlFS048+RN7YXOPtFNN3NrKWFoO7HBGEjGNlPUkRs7WMwanvcQzFZJPzYSc5YxCKpb87dF
	jhCS8gm9afxLzP8FQg5o8aPQYiN4POLb6f65cW7b918HZuokzaVPOVPbE1bfIAZu6t98=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] vpci/header: program p2m with guest BAR view
Message-Id: <E1rey1N-0005rM-6P@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 14:01:25 +0000

commit 52ebde3cfae240e708571742eb7b6942efbd42a2
Author:     Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
AuthorDate: Tue Feb 27 14:57:16 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:57:16 2024 +0100

    vpci/header: program p2m with guest BAR view
    
    Take into account guest's BAR view and program its p2m accordingly:
    gfn is guest's view of the BAR and mfn is the physical BAR value.
    This way hardware domain sees physical BAR values and guest sees
    emulated ones.
    
    Hardware domain continues getting the BARs identity mapped, while for
    domUs the BARs are mapped at the requested guest address without
    modifying the BAR address in the device PCI config space.
    
    Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/vpci/header.c | 83 ++++++++++++++++++++++++++++++++++++-----------
 xen/include/xen/vpci.h    |  3 +-
 2 files changed, 66 insertions(+), 20 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index feccd070dd..47648c3951 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -34,6 +34,7 @@
 
 struct map_data {
     struct domain *d;
+    const struct vpci_bar *bar;
     bool map;
 };
 
@@ -41,26 +42,37 @@ static int cf_check map_range(
     unsigned long s, unsigned long e, void *data, unsigned long *c)
 {
     const struct map_data *map = data;
+    /* Start address of the BAR as seen by the guest. */
+    unsigned long start_gfn = PFN_DOWN(map->bar->guest_addr);
+    /* Physical start address of the BAR. */
+    unsigned long start_mfn = PFN_DOWN(map->bar->addr);
     int rc;
 
     for ( ; ; )
     {
         unsigned long size = e - s + 1;
+        /*
+         * Ranges to be mapped don't always start at the BAR start address, as
+         * there can be holes or partially consumed ranges. Account for the
+         * offset of the current address from the BAR start.
+         */
+        unsigned long map_mfn = start_mfn + s - start_gfn;
+        unsigned long m_end = map_mfn + size - 1;
 
-        if ( !iomem_access_permitted(map->d, s, e) )
+        if ( !iomem_access_permitted(map->d, map_mfn, m_end) )
         {
             printk(XENLOG_G_WARNING
                    "%pd denied access to MMIO range [%#lx, %#lx]\n",
-                   map->d, s, e);
+                   map->d, map_mfn, m_end);
             return -EPERM;
         }
 
-        rc = xsm_iomem_mapping(XSM_HOOK, map->d, s, e, map->map);
+        rc = xsm_iomem_mapping(XSM_HOOK, map->d, map_mfn, m_end, map->map);
         if ( rc )
         {
             printk(XENLOG_G_WARNING
                    "%pd XSM denied access to MMIO range [%#lx, %#lx]: %d\n",
-                   map->d, s, e, rc);
+                   map->d, map_mfn, m_end, rc);
             return rc;
         }
 
@@ -73,8 +85,8 @@ static int cf_check map_range(
          * - {un}map_mmio_regions doesn't support preemption.
          */
 
-        rc = map->map ? map_mmio_regions(map->d, _gfn(s), size, _mfn(s))
-                      : unmap_mmio_regions(map->d, _gfn(s), size, _mfn(s));
+        rc = map->map ? map_mmio_regions(map->d, _gfn(s), size, _mfn(map_mfn))
+                      : unmap_mmio_regions(map->d, _gfn(s), size, _mfn(map_mfn));
         if ( rc == 0 )
         {
             *c += size;
@@ -83,8 +95,9 @@ static int cf_check map_range(
         if ( rc < 0 )
         {
             printk(XENLOG_G_WARNING
-                   "Failed to identity %smap [%lx, %lx] for d%d: %d\n",
-                   map->map ? "" : "un", s, e, map->d->domain_id, rc);
+                   "Failed to %smap [%lx %lx] -> [%lx %lx] for %pd: %d\n",
+                   map->map ? "" : "un", s, e, map_mfn,
+                   map_mfn + size, map->d, rc);
             break;
         }
         ASSERT(rc < size);
@@ -163,10 +176,6 @@ static void modify_decoding(const struct pci_dev *pdev, uint16_t cmd,
 bool vpci_process_pending(struct vcpu *v)
 {
     struct pci_dev *pdev = v->vpci.pdev;
-    struct map_data data = {
-        .d = v->domain,
-        .map = v->vpci.cmd & PCI_COMMAND_MEMORY,
-    };
     struct vpci_header *header = NULL;
     unsigned int i;
 
@@ -186,6 +195,11 @@ bool vpci_process_pending(struct vcpu *v)
     for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
     {
         struct vpci_bar *bar = &header->bars[i];
+        struct map_data data = {
+            .d = v->domain,
+            .map = v->vpci.cmd & PCI_COMMAND_MEMORY,
+            .bar = bar,
+        };
         int rc;
 
         if ( rangeset_is_empty(bar->mem) )
@@ -236,7 +250,6 @@ bool vpci_process_pending(struct vcpu *v)
 static int __init apply_map(struct domain *d, const struct pci_dev *pdev,
                             uint16_t cmd)
 {
-    struct map_data data = { .d = d, .map = true };
     struct vpci_header *header = &pdev->vpci->header;
     int rc = 0;
     unsigned int i;
@@ -246,6 +259,7 @@ static int __init apply_map(struct domain *d, const struct pci_dev *pdev,
     for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
     {
         struct vpci_bar *bar = &header->bars[i];
+        struct map_data data = { .d = d, .map = true, .bar = bar };
 
         if ( rangeset_is_empty(bar->mem) )
             continue;
@@ -311,12 +325,16 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
      * First fill the rangesets with the BAR of this device or with the ROM
      * BAR only, depending on whether the guest is toggling the memory decode
      * bit of the command register, or the enable bit of the ROM BAR register.
+     *
+     * For non-hardware domain we use guest physical addresses.
      */
     for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
     {
         struct vpci_bar *bar = &header->bars[i];
         unsigned long start = PFN_DOWN(bar->addr);
         unsigned long end = PFN_DOWN(bar->addr + bar->size - 1);
+        unsigned long start_guest = PFN_DOWN(bar->guest_addr);
+        unsigned long end_guest = PFN_DOWN(bar->guest_addr + bar->size - 1);
 
         if ( !bar->mem )
             continue;
@@ -336,11 +354,26 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
             continue;
         }
 
-        rc = rangeset_add_range(bar->mem, start, end);
+        ASSERT(rangeset_is_empty(bar->mem));
+
+        /*
+         * Make sure that the guest set address has the same page offset
+         * as the physical address on the host or otherwise things won't work as
+         * expected.
+         */
+        if ( PAGE_OFFSET(bar->guest_addr) != PAGE_OFFSET(bar->addr) )
+        {
+            gprintk(XENLOG_G_WARNING,
+                    "%pp: can't map BAR%u - offset mismatch: %#lx vs %#lx\n",
+                    &pdev->sbdf, i, bar->guest_addr, bar->addr);
+            return -EINVAL;
+        }
+
+        rc = rangeset_add_range(bar->mem, start_guest, end_guest);
         if ( rc )
         {
             printk(XENLOG_G_WARNING "Failed to add [%lx, %lx]: %d\n",
-                   start, end, rc);
+                   start_guest, end_guest, rc);
             return rc;
         }
 
@@ -352,12 +385,12 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
             if ( rangeset_is_empty(prev_bar->mem) )
                 continue;
 
-            rc = rangeset_remove_range(prev_bar->mem, start, end);
+            rc = rangeset_remove_range(prev_bar->mem, start_guest, end_guest);
             if ( rc )
             {
                 gprintk(XENLOG_WARNING,
                        "%pp: failed to remove overlapping range [%lx, %lx]: %d\n",
-                        &pdev->sbdf, start, end, rc);
+                        &pdev->sbdf, start_guest, end_guest, rc);
                 return rc;
             }
         }
@@ -425,8 +458,8 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
             for ( i = 0; i < ARRAY_SIZE(tmp->vpci->header.bars); i++ )
             {
                 const struct vpci_bar *remote_bar = &tmp->vpci->header.bars[i];
-                unsigned long start = PFN_DOWN(remote_bar->addr);
-                unsigned long end = PFN_DOWN(remote_bar->addr +
+                unsigned long start = PFN_DOWN(remote_bar->guest_addr);
+                unsigned long end = PFN_DOWN(remote_bar->guest_addr +
                                              remote_bar->size - 1);
 
                 if ( !remote_bar->enabled )
@@ -513,6 +546,8 @@ static void cf_check bar_write(
     struct vpci_bar *bar = data;
     bool hi = false;
 
+    ASSERT(is_hardware_domain(pdev->domain));
+
     if ( bar->type == VPCI_BAR_MEM64_HI )
     {
         ASSERT(reg > PCI_BASE_ADDRESS_0);
@@ -543,6 +578,8 @@ static void cf_check bar_write(
      */
     bar->addr &= ~(0xffffffffULL << (hi ? 32 : 0));
     bar->addr |= (uint64_t)val << (hi ? 32 : 0);
+    /* Update guest address, so hardware domain BAR is identity mapped. */
+    bar->guest_addr = bar->addr;
 
     /* Make sure Xen writes back the same value for the BAR RO bits. */
     if ( !hi )
@@ -639,11 +676,14 @@ static void cf_check rom_write(
     }
 
     if ( !rom->enabled )
+    {
         /*
          * If the ROM BAR is not mapped update the address field so the
          * correct address is mapped into the p2m.
          */
         rom->addr = val & PCI_ROM_ADDRESS_MASK;
+        rom->guest_addr = rom->addr;
+    }
 
     if ( !header->bars_mapped || rom->enabled == new_enabled )
     {
@@ -667,7 +707,10 @@ static void cf_check rom_write(
         return;
 
     if ( !new_enabled )
+    {
         rom->addr = val & PCI_ROM_ADDRESS_MASK;
+        rom->guest_addr = rom->addr;
+    }
 }
 
 static int bar_add_rangeset(const struct pci_dev *pdev, struct vpci_bar *bar,
@@ -862,6 +905,7 @@ static int cf_check init_header(struct pci_dev *pdev)
         }
 
         bars[i].addr = addr;
+        bars[i].guest_addr = addr;
         bars[i].size = size;
         bars[i].prefetchable = val & PCI_BASE_ADDRESS_MEM_PREFETCH;
 
@@ -884,6 +928,7 @@ static int cf_check init_header(struct pci_dev *pdev)
         rom->type = VPCI_BAR_ROM;
         rom->size = size;
         rom->addr = addr;
+        rom->guest_addr = addr;
         header->rom_enabled = pci_conf_read32(pdev->sbdf, rom_reg) &
                               PCI_ROM_ADDRESS_ENABLE;
 
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index 817ee9ee73..e89c571890 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -216,7 +216,8 @@ int vpci_msix_arch_print(const struct vpci_msix *msix);
  */
 static inline paddr_t vmsix_table_base(const struct vpci *vpci, unsigned int nr)
 {
-    return vpci->header.bars[vpci->msix->tables[nr] & PCI_MSIX_BIRMASK].addr;
+    return vpci->header.bars[vpci->msix->tables[nr] &
+                             PCI_MSIX_BIRMASK].guest_addr;
 }
 
 static inline paddr_t vmsix_table_addr(const struct vpci *vpci, unsigned int nr)
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 14:01:36 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 14:01:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686211.1067955 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey1Y-00069e-Tl; Tue, 27 Feb 2024 14:01:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686211.1067955; Tue, 27 Feb 2024 14:01:36 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey1Y-00069S-Pg; Tue, 27 Feb 2024 14:01:36 +0000
Received: by outflank-mailman (input) for mailman id 686211;
 Tue, 27 Feb 2024 14:01:35 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey1X-00069F-Aw
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:35 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey1X-0001Qa-AI
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:35 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey1X-0005sK-9K
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:35 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=z210suL1wiS4GC0o9lcOV+sW6PUxEe2MJrJf11UfZlo=; b=Kj5+VPH129we2F3md3OLNjQDmS
	VQ9uGkmA1zrS2Em3U53Z4Vry+/ComiaqLTLhbN2q6Z2LRqNJvaojpirOd+EHEYM1TjNkYmgf9pwhr
	XX0s5q+PlPdB348axD4OrWSIHcDSs7YZcfOTPKVl9g/NB5P14Sfk0lBmc1yDy2AQkGMI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/spec: print the built-in SPECULATIVE_HARDEN_* options
Message-Id: <E1rey1X-0005sK-9K@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 14:01:35 +0000

commit 6e9507f7d51fe49df8bc70f83e49ce06c92e4e54
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 14:57:52 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:57:52 2024 +0100

    x86/spec: print the built-in SPECULATIVE_HARDEN_* options
    
    Just like it's done for INDIRECT_THUNK and SHADOW_PAGING.
    
    Reported-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/spec_ctrl.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 503f1c7a37..2d17cbe25f 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -476,13 +476,25 @@ static void __init print_details(enum ind_thunk thunk)
            (e21a & cpufeat_mask(X86_FEATURE_SBPB))           ? " SBPB"           : "");
 
     /* Compiled-in support which pertains to mitigations. */
-    if ( IS_ENABLED(CONFIG_INDIRECT_THUNK) || IS_ENABLED(CONFIG_SHADOW_PAGING) )
+    if ( IS_ENABLED(CONFIG_INDIRECT_THUNK) || IS_ENABLED(CONFIG_SHADOW_PAGING) ||
+         IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_ARRAY) ||
+         IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH) ||
+         IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_GUEST_ACCESS) )
         printk("  Compiled-in support:"
 #ifdef CONFIG_INDIRECT_THUNK
                " INDIRECT_THUNK"
 #endif
 #ifdef CONFIG_SHADOW_PAGING
                " SHADOW_PAGING"
+#endif
+#ifdef CONFIG_SPECULATIVE_HARDEN_ARRAY
+               " HARDEN_ARRAY"
+#endif
+#ifdef CONFIG_SPECULATIVE_HARDEN_BRANCH
+               " HARDEN_BRANCH"
+#endif
+#ifdef CONFIG_SPECULATIVE_HARDEN_GUEST_ACCESS
+               " HARDEN_GUEST_ACCESS"
 #endif
                "\n");
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 14:01:46 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 14:01:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686212.1067957 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey1i-0006Dl-U9; Tue, 27 Feb 2024 14:01:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686212.1067957; Tue, 27 Feb 2024 14:01:46 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey1i-0006Da-RT; Tue, 27 Feb 2024 14:01:46 +0000
Received: by outflank-mailman (input) for mailman id 686212;
 Tue, 27 Feb 2024 14:01:45 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey1h-0006DO-E6
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:45 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey1h-0001Qj-DP
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:45 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey1h-0005tN-Cc
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:45 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=FOE/77AQmZ4gBGmivAyONY61l/p1BUacNhcNrmmt1+U=; b=DfFG7rFxhsgwnOkWPUPPJBPtZL
	NLGvh2RBB2hH6zZ6FGZCfewmtRFcUiAnaBK63d822+c9WK329ihoQrPZsI7t5cCR9L11UG20mN+SA
	vgKLkySrJgzr+bJPxmfvXhQO3u+DXKC7ktGG8Ptn+ejXOcYeqsVqsDx2gk0GjfFiMts8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/spec: fix INDIRECT_THUNK option to only be set when build-enabled
Message-Id: <E1rey1h-0005tN-Cc@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 14:01:45 +0000

commit 8441fa806a3b778867867cd0159fa1722e90397e
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 14:58:20 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:58:20 2024 +0100

    x86/spec: fix INDIRECT_THUNK option to only be set when build-enabled
    
    Attempt to provide a more helpful error message when the user attempts to set
    spec-ctrl=bti-thunk option but the support is build-time disabled.
    
    While there also adjust the command line documentation to mention
    CONFIG_INDIRECT_THUNK instead of INDIRECT_THUNK.
    
    Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 docs/misc/xen-command-line.pandoc | 10 +++++-----
 xen/arch/x86/spec_ctrl.c          |  7 ++++++-
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
index be76be8d53..02896598df 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -2417,11 +2417,11 @@ guests to use.
   performance reasons dom0 is unprotected by default.  If it is necessary to
   protect dom0 too, boot with `spec-ctrl=ibpb-entry`.
 
-If Xen was compiled with INDIRECT_THUNK support, `bti-thunk=` can be used to
-select which of the thunks gets patched into the `__x86_indirect_thunk_%reg`
-locations.  The default thunk is `retpoline` (generally preferred), with the
-alternatives being `jmp` (a `jmp *%reg` gadget, minimal overhead), and
-`lfence` (an `lfence; jmp *%reg` gadget).
+If Xen was compiled with `CONFIG_INDIRECT_THUNK` support, `bti-thunk=` can be
+used to select which of the thunks gets patched into the
+`__x86_indirect_thunk_%reg` locations.  The default thunk is `retpoline`
+(generally preferred), with the alternatives being `jmp` (a `jmp *%reg` gadget,
+minimal overhead), and `lfence` (an `lfence; jmp *%reg` gadget).
 
 On hardware supporting IBRS (Indirect Branch Restricted Speculation), the
 `ibrs=` option can be used to force or prevent Xen using the feature itself.
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 2d17cbe25f..74d2136d42 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -241,7 +241,12 @@ static int __init cf_check parse_spec_ctrl(const char *s)
         {
             s += 10;
 
-            if ( !cmdline_strcmp(s, "retpoline") )
+            if ( !IS_ENABLED(CONFIG_INDIRECT_THUNK) )
+            {
+                no_config_param("INDIRECT_THUNK", "spec-ctrl", s - 10, ss);
+                rc = -EINVAL;
+            }
+            else if ( !cmdline_strcmp(s, "retpoline") )
                 opt_thunk = THUNK_RETPOLINE;
             else if ( !cmdline_strcmp(s, "lfence") )
                 opt_thunk = THUNK_LFENCE;
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 14:01:57 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 14:01:57 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686213.1067961 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey1s-0006GK-Vf; Tue, 27 Feb 2024 14:01:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686213.1067961; Tue, 27 Feb 2024 14:01:56 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rey1s-0006GC-Sr; Tue, 27 Feb 2024 14:01:56 +0000
Received: by outflank-mailman (input) for mailman id 686213;
 Tue, 27 Feb 2024 14:01:55 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey1r-0006G0-Gz
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:55 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey1r-0001Qt-GJ
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:55 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rey1r-0005uU-FX
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 14:01:55 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=mJCXDWGMIK4ki5KY9OQHfiONPCNCHtyUZjdU1VTnyyY=; b=1aCmuoxeBVhwnk44esr+mpXjvZ
	phhigRPZpwtrziRPGpQOpcwUQnaRnAho+kn67Z/9+eBoYWpc2TvvmmU+pkCrDtzyETSqbJ1adkt6t
	97GpkPulLKMiC0KNMnFS4CrvOgqdUUxvYC8rNlxb1J0xAgr9Xk6HnFfZnzLWoquftm24=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/spec: do not print thunk option selection if not built-in
Message-Id: <E1rey1r-0005uU-FX@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 14:01:55 +0000

commit 576528a2a742069af203e90c613c5c93e23c9755
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 14:58:40 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:58:40 2024 +0100

    x86/spec: do not print thunk option selection if not built-in
    
    Since the thunk built-in enable is printed as part of the "Compiled-in
    support:" line, avoid printing anything in "Xen settings:" if the thunk is
    disabled at build time.
    
    Note the BTI-Thunk option printing is also adjusted to print a colon in the
    same way the other options on the line do.
    
    Requested-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/spec_ctrl.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 74d2136d42..752225faa6 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -504,11 +504,12 @@ static void __init print_details(enum ind_thunk thunk)
                "\n");
 
     /* Settings for Xen's protection, irrespective of guests. */
-    printk("  Xen settings: BTI-Thunk %s, SPEC_CTRL: %s%s%s%s%s, Other:%s%s%s%s%s%s\n",
-           thunk == THUNK_NONE      ? "N/A" :
-           thunk == THUNK_RETPOLINE ? "RETPOLINE" :
-           thunk == THUNK_LFENCE    ? "LFENCE" :
-           thunk == THUNK_JMP       ? "JMP" : "?",
+    printk("  Xen settings: %s%sSPEC_CTRL: %s%s%s%s%s, Other:%s%s%s%s%s%s\n",
+           thunk != THUNK_NONE      ? "BTI-Thunk: " : "",
+           thunk == THUNK_NONE      ? "" :
+           thunk == THUNK_RETPOLINE ? "RETPOLINE, " :
+           thunk == THUNK_LFENCE    ? "LFENCE, " :
+           thunk == THUNK_JMP       ? "JMP, " : "?, ",
            (!boot_cpu_has(X86_FEATURE_IBRSB) &&
             !boot_cpu_has(X86_FEATURE_IBRS))         ? "No" :
            (default_xen_spec_ctrl & SPEC_CTRL_IBRS)  ? "IBRS+" :  "IBRS-",
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 17:11:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 17:11:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686275.1068101 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf0yu-0003pY-7e; Tue, 27 Feb 2024 17:11:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686275.1068101; Tue, 27 Feb 2024 17:11:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf0yu-0003pQ-52; Tue, 27 Feb 2024 17:11:04 +0000
Received: by outflank-mailman (input) for mailman id 686275;
 Tue, 27 Feb 2024 17:11:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf0yt-0003pI-EL
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 17:11:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf0yt-0005Of-C9
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 17:11:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf0yt-0004Rq-Ak
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 17:11:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Aowdh1egfB91hLgbhxobq///wxs2d49l/pFyg6iQJf4=; b=xw5DrpFJX6mAsQKNrU0x6iAgnG
	TquxQyGpYp3+hGAggGX1bpM7xF4o2YONFrsqfxVu1KpH+ap2PqYkJ6ITGCvzfzHneszRkXjD3OR13
	GN07eQ0xTV4oHETwPORoJ520xEd+XrTViMgBBCl2qBHos24Tu6+u2ZxAIg7sxqJWu+uc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tests/vpci: fix unit tests after locking change
Message-Id: <E1rf0yt-0004Rq-Ak@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 17:11:03 +0000

commit 801c4e72621d5541d249af1938a77466f0dcfe88
Author:     Stewart Hildebrand <stewart.hildebrand@amd.com>
AuthorDate: Tue Feb 27 18:02:01 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 18:02:01 2024 +0100

    tests/vpci: fix unit tests after locking change
    
    The recent vPCI locking broke the vPCI unit tests. Fix it to unblock CI.
    
    Fixes: 4f78438b45e2 ("vpci: use per-domain PCI lock to protect vpci structure")
    Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
    Acked-by: Roger Pau Monné <roger.pau@citrix.com>
---
 tools/tests/vpci/emul.h | 9 ++++++++-
 tools/tests/vpci/main.c | 2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/tests/vpci/emul.h b/tools/tests/vpci/emul.h
index 3c2f66a18f..da446bba86 100644
--- a/tools/tests/vpci/emul.h
+++ b/tools/tests/vpci/emul.h
@@ -37,7 +37,10 @@
 
 #include "list.h"
 
+typedef bool rwlock_t;
+
 struct domain {
+    rwlock_t pci_lock;
 };
 
 struct pci_dev {
@@ -46,7 +49,7 @@ struct pci_dev {
 
 struct vcpu
 {
-    const struct domain *domain;
+    struct domain *domain;
 };
 
 extern const struct vcpu *current;
@@ -56,6 +59,10 @@ typedef bool spinlock_t;
 #define spin_lock_init(l) (*(l) = false)
 #define spin_lock(l) (*(l) = true)
 #define spin_unlock(l) (*(l) = false)
+#define read_lock(l) (*(l) = true)
+#define read_unlock(l) (*(l) = false)
+#define write_lock(l) (*(l) = true)
+#define write_unlock(l) (*(l) = false)
 
 typedef union {
     uint32_t sbdf;
diff --git a/tools/tests/vpci/main.c b/tools/tests/vpci/main.c
index 64d4552936..33223db3eb 100644
--- a/tools/tests/vpci/main.c
+++ b/tools/tests/vpci/main.c
@@ -21,7 +21,7 @@
 /* Single vcpu (current), and single domain with a single PCI device. */
 static struct vpci vpci;
 
-const static struct domain d;
+static struct domain d;
 
 const struct pci_dev test_pdev = {
     .vpci = &vpci,
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 17:44:07 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 17:44:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686289.1068121 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf1Uo-0000YR-Rg; Tue, 27 Feb 2024 17:44:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686289.1068121; Tue, 27 Feb 2024 17:44:02 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf1Uo-0000YJ-P1; Tue, 27 Feb 2024 17:44:02 +0000
Received: by outflank-mailman (input) for mailman id 686289;
 Tue, 27 Feb 2024 17:44:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf1Uo-0000YD-4U
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 17:44:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf1Uo-0005x1-3f
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 17:44:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf1Uo-00068A-2B
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 17:44:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=uuFpx/+a791oTZLJJPs1ghVW6h7Efx71kBO0o0Kk+rs=; b=SFSc7hBdqgM3UMqVqkMFosXJPK
	6e/aWpBr0NFPpOJJ4Kpe0WkBZzFwmdJZNU2PjN7klcteAtvkzwEftbs0g0dUBPNbO6oRARSkOJIeH
	RpIP78ttRHqRTGm3EZF7N22/ZJjaEGrwO1LEItKlIXpNcUFj1qjkKvRAm/3NFnd9VD2c=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] docs/sphinx: Start an FAQ, and add Kconfig/CET details
Message-Id: <E1rf1Uo-00068A-2B@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 17:44:02 +0000

commit 6f1b2808760874d3912d3b9a02aec9433d08f35c
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Feb 7 12:06:25 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Feb 26 18:20:27 2024 +0000

    docs/sphinx: Start an FAQ, and add Kconfig/CET details
    
    This is long overdue, and we need to start somewhere.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 docs/faq.rst      | 71 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 docs/glossary.rst | 15 ++++++++++++
 docs/index.rst    |  1 +
 3 files changed, 87 insertions(+)

diff --git a/docs/faq.rst b/docs/faq.rst
new file mode 100644
index 0000000000..a56b607814
--- /dev/null
+++ b/docs/faq.rst
@@ -0,0 +1,71 @@
+.. SPDX-License-Identifier: CC-BY-4.0
+
+Frequently Asked Questions
+==========================
+
+How do I...
+-----------
+
+... check whether a Kconfig option is active?
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+  Kconfig is a build time configuration system, combining inherent knowledge,
+  the capabilities of the toolchain, and explicit user choice to form a
+  configuration of a build of Xen.
+
+  A file, by default ``.config``, is produced by the build identifying the
+  configuration used.  Kconfig symbols all start with ``CONFIG_``, and come in
+  a variety of types including strings, integers and booleans.  Booleans are
+  the most common, and when active are expressed with ``...=y``.  e.g.::
+
+    xen.git/xen$ grep CONFIG_FOO .config
+    CONFIG_FOO_BOOLEAN=y
+    CONFIG_FOO_STRING="lorem ipsum"
+    CONFIG_FOO_INTEGER=42
+
+  Symbols which are either absent, or expressed as ``... is not set`` are
+  disabled.  e.g.::
+
+    xen.git/xen$ grep CONFIG_BAR .config
+    # CONFIG_BAR is not set
+
+  Builds of Xen configured with ``CONFIG_HYPFS_CONFIG=y`` embed their own
+  ``.config`` at build time, and can provide it to the :term:`control domain`
+  upon requested.  e.g.::
+
+    [root@host ~]# xenhypfs cat /buildinfo/config | grep -e FOO -e BAR
+    CONFIG_FOO=y
+    # CONFIG_BAR is not set
+
+
+... tell if CET is active?
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+  Control-flow Enforcement Technology support was added to Xen 4.14.  It is
+  build time conditional, dependent on both having a new-enough toolchain and
+  an explicit Kconfig option, and also requires capable hardware.  See
+  :term:`CET`.
+
+  For CET-SS, Shadow Stacks, the minimum toolchain requirements are ``binutils
+  >= 2.29`` or ``LLVM >= 6``.  No specific compiler support is required.
+  Check for ``CONFIG_XEN_SHSTK`` being active.
+
+  For CET-IBT, Indirect Branch Tracking, the minimum toolchain requirements
+  are ``GCC >= 9`` and ``binutils >= 2.29``.  Xen relies on a compiler feature
+  which is specific to GCC at the time of writing.  Check for
+  ``CONFIG_XEN_IBT`` being active.
+
+  If a capable Xen is booted on capable hardware, and CET is not disabled by
+  command line option or errata, Xen will print some details early on boot
+  about which CET facilities have been turned on::
+
+    ...
+    (XEN) CPU Vendor: Intel, Family 6 (0x6), Model 143 (0x8f), Stepping 8 (raw 000806f8)
+    (XEN) Enabling Supervisor Shadow Stacks
+    (XEN) Enabling Indirect Branch Tracking
+    (XEN)   - IBT disabled in UEFI Runtime Services
+    (XEN) EFI RAM map:
+    ...
+
+  This can be obtained from the control domain with ``xl dmesg``, but remember
+  to confirm that the console ring hasn't wrapped.
diff --git a/docs/glossary.rst b/docs/glossary.rst
index 8ddbdab160..6adeec77e1 100644
--- a/docs/glossary.rst
+++ b/docs/glossary.rst
@@ -28,6 +28,21 @@ Glossary
      single instance of Xen, used as the identifier in various APIs, and is
      typically allocated sequentially from 0.
 
+   CET
+     Control-flow Enforcement Technology is a facility in x86 CPUs for
+     defending against memory safety vulnerabilities.  It is formed of two
+     independent features:
+
+     * CET-SS, Shadow Stacks, are designed to protect against Return Oriented
+       Programming (ROP) attacks.
+
+     * CET-IBT, Indirect Branch Tracking, is designed to protect against Call
+       or Jump Oriented Programming (COP/JOP) attacks.
+
+     Intel support CET-SS and CET-IBT from the Tiger Lake (Client, 2020) and
+     Sapphire Rapids (Server, 2023) CPUs.  AMD support only CET-SS, starting
+     with Zen3 (Both client and server, 2020) CPUs.
+
    guest
      The term 'guest' has two different meanings, depending on context, and
      should not be confused with :term:`domain`.
diff --git a/docs/index.rst b/docs/index.rst
index 22fdde8059..ab051a0f38 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -72,4 +72,5 @@ Miscellanea
 
 .. toctree::
 
+   faq
    glossary
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 17:44:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 17:44:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686290.1068125 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf1Uy-0000av-TM; Tue, 27 Feb 2024 17:44:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686290.1068125; Tue, 27 Feb 2024 17:44:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf1Uy-0000al-QR; Tue, 27 Feb 2024 17:44:12 +0000
Received: by outflank-mailman (input) for mailman id 686290;
 Tue, 27 Feb 2024 17:44:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf1Uy-0000ab-7i
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 17:44:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf1Uy-0005xA-6m
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 17:44:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf1Uy-00069K-5q
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 17:44:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ncCVX9iAU42Ymiok1WBo3806dxuF0NBObrOwPVgFgkw=; b=koVWozPFrjTbNkt+u9NT+WEE+2
	uPzgz60BytmGO/p5MuHq9u/KvurET7ebiLvkG9gru1dPXKBj/azieKoY9HEsHacbSrsqM+GtKcSkC
	Kn8OQ5hlThpCkZigF8pYTHn1RVjmcmtKi7wMyzHnpXaXok4Nm/Zov8CGtu+Q8o2tQSRU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/entry: Adjustments to "reduce assembly code size of entry points"
Message-Id: <E1rf1Uy-00069K-5q@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 17:44:12 +0000

commit 7d3c91377d121b31b9d602f8d44abdcb66b0cbe5
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Feb 20 20:53:15 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Feb 26 18:20:27 2024 +0000

    x86/entry: Adjustments to "reduce assembly code size of entry points"
    
    Some retroactive review, for if I'd got to the patch in time.
    
     * The new ASM-friendly BUILD_BUG_ON() should be in a header file.
     * entry_int82() wants the movl->movb treatment too.
    
    Fixes: c144b9e32427 ("x86: Reduce assembly code size of entry points")
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/include/asm/asm_defns.h | 8 ++++++++
 xen/arch/x86/x86_64/compat/entry.S   | 2 +-
 xen/arch/x86/x86_64/entry.S          | 8 --------
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/include/asm/asm_defns.h b/xen/arch/x86/include/asm/asm_defns.h
index a9a6c21c76..cf9573705d 100644
--- a/xen/arch/x86/include/asm/asm_defns.h
+++ b/xen/arch/x86/include/asm/asm_defns.h
@@ -82,6 +82,14 @@ register unsigned long current_stack_pointer asm("rsp");
 
 #ifdef __ASSEMBLY__
 
+.macro BUILD_BUG_ON condstr cond:vararg
+        .if \cond
+        .error "Condition \"\condstr\" not satisfied"
+        .endif
+.endm
+/* preprocessor macro to make error message more user friendly */
+#define BUILD_BUG_ON(cond) BUILD_BUG_ON #cond cond
+
 #ifdef HAVE_AS_QUOTED_SYM
 #define SUBSECTION_LBL(tag)                        \
         .ifndef .L.tag;                            \
diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compat/entry.S
index d4f0e48040..93fbbeb4ae 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -15,7 +15,7 @@ FUNC(entry_int82)
         ENDBR64
         ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
         pushq $0
-        movl  $HYPERCALL_VECTOR, 4(%rsp)
+        movb  $HYPERCALL_VECTOR, 4(%rsp)
         SAVE_ALL compat=1 /* DPL1 gate, restricted to 32bit PV guests only. */
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index a7bd8f0ca5..f8938b0b42 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -22,14 +22,6 @@
 #endif
 .endm
 
-.macro BUILD_BUG_ON condstr cond:vararg
-        .if \cond
-        .error "Condition \"\condstr\" not satisfied"
-        .endif
-.endm
-/* preprocessor macro to make error message more user friendly */
-#define BUILD_BUG_ON(cond) BUILD_BUG_ON #cond cond
-
 #ifdef CONFIG_PV
 /* %rbx: struct vcpu */
 FUNC_LOCAL(switch_to_kernel)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 17:44:22 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 17:44:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686291.1068130 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf1V8-0000dg-VA; Tue, 27 Feb 2024 17:44:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686291.1068130; Tue, 27 Feb 2024 17:44:22 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf1V8-0000dY-Rt; Tue, 27 Feb 2024 17:44:22 +0000
Received: by outflank-mailman (input) for mailman id 686291;
 Tue, 27 Feb 2024 17:44:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf1V8-0000dS-D6
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 17:44:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf1V8-0005yu-BT
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 17:44:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf1V8-00069t-8n
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 17:44:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=35COEOUhdfXMqGiBESpKlixFCQfVJC801ZJR1cePG+0=; b=QOk/vyktsgXrnjWnZAqCbfhKng
	8eIipchhd6GSJ/LzsOSw2wMVijdSNI9t+XSCpS3CLtJK6RQEvanmgAQOKoxm0UjiW5tKhDJSf1gmF
	hTmx/vRkm3KOeulIe84wdrK+eZgL9CxBFmhK8TntjaJMrsKSQtSp0sjZt4z+bmV3/x14=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/entry: Simplify expressions in compat_restore_all_guest()
Message-Id: <E1rf1V8-00069t-8n@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 17:44:22 +0000

commit 0603a0c0923c278e2073c4aa00684c6269df317e
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Feb 20 20:54:10 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Feb 26 18:20:27 2024 +0000

    x86/entry: Simplify expressions in compat_restore_all_guest()
    
    compat_restore_all_guest() already has SPEC_CTRL_EXIT_TO_PV with a documented
    requirement for %rsp to be both regs and cpuinfo.
    
    Use the now-normal annotations and simplify the expressions which happen to be
    a subtraction of 0.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/x86_64/compat/entry.S | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compat/entry.S
index 93fbbeb4ae..727ab65290 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -117,19 +117,19 @@ compat_process_trap:
         jmp   compat_test_all_events
 END(compat_test_all_events)
 
-/* %rbx: struct vcpu, interrupts disabled */
+/* %rbx: struct vcpu, interrupts disabled, %rsp=regs/cpuinfo */
 FUNC(compat_restore_all_guest)
         ASSERT_INTERRUPTS_DISABLED
         mov   $~(X86_EFLAGS_IOPL | X86_EFLAGS_VM), %r11d
         and   UREGS_eflags(%rsp),%r11d
 
-.macro alt_cr4_pv32
+.macro alt_cr4_pv32 /* %rsp=regs/cpuinfo */
         testb $3,UREGS_cs(%rsp)
         jpe   2f
-        mov   CPUINFO_cr4-CPUINFO_guest_cpu_user_regs(%rsp), %rax
+        mov   CPUINFO_cr4(%rsp), %rax
         and   $~XEN_CR4_PV32_BITS, %rax
 1:
-        mov   %rax, CPUINFO_cr4-CPUINFO_guest_cpu_user_regs(%rsp)
+        mov   %rax, CPUINFO_cr4(%rsp)
         mov   %rax, %cr4
         /*
          * An NMI or MCE may have occurred between the previous two
@@ -141,7 +141,7 @@ FUNC(compat_restore_all_guest)
          * loop to cause a live lock: If NMIs/MCEs occurred at that
          * high a rate, we'd be live locked anyway.
          */
-        cmp   %rax, CPUINFO_cr4-CPUINFO_guest_cpu_user_regs(%rsp)
+        cmp   %rax, CPUINFO_cr4(%rsp)
         jne   1b
 2:
 .endm
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 17:44:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 17:44:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686292.1068132 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf1VJ-0000gz-15; Tue, 27 Feb 2024 17:44:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686292.1068132; Tue, 27 Feb 2024 17:44:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf1VI-0000gr-Um; Tue, 27 Feb 2024 17:44:32 +0000
Received: by outflank-mailman (input) for mailman id 686292;
 Tue, 27 Feb 2024 17:44:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf1VI-0000gk-FA
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 17:44:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf1VI-0005zJ-EU
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 17:44:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf1VI-0006AN-Dc
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 17:44:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=EOogQSR1uc5untvNw8r1jjTvY1HWYm0tYx0vm70g5Ic=; b=VzDgxyIxByrraKSBDqp76Pynda
	FGy+be+En5frlNnco2DiO5UeY7/byBaK8hHAVFtQWOhv6zPVepgMbSFzOjvVdBasr4vlK6bhjdGSo
	4AEs8bVEcER0s9X07CUCMLkgoznPQgI/qPRU3ycTT6Fyw7teirPWqsvIfrDIXjDvTVr8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/entry: Introduce EFRAME_* constants
Message-Id: <E1rf1VI-0006AN-Dc@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 17:44:32 +0000

commit 37541208f119a9c552c6c6c3246ea61be0d44035
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Sat Jan 27 17:52:09 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Feb 26 18:20:27 2024 +0000

    x86/entry: Introduce EFRAME_* constants
    
    restore_all_guest() does a lot of manipulation of the stack after popping the
    GPRs, and uses raw %rsp displacements to do so.  Also, almost all entrypaths
    use raw %rsp displacements prior to pushing GPRs.
    
    Provide better mnemonics, to aid readability and reduce the chance of errors
    when editing.
    
    No functional change.  The resulting binary is identical.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/x86_64/asm-offsets.c  | 17 ++++++++++
 xen/arch/x86/x86_64/compat/entry.S |  2 +-
 xen/arch/x86/x86_64/entry.S        | 68 +++++++++++++++++++-------------------
 3 files changed, 52 insertions(+), 35 deletions(-)

diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c
index fee0edc61a..02242a9b73 100644
--- a/xen/arch/x86/x86_64/asm-offsets.c
+++ b/xen/arch/x86/x86_64/asm-offsets.c
@@ -51,6 +51,23 @@ void __dummy__(void)
     OFFSET(UREGS_kernel_sizeof, struct cpu_user_regs, es);
     BLANK();
 
+    /*
+     * EFRAME_* is for the entry/exit logic where %rsp is pointing at
+     * UREGS_error_code and GPRs are still/already guest values.
+     */
+#define OFFSET_EF(sym, mem)                                             \
+    DEFINE(sym, offsetof(struct cpu_user_regs, mem) -                   \
+                offsetof(struct cpu_user_regs, error_code))
+
+    OFFSET_EF(EFRAME_entry_vector,    entry_vector);
+    OFFSET_EF(EFRAME_rip,             rip);
+    OFFSET_EF(EFRAME_cs,              cs);
+    OFFSET_EF(EFRAME_eflags,          eflags);
+    OFFSET_EF(EFRAME_rsp,             rsp);
+    BLANK();
+
+#undef OFFSET_EF
+
     OFFSET(VCPU_processor, struct vcpu, processor);
     OFFSET(VCPU_domain, struct vcpu, domain);
     OFFSET(VCPU_vcpu_info, struct vcpu, vcpu_info_area.map);
diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compat/entry.S
index 727ab65290..2f8fe5ebfb 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -15,7 +15,7 @@ FUNC(entry_int82)
         ENDBR64
         ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
         pushq $0
-        movb  $HYPERCALL_VECTOR, 4(%rsp)
+        movb  $HYPERCALL_VECTOR, EFRAME_entry_vector(%rsp)
         SAVE_ALL compat=1 /* DPL1 gate, restricted to 32bit PV guests only. */
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index f8938b0b42..1b846f3aaf 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -188,15 +188,15 @@ FUNC_LOCAL(restore_all_guest)
 
         RESTORE_ALL
         BUILD_BUG_ON(TRAP_syscall & 0xff)
-        testb $TRAP_syscall >> 8, 4+1(%rsp)
+        testb $TRAP_syscall >> 8, EFRAME_entry_vector + 1(%rsp)
         jz    iret_exit_to_guest
 
-        movq  24(%rsp),%r11           # RFLAGS
+        mov   EFRAME_eflags(%rsp), %r11
         andq  $~(X86_EFLAGS_IOPL | X86_EFLAGS_VM), %r11
         orq   $X86_EFLAGS_IF,%r11
 
         /* Don't use SYSRET path if the return address is not canonical. */
-        movq  8(%rsp),%rcx
+        mov   EFRAME_rip(%rsp), %rcx
         sarq  $47,%rcx
         incl  %ecx
         cmpl  $1,%ecx
@@ -211,19 +211,19 @@ FUNC_LOCAL(restore_all_guest)
         ALTERNATIVE "", rag_clrssbsy, X86_FEATURE_XEN_SHSTK
 #endif
 
-        movq  8(%rsp), %rcx           # RIP
-        cmpw  $FLAT_USER_CS32,16(%rsp)# CS
-        movq  32(%rsp),%rsp           # RSP
+        mov   EFRAME_rip(%rsp), %rcx
+        cmpw  $FLAT_USER_CS32, EFRAME_cs(%rsp)
+        mov   EFRAME_rsp(%rsp), %rsp
         je    1f
         sysretq
 1:      sysretl
 
 LABEL_LOCAL(.Lrestore_rcx_iret_exit_to_guest)
-        movq  8(%rsp), %rcx           # RIP
+        mov   EFRAME_rip(%rsp), %rcx
 /* No special register assumptions. */
 iret_exit_to_guest:
-        andl  $~(X86_EFLAGS_IOPL | X86_EFLAGS_VM), 24(%rsp)
-        orl   $X86_EFLAGS_IF,24(%rsp)
+        andl  $~(X86_EFLAGS_IOPL | X86_EFLAGS_VM), EFRAME_eflags(%rsp)
+        orl   $X86_EFLAGS_IF, EFRAME_eflags(%rsp)
         addq  $8,%rsp
 .Lft0:  iretq
         _ASM_PRE_EXTABLE(.Lft0, handle_exception)
@@ -256,7 +256,7 @@ FUNC(lstar_enter)
         pushq %rcx
         pushq $0
         BUILD_BUG_ON(TRAP_syscall & 0xff)
-        movb  $TRAP_syscall >> 8, 4+1(%rsp)
+        movb  $TRAP_syscall >> 8, EFRAME_entry_vector + 1(%rsp)
         SAVE_ALL
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
@@ -295,7 +295,7 @@ FUNC(cstar_enter)
         pushq %rcx
         pushq $0
         BUILD_BUG_ON(TRAP_syscall & 0xff)
-        movb  $TRAP_syscall >> 8, 4+1(%rsp)
+        movb  $TRAP_syscall >> 8, EFRAME_entry_vector + 1(%rsp)
         SAVE_ALL
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
@@ -338,7 +338,7 @@ LABEL(sysenter_eflags_saved, 0)
         pushq $0 /* null rip */
         pushq $0
         BUILD_BUG_ON(TRAP_syscall & 0xff)
-        movb  $TRAP_syscall >> 8, 4+1(%rsp)
+        movb  $TRAP_syscall >> 8, EFRAME_entry_vector + 1(%rsp)
         SAVE_ALL
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
@@ -393,7 +393,7 @@ FUNC(entry_int80)
         ENDBR64
         ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
         pushq $0
-        movb  $0x80, 4(%rsp)
+        movb  $0x80, EFRAME_entry_vector(%rsp)
         SAVE_ALL
 
         SPEC_CTRL_ENTRY_FROM_PV /* Req: %rsp=regs/cpuinfo, %rdx=0, Clob: acd */
@@ -658,7 +658,7 @@ END(ret_from_intr)
         .section .init.text, "ax", @progbits
 FUNC(early_page_fault)
         ENDBR64
-        movb  $X86_EXC_PF, 4(%rsp)
+        movb  $X86_EXC_PF, EFRAME_entry_vector(%rsp)
         SAVE_ALL
         movq  %rsp, %rdi
         call  do_early_page_fault
@@ -727,7 +727,7 @@ END(common_interrupt)
 
 FUNC(entry_PF)
         ENDBR64
-        movb  $X86_EXC_PF, 4(%rsp)
+        movb  $X86_EXC_PF, EFRAME_entry_vector(%rsp)
 END(entry_PF)
 /* No special register assumptions. */
 FUNC(handle_exception, 0)
@@ -911,98 +911,98 @@ END(entry_DE)
 FUNC(entry_MF)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_MF, 4(%rsp)
+        movb  $X86_EXC_MF, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_MF)
 
 FUNC(entry_XM)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_XM, 4(%rsp)
+        movb  $X86_EXC_XM, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_XM)
 
 FUNC(entry_NM)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_NM, 4(%rsp)
+        movb  $X86_EXC_NM, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_NM)
 
 FUNC(entry_DB)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_DB, 4(%rsp)
+        movb  $X86_EXC_DB, EFRAME_entry_vector(%rsp)
         jmp   handle_ist_exception
 END(entry_DB)
 
 FUNC(entry_BP)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_BP, 4(%rsp)
+        movb  $X86_EXC_BP, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_BP)
 
 FUNC(entry_OF)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_OF, 4(%rsp)
+        movb  $X86_EXC_OF, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_OF)
 
 FUNC(entry_BR)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_BR, 4(%rsp)
+        movb  $X86_EXC_BR, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_BR)
 
 FUNC(entry_UD)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_UD, 4(%rsp)
+        movb  $X86_EXC_UD, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_UD)
 
 FUNC(entry_TS)
         ENDBR64
-        movb  $X86_EXC_TS, 4(%rsp)
+        movb  $X86_EXC_TS, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_TS)
 
 FUNC(entry_NP)
         ENDBR64
-        movb  $X86_EXC_NP, 4(%rsp)
+        movb  $X86_EXC_NP, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_NP)
 
 FUNC(entry_SS)
         ENDBR64
-        movb  $X86_EXC_SS, 4(%rsp)
+        movb  $X86_EXC_SS, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_SS)
 
 FUNC(entry_GP)
         ENDBR64
-        movb  $X86_EXC_GP, 4(%rsp)
+        movb  $X86_EXC_GP, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_GP)
 
 FUNC(entry_AC)
         ENDBR64
-        movb  $X86_EXC_AC, 4(%rsp)
+        movb  $X86_EXC_AC, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_AC)
 
 FUNC(entry_CP)
         ENDBR64
-        movb  $X86_EXC_CP, 4(%rsp)
+        movb  $X86_EXC_CP, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 END(entry_CP)
 
 FUNC(entry_DF)
         ENDBR64
-        movb  $X86_EXC_DF, 4(%rsp)
+        movb  $X86_EXC_DF, EFRAME_entry_vector(%rsp)
         /* Set AC to reduce chance of further SMAP faults */
         ALTERNATIVE "", stac, X86_FEATURE_XEN_SMAP
         SAVE_ALL
@@ -1028,7 +1028,7 @@ END(entry_DF)
 FUNC(entry_NMI)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_NMI, 4(%rsp)
+        movb  $X86_EXC_NMI, EFRAME_entry_vector(%rsp)
 END(entry_NMI)
 
 FUNC(handle_ist_exception)
@@ -1164,7 +1164,7 @@ END(handle_ist_exception)
 FUNC(entry_MC)
         ENDBR64
         pushq $0
-        movb  $X86_EXC_MC, 4(%rsp)
+        movb  $X86_EXC_MC, EFRAME_entry_vector(%rsp)
         jmp   handle_ist_exception
 END(entry_MC)
 
@@ -1203,7 +1203,7 @@ FUNC_LOCAL(autogen_stubs, 0) /* Automatically generated stubs. */
 1:
         ENDBR64
         pushq $0
-        movb  $vec,4(%rsp)
+        movb  $vec, EFRAME_entry_vector(%rsp)
         jmp   common_interrupt
 
         entrypoint 1b
@@ -1217,7 +1217,7 @@ FUNC_LOCAL(autogen_stubs, 0) /* Automatically generated stubs. */
         test  $8,%spl        /* 64bit exception frames are 16 byte aligned, but the word */
         jz    2f             /* size is 8 bytes.  Check whether the processor gave us an */
         pushq $0             /* error code, and insert an empty one if not.              */
-2:      movb  $vec,4(%rsp)
+2:      movb  $vec, EFRAME_entry_vector(%rsp)
         jmp   handle_exception
 
         entrypoint 1b
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 23:44:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 23:44:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686346.1068233 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf77C-0001xY-Qy; Tue, 27 Feb 2024 23:44:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686346.1068233; Tue, 27 Feb 2024 23:44:02 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf77C-0001xQ-OQ; Tue, 27 Feb 2024 23:44:02 +0000
Received: by outflank-mailman (input) for mailman id 686346;
 Tue, 27 Feb 2024 23:44:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf77C-0001we-CL
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf77C-0004Az-AJ
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf77C-0004ME-9M
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=zA8JWfT+aLlJbChOD1jX76DLBOykh6Blrbzrf7x6ngk=; b=jxqNkZcBNXxIEkrOdNpEznBKCr
	ynxthmH8idUKHOW4SUTRxKKa3gsVuVAFbtYxAG2hTXD525HNWdQlOPG3Rpp4QfRadN6B+vFYzA6q5
	unV4EHdPGQHBHZbFx/TRkupLMHsMs0jWmMQ63pwqCLfWxYkhprLFpRY8C9UKjbkHFbi0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] tools/xentop: fix sorting bug for some columns
Message-Id: <E1rf77C-0004ME-9M@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 23:44:02 +0000

commit 184d723e7a5d1c021d297e14d19fe5344eac7a56
Author:     Cyril Rébert (zithro) <slack@rabbit.lu>
AuthorDate: Tue Feb 27 13:53:42 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:53:42 2024 +0100

    tools/xentop: fix sorting bug for some columns
    
    Sort doesn't work on columns VBD_OO, VBD_RD, VBD_WR and VBD_RSECT.
    Fix by adjusting variables names in compare functions.
    Bug fix only. No functional change.
    
    Fixes: 91c3e3dc91d6 ("tools/xentop: Display '-' when stats are not available.")
    Signed-off-by: Cyril Rébert (zithro) <slack@rabbit.lu>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    master commit: 29f17d837421f13c0e0010802de1b2d51d2ded4a
    master date: 2024-02-05 17:58:23 +0000
---
 tools/xentop/xentop.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/xentop/xentop.c b/tools/xentop/xentop.c
index 950e8935c4..545bd5e96d 100644
--- a/tools/xentop/xentop.c
+++ b/tools/xentop/xentop.c
@@ -684,7 +684,7 @@ static int compare_vbd_oo(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_oo = 0, dom2_vbd_oo = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_OO, &dom1_vbd_oo);
-	tot_vbd_reqs(domain1, FIELD_VBD_OO, &dom2_vbd_oo);
+	tot_vbd_reqs(domain2, FIELD_VBD_OO, &dom2_vbd_oo);
 
 	return -compare(dom1_vbd_oo, dom2_vbd_oo);
 }
@@ -711,9 +711,9 @@ static int compare_vbd_rd(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_rd = 0, dom2_vbd_rd = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_RD, &dom1_vbd_rd);
-	tot_vbd_reqs(domain1, FIELD_VBD_RD, &dom2_vbd_rd);
+	tot_vbd_reqs(domain2, FIELD_VBD_RD, &dom2_vbd_rd);
 
-	return -compare(dom1_vbd_rd, dom1_vbd_rd);
+	return -compare(dom1_vbd_rd, dom2_vbd_rd);
 }
 
 /* Prints number of total VBD READ requests statistic */
@@ -738,7 +738,7 @@ static int compare_vbd_wr(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_wr = 0, dom2_vbd_wr = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_WR, &dom1_vbd_wr);
-	tot_vbd_reqs(domain1, FIELD_VBD_WR, &dom2_vbd_wr);
+	tot_vbd_reqs(domain2, FIELD_VBD_WR, &dom2_vbd_wr);
 
 	return -compare(dom1_vbd_wr, dom2_vbd_wr);
 }
@@ -765,7 +765,7 @@ static int compare_vbd_rsect(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_rsect = 0, dom2_vbd_rsect = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_RSECT, &dom1_vbd_rsect);
-	tot_vbd_reqs(domain1, FIELD_VBD_RSECT, &dom2_vbd_rsect);
+	tot_vbd_reqs(domain2, FIELD_VBD_RSECT, &dom2_vbd_rsect);
 
 	return -compare(dom1_vbd_rsect, dom2_vbd_rsect);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 23:44:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 23:44:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686347.1068237 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf77N-00025N-Sy; Tue, 27 Feb 2024 23:44:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686347.1068237; Tue, 27 Feb 2024 23:44:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf77N-00025D-Pq; Tue, 27 Feb 2024 23:44:13 +0000
Received: by outflank-mailman (input) for mailman id 686347;
 Tue, 27 Feb 2024 23:44:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf77M-00023W-Ez
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf77M-0004B3-EG
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf77M-0004NA-CW
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=bF2SKvmhdYdNc/WOSAt7kEgWAkMk7EiRcc/B9NpEigY=; b=uMtQUUbvXJ+hMoBGujhiVw62e+
	8ZS1rHHXKjg6Nxu/gXlKgcDhKDtsmje/MQMYUaLMNn+ByALIJ9pWLw3C12MUcwmhMet0u4st//gwp
	KKq4qsPsDg3/VoTu/ql57fzcpJyR/p0CsxAUIQ1PD/erc06ezyCNnE7BXM10n35M6LbA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] amd-vi: fix IVMD memory type checks
Message-Id: <E1rf77M-0004NA-CW@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 23:44:12 +0000

commit fa9950a527a70971bf9279be62d445cf9c83aedf
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 13:54:04 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:54:04 2024 +0100

    amd-vi: fix IVMD memory type checks
    
    The current code that parses the IVMD blocks is relaxed with regard to the
    restriction that such unity regions should always fall into memory ranges
    marked as reserved in the memory map.
    
    However the type checks for the IVMD addresses are inverted, and as a result
    IVMD ranges falling into RAM areas are accepted.  Note that having such ranges
    in the first place is a firmware bug, as IVMD should always fall into reserved
    ranges.
    
    Fixes: ed6c77ebf0c1 ('AMD/IOMMU: check / convert IVMD ranges for being / to be reserved')
    Reported-by: Ox <oxjo@proton.me>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Tested-by: oxjo <oxjo@proton.me>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: 83afa313583019d9f159c122cecf867735d27ec5
    master date: 2024-02-06 11:56:13 +0100
---
 xen/drivers/passthrough/amd/iommu_acpi.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_acpi.c b/xen/drivers/passthrough/amd/iommu_acpi.c
index 699d33f429..96d8879e7b 100644
--- a/xen/drivers/passthrough/amd/iommu_acpi.c
+++ b/xen/drivers/passthrough/amd/iommu_acpi.c
@@ -426,9 +426,14 @@ static int __init parse_ivmd_block(const struct acpi_ivrs_memory *ivmd_block)
                 return -EIO;
             }
 
-            /* Types which won't be handed out are considered good enough. */
-            if ( !(type & (RAM_TYPE_RESERVED | RAM_TYPE_ACPI |
-                           RAM_TYPE_UNUSABLE)) )
+            /*
+             * Types which aren't RAM are considered good enough.
+             * Note that a page being partially RESERVED, ACPI or UNUSABLE will
+             * force Xen into assuming the whole page as having that type in
+             * practice.
+             */
+            if ( type & (RAM_TYPE_RESERVED | RAM_TYPE_ACPI |
+                         RAM_TYPE_UNUSABLE) )
                 continue;
 
             AMD_IOMMU_ERROR("IVMD: page at %lx can't be converted\n", addr);
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 23:44:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 23:44:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686348.1068241 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf77X-00028F-Tr; Tue, 27 Feb 2024 23:44:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686348.1068241; Tue, 27 Feb 2024 23:44:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf77X-000286-RH; Tue, 27 Feb 2024 23:44:23 +0000
Received: by outflank-mailman (input) for mailman id 686348;
 Tue, 27 Feb 2024 23:44:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf77W-00027u-Hx
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf77W-0004Cn-H8
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf77W-0004No-GI
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=C4rOJwuK2IMcFtNa66i/6j6nTnbpliRXwXuZ5A9/qXc=; b=bLEBgotRo0S1Ggi04zMUY163Q9
	BtFHcO5Ntm2AZMPZQDlHPv5RT9erU4U9IIHqdtSTL1q7SMHYrg0l8iBtLm/roq4vNxZXbMrmKm750
	jD+uM8NySpRGp7h3UxVQVy9rP1jE9815xeC7ftgVwW7goR1D+EQNTTYyGNJromvU03SI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] block-common: Fix same_vm for no targets
Message-Id: <E1rf77W-0004No-GI@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 23:44:22 +0000

commit 16475909baa2bcfda3ebc07ced5e5cd0ca8172d6
Author:     Jason Andryuk <jandryuk@gmail.com>
AuthorDate: Tue Feb 27 13:55:03 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:55:03 2024 +0100

    block-common: Fix same_vm for no targets
    
    same_vm is broken when the two main domains do not have targets.  otvm
    and targetvm are both missing, which means they get set to -1 and then
    converted to empty strings:
    
    ++10697+ local targetvm=-1
    ++10697+ local otvm=-1
    ++10697+ otvm=
    ++10697+ othervm=/vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4
    ++10697+ targetvm=
    ++10697+ local frontend_uuid=/vm/844dea4e-44f8-4e3e-8145-325132a31ca5
    
    The final comparison returns true since the two empty strings match:
    
    ++10697+ '[' /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = /vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o '' = /vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = '' -o '' = '' ']'
    
    Replace -1 with distinct strings indicating the lack of a value and
    remove the collescing to empty stings.  The strings themselves will no
    longer match, and that is correct.
    
    ++12364+ '[' /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = /vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o 'No target' = /vm/cc97bc2f-3a91-43f7-8fbc-4cb92f90b4e4 -o /vm/844dea4e-44f8-4e3e-8145-325132a31ca5 = 'No other target' -o 'No target' = 'No other target' ']'
    
    Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    master commit: e8f1bb803fdf44db708991593568a9e3e6b3d130
    master date: 2024-02-07 13:46:52 +0100
---
 tools/hotplug/Linux/block-common.sh | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/tools/hotplug/Linux/block-common.sh b/tools/hotplug/Linux/block-common.sh
index f86a88c4eb..5c80237d99 100644
--- a/tools/hotplug/Linux/block-common.sh
+++ b/tools/hotplug/Linux/block-common.sh
@@ -112,14 +112,12 @@ same_vm()
                   "$FRONTEND_UUID")
   local target=$(xenstore_read_default  "/local/domain/$FRONTEND_ID/target"   \
                  "-1")
-  local targetvm=$(xenstore_read_default "/local/domain/$target/vm" "-1")
+  local targetvm=$(xenstore_read_default "/local/domain/$target/vm" "No Target")
   local otarget=$(xenstore_read_default  "/local/domain/$otherdom/target"   \
                  "-1")
   local otvm=$(xenstore_read_default  "/local/domain/$otarget/vm"   \
-                 "-1")
-  otvm=${otvm%-1}
-  othervm=${othervm%-1}
-  targetvm=${targetvm%-1}
+                 "No Other Target")
+
   local frontend_uuid=${FRONTEND_UUID%-1}
   
   [ "$frontend_uuid" = "$othervm" -o "$targetvm" = "$othervm" -o \
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 23:44:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 23:44:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686349.1068245 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf77h-0002BU-Vj; Tue, 27 Feb 2024 23:44:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686349.1068245; Tue, 27 Feb 2024 23:44:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf77h-0002BM-Si; Tue, 27 Feb 2024 23:44:33 +0000
Received: by outflank-mailman (input) for mailman id 686349;
 Tue, 27 Feb 2024 23:44:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf77g-0002Ay-Kz
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf77g-0004DI-KC
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf77g-0004OM-JQ
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=PBTWcFdMYQ4YwHHPtUH9CIsOPk34SSOhhAJ+7Maw/s0=; b=NnrdXNMh2DlioWcDv74TEXRziJ
	FddhaQyKNpgQQp0uyi8remcSZXipT3XFBJRHKXZxI25t1lXi4Xbs7qMsd3rwdfuQZOGIQq5rpDlS4
	xdMAK/+bxyEgvGVnen8cUkt2BHzq8qyGG3I+AiSpbkPqivVuMoR6Oj3WjhRFu9qtn9sY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] x86/hvm: Fix fast singlestep state persistence
Message-Id: <E1rf77g-0004OM-JQ@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 23:44:32 +0000

commit b51fd78aed865033413178f5953147effedc7ce0
Author:     Petr Beneš <w1benny@gmail.com>
AuthorDate: Tue Feb 27 13:55:25 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:55:25 2024 +0100

    x86/hvm: Fix fast singlestep state persistence
    
    This patch addresses an issue where the fast singlestep setting would persist
    despite xc_domain_debug_control being called with XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF.
    Specifically, if fast singlestep was enabled in a VMI session and that session
    stopped before the MTF trap occurred, the fast singlestep setting remained
    active even though MTF itself was disabled.  This led to a situation where, upon
    starting a new VMI session, the first event to trigger an EPT violation would
    cause the corresponding EPT event callback to be skipped due to the lingering
    fast singlestep setting.
    
    The fix ensures that the fast singlestep setting is properly reset when
    disabling single step debugging operations.
    
    Signed-off-by: Petr Beneš <w1benny@gmail.com>
    Reviewed-by: Tamas K Lengyel <tamas@tklengyel.com>
    master commit: 897def94b56175ce569673a05909d2f223e1e749
    master date: 2024-02-12 09:37:58 +0100
---
 xen/arch/x86/hvm/hvm.c | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 482eebbabf..a70b351373 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -5167,26 +5167,40 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
 
 int hvm_debug_op(struct vcpu *v, int32_t op)
 {
-    int rc;
+    int rc = 0;
 
     switch ( op )
     {
         case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON:
         case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF:
-            rc = -EOPNOTSUPP;
             if ( !cpu_has_monitor_trap_flag )
-                break;
-            rc = 0;
-            vcpu_pause(v);
-            v->arch.hvm.single_step =
-                (op == XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON);
-            vcpu_unpause(v); /* guest will latch new state */
+                return -EOPNOTSUPP;
             break;
         default:
-            rc = -ENOSYS;
-            break;
+            return -ENOSYS;
+    }
+
+    vcpu_pause(v);
+
+    switch ( op )
+    {
+    case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON:
+        v->arch.hvm.single_step = true;
+        break;
+
+    case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF:
+        v->arch.hvm.single_step = false;
+        v->arch.hvm.fast_single_step.enabled = false;
+        v->arch.hvm.fast_single_step.p2midx = 0;
+        break;
+
+    default: /* Excluded above */
+        ASSERT_UNREACHABLE();
+        return -ENOSYS;
     }
 
+    vcpu_unpause(v); /* guest will latch new state */
+
     return rc;
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 23:44:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 23:44:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686350.1068248 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf77s-0002Fb-2b; Tue, 27 Feb 2024 23:44:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686350.1068248; Tue, 27 Feb 2024 23:44:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf77r-0002FU-W9; Tue, 27 Feb 2024 23:44:43 +0000
Received: by outflank-mailman (input) for mailman id 686350;
 Tue, 27 Feb 2024 23:44:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf77q-0002FI-Pl
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf77q-0004DR-P0
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf77q-0004Oo-MT
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=jCn38UukI3A2p3dX4Gu8NSeRfsso0Ku/51SirsHU3+w=; b=zYPjXAi9PeOHIrBBN3OWwsnlLe
	UdaTr6xFGKpl181c/TzAuVza+dqLH4X5ol/lymzmkCRsl3jC/YqWge7wjs2VOO8o0xl2BVI9+o1fp
	FfSjLsh84DTpKer06nCDm7Uf95ZEHe2jowiBbdw5TsNVogqNBgG2+FUkhIlI0K2pCef4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] x86/HVM: tidy state on hvmemul_map_linear_addr()'s error path
Message-Id: <E1rf77q-0004Oo-MT@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 23:44:42 +0000

commit 59e6ad6597dc9930c966b20485a9d0b369ff71a5
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 13:55:56 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:55:56 2024 +0100

    x86/HVM: tidy state on hvmemul_map_linear_addr()'s error path
    
    While in the vast majority of cases failure of the function will not
    be followed by re-invocation with the same emulation context, a few
    very specific insns - involving multiple independent writes, e.g. ENTER
    and PUSHA - exist where this can happen. Since failure of the function
    only signals to the caller that it ought to try an MMIO write instead,
    such failure also cannot be assumed to result in wholesale failure of
    emulation of the current insn. Instead we have to maintain internal
    state such that another invocation of the function with the same
    emulation context remains possible. To achieve that we need to reset MFN
    slots after putting page references on the error path.
    
    Note that all of this affects debugging code only, in causing an
    assertion to trigger (higher up in the function). There's otherwise no
    misbehavior - such a "leftover" slot would simply be overwritten by new
    contents in a release build.
    
    Also extend the related unmap() assertion, to further check for MFN 0.
    
    Fixes: 8cbd4fb0b7ea ("x86/hvm: implement hvmemul_write() using real mappings")
    Reported-by: Manuel Andreas <manuel.andreas@tum.de>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Paul Durrant <paul@xen.org>
    master commit: e72f951df407bc3be82faac64d8733a270036ba1
    master date: 2024-02-13 09:36:14 +0100
---
 xen/arch/x86/hvm/emulate.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 254716c766..865aa08bbc 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -696,7 +696,12 @@ static void *hvmemul_map_linear_addr(
  out:
     /* Drop all held references. */
     while ( mfn-- > hvmemul_ctxt->mfn )
+    {
         put_page(mfn_to_page(*mfn));
+#ifndef NDEBUG /* Clean slot for a subsequent map()'s error checking. */
+        *mfn = _mfn(0);
+#endif
+    }
 
     return err;
 }
@@ -718,7 +723,7 @@ static void hvmemul_unmap_linear_addr(
 
     for ( i = 0; i < nr_frames; i++ )
     {
-        ASSERT(mfn_valid(*mfn));
+        ASSERT(mfn_x(*mfn) && mfn_valid(*mfn));
         paging_mark_dirty(currd, *mfn);
         put_page(mfn_to_page(*mfn));
 
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 23:44:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 23:44:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686351.1068254 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf782-0002Id-4h; Tue, 27 Feb 2024 23:44:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686351.1068254; Tue, 27 Feb 2024 23:44:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf782-0002IV-1W; Tue, 27 Feb 2024 23:44:54 +0000
Received: by outflank-mailman (input) for mailman id 686351;
 Tue, 27 Feb 2024 23:44:52 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf780-0002IK-Sk
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:52 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf780-0004Dh-Ry
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf780-0004PH-R6
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:44:52 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=HxcMNV6jvR7LV1EFN2GIg+OPXDS6DK8/PiwykakkIBo=; b=vXvGcNbxnT4GIQjfhmLaAzhPgm
	5qEuUhZAnG8YvETfAoZS1YDktMhLQwxwRq6zB+TnoX6by5IcvbMQKajAYA+CszNOHTbAyo3TW+CLd
	x5+oghXX5JgkJjdytc/BLXW5IDlnVOPq4XNEYjC/6egi0TXTYb1u/zTsfeS7wbePF5eU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] build: Replace `which` with `command -v`
Message-Id: <E1rf780-0004PH-R6@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 23:44:52 +0000

commit 006764b871db75d5d025500a079ad246d1d418a1
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Tue Feb 27 13:56:25 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:56:25 2024 +0100

    build: Replace `which` with `command -v`
    
    The `which` command is not standard, may not exist on the build host,
    or may not behave as expected by the build system. It is recommended
    to use `command -v` to find out if a command exist and have its path,
    and it's part of a POSIX shell standard (at least, it seems to be
    mandatory since IEEE Std 1003.1-2008, but was optional before).
    
    Fixes: c8a8645f1efe ("xen/build: Automatically locate a suitable python interpreter")
    Fixes: 3b47bcdb6d38 ("xen/build: Use a distro version of figlet")
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Tested-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: f93629b18b528a5ab1b1092949c5420069c7226c
    master date: 2024-02-19 12:45:48 +0100
---
 xen/Makefile | 4 ++--
 xen/build.mk | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/Makefile b/xen/Makefile
index a92709b43e..59d368e4d8 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -25,8 +25,8 @@ export XEN_BUILD_HOST	:= $(shell hostname)
 endif
 
 # Best effort attempt to find a python interpreter, defaulting to Python 3 if
-# available.  Fall back to just `python` if `which` is nowhere to be found.
-PYTHON_INTERPRETER	:= $(word 1,$(shell which python3 python python2 2>/dev/null) python)
+# available.  Fall back to just `python`.
+PYTHON_INTERPRETER	:= $(word 1,$(shell command -v python3 || command -v python || command -v python2) python)
 export PYTHON		?= $(PYTHON_INTERPRETER)
 
 export CHECKPOLICY	?= checkpolicy
diff --git a/xen/build.mk b/xen/build.mk
index 26dd5a8e87..0f490ca71b 100644
--- a/xen/build.mk
+++ b/xen/build.mk
@@ -1,6 +1,6 @@
 quiet_cmd_banner = BANNER  $@
 define cmd_banner
-    if which figlet >/dev/null 2>&1 ; then \
+    if command -v figlet >/dev/null 2>&1 ; then \
 	echo " Xen $(XEN_FULLVERSION)" | figlet -f $< > $@.tmp; \
     else \
 	echo " Xen $(XEN_FULLVERSION)" > $@.tmp; \
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 23:45:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 23:45:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686352.1068256 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf78C-0002LP-5O; Tue, 27 Feb 2024 23:45:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686352.1068256; Tue, 27 Feb 2024 23:45:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf78C-0002LI-2u; Tue, 27 Feb 2024 23:45:04 +0000
Received: by outflank-mailman (input) for mailman id 686352;
 Tue, 27 Feb 2024 23:45:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78A-0002L3-VX
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78A-0004EI-Ur
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78A-0004Pz-UC
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=NGG7tAjj73Y8Q9+u9AUtpZJaRWT5qYcHuEnhAl51yx8=; b=jk1hEoVwal7DzMq0KjKG2a0f+f
	YRQzmIL4B8czgF5ikxRXDcGzK3iWY+5xte10pOTxFkc+VyahcV0bnEp92QESiIMEpn7Ald0TFQ6zM
	v2bw+3E7gO+DiBvAZrixJgppSB87sSvawt1Ee3Y3yHtg0Rpul28ZwIfkrn6NH7nCZfgY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] libxl: Disable relocating memory for qemu-xen in stubdomain too
Message-Id: <E1rf78A-0004Pz-UC@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 23:45:02 +0000

commit 489c2b9ba173376e978c0ef3de416a2f09452e85
Author:     Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
AuthorDate: Tue Feb 27 13:57:07 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:57:07 2024 +0100

    libxl: Disable relocating memory for qemu-xen in stubdomain too
    
    According to comments (and experiments) qemu-xen cannot handle memory
    reolcation done by hvmloader. The code was already disabled when running
    qemu-xen in dom0 (see libxl__spawn_local_dm()), but it was missed when
    adding qemu-xen support to stubdomain. Adjust libxl__spawn_stub_dm() to
    be consistent in this regard.
    
    Reported-by: Neowutran <xen@neowutran.ovh>
    Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    master commit: 97883aa269f6745a6ded232be3a855abb1297e0d
    master date: 2024-02-22 11:48:22 +0100
---
 tools/libs/light/libxl_dm.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
index 14b593110f..ed620a9d8e 100644
--- a/tools/libs/light/libxl_dm.c
+++ b/tools/libs/light/libxl_dm.c
@@ -2432,6 +2432,16 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
                         "%s",
                         libxl_bios_type_to_string(guest_config->b_info.u.hvm.bios));
     }
+    /* Disable relocating memory to make the MMIO hole larger
+     * unless we're running qemu-traditional and vNUMA is not
+     * configured. */
+    libxl__xs_printf(gc, XBT_NULL,
+                     libxl__sprintf(gc, "%s/hvmloader/allow-memory-relocate",
+                                    libxl__xs_get_dompath(gc, guest_domid)),
+                     "%d",
+                     guest_config->b_info.device_model_version
+                        == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL &&
+                     !libxl__vnuma_configured(&guest_config->b_info));
     ret = xc_domain_set_target(ctx->xch, dm_domid, guest_domid);
     if (ret<0) {
         LOGED(ERROR, guest_domid, "setting target domain %d -> %d",
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 23:45:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 23:45:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686354.1068261 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf78M-0002Oe-7D; Tue, 27 Feb 2024 23:45:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686354.1068261; Tue, 27 Feb 2024 23:45:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf78M-0002OW-4M; Tue, 27 Feb 2024 23:45:14 +0000
Received: by outflank-mailman (input) for mailman id 686354;
 Tue, 27 Feb 2024 23:45:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78L-0002OD-2M
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78L-0004EV-1Z
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78L-0004QQ-0i
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=TPwabU1AosxLjVCDkprDZRUhWLYgf0AjFKvpafNBWg0=; b=iyWoBYrkziggTAigraN9mm1vQ2
	faLUbhWkaNeNTjq2tgY19EEcR4z4KA+u0BQj5KMFJibCq1HeCn3GURec+aOcPsrNzbhj7Yve67Y8V
	/5wvJhq3TtrfY78NLoK/jr/TrR7tSBFw2lOWtMlbFdnph+1/xEJDfNLRxOvXc6Di62qw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] build: make sure build fails when running kconfig fails
Message-Id: <E1rf78L-0004QQ-0i@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 23:45:13 +0000

commit 5fda82641461a5234ab9bf0575423dfb8bfc5657
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 13:57:31 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:57:31 2024 +0100

    build: make sure build fails when running kconfig fails
    
    Because of using "-include", failure to (re)build auto.conf (with
    auto.conf.cmd produced as a secondary target) won't stop make from
    continuing the build. Arrange for it being possible to drop the - from
    Rules.mk, requiring that the include be skipped for tools-only targets.
    Note that relying on the inclusion in those cases wouldn't be correct
    anyway, as it might be a stale file (yet to be rebuilt) which would be
    included, while during initial build, the file would be absent
    altogether.
    
    Fixes: 8d4c17a90b0a ("xen/build: silence make warnings about missing auto.conf*")
    Reported-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    master commit: d34e5fa2e8db19f23081f46a3e710bb122130691
    master date: 2024-02-22 11:52:47 +0100
---
 xen/Makefile | 1 +
 xen/Rules.mk | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/xen/Makefile b/xen/Makefile
index 59d368e4d8..fdf9fd3f22 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -374,6 +374,7 @@ $(KCONFIG_CONFIG): tools_fixdep
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
+	$(Q)rm -f include/config/auto.conf
 	$(Q)$(MAKE) $(build)=tools/kconfig syncconfig
 
 ifeq ($(CONFIG_DEBUG),y)
diff --git a/xen/Rules.mk b/xen/Rules.mk
index 8af3dd7277..d759cccee3 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -15,7 +15,9 @@ srcdir := $(srctree)/$(src)
 PHONY := __build
 __build:
 
--include $(objtree)/include/config/auto.conf
+ifneq ($(firstword $(subst /, ,$(obj))),tools)
+include $(objtree)/include/config/auto.conf
+endif
 
 include $(XEN_ROOT)/Config.mk
 include $(srctree)/scripts/Kbuild.include
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 23:45:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 23:45:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686355.1068265 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf78W-0002RM-8p; Tue, 27 Feb 2024 23:45:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686355.1068265; Tue, 27 Feb 2024 23:45:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf78W-0002RE-5s; Tue, 27 Feb 2024 23:45:24 +0000
Received: by outflank-mailman (input) for mailman id 686355;
 Tue, 27 Feb 2024 23:45:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78V-0002R3-5s
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78V-0004Ed-4o
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78V-0004Qs-46
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=qoddPdmhcj+vkxTPzSaP6HHQCY8cIQQLEk4SoN97qso=; b=WKdRY5nGmMquQPCh/2ObHgO4h7
	jZBhGoStmJT5U9lciaw8mWt0CDCvkuMOTTItN9uYDuKWxfl6vztftwKx86AeRaIRu82wLNHFRD4uE
	enF8E7xzrlDYyj4Y82aXJtKqHMu+r2K/mSQwL5607Z4oSFXIaAgRqHIAww2nlb99jMaM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] x86emul: add missing EVEX.R' checks
Message-Id: <E1rf78V-0004Qs-46@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 23:45:23 +0000

commit a751d1321f6e1491d6ec2134d59eefa9f9752b86
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 13:57:50 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:57:50 2024 +0100

    x86emul: add missing EVEX.R' checks
    
    EVEX.R' is not ignored in 64-bit code when encoding a GPR or mask
    register. While for mask registers suitable checks are in place (there
    also covering EVEX.R), they were missing for the few cases where in
    EVEX-encoded instructions ModR/M.reg encodes a GPR. While for VPEXTRW
    the bit is replaced before an emulation stub is invoked, for
    VCVT{,T}{S,D,H}2{,U}SI this actually would have led to #UD from inside
    an emulation stub, in turn raising #UD to the guest, but accompanied by
    log messages indicating something's wrong in Xen nevertheless.
    
    Fixes: 001bd91ad864 ("x86emul: support AVX512{F,BW,DQ} extract insns")
    Fixes: baf4a376f550 ("x86emul: support AVX512F legacy-equivalent scalar int/FP conversion insns")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: cb319824bfa8d3c9ea0410cc71daaedc3e11aa2a
    master date: 2024-02-22 11:54:07 +0100
---
 xen/arch/x86/x86_emulate/x86_emulate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index cf780da501..d6b60f0539 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -3686,7 +3686,8 @@ x86_emulate(
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x2d): /* vcvts{s,d}2si xmm/mem,reg */
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x78): /* vcvtts{s,d}2usi xmm/mem,reg */
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x79): /* vcvts{s,d}2usi xmm/mem,reg */
-        generate_exception_if((evex.reg != 0xf || !evex.RX || evex.opmsk ||
+        generate_exception_if((evex.reg != 0xf || !evex.RX || !evex.R ||
+                               evex.opmsk ||
                                (ea.type != OP_REG && evex.brs)),
                               X86_EXC_UD);
         host_and_vcpu_must_have(avx512f);
@@ -7295,7 +7296,7 @@ x86_emulate(
         goto pextr;
 
     case X86EMUL_OPC_EVEX_66(0x0f, 0xc5):   /* vpextrw $imm8,xmm,reg */
-        generate_exception_if(ea.type != OP_REG, X86_EXC_UD);
+        generate_exception_if(ea.type != OP_REG || !evex.R, X86_EXC_UD);
         /* Convert to alternative encoding: We want to use a memory operand. */
         evex.opcx = ext_0f3a;
         b = 0x15;
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 23:45:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 23:45:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686356.1068268 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf78g-0002UH-A2; Tue, 27 Feb 2024 23:45:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686356.1068268; Tue, 27 Feb 2024 23:45:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf78g-0002UA-7I; Tue, 27 Feb 2024 23:45:34 +0000
Received: by outflank-mailman (input) for mailman id 686356;
 Tue, 27 Feb 2024 23:45:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78f-0002Ts-8K
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78f-0004F5-7i
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78f-0004RH-6v
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=1XGlNiuFSoNzw5v1+yAQSyc/MLIb1TH4le9Kx2mAhrI=; b=6JOGulUL2BB9NR6dY3Qswm/ajA
	QG4SVQDEZPc65Xx8ReCyXAi6Oei/zGxJm7uyLxnl9iU1J9RENyL3XsyjTlxgiU1GLUX8Tsze3hv1b
	JDE3PH+EPw+LY9r5lkN3e6AFm8WI13FWl5m4MnyUoiTEjGcNcekMSLi4DhbwuNv/gnSE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] xen/livepatch: fix norevert test hook setup typo
Message-Id: <E1rf78f-0004RH-6v@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 23:45:33 +0000

commit 33a0368d3beb82ddb0cf7ed398b047325bb7be1c
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 13:58:21 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:58:21 2024 +0100

    xen/livepatch: fix norevert test hook setup typo
    
    The test code has a typo in using LIVEPATCH_APPLY_HOOK() instead of
    LIVEPATCH_REVERT_HOOK().
    
    Fixes: 6047104c3ccc ('livepatch: Add per-function applied/reverted state tracking marker')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
    master commit: f0622dd4fd6ae6ddb523a45d89ed9b8f3a9a8f36
    master date: 2024-02-26 10:13:46 +0100
---
 xen/test/livepatch/xen_action_hooks_norevert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/test/livepatch/xen_action_hooks_norevert.c b/xen/test/livepatch/xen_action_hooks_norevert.c
index 3e21ade6ab..c173855192 100644
--- a/xen/test/livepatch/xen_action_hooks_norevert.c
+++ b/xen/test/livepatch/xen_action_hooks_norevert.c
@@ -120,7 +120,7 @@ static void post_revert_hook(livepatch_payload_t *payload)
     printk(KERN_DEBUG "%s: Hook done.\n", __func__);
 }
 
-LIVEPATCH_APPLY_HOOK(revert_hook);
+LIVEPATCH_REVERT_HOOK(revert_hook);
 
 LIVEPATCH_PREAPPLY_HOOK(pre_apply_hook);
 LIVEPATCH_POSTAPPLY_HOOK(post_apply_hook);
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 23:45:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 23:45:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686357.1068273 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf78q-0002X7-Bg; Tue, 27 Feb 2024 23:45:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686357.1068273; Tue, 27 Feb 2024 23:45:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf78q-0002X0-8p; Tue, 27 Feb 2024 23:45:44 +0000
Received: by outflank-mailman (input) for mailman id 686357;
 Tue, 27 Feb 2024 23:45:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78p-0002Wq-Bp
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:43 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78p-0004FE-B9
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78p-0004Rh-9r
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=EdOZyulIBSnESHnnyHkl/pILKwN/m0Azi9yteibujzs=; b=zWTvjtPxrMaU8Sawf5k7G0KGtl
	uijr/HyNia3jAls+o1b0RnAy/oiRd31RZC2ry77r8soJ2wgSxuwdSE5Cx/q1qUYP7mR/wZjZgl787
	pKTf71rt3NxmAspmOvOqXxIbDjo6vpDXJCWhoGwaY8MqH2lgDG0Rai6MCt7scQk6jvok=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] xen/cmdline: fix printf format specifier in no_config_param()
Message-Id: <E1rf78p-0004Rh-9r@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 23:45:43 +0000

commit f6e5ab5fa7257783fdbbaabf6010d8d97656c11f
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 13:58:36 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:58:36 2024 +0100

    xen/cmdline: fix printf format specifier in no_config_param()
    
    '*' sets the width field, which is the minimum number of characters to output,
    but what we want in no_config_param() is the precision instead, which is '.*'
    as it imposes a maximum limit on the output.
    
    Fixes: 68d757df8dd2 ('x86/pv: Options to disable and/or compile out 32bit PV support')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: ef101f525173cf51dc70f4c77862f6f10a8ddccf
    master date: 2024-02-26 10:17:40 +0100
---
 xen/include/xen/param.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/include/xen/param.h b/xen/include/xen/param.h
index 93c3fe7cb7..e02e49635c 100644
--- a/xen/include/xen/param.h
+++ b/xen/include/xen/param.h
@@ -191,7 +191,7 @@ static inline void no_config_param(const char *cfg, const char *param,
 {
     int len = e ? ({ ASSERT(e >= s); e - s; }) : strlen(s);
 
-    printk(XENLOG_INFO "CONFIG_%s disabled - ignoring '%s=%*s' setting\n",
+    printk(XENLOG_INFO "CONFIG_%s disabled - ignoring '%s=%.*s' setting\n",
            cfg, param, len, s);
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 23:45:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 23:45:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686358.1068278 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf790-0002Zs-DL; Tue, 27 Feb 2024 23:45:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686358.1068278; Tue, 27 Feb 2024 23:45:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf790-0002Zk-AJ; Tue, 27 Feb 2024 23:45:54 +0000
Received: by outflank-mailman (input) for mailman id 686358;
 Tue, 27 Feb 2024 23:45:53 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78z-0002ZZ-Ep
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:53 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78z-0004FN-E0
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:53 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf78z-0004SC-DC
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:45:53 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Vb88cxb6A6cxy0b1h6/08bJfX/q51Z9w0DBmeRZWhyA=; b=R9DuBd8NPGzIgfSzNMvy8CyMSH
	qAKGEKeYswqv0fkyiRZ04s8S+nvB3ie9HOiapo6aj9KzW7wMYHFX8h2bxp+8NLI9sHCISyoXgv5Cq
	g37+ST1JJNN0mlT+TQxEAZJHvPLUhNot0rfHBVXWBP7pqcngXH15ZXYemDUKDHzPVWXo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] x86/altcall: use a union as register type for function parameters on clang
Message-Id: <E1rf78z-0004SC-DC@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 23:45:53 +0000

commit 19fd9ff9981732995b1028f9e7e406061b723651
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 13:59:05 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:59:05 2024 +0100

    x86/altcall: use a union as register type for function parameters on clang
    
    The current code for alternative calls uses the caller parameter types as the
    types for the register variables that serve as function parameters:
    
    uint8_t foo;
    [...]
    alternative_call(myfunc, foo);
    
    Would expand roughly into:
    
    register unint8_t a1_ asm("rdi") = foo;
    register unsigned long a2_ asm("rsi");
    [...]
    asm volatile ("call *%c[addr](%%rip)"...);
    
    However with -O2 clang will generate incorrect code, given the following
    example:
    
    unsigned int func(uint8_t t)
    {
        return t;
    }
    
    static void bar(uint8_t b)
    {
        int ret_;
        register uint8_t di asm("rdi") = b;
        register unsigned long si asm("rsi");
        register unsigned long dx asm("rdx");
        register unsigned long cx asm("rcx");
        register unsigned long r8 asm("r8");
        register unsigned long r9 asm("r9");
        register unsigned long r10 asm("r10");
        register unsigned long r11 asm("r11");
    
        asm volatile ( "call %c[addr]"
                       : "+r" (di), "=r" (si), "=r" (dx),
                         "=r" (cx), "=r" (r8), "=r" (r9),
                         "=r" (r10), "=r" (r11), "=a" (ret_)
                       : [addr] "i" (&(func)), "g" (func)
                       : "memory" );
    }
    
    void foo(unsigned int a)
    {
        bar(a);
    }
    
    Clang generates the following assembly code:
    
    func:                                   # @func
            movl    %edi, %eax
            retq
    foo:                                    # @foo
            callq   func
            retq
    
    Note the truncation of the unsigned int parameter 'a' of foo() to uint8_t when
    passed into bar() is lost.  clang doesn't zero extend the parameters in the
    callee when required, as the psABI mandates.
    
    The above can be worked around by using a union when defining the register
    variables, so that `di` becomes:
    
    register union {
        uint8_t e;
        unsigned long r;
    } di asm("rdi") = { .e = b };
    
    Which results in following code generated for `foo()`:
    
    foo:                                    # @foo
            movzbl  %dil, %edi
            callq   func
            retq
    
    So the truncation is not longer lost.  Apply such workaround only when built
    with clang.
    
    Reported-by: Matthew Grooms <mgrooms@shrew.net>
    Link: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277200
    Link: https://github.com/llvm/llvm-project/issues/12579
    Link: https://github.com/llvm/llvm-project/issues/82598
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    master commit: 2ce562b2a413cbdb2e1128989ed1722290a27c4e
    master date: 2024-02-26 10:18:01 +0100
---
 xen/arch/x86/include/asm/alternative.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/xen/arch/x86/include/asm/alternative.h b/xen/arch/x86/include/asm/alternative.h
index a1cd6a9fe5..3c14db5078 100644
--- a/xen/arch/x86/include/asm/alternative.h
+++ b/xen/arch/x86/include/asm/alternative.h
@@ -167,9 +167,34 @@ extern void alternative_branches(void);
 #define ALT_CALL_arg5 "r8"
 #define ALT_CALL_arg6 "r9"
 
+#ifdef CONFIG_CC_IS_CLANG
+/*
+ * Use a union with an unsigned long in order to prevent clang from
+ * skipping a possible truncation of the value.  By using the union any
+ * truncation is carried before the call instruction, in turn covering
+ * for ABI-non-compliance in that the necessary clipping / extension of
+ * the value is supposed to be carried out in the callee.
+ *
+ * Note this behavior is not mandated by the standard, and hence could
+ * stop being a viable workaround, or worse, could cause a different set
+ * of code-generation issues in future clang versions.
+ *
+ * This has been reported upstream:
+ * https://github.com/llvm/llvm-project/issues/12579
+ * https://github.com/llvm/llvm-project/issues/82598
+ */
+#define ALT_CALL_ARG(arg, n)                                            \
+    register union {                                                    \
+        typeof(arg) e;                                                  \
+        unsigned long r;                                                \
+    } a ## n ## _ asm ( ALT_CALL_arg ## n ) = {                         \
+        .e = ({ BUILD_BUG_ON(sizeof(arg) > sizeof(void *)); (arg); })   \
+    }
+#else
 #define ALT_CALL_ARG(arg, n) \
     register typeof(arg) a ## n ## _ asm ( ALT_CALL_arg ## n ) = \
         ({ BUILD_BUG_ON(sizeof(arg) > sizeof(void *)); (arg); })
+#endif
 #define ALT_CALL_NO_ARG(n) \
     register unsigned long a ## n ## _ asm ( ALT_CALL_arg ## n )
 
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 23:46:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 23:46:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686359.1068281 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf79A-0002dE-Gp; Tue, 27 Feb 2024 23:46:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686359.1068281; Tue, 27 Feb 2024 23:46:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf79A-0002d6-Dv; Tue, 27 Feb 2024 23:46:04 +0000
Received: by outflank-mailman (input) for mailman id 686359;
 Tue, 27 Feb 2024 23:46:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf799-0002cy-Ha
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:46:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf799-0004Fl-Gw
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:46:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf799-0004TQ-GC
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:46:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=qixozA8kHLFp2bb1VykRqwmHucQehv239AyBQ3fWp64=; b=UFXJf2f2ruq+meOk1wvp53IvTZ
	8bvbgC9jbzHpzINTqu0jrg5C5ArMS9oXmuG46n26w3R5SKCw1RhsvAURdSBtHMLMRXSiGQQFItogs
	FAnZJec+XkrENuFHQL0WIZPmsQhDNH8AKE8tRk3HEMhcoJ2uhdcGPNbPQGLUzmzP2u/4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] x86/spec: fix BRANCH_HARDEN option to only be set when build-enabled
Message-Id: <E1rf799-0004TQ-GC@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 23:46:03 +0000

commit 4d47dca20dcfdca2340c8cda6f50dcdcafb1c054
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 13:59:42 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:59:42 2024 +0100

    x86/spec: fix BRANCH_HARDEN option to only be set when build-enabled
    
    The current logic to handle the BRANCH_HARDEN option will report it as enabled
    even when build-time disabled. Fix this by only allowing the option to be set
    when support for it is built into Xen.
    
    Fixes: 2d6f36daa086 ('x86/nospec: Introduce CONFIG_SPECULATIVE_HARDEN_BRANCH')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: 60e00f77a5cc671d30c5ef3318f5b8e9b74e4aa3
    master date: 2024-02-26 16:06:42 +0100
---
 xen/arch/x86/spec_ctrl.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index a8d8af22f6..01ba59cff7 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -50,7 +50,8 @@ static int8_t __initdata opt_psfd = -1;
 int8_t __ro_after_init opt_ibpb_ctxt_switch = -1;
 int8_t __read_mostly opt_eager_fpu = -1;
 int8_t __read_mostly opt_l1d_flush = -1;
-static bool __initdata opt_branch_harden = true;
+static bool __initdata opt_branch_harden =
+    IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH);
 
 bool __initdata bsp_delay_spec_ctrl;
 uint8_t __read_mostly default_xen_spec_ctrl;
@@ -268,7 +269,16 @@ static int __init cf_check parse_spec_ctrl(const char *s)
         else if ( (val = parse_boolean("l1d-flush", s, ss)) >= 0 )
             opt_l1d_flush = val;
         else if ( (val = parse_boolean("branch-harden", s, ss)) >= 0 )
-            opt_branch_harden = val;
+        {
+            if ( IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH) )
+                opt_branch_harden = val;
+            else
+            {
+                no_config_param("SPECULATIVE_HARDEN_BRANCH", "spec-ctrl", s,
+                                ss);
+                rc = -EINVAL;
+            }
+        }
         else if ( (val = parse_boolean("srb-lock", s, ss)) >= 0 )
             opt_srb_lock = val;
         else if ( (val = parse_boolean("unpriv-mmio", s, ss)) >= 0 )
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Tue Feb 27 23:46:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 27 Feb 2024 23:46:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686360.1068284 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf79K-0002gG-Hm; Tue, 27 Feb 2024 23:46:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686360.1068284; Tue, 27 Feb 2024 23:46:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rf79K-0002g9-FK; Tue, 27 Feb 2024 23:46:14 +0000
Received: by outflank-mailman (input) for mailman id 686360;
 Tue, 27 Feb 2024 23:46:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf79J-0002g3-Kj
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:46:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf79J-0004G2-K6
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:46:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rf79J-0004Tt-JL
 for xen-changelog@lists.xenproject.org; Tue, 27 Feb 2024 23:46:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=of8nPoFMWPsAfcGlApxsxsM7rYItqrGtIC4iUl67gAU=; b=PWmSeZfqleYWi+wxPcPzjZ2DfS
	GsuKiJ67Jda4aSErwAe5l6QfF3mGvnUAgZ7Gbd0QWA1GNYOFVVTXgNRomp2ek/KFZOUkLA3RQPyOH
	lfThAOao48qG/HAWCtmSDv3cpsUOJyCXIp4KNYhIensciU59ugjo+aFSGto0DAQ1qSGk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] x86: account for shadow stack in exception-from-stub recovery
Message-Id: <E1rf79J-0004Tt-JL@xenbits.xenproject.org>
Date: Tue, 27 Feb 2024 23:46:13 +0000

commit 58bb8115104c9fca749ee4cfcd3579ac1ed644db
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 14:00:22 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:00:22 2024 +0100

    x86: account for shadow stack in exception-from-stub recovery
    
    Dealing with exceptions raised from within emulation stubs involves
    discarding return address (replaced by exception related information).
    Such discarding of course also requires removing the corresponding entry
    from the shadow stack.
    
    Also amend the comment in fixup_exception_return(), to further clarify
    why use of ptr[1] can't be an out-of-bounds access.
    
    While touching do_invalid_op() also add a missing fall-through
    annotation.
    
    This is CVE-2023-46841 / XSA-451.
    
    Fixes: 209fb9919b50 ("x86/extable: Adjust extable handling to be shadow stack compatible")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: 91f5f7a9154919a765c3933521760acffeddbf28
    master date: 2024-02-27 13:49:22 +0100
---
 xen/arch/x86/extable.c             | 20 +++++++-----
 xen/arch/x86/include/asm/uaccess.h |  3 +-
 xen/arch/x86/traps.c               | 62 +++++++++++++++++++++++++++++++++++---
 3 files changed, 71 insertions(+), 14 deletions(-)

diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index 74b14246e9..8ffcd346d7 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -86,26 +86,29 @@ search_one_extable(const struct exception_table_entry *first,
 }
 
 unsigned long
-search_exception_table(const struct cpu_user_regs *regs)
+search_exception_table(const struct cpu_user_regs *regs, unsigned long *stub_ra)
 {
     const struct virtual_region *region = find_text_region(regs->rip);
     unsigned long stub = this_cpu(stubs.addr);
 
     if ( region && region->ex )
+    {
+        *stub_ra = 0;
         return search_one_extable(region->ex, region->ex_end, regs->rip);
+    }
 
     if ( regs->rip >= stub + STUB_BUF_SIZE / 2 &&
          regs->rip < stub + STUB_BUF_SIZE &&
          regs->rsp > (unsigned long)regs &&
          regs->rsp < (unsigned long)get_cpu_info() )
     {
-        unsigned long retptr = *(unsigned long *)regs->rsp;
+        unsigned long retaddr = *(unsigned long *)regs->rsp, fixup;
 
-        region = find_text_region(retptr);
-        retptr = region && region->ex
-                 ? search_one_extable(region->ex, region->ex_end, retptr)
-                 : 0;
-        if ( retptr )
+        region = find_text_region(retaddr);
+        fixup = region && region->ex
+                ? search_one_extable(region->ex, region->ex_end, retaddr)
+                : 0;
+        if ( fixup )
         {
             /*
              * Put trap number and error code on the stack (in place of the
@@ -117,7 +120,8 @@ search_exception_table(const struct cpu_user_regs *regs)
             };
 
             *(unsigned long *)regs->rsp = token.raw;
-            return retptr;
+            *stub_ra = retaddr;
+            return fixup;
         }
     }
 
diff --git a/xen/arch/x86/include/asm/uaccess.h b/xen/arch/x86/include/asm/uaccess.h
index 684fccd95c..74bb222c03 100644
--- a/xen/arch/x86/include/asm/uaccess.h
+++ b/xen/arch/x86/include/asm/uaccess.h
@@ -421,7 +421,8 @@ union stub_exception_token {
     unsigned long raw;
 };
 
-extern unsigned long search_exception_table(const struct cpu_user_regs *regs);
+extern unsigned long search_exception_table(const struct cpu_user_regs *regs,
+                                            unsigned long *stub_ra);
 extern void sort_exception_tables(void);
 extern void sort_exception_table(struct exception_table_entry *start,
                                  const struct exception_table_entry *stop);
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index e1356f696a..45e1b277ea 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -845,7 +845,7 @@ void do_unhandled_trap(struct cpu_user_regs *regs)
 }
 
 static void fixup_exception_return(struct cpu_user_regs *regs,
-                                   unsigned long fixup)
+                                   unsigned long fixup, unsigned long stub_ra)
 {
     if ( IS_ENABLED(CONFIG_XEN_SHSTK) )
     {
@@ -862,7 +862,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
             /*
              * Search for %rip.  The shstk currently looks like this:
              *
-             *   ...  [Likely pointed to by SSP]
+             *   tok  [Supervisor token, == &tok | BUSY, only with FRED inactive]
+             *   ...  [Pointed to by SSP for most exceptions, empty in IST cases]
              *   %cs  [== regs->cs]
              *   %rip [== regs->rip]
              *   SSP  [Likely points to 3 slots higher, above %cs]
@@ -880,7 +881,56 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
              */
             if ( ptr[0] == regs->rip && ptr[1] == regs->cs )
             {
+                unsigned long primary_shstk =
+                    (ssp & ~(STACK_SIZE - 1)) +
+                    (PRIMARY_SHSTK_SLOT + 1) * PAGE_SIZE - 8;
+
                 wrss(fixup, ptr);
+
+                if ( !stub_ra )
+                    goto shstk_done;
+
+                /*
+                 * Stub recovery ought to happen only when the outer context
+                 * was on the main shadow stack.  We need to also "pop" the
+                 * stub's return address from the interrupted context's shadow
+                 * stack.  That is,
+                 * - if we're still on the main stack, we need to move the
+                 *   entire stack (up to and including the exception frame)
+                 *   up by one slot, incrementing the original SSP in the
+                 *   exception frame,
+                 * - if we're on an IST stack, we need to increment the
+                 *   original SSP.
+                 */
+                BUG_ON((ptr[-1] ^ primary_shstk) >> PAGE_SHIFT);
+
+                if ( (ssp ^ primary_shstk) >> PAGE_SHIFT )
+                {
+                    /*
+                     * We're on an IST stack.  First make sure the two return
+                     * addresses actually match.  Then increment the interrupted
+                     * context's SSP.
+                     */
+                    BUG_ON(stub_ra != *(unsigned long*)ptr[-1]);
+                    wrss(ptr[-1] + 8, &ptr[-1]);
+                    goto shstk_done;
+                }
+
+                /* Make sure the two return addresses actually match. */
+                BUG_ON(stub_ra != ptr[2]);
+
+                /* Move exception frame, updating SSP there. */
+                wrss(ptr[1], &ptr[2]); /* %cs */
+                wrss(ptr[0], &ptr[1]); /* %rip */
+                wrss(ptr[-1] + 8, &ptr[0]); /* SSP */
+
+                /* Move all newer entries. */
+                while ( --ptr != _p(ssp) )
+                    wrss(ptr[-1], &ptr[0]);
+
+                /* Finally account for our own stack having shifted up. */
+                asm volatile ( "incsspd %0" :: "r" (2) );
+
                 goto shstk_done;
             }
         }
@@ -901,7 +951,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
 
 static bool extable_fixup(struct cpu_user_regs *regs, bool print)
 {
-    unsigned long fixup = search_exception_table(regs);
+    unsigned long stub_ra = 0;
+    unsigned long fixup = search_exception_table(regs, &stub_ra);
 
     if ( unlikely(fixup == 0) )
         return false;
@@ -915,7 +966,7 @@ static bool extable_fixup(struct cpu_user_regs *regs, bool print)
                vector_name(regs->entry_vector), regs->error_code,
                _p(regs->rip), _p(regs->rip), _p(fixup));
 
-    fixup_exception_return(regs, fixup);
+    fixup_exception_return(regs, fixup, stub_ra);
     this_cpu(last_extable_addr) = regs->rip;
 
     return true;
@@ -1183,7 +1234,8 @@ void do_invalid_op(struct cpu_user_regs *regs)
     {
     case BUGFRAME_run_fn:
     case BUGFRAME_warn:
-        fixup_exception_return(regs, (unsigned long)eip);
+        fixup_exception_return(regs, (unsigned long)eip, 0);
+        fallthrough;
     case BUGFRAME_bug:
     case BUGFRAME_assert:
         return;
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 02:55:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 02:55:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686390.1068349 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfA63-0000r1-Fu; Wed, 28 Feb 2024 02:55:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686390.1068349; Wed, 28 Feb 2024 02:55:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfA63-0000qu-DG; Wed, 28 Feb 2024 02:55:03 +0000
Received: by outflank-mailman (input) for mailman id 686390;
 Wed, 28 Feb 2024 02:55:01 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfA61-0000qf-Cj
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 02:55:01 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfA61-00072m-BV
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 02:55:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfA61-0008Hj-8u
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 02:55:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=S9BjaCgKnxswJP9VEhS04x5iz9AB4BVCQDoXDQ5vGVM=; b=Q4WTxaSexsDIx0hh47TE2g5lVT
	oExqxTa8/dKDrvmFcHMfBt6BYBRzVIftNZwk3tQqc13133/4nlDX4UslnUgF1pfhVPWMlmJts3ctH
	5Ywcj8csko1+GhUP81wIq/dqCptGhRuQgqlRj1jrF3Hea9F/lv6GSB9Adfg2Zypkt2pQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.15] x86: account for shadow stack in exception-from-stub recovery
Message-Id: <E1rfA61-0008Hj-8u@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 02:55:01 +0000

commit 2484803074fc1f93942912a82e4906f9e441bf4e
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 14:14:24 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:14:24 2024 +0100

    x86: account for shadow stack in exception-from-stub recovery
    
    Dealing with exceptions raised from within emulation stubs involves
    discarding return address (replaced by exception related information).
    Such discarding of course also requires removing the corresponding entry
    from the shadow stack.
    
    Also amend the comment in fixup_exception_return(), to further clarify
    why use of ptr[1] can't be an out-of-bounds access.
    
    This is CVE-2023-46841 / XSA-451.
    
    Fixes: 209fb9919b50 ("x86/extable: Adjust extable handling to be shadow stack compatible")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: 91f5f7a9154919a765c3933521760acffeddbf28
    master date: 2024-02-27 13:49:22 +0100
---
 xen/arch/x86/extable.c        | 20 ++++++++------
 xen/arch/x86/traps.c          | 63 ++++++++++++++++++++++++++++++++++++++-----
 xen/include/asm-x86/uaccess.h |  3 ++-
 3 files changed, 71 insertions(+), 15 deletions(-)

diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index 0d30595ea1..fd26712574 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -85,26 +85,29 @@ search_one_extable(const struct exception_table_entry *first,
 }
 
 unsigned long
-search_exception_table(const struct cpu_user_regs *regs)
+search_exception_table(const struct cpu_user_regs *regs, unsigned long *stub_ra)
 {
     const struct virtual_region *region = find_text_region(regs->rip);
     unsigned long stub = this_cpu(stubs.addr);
 
     if ( region && region->ex )
+    {
+        *stub_ra = 0;
         return search_one_extable(region->ex, region->ex_end - 1, regs->rip);
+    }
 
     if ( regs->rip >= stub + STUB_BUF_SIZE / 2 &&
          regs->rip < stub + STUB_BUF_SIZE &&
          regs->rsp > (unsigned long)regs &&
          regs->rsp < (unsigned long)get_cpu_info() )
     {
-        unsigned long retptr = *(unsigned long *)regs->rsp;
+        unsigned long retaddr = *(unsigned long *)regs->rsp, fixup;
 
-        region = find_text_region(retptr);
-        retptr = region && region->ex
-                 ? search_one_extable(region->ex, region->ex_end - 1, retptr)
-                 : 0;
-        if ( retptr )
+        region = find_text_region(retaddr);
+        fixup = region && region->ex
+                ? search_one_extable(region->ex, region->ex_end - 1, retaddr)
+                : 0;
+        if ( fixup )
         {
             /*
              * Put trap number and error code on the stack (in place of the
@@ -116,7 +119,8 @@ search_exception_table(const struct cpu_user_regs *regs)
             };
 
             *(unsigned long *)regs->rsp = token.raw;
-            return retptr;
+            *stub_ra = retaddr;
+            return fixup;
         }
     }
 
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index df97ee6c4f..273d4c3128 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -783,7 +783,7 @@ static void do_reserved_trap(struct cpu_user_regs *regs)
 }
 
 static void fixup_exception_return(struct cpu_user_regs *regs,
-                                   unsigned long fixup)
+                                   unsigned long fixup, unsigned long stub_ra)
 {
     if ( IS_ENABLED(CONFIG_XEN_SHSTK) )
     {
@@ -800,7 +800,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
             /*
              * Search for %rip.  The shstk currently looks like this:
              *
-             *   ...  [Likely pointed to by SSP]
+             *   tok  [Supervisor token, == &tok | BUSY, only with FRED inactive]
+             *   ...  [Pointed to by SSP for most exceptions, empty in IST cases]
              *   %cs  [== regs->cs]
              *   %rip [== regs->rip]
              *   SSP  [Likely points to 3 slots higher, above %cs]
@@ -818,7 +819,56 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
              */
             if ( ptr[0] == regs->rip && ptr[1] == regs->cs )
             {
+                unsigned long primary_shstk =
+                    (ssp & ~(STACK_SIZE - 1)) +
+                    (PRIMARY_SHSTK_SLOT + 1) * PAGE_SIZE - 8;
+
                 wrss(fixup, ptr);
+
+                if ( !stub_ra )
+                    goto shstk_done;
+
+                /*
+                 * Stub recovery ought to happen only when the outer context
+                 * was on the main shadow stack.  We need to also "pop" the
+                 * stub's return address from the interrupted context's shadow
+                 * stack.  That is,
+                 * - if we're still on the main stack, we need to move the
+                 *   entire stack (up to and including the exception frame)
+                 *   up by one slot, incrementing the original SSP in the
+                 *   exception frame,
+                 * - if we're on an IST stack, we need to increment the
+                 *   original SSP.
+                 */
+                BUG_ON((ptr[-1] ^ primary_shstk) >> PAGE_SHIFT);
+
+                if ( (ssp ^ primary_shstk) >> PAGE_SHIFT )
+                {
+                    /*
+                     * We're on an IST stack.  First make sure the two return
+                     * addresses actually match.  Then increment the interrupted
+                     * context's SSP.
+                     */
+                    BUG_ON(stub_ra != *(unsigned long*)ptr[-1]);
+                    wrss(ptr[-1] + 8, &ptr[-1]);
+                    goto shstk_done;
+                }
+
+                /* Make sure the two return addresses actually match. */
+                BUG_ON(stub_ra != ptr[2]);
+
+                /* Move exception frame, updating SSP there. */
+                wrss(ptr[1], &ptr[2]); /* %cs */
+                wrss(ptr[0], &ptr[1]); /* %rip */
+                wrss(ptr[-1] + 8, &ptr[0]); /* SSP */
+
+                /* Move all newer entries. */
+                while ( --ptr != _p(ssp) )
+                    wrss(ptr[-1], &ptr[0]);
+
+                /* Finally account for our own stack having shifted up. */
+                asm volatile ( "incsspd %0" :: "r" (2) );
+
                 goto shstk_done;
             }
         }
@@ -839,7 +889,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
 
 static bool extable_fixup(struct cpu_user_regs *regs, bool print)
 {
-    unsigned long fixup = search_exception_table(regs);
+    unsigned long stub_ra = 0;
+    unsigned long fixup = search_exception_table(regs, &stub_ra);
 
     if ( unlikely(fixup == 0) )
         return false;
@@ -853,7 +904,7 @@ static bool extable_fixup(struct cpu_user_regs *regs, bool print)
                vec_name(regs->entry_vector), regs->error_code,
                _p(regs->rip), _p(regs->rip), _p(fixup));
 
-    fixup_exception_return(regs, fixup);
+    fixup_exception_return(regs, fixup, stub_ra);
     this_cpu(last_extable_addr) = regs->rip;
 
     return true;
@@ -1144,7 +1195,7 @@ void do_invalid_op(struct cpu_user_regs *regs)
         void (*fn)(struct cpu_user_regs *) = bug_ptr(bug);
 
         fn(regs);
-        fixup_exception_return(regs, (unsigned long)eip);
+        fixup_exception_return(regs, (unsigned long)eip, 0);
         return;
     }
 
@@ -1165,7 +1216,7 @@ void do_invalid_op(struct cpu_user_regs *regs)
     case BUGFRAME_warn:
         printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno);
         show_execution_state(regs);
-        fixup_exception_return(regs, (unsigned long)eip);
+        fixup_exception_return(regs, (unsigned long)eip, 0);
         return;
 
     case BUGFRAME_bug:
diff --git a/xen/include/asm-x86/uaccess.h b/xen/include/asm-x86/uaccess.h
index 684fccd95c..74bb222c03 100644
--- a/xen/include/asm-x86/uaccess.h
+++ b/xen/include/asm-x86/uaccess.h
@@ -421,7 +421,8 @@ union stub_exception_token {
     unsigned long raw;
 };
 
-extern unsigned long search_exception_table(const struct cpu_user_regs *regs);
+extern unsigned long search_exception_table(const struct cpu_user_regs *regs,
+                                            unsigned long *stub_ra);
 extern void sort_exception_tables(void);
 extern void sort_exception_table(struct exception_table_entry *start,
                                  const struct exception_table_entry *stop);
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.15


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 10:11:07 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 10:11:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686442.1068463 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGty-00063i-G6; Wed, 28 Feb 2024 10:11:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686442.1068463; Wed, 28 Feb 2024 10:11:02 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGty-00063a-DA; Wed, 28 Feb 2024 10:11:02 +0000
Received: by outflank-mailman (input) for mailman id 686442;
 Wed, 28 Feb 2024 10:11:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGty-00063U-15
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGtx-0007lJ-Vf
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGtx-0001vE-SU
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=9wYeQFBoa1irFCNKEXF6hom8ROvfw2ATbkpwPvVLoLA=; b=HtiW79P8SmsQ0OQ/lPfYMGqAX+
	BIFKg7JDLXJhYzq/A/0dV/5fE+b9JMGyK0BUcAn0etKEPCxbKd2ydMr6pnZ8/dBYPcoB4jpx6Kujb
	GslyObktrsAoWGYOx1/fC5J9Fjh8gmGVDeXtM9MNdUtokT+G9nL8KDkcUdF/hKxKo8zw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] tools/xentop: fix sorting bug for some columns
Message-Id: <E1rfGtx-0001vE-SU@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 10:11:01 +0000

commit 61da71968ea44964fd1dd2e449b053c77eb83139
Author:     Cyril Rébert (zithro) <slack@rabbit.lu>
AuthorDate: Tue Feb 27 14:06:53 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:06:53 2024 +0100

    tools/xentop: fix sorting bug for some columns
    
    Sort doesn't work on columns VBD_OO, VBD_RD, VBD_WR and VBD_RSECT.
    Fix by adjusting variables names in compare functions.
    Bug fix only. No functional change.
    
    Fixes: 91c3e3dc91d6 ("tools/xentop: Display '-' when stats are not available.")
    Signed-off-by: Cyril Rébert (zithro) <slack@rabbit.lu>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    master commit: 29f17d837421f13c0e0010802de1b2d51d2ded4a
    master date: 2024-02-05 17:58:23 +0000
---
 tools/xentop/xentop.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/xentop/xentop.c b/tools/xentop/xentop.c
index 950e8935c4..545bd5e96d 100644
--- a/tools/xentop/xentop.c
+++ b/tools/xentop/xentop.c
@@ -684,7 +684,7 @@ static int compare_vbd_oo(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_oo = 0, dom2_vbd_oo = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_OO, &dom1_vbd_oo);
-	tot_vbd_reqs(domain1, FIELD_VBD_OO, &dom2_vbd_oo);
+	tot_vbd_reqs(domain2, FIELD_VBD_OO, &dom2_vbd_oo);
 
 	return -compare(dom1_vbd_oo, dom2_vbd_oo);
 }
@@ -711,9 +711,9 @@ static int compare_vbd_rd(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_rd = 0, dom2_vbd_rd = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_RD, &dom1_vbd_rd);
-	tot_vbd_reqs(domain1, FIELD_VBD_RD, &dom2_vbd_rd);
+	tot_vbd_reqs(domain2, FIELD_VBD_RD, &dom2_vbd_rd);
 
-	return -compare(dom1_vbd_rd, dom1_vbd_rd);
+	return -compare(dom1_vbd_rd, dom2_vbd_rd);
 }
 
 /* Prints number of total VBD READ requests statistic */
@@ -738,7 +738,7 @@ static int compare_vbd_wr(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_wr = 0, dom2_vbd_wr = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_WR, &dom1_vbd_wr);
-	tot_vbd_reqs(domain1, FIELD_VBD_WR, &dom2_vbd_wr);
+	tot_vbd_reqs(domain2, FIELD_VBD_WR, &dom2_vbd_wr);
 
 	return -compare(dom1_vbd_wr, dom2_vbd_wr);
 }
@@ -765,7 +765,7 @@ static int compare_vbd_rsect(xenstat_domain *domain1, xenstat_domain *domain2)
 	unsigned long long dom1_vbd_rsect = 0, dom2_vbd_rsect = 0;
 
 	tot_vbd_reqs(domain1, FIELD_VBD_RSECT, &dom1_vbd_rsect);
-	tot_vbd_reqs(domain1, FIELD_VBD_RSECT, &dom2_vbd_rsect);
+	tot_vbd_reqs(domain2, FIELD_VBD_RSECT, &dom2_vbd_rsect);
 
 	return -compare(dom1_vbd_rsect, dom2_vbd_rsect);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 10:11:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 10:11:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686443.1068467 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGu8-00065T-HQ; Wed, 28 Feb 2024 10:11:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686443.1068467; Wed, 28 Feb 2024 10:11:12 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGu8-00065M-Eh; Wed, 28 Feb 2024 10:11:12 +0000
Received: by outflank-mailman (input) for mailman id 686443;
 Wed, 28 Feb 2024 10:11:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGu8-00065G-4l
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGu8-0007lX-3G
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGu8-0001wK-1d
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=+Czh0dWflfmGx4VaeFtafOKubfZKtiVC8QVeOEVHVFk=; b=OVHreu1nX44UqKCx8qtwTmNTXD
	E9gdsPaME0+vVka2XOW4ZnNBHdhDJ+TaF0AfjFkJkqbAFawTjEjyvRrt6QaTkw2SpYJnV8BgCDhtO
	Sjq9dUSK9cv2Bgta+Xmfn0BkUYW5GZh5O4x8qDPWX65vMU0vYyM9qDFcSzFuMw82K24Q=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] amd-vi: fix IVMD memory type checks
Message-Id: <E1rfGu8-0001wK-1d@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 10:11:12 +0000

commit 463aaf3fbf62d24e898ae0c2ba53d85ca0f94d3f
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 14:07:12 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:07:12 2024 +0100

    amd-vi: fix IVMD memory type checks
    
    The current code that parses the IVMD blocks is relaxed with regard to the
    restriction that such unity regions should always fall into memory ranges
    marked as reserved in the memory map.
    
    However the type checks for the IVMD addresses are inverted, and as a result
    IVMD ranges falling into RAM areas are accepted.  Note that having such ranges
    in the first place is a firmware bug, as IVMD should always fall into reserved
    ranges.
    
    Fixes: ed6c77ebf0c1 ('AMD/IOMMU: check / convert IVMD ranges for being / to be reserved')
    Reported-by: Ox <oxjo@proton.me>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Tested-by: oxjo <oxjo@proton.me>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: 83afa313583019d9f159c122cecf867735d27ec5
    master date: 2024-02-06 11:56:13 +0100
---
 xen/drivers/passthrough/amd/iommu_acpi.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_acpi.c b/xen/drivers/passthrough/amd/iommu_acpi.c
index 3b577c9b39..3a7045c39b 100644
--- a/xen/drivers/passthrough/amd/iommu_acpi.c
+++ b/xen/drivers/passthrough/amd/iommu_acpi.c
@@ -426,9 +426,14 @@ static int __init parse_ivmd_block(const struct acpi_ivrs_memory *ivmd_block)
                 return -EIO;
             }
 
-            /* Types which won't be handed out are considered good enough. */
-            if ( !(type & (RAM_TYPE_RESERVED | RAM_TYPE_ACPI |
-                           RAM_TYPE_UNUSABLE)) )
+            /*
+             * Types which aren't RAM are considered good enough.
+             * Note that a page being partially RESERVED, ACPI or UNUSABLE will
+             * force Xen into assuming the whole page as having that type in
+             * practice.
+             */
+            if ( type & (RAM_TYPE_RESERVED | RAM_TYPE_ACPI |
+                         RAM_TYPE_UNUSABLE) )
                 continue;
 
             AMD_IOMMU_ERROR("IVMD: page at %lx can't be converted\n", addr);
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 10:11:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 10:11:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686444.1068471 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGuJ-00068l-KS; Wed, 28 Feb 2024 10:11:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686444.1068471; Wed, 28 Feb 2024 10:11:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGuJ-00068d-He; Wed, 28 Feb 2024 10:11:23 +0000
Received: by outflank-mailman (input) for mailman id 686444;
 Wed, 28 Feb 2024 10:11:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGuI-00068N-7g
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGuI-0007ln-6v
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGuI-0001wx-5X
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=aZGA4CeHXjxCQg/AimAltYlZH/5lPxlYQVMEFvU7IoU=; b=hwYmg7O0x2MnhX5HcUeUgVDGyg
	bpMZFiurZNkY26M9dw2Fw+zCXfifnRBamwbux/DSDoGE71hmp7FGKQ9k2a3at1hQOEqy0OO5XCSpb
	cB8EHt4dNJUs7oNAvQGj6vLA56GHCb1yN0bHRiZLDY08Mvo2CD0f8q+fiedGIv3h+5D4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] x86/hvm: Fix fast singlestep state persistence
Message-Id: <E1rfGuI-0001wx-5X@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 10:11:22 +0000

commit 415f770d23f9fcbc02436560fa6583dcd8e1343f
Author:     Petr Beneš <w1benny@gmail.com>
AuthorDate: Tue Feb 27 14:07:45 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:07:45 2024 +0100

    x86/hvm: Fix fast singlestep state persistence
    
    This patch addresses an issue where the fast singlestep setting would persist
    despite xc_domain_debug_control being called with XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF.
    Specifically, if fast singlestep was enabled in a VMI session and that session
    stopped before the MTF trap occurred, the fast singlestep setting remained
    active even though MTF itself was disabled.  This led to a situation where, upon
    starting a new VMI session, the first event to trigger an EPT violation would
    cause the corresponding EPT event callback to be skipped due to the lingering
    fast singlestep setting.
    
    The fix ensures that the fast singlestep setting is properly reset when
    disabling single step debugging operations.
    
    Signed-off-by: Petr Beneš <w1benny@gmail.com>
    Reviewed-by: Tamas K Lengyel <tamas@tklengyel.com>
    master commit: 897def94b56175ce569673a05909d2f223e1e749
    master date: 2024-02-12 09:37:58 +0100
---
 xen/arch/x86/hvm/hvm.c | 34 ++++++++++++++++++++++++----------
 1 file changed, 24 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index d6c6ab8897..558dc3eddc 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -5153,26 +5153,40 @@ long do_hvm_op(unsigned long op, XEN_GUEST_HANDLE_PARAM(void) arg)
 
 int hvm_debug_op(struct vcpu *v, int32_t op)
 {
-    int rc;
+    int rc = 0;
 
     switch ( op )
     {
         case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON:
         case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF:
-            rc = -EOPNOTSUPP;
             if ( !cpu_has_monitor_trap_flag )
-                break;
-            rc = 0;
-            vcpu_pause(v);
-            v->arch.hvm.single_step =
-                (op == XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON);
-            vcpu_unpause(v); /* guest will latch new state */
+                return -EOPNOTSUPP;
             break;
         default:
-            rc = -ENOSYS;
-            break;
+            return -ENOSYS;
+    }
+
+    vcpu_pause(v);
+
+    switch ( op )
+    {
+    case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_ON:
+        v->arch.hvm.single_step = true;
+        break;
+
+    case XEN_DOMCTL_DEBUG_OP_SINGLE_STEP_OFF:
+        v->arch.hvm.single_step = false;
+        v->arch.hvm.fast_single_step.enabled = false;
+        v->arch.hvm.fast_single_step.p2midx = 0;
+        break;
+
+    default: /* Excluded above */
+        ASSERT_UNREACHABLE();
+        return -ENOSYS;
     }
 
+    vcpu_unpause(v); /* guest will latch new state */
+
     return rc;
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 10:11:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 10:11:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686445.1068475 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGuT-0006BU-MA; Wed, 28 Feb 2024 10:11:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686445.1068475; Wed, 28 Feb 2024 10:11:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGuT-0006BN-JK; Wed, 28 Feb 2024 10:11:33 +0000
Received: by outflank-mailman (input) for mailman id 686445;
 Wed, 28 Feb 2024 10:11:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGuS-0006B9-Ai
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGuS-0007lv-9v
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGuS-0001xM-95
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ujOSQ+EuKbTFqgRsaczsNZ7aR6icrz7mIzPpjpJNQsw=; b=Ym/HHKUbkBRYHgynJqM4qECLUe
	qP3kYVI6ljfQoXmv4Ozf/fMgeMXdeAXrmDyFgfa9rNBeKjSXj7BcvXaw9uzJY8MwlAlzmiEGaoK+m
	plIJbPfkg/mkGFXi+ZCA8A85YkSqiSTpTOBCmxyVU4vLtvHPyhVazran35UpCiDadxW4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] x86/HVM: tidy state on hvmemul_map_linear_addr()'s error path
Message-Id: <E1rfGuS-0001xM-95@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 10:11:32 +0000

commit b3ae0e6201495216b12157bd8b2382b28fdd7dae
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 14:08:20 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:08:20 2024 +0100

    x86/HVM: tidy state on hvmemul_map_linear_addr()'s error path
    
    While in the vast majority of cases failure of the function will not
    be followed by re-invocation with the same emulation context, a few
    very specific insns - involving multiple independent writes, e.g. ENTER
    and PUSHA - exist where this can happen. Since failure of the function
    only signals to the caller that it ought to try an MMIO write instead,
    such failure also cannot be assumed to result in wholesale failure of
    emulation of the current insn. Instead we have to maintain internal
    state such that another invocation of the function with the same
    emulation context remains possible. To achieve that we need to reset MFN
    slots after putting page references on the error path.
    
    Note that all of this affects debugging code only, in causing an
    assertion to trigger (higher up in the function). There's otherwise no
    misbehavior - such a "leftover" slot would simply be overwritten by new
    contents in a release build.
    
    Also extend the related unmap() assertion, to further check for MFN 0.
    
    Fixes: 8cbd4fb0b7ea ("x86/hvm: implement hvmemul_write() using real mappings")
    Reported-by: Manuel Andreas <manuel.andreas@tum.de>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Paul Durrant <paul@xen.org>
    master commit: e72f951df407bc3be82faac64d8733a270036ba1
    master date: 2024-02-13 09:36:14 +0100
---
 xen/arch/x86/hvm/emulate.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index 275451dd36..27928dc3f3 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -697,7 +697,12 @@ static void *hvmemul_map_linear_addr(
  out:
     /* Drop all held references. */
     while ( mfn-- > hvmemul_ctxt->mfn )
+    {
         put_page(mfn_to_page(*mfn));
+#ifndef NDEBUG /* Clean slot for a subsequent map()'s error checking. */
+        *mfn = _mfn(0);
+#endif
+    }
 
     return err;
 }
@@ -719,7 +724,7 @@ static void hvmemul_unmap_linear_addr(
 
     for ( i = 0; i < nr_frames; i++ )
     {
-        ASSERT(mfn_valid(*mfn));
+        ASSERT(mfn_x(*mfn) && mfn_valid(*mfn));
         paging_mark_dirty(currd, *mfn);
         put_page(mfn_to_page(*mfn));
 
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 10:11:43 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 10:11:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686446.1068479 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGud-0006Eh-NX; Wed, 28 Feb 2024 10:11:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686446.1068479; Wed, 28 Feb 2024 10:11:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGud-0006Ea-L4; Wed, 28 Feb 2024 10:11:43 +0000
Received: by outflank-mailman (input) for mailman id 686446;
 Wed, 28 Feb 2024 10:11:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGuc-0006EJ-Db
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGuc-0007mL-Cr
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGuc-0001xp-C2
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ZDYUMmFr4NjGLdAWwGEbUKBeKaCe8I9y2aRlImiNbXA=; b=d3iV6wJ81cXgs/GTWfWo0oy7oS
	dIb5TXYk3kojibyKxmxHDnOMHLh1QPlS9bV3ig0TkmZ87QMCxeg2uDgc94LiU20ThucuvLcBpcnRp
	VOAnkEhpANYiDYI+cV2U9v57dnSink1M8Etmfr4Kz4JZD/UpmcHUwQ1laiIZeYHCOJH8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] build: Replace `which` with `command -v`
Message-Id: <E1rfGuc-0001xp-C2@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 10:11:42 +0000

commit 1330a5fe44ca91f98857b53fe8bbe06522d9db27
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Tue Feb 27 14:08:50 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:08:50 2024 +0100

    build: Replace `which` with `command -v`
    
    The `which` command is not standard, may not exist on the build host,
    or may not behave as expected by the build system. It is recommended
    to use `command -v` to find out if a command exist and have its path,
    and it's part of a POSIX shell standard (at least, it seems to be
    mandatory since IEEE Std 1003.1-2008, but was optional before).
    
    Fixes: c8a8645f1efe ("xen/build: Automatically locate a suitable python interpreter")
    Fixes: 3b47bcdb6d38 ("xen/build: Use a distro version of figlet")
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Tested-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: f93629b18b528a5ab1b1092949c5420069c7226c
    master date: 2024-02-19 12:45:48 +0100
---
 xen/Makefile | 4 ++--
 xen/build.mk | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/Makefile b/xen/Makefile
index dd0b004e1c..7ea13a6791 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -25,8 +25,8 @@ export XEN_BUILD_HOST	:= $(shell hostname)
 endif
 
 # Best effort attempt to find a python interpreter, defaulting to Python 3 if
-# available.  Fall back to just `python` if `which` is nowhere to be found.
-PYTHON_INTERPRETER	:= $(word 1,$(shell which python3 python python2 2>/dev/null) python)
+# available.  Fall back to just `python`.
+PYTHON_INTERPRETER	:= $(word 1,$(shell command -v python3 || command -v python || command -v python2) python)
 export PYTHON		?= $(PYTHON_INTERPRETER)
 
 export CHECKPOLICY	?= checkpolicy
diff --git a/xen/build.mk b/xen/build.mk
index 9ecb104f1e..b489f77b7c 100644
--- a/xen/build.mk
+++ b/xen/build.mk
@@ -1,6 +1,6 @@
 quiet_cmd_banner = BANNER  $@
 define cmd_banner
-    if which figlet >/dev/null 2>&1 ; then \
+    if command -v figlet >/dev/null 2>&1 ; then \
 	echo " Xen $(XEN_FULLVERSION)" | figlet -f $< > $@.tmp; \
     else \
 	echo " Xen $(XEN_FULLVERSION)" > $@.tmp; \
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 10:11:53 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 10:11:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686447.1068484 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGun-0006H9-QF; Wed, 28 Feb 2024 10:11:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686447.1068484; Wed, 28 Feb 2024 10:11:53 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGun-0006H1-MW; Wed, 28 Feb 2024 10:11:53 +0000
Received: by outflank-mailman (input) for mailman id 686447;
 Wed, 28 Feb 2024 10:11:52 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGum-0006Gq-Gd
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:52 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGum-0007mT-Fy
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGum-0001yE-F2
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:11:52 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=dFyHrGR9ex01i5AILaECQAvlLPQFOaCnvcSokxO1Kz0=; b=pbPthkgo/lB+6bI3fP5/1iu1kr
	5gsm9zxbLFPJfiHBFpCwaKMg+J6V22BRvdqz+hASa0ooZCPc0Lw/rd4dOXbQjXODPJpI2qz9ljtHd
	pOWyeQ6QsOLLCxO8AtUK4LX3meh4G5x7q8zgG2oWyjJ4XuvyQIArh64RQI/kzmQyReL4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] libxl: Disable relocating memory for qemu-xen in stubdomain too
Message-Id: <E1rfGum-0001yE-F2@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 10:11:52 +0000

commit b9745280736ee526374873aa3c4142596e2ba10b
Author:     Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
AuthorDate: Tue Feb 27 14:09:19 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:09:19 2024 +0100

    libxl: Disable relocating memory for qemu-xen in stubdomain too
    
    According to comments (and experiments) qemu-xen cannot handle memory
    reolcation done by hvmloader. The code was already disabled when running
    qemu-xen in dom0 (see libxl__spawn_local_dm()), but it was missed when
    adding qemu-xen support to stubdomain. Adjust libxl__spawn_stub_dm() to
    be consistent in this regard.
    
    Reported-by: Neowutran <xen@neowutran.ovh>
    Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
    master commit: 97883aa269f6745a6ded232be3a855abb1297e0d
    master date: 2024-02-22 11:48:22 +0100
---
 tools/libs/light/libxl_dm.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
index 14b593110f..ed620a9d8e 100644
--- a/tools/libs/light/libxl_dm.c
+++ b/tools/libs/light/libxl_dm.c
@@ -2432,6 +2432,16 @@ void libxl__spawn_stub_dm(libxl__egc *egc, libxl__stub_dm_spawn_state *sdss)
                         "%s",
                         libxl_bios_type_to_string(guest_config->b_info.u.hvm.bios));
     }
+    /* Disable relocating memory to make the MMIO hole larger
+     * unless we're running qemu-traditional and vNUMA is not
+     * configured. */
+    libxl__xs_printf(gc, XBT_NULL,
+                     libxl__sprintf(gc, "%s/hvmloader/allow-memory-relocate",
+                                    libxl__xs_get_dompath(gc, guest_domid)),
+                     "%d",
+                     guest_config->b_info.device_model_version
+                        == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL &&
+                     !libxl__vnuma_configured(&guest_config->b_info));
     ret = xc_domain_set_target(ctx->xch, dm_domid, guest_domid);
     if (ret<0) {
         LOGED(ERROR, guest_domid, "setting target domain %d -> %d",
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 10:12:03 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 10:12:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686448.1068486 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGux-0006JE-QZ; Wed, 28 Feb 2024 10:12:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686448.1068486; Wed, 28 Feb 2024 10:12:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGux-0006J7-O8; Wed, 28 Feb 2024 10:12:03 +0000
Received: by outflank-mailman (input) for mailman id 686448;
 Wed, 28 Feb 2024 10:12:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGuw-0006J1-KO
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGuw-0007mn-Jg
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGuw-0001z7-I7
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=tDajih1wtUg6vqP1+5XSNUgG8WbHjL0S/3sZ+CF2Q+w=; b=GGAxYjvkKIICinHfBhCLqXn5df
	uzrPLWmFH/dQ9wLr+myojoYrCQM/5h6ZP+wgZioZOZFomBraT5xq5G/53oOpQPjGBhb5d9QajI2DX
	gXKVX4xukPJh+cuF9p6KiY/NYeh+IntHCuxodUHWWcWU+6RDSiXcy46yuSg+LwU54tqQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] build: make sure build fails when running kconfig fails
Message-Id: <E1rfGuw-0001z7-I7@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 10:12:02 +0000

commit ea869977271f93945451908be9b6117ffd1fb02d
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 14:09:37 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:09:37 2024 +0100

    build: make sure build fails when running kconfig fails
    
    Because of using "-include", failure to (re)build auto.conf (with
    auto.conf.cmd produced as a secondary target) won't stop make from
    continuing the build. Arrange for it being possible to drop the - from
    Rules.mk, requiring that the include be skipped for tools-only targets.
    Note that relying on the inclusion in those cases wouldn't be correct
    anyway, as it might be a stale file (yet to be rebuilt) which would be
    included, while during initial build, the file would be absent
    altogether.
    
    Fixes: 8d4c17a90b0a ("xen/build: silence make warnings about missing auto.conf*")
    Reported-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    master commit: d34e5fa2e8db19f23081f46a3e710bb122130691
    master date: 2024-02-22 11:52:47 +0100
---
 xen/Makefile | 1 +
 xen/Rules.mk | 4 +++-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/xen/Makefile b/xen/Makefile
index 7ea13a6791..bac3684a36 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -374,6 +374,7 @@ $(KCONFIG_CONFIG): tools_fixdep
 # This exploits the 'multi-target pattern rule' trick.
 # The syncconfig should be executed only once to make all the targets.
 include/config/%.conf include/config/%.conf.cmd: $(KCONFIG_CONFIG)
+	$(Q)rm -f include/config/auto.conf
 	$(Q)$(MAKE) $(build)=tools/kconfig syncconfig
 
 ifeq ($(CONFIG_DEBUG),y)
diff --git a/xen/Rules.mk b/xen/Rules.mk
index 8af3dd7277..d759cccee3 100644
--- a/xen/Rules.mk
+++ b/xen/Rules.mk
@@ -15,7 +15,9 @@ srcdir := $(srctree)/$(src)
 PHONY := __build
 __build:
 
--include $(objtree)/include/config/auto.conf
+ifneq ($(firstword $(subst /, ,$(obj))),tools)
+include $(objtree)/include/config/auto.conf
+endif
 
 include $(XEN_ROOT)/Config.mk
 include $(srctree)/scripts/Kbuild.include
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 10:12:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 10:12:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686449.1068491 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGv7-0006MG-Sb; Wed, 28 Feb 2024 10:12:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686449.1068491; Wed, 28 Feb 2024 10:12:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGv7-0006M6-PY; Wed, 28 Feb 2024 10:12:13 +0000
Received: by outflank-mailman (input) for mailman id 686449;
 Wed, 28 Feb 2024 10:12:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGv6-0006Lr-OF
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGv6-0007mx-NB
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGv6-00020l-MJ
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=GMnM/L0+3Ao3b5WNXAcr0L0fup5zlLavEWU+RISC/d0=; b=Ctka4c4rOkqj0zt90fcUX81b9+
	XLxalY2E3RvbYR2cS24QVljRZvaRWjfogH8kQEL2is3ymjHnQUPgyQmonnW9plWkjvR7cgsIE2EJx
	hm9FgVm/tCAWq6aX4S/ipIK+V1ECEbgEJDqrem78rQj/P6kNxPqT4DeMyA2crdB8GOi4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] x86emul: add missing EVEX.R' checks
Message-Id: <E1rfGv6-00020l-MJ@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 10:12:12 +0000

commit 16f2e47eb1207d866f95cf694a60a7ceb8f96a36
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 14:09:55 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:09:55 2024 +0100

    x86emul: add missing EVEX.R' checks
    
    EVEX.R' is not ignored in 64-bit code when encoding a GPR or mask
    register. While for mask registers suitable checks are in place (there
    also covering EVEX.R), they were missing for the few cases where in
    EVEX-encoded instructions ModR/M.reg encodes a GPR. While for VPEXTRW
    the bit is replaced before an emulation stub is invoked, for
    VCVT{,T}{S,D,H}2{,U}SI this actually would have led to #UD from inside
    an emulation stub, in turn raising #UD to the guest, but accompanied by
    log messages indicating something's wrong in Xen nevertheless.
    
    Fixes: 001bd91ad864 ("x86emul: support AVX512{F,BW,DQ} extract insns")
    Fixes: baf4a376f550 ("x86emul: support AVX512F legacy-equivalent scalar int/FP conversion insns")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: cb319824bfa8d3c9ea0410cc71daaedc3e11aa2a
    master date: 2024-02-22 11:54:07 +0100
---
 xen/arch/x86/x86_emulate/x86_emulate.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index 0c0336f737..995670cbc8 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -6829,7 +6829,8 @@ x86_emulate(
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x2d): /* vcvts{s,d}2si xmm/mem,reg */
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x78): /* vcvtts{s,d}2usi xmm/mem,reg */
     CASE_SIMD_SCALAR_FP(_EVEX, 0x0f, 0x79): /* vcvts{s,d}2usi xmm/mem,reg */
-        generate_exception_if((evex.reg != 0xf || !evex.RX || evex.opmsk ||
+        generate_exception_if((evex.reg != 0xf || !evex.RX || !evex.R ||
+                               evex.opmsk ||
                                (ea.type != OP_REG && evex.brs)),
                               EXC_UD);
         host_and_vcpu_must_have(avx512f);
@@ -10705,7 +10706,7 @@ x86_emulate(
         goto pextr;
 
     case X86EMUL_OPC_EVEX_66(0x0f, 0xc5):   /* vpextrw $imm8,xmm,reg */
-        generate_exception_if(ea.type != OP_REG, EXC_UD);
+        generate_exception_if(ea.type != OP_REG || !evex.R, EXC_UD);
         /* Convert to alternative encoding: We want to use a memory operand. */
         evex.opcx = ext_0f3a;
         b = 0x15;
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 10:12:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 10:12:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686450.1068495 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGvH-0006PK-Tz; Wed, 28 Feb 2024 10:12:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686450.1068495; Wed, 28 Feb 2024 10:12:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGvH-0006PC-RG; Wed, 28 Feb 2024 10:12:23 +0000
Received: by outflank-mailman (input) for mailman id 686450;
 Wed, 28 Feb 2024 10:12:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGvG-0006P0-Qf
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGvG-0007n8-Q0
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGvG-00022B-PD
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=GfjJS3cCuJN2vWfvX5f/as01SiPO1FgjUD96SOyQ3bs=; b=UMYiAx1v4Tqs/qqiZUDavFsJL8
	GyxoDrKqFo20jn60wSqw/4dG+s3FmIzqv3HPvFGAwJlPxLn5Rdt6cn5ymqP7XrkL2CON6hUL6k8bl
	ht0Z+o4T2GPjNAuX7RZuonmf7R5uOkqzn8yuMtrxm4aY4GtP4MXerCCZUpm+3sSKC1g4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] xen/livepatch: fix norevert test hook setup typo
Message-Id: <E1rfGvG-00022B-PD@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 10:12:22 +0000

commit f6b12792542e372f36a71ea4c2563e6dd6e4fa57
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 14:10:24 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:10:24 2024 +0100

    xen/livepatch: fix norevert test hook setup typo
    
    The test code has a typo in using LIVEPATCH_APPLY_HOOK() instead of
    LIVEPATCH_REVERT_HOOK().
    
    Fixes: 6047104c3ccc ('livepatch: Add per-function applied/reverted state tracking marker')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
    master commit: f0622dd4fd6ae6ddb523a45d89ed9b8f3a9a8f36
    master date: 2024-02-26 10:13:46 +0100
---
 xen/test/livepatch/xen_action_hooks_norevert.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/test/livepatch/xen_action_hooks_norevert.c b/xen/test/livepatch/xen_action_hooks_norevert.c
index 3e21ade6ab..c173855192 100644
--- a/xen/test/livepatch/xen_action_hooks_norevert.c
+++ b/xen/test/livepatch/xen_action_hooks_norevert.c
@@ -120,7 +120,7 @@ static void post_revert_hook(livepatch_payload_t *payload)
     printk(KERN_DEBUG "%s: Hook done.\n", __func__);
 }
 
-LIVEPATCH_APPLY_HOOK(revert_hook);
+LIVEPATCH_REVERT_HOOK(revert_hook);
 
 LIVEPATCH_PREAPPLY_HOOK(pre_apply_hook);
 LIVEPATCH_POSTAPPLY_HOOK(post_apply_hook);
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 10:12:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 10:12:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686451.1068499 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGvS-0006Si-0U; Wed, 28 Feb 2024 10:12:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686451.1068499; Wed, 28 Feb 2024 10:12:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGvR-0006Sa-U9; Wed, 28 Feb 2024 10:12:33 +0000
Received: by outflank-mailman (input) for mailman id 686451;
 Wed, 28 Feb 2024 10:12:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGvQ-0006SP-U3
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGvQ-0007nQ-TJ
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGvQ-00022i-S3
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=bA+NhsYwiFrVL+M0SOHESwCo/1bpFv15capxLlsx4J0=; b=Svi9jgAa6F3ojg3CTG2ONAp+UI
	nL8bi7bP1WFgcpLdHnRc3VvJ7mxuUsR2hK1YktHmQAvM+omAXHBGYeyeysuDRmM/TLboynTlHTqsO
	TKm2xuqISLBBhDqYX8OE8F/7eUlR8jyfRXjOvbECGYg0ibjqJXaKwhx4g/dWgxb5PC+w=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] xen/cmdline: fix printf format specifier in no_config_param()
Message-Id: <E1rfGvQ-00022i-S3@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 10:12:32 +0000

commit 229e8a72ee4cde5698aaf42cc59ae57446dce60f
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 14:10:39 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:10:39 2024 +0100

    xen/cmdline: fix printf format specifier in no_config_param()
    
    '*' sets the width field, which is the minimum number of characters to output,
    but what we want in no_config_param() is the precision instead, which is '.*'
    as it imposes a maximum limit on the output.
    
    Fixes: 68d757df8dd2 ('x86/pv: Options to disable and/or compile out 32bit PV support')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: ef101f525173cf51dc70f4c77862f6f10a8ddccf
    master date: 2024-02-26 10:17:40 +0100
---
 xen/include/xen/param.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/include/xen/param.h b/xen/include/xen/param.h
index 93c3fe7cb7..e02e49635c 100644
--- a/xen/include/xen/param.h
+++ b/xen/include/xen/param.h
@@ -191,7 +191,7 @@ static inline void no_config_param(const char *cfg, const char *param,
 {
     int len = e ? ({ ASSERT(e >= s); e - s; }) : strlen(s);
 
-    printk(XENLOG_INFO "CONFIG_%s disabled - ignoring '%s=%*s' setting\n",
+    printk(XENLOG_INFO "CONFIG_%s disabled - ignoring '%s=%.*s' setting\n",
            cfg, param, len, s);
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 10:12:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 10:12:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686452.1068503 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGvc-0006VO-2D; Wed, 28 Feb 2024 10:12:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686452.1068503; Wed, 28 Feb 2024 10:12:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGvb-0006VF-Va; Wed, 28 Feb 2024 10:12:43 +0000
Received: by outflank-mailman (input) for mailman id 686452;
 Wed, 28 Feb 2024 10:12:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGvb-0006V8-0h
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:43 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGva-0007ns-W4
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGva-00023B-VL
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=OOK/FsiUf8m0NHlVqpHKt3D3mvXYs5VA8XWf6idIBig=; b=W60+HYpajrsbHTVryv/1HK8+9t
	zMlYXA5i/d7fAaNW6hZzecOaKF/JAl8lUA0BQh7G95Lj3GXDYvEglV6+LKUqqUtFYq/tR10mQ4n0K
	M8Iapu3dZAZ8I1gsNmQddDh6761O5Tt+Pqp7YK+MdWLKDwqaF7o/RLWl/SYr7wkrFAaU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] x86/altcall: use a union as register type for function parameters on clang
Message-Id: <E1rfGva-00023B-VL@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 10:12:42 +0000

commit 1aafe054e7d1efbf8e8482a9cdd4be5753b79e2f
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 14:11:04 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:11:04 2024 +0100

    x86/altcall: use a union as register type for function parameters on clang
    
    The current code for alternative calls uses the caller parameter types as the
    types for the register variables that serve as function parameters:
    
    uint8_t foo;
    [...]
    alternative_call(myfunc, foo);
    
    Would expand roughly into:
    
    register unint8_t a1_ asm("rdi") = foo;
    register unsigned long a2_ asm("rsi");
    [...]
    asm volatile ("call *%c[addr](%%rip)"...);
    
    However with -O2 clang will generate incorrect code, given the following
    example:
    
    unsigned int func(uint8_t t)
    {
        return t;
    }
    
    static void bar(uint8_t b)
    {
        int ret_;
        register uint8_t di asm("rdi") = b;
        register unsigned long si asm("rsi");
        register unsigned long dx asm("rdx");
        register unsigned long cx asm("rcx");
        register unsigned long r8 asm("r8");
        register unsigned long r9 asm("r9");
        register unsigned long r10 asm("r10");
        register unsigned long r11 asm("r11");
    
        asm volatile ( "call %c[addr]"
                       : "+r" (di), "=r" (si), "=r" (dx),
                         "=r" (cx), "=r" (r8), "=r" (r9),
                         "=r" (r10), "=r" (r11), "=a" (ret_)
                       : [addr] "i" (&(func)), "g" (func)
                       : "memory" );
    }
    
    void foo(unsigned int a)
    {
        bar(a);
    }
    
    Clang generates the following assembly code:
    
    func:                                   # @func
            movl    %edi, %eax
            retq
    foo:                                    # @foo
            callq   func
            retq
    
    Note the truncation of the unsigned int parameter 'a' of foo() to uint8_t when
    passed into bar() is lost.  clang doesn't zero extend the parameters in the
    callee when required, as the psABI mandates.
    
    The above can be worked around by using a union when defining the register
    variables, so that `di` becomes:
    
    register union {
        uint8_t e;
        unsigned long r;
    } di asm("rdi") = { .e = b };
    
    Which results in following code generated for `foo()`:
    
    foo:                                    # @foo
            movzbl  %dil, %edi
            callq   func
            retq
    
    So the truncation is not longer lost.  Apply such workaround only when built
    with clang.
    
    Reported-by: Matthew Grooms <mgrooms@shrew.net>
    Link: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=277200
    Link: https://github.com/llvm/llvm-project/issues/12579
    Link: https://github.com/llvm/llvm-project/issues/82598
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    master commit: 2ce562b2a413cbdb2e1128989ed1722290a27c4e
    master date: 2024-02-26 10:18:01 +0100
---
 xen/arch/x86/include/asm/alternative.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/xen/arch/x86/include/asm/alternative.h b/xen/arch/x86/include/asm/alternative.h
index a7a82c2c03..bcb1dc94f4 100644
--- a/xen/arch/x86/include/asm/alternative.h
+++ b/xen/arch/x86/include/asm/alternative.h
@@ -167,9 +167,34 @@ extern void alternative_branches(void);
 #define ALT_CALL_arg5 "r8"
 #define ALT_CALL_arg6 "r9"
 
+#ifdef CONFIG_CC_IS_CLANG
+/*
+ * Use a union with an unsigned long in order to prevent clang from
+ * skipping a possible truncation of the value.  By using the union any
+ * truncation is carried before the call instruction, in turn covering
+ * for ABI-non-compliance in that the necessary clipping / extension of
+ * the value is supposed to be carried out in the callee.
+ *
+ * Note this behavior is not mandated by the standard, and hence could
+ * stop being a viable workaround, or worse, could cause a different set
+ * of code-generation issues in future clang versions.
+ *
+ * This has been reported upstream:
+ * https://github.com/llvm/llvm-project/issues/12579
+ * https://github.com/llvm/llvm-project/issues/82598
+ */
+#define ALT_CALL_ARG(arg, n)                                            \
+    register union {                                                    \
+        typeof(arg) e;                                                  \
+        unsigned long r;                                                \
+    } a ## n ## _ asm ( ALT_CALL_arg ## n ) = {                         \
+        .e = ({ BUILD_BUG_ON(sizeof(arg) > sizeof(void *)); (arg); })   \
+    }
+#else
 #define ALT_CALL_ARG(arg, n) \
     register typeof(arg) a ## n ## _ asm ( ALT_CALL_arg ## n ) = \
         ({ BUILD_BUG_ON(sizeof(arg) > sizeof(void *)); (arg); })
+#endif
 #define ALT_CALL_NO_ARG(n) \
     register unsigned long a ## n ## _ asm ( ALT_CALL_arg ## n )
 
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 10:12:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 10:12:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686453.1068507 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGvm-0006Xw-3B; Wed, 28 Feb 2024 10:12:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686453.1068507; Wed, 28 Feb 2024 10:12:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGvm-0006Xp-0j; Wed, 28 Feb 2024 10:12:54 +0000
Received: by outflank-mailman (input) for mailman id 686453;
 Wed, 28 Feb 2024 10:12:53 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGvl-0006Xa-3H
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:53 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGvl-0007nz-2X
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:53 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGvl-00023n-1w
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:12:53 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=8CTjxigIdX3DaPhMS3UV/nfl5j/rkp3yGOWzpXoEdtI=; b=zLREJcwOMQoeO2ureRGphwJUNe
	ZCXjzMT3YifZCQz+kupzIXksDbsca3YO0vHzG5otZle1JM62VRLRfmw13Ozzcy2H4crmJ8zBkfQ5u
	6CBp+iTgXyjXT5gISqkI9dRzInvbcVFlrAWlSzE2f/4Vye8ujL0rguksI7ULOzylmG14=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] x86/spec: fix BRANCH_HARDEN option to only be set when build-enabled
Message-Id: <E1rfGvl-00023n-1w@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 10:12:53 +0000

commit 91650010815f3da0834bc9781c4359350d1162a5
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 14:11:40 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:11:40 2024 +0100

    x86/spec: fix BRANCH_HARDEN option to only be set when build-enabled
    
    The current logic to handle the BRANCH_HARDEN option will report it as enabled
    even when build-time disabled. Fix this by only allowing the option to be set
    when support for it is built into Xen.
    
    Fixes: 2d6f36daa086 ('x86/nospec: Introduce CONFIG_SPECULATIVE_HARDEN_BRANCH')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    master commit: 60e00f77a5cc671d30c5ef3318f5b8e9b74e4aa3
    master date: 2024-02-26 16:06:42 +0100
---
 xen/arch/x86/spec_ctrl.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 56e07d7536..661716d695 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -62,7 +62,8 @@ int8_t __initdata opt_psfd = -1;
 int8_t __ro_after_init opt_ibpb_ctxt_switch = -1;
 int8_t __read_mostly opt_eager_fpu = -1;
 int8_t __read_mostly opt_l1d_flush = -1;
-static bool __initdata opt_branch_harden = true;
+static bool __initdata opt_branch_harden =
+    IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH);
 
 bool __initdata bsp_delay_spec_ctrl;
 uint8_t __read_mostly default_xen_spec_ctrl;
@@ -280,7 +281,16 @@ static int __init cf_check parse_spec_ctrl(const char *s)
         else if ( (val = parse_boolean("l1d-flush", s, ss)) >= 0 )
             opt_l1d_flush = val;
         else if ( (val = parse_boolean("branch-harden", s, ss)) >= 0 )
-            opt_branch_harden = val;
+        {
+            if ( IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH) )
+                opt_branch_harden = val;
+            else
+            {
+                no_config_param("SPECULATIVE_HARDEN_BRANCH", "spec-ctrl", s,
+                                ss);
+                rc = -EINVAL;
+            }
+        }
         else if ( (val = parse_boolean("srb-lock", s, ss)) >= 0 )
             opt_srb_lock = val;
         else if ( (val = parse_boolean("unpriv-mmio", s, ss)) >= 0 )
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 10:13:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 10:13:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686454.1068510 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGvw-0006aS-4s; Wed, 28 Feb 2024 10:13:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686454.1068510; Wed, 28 Feb 2024 10:13:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfGvw-0006aK-2B; Wed, 28 Feb 2024 10:13:04 +0000
Received: by outflank-mailman (input) for mailman id 686454;
 Wed, 28 Feb 2024 10:13:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGvv-0006aA-6I
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:13:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGvv-0007oJ-5V
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:13:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfGvv-00024R-4m
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 10:13:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=SJLujkmDZyeLmzz1C+7HgGmlZNnuU5CW61DRxFhEGIs=; b=PVaa+XRYC5f5js7EGbx9upQ6u9
	auFn0U4jE1L4RkyO0DTH2TmzDVtCjLJenUh/MknxmS/zKEHaTfPMP4Yj+zIsDNhCgxX7U1GhqLxiA
	VD2ab3SGNsgKXAVmAa28epiue05b8lolVwoxzZtg//77mmRpAYUcOuyRqLVztsifHX58=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] x86: account for shadow stack in exception-from-stub recovery
Message-Id: <E1rfGvv-00024R-4m@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 10:13:03 +0000

commit 49f77602373b58b7bbdb40cea2b49d2f88d4003d
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 14:12:11 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:12:11 2024 +0100

    x86: account for shadow stack in exception-from-stub recovery
    
    Dealing with exceptions raised from within emulation stubs involves
    discarding return address (replaced by exception related information).
    Such discarding of course also requires removing the corresponding entry
    from the shadow stack.
    
    Also amend the comment in fixup_exception_return(), to further clarify
    why use of ptr[1] can't be an out-of-bounds access.
    
    This is CVE-2023-46841 / XSA-451.
    
    Fixes: 209fb9919b50 ("x86/extable: Adjust extable handling to be shadow stack compatible")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: 91f5f7a9154919a765c3933521760acffeddbf28
    master date: 2024-02-27 13:49:22 +0100
---
 xen/arch/x86/extable.c             | 20 +++++++-----
 xen/arch/x86/include/asm/uaccess.h |  3 +-
 xen/arch/x86/traps.c               | 63 ++++++++++++++++++++++++++++++++++----
 3 files changed, 71 insertions(+), 15 deletions(-)

diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index 6758ba1dca..dd9583f2a5 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -86,26 +86,29 @@ search_one_extable(const struct exception_table_entry *first,
 }
 
 unsigned long
-search_exception_table(const struct cpu_user_regs *regs)
+search_exception_table(const struct cpu_user_regs *regs, unsigned long *stub_ra)
 {
     const struct virtual_region *region = find_text_region(regs->rip);
     unsigned long stub = this_cpu(stubs.addr);
 
     if ( region && region->ex )
+    {
+        *stub_ra = 0;
         return search_one_extable(region->ex, region->ex_end, regs->rip);
+    }
 
     if ( regs->rip >= stub + STUB_BUF_SIZE / 2 &&
          regs->rip < stub + STUB_BUF_SIZE &&
          regs->rsp > (unsigned long)regs &&
          regs->rsp < (unsigned long)get_cpu_info() )
     {
-        unsigned long retptr = *(unsigned long *)regs->rsp;
+        unsigned long retaddr = *(unsigned long *)regs->rsp, fixup;
 
-        region = find_text_region(retptr);
-        retptr = region && region->ex
-                 ? search_one_extable(region->ex, region->ex_end, retptr)
-                 : 0;
-        if ( retptr )
+        region = find_text_region(retaddr);
+        fixup = region && region->ex
+                ? search_one_extable(region->ex, region->ex_end, retaddr)
+                : 0;
+        if ( fixup )
         {
             /*
              * Put trap number and error code on the stack (in place of the
@@ -117,7 +120,8 @@ search_exception_table(const struct cpu_user_regs *regs)
             };
 
             *(unsigned long *)regs->rsp = token.raw;
-            return retptr;
+            *stub_ra = retaddr;
+            return fixup;
         }
     }
 
diff --git a/xen/arch/x86/include/asm/uaccess.h b/xen/arch/x86/include/asm/uaccess.h
index 684fccd95c..74bb222c03 100644
--- a/xen/arch/x86/include/asm/uaccess.h
+++ b/xen/arch/x86/include/asm/uaccess.h
@@ -421,7 +421,8 @@ union stub_exception_token {
     unsigned long raw;
 };
 
-extern unsigned long search_exception_table(const struct cpu_user_regs *regs);
+extern unsigned long search_exception_table(const struct cpu_user_regs *regs,
+                                            unsigned long *stub_ra);
 extern void sort_exception_tables(void);
 extern void sort_exception_table(struct exception_table_entry *start,
                                  const struct exception_table_entry *stop);
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 06c4f3868b..7599bee361 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -856,7 +856,7 @@ void do_unhandled_trap(struct cpu_user_regs *regs)
 }
 
 static void fixup_exception_return(struct cpu_user_regs *regs,
-                                   unsigned long fixup)
+                                   unsigned long fixup, unsigned long stub_ra)
 {
     if ( IS_ENABLED(CONFIG_XEN_SHSTK) )
     {
@@ -873,7 +873,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
             /*
              * Search for %rip.  The shstk currently looks like this:
              *
-             *   ...  [Likely pointed to by SSP]
+             *   tok  [Supervisor token, == &tok | BUSY, only with FRED inactive]
+             *   ...  [Pointed to by SSP for most exceptions, empty in IST cases]
              *   %cs  [== regs->cs]
              *   %rip [== regs->rip]
              *   SSP  [Likely points to 3 slots higher, above %cs]
@@ -891,7 +892,56 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
              */
             if ( ptr[0] == regs->rip && ptr[1] == regs->cs )
             {
+                unsigned long primary_shstk =
+                    (ssp & ~(STACK_SIZE - 1)) +
+                    (PRIMARY_SHSTK_SLOT + 1) * PAGE_SIZE - 8;
+
                 wrss(fixup, ptr);
+
+                if ( !stub_ra )
+                    goto shstk_done;
+
+                /*
+                 * Stub recovery ought to happen only when the outer context
+                 * was on the main shadow stack.  We need to also "pop" the
+                 * stub's return address from the interrupted context's shadow
+                 * stack.  That is,
+                 * - if we're still on the main stack, we need to move the
+                 *   entire stack (up to and including the exception frame)
+                 *   up by one slot, incrementing the original SSP in the
+                 *   exception frame,
+                 * - if we're on an IST stack, we need to increment the
+                 *   original SSP.
+                 */
+                BUG_ON((ptr[-1] ^ primary_shstk) >> PAGE_SHIFT);
+
+                if ( (ssp ^ primary_shstk) >> PAGE_SHIFT )
+                {
+                    /*
+                     * We're on an IST stack.  First make sure the two return
+                     * addresses actually match.  Then increment the interrupted
+                     * context's SSP.
+                     */
+                    BUG_ON(stub_ra != *(unsigned long*)ptr[-1]);
+                    wrss(ptr[-1] + 8, &ptr[-1]);
+                    goto shstk_done;
+                }
+
+                /* Make sure the two return addresses actually match. */
+                BUG_ON(stub_ra != ptr[2]);
+
+                /* Move exception frame, updating SSP there. */
+                wrss(ptr[1], &ptr[2]); /* %cs */
+                wrss(ptr[0], &ptr[1]); /* %rip */
+                wrss(ptr[-1] + 8, &ptr[0]); /* SSP */
+
+                /* Move all newer entries. */
+                while ( --ptr != _p(ssp) )
+                    wrss(ptr[-1], &ptr[0]);
+
+                /* Finally account for our own stack having shifted up. */
+                asm volatile ( "incsspd %0" :: "r" (2) );
+
                 goto shstk_done;
             }
         }
@@ -912,7 +962,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
 
 static bool extable_fixup(struct cpu_user_regs *regs, bool print)
 {
-    unsigned long fixup = search_exception_table(regs);
+    unsigned long stub_ra = 0;
+    unsigned long fixup = search_exception_table(regs, &stub_ra);
 
     if ( unlikely(fixup == 0) )
         return false;
@@ -926,7 +977,7 @@ static bool extable_fixup(struct cpu_user_regs *regs, bool print)
                vector_name(regs->entry_vector), regs->error_code,
                _p(regs->rip), _p(regs->rip), _p(fixup));
 
-    fixup_exception_return(regs, fixup);
+    fixup_exception_return(regs, fixup, stub_ra);
     this_cpu(last_extable_addr) = regs->rip;
 
     return true;
@@ -1214,7 +1265,7 @@ void do_invalid_op(struct cpu_user_regs *regs)
         void (*fn)(struct cpu_user_regs *) = bug_ptr(bug);
 
         fn(regs);
-        fixup_exception_return(regs, (unsigned long)eip);
+        fixup_exception_return(regs, (unsigned long)eip, 0);
         return;
     }
 
@@ -1235,7 +1286,7 @@ void do_invalid_op(struct cpu_user_regs *regs)
     case BUGFRAME_warn:
         printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno);
         show_execution_state(regs);
-        fixup_exception_return(regs, (unsigned long)eip);
+        fixup_exception_return(regs, (unsigned long)eip, 0);
         return;
 
     case BUGFRAME_bug:
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 12:00:11 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 12:00:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686513.1068684 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfIbV-0004Cg-I7; Wed, 28 Feb 2024 12:00:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686513.1068684; Wed, 28 Feb 2024 12:00:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfIbV-0004CO-FO; Wed, 28 Feb 2024 12:00:05 +0000
Received: by outflank-mailman (input) for mailman id 686513;
 Wed, 28 Feb 2024 12:00:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfIbU-0003yW-6I
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 12:00:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfIbU-0001Mc-5U
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 12:00:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfIbU-0008Ah-4f
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 12:00:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=vyRUfp0DQblUgWsAF67zDgDDxBhRECuSpz9B03Vp2EI=; b=4/ED96O9hFkXRV9tQs/BkwULy7
	9isRnoqRosRBX8HaS3P4bm90FHUau95sVjsvj4RVm5ycmHf2soH4xzvm1h2R4LMkazwCOGAdugYJQ
	mnmdGaKE+voVt5Y8+lieVDCeMwSY6koEVqJQtvEeSnxnw5ecnhov0YaqwlSnYPKLLnj8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/lib: introduce generic find next bit operations
Message-Id: <E1rfIbU-0008Ah-4f@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 12:00:04 +0000

commit ba0d1a7cedc8b282b5b6e780e0846f3189e9cc90
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Fri Feb 9 18:58:30 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Wed Feb 28 11:55:32 2024 +0000

    xen/lib: introduce generic find next bit operations
    
    find-next-bit.c is common for Arm64, PPC and RISCV64,
    so it is moved to xen/lib.
    
    PPC has been transitioned to generic functions from find-next-bit.c
    since it now shares the same implementation as the PPC-specific code.
    
    The MISRA exclude list has been updated to verify
    lib/find-next-bit.c instead of Arm's find_next_bit.c,
    as Arm's find_next_bit.c has been relocated to xen/lib/.
    
    Despite CONFIG_GENERIC_FIND_FIRST_BIT not currently being used in
    Xen and being removed from the Linux kernel [1], it could theoretically
    prove useful for Xen. This is because the Linux kernel transitioned
    Arm to the generic version of find_first_bit() and
    find_first_zero_bit() due to improvements [1] in both performance
    and .text size.
    It would be prudent to investigate whether [1] is applicable to Xen
    as well and, if so, implement the necessary changes in a separate patch.
    
    [1] https://lore.kernel.org/linux-arch/20211005054059.475634-5-yury.norov@gmail.com/
    
    Suggested-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Shawn Anastasio <sanastasio@raptorengineering.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 docs/misra/exclude-list.json            |   8 +-
 xen/arch/arm/arm64/lib/Makefile         |   2 +-
 xen/arch/arm/arm64/lib/find_next_bit.c  | 281 --------------------------------
 xen/arch/arm/include/asm/arm64/bitops.h |  46 +-----
 xen/arch/ppc/include/asm/bitops.h       | 115 -------------
 xen/include/xen/bitops.h                |  48 ++++++
 xen/lib/Makefile                        |   1 +
 xen/lib/find-next-bit.c                 | 281 ++++++++++++++++++++++++++++++++
 8 files changed, 336 insertions(+), 446 deletions(-)

diff --git a/docs/misra/exclude-list.json b/docs/misra/exclude-list.json
index bfd967f0e4..36bad9e54f 100644
--- a/docs/misra/exclude-list.json
+++ b/docs/misra/exclude-list.json
@@ -13,10 +13,6 @@
             "rel_path": "arch/arm/arm64/insn.c",
             "comment": "Imported on Linux, ignore for now"
         },
-        {
-            "rel_path": "arch/arm/arm64/lib/find_next_bit.c",
-            "comment": "Imported from Linux, ignore for now"
-        },
         {
             "rel_path": "arch/x86/acpi/boot.c",
             "comment": "Imported from Linux, ignore for now"
@@ -225,6 +221,10 @@
             "rel_path": "include/xen/decompress.h",
             "comment": "Imported from Linux, ignore for now"
         },
+        {
+            "rel_path": "lib/find-next-bit.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
         {
             "rel_path": "lib/list-sort.c",
             "comment": "Imported from Linux, ignore for now"
diff --git a/xen/arch/arm/arm64/lib/Makefile b/xen/arch/arm/arm64/lib/Makefile
index 1b9c7a95e6..66cfac435a 100644
--- a/xen/arch/arm/arm64/lib/Makefile
+++ b/xen/arch/arm/arm64/lib/Makefile
@@ -1,4 +1,4 @@
 obj-y += memcpy.o memcmp.o memmove.o memset.o memchr.o
 obj-y += clear_page.o
-obj-y += bitops.o find_next_bit.o
+obj-y += bitops.o
 obj-y += strchr.o strcmp.o strlen.o strncmp.o strnlen.o strrchr.o
diff --git a/xen/arch/arm/arm64/lib/find_next_bit.c b/xen/arch/arm/arm64/lib/find_next_bit.c
deleted file mode 100644
index ca6f82277e..0000000000
--- a/xen/arch/arm/arm64/lib/find_next_bit.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/* find_next_bit.c: fallback find next bit implementation
- *
- * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
- * Written by David Howells (dhowells@redhat.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-#include <xen/bitops.h>
-
-#include <asm/byteorder.h>
-
-#ifndef find_next_bit
-/*
- * Find the next set bit in a memory region.
- */
-unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
-			    unsigned long offset)
-{
-	const unsigned long *p = addr + BIT_WORD(offset);
-	unsigned long result = offset & ~(BITS_PER_LONG-1);
-	unsigned long tmp;
-
-	if (offset >= size)
-		return size;
-	size -= result;
-	offset %= BITS_PER_LONG;
-	if (offset) {
-		tmp = *(p++);
-		tmp &= (~0UL << offset);
-		if (size < BITS_PER_LONG)
-			goto found_first;
-		if (tmp)
-			goto found_middle;
-		size -= BITS_PER_LONG;
-		result += BITS_PER_LONG;
-	}
-	while (size & ~(BITS_PER_LONG-1)) {
-		if ((tmp = *(p++)))
-			goto found_middle;
-		result += BITS_PER_LONG;
-		size -= BITS_PER_LONG;
-	}
-	if (!size)
-		return result;
-	tmp = *p;
-
-found_first:
-	tmp &= (~0UL >> (BITS_PER_LONG - size));
-	if (tmp == 0UL)		/* Are any bits set? */
-		return result + size;	/* Nope. */
-found_middle:
-	return result + __ffs(tmp);
-}
-EXPORT_SYMBOL(find_next_bit);
-#endif
-
-#ifndef find_next_zero_bit
-/*
- * This implementation of find_{first,next}_zero_bit was stolen from
- * Linus' asm-alpha/bitops.h.
- */
-unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
-				 unsigned long offset)
-{
-	const unsigned long *p = addr + BIT_WORD(offset);
-	unsigned long result = offset & ~(BITS_PER_LONG-1);
-	unsigned long tmp;
-
-	if (offset >= size)
-		return size;
-	size -= result;
-	offset %= BITS_PER_LONG;
-	if (offset) {
-		tmp = *(p++);
-		tmp |= ~0UL >> (BITS_PER_LONG - offset);
-		if (size < BITS_PER_LONG)
-			goto found_first;
-		if (~tmp)
-			goto found_middle;
-		size -= BITS_PER_LONG;
-		result += BITS_PER_LONG;
-	}
-	while (size & ~(BITS_PER_LONG-1)) {
-		if (~(tmp = *(p++)))
-			goto found_middle;
-		result += BITS_PER_LONG;
-		size -= BITS_PER_LONG;
-	}
-	if (!size)
-		return result;
-	tmp = *p;
-
-found_first:
-	tmp |= ~0UL << size;
-	if (tmp == ~0UL)	/* Are any bits zero? */
-		return result + size;	/* Nope. */
-found_middle:
-	return result + ffz(tmp);
-}
-EXPORT_SYMBOL(find_next_zero_bit);
-#endif
-
-#ifndef find_first_bit
-/*
- * Find the first set bit in a memory region.
- */
-unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
-{
-	const unsigned long *p = addr;
-	unsigned long result = 0;
-	unsigned long tmp;
-
-	while (size & ~(BITS_PER_LONG-1)) {
-		if ((tmp = *(p++)))
-			goto found;
-		result += BITS_PER_LONG;
-		size -= BITS_PER_LONG;
-	}
-	if (!size)
-		return result;
-
-	tmp = (*p) & (~0UL >> (BITS_PER_LONG - size));
-	if (tmp == 0UL)		/* Are any bits set? */
-		return result + size;	/* Nope. */
-found:
-	return result + __ffs(tmp);
-}
-EXPORT_SYMBOL(find_first_bit);
-#endif
-
-#ifndef find_first_zero_bit
-/*
- * Find the first cleared bit in a memory region.
- */
-unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
-{
-	const unsigned long *p = addr;
-	unsigned long result = 0;
-	unsigned long tmp;
-
-	while (size & ~(BITS_PER_LONG-1)) {
-		if (~(tmp = *(p++)))
-			goto found;
-		result += BITS_PER_LONG;
-		size -= BITS_PER_LONG;
-	}
-	if (!size)
-		return result;
-
-	tmp = (*p) | (~0UL << size);
-	if (tmp == ~0UL)	/* Are any bits zero? */
-		return result + size;	/* Nope. */
-found:
-	return result + ffz(tmp);
-}
-EXPORT_SYMBOL(find_first_zero_bit);
-#endif
-
-#ifdef __BIG_ENDIAN
-
-/* include/linux/byteorder does not support "unsigned long" type */
-static inline unsigned long ext2_swabp(const unsigned long * x)
-{
-#if BITS_PER_LONG == 64
-	return (unsigned long) __swab64p((u64 *) x);
-#elif BITS_PER_LONG == 32
-	return (unsigned long) __swab32p((u32 *) x);
-#else
-#error BITS_PER_LONG not defined
-#endif
-}
-
-/* include/linux/byteorder doesn't support "unsigned long" type */
-static inline unsigned long ext2_swab(const unsigned long y)
-{
-#if BITS_PER_LONG == 64
-	return (unsigned long) __swab64((u64) y);
-#elif BITS_PER_LONG == 32
-	return (unsigned long) __swab32((u32) y);
-#else
-#error BITS_PER_LONG not defined
-#endif
-}
-
-#ifndef find_next_zero_bit_le
-unsigned long find_next_zero_bit_le(const void *addr, unsigned
-		long size, unsigned long offset)
-{
-	const unsigned long *p = addr;
-	unsigned long result = offset & ~(BITS_PER_LONG - 1);
-	unsigned long tmp;
-
-	if (offset >= size)
-		return size;
-	p += BIT_WORD(offset);
-	size -= result;
-	offset &= (BITS_PER_LONG - 1UL);
-	if (offset) {
-		tmp = ext2_swabp(p++);
-		tmp |= (~0UL >> (BITS_PER_LONG - offset));
-		if (size < BITS_PER_LONG)
-			goto found_first;
-		if (~tmp)
-			goto found_middle;
-		size -= BITS_PER_LONG;
-		result += BITS_PER_LONG;
-	}
-
-	while (size & ~(BITS_PER_LONG - 1)) {
-		if (~(tmp = *(p++)))
-			goto found_middle_swap;
-		result += BITS_PER_LONG;
-		size -= BITS_PER_LONG;
-	}
-	if (!size)
-		return result;
-	tmp = ext2_swabp(p);
-found_first:
-	tmp |= ~0UL << size;
-	if (tmp == ~0UL)	/* Are any bits zero? */
-		return result + size; /* Nope. Skip ffz */
-found_middle:
-	return result + ffz(tmp);
-
-found_middle_swap:
-	return result + ffz(ext2_swab(tmp));
-}
-EXPORT_SYMBOL(find_next_zero_bit_le);
-#endif
-
-#ifndef find_next_bit_le
-unsigned long find_next_bit_le(const void *addr, unsigned
-		long size, unsigned long offset)
-{
-	const unsigned long *p = addr;
-	unsigned long result = offset & ~(BITS_PER_LONG - 1);
-	unsigned long tmp;
-
-	if (offset >= size)
-		return size;
-	p += BIT_WORD(offset);
-	size -= result;
-	offset &= (BITS_PER_LONG - 1UL);
-	if (offset) {
-		tmp = ext2_swabp(p++);
-		tmp &= (~0UL << offset);
-		if (size < BITS_PER_LONG)
-			goto found_first;
-		if (tmp)
-			goto found_middle;
-		size -= BITS_PER_LONG;
-		result += BITS_PER_LONG;
-	}
-
-	while (size & ~(BITS_PER_LONG - 1)) {
-		tmp = *(p++);
-		if (tmp)
-			goto found_middle_swap;
-		result += BITS_PER_LONG;
-		size -= BITS_PER_LONG;
-	}
-	if (!size)
-		return result;
-	tmp = ext2_swabp(p);
-found_first:
-	tmp &= (~0UL >> (BITS_PER_LONG - size));
-	if (tmp == 0UL)		/* Are any bits set? */
-		return result + size; /* Nope. */
-found_middle:
-	return result + __ffs(tmp);
-
-found_middle_swap:
-	return result + __ffs(ext2_swab(tmp));
-}
-EXPORT_SYMBOL(find_next_bit_le);
-#endif
-
-#endif /* __BIG_ENDIAN */
diff --git a/xen/arch/arm/include/asm/arm64/bitops.h b/xen/arch/arm/include/asm/arm64/bitops.h
index d85a49bca4..0efde29068 100644
--- a/xen/arch/arm/include/asm/arm64/bitops.h
+++ b/xen/arch/arm/include/asm/arm64/bitops.h
@@ -36,57 +36,13 @@ static inline int flsl(unsigned long x)
 
 /* Based on linux/include/asm-generic/bitops/find.h */
 
-#ifndef find_next_bit
-/**
- * find_next_bit - find the next set bit in a memory region
- * @addr: The address to base the search on
- * @offset: The bitnumber to start searching at
- * @size: The bitmap size in bits
- */
-extern unsigned long find_next_bit(const unsigned long *addr, unsigned long
-		size, unsigned long offset);
-#endif
-
-#ifndef find_next_zero_bit
-/**
- * find_next_zero_bit - find the next cleared bit in a memory region
- * @addr: The address to base the search on
- * @offset: The bitnumber to start searching at
- * @size: The bitmap size in bits
- */
-extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned
-		long size, unsigned long offset);
-#endif
-
-#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
-
-/**
- * find_first_bit - find the first set bit in a memory region
- * @addr: The address to start the search at
- * @size: The maximum size to search
- *
- * Returns the bit number of the first set bit.
- */
-extern unsigned long find_first_bit(const unsigned long *addr,
-				    unsigned long size);
-
-/**
- * find_first_zero_bit - find the first cleared bit in a memory region
- * @addr: The address to start the search at
- * @size: The maximum size to search
- *
- * Returns the bit number of the first cleared bit.
- */
-extern unsigned long find_first_zero_bit(const unsigned long *addr,
-					 unsigned long size);
-#else /* CONFIG_GENERIC_FIND_FIRST_BIT */
+#ifndef CONFIG_GENERIC_FIND_FIRST_BIT
 
 #define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
 #define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0)
 
 #endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
 
-
 #endif /* _ARM_ARM64_BITOPS_H */
 /*
  * Local variables:
diff --git a/xen/arch/ppc/include/asm/bitops.h b/xen/arch/ppc/include/asm/bitops.h
index 5e7f36c21d..5820b9ce7b 100644
--- a/xen/arch/ppc/include/asm/bitops.h
+++ b/xen/arch/ppc/include/asm/bitops.h
@@ -217,119 +217,4 @@ static always_inline unsigned long __ffs(unsigned long word)
  */
 #define find_first_set_bit(x) (ffsl(x) - 1)
 
-/*
- * Find the first set bit in a memory region.
- */
-static inline unsigned long find_first_bit(const unsigned long *addr,
-                                           unsigned long size)
-{
-    const unsigned long *p = addr;
-    unsigned long result = 0;
-    unsigned long tmp;
-
-    while ( size & ~(BITS_PER_LONG - 1) )
-    {
-        if ( (tmp = *(p++)) )
-            goto found;
-        result += BITS_PER_LONG;
-        size -= BITS_PER_LONG;
-    }
-    if ( !size )
-        return result;
-
-    tmp = (*p) & (~0UL >> (BITS_PER_LONG - size));
-    if ( tmp == 0UL )         /* Are any bits set? */
-        return result + size; /* Nope. */
- found:
-    return result + __ffs(tmp);
-}
-
-static inline unsigned long find_next_bit(const unsigned long *addr,
-                                          unsigned long size,
-                                          unsigned long offset)
-{
-    const unsigned long *p = addr + BITOP_WORD(offset);
-    unsigned long result = offset & ~(BITS_PER_LONG - 1);
-    unsigned long tmp;
-
-    if ( offset >= size )
-        return size;
-    size -= result;
-    offset %= BITS_PER_LONG;
-    if ( offset )
-    {
-        tmp = *(p++);
-        tmp &= (~0UL << offset);
-        if ( size < BITS_PER_LONG )
-            goto found_first;
-        if ( tmp )
-            goto found_middle;
-        size -= BITS_PER_LONG;
-        result += BITS_PER_LONG;
-    }
-    while ( size & ~(BITS_PER_LONG - 1) )
-    {
-        if ( (tmp = *(p++)) )
-            goto found_middle;
-        result += BITS_PER_LONG;
-        size -= BITS_PER_LONG;
-    }
-    if ( !size )
-        return result;
-    tmp = *p;
-
- found_first:
-    tmp &= (~0UL >> (BITS_PER_LONG - size));
-    if ( tmp == 0UL )         /* Are any bits set? */
-        return result + size; /* Nope. */
- found_middle:
-    return result + __ffs(tmp);
-}
-
-/*
- * This implementation of find_{first,next}_zero_bit was stolen from
- * Linus' asm-alpha/bitops.h.
- */
-static inline unsigned long find_next_zero_bit(const unsigned long *addr,
-                                               unsigned long size,
-                                               unsigned long offset)
-{
-    const unsigned long *p = addr + BITOP_WORD(offset);
-    unsigned long result = offset & ~(BITS_PER_LONG - 1);
-    unsigned long tmp;
-
-    if ( offset >= size )
-        return size;
-    size -= result;
-    offset %= BITS_PER_LONG;
-    if ( offset )
-    {
-        tmp = *(p++);
-        tmp |= ~0UL >> (BITS_PER_LONG - offset);
-        if ( size < BITS_PER_LONG )
-            goto found_first;
-        if ( ~tmp )
-            goto found_middle;
-        size -= BITS_PER_LONG;
-        result += BITS_PER_LONG;
-    }
-    while ( size & ~(BITS_PER_LONG - 1) )
-    {
-        if ( ~(tmp = *(p++)) )
-            goto found_middle;
-        result += BITS_PER_LONG;
-        size -= BITS_PER_LONG;
-    }
-    if ( !size )
-        return result;
-    tmp = *p;
-
- found_first:
-    tmp |= ~0UL << size;
-    if ( tmp == ~0UL )        /* Are any bits zero? */
-        return result + size; /* Nope. */
- found_middle:
-    return result + ffz(tmp);
-}
-
 #endif /* _ASM_PPC_BITOPS_H */
diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h
index 2cb7892bcc..e3c5a4ccf3 100644
--- a/xen/include/xen/bitops.h
+++ b/xen/include/xen/bitops.h
@@ -105,6 +105,54 @@ static inline int generic_flsl(unsigned long x)
  */
 #include <asm/bitops.h>
 
+#ifndef find_next_bit
+/**
+ * find_next_bit - find the next set bit in a memory region
+ * @addr: The address to base the search on
+ * @offset: The bitnumber to start searching at
+ * @size: The bitmap size in bits
+ */
+extern unsigned long find_next_bit(const unsigned long *addr,
+                                   unsigned long size,
+                                   unsigned long offset);
+#endif
+
+#ifndef find_next_zero_bit
+/**
+ * find_next_zero_bit - find the next cleared bit in a memory region
+ * @addr: The address to base the search on
+ * @offset: The bitnumber to start searching at
+ * @size: The bitmap size in bits
+ */
+extern unsigned long find_next_zero_bit(const unsigned long *addr,
+                                        unsigned long size,
+                                        unsigned long offset);
+#endif
+
+#ifndef find_first_bit
+/**
+ * find_first_bit - find the first set bit in a memory region
+ * @addr: The address to start the search at
+ * @size: The maximum size to search
+ *
+ * Returns the bit number of the first set bit.
+ */
+extern unsigned long find_first_bit(const unsigned long *addr,
+                                    unsigned long size);
+#endif
+
+#ifndef find_first_zero_bit
+/**
+ * find_first_zero_bit - find the first cleared bit in a memory region
+ * @addr: The address to start the search at
+ * @size: The maximum size to search
+ *
+ * Returns the bit number of the first cleared bit.
+ */
+extern unsigned long find_first_zero_bit(const unsigned long *addr,
+                                         unsigned long size);
+#endif
+
 #if BITS_PER_LONG == 64
 # define fls64 flsl
 # define ffs64 ffsl
diff --git a/xen/lib/Makefile b/xen/lib/Makefile
index 2d9ebb945f..e63798e1d4 100644
--- a/xen/lib/Makefile
+++ b/xen/lib/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_X86) += x86/
 lib-y += bsearch.o
 lib-y += ctors.o
 lib-y += ctype.o
+lib-y += find-next-bit.o
 lib-y += list-sort.o
 lib-y += memchr.o
 lib-y += memchr_inv.o
diff --git a/xen/lib/find-next-bit.c b/xen/lib/find-next-bit.c
new file mode 100644
index 0000000000..ca6f82277e
--- /dev/null
+++ b/xen/lib/find-next-bit.c
@@ -0,0 +1,281 @@
+/* find_next_bit.c: fallback find next bit implementation
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+#include <xen/bitops.h>
+
+#include <asm/byteorder.h>
+
+#ifndef find_next_bit
+/*
+ * Find the next set bit in a memory region.
+ */
+unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
+			    unsigned long offset)
+{
+	const unsigned long *p = addr + BIT_WORD(offset);
+	unsigned long result = offset & ~(BITS_PER_LONG-1);
+	unsigned long tmp;
+
+	if (offset >= size)
+		return size;
+	size -= result;
+	offset %= BITS_PER_LONG;
+	if (offset) {
+		tmp = *(p++);
+		tmp &= (~0UL << offset);
+		if (size < BITS_PER_LONG)
+			goto found_first;
+		if (tmp)
+			goto found_middle;
+		size -= BITS_PER_LONG;
+		result += BITS_PER_LONG;
+	}
+	while (size & ~(BITS_PER_LONG-1)) {
+		if ((tmp = *(p++)))
+			goto found_middle;
+		result += BITS_PER_LONG;
+		size -= BITS_PER_LONG;
+	}
+	if (!size)
+		return result;
+	tmp = *p;
+
+found_first:
+	tmp &= (~0UL >> (BITS_PER_LONG - size));
+	if (tmp == 0UL)		/* Are any bits set? */
+		return result + size;	/* Nope. */
+found_middle:
+	return result + __ffs(tmp);
+}
+EXPORT_SYMBOL(find_next_bit);
+#endif
+
+#ifndef find_next_zero_bit
+/*
+ * This implementation of find_{first,next}_zero_bit was stolen from
+ * Linus' asm-alpha/bitops.h.
+ */
+unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
+				 unsigned long offset)
+{
+	const unsigned long *p = addr + BIT_WORD(offset);
+	unsigned long result = offset & ~(BITS_PER_LONG-1);
+	unsigned long tmp;
+
+	if (offset >= size)
+		return size;
+	size -= result;
+	offset %= BITS_PER_LONG;
+	if (offset) {
+		tmp = *(p++);
+		tmp |= ~0UL >> (BITS_PER_LONG - offset);
+		if (size < BITS_PER_LONG)
+			goto found_first;
+		if (~tmp)
+			goto found_middle;
+		size -= BITS_PER_LONG;
+		result += BITS_PER_LONG;
+	}
+	while (size & ~(BITS_PER_LONG-1)) {
+		if (~(tmp = *(p++)))
+			goto found_middle;
+		result += BITS_PER_LONG;
+		size -= BITS_PER_LONG;
+	}
+	if (!size)
+		return result;
+	tmp = *p;
+
+found_first:
+	tmp |= ~0UL << size;
+	if (tmp == ~0UL)	/* Are any bits zero? */
+		return result + size;	/* Nope. */
+found_middle:
+	return result + ffz(tmp);
+}
+EXPORT_SYMBOL(find_next_zero_bit);
+#endif
+
+#ifndef find_first_bit
+/*
+ * Find the first set bit in a memory region.
+ */
+unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
+{
+	const unsigned long *p = addr;
+	unsigned long result = 0;
+	unsigned long tmp;
+
+	while (size & ~(BITS_PER_LONG-1)) {
+		if ((tmp = *(p++)))
+			goto found;
+		result += BITS_PER_LONG;
+		size -= BITS_PER_LONG;
+	}
+	if (!size)
+		return result;
+
+	tmp = (*p) & (~0UL >> (BITS_PER_LONG - size));
+	if (tmp == 0UL)		/* Are any bits set? */
+		return result + size;	/* Nope. */
+found:
+	return result + __ffs(tmp);
+}
+EXPORT_SYMBOL(find_first_bit);
+#endif
+
+#ifndef find_first_zero_bit
+/*
+ * Find the first cleared bit in a memory region.
+ */
+unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
+{
+	const unsigned long *p = addr;
+	unsigned long result = 0;
+	unsigned long tmp;
+
+	while (size & ~(BITS_PER_LONG-1)) {
+		if (~(tmp = *(p++)))
+			goto found;
+		result += BITS_PER_LONG;
+		size -= BITS_PER_LONG;
+	}
+	if (!size)
+		return result;
+
+	tmp = (*p) | (~0UL << size);
+	if (tmp == ~0UL)	/* Are any bits zero? */
+		return result + size;	/* Nope. */
+found:
+	return result + ffz(tmp);
+}
+EXPORT_SYMBOL(find_first_zero_bit);
+#endif
+
+#ifdef __BIG_ENDIAN
+
+/* include/linux/byteorder does not support "unsigned long" type */
+static inline unsigned long ext2_swabp(const unsigned long * x)
+{
+#if BITS_PER_LONG == 64
+	return (unsigned long) __swab64p((u64 *) x);
+#elif BITS_PER_LONG == 32
+	return (unsigned long) __swab32p((u32 *) x);
+#else
+#error BITS_PER_LONG not defined
+#endif
+}
+
+/* include/linux/byteorder doesn't support "unsigned long" type */
+static inline unsigned long ext2_swab(const unsigned long y)
+{
+#if BITS_PER_LONG == 64
+	return (unsigned long) __swab64((u64) y);
+#elif BITS_PER_LONG == 32
+	return (unsigned long) __swab32((u32) y);
+#else
+#error BITS_PER_LONG not defined
+#endif
+}
+
+#ifndef find_next_zero_bit_le
+unsigned long find_next_zero_bit_le(const void *addr, unsigned
+		long size, unsigned long offset)
+{
+	const unsigned long *p = addr;
+	unsigned long result = offset & ~(BITS_PER_LONG - 1);
+	unsigned long tmp;
+
+	if (offset >= size)
+		return size;
+	p += BIT_WORD(offset);
+	size -= result;
+	offset &= (BITS_PER_LONG - 1UL);
+	if (offset) {
+		tmp = ext2_swabp(p++);
+		tmp |= (~0UL >> (BITS_PER_LONG - offset));
+		if (size < BITS_PER_LONG)
+			goto found_first;
+		if (~tmp)
+			goto found_middle;
+		size -= BITS_PER_LONG;
+		result += BITS_PER_LONG;
+	}
+
+	while (size & ~(BITS_PER_LONG - 1)) {
+		if (~(tmp = *(p++)))
+			goto found_middle_swap;
+		result += BITS_PER_LONG;
+		size -= BITS_PER_LONG;
+	}
+	if (!size)
+		return result;
+	tmp = ext2_swabp(p);
+found_first:
+	tmp |= ~0UL << size;
+	if (tmp == ~0UL)	/* Are any bits zero? */
+		return result + size; /* Nope. Skip ffz */
+found_middle:
+	return result + ffz(tmp);
+
+found_middle_swap:
+	return result + ffz(ext2_swab(tmp));
+}
+EXPORT_SYMBOL(find_next_zero_bit_le);
+#endif
+
+#ifndef find_next_bit_le
+unsigned long find_next_bit_le(const void *addr, unsigned
+		long size, unsigned long offset)
+{
+	const unsigned long *p = addr;
+	unsigned long result = offset & ~(BITS_PER_LONG - 1);
+	unsigned long tmp;
+
+	if (offset >= size)
+		return size;
+	p += BIT_WORD(offset);
+	size -= result;
+	offset &= (BITS_PER_LONG - 1UL);
+	if (offset) {
+		tmp = ext2_swabp(p++);
+		tmp &= (~0UL << offset);
+		if (size < BITS_PER_LONG)
+			goto found_first;
+		if (tmp)
+			goto found_middle;
+		size -= BITS_PER_LONG;
+		result += BITS_PER_LONG;
+	}
+
+	while (size & ~(BITS_PER_LONG - 1)) {
+		tmp = *(p++);
+		if (tmp)
+			goto found_middle_swap;
+		result += BITS_PER_LONG;
+		size -= BITS_PER_LONG;
+	}
+	if (!size)
+		return result;
+	tmp = ext2_swabp(p);
+found_first:
+	tmp &= (~0UL >> (BITS_PER_LONG - size));
+	if (tmp == 0UL)		/* Are any bits set? */
+		return result + size; /* Nope. */
+found_middle:
+	return result + __ffs(tmp);
+
+found_middle_swap:
+	return result + __ffs(ext2_swab(tmp));
+}
+EXPORT_SYMBOL(find_next_bit_le);
+#endif
+
+#endif /* __BIG_ENDIAN */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 12:00:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 12:00:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686514.1068688 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfIbf-0004Rx-Jp; Wed, 28 Feb 2024 12:00:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686514.1068688; Wed, 28 Feb 2024 12:00:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfIbf-0004Rq-Gu; Wed, 28 Feb 2024 12:00:15 +0000
Received: by outflank-mailman (input) for mailman id 686514;
 Wed, 28 Feb 2024 12:00:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfIbe-0004RP-9M
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 12:00:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfIbe-0001Mm-8e
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 12:00:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfIbe-0008CJ-7m
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 12:00:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=xzU8wDSSulrgMZSShyY4afW/JQPBc+gWP/dC30KtC4U=; b=M4TR42PA16lsADlUZcxSObb0fZ
	Z5ts4Mr7nZ9XhZReK+/34BrwOccMqlAhj1TpAIF0huW5SCHT3UA/XCLpC3ehaqf2vsqGfB2n6iLk6
	2aJNf4heViZTIs7RNYGSY9unOQAKjYRX2llkaPSyfLINcUXx3F3CrUc2+9VIWvkD0v3I=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/arm: Fix arm32 build failure when early printk is enabled
Message-Id: <E1rfIbe-0008CJ-7m@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 12:00:14 +0000

commit b2b3d40f9a030ba79ce3abadccb5da485af33589
Author:     Michal Orzel <michal.orzel@amd.com>
AuthorDate: Wed Feb 28 11:35:55 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Wed Feb 28 11:56:47 2024 +0000

    xen/arm: Fix arm32 build failure when early printk is enabled
    
    Commit 0441c3acc7e9 forgot to rename FIXMAP_CONSOLE to FIX_CONSOLE in
    TEMPORARY_EARLY_UART_VIRTUAL_ADDRESS macro. This results in a build
    failure on arm32, when early printk is enabled:
    arch/arm/arm32/mmu/head.S:311: Error: invalid operands (*UND* and *ABS* sections) for `*'
    
    Fixes: 0441c3acc7e9 ("xen/arm: fixmap: Rename the fixmap slots to follow the x86 convention")
    Signed-off-by: Michal Orzel <michal.orzel@amd.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/include/asm/early_printk.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/include/asm/early_printk.h b/xen/arch/arm/include/asm/early_printk.h
index f444e89a86..46a5e562dd 100644
--- a/xen/arch/arm/include/asm/early_printk.h
+++ b/xen/arch/arm/include/asm/early_printk.h
@@ -20,7 +20,7 @@
     (FIXMAP_ADDR(FIX_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
 
 #define TEMPORARY_EARLY_UART_VIRTUAL_ADDRESS \
-    (TEMPORARY_FIXMAP_ADDR(FIXMAP_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
+    (TEMPORARY_FIXMAP_ADDR(FIX_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
 
 #endif /* !CONFIG_EARLY_PRINTK */
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 13:33:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 13:33:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686620.1068840 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfK3V-0003sA-BF; Wed, 28 Feb 2024 13:33:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686620.1068840; Wed, 28 Feb 2024 13:33:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfK3V-0003s3-8Q; Wed, 28 Feb 2024 13:33:05 +0000
Received: by outflank-mailman (input) for mailman id 686620;
 Wed, 28 Feb 2024 13:33:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfK3T-0003rx-VN
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 13:33:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfK3T-00030j-St
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 13:33:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfK3T-0004sX-Rw
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 13:33:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=KAgCi9b1eUrHHB+usaCSs2BB4YSHcDUFYum3xB7yWu8=; b=Xy7Fs5MMwzRDKPVH5qDa1ISQ0e
	LBQRzLMa9mlwn0fL52Vn7fVouZt42QELAGQXo1H+HTLXV1b89YPWTaEnO7MUjDrjZQMdKJcgV2lZ/
	3dq3FIHCYcVdhb62e3Kd6/yoqyCg3i1QdTW5RtjEj95eJ7nrz0tFMx9aMbd4fJv0nwnw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86: Resync intel-family.h from Linux
Message-Id: <E1rfK3T-0004sX-Rw@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 13:33:03 +0000

commit 195e75371b13c4f7ecdf7b5c50aed0d02f2d7ce8
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Feb 27 16:07:39 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Feb 28 13:25:04 2024 +0000

    x86: Resync intel-family.h from Linux
    
    From v6.8-rc6
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/include/asm/intel-family.h | 38 +++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/include/asm/intel-family.h b/xen/arch/x86/include/asm/intel-family.h
index ffc49151be..b65e9c46b9 100644
--- a/xen/arch/x86/include/asm/intel-family.h
+++ b/xen/arch/x86/include/asm/intel-family.h
@@ -26,6 +26,9 @@
  *		_G	- parts with extra graphics on
  *		_X	- regular server parts
  *		_D	- micro server parts
+ *		_N,_P	- other mobile parts
+ *		_H	- premium mobile parts
+ *		_S	- other client parts
  *
  *		Historical OPTDIFFs:
  *
@@ -37,6 +40,9 @@
  * their own names :-(
  */
 
+/* Wildcard match for FAM6 so X86_MATCH_INTEL_FAM6_MODEL(ANY) works */
+#define INTEL_FAM6_ANY			X86_MODEL_ANY
+
 #define INTEL_FAM6_CORE_YONAH		0x0E
 
 #define INTEL_FAM6_CORE2_MEROM		0x0F
@@ -93,8 +99,6 @@
 #define INTEL_FAM6_ICELAKE_L		0x7E	/* Sunny Cove */
 #define INTEL_FAM6_ICELAKE_NNPI		0x9D	/* Sunny Cove */
 
-#define INTEL_FAM6_LAKEFIELD		0x8A	/* Sunny Cove / Tremont */
-
 #define INTEL_FAM6_ROCKETLAKE		0xA7	/* Cypress Cove */
 
 #define INTEL_FAM6_TIGERLAKE_L		0x8C	/* Willow Cove */
@@ -102,12 +106,31 @@
 
 #define INTEL_FAM6_SAPPHIRERAPIDS_X	0x8F	/* Golden Cove */
 
+#define INTEL_FAM6_EMERALDRAPIDS_X	0xCF
+
+#define INTEL_FAM6_GRANITERAPIDS_X	0xAD
+#define INTEL_FAM6_GRANITERAPIDS_D	0xAE
+
+/* "Hybrid" Processors (P-Core/E-Core) */
+
+#define INTEL_FAM6_LAKEFIELD		0x8A	/* Sunny Cove / Tremont */
+
 #define INTEL_FAM6_ALDERLAKE		0x97	/* Golden Cove / Gracemont */
 #define INTEL_FAM6_ALDERLAKE_L		0x9A	/* Golden Cove / Gracemont */
 
-#define INTEL_FAM6_RAPTORLAKE		0xB7
+#define INTEL_FAM6_RAPTORLAKE		0xB7	/* Raptor Cove / Enhanced Gracemont */
+#define INTEL_FAM6_RAPTORLAKE_P		0xBA
+#define INTEL_FAM6_RAPTORLAKE_S		0xBF
+
+#define INTEL_FAM6_METEORLAKE		0xAC
+#define INTEL_FAM6_METEORLAKE_L		0xAA
+
+#define INTEL_FAM6_ARROWLAKE_H		0xC5
+#define INTEL_FAM6_ARROWLAKE		0xC6
+
+#define INTEL_FAM6_LUNARLAKE_M		0xBD
 
-/* "Small Core" Processors (Atom) */
+/* "Small Core" Processors (Atom/E-Core) */
 
 #define INTEL_FAM6_ATOM_BONNELL		0x1C /* Diamondville, Pineview */
 #define INTEL_FAM6_ATOM_BONNELL_MID	0x26 /* Silverthorne, Lincroft */
@@ -134,6 +157,13 @@
 #define INTEL_FAM6_ATOM_TREMONT		0x96 /* Elkhart Lake */
 #define INTEL_FAM6_ATOM_TREMONT_L	0x9C /* Jasper Lake */
 
+#define INTEL_FAM6_ATOM_GRACEMONT	0xBE /* Alderlake N */
+
+#define INTEL_FAM6_ATOM_CRESTMONT_X	0xAF /* Sierra Forest */
+#define INTEL_FAM6_ATOM_CRESTMONT	0xB6 /* Grand Ridge */
+
+#define INTEL_FAM6_ATOM_DARKMONT_X	0xDD /* Clearwater Forest */
+
 /* Xeon Phi */
 
 #define INTEL_FAM6_XEON_PHI_KNL		0x57 /* Knights Landing */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 17:00:11 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 17:00:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686747.1069168 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfNHp-0003AA-8D; Wed, 28 Feb 2024 17:00:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686747.1069168; Wed, 28 Feb 2024 17:00:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfNHp-00039k-5U; Wed, 28 Feb 2024 17:00:05 +0000
Received: by outflank-mailman (input) for mailman id 686747;
 Wed, 28 Feb 2024 17:00:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfNHn-0002r2-M0
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 17:00:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfNHn-0007Jy-Ib
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 17:00:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfNHn-0003AL-HI
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 17:00:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ZLJkGkBdSVSRnXX13ZdUIt2WXd1+W2vQc54mlB+V9JE=; b=j7UC2rQnDcd313meYSx7FZPs2k
	1fO4OylKusIqocKDeo0ySvBTdGTJ5h8Rq0vYcykw3mWbCV5HF4N5LYV6Nn2qH6+nay6xEFmoxeZo1
	tg9rYrjEQH+o5XTpKrlcQnuHx4xPCgHXngLA8OAVSnrFctuGbPIk+Jnjac+HqGXMtZ6w=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/livepatch: register livepatch regions when loaded
Message-Id: <E1rfNHn-0003AL-HI@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 17:00:03 +0000

commit a57b4074ab39bee78b6c116277f0a9963bd8e687
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 12:25:24 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Feb 28 16:57:25 2024 +0000

    xen/livepatch: register livepatch regions when loaded
    
    Currently livepatch regions are registered as virtual regions only after the
    livepatch has been applied.
    
    This can lead to issues when using the pre-apply or post-revert hooks, as at
    that point the livepatch is not in the virtual regions list.  If a livepatch
    pre-apply hook contains a WARN() it would trigger an hypervisor crash, as the
    code to handle the bug frame won't be able to find the instruction pointer that
    triggered the #UD in any of the registered virtual regions, and hence crash.
    
    Fix this by adding the livepatch payloads as virtual regions as soon as loaded,
    and only remove them once the payload is unloaded.  This requires some changes
    to the virtual regions code, as the removal of the virtual regions is no longer
    done in stop machine context, and hence an RCU barrier is added in order to
    make sure there are no users of the virtual region after it's been removed from
    the list.
    
    Fixes: 8313c864fa95 ('livepatch: Implement pre-|post- apply|revert hooks')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 xen/common/livepatch.c      |  4 ++--
 xen/common/virtual_region.c | 44 +++++++++++++++++---------------------------
 2 files changed, 19 insertions(+), 29 deletions(-)

diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
index 2c4b843827..d7f50e1018 100644
--- a/xen/common/livepatch.c
+++ b/xen/common/livepatch.c
@@ -1071,6 +1071,7 @@ static int build_symbol_table(struct payload *payload,
 static void free_payload(struct payload *data)
 {
     ASSERT(spin_is_locked(&payload_lock));
+    unregister_virtual_region(&data->region);
     list_del(&data->list);
     payload_cnt--;
     payload_version++;
@@ -1170,6 +1171,7 @@ static int livepatch_upload(struct xen_sysctl_livepatch_upload *upload)
         INIT_LIST_HEAD(&data->list);
         INIT_LIST_HEAD(&data->applied_list);
 
+        register_virtual_region(&data->region);
         list_add_tail(&data->list, &payload_list);
         payload_cnt++;
         payload_version++;
@@ -1386,7 +1388,6 @@ static inline void apply_payload_tail(struct payload *data)
      * The applied_list is iterated by the trap code.
      */
     list_add_tail_rcu(&data->applied_list, &applied_list);
-    register_virtual_region(&data->region);
 
     data->state = LIVEPATCH_STATE_APPLIED;
 }
@@ -1432,7 +1433,6 @@ static inline void revert_payload_tail(struct payload *data)
      * The applied_list is iterated by the trap code.
      */
     list_del_rcu(&data->applied_list);
-    unregister_virtual_region(&data->region);
 
     data->reverted = true;
     data->state = LIVEPATCH_STATE_CHECKED;
diff --git a/xen/common/virtual_region.c b/xen/common/virtual_region.c
index ddac5c9147..cefef3e47e 100644
--- a/xen/common/virtual_region.c
+++ b/xen/common/virtual_region.c
@@ -23,14 +23,8 @@ static struct virtual_region core_init __initdata = {
 };
 
 /*
- * RCU locking. Additions are done either at startup (when there is only
- * one CPU) or when all CPUs are running without IRQs.
- *
- * Deletions are bit tricky. We do it when Live Patch (all CPUs running
- * without IRQs) or during bootup (when clearing the init).
- *
- * Hence we use list_del_rcu (which sports an memory fence) and a spinlock
- * on deletion.
+ * RCU locking. Modifications to the list must be done in exclusive mode, and
+ * hence need to hold the spinlock.
  *
  * All readers of virtual_region_list MUST use list_for_each_entry_rcu.
  */
@@ -58,41 +52,36 @@ const struct virtual_region *find_text_region(unsigned long addr)
 
 void register_virtual_region(struct virtual_region *r)
 {
-    ASSERT(!local_irq_is_enabled());
+    unsigned long flags;
 
+    spin_lock_irqsave(&virtual_region_lock, flags);
     list_add_tail_rcu(&r->list, &virtual_region_list);
+    spin_unlock_irqrestore(&virtual_region_lock, flags);
 }
 
-static void remove_virtual_region(struct virtual_region *r)
+/*
+ * Suggest inline so when !CONFIG_LIVEPATCH the function is not left
+ * unreachable after init code is removed.
+ */
+static void inline remove_virtual_region(struct virtual_region *r)
 {
     unsigned long flags;
 
     spin_lock_irqsave(&virtual_region_lock, flags);
     list_del_rcu(&r->list);
     spin_unlock_irqrestore(&virtual_region_lock, flags);
-    /*
-     * We do not need to invoke call_rcu.
-     *
-     * This is due to the fact that on the deletion we have made sure
-     * to use spinlocks (to guard against somebody else calling
-     * unregister_virtual_region) and list_deletion spiced with
-     * memory barrier.
-     *
-     * That protects us from corrupting the list as the readers all
-     * use list_for_each_entry_rcu which is safe against concurrent
-     * deletions.
-     */
 }
 
+#ifdef CONFIG_LIVEPATCH
 void unregister_virtual_region(struct virtual_region *r)
 {
-    /* Expected to be called from Live Patch - which has IRQs disabled. */
-    ASSERT(!local_irq_is_enabled());
-
     remove_virtual_region(r);
+
+    /* Assert that no CPU might be using the removed region. */
+    rcu_barrier();
 }
 
-#if defined(CONFIG_LIVEPATCH) && defined(CONFIG_X86)
+#ifdef CONFIG_X86
 void relax_virtual_region_perms(void)
 {
     const struct virtual_region *region;
@@ -116,7 +105,8 @@ void tighten_virtual_region_perms(void)
                                  PAGE_HYPERVISOR_RX);
     rcu_read_unlock(&rcu_virtual_region_lock);
 }
-#endif
+#endif /* CONFIG_X86 */
+#endif /* CONFIG_LIVEPATCH */
 
 void __init unregister_init_virtual_region(void)
 {
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 17:00:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 17:00:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686748.1069173 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfNHz-0003Uw-9l; Wed, 28 Feb 2024 17:00:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686748.1069173; Wed, 28 Feb 2024 17:00:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfNHz-0003Uo-70; Wed, 28 Feb 2024 17:00:15 +0000
Received: by outflank-mailman (input) for mailman id 686748;
 Wed, 28 Feb 2024 17:00:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfNHx-0003Ue-NE
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 17:00:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfNHx-0007KA-MQ
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 17:00:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfNHx-0003BU-Kv
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 17:00:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=yuq9UfFSWPExotXbGhGaQcCEpadk5NbGXKQw97MtyQA=; b=lJY0XHTPH4pGwfONSsEskpTwgh
	pc3YjfbCEqp0AIxfZ1skZ23AL8qorN12Rxmxjh2Y4x3CkwJUMPp+CHNzGSr4J+CMwQp8jn76AhLP2
	6RL3jtnaLSq06w/Fe2+P6P7VnxFEHHa4b7E7sW8vGw4fQ0QOoOxVfD/gKf2On5CfHZyI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/livepatch: search for symbols in all loaded payloads
Message-Id: <E1rfNHx-0003BU-Kv@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 17:00:13 +0000

commit d2daa40fb3ddb8f83e238e57854bd878924cde90
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 12:25:25 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Feb 28 16:57:25 2024 +0000

    xen/livepatch: search for symbols in all loaded payloads
    
    When checking if an address belongs to a patch, or when resolving a symbol,
    take into account all loaded livepatch payloads, even if not applied.
    
    This is required in order for the pre-apply and post-revert hooks to work
    properly, or else Xen won't detect the instruction pointer belonging to those
    hooks as being part of the currently active text.
    
    Move the RCU handling to be used for payload_list instead of applied_list, as
    now the calls from trap code will iterate over the payload_list.
    
    Fixes: 8313c864fa95 ('livepatch: Implement pre-|post- apply|revert hooks')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 xen/common/livepatch.c | 49 +++++++++++++++++--------------------------------
 1 file changed, 17 insertions(+), 32 deletions(-)

diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
index d7f50e1018..14295bae87 100644
--- a/xen/common/livepatch.c
+++ b/xen/common/livepatch.c
@@ -36,13 +36,14 @@
  * caller in schedule_work.
  */
 static DEFINE_SPINLOCK(payload_lock);
-static LIST_HEAD(payload_list);
-
 /*
- * Patches which have been applied. Need RCU in case we crash (and then
- * traps code would iterate via applied_list) when adding entries on the list.
+ * Need RCU in case we crash (and then traps code would iterate via
+ * payload_list) when adding entries on the list.
  */
-static DEFINE_RCU_READ_LOCK(rcu_applied_lock);
+static DEFINE_RCU_READ_LOCK(rcu_payload_lock);
+static LIST_HEAD(payload_list);
+
+/* Patches which have been applied. Only modified from stop machine context. */
 static LIST_HEAD(applied_list);
 
 static unsigned int payload_cnt;
@@ -111,12 +112,8 @@ bool is_patch(const void *ptr)
     const struct payload *data;
     bool r = false;
 
-    /*
-     * Only RCU locking since this list is only ever changed during apply
-     * or revert context. And in case it dies there we need an safe list.
-     */
-    rcu_read_lock(&rcu_applied_lock);
-    list_for_each_entry_rcu ( data, &applied_list, applied_list )
+    rcu_read_lock(&rcu_payload_lock);
+    list_for_each_entry_rcu ( data, &payload_list, list )
     {
         if ( (ptr >= data->rw_addr &&
               ptr < (data->rw_addr + data->rw_size)) ||
@@ -130,7 +127,7 @@ bool is_patch(const void *ptr)
         }
 
     }
-    rcu_read_unlock(&rcu_applied_lock);
+    rcu_read_unlock(&rcu_payload_lock);
 
     return r;
 }
@@ -166,12 +163,8 @@ static const char *cf_check livepatch_symbols_lookup(
     const void *va = (const void *)addr;
     const char *n = NULL;
 
-    /*
-     * Only RCU locking since this list is only ever changed during apply
-     * or revert context. And in case it dies there we need an safe list.
-     */
-    rcu_read_lock(&rcu_applied_lock);
-    list_for_each_entry_rcu ( data, &applied_list, applied_list )
+    rcu_read_lock(&rcu_payload_lock);
+    list_for_each_entry_rcu ( data, &payload_list, list )
     {
         if ( va < data->text_addr ||
              va >= (data->text_addr + data->text_size) )
@@ -200,7 +193,7 @@ static const char *cf_check livepatch_symbols_lookup(
         n = data->symtab[best].name;
         break;
     }
-    rcu_read_unlock(&rcu_applied_lock);
+    rcu_read_unlock(&rcu_payload_lock);
 
     return n;
 }
@@ -1072,7 +1065,8 @@ static void free_payload(struct payload *data)
 {
     ASSERT(spin_is_locked(&payload_lock));
     unregister_virtual_region(&data->region);
-    list_del(&data->list);
+    list_del_rcu(&data->list);
+    rcu_barrier();
     payload_cnt--;
     payload_version++;
     free_payload_data(data);
@@ -1172,7 +1166,7 @@ static int livepatch_upload(struct xen_sysctl_livepatch_upload *upload)
         INIT_LIST_HEAD(&data->applied_list);
 
         register_virtual_region(&data->region);
-        list_add_tail(&data->list, &payload_list);
+        list_add_tail_rcu(&data->list, &payload_list);
         payload_cnt++;
         payload_version++;
     }
@@ -1383,11 +1377,7 @@ static int apply_payload(struct payload *data)
 
 static inline void apply_payload_tail(struct payload *data)
 {
-    /*
-     * We need RCU variant (which has barriers) in case we crash here.
-     * The applied_list is iterated by the trap code.
-     */
-    list_add_tail_rcu(&data->applied_list, &applied_list);
+    list_add_tail(&data->applied_list, &applied_list);
 
     data->state = LIVEPATCH_STATE_APPLIED;
 }
@@ -1427,12 +1417,7 @@ static int revert_payload(struct payload *data)
 
 static inline void revert_payload_tail(struct payload *data)
 {
-
-    /*
-     * We need RCU variant (which has barriers) in case we crash here.
-     * The applied_list is iterated by the trap code.
-     */
-    list_del_rcu(&data->applied_list);
+    list_del(&data->applied_list);
 
     data->reverted = true;
     data->state = LIVEPATCH_STATE_CHECKED;
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 17:00:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 17:00:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686749.1069177 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfNI9-0003ae-B3; Wed, 28 Feb 2024 17:00:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686749.1069177; Wed, 28 Feb 2024 17:00:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfNI9-0003aV-8Q; Wed, 28 Feb 2024 17:00:25 +0000
Received: by outflank-mailman (input) for mailman id 686749;
 Wed, 28 Feb 2024 17:00:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfNI7-0003aK-QP
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 17:00:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfNI7-0007KO-Pd
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 17:00:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfNI7-0003C2-Oi
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 17:00:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=i97g3Att/rcy+iV3ae89+2jR/eLK3PqObeyo527Cdbw=; b=hFh/3DHLPcZ3jwjSe9G/W0uMlr
	D8k9qaZtFoGbJo9IqFPT2DUxvNIf3VrLY55vBO+3G7+4i7T13GAu52KICtO6A1lFdpYzFiBG/dO83
	cs6PvE0OONfgOdalSTb2Ek8tFdnAT0900v/qLFpuYII+jjo/X4raPdrd9RHmIoAiDM+4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/livepatch: fix norevert test attempt to open-code revert
Message-Id: <E1rfNI7-0003C2-Oi@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 17:00:23 +0000

commit cdae267ce10d04d71d1687b5701ff2911a96b6dc
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 12:25:26 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Feb 28 16:57:25 2024 +0000

    xen/livepatch: fix norevert test attempt to open-code revert
    
    The purpose of the norevert test is to install a dummy handler that replaces
    the internal Xen revert code, and then perform the revert in the post-revert
    hook.  For that purpose the usage of the previous common_livepatch_revert() is
    not enough, as that just reverts specific functions, but not the whole state of
    the payload.
    
    Remove both common_livepatch_{apply,revert}() and instead expose
    revert_payload{,_tail}() in order to perform the patch revert from the
    post-revert hook.
    
    Fixes: 6047104c3ccc ('livepatch: Add per-function applied/reverted state tracking marker')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 xen/common/livepatch.c                         | 41 +++++++++++++++++++++++---
 xen/include/xen/livepatch.h                    | 32 +++-----------------
 xen/test/livepatch/xen_action_hooks_norevert.c | 22 ++++----------
 3 files changed, 46 insertions(+), 49 deletions(-)

diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
index 14295bae87..5a7d5b7be0 100644
--- a/xen/common/livepatch.c
+++ b/xen/common/livepatch.c
@@ -1366,7 +1366,22 @@ static int apply_payload(struct payload *data)
     ASSERT(!local_irq_is_enabled());
 
     for ( i = 0; i < data->nfuncs; i++ )
-        common_livepatch_apply(&data->funcs[i], &data->fstate[i]);
+    {
+        const struct livepatch_func *func = &data->funcs[i];
+        struct livepatch_fstate *state = &data->fstate[i];
+
+        /* If the action has been already executed on this function, do nothing. */
+        if ( state->applied == LIVEPATCH_FUNC_APPLIED )
+        {
+            printk(XENLOG_WARNING LIVEPATCH
+                   "%s: %s has been already applied before\n",
+                   __func__, func->name);
+            continue;
+        }
+
+        arch_livepatch_apply(func, state);
+        state->applied = LIVEPATCH_FUNC_APPLIED;
+    }
 
     arch_livepatch_revive();
 
@@ -1382,7 +1397,7 @@ static inline void apply_payload_tail(struct payload *data)
     data->state = LIVEPATCH_STATE_APPLIED;
 }
 
-static int revert_payload(struct payload *data)
+int revert_payload(struct payload *data)
 {
     unsigned int i;
     int rc;
@@ -1397,7 +1412,25 @@ static int revert_payload(struct payload *data)
     }
 
     for ( i = 0; i < data->nfuncs; i++ )
-        common_livepatch_revert(&data->funcs[i], &data->fstate[i]);
+    {
+        const struct livepatch_func *func = &data->funcs[i];
+        struct livepatch_fstate *state = &data->fstate[i];
+
+        /*
+         * If the apply action hasn't been executed on this function, do
+         * nothing.
+         */
+        if ( !func->old_addr || state->applied == LIVEPATCH_FUNC_NOT_APPLIED )
+        {
+            printk(XENLOG_WARNING LIVEPATCH
+                   "%s: %s has not been applied before\n",
+                   __func__, func->name);
+            continue;
+        }
+
+        arch_livepatch_revert(func, state);
+        state->applied = LIVEPATCH_FUNC_NOT_APPLIED;
+    }
 
     /*
      * Since we are running with IRQs disabled and the hooks may call common
@@ -1415,7 +1448,7 @@ static int revert_payload(struct payload *data)
     return 0;
 }
 
-static inline void revert_payload_tail(struct payload *data)
+void revert_payload_tail(struct payload *data)
 {
     list_del(&data->applied_list);
 
diff --git a/xen/include/xen/livepatch.h b/xen/include/xen/livepatch.h
index ad0eae28bd..d074a5bebe 100644
--- a/xen/include/xen/livepatch.h
+++ b/xen/include/xen/livepatch.h
@@ -138,35 +138,11 @@ void arch_livepatch_post_action(void);
 void arch_livepatch_mask(void);
 void arch_livepatch_unmask(void);
 
-static inline void common_livepatch_apply(const struct livepatch_func *func,
-                                          struct livepatch_fstate *state)
-{
-    /* If the action has been already executed on this function, do nothing. */
-    if ( state->applied == LIVEPATCH_FUNC_APPLIED )
-    {
-        printk(XENLOG_WARNING LIVEPATCH "%s: %s has been already applied before\n",
-                __func__, func->name);
-        return;
-    }
-
-    arch_livepatch_apply(func, state);
-    state->applied = LIVEPATCH_FUNC_APPLIED;
-}
+/* Only for testing purposes. */
+struct payload;
+int revert_payload(struct payload *data);
+void revert_payload_tail(struct payload *data);
 
-static inline void common_livepatch_revert(const struct livepatch_func *func,
-                                           struct livepatch_fstate *state)
-{
-    /* If the apply action hasn't been executed on this function, do nothing. */
-    if ( !func->old_addr || state->applied == LIVEPATCH_FUNC_NOT_APPLIED )
-    {
-        printk(XENLOG_WARNING LIVEPATCH "%s: %s has not been applied before\n",
-                __func__, func->name);
-        return;
-    }
-
-    arch_livepatch_revert(func, state);
-    state->applied = LIVEPATCH_FUNC_NOT_APPLIED;
-}
 #else
 
 /*
diff --git a/xen/test/livepatch/xen_action_hooks_norevert.c b/xen/test/livepatch/xen_action_hooks_norevert.c
index c173855192..c5fbab1746 100644
--- a/xen/test/livepatch/xen_action_hooks_norevert.c
+++ b/xen/test/livepatch/xen_action_hooks_norevert.c
@@ -96,26 +96,14 @@ static int revert_hook(livepatch_payload_t *payload)
 
 static void post_revert_hook(livepatch_payload_t *payload)
 {
-    int i;
+    unsigned long flags;
 
     printk(KERN_DEBUG "%s: Hook starting.\n", __func__);
 
-    for (i = 0; i < payload->nfuncs; i++)
-    {
-        const struct livepatch_func *func = &payload->funcs[i];
-        struct livepatch_fstate *fstate = &payload->fstate[i];
-
-        BUG_ON(revert_cnt != 1);
-        BUG_ON(fstate->applied != LIVEPATCH_FUNC_APPLIED);
-
-        /* Outside of quiesce zone: MAY TRIGGER HOST CRASH/UNDEFINED BEHAVIOR */
-        arch_livepatch_quiesce();
-        common_livepatch_revert(payload);
-        arch_livepatch_revive();
-        BUG_ON(fstate->applied == LIVEPATCH_FUNC_APPLIED);
-
-        printk(KERN_DEBUG "%s: post reverted: %s\n", __func__, func->name);
-    }
+    local_irq_save(flags);
+    BUG_ON(revert_payload(payload));
+    revert_payload_tail(payload);
+    local_irq_restore(flags);
 
     printk(KERN_DEBUG "%s: Hook done.\n", __func__);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 17:00:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 17:00:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686750.1069181 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfNII-0003en-Cb; Wed, 28 Feb 2024 17:00:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686750.1069181; Wed, 28 Feb 2024 17:00:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfNII-0003ef-9y; Wed, 28 Feb 2024 17:00:34 +0000
Received: by outflank-mailman (input) for mailman id 686750;
 Wed, 28 Feb 2024 17:00:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfNIH-0003eV-TL
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 17:00:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfNIH-0007KY-SV
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 17:00:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfNIH-0003Cf-Rh
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 17:00:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=qZDNNfoeW1us6wLpwK/KOBUn8XHDwi0jtKYhq9AlVMI=; b=Qz67wnuU0qUO5AuAnDu+OIx0Sb
	aX+u4KyEzUJLuTEwhQKrRRICW3zgwpkuhRY54tR0gE1/iJc13n3KR8TYP1fj1ezbe7iq5+vJbtLI4
	f3rfSCmLZqv6u0cE2ioa/05zYjeH7BqxeVf627mfeiEEsCcT914+ZjhgzcESBZcLC8wY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/livepatch: properly build the noapply and norevert tests
Message-Id: <E1rfNIH-0003Cf-Rh@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 17:00:33 +0000

commit e579677095782c7dec792597ba8b037b7d716b32
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 12:25:27 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Feb 28 16:57:25 2024 +0000

    xen/livepatch: properly build the noapply and norevert tests
    
    It seems the build variables for those tests where copy-pasted from
    xen_action_hooks_marker-objs and not adjusted to use the correct source files.
    
    Fixes: 6047104c3ccc ('livepatch: Add per-function applied/reverted state tracking marker')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 xen/test/livepatch/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/xen/test/livepatch/Makefile b/xen/test/livepatch/Makefile
index c258ab0b59..d987a8367f 100644
--- a/xen/test/livepatch/Makefile
+++ b/xen/test/livepatch/Makefile
@@ -118,12 +118,12 @@ xen_action_hooks_marker-objs := xen_action_hooks_marker.o xen_hello_world_func.o
 $(obj)/xen_action_hooks_noapply.o: $(obj)/config.h
 
 extra-y += xen_action_hooks_noapply.livepatch
-xen_action_hooks_noapply-objs := xen_action_hooks_marker.o xen_hello_world_func.o note.o xen_note.o
+xen_action_hooks_noapply-objs := xen_action_hooks_noapply.o xen_hello_world_func.o note.o xen_note.o
 
 $(obj)/xen_action_hooks_norevert.o: $(obj)/config.h
 
 extra-y += xen_action_hooks_norevert.livepatch
-xen_action_hooks_norevert-objs := xen_action_hooks_marker.o xen_hello_world_func.o note.o xen_note.o
+xen_action_hooks_norevert-objs := xen_action_hooks_norevert.o xen_hello_world_func.o note.o xen_note.o
 
 EXPECT_BYTES_COUNT := 8
 CODE_GET_EXPECT=$(shell $(OBJDUMP) -d --insn-width=1 $(1) | sed -n -e '/<'$(2)'>:$$/,/^$$/ p' | tail -n +2 | head -n $(EXPECT_BYTES_COUNT) | awk '{$$0=$$2; printf "%s", substr($$0,length-1)}' | sed 's/.\{2\}/0x&,/g' | sed 's/^/{/;s/,$$/}/g')
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 17:00:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 17:00:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686751.1069185 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfNIS-0003hV-FZ; Wed, 28 Feb 2024 17:00:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686751.1069185; Wed, 28 Feb 2024 17:00:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfNIS-0003hL-Ch; Wed, 28 Feb 2024 17:00:44 +0000
Received: by outflank-mailman (input) for mailman id 686751;
 Wed, 28 Feb 2024 17:00:44 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfNIS-0003hF-07
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 17:00:44 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfNIR-0007Kv-VZ
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 17:00:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfNIR-0003D6-Ug
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 17:00:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=nnprc9apavseKSJv88Mkq0c1LDAy8SkelsK1d7/EBBI=; b=gMeR1NO+xMUAXom+qMqoRleEYj
	R6hZPWpAHseZ8Qh/dkHKdbvC6af1j10AfWkm4mtBuglADHQdYwQBLMoTHOv2YJzLjyvVW8qU8AWVD
	Ja7LYMslt7rkh59nsIl+Z0kDvPJceTosvvuopdsggoFKG16Dymsq+aCGCxEkkW6cqmgo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/livepatch: group and document payload hooks
Message-Id: <E1rfNIR-0003D6-Ug@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 17:00:43 +0000

commit 54fd7b997470e6686667ca8e18f9ba6139efcdea
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 12:25:28 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Feb 28 16:57:25 2024 +0000

    xen/livepatch: group and document payload hooks
    
    Group the payload hooks between the pre/post handlers, and the apply/revert
    replacements.  Also attempt to comment the context in which the hooks are
    executed.
    
    No functional change.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
---
 xen/include/xen/livepatch_payload.h | 37 +++++++++++++++++++++++++++++--------
 1 file changed, 29 insertions(+), 8 deletions(-)

diff --git a/xen/include/xen/livepatch_payload.h b/xen/include/xen/livepatch_payload.h
index b9cd4f2096..472d6a4a63 100644
--- a/xen/include/xen/livepatch_payload.h
+++ b/xen/include/xen/livepatch_payload.h
@@ -82,6 +82,8 @@ struct payload {
  * collision.  Since multiple hooks can be registered, the
  * .livepatch.hook.load section is a table of functions that will be
  * executed in series by the livepatch infrastructure at patch load time.
+ *
+ * Note the load hook is executed in quiesced context.
  */
 #define LIVEPATCH_LOAD_HOOK(_fn) \
     livepatch_loadcall_t *__weak \
@@ -96,14 +98,20 @@ struct payload {
      livepatch_unloadcall_t *__weak \
         const livepatch_unload_data_##_fn __section(".livepatch.hooks.unload") = _fn;
 
+/*
+ * Pre/Post action hooks.
+ *
+ * This hooks are executed before or after the livepatch application. Pre hooks
+ * can veto the application/revert of the livepatch.  They are not executed in
+ * quiesced context.  All of pre and post hooks are considered vetoing, and
+ * hence filling any of those will block the usage of the REPLACE action.
+ *
+ * Each of the hooks below can only be set once per livepatch payload.
+ */
 #define LIVEPATCH_PREAPPLY_HOOK(_fn) \
     livepatch_precall_t *__attribute__((weak, used)) \
         const livepatch_preapply_data_##_fn __section(".livepatch.hooks.preapply") = _fn;
 
-#define LIVEPATCH_APPLY_HOOK(_fn) \
-    livepatch_actioncall_t *__attribute__((weak, used)) \
-        const livepatch_apply_data_##_fn __section(".livepatch.hooks.apply") = _fn;
-
 #define LIVEPATCH_POSTAPPLY_HOOK(_fn) \
     livepatch_postcall_t *__attribute__((weak, used)) \
         const livepatch_postapply_data_##_fn __section(".livepatch.hooks.postapply") = _fn;
@@ -112,14 +120,27 @@ struct payload {
     livepatch_precall_t *__attribute__((weak, used)) \
         const livepatch_prerevert_data_##_fn __section(".livepatch.hooks.prerevert") = _fn;
 
-#define LIVEPATCH_REVERT_HOOK(_fn) \
-    livepatch_actioncall_t *__attribute__((weak, used)) \
-        const livepatch_revert_data_##_fn __section(".livepatch.hooks.revert") = _fn;
-
 #define LIVEPATCH_POSTREVERT_HOOK(_fn) \
     livepatch_postcall_t *__attribute__((weak, used)) \
         const livepatch_postrevert_data_##_fn __section(".livepatch.hooks.postrevert") = _fn;
 
+/*
+ * Action replacement hooks.
+ *
+ * The following hooks replace the hypervisor implementation for the livepatch
+ * application and revert routines.  When filling the hooks below the native
+ * apply and revert routines will not be executed, so the provided hooks need
+ * to make sure the state of the payload after apply or revert is as expected
+ * by the livepatch logic.
+ */
+#define LIVEPATCH_APPLY_HOOK(_fn) \
+    livepatch_actioncall_t *__attribute__((weak, used)) \
+        const livepatch_apply_data_##_fn __section(".livepatch.hooks.apply") = _fn;
+
+#define LIVEPATCH_REVERT_HOOK(_fn) \
+    livepatch_actioncall_t *__attribute__((weak, used)) \
+        const livepatch_revert_data_##_fn __section(".livepatch.hooks.revert") = _fn;
+
 #endif /* __XEN_LIVEPATCH_PAYLOAD_H__ */
 
 /*
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 19:22:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 19:22:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686771.1069221 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfPVD-0006rt-Vg; Wed, 28 Feb 2024 19:22:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686771.1069221; Wed, 28 Feb 2024 19:22:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfPVD-0006rm-T8; Wed, 28 Feb 2024 19:22:03 +0000
Received: by outflank-mailman (input) for mailman id 686771;
 Wed, 28 Feb 2024 19:22:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfPVC-0006rf-8L
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 19:22:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfPVC-0001QG-1E
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 19:22:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfPVB-0002VE-VM
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 19:22:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=YFRtE/SB2LfR5c+8UmOlP15KJUd7krBAwd/mANnPqBs=; b=BuunX4c6AkrYMv6siVZobBSCu5
	fd1VPAcrL2Lj2F1Gpvl5l0d+msj4hKKf+a3GPA76pDdVJeX/Z9oQNOSj0g4qFF29fwz0KN+toL7AB
	R2q7hzUVLzywNOPUrHX8WPgrvxA5Ydlv85fqIRiuMh0pxPOL3nyf7SbvKKsldzt+jzFs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] automation: remove bin86/dev86 from tumbleweed image
Message-Id: <E1rfPVB-0002VE-VM@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 19:22:01 +0000

commit 150e7a4e79d3d60e8e7c988c1367a0c1d7830693
Author:     Olaf Hering <olaf@aepfle.de>
AuthorDate: Tue Feb 27 10:16:35 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 10:16:35 2024 +0100

    automation: remove bin86/dev86 from tumbleweed image
    
    https://build.opensuse.org/request/show/1126240
    
    Signed-off-by: Olaf Hering <olaf@aepfle.de>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 automation/build/suse/opensuse-tumbleweed.dockerfile | 2 --
 1 file changed, 2 deletions(-)

diff --git a/automation/build/suse/opensuse-tumbleweed.dockerfile b/automation/build/suse/opensuse-tumbleweed.dockerfile
index 38f6fda2ff..f00e03eda7 100644
--- a/automation/build/suse/opensuse-tumbleweed.dockerfile
+++ b/automation/build/suse/opensuse-tumbleweed.dockerfile
@@ -11,13 +11,11 @@ RUN zypper ref && zypper dup -y --no-recommends
 RUN zypper install -y --no-recommends \
         acpica \
         bc \
-        bin86 \
         bison \
         bzip2 \
         checkpolicy \
         clang \
         cmake \
-        dev86 \
         diffutils \
         discount \
         flex \
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 19:22:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 19:22:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686772.1069226 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfPVO-0006tf-0u; Wed, 28 Feb 2024 19:22:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686772.1069226; Wed, 28 Feb 2024 19:22:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfPVN-0006tX-Ub; Wed, 28 Feb 2024 19:22:13 +0000
Received: by outflank-mailman (input) for mailman id 686772;
 Wed, 28 Feb 2024 19:22:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfPVM-0006tK-7d
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 19:22:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfPVM-0001QK-54
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 19:22:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfPVM-0002Vt-3K
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 19:22:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=DdiP3HFEKCalT5fuLXzIT4LMcKHpBb5qnb7pj8CaAZ8=; b=NeusnQU1F6MHHIefTmIhnF3YCT
	zZkaQpFJCS6wvO/WY2LBgw7WlgRzhoFospvpaT3cfoiOmtvcR0rzniUKC3A/6gAzbbqrS5TJHdwhZ
	d5mBPM2tkvSckvjmgT8jw7Q+JnWTSpKDzx6Z9qtgl1j8yKYQSdVkC7qcYgWmNl8rog84=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/ppc: address violations of MISRA C:2012 Rule 11.8
Message-Id: <E1rfPVM-0002Vt-3K@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 19:22:12 +0000

commit 84b9617c039f566f43af4a7448bd34d160cbd112
Author:     Maria Celeste Cesario <maria.celeste.cesario@bugseng.com>
AuthorDate: Tue Feb 27 10:16:52 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 10:16:52 2024 +0100

    xen/ppc: address violations of MISRA C:2012 Rule 11.8
    
    The xen sources contain violations of MISRA C:2012 Rule 11.8 whose
    headline states:
    "A conversion shall not remove any const, volatile or _Atomic qualification
    from the type pointed to by a pointer".
    
    Fix violation by adding missing const qualifier in cast.
    
    Signed-off-by: Maria Celeste Cesario <maria.celeste.cesario@bugseng.com>
    Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Acked-by: Shawn Anastasio <sanastasio@raptorengineering.com>
---
 xen/arch/ppc/include/asm/atomic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/ppc/include/asm/atomic.h b/xen/arch/ppc/include/asm/atomic.h
index 64168aa3f1..fe778579fb 100644
--- a/xen/arch/ppc/include/asm/atomic.h
+++ b/xen/arch/ppc/include/asm/atomic.h
@@ -16,7 +16,7 @@
 
 static inline int atomic_read(const atomic_t *v)
 {
-    return *(volatile int *)&v->counter;
+    return *(const volatile int *)&v->counter;
 }
 
 static inline int _atomic_read(atomic_t v)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 19:22:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 19:22:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686773.1069229 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfPVY-0006wP-2I; Wed, 28 Feb 2024 19:22:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686773.1069229; Wed, 28 Feb 2024 19:22:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfPVX-0006wH-W3; Wed, 28 Feb 2024 19:22:23 +0000
Received: by outflank-mailman (input) for mailman id 686773;
 Wed, 28 Feb 2024 19:22:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfPVW-0006w1-9H
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 19:22:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfPVW-0001Qc-8T
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 19:22:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfPVW-0002Xp-7J
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 19:22:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=fE5pXKnWdGXueeH6kJaAlVzD1TOf3p+mYorIJmkrmkA=; b=kwvF6Yp+ur2Cr6TWEkU8LaR/9/
	oQW16Hb7ILTaQqyArZtSaJgOESBkrIJUG32kjH9phMbt/p9i3fB0SRqPdqUFEBJ770/xoj9/yxTYL
	DYcHdk5O9Az29qV1zp0lH1Fr1uvqPRZyLRfk87PwcbSUrNYYe0X+twKMCfMnc/tdJ9aE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen: introduce Kconfig function alignment option
Message-Id: <E1rfPVW-0002Xp-7J@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 19:22:22 +0000

commit ca7c872c70cb58f1e4b59f8eb619ffa0ecc1ed87
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 10:17:59 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 10:17:59 2024 +0100

    xen: introduce Kconfig function alignment option
    
    And use it to replace CODE_ALIGN in assembly.  This allows to generalize the
    way the code alignment gets set across all architectures.
    
    No functional change intended.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Michal Orzel <michal.orzel@amd.com>
    Acked-by: Shawn Anastasio <sanastasio@raptorengineering.com>
---
 xen/Kconfig                         | 17 +++++++++++++++++
 xen/arch/arm/Kconfig                |  1 +
 xen/arch/arm/include/asm/config.h   |  3 +--
 xen/arch/ppc/Kconfig                |  1 +
 xen/arch/ppc/include/asm/config.h   |  5 -----
 xen/arch/riscv/Kconfig              |  1 +
 xen/arch/riscv/include/asm/config.h |  1 -
 xen/arch/x86/Kconfig                |  1 +
 xen/arch/x86/include/asm/config.h   |  3 +--
 xen/include/xen/linkage.h           |  6 +++---
 10 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/xen/Kconfig b/xen/Kconfig
index 134e6e68ad..1e1b041fd5 100644
--- a/xen/Kconfig
+++ b/xen/Kconfig
@@ -37,6 +37,23 @@ config CC_HAS_VISIBILITY_ATTRIBUTE
 config CC_SPLIT_SECTIONS
 	bool
 
+# Set code alignment.
+#
+# Allow setting on a boolean basis, and then convert such selection to an
+# integer for the build system and code to consume more easily.
+config FUNCTION_ALIGNMENT_4B
+	bool
+config FUNCTION_ALIGNMENT_8B
+	bool
+config FUNCTION_ALIGNMENT_16B
+	bool
+config FUNCTION_ALIGNMENT
+	int
+	default 16 if FUNCTION_ALIGNMENT_16B
+	default  8 if  FUNCTION_ALIGNMENT_8B
+	default  4 if  FUNCTION_ALIGNMENT_4B
+	default  0
+
 source "arch/$(SRCARCH)/Kconfig"
 
 config DEFCONFIG_LIST
diff --git a/xen/arch/arm/Kconfig b/xen/arch/arm/Kconfig
index 72af329564..40f834bb71 100644
--- a/xen/arch/arm/Kconfig
+++ b/xen/arch/arm/Kconfig
@@ -11,6 +11,7 @@ config ARM_64
 
 config ARM
 	def_bool y
+	select FUNCTION_ALIGNMENT_4B
 	select HAS_ALTERNATIVE
 	select HAS_DEVICE_TREE
 	select HAS_PASSTHROUGH
diff --git a/xen/arch/arm/include/asm/config.h b/xen/arch/arm/include/asm/config.h
index 3b6d829197..a2e22b659d 100644
--- a/xen/arch/arm/include/asm/config.h
+++ b/xen/arch/arm/include/asm/config.h
@@ -53,8 +53,7 @@
 
 /* Linkage for ARM */
 #ifdef __ASSEMBLY__
-#define CODE_ALIGN 4
-#define ALIGN .balign CODE_ALIGN
+#define ALIGN .balign CONFIG_FUNCTION_ALIGNMENT
 #define ENTRY(name)                             \
   .globl name;                                  \
   ALIGN;                                        \
diff --git a/xen/arch/ppc/Kconfig b/xen/arch/ppc/Kconfig
index ab116ffb2a..f6a77a8200 100644
--- a/xen/arch/ppc/Kconfig
+++ b/xen/arch/ppc/Kconfig
@@ -1,5 +1,6 @@
 config PPC
 	def_bool y
+	select FUNCTION_ALIGNMENT_4B
 	select HAS_DEVICE_TREE
 
 config PPC64
diff --git a/xen/arch/ppc/include/asm/config.h b/xen/arch/ppc/include/asm/config.h
index e5d201e16c..148fb3074d 100644
--- a/xen/arch/ppc/include/asm/config.h
+++ b/xen/arch/ppc/include/asm/config.h
@@ -30,11 +30,6 @@
 #define OPT_CONSOLE_STR "dtuart"
 #define INVALID_VCPU_ID MAX_VIRT_CPUS
 
-/* Linkage for PPC */
-#ifdef __ASSEMBLY__
-#define CODE_ALIGN 4
-#endif
-
 #define XEN_VIRT_START _AC(0xc000000000000000, UL)
 
 /* Fixed address for start of the section containing exception vectors */
diff --git a/xen/arch/riscv/Kconfig b/xen/arch/riscv/Kconfig
index f382b36f6c..b4b354a778 100644
--- a/xen/arch/riscv/Kconfig
+++ b/xen/arch/riscv/Kconfig
@@ -1,5 +1,6 @@
 config RISCV
 	def_bool y
+	select FUNCTION_ALIGNMENT_16B
 
 config RISCV_64
 	def_bool y
diff --git a/xen/arch/riscv/include/asm/config.h b/xen/arch/riscv/include/asm/config.h
index 2c7f2b1ff9..c5f93e6a01 100644
--- a/xen/arch/riscv/include/asm/config.h
+++ b/xen/arch/riscv/include/asm/config.h
@@ -132,7 +132,6 @@
 
 /* Linkage for RISCV */
 #ifdef __ASSEMBLY__
-#define CODE_ALIGN 16
 #define CODE_FILL /* empty */
 #endif
 
diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
index 1acdffc51c..01c6bea480 100644
--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -11,6 +11,7 @@ config X86
 	select ARCH_MAP_DOMAIN_PAGE
 	select ARCH_SUPPORTS_INT128
 	imply CORE_PARKING
+	select FUNCTION_ALIGNMENT_16B
 	select GENERIC_BUG_FRAME
 	select HAS_ALTERNATIVE
 	select HAS_COMPAT
diff --git a/xen/arch/x86/include/asm/config.h b/xen/arch/x86/include/asm/config.h
index 660246d1da..ab7288cb36 100644
--- a/xen/arch/x86/include/asm/config.h
+++ b/xen/arch/x86/include/asm/config.h
@@ -43,9 +43,8 @@
 
 /* Linkage for x86 */
 #ifdef __ASSEMBLY__
-#define CODE_ALIGN 16
 #define CODE_FILL 0x90
-#define ALIGN .align CODE_ALIGN, CODE_FILL
+#define ALIGN .align CONFIG_FUNCTION_ALIGNMENT, CODE_FILL
 #define ENTRY(name)                             \
   ALIGN;                                        \
   GLOBAL(name)
diff --git a/xen/include/xen/linkage.h b/xen/include/xen/linkage.h
index 0997e16810..478b1d7287 100644
--- a/xen/include/xen/linkage.h
+++ b/xen/include/xen/linkage.h
@@ -5,7 +5,6 @@
 
 #include <xen/macros.h>
 
-/* CODE_ALIGN needs to be specified by every architecture. */
 #ifndef CODE_FILL
 # define CODE_FILL ~0
 #endif
@@ -41,9 +40,10 @@
  */
 #define count_args_exp(args...) count_args(args)
 #if count_args_exp(CODE_FILL)
-# define DO_CODE_ALIGN(align...) LASTARG(CODE_ALIGN, ## align), CODE_FILL
+# define DO_CODE_ALIGN(align...) LASTARG(CONFIG_FUNCTION_ALIGNMENT, ## align), \
+                                 CODE_FILL
 #else
-# define DO_CODE_ALIGN(align...) LASTARG(CODE_ALIGN, ## align)
+# define DO_CODE_ALIGN(align...) LASTARG(CONFIG_FUNCTION_ALIGNMENT, ## align)
 #endif
 
 #define FUNC(name, align...) \
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 21:00:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 21:00:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686785.1069253 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfR23-0001fK-AY; Wed, 28 Feb 2024 21:00:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686785.1069253; Wed, 28 Feb 2024 21:00:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfR23-0001f1-87; Wed, 28 Feb 2024 21:00:03 +0000
Received: by outflank-mailman (input) for mailman id 686785;
 Wed, 28 Feb 2024 21:00:01 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfR21-0001Ok-Qb
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 21:00:01 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfR21-0003G6-Ko
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 21:00:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfR21-0007WE-Iy
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 21:00:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=g/uWyy8XZ+YSkd4/JUC/AADiTEn265WiEgh8IaW5fTk=; b=VGDltepUq798fdKiQ+q+E2HoxY
	sDfz9MTeQf7uiQSUoRQ7uWKGBv5N10Dru3YTiFX8uNE6eg/5ks3+vfMXbS50zVFOTxYz7tLh1BLHL
	TJueu2bUSTMvxSZsUzNTs4PDUT6ll15Yx78Blu5Fq1IfwjFwUw4fywo/SorAODUdOesc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.16] x86: account for shadow stack in exception-from-stub recovery
Message-Id: <E1rfR21-0007WE-Iy@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 21:00:01 +0000

commit ffd75b161de76e43fd54d751ab70d2fdf6e2e87d
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 14:13:21 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:13:21 2024 +0100

    x86: account for shadow stack in exception-from-stub recovery
    
    Dealing with exceptions raised from within emulation stubs involves
    discarding return address (replaced by exception related information).
    Such discarding of course also requires removing the corresponding entry
    from the shadow stack.
    
    Also amend the comment in fixup_exception_return(), to further clarify
    why use of ptr[1] can't be an out-of-bounds access.
    
    This is CVE-2023-46841 / XSA-451.
    
    Fixes: 209fb9919b50 ("x86/extable: Adjust extable handling to be shadow stack compatible")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    master commit: 91f5f7a9154919a765c3933521760acffeddbf28
    master date: 2024-02-27 13:49:22 +0100
---
 xen/arch/x86/extable.c        | 20 ++++++++------
 xen/arch/x86/traps.c          | 63 ++++++++++++++++++++++++++++++++++++++-----
 xen/include/asm-x86/uaccess.h |  3 ++-
 3 files changed, 71 insertions(+), 15 deletions(-)

diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index c18cf97875..f25f56b714 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -86,26 +86,29 @@ search_one_extable(const struct exception_table_entry *first,
 }
 
 unsigned long
-search_exception_table(const struct cpu_user_regs *regs)
+search_exception_table(const struct cpu_user_regs *regs, unsigned long *stub_ra)
 {
     const struct virtual_region *region = find_text_region(regs->rip);
     unsigned long stub = this_cpu(stubs.addr);
 
     if ( region && region->ex )
+    {
+        *stub_ra = 0;
         return search_one_extable(region->ex, region->ex_end, regs->rip);
+    }
 
     if ( regs->rip >= stub + STUB_BUF_SIZE / 2 &&
          regs->rip < stub + STUB_BUF_SIZE &&
          regs->rsp > (unsigned long)regs &&
          regs->rsp < (unsigned long)get_cpu_info() )
     {
-        unsigned long retptr = *(unsigned long *)regs->rsp;
+        unsigned long retaddr = *(unsigned long *)regs->rsp, fixup;
 
-        region = find_text_region(retptr);
-        retptr = region && region->ex
-                 ? search_one_extable(region->ex, region->ex_end, retptr)
-                 : 0;
-        if ( retptr )
+        region = find_text_region(retaddr);
+        fixup = region && region->ex
+                ? search_one_extable(region->ex, region->ex_end, retaddr)
+                : 0;
+        if ( fixup )
         {
             /*
              * Put trap number and error code on the stack (in place of the
@@ -117,7 +120,8 @@ search_exception_table(const struct cpu_user_regs *regs)
             };
 
             *(unsigned long *)regs->rsp = token.raw;
-            return retptr;
+            *stub_ra = retaddr;
+            return fixup;
         }
     }
 
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index a142a63dd8..d74dcc343b 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -895,7 +895,7 @@ static void do_reserved_trap(struct cpu_user_regs *regs)
 }
 
 static void fixup_exception_return(struct cpu_user_regs *regs,
-                                   unsigned long fixup)
+                                   unsigned long fixup, unsigned long stub_ra)
 {
     if ( IS_ENABLED(CONFIG_XEN_SHSTK) )
     {
@@ -912,7 +912,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
             /*
              * Search for %rip.  The shstk currently looks like this:
              *
-             *   ...  [Likely pointed to by SSP]
+             *   tok  [Supervisor token, == &tok | BUSY, only with FRED inactive]
+             *   ...  [Pointed to by SSP for most exceptions, empty in IST cases]
              *   %cs  [== regs->cs]
              *   %rip [== regs->rip]
              *   SSP  [Likely points to 3 slots higher, above %cs]
@@ -930,7 +931,56 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
              */
             if ( ptr[0] == regs->rip && ptr[1] == regs->cs )
             {
+                unsigned long primary_shstk =
+                    (ssp & ~(STACK_SIZE - 1)) +
+                    (PRIMARY_SHSTK_SLOT + 1) * PAGE_SIZE - 8;
+
                 wrss(fixup, ptr);
+
+                if ( !stub_ra )
+                    goto shstk_done;
+
+                /*
+                 * Stub recovery ought to happen only when the outer context
+                 * was on the main shadow stack.  We need to also "pop" the
+                 * stub's return address from the interrupted context's shadow
+                 * stack.  That is,
+                 * - if we're still on the main stack, we need to move the
+                 *   entire stack (up to and including the exception frame)
+                 *   up by one slot, incrementing the original SSP in the
+                 *   exception frame,
+                 * - if we're on an IST stack, we need to increment the
+                 *   original SSP.
+                 */
+                BUG_ON((ptr[-1] ^ primary_shstk) >> PAGE_SHIFT);
+
+                if ( (ssp ^ primary_shstk) >> PAGE_SHIFT )
+                {
+                    /*
+                     * We're on an IST stack.  First make sure the two return
+                     * addresses actually match.  Then increment the interrupted
+                     * context's SSP.
+                     */
+                    BUG_ON(stub_ra != *(unsigned long*)ptr[-1]);
+                    wrss(ptr[-1] + 8, &ptr[-1]);
+                    goto shstk_done;
+                }
+
+                /* Make sure the two return addresses actually match. */
+                BUG_ON(stub_ra != ptr[2]);
+
+                /* Move exception frame, updating SSP there. */
+                wrss(ptr[1], &ptr[2]); /* %cs */
+                wrss(ptr[0], &ptr[1]); /* %rip */
+                wrss(ptr[-1] + 8, &ptr[0]); /* SSP */
+
+                /* Move all newer entries. */
+                while ( --ptr != _p(ssp) )
+                    wrss(ptr[-1], &ptr[0]);
+
+                /* Finally account for our own stack having shifted up. */
+                asm volatile ( "incsspd %0" :: "r" (2) );
+
                 goto shstk_done;
             }
         }
@@ -951,7 +1001,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
 
 static bool extable_fixup(struct cpu_user_regs *regs, bool print)
 {
-    unsigned long fixup = search_exception_table(regs);
+    unsigned long stub_ra = 0;
+    unsigned long fixup = search_exception_table(regs, &stub_ra);
 
     if ( unlikely(fixup == 0) )
         return false;
@@ -965,7 +1016,7 @@ static bool extable_fixup(struct cpu_user_regs *regs, bool print)
                vec_name(regs->entry_vector), regs->error_code,
                _p(regs->rip), _p(regs->rip), _p(fixup));
 
-    fixup_exception_return(regs, fixup);
+    fixup_exception_return(regs, fixup, stub_ra);
     this_cpu(last_extable_addr) = regs->rip;
 
     return true;
@@ -1256,7 +1307,7 @@ void do_invalid_op(struct cpu_user_regs *regs)
         void (*fn)(struct cpu_user_regs *) = bug_ptr(bug);
 
         fn(regs);
-        fixup_exception_return(regs, (unsigned long)eip);
+        fixup_exception_return(regs, (unsigned long)eip, 0);
         return;
     }
 
@@ -1277,7 +1328,7 @@ void do_invalid_op(struct cpu_user_regs *regs)
     case BUGFRAME_warn:
         printk("Xen WARN at %s%s:%d\n", prefix, filename, lineno);
         show_execution_state(regs);
-        fixup_exception_return(regs, (unsigned long)eip);
+        fixup_exception_return(regs, (unsigned long)eip, 0);
         return;
 
     case BUGFRAME_bug:
diff --git a/xen/include/asm-x86/uaccess.h b/xen/include/asm-x86/uaccess.h
index 684fccd95c..74bb222c03 100644
--- a/xen/include/asm-x86/uaccess.h
+++ b/xen/include/asm-x86/uaccess.h
@@ -421,7 +421,8 @@ union stub_exception_token {
     unsigned long raw;
 };
 
-extern unsigned long search_exception_table(const struct cpu_user_regs *regs);
+extern unsigned long search_exception_table(const struct cpu_user_regs *regs,
+                                            unsigned long *stub_ra);
 extern void sort_exception_tables(void);
 extern void sort_exception_table(struct exception_table_entry *start,
                                  const struct exception_table_entry *stop);
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.16


From xen-changelog-bounces@lists.xenproject.org Wed Feb 28 22:55:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 28 Feb 2024 22:55:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686813.1069318 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfSpN-0000TO-K7; Wed, 28 Feb 2024 22:55:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686813.1069318; Wed, 28 Feb 2024 22:55:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfSpN-0000TG-HA; Wed, 28 Feb 2024 22:55:05 +0000
Received: by outflank-mailman (input) for mailman id 686813;
 Wed, 28 Feb 2024 22:55:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfSpM-0000T9-1a
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 22:55:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfSpL-0005Dx-Tc
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 22:55:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfSpL-0005SV-RO
 for xen-changelog@lists.xenproject.org; Wed, 28 Feb 2024 22:55:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=p+rmoLd04a3DzdK426wC25io2QyRYAsBYvm9sH9iOJ4=; b=dHK5KMV5ynacsYhQZt6JHK92P/
	VlBDIiUxZlNgKLSgeD7Rahexcn2Ao/G+zwrqItp5BVPAlW9gKyyiWJ9xF5/F83vMpk2QMGVKXk4Hr
	Vu3hlDtg3FuKJ3TwH7DstFeUcUAC9/83th471EaPAySw1KcWhxfr88boFwhyKyidTWtM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging-4.18] xen/arm: Fix UBSAN failure in start_xen()
Message-Id: <E1rfSpL-0005SV-RO@xenbits.xenproject.org>
Date: Wed, 28 Feb 2024 22:55:03 +0000

commit 498b3624d0ecc1267773e6482fd0b732e90c4511
Author:     Michal Orzel <michal.orzel@amd.com>
AuthorDate: Thu Feb 8 11:43:39 2024 +0100
Commit:     Stefano Stabellini <stefano.stabellini@amd.com>
CommitDate: Wed Feb 28 14:43:26 2024 -0800

    xen/arm: Fix UBSAN failure in start_xen()
    
    When running Xen on arm32, in scenario where Xen is loaded at an address
    such as boot_phys_offset >= 2GB, UBSAN reports the following:
    
    (XEN) UBSAN: Undefined behaviour in arch/arm/setup.c:739:58
    (XEN) pointer operation underflowed 00200000 to 86800000
    (XEN) Xen WARN at common/ubsan/ubsan.c:172
    (XEN) ----[ Xen-4.19-unstable  arm32  debug=y ubsan=y  Not tainted ]----
    ...
    (XEN) Xen call trace:
    (XEN)    [<0031b4c0>] ubsan.c#ubsan_epilogue+0x18/0xf0 (PC)
    (XEN)    [<0031d134>] __ubsan_handle_pointer_overflow+0xb8/0xd4 (LR)
    (XEN)    [<0031d134>] __ubsan_handle_pointer_overflow+0xb8/0xd4
    (XEN)    [<004d15a8>] start_xen+0xe0/0xbe0
    (XEN)    [<0020007c>] head.o#primary_switched+0x4/0x30
    
    The failure is reported for the following line:
    (paddr_t)(uintptr_t)(_start + boot_phys_offset)
    
    This occurs because the compiler treats (ptr + size) with size bigger than
    PTRDIFF_MAX as undefined behavior. To address this, switch to macro
    virt_to_maddr(), given the future plans to eliminate boot_phys_offset.
    
    Signed-off-by: Michal Orzel <michal.orzel@amd.com>
    Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
    Tested-by: Luca Fancellu <luca.fancellu@arm.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    (cherry picked from commit e11f5766503c0ff074b4e0f888bbfc931518a169)
---
 xen/arch/arm/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index db748839d3..2ccdde5277 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -1109,7 +1109,7 @@ void __init start_xen(unsigned long boot_phys_offset,
 
     /* Register Xen's load address as a boot module. */
     xen_bootmodule = add_boot_module(BOOTMOD_XEN,
-                             (paddr_t)(uintptr_t)(_start + boot_phys_offset),
+                             virt_to_maddr(_start),
                              (paddr_t)(uintptr_t)(_end - _start), false);
     BUG_ON(!xen_bootmodule);
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.18


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 07:11:11 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 07:11:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686856.1069402 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfaZM-0007Oh-C7; Thu, 29 Feb 2024 07:11:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686856.1069402; Thu, 29 Feb 2024 07:11:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfaZM-0007OZ-9L; Thu, 29 Feb 2024 07:11:04 +0000
Received: by outflank-mailman (input) for mailman id 686856;
 Thu, 29 Feb 2024 07:11:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfaZK-0007OR-RN
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:11:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfaZK-0005LT-Ov
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:11:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfaZK-0007ll-NY
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:11:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=SKZzTTanJz1GeCwXdAIluZkzwLH9APGR1MF3ISpTKdo=; b=bIdiXsDR64lipbY9rGwgRv+plz
	xz8LWIsjs7n6abopGRY4x4wkTcD/9mMwHzX2hzUt1AsgdmudogWpmdo8doJRhKHEVopT9w7HO4umB
	+UtHd8sVb+abLFAhhxIHsbEGHIvUilpN57QvRbFquqGFo8nvImI7PHPanNzz230ZfzFQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [mini-os master] Mini-OS: add symbol exports for xenstore stubdom
Message-Id: <E1rfaZK-0007ll-NY@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 07:11:02 +0000

commit b6a5b4d72b88e5c4faed01f5a44505de022860fc
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 29 08:01:03 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 29 08:01:03 2024 +0100

    Mini-OS: add symbol exports for xenstore stubdom
    
    Xenstore stubdom needs some more symbols exported.
    
    Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 xenbus.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xenbus.c b/xenbus.c
index eb9af05..686428a 100644
--- a/xenbus.c
+++ b/xenbus.c
@@ -45,6 +45,7 @@
 #endif
 
 struct xenstore_domain_interface *xenstore_buf;
+EXPORT_SYMBOL(xenstore_buf);
 static DECLARE_WAIT_QUEUE_HEAD(xb_waitq);
 DECLARE_WAIT_QUEUE_HEAD(xenbus_watch_queue);
 static __DECLARE_SEMAPHORE_GENERIC(xb_write_sem, 1);
@@ -70,6 +71,7 @@ static struct xenbus_req_info req_info[NR_REQS];
 static char *errmsg(struct xsd_sockmsg *rep);
 
 uint32_t xenbus_evtchn;
+EXPORT_SYMBOL(xenbus_evtchn);
 
 #ifdef CONFIG_PARAVIRT
 void get_xenbus(void *p)
--
generated by git-patchbot for /home/xen/git/mini-os.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 07:33:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 07:33:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686861.1069407 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfauf-0001Rn-VR; Thu, 29 Feb 2024 07:33:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686861.1069407; Thu, 29 Feb 2024 07:33:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfauf-0001Rf-RW; Thu, 29 Feb 2024 07:33:05 +0000
Received: by outflank-mailman (input) for mailman id 686861;
 Thu, 29 Feb 2024 07:33:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfaue-0001RZ-1l
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:33:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfaud-0005ik-Ry
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:33:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfaud-0000YN-QF
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:33:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=E2V4jM7LdvGq9mkFJQGqU3Gdq0cnKfO1WOfKsQxgoio=; b=5iq4J7c/xycNn4XuuID96znmlc
	kHPP7lLqSmgT+fhhG6for1eMUsnSNtgJ2h0RxL8JSnM319jWrt/8ocfXMAEOPpgX0fiRmQsBR2Ys+
	EwPq9tKMG4MzvPTJxXORuXAmkEioUZ5Oe4oeFn+OiJIeIvW5shzZG//HjZi3r8rF8ZZA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] libxl: Fix segfault in device_model_spawn_outcome
Message-Id: <E1rfaud-0000YN-QF@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 07:33:03 +0000

commit d4f3d35f043f6ef29393166b0dd131c8102cf255
Author:     Jason Andryuk <jandryuk@gmail.com>
AuthorDate: Thu Feb 29 08:18:38 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 29 08:18:38 2024 +0100

    libxl: Fix segfault in device_model_spawn_outcome
    
    libxl__spawn_qdisk_backend() explicitly sets guest_config to NULL when
    starting QEMU (the usual launch through libxl__spawn_local_dm() has a
    guest_config though).
    
    Bail early on a NULL guest_config/d_config.  This skips the QMP queries
    for chardevs and VNC, but this xenpv QEMU instance isn't expected to
    provide those - only qdisk (or 9pfs backends after an upcoming change).
    
    Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libs/light/libxl_dm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/libs/light/libxl_dm.c b/tools/libs/light/libxl_dm.c
index dc4c2dfb9f..0b03a7c747 100644
--- a/tools/libs/light/libxl_dm.c
+++ b/tools/libs/light/libxl_dm.c
@@ -3172,8 +3172,8 @@ static void device_model_spawn_outcome(libxl__egc *egc,
 
     /* Check if spawn failed */
     if (rc) goto out;
-
-    if (d_config->b_info.device_model_version
+    /* d_config is NULL for xl devd/libxl__spawn_qemu_xenpv_backend(). */
+    if (d_config && d_config->b_info.device_model_version
             == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
         rc = libxl__ev_time_register_rel(ao, &dmss->timeout,
                                          devise_model_postconfig_timeout,
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 07:33:16 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 07:33:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686862.1069410 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfaup-0001US-Vw; Thu, 29 Feb 2024 07:33:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686862.1069410; Thu, 29 Feb 2024 07:33:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfaup-0001UK-T1; Thu, 29 Feb 2024 07:33:15 +0000
Received: by outflank-mailman (input) for mailman id 686862;
 Thu, 29 Feb 2024 07:33:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfauo-0001TL-0k
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:33:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfaun-0005iv-Vn
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:33:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfaun-0000ZL-U7
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:33:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=QNTT1iKtB2d0v6UIuS70QSh6g4+wo6fnwc4K6HGunXo=; b=qyiSilU68LZlXKqIwkOzeOndU1
	yPPfzbV4+WgQJtJ7AfBAbUJ2mLoDT8VAFwY/U0BGPSfesORAOg8SXObRfAKJL+oW/6UUGBAs2lMlY
	wn2+SUEMT+aP2glmXgwePWsTWdldJwVPQ68StrOf5tlFrEo8kGKWoWBSrNPnm/2mBtQ8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/memsharing: use an atomic add instead of a cmpxchg loop
Message-Id: <E1rfaun-0000ZL-U7@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 07:33:13 +0000

commit 6d05d529404a7fad1ed277865ceb31273272a23e
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 29 08:19:22 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 29 08:19:22 2024 +0100

    x86/memsharing: use an atomic add instead of a cmpxchg loop
    
    The usage of a cmpxchg loop in get_next_handle() is unnecessary, as the same
    can be achieved with an atomic increment, which is both simpler to read, and
    avoid any need for a loop.
    
    The cmpxchg usage is likely a remnant of 32bit support, which didn't have an
    instruction to do an atomic 64bit add, and instead a cmpxchg had to be used.
    
    Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-of-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
    Acked-by: Tamas K Lengyel <tamas@tklengyel.com>
---
 xen/arch/x86/mm/mem_sharing.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c
index 4f810706a3..fe299a2bf9 100644
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -179,13 +179,7 @@ static void mem_sharing_page_unlock(struct page_info *pg)
 
 static shr_handle_t get_next_handle(void)
 {
-    /* Get the next handle get_page style */
-    uint64_t x, y = next_handle;
-    do {
-        x = y;
-    }
-    while ( (y = cmpxchg(&next_handle, x, x + 1)) != x );
-    return x + 1;
+    return arch_fetch_and_add(&next_handle, 1) + 1;
 }
 
 static atomic_t nr_saved_mfns   = ATOMIC_INIT(0);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 07:33:26 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 07:33:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686863.1069414 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfav0-0001XY-27; Thu, 29 Feb 2024 07:33:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686863.1069414; Thu, 29 Feb 2024 07:33:26 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfauz-0001XQ-Uf; Thu, 29 Feb 2024 07:33:25 +0000
Received: by outflank-mailman (input) for mailman id 686863;
 Thu, 29 Feb 2024 07:33:24 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfauy-0001XF-3t
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:33:24 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfauy-0005j4-2a
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:33:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfauy-0000Zk-1i
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:33:24 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=AlFgQ0fFBgVCWvsWhbSC7g3ek0jPu1USSr/vNEtZJ4c=; b=VT+eLjw5ba2uTv6Ms8XlcNDvx4
	y9QO4QzrC3DsSVcxuQKXqSrCzt7HPGLnn3SrYIH0xDx6R4OB0I9+jFXsq2CmotnIM/gDV9xTMGYqi
	ViivhlozOtLuy227UrXIRa8u9BOs8nn7BbPCk2UdzUnGIH+cmuBprdLf/dNiQixjYyAQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] docs: Move function and macro properties in docs/misra
Message-Id: <E1rfauy-0000Zk-1i@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 07:33:24 +0000

commit b36d850c228807287b138b83fe6b198c943c2b66
Author:     Simone Ballarin <simone.ballarin@bugseng.com>
AuthorDate: Tue Feb 27 16:36:30 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 29 08:20:05 2024 +0100

    docs: Move function and macro properties in docs/misra
    
    The list of function/macro properties is not MISRA-specific documentation.
    Their addition was directly motivated to address MISRA findings and they
    are not used elsewhere. For this reason, this patch moves these properties
    in docs/misra.
    
    This patch also fixes a Sphinx warning caused by the missing inclusion
    of the rst file in the toctree.
    
    Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Fixes: f4519ee8 ("eclair: move function and macro properties outside ECLAIR")
    Signed-off-by: Simone Ballarin <simone.ballarin@bugseng.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 automation/eclair_analysis/propertyparser.py |   2 +-
 docs/function_macro_properties.json          | 841 ---------------------------
 docs/function_macro_properties.rst           |  58 --
 docs/misra/function-macro-properties.json    | 841 +++++++++++++++++++++++++++
 docs/misra/function-macro-properties.rst     |  58 ++
 docs/misra/index.rst                         |   1 +
 6 files changed, 901 insertions(+), 900 deletions(-)

diff --git a/automation/eclair_analysis/propertyparser.py b/automation/eclair_analysis/propertyparser.py
index 0d02f505a6..5059a68fec 100644
--- a/automation/eclair_analysis/propertyparser.py
+++ b/automation/eclair_analysis/propertyparser.py
@@ -2,7 +2,7 @@ import json
 import os
 
 script_dir = os.path.dirname(__file__)
-properties_path = os.path.join(script_dir, "../../docs/function_macro_properties.json")
+properties_path = os.path.join(script_dir, "../../docs/misra/function-macro-properties.json")
 output_path   = os.path.join(script_dir, "ECLAIR/call_properties.ecl")
 
 with open(properties_path) as fp:
diff --git a/docs/function_macro_properties.json b/docs/function_macro_properties.json
deleted file mode 100644
index 74058297b5..0000000000
--- a/docs/function_macro_properties.json
+++ /dev/null
@@ -1,841 +0,0 @@
-{
-   "version": "1.0",
-   "content": [
-      {
-         "type": "function",
-         "value": "^printk.*$",
-         "properties":{
-            "pointee_write": "1..=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^debugtrace_printk.*$",
-         "properties":{
-            "pointee_write": "1..=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^panic.*$",
-         "properties":{
-            "pointee_write": "1..=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "macro",
-         "value": "^domain_crash$",
-         "properties":{
-            "pointee_write": "2..=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "macro",
-         "value": "^(g?d|mm_)?printk$",
-         "properties":{
-            "pointee_write": "2..=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "macro",
-         "value": "^guest_bug_on_failed$",
-         "properties":{
-            "pointee_write": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "macro",
-         "value": "^spin_lock_init_prof$",
-         "properties":{
-            "pointee_write": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "macro",
-         "value": "^sched_test_func$",
-         "properties":{
-            "pointee_write": "1..=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "macro",
-         "value": "^dev_(info|warn)$",
-         "properties":{
-            "pointee_write": "1..=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "macro",
-         "value": "^PAGING_DEBUG$",
-         "properties":{
-            "pointee_write": "1..=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "macro",
-         "value": "^ACPI_(WARNING|ERROR|INFO)$",
-         "properties":{
-            "pointee_write": "1..=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^fdt_get_property_by_offset_.*$",
-         "properties":{
-            "pointee_write": "3=always",
-            "pointee_read": "3=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^read_atomic_size.*$",
-         "properties":{
-            "pointee_write": "2=always",
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^device_tree_get_reg.*$",
-         "properties":{
-            "pointee_write": "4..=always",
-            "pointee_read": "4..=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^dt_get_range.*$",
-         "properties":{
-            "pointee_write": "3..=always",
-            "pointee_read": "3..=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^parse_static_mem_prop.*$",
-         "properties":{
-            "pointee_write": "2..=always",
-            "pointee_read": "2..=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^get_ttbr_and_gran_64bit.*$",
-         "properties":{
-            "pointee_write": "1..2=always",
-            "pointee_read": "1..2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^hvm_emulate_init_once.*$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^__vmread.*$",
-         "properties":{
-            "pointee_write": "2=always",
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^hvm_pci_decode_addr.*$",
-         "properties":{
-            "pointee_write": "3=always",
-            "pointee_read": "3=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^vpci_mmcfg_decode_addr.*$",
-         "properties":{
-            "pointee_write": "3=always",
-            "pointee_read": "3=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^x86emul_decode.*$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^unmap_grant_ref.*$",
-         "properties":{
-            "pointee_write": "2=always",
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^arm_smmu_cmdq_build_cmd.*$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^pci_size_mem_bar.*$",
-         "properties":{
-            "pointee_write": "4=always",
-            "pointee_read": "4=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^_hvm_read_entry.*$",
-         "properties":{
-            "pointee_write": "2=always",
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^hvm_map_guest_frame_rw.*$",
-         "properties":{
-            "pointee_write": "3=always",
-            "pointee_read": "3=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^guest_cpuid.*$",
-         "properties":{
-            "pointee_write": "4=always",
-            "pointee_read": "4=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^epte_get_entry_emt.*$",
-         "properties":{
-            "pointee_write": "5=always",
-            "pointee_read": "5=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^mcheck_mca_logout.*$",
-         "properties":{
-            "pointee_write": "3=always",
-            "pointee_read": "3=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^set_field_in_reg_u32.*$",
-         "properties":{
-            "pointee_write": "5=always",
-            "pointee_read": "5=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^alloc_affinity_masks.*$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^xasprintf.*$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^find_non_smt.*$",
-         "properties":{
-            "pointee_write": "2=always",
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^call_rcu.*$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^getdomaininfo.*$",
-         "properties":{
-            "pointee_write": "2=always",
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^MAPPING_(INSERT|SEARCH)\\(.*$",
-         "properties":{
-            "pointee_write": "2..=always",
-            "pointee_read": "2..=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^FormatDec.*$",
-         "properties":{
-            "pointee_write": "2=always",
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^FormatHex.*$",
-         "properties":{
-            "pointee_write": "3=always",
-            "pointee_read": "3=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^p2m_get_ioreq_server.*$",
-         "properties":{
-            "pointee_write": "2=always",
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^elf_memset_unchecked.*$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^set_iommu_pte_present.*$",
-         "properties":{
-            "pointee_write": "7=always",
-            "pointee_read": "7=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^clear_iommu_pte_present.*$",
-         "properties":{
-            "pointee_write": "4=always",
-            "pointee_read": "4=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^vcpu_runstate_get.*$",
-         "properties":{
-            "pointee_write": "2=always",
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^va_start.*$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^sgi_target_init.*$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^get_hw_residencies.*$",
-         "properties":{
-            "pointee_write": "2=always",
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^x86_cpu_policy_to_featureset.*$",
-         "properties":{
-            "pointee_write": "2=always",
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^simple_strtou?ll?\\(.*$",
-         "properties":{
-            "pointee_write": "2=always",
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^msi_compose_msg.*$",
-         "properties":{
-            "pointee_write": "3=always",
-            "pointee_read": "3=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^print_tainted.*$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^get_hvm_registers.*$",
-         "properties":{
-            "pointee_write": "3=always",
-            "pointee_read": "3=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^x86_insn_modrm.*$",
-         "properties":{
-            "pointee_write": "2..3=always",
-            "pointee_read": "2..3=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^cpuid_count_leaf.*$",
-         "properties":{
-            "pointee_write": "3=always",
-            "pointee_read": "3=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^rcu_lock_remote_domain_by_id.*$",
-         "properties":{
-            "pointee_write": "2=always",
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^cpuid_count.*$",
-         "properties":{
-            "pointee_write": "3..=always",
-            "pointee_read": "3..=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^.*efi_boot_mem_unused.*$",
-         "properties":{
-            "pointee_write": "1..=always",
-            "pointee_read": "1..=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^collect_time_info.*$",
-         "properties":{
-            "pointee_write": "2=always",
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^setup_xstate_comp.*$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^map_domain_gfn.*$",
-         "properties":{
-            "pointee_read": "5=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^fdt_getprop.*$",
-         "properties":{
-            "pointee_read": "4=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^fdt_get_name.*$",
-         "properties":{
-            "pointee_read": "3=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^fdt_get_property.*$",
-         "properties":{
-            "pointee_read": "4=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^pci_get_host_bridge_segment.*$",
-         "properties":{
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^dt_get_property.*$",
-         "properties":{
-            "pointee_read": "3=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^dt_property_read_u32.*$",
-         "properties":{
-            "pointee_read": "3=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^dt_device_get_paddr.*$",
-         "properties":{
-            "pointee_read": "3..4=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^get_evtchn_dt_property.*$",
-         "properties":{
-            "pointee_write": "2..3=maybe",
-            "pointee_read": "2..3=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^setup_chosen_node.*$",
-         "properties":{
-            "pointee_write": "2..3=maybe",
-            "pointee_read": "2..3=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^queue_remove_raw.*$",
-         "properties":{
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "macro",
-         "value": "^memset$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "macro",
-         "value": "^va_start$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "macro",
-         "value": "^memcmp$",
-         "properties":{
-            "pointee_write": "1..2=never",
-            "taken": ""
-         }
-      },
-      {
-         "type": "macro",
-         "value": "^memcpy$",
-         "properties":{
-            "pointee_write": "1=always&&2..=never",
-            "pointee_read": "1=never&&2..=always",
-            "taken": ""
-         }
-      },
-      {
-         "type": "function",
-         "value": "^get_cpu_info.*$",
-         "properties":{
-            "attribute": "pure"
-         }
-      },
-      {
-         "type": "function",
-         "value": "^pdx_to_pfn.*$",
-         "properties":{
-            "attribute": "pure"
-         }
-      },
-      {
-         "type": "function",
-         "value": "^is_pci_passthrough_enabled.*$",
-         "properties":{
-            "attribute": "const"
-         }
-      },
-      {
-         "type": "function",
-         "value": "^get_cycles.*$",
-         "properties":{
-            "attribute": "noeffect"
-         }
-      },
-      {
-         "type": "function",
-         "value": "^msi_gflags.*$",
-         "properties":{
-            "attribute": "const"
-         }
-      },
-      {
-         "type": "function",
-         "value": "^hvm_save_size.*$",
-         "properties":{
-            "attribute": "pure"
-         }
-      },
-      {
-         "type": "function",
-         "value": "^cpu_has.*$",
-         "properties":{
-            "attribute": "pure"
-         }
-      },
-      {
-         "type": "function",
-         "value": "^boot_cpu_has.*$",
-         "properties":{
-            "attribute": "pure"
-         }
-      },
-      {
-         "type": "function",
-         "value": "^get_cpu_info.*$",
-         "properties":{
-            "attribute": "pure"
-         }
-      },
-      {
-         "type": "function",
-         "value": "^put_pte_flags.*$",
-         "properties":{
-            "attribute": "const"
-         }
-      },
-      {
-         "type": "function",
-         "value": "^is_pv_cpu.*$",
-         "properties":{
-            "attribute": "pure"
-         }
-      },
-      {
-         "description": "Property inferred as a consequence of the semantics of device_tree_get_reg",
-         "type": "function",
-         "value": "^acquire_static_memory_bank.*$",
-         "properties":{
-            "pointee_write": "4..=always",
-            "pointee_read": "4..=never",
-            "taken": ""
-         }
-      },
-      {
-         "description": "Property inferred as a consequence of the semantics of dt_set_cell",
-         "type": "function",
-         "value": "^set_interrupt.*$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "description":"Property inferred as a consequence of the semantics of __p2m_get_mem_access",
-         "type": "function",
-         "value": "^p2m_get_mem_access.*$",
-         "properties":{
-            "pointee_write": "3=always",
-            "pointee_read": "3=never",
-            "taken": ""
-         }
-      },
-      {
-         "description": "This function has alternative definitions with props {write=always,read=never} and {write=never,read=never}",
-         "type": "function",
-         "value": "^alloc_cpumask_var.*$",
-         "properties":{
-            "pointee_write": "1=maybe",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "description": "Property inferred as a consequence of the semantics of alloc_cpumask_var",
-         "type": "function",
-         "value": "^xenctl_bitmap_to_cpumask.*$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "description": "The call to bitmap_and causes the pointee of dstp to be always written",
-         "type": "function",
-         "value": "^cpumask_(and|andnot|clear|copy|complement).*$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "description": "The call to bitmap_and causes the pointee of dstp to be always written",
-         "type": "function",
-         "value": "^bitmap_(andnot|complement|fill).*$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "description": "The .*copy_(to|from).* helpers all have a memcpy-like expectation that the destination is a copy of the source. Furthermore, their uses do initialize the involved variables as needed by futher uses in the caller.",
-         "type": "macro",
-         "value": "^(__)?(raw_)?copy_from_(paddr|guest|compat)(_offset)?$",
-         "properties":{
-            "pointee_write": "1=always",
-            "pointee_read": "1=never",
-            "taken": ""
-         }
-      },
-      {
-         "description":"The .*copy_(to|from).* helpers all have a memcpy-like expectation that the destination is a copy of the source. Furthermore, their uses do initialize the involved variables as needed by futher uses in the caller.",
-         "type": "macro",
-         "value": "^(__)?copy_to_(guest|compat)(_offset)?$",
-         "properties":{
-            "pointee_write": "2=always",
-            "pointee_read": "2=never",
-            "taken": ""
-         }
-      },
-      {
-         "description": "Functions generated by build_atomic_read cannot be considered pure since the input pointer is volatile, but they do not produce any persistent side effect.",
-         "type": "function",
-         "value": "^read_u(8|16|32|64|int)_atomic.*$",
-         "properties":{
-            "attribute": "noeffect"
-         }
-      },
-      {
-         "description": "Functions generated by TYPE_SAFE are const.",
-         "type": "function",
-         "value": "^(mfn|gfn|pfn)_x\\(.*$",
-         "properties":{
-            "attribute": "const"
-         }
-      },
-      {
-         "description": "Functions generated by TYPE_SAFE are const.",
-         "type": "function",
-         "value": "^_(mfn|gfn|pfn)\\(.*$",
-         "properties":{
-            "attribute": "const"
-         }
-      }
-   ]
-}
diff --git a/docs/function_macro_properties.rst b/docs/function_macro_properties.rst
deleted file mode 100644
index ea6fb5cf1f..0000000000
--- a/docs/function_macro_properties.rst
+++ /dev/null
@@ -1,58 +0,0 @@
-.. SPDX-License-Identifier: CC-BY-4.0
-
-Properties list for Xen
-=======================
-
-Some functions and macros are found to have properties relevant to
-the Xen codebase. For this reason, the file docs/properties.json
-contains all the needed properties.
-
-Here is an example of the properties.json file::
-
-  {
-     "version": "1.0",
-     "content": [
-        {
-           "description": ""
-           "type": "function",       // required
-           "value:": "^printk*.$",   // required
-           "properties":{
-              "pointee_write": "1..2=never",
-              "pointee_read": "",
-              "taken": ""
-              "attribute": ""
-           }
-        }
-     ]
-  }
-
-Here is an explanation of the fields inside an object of the "content" array:
-
- - description: a brief description of why the properties apply
- - type: this is the kind of the element called: it may be either ``macro`` or ``function``
- - value: must be a regex, starting with ^ and ending with $ and matching function fully
-   qualified name or macro name.
- - properties: a list of properties applied to said function.
-   Possible values are:
-
-    - pointee_write: indicate the write use for call arguments that correspond to
-      parameters whose pointee types are non-const
-    - pointee_read: indicate the read use for call arguments that correspond to
-      parameters whose pointee types are non-const
-    - taken: indicates that the specified address arguments may be stored in objects
-      that persist after the function has ceased to exist (excluding the returned value);
-      address arguments not listed are never taken
-    - attribute: attributes a function may have. Possible values are pure, const and noeffect.
-
-   pointee_read and pointee_write use a specific kind of argument, structured as pointee_arg=rw:
-
-    - pointee_arg: argument index for callee. Index 0 refers to the return value,
-      the indices of the arguments start from 1. It can be either a single value or a range.
-    - rw: a value that's either always, maybe or never
-
-       - always: for pointee_read: argument pointee is expected to be fully read in the function body,
-         for pointee_write: argument pointee is fully initialized at function exit
-       - maybe: for pointee_read: argument pointee may be expected to be read in the function body,
-         for pointee_write: argument pointee may be written by function body
-       - never: for pointee_read: argument pointee is not expected to be read in the function body,
-         for pointee_write: argument pointee is never written by function body
diff --git a/docs/misra/function-macro-properties.json b/docs/misra/function-macro-properties.json
new file mode 100644
index 0000000000..74058297b5
--- /dev/null
+++ b/docs/misra/function-macro-properties.json
@@ -0,0 +1,841 @@
+{
+   "version": "1.0",
+   "content": [
+      {
+         "type": "function",
+         "value": "^printk.*$",
+         "properties":{
+            "pointee_write": "1..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^debugtrace_printk.*$",
+         "properties":{
+            "pointee_write": "1..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^panic.*$",
+         "properties":{
+            "pointee_write": "1..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^domain_crash$",
+         "properties":{
+            "pointee_write": "2..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^(g?d|mm_)?printk$",
+         "properties":{
+            "pointee_write": "2..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^guest_bug_on_failed$",
+         "properties":{
+            "pointee_write": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^spin_lock_init_prof$",
+         "properties":{
+            "pointee_write": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^sched_test_func$",
+         "properties":{
+            "pointee_write": "1..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^dev_(info|warn)$",
+         "properties":{
+            "pointee_write": "1..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^PAGING_DEBUG$",
+         "properties":{
+            "pointee_write": "1..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^ACPI_(WARNING|ERROR|INFO)$",
+         "properties":{
+            "pointee_write": "1..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^fdt_get_property_by_offset_.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^read_atomic_size.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^device_tree_get_reg.*$",
+         "properties":{
+            "pointee_write": "4..=always",
+            "pointee_read": "4..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^dt_get_range.*$",
+         "properties":{
+            "pointee_write": "3..=always",
+            "pointee_read": "3..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^parse_static_mem_prop.*$",
+         "properties":{
+            "pointee_write": "2..=always",
+            "pointee_read": "2..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^get_ttbr_and_gran_64bit.*$",
+         "properties":{
+            "pointee_write": "1..2=always",
+            "pointee_read": "1..2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^hvm_emulate_init_once.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^__vmread.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^hvm_pci_decode_addr.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^vpci_mmcfg_decode_addr.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^x86emul_decode.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^unmap_grant_ref.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^arm_smmu_cmdq_build_cmd.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^pci_size_mem_bar.*$",
+         "properties":{
+            "pointee_write": "4=always",
+            "pointee_read": "4=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^_hvm_read_entry.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^hvm_map_guest_frame_rw.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^guest_cpuid.*$",
+         "properties":{
+            "pointee_write": "4=always",
+            "pointee_read": "4=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^epte_get_entry_emt.*$",
+         "properties":{
+            "pointee_write": "5=always",
+            "pointee_read": "5=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^mcheck_mca_logout.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^set_field_in_reg_u32.*$",
+         "properties":{
+            "pointee_write": "5=always",
+            "pointee_read": "5=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^alloc_affinity_masks.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^xasprintf.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^find_non_smt.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^call_rcu.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^getdomaininfo.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^MAPPING_(INSERT|SEARCH)\\(.*$",
+         "properties":{
+            "pointee_write": "2..=always",
+            "pointee_read": "2..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^FormatDec.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^FormatHex.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^p2m_get_ioreq_server.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^elf_memset_unchecked.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^set_iommu_pte_present.*$",
+         "properties":{
+            "pointee_write": "7=always",
+            "pointee_read": "7=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^clear_iommu_pte_present.*$",
+         "properties":{
+            "pointee_write": "4=always",
+            "pointee_read": "4=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^vcpu_runstate_get.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^va_start.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^sgi_target_init.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^get_hw_residencies.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^x86_cpu_policy_to_featureset.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^simple_strtou?ll?\\(.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^msi_compose_msg.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^print_tainted.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^get_hvm_registers.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^x86_insn_modrm.*$",
+         "properties":{
+            "pointee_write": "2..3=always",
+            "pointee_read": "2..3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^cpuid_count_leaf.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^rcu_lock_remote_domain_by_id.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^cpuid_count.*$",
+         "properties":{
+            "pointee_write": "3..=always",
+            "pointee_read": "3..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^.*efi_boot_mem_unused.*$",
+         "properties":{
+            "pointee_write": "1..=always",
+            "pointee_read": "1..=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^collect_time_info.*$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^setup_xstate_comp.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^map_domain_gfn.*$",
+         "properties":{
+            "pointee_read": "5=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^fdt_getprop.*$",
+         "properties":{
+            "pointee_read": "4=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^fdt_get_name.*$",
+         "properties":{
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^fdt_get_property.*$",
+         "properties":{
+            "pointee_read": "4=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^pci_get_host_bridge_segment.*$",
+         "properties":{
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^dt_get_property.*$",
+         "properties":{
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^dt_property_read_u32.*$",
+         "properties":{
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^dt_device_get_paddr.*$",
+         "properties":{
+            "pointee_read": "3..4=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^get_evtchn_dt_property.*$",
+         "properties":{
+            "pointee_write": "2..3=maybe",
+            "pointee_read": "2..3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^setup_chosen_node.*$",
+         "properties":{
+            "pointee_write": "2..3=maybe",
+            "pointee_read": "2..3=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^queue_remove_raw.*$",
+         "properties":{
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^memset$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^va_start$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^memcmp$",
+         "properties":{
+            "pointee_write": "1..2=never",
+            "taken": ""
+         }
+      },
+      {
+         "type": "macro",
+         "value": "^memcpy$",
+         "properties":{
+            "pointee_write": "1=always&&2..=never",
+            "pointee_read": "1=never&&2..=always",
+            "taken": ""
+         }
+      },
+      {
+         "type": "function",
+         "value": "^get_cpu_info.*$",
+         "properties":{
+            "attribute": "pure"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^pdx_to_pfn.*$",
+         "properties":{
+            "attribute": "pure"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^is_pci_passthrough_enabled.*$",
+         "properties":{
+            "attribute": "const"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^get_cycles.*$",
+         "properties":{
+            "attribute": "noeffect"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^msi_gflags.*$",
+         "properties":{
+            "attribute": "const"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^hvm_save_size.*$",
+         "properties":{
+            "attribute": "pure"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^cpu_has.*$",
+         "properties":{
+            "attribute": "pure"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^boot_cpu_has.*$",
+         "properties":{
+            "attribute": "pure"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^get_cpu_info.*$",
+         "properties":{
+            "attribute": "pure"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^put_pte_flags.*$",
+         "properties":{
+            "attribute": "const"
+         }
+      },
+      {
+         "type": "function",
+         "value": "^is_pv_cpu.*$",
+         "properties":{
+            "attribute": "pure"
+         }
+      },
+      {
+         "description": "Property inferred as a consequence of the semantics of device_tree_get_reg",
+         "type": "function",
+         "value": "^acquire_static_memory_bank.*$",
+         "properties":{
+            "pointee_write": "4..=always",
+            "pointee_read": "4..=never",
+            "taken": ""
+         }
+      },
+      {
+         "description": "Property inferred as a consequence of the semantics of dt_set_cell",
+         "type": "function",
+         "value": "^set_interrupt.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "description":"Property inferred as a consequence of the semantics of __p2m_get_mem_access",
+         "type": "function",
+         "value": "^p2m_get_mem_access.*$",
+         "properties":{
+            "pointee_write": "3=always",
+            "pointee_read": "3=never",
+            "taken": ""
+         }
+      },
+      {
+         "description": "This function has alternative definitions with props {write=always,read=never} and {write=never,read=never}",
+         "type": "function",
+         "value": "^alloc_cpumask_var.*$",
+         "properties":{
+            "pointee_write": "1=maybe",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "description": "Property inferred as a consequence of the semantics of alloc_cpumask_var",
+         "type": "function",
+         "value": "^xenctl_bitmap_to_cpumask.*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "description": "The call to bitmap_and causes the pointee of dstp to be always written",
+         "type": "function",
+         "value": "^cpumask_(and|andnot|clear|copy|complement).*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "description": "The call to bitmap_and causes the pointee of dstp to be always written",
+         "type": "function",
+         "value": "^bitmap_(andnot|complement|fill).*$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "description": "The .*copy_(to|from).* helpers all have a memcpy-like expectation that the destination is a copy of the source. Furthermore, their uses do initialize the involved variables as needed by futher uses in the caller.",
+         "type": "macro",
+         "value": "^(__)?(raw_)?copy_from_(paddr|guest|compat)(_offset)?$",
+         "properties":{
+            "pointee_write": "1=always",
+            "pointee_read": "1=never",
+            "taken": ""
+         }
+      },
+      {
+         "description":"The .*copy_(to|from).* helpers all have a memcpy-like expectation that the destination is a copy of the source. Furthermore, their uses do initialize the involved variables as needed by futher uses in the caller.",
+         "type": "macro",
+         "value": "^(__)?copy_to_(guest|compat)(_offset)?$",
+         "properties":{
+            "pointee_write": "2=always",
+            "pointee_read": "2=never",
+            "taken": ""
+         }
+      },
+      {
+         "description": "Functions generated by build_atomic_read cannot be considered pure since the input pointer is volatile, but they do not produce any persistent side effect.",
+         "type": "function",
+         "value": "^read_u(8|16|32|64|int)_atomic.*$",
+         "properties":{
+            "attribute": "noeffect"
+         }
+      },
+      {
+         "description": "Functions generated by TYPE_SAFE are const.",
+         "type": "function",
+         "value": "^(mfn|gfn|pfn)_x\\(.*$",
+         "properties":{
+            "attribute": "const"
+         }
+      },
+      {
+         "description": "Functions generated by TYPE_SAFE are const.",
+         "type": "function",
+         "value": "^_(mfn|gfn|pfn)\\(.*$",
+         "properties":{
+            "attribute": "const"
+         }
+      }
+   ]
+}
diff --git a/docs/misra/function-macro-properties.rst b/docs/misra/function-macro-properties.rst
new file mode 100644
index 0000000000..ea6fb5cf1f
--- /dev/null
+++ b/docs/misra/function-macro-properties.rst
@@ -0,0 +1,58 @@
+.. SPDX-License-Identifier: CC-BY-4.0
+
+Properties list for Xen
+=======================
+
+Some functions and macros are found to have properties relevant to
+the Xen codebase. For this reason, the file docs/properties.json
+contains all the needed properties.
+
+Here is an example of the properties.json file::
+
+  {
+     "version": "1.0",
+     "content": [
+        {
+           "description": ""
+           "type": "function",       // required
+           "value:": "^printk*.$",   // required
+           "properties":{
+              "pointee_write": "1..2=never",
+              "pointee_read": "",
+              "taken": ""
+              "attribute": ""
+           }
+        }
+     ]
+  }
+
+Here is an explanation of the fields inside an object of the "content" array:
+
+ - description: a brief description of why the properties apply
+ - type: this is the kind of the element called: it may be either ``macro`` or ``function``
+ - value: must be a regex, starting with ^ and ending with $ and matching function fully
+   qualified name or macro name.
+ - properties: a list of properties applied to said function.
+   Possible values are:
+
+    - pointee_write: indicate the write use for call arguments that correspond to
+      parameters whose pointee types are non-const
+    - pointee_read: indicate the read use for call arguments that correspond to
+      parameters whose pointee types are non-const
+    - taken: indicates that the specified address arguments may be stored in objects
+      that persist after the function has ceased to exist (excluding the returned value);
+      address arguments not listed are never taken
+    - attribute: attributes a function may have. Possible values are pure, const and noeffect.
+
+   pointee_read and pointee_write use a specific kind of argument, structured as pointee_arg=rw:
+
+    - pointee_arg: argument index for callee. Index 0 refers to the return value,
+      the indices of the arguments start from 1. It can be either a single value or a range.
+    - rw: a value that's either always, maybe or never
+
+       - always: for pointee_read: argument pointee is expected to be fully read in the function body,
+         for pointee_write: argument pointee is fully initialized at function exit
+       - maybe: for pointee_read: argument pointee may be expected to be read in the function body,
+         for pointee_write: argument pointee may be written by function body
+       - never: for pointee_read: argument pointee is not expected to be read in the function body,
+         for pointee_write: argument pointee is never written by function body
diff --git a/docs/misra/index.rst b/docs/misra/index.rst
index 5068ee5aef..bde9d9cffb 100644
--- a/docs/misra/index.rst
+++ b/docs/misra/index.rst
@@ -16,3 +16,4 @@ Xen hypervisor code and related documents.
    documenting-violations
    exclude-list
    xen-static-analysis
+   function-macro-properties
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 07:33:36 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 07:33:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686864.1069418 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfavA-0001cB-5Z; Thu, 29 Feb 2024 07:33:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686864.1069418; Thu, 29 Feb 2024 07:33:36 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfavA-0001c3-2U; Thu, 29 Feb 2024 07:33:36 +0000
Received: by outflank-mailman (input) for mailman id 686864;
 Thu, 29 Feb 2024 07:33:34 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfav8-0001bm-7G
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:33:34 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfav8-0005jC-5e
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:33:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfav8-0000aH-4o
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:33:34 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=mBcc91snf2XD2Od33fwoCOiIxNaSTIh+A0QCoLY95Dk=; b=dOmoLuuUzKEASlEORoViYx/duL
	Y1asEPPYw/EVoROnLm1riVrbxIugp3HZIyJclRjFvo2UkxjgGRKGhkP/T47KnvKQiZifykQAadKmx
	b6nanBCoUKFKEuLeDK2PVtffVcHkF+TtEC332ZNqfeLF2HRPCUop4T/iGdH469UTAxz0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86: remove redundant XEN_SHSTK check from reinit_bsp_stack()
Message-Id: <E1rfav8-0000aH-4o@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 07:33:34 +0000

commit c103bb8ad41aeffbbb990ac60a5b2b0da28c82fd
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Feb 29 08:20:46 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 29 08:20:46 2024 +0100

    x86: remove redundant XEN_SHSTK check from reinit_bsp_stack()
    
    As of 72d51813d631 ("x86: amend cpu_has_xen_{ibt,shstk}") this has been
    integrated into cpu_has_xen_shstk.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index e487591fe0..a21984b1cc 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -810,7 +810,7 @@ static void __init noreturn reinit_bsp_stack(void)
     if ( rc )
         panic("Error %d setting up PV root page table\n", rc);
 
-    if ( IS_ENABLED(CONFIG_XEN_SHSTK) && cpu_has_xen_shstk )
+    if ( cpu_has_xen_shstk )
     {
         wrmsrl(MSR_PL0_SSP,
                (unsigned long)stack + (PRIMARY_SHSTK_SLOT + 1) * PAGE_SIZE - 8);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 07:33:46 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 07:33:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.686865.1069421 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfavK-0001f7-6Q; Thu, 29 Feb 2024 07:33:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 686865.1069421; Thu, 29 Feb 2024 07:33:46 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfavK-0001f0-3v; Thu, 29 Feb 2024 07:33:46 +0000
Received: by outflank-mailman (input) for mailman id 686865;
 Thu, 29 Feb 2024 07:33:44 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfavI-0001ec-9Z
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:33:44 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfavI-0005jL-8k
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:33:44 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfavI-0000ag-7p
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 07:33:44 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=O/rcs0OtQyGwNYMCbMiMKR3N8wc5+gDB85VVYn1odpg=; b=gzOXOufM2Qy+FbRhRCq8ijGTNo
	njN1nN/aZDCwMqyKouhxY6yACUvX8MK/VZpLzv5GyyhLa7KXT67gR19dJkz5fySQV1K28yGG8Mk/D
	VVeHgQqKR5ZU40Wo9L3enFJd3u259DDMlyeG2/a7TVsG8VEZDgmPiuj5PfaG1AvPUPhE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/altcall: always use a temporary parameter stashing variable
Message-Id: <E1rfavI-0000ag-7p@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 07:33:44 +0000

commit c20850540ad6a32f4fc17bde9b01c92b0df18bf0
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Thu Feb 29 08:21:49 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 29 08:21:49 2024 +0100

    x86/altcall: always use a temporary parameter stashing variable
    
    The usage in ALT_CALL_ARG() on clang of:
    
    register union {
        typeof(arg) e;
        const unsigned long r;
    } ...
    
    When `arg` is the first argument to alternative_{,v}call() and
    const_vlapic_vcpu() is used results in clang 3.5.0 complaining with:
    
    arch/x86/hvm/vlapic.c:141:47: error: non-const static data member must be initialized out of line
             alternative_call(hvm_funcs.test_pir, const_vlapic_vcpu(vlapic), vec) )
    
    Workaround this by pulling `arg1` into a local variable, like it's done for
    further arguments (arg2, arg3...)
    
    Originally arg1 wasn't pulled into a variable because for the a1_ register
    local variable the possible clobbering as a result of operators on other
    variables don't matter:
    
    https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html#Local-Register-Variables
    
    Note clang version 3.8.1 seems to already be fixed and don't require the
    workaround, but since it's harmless do it uniformly everywhere.
    
    Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Fixes: 2ce562b2a413 ('x86/altcall: use a union as register type for function parameters on clang')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/include/asm/alternative.h | 36 ++++++++++++++++++++++------------
 1 file changed, 24 insertions(+), 12 deletions(-)

diff --git a/xen/arch/x86/include/asm/alternative.h b/xen/arch/x86/include/asm/alternative.h
index 3c14db5078..0d3697f1de 100644
--- a/xen/arch/x86/include/asm/alternative.h
+++ b/xen/arch/x86/include/asm/alternative.h
@@ -253,21 +253,24 @@ extern void alternative_branches(void);
 })
 
 #define alternative_vcall1(func, arg) ({           \
-    ALT_CALL_ARG(arg, 1);                          \
+    typeof(arg) v1_ = (arg);                       \
+    ALT_CALL_ARG(v1_, 1);                          \
     ALT_CALL_NO_ARG2;                              \
     (void)sizeof(func(arg));                       \
     (void)alternative_callN(1, int, func);         \
 })
 
 #define alternative_call1(func, arg) ({            \
-    ALT_CALL_ARG(arg, 1);                          \
+    typeof(arg) v1_ = (arg);                       \
+    ALT_CALL_ARG(v1_, 1);                          \
     ALT_CALL_NO_ARG2;                              \
     alternative_callN(1, typeof(func(arg)), func); \
 })
 
 #define alternative_vcall2(func, arg1, arg2) ({           \
+    typeof(arg1) v1_ = (arg1);                            \
     typeof(arg2) v2_ = (arg2);                            \
-    ALT_CALL_ARG(arg1, 1);                                \
+    ALT_CALL_ARG(v1_, 1);                                 \
     ALT_CALL_ARG(v2_, 2);                                 \
     ALT_CALL_NO_ARG3;                                     \
     (void)sizeof(func(arg1, arg2));                       \
@@ -275,17 +278,19 @@ extern void alternative_branches(void);
 })
 
 #define alternative_call2(func, arg1, arg2) ({            \
+    typeof(arg1) v1_ = (arg1);                            \
     typeof(arg2) v2_ = (arg2);                            \
-    ALT_CALL_ARG(arg1, 1);                                \
+    ALT_CALL_ARG(v1_, 1);                                 \
     ALT_CALL_ARG(v2_, 2);                                 \
     ALT_CALL_NO_ARG3;                                     \
     alternative_callN(2, typeof(func(arg1, arg2)), func); \
 })
 
 #define alternative_vcall3(func, arg1, arg2, arg3) ({    \
+    typeof(arg1) v1_ = (arg1);                           \
     typeof(arg2) v2_ = (arg2);                           \
     typeof(arg3) v3_ = (arg3);                           \
-    ALT_CALL_ARG(arg1, 1);                               \
+    ALT_CALL_ARG(v1_, 1);                                \
     ALT_CALL_ARG(v2_, 2);                                \
     ALT_CALL_ARG(v3_, 3);                                \
     ALT_CALL_NO_ARG4;                                    \
@@ -294,9 +299,10 @@ extern void alternative_branches(void);
 })
 
 #define alternative_call3(func, arg1, arg2, arg3) ({     \
+    typeof(arg1) v1_ = (arg1);                            \
     typeof(arg2) v2_ = (arg2);                           \
     typeof(arg3) v3_ = (arg3);                           \
-    ALT_CALL_ARG(arg1, 1);                               \
+    ALT_CALL_ARG(v1_, 1);                                \
     ALT_CALL_ARG(v2_, 2);                                \
     ALT_CALL_ARG(v3_, 3);                                \
     ALT_CALL_NO_ARG4;                                    \
@@ -305,10 +311,11 @@ extern void alternative_branches(void);
 })
 
 #define alternative_vcall4(func, arg1, arg2, arg3, arg4) ({ \
+    typeof(arg1) v1_ = (arg1);                              \
     typeof(arg2) v2_ = (arg2);                              \
     typeof(arg3) v3_ = (arg3);                              \
     typeof(arg4) v4_ = (arg4);                              \
-    ALT_CALL_ARG(arg1, 1);                                  \
+    ALT_CALL_ARG(v1_, 1);                                   \
     ALT_CALL_ARG(v2_, 2);                                   \
     ALT_CALL_ARG(v3_, 3);                                   \
     ALT_CALL_ARG(v4_, 4);                                   \
@@ -318,10 +325,11 @@ extern void alternative_branches(void);
 })
 
 #define alternative_call4(func, arg1, arg2, arg3, arg4) ({  \
+    typeof(arg1) v1_ = (arg1);                              \
     typeof(arg2) v2_ = (arg2);                              \
     typeof(arg3) v3_ = (arg3);                              \
     typeof(arg4) v4_ = (arg4);                              \
-    ALT_CALL_ARG(arg1, 1);                                  \
+    ALT_CALL_ARG(v1_, 1);                                   \
     ALT_CALL_ARG(v2_, 2);                                   \
     ALT_CALL_ARG(v3_, 3);                                   \
     ALT_CALL_ARG(v4_, 4);                                   \
@@ -332,11 +340,12 @@ extern void alternative_branches(void);
 })
 
 #define alternative_vcall5(func, arg1, arg2, arg3, arg4, arg5) ({ \
+    typeof(arg1) v1_ = (arg1);                                    \
     typeof(arg2) v2_ = (arg2);                                    \
     typeof(arg3) v3_ = (arg3);                                    \
     typeof(arg4) v4_ = (arg4);                                    \
     typeof(arg5) v5_ = (arg5);                                    \
-    ALT_CALL_ARG(arg1, 1);                                        \
+    ALT_CALL_ARG(v1_, 1);                                         \
     ALT_CALL_ARG(v2_, 2);                                         \
     ALT_CALL_ARG(v3_, 3);                                         \
     ALT_CALL_ARG(v4_, 4);                                         \
@@ -347,11 +356,12 @@ extern void alternative_branches(void);
 })
 
 #define alternative_call5(func, arg1, arg2, arg3, arg4, arg5) ({  \
+    typeof(arg1) v1_ = (arg1);                                    \
     typeof(arg2) v2_ = (arg2);                                    \
     typeof(arg3) v3_ = (arg3);                                    \
     typeof(arg4) v4_ = (arg4);                                    \
     typeof(arg5) v5_ = (arg5);                                    \
-    ALT_CALL_ARG(arg1, 1);                                        \
+    ALT_CALL_ARG(v1_, 1);                                         \
     ALT_CALL_ARG(v2_, 2);                                         \
     ALT_CALL_ARG(v3_, 3);                                         \
     ALT_CALL_ARG(v4_, 4);                                         \
@@ -363,12 +373,13 @@ extern void alternative_branches(void);
 })
 
 #define alternative_vcall6(func, arg1, arg2, arg3, arg4, arg5, arg6) ({ \
+    typeof(arg1) v1_ = (arg1);                                          \
     typeof(arg2) v2_ = (arg2);                                          \
     typeof(arg3) v3_ = (arg3);                                          \
     typeof(arg4) v4_ = (arg4);                                          \
     typeof(arg5) v5_ = (arg5);                                          \
     typeof(arg6) v6_ = (arg6);                                          \
-    ALT_CALL_ARG(arg1, 1);                                              \
+    ALT_CALL_ARG(v1_, 1);                                               \
     ALT_CALL_ARG(v2_, 2);                                               \
     ALT_CALL_ARG(v3_, 3);                                               \
     ALT_CALL_ARG(v4_, 4);                                               \
@@ -379,12 +390,13 @@ extern void alternative_branches(void);
 })
 
 #define alternative_call6(func, arg1, arg2, arg3, arg4, arg5, arg6) ({  \
+    typeof(arg1) v1_ = (arg1);                                          \
     typeof(arg2) v2_ = (arg2);                                          \
     typeof(arg3) v3_ = (arg3);                                          \
     typeof(arg4) v4_ = (arg4);                                          \
     typeof(arg5) v5_ = (arg5);                                          \
     typeof(arg6) v6_ = (arg6);                                          \
-    ALT_CALL_ARG(arg1, 1);                                              \
+    ALT_CALL_ARG(v1_, 1);                                               \
     ALT_CALL_ARG(v2_, 2);                                               \
     ALT_CALL_ARG(v3_, 3);                                               \
     ALT_CALL_ARG(v4_, 4);                                               \
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:22:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:22:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687086.1069916 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgMN-0003Bq-Ov; Thu, 29 Feb 2024 13:22:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687086.1069916; Thu, 29 Feb 2024 13:22:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgMN-0003Bj-MU; Thu, 29 Feb 2024 13:22:03 +0000
Received: by outflank-mailman (input) for mailman id 687086;
 Thu, 29 Feb 2024 13:22:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgMM-0003Bd-CT
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgMM-0004pm-9o
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgMM-0004AN-8r
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=a59++7nN32osQ9HOdmGKbQfzw55YhJHLzeUSESBXGsg=; b=ut2piyHGu60mj1LT4qPaLB6e0V
	/tjd/VnzXF430fJqW/QjSVvl4cY+q2FspYtuTrOLRRmcP3PtOjOSjWHO48nFRSPf2OTkJsTKpUr8l
	nOD9GPWYhRUyqzekrASDVcxHmcpizE57H736NDBqv4qFLAUNbWvTM7y80AtVpKfTuWho=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: ffa: reclaim shared memory on guest destroy
Message-Id: <E1rfgMM-0004AN-8r@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:22:02 +0000

commit 7356bb5e47d3cfccc3e19264227749cc4756ebdb
Author:     Jens Wiklander <jens.wiklander@linaro.org>
AuthorDate: Tue Feb 13 12:13:36 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Tue Feb 27 11:12:06 2024 +0000

    xen/arm: ffa: reclaim shared memory on guest destroy
    
    When an FF-A enabled guest is destroyed it may leave behind memory
    shared with SPs. This memory must be reclaimed before it's reused or an
    SP may make changes to memory used by a new unrelated guest. So when the
    domain is teared down add FF-A requests to reclaim all remaining shared
    memory.
    
    SPs in the secure world are notified using VM_DESTROYED that a guest has
    been destroyed. An SP is supposed to relinquish all shared memory to allow
    reclaiming the memory. The relinquish operation may need to be delayed if
    the shared memory is for instance part of a DMA operation.
    
    The domain reference counter is increased when the first FF-A shared
    memory is registered and the counter is decreased again when the last
    shared memory is reclaimed. If FF-A shared memory registrations remain
    at the end of of ffa_domain_teardown() a timer is set to try to reclaim
    the shared memory every second until the memory is reclaimed.
    
    A few minor style fixes with a removed empty line here and an added new
    line there.
    
    Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
---
 xen/arch/arm/tee/ffa.c | 295 ++++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 245 insertions(+), 50 deletions(-)

diff --git a/xen/arch/arm/tee/ffa.c b/xen/arch/arm/tee/ffa.c
index 0793c1c758..9a05dcede1 100644
--- a/xen/arch/arm/tee/ffa.c
+++ b/xen/arch/arm/tee/ffa.c
@@ -54,6 +54,7 @@
 #include <xen/mm.h>
 #include <xen/sched.h>
 #include <xen/sizes.h>
+#include <xen/timer.h>
 #include <xen/types.h>
 
 #include <asm/event.h>
@@ -144,6 +145,12 @@
  */
 #define FFA_MAX_SHM_COUNT               32
 
+/*
+ * The time we wait until trying to tear down a domain again if it was
+ * blocked initially.
+ */
+#define FFA_CTX_TEARDOWN_DELAY          SECONDS(1)
+
 /* FF-A-1.1-REL0 section 10.9.2 Memory region handle, page 167 */
 #define FFA_HANDLE_HYP_FLAG             BIT(63, ULL)
 #define FFA_HANDLE_INVALID              0xffffffffffffffffULL
@@ -384,11 +391,6 @@ struct ffa_ctx {
     unsigned int page_count;
     /* FF-A version used by the guest */
     uint32_t guest_vers;
-    /*
-     * Number of SPs that we have sent a VM created signal to, used in
-     * ffa_domain_teardown() to know which SPs need to be signalled.
-     */
-    uint16_t create_signal_count;
     bool rx_is_free;
     /* Used shared memory objects, struct ffa_shm_mem */
     struct list_head shm_list;
@@ -402,6 +404,15 @@ struct ffa_ctx {
     spinlock_t tx_lock;
     spinlock_t rx_lock;
     spinlock_t lock;
+    /* Used if domain can't be torn down immediately */
+    struct domain *teardown_d;
+    struct list_head teardown_list;
+    s_time_t teardown_expire;
+    /*
+     * Used for ffa_domain_teardown() to keep track of which SPs should be
+     * notified that this guest is being destroyed.
+     */
+    unsigned long vm_destroy_bitmap[];
 };
 
 struct ffa_shm_mem {
@@ -436,6 +447,12 @@ static void *ffa_tx __read_mostly;
 static DEFINE_SPINLOCK(ffa_rx_buffer_lock);
 static DEFINE_SPINLOCK(ffa_tx_buffer_lock);
 
+
+/* Used to track domains that could not be torn down immediately. */
+static struct timer ffa_teardown_timer;
+static struct list_head ffa_teardown_head;
+static DEFINE_SPINLOCK(ffa_teardown_lock);
+
 static bool ffa_get_version(uint32_t *vers)
 {
     const struct arm_smccc_1_2_regs arg = {
@@ -853,7 +870,6 @@ static int32_t handle_partition_info_get(uint32_t w1, uint32_t w2, uint32_t w3,
             goto out_rx_release;
         }
 
-
         memcpy(ctx->rx, ffa_rx, sz);
     }
     ctx->rx_is_free = false;
@@ -992,53 +1008,83 @@ static void put_shm_pages(struct ffa_shm_mem *shm)
     }
 }
 
-static bool inc_ctx_shm_count(struct ffa_ctx *ctx)
+static bool inc_ctx_shm_count(struct domain *d, struct ffa_ctx *ctx)
 {
     bool ret = true;
 
     spin_lock(&ctx->lock);
-    if (ctx->shm_count >= FFA_MAX_SHM_COUNT)
+
+    if ( ctx->shm_count >= FFA_MAX_SHM_COUNT )
+    {
         ret = false;
+    }
     else
+    {
+        /*
+         * If this is the first shm added, increase the domain reference
+         * counter as we need to keep domain around a bit longer to reclaim
+         * the shared memory in the teardown path.
+         */
+        if ( !ctx->shm_count )
+            get_knownalive_domain(d);
+
         ctx->shm_count++;
+    }
+
     spin_unlock(&ctx->lock);
 
     return ret;
 }
 
-static void dec_ctx_shm_count(struct ffa_ctx *ctx)
+static void dec_ctx_shm_count(struct domain *d, struct ffa_ctx *ctx)
 {
+    bool drop_ref;
+
     spin_lock(&ctx->lock);
+
     ASSERT(ctx->shm_count > 0);
     ctx->shm_count--;
+
+    /*
+     * If this was the last shm removed, let go of the domain reference we
+     * took in inc_ctx_shm_count() above.
+     */
+    drop_ref = !ctx->shm_count;
+
     spin_unlock(&ctx->lock);
+
+    if ( drop_ref )
+        put_domain(d);
 }
 
-static struct ffa_shm_mem *alloc_ffa_shm_mem(struct ffa_ctx *ctx,
+static struct ffa_shm_mem *alloc_ffa_shm_mem(struct domain *d,
                                              unsigned int page_count)
 {
+    struct ffa_ctx *ctx = d->arch.tee;
     struct ffa_shm_mem *shm;
 
     if ( page_count >= FFA_MAX_SHM_PAGE_COUNT )
         return NULL;
-    if ( !inc_ctx_shm_count(ctx) )
+    if ( !inc_ctx_shm_count(d, ctx) )
         return NULL;
 
     shm = xzalloc_flex_struct(struct ffa_shm_mem, pages, page_count);
     if ( shm )
         shm->page_count = page_count;
     else
-        dec_ctx_shm_count(ctx);
+        dec_ctx_shm_count(d, ctx);
 
     return shm;
 }
 
-static void free_ffa_shm_mem(struct ffa_ctx *ctx, struct ffa_shm_mem *shm)
+static void free_ffa_shm_mem(struct domain *d, struct ffa_shm_mem *shm)
 {
+    struct ffa_ctx *ctx = d->arch.tee;
+
     if ( !shm )
         return;
 
-    dec_ctx_shm_count(ctx);
+    dec_ctx_shm_count(d, ctx);
     put_shm_pages(shm);
     xfree(shm);
 }
@@ -1306,7 +1352,7 @@ static void handle_mem_share(struct cpu_user_regs *regs)
         goto out_unlock;
     }
 
-    shm = alloc_ffa_shm_mem(ctx, page_count);
+    shm = alloc_ffa_shm_mem(d, page_count);
     if ( !shm )
     {
         ret = FFA_RET_NO_MEMORY;
@@ -1350,7 +1396,7 @@ static void handle_mem_share(struct cpu_user_regs *regs)
 
 out:
     if ( ret )
-        free_ffa_shm_mem(ctx, shm);
+        free_ffa_shm_mem(d, shm);
 out_unlock:
     spin_unlock(&ctx->tx_lock);
 
@@ -1401,7 +1447,7 @@ static int handle_mem_reclaim(uint64_t handle, uint32_t flags)
     }
     else
     {
-        free_ffa_shm_mem(ctx, shm);
+        free_ffa_shm_mem(d, shm);
     }
 
     return ret;
@@ -1486,6 +1532,41 @@ static bool ffa_handle_call(struct cpu_user_regs *regs)
     }
 }
 
+static bool is_in_subscr_list(const uint16_t *subscr, uint16_t start,
+                              uint16_t end, uint16_t sp_id)
+{
+    unsigned int n;
+
+    for ( n = start; n < end; n++ )
+    {
+        if ( subscr[n] == sp_id )
+            return true;
+    }
+
+    return false;
+}
+
+static void vm_destroy_bitmap_init(struct ffa_ctx *ctx,
+                                   unsigned int create_signal_count)
+{
+    unsigned int n;
+
+    for ( n = 0; n < subscr_vm_destroyed_count; n++ )
+    {
+        /*
+         * Skip SPs subscribed to the VM created event that never was
+         * notified of the VM creation due to an error during
+         * ffa_domain_init().
+         */
+        if ( is_in_subscr_list(subscr_vm_created, create_signal_count,
+                               subscr_vm_created_count,
+                               subscr_vm_destroyed[n]) )
+            continue;
+
+        set_bit(n, ctx->vm_destroy_bitmap);
+    }
+}
+
 static int ffa_domain_init(struct domain *d)
 {
     struct ffa_ctx *ctx;
@@ -1501,11 +1582,14 @@ static int ffa_domain_init(struct domain *d)
     if ( d->domain_id >= UINT16_MAX)
         return -ERANGE;
 
-    ctx = xzalloc(struct ffa_ctx);
+    ctx = xzalloc_flex_struct(struct ffa_ctx, vm_destroy_bitmap,
+                              BITS_TO_LONGS(subscr_vm_destroyed_count));
     if ( !ctx )
         return -ENOMEM;
 
     d->arch.tee = ctx;
+    ctx->teardown_d = d;
+    INIT_LIST_HEAD(&ctx->shm_list);
 
     for ( n = 0; n < subscr_vm_created_count; n++ )
     {
@@ -1515,65 +1599,173 @@ static int ffa_domain_init(struct domain *d)
         {
             printk(XENLOG_ERR "ffa: Failed to report creation of vm_id %u to  %u: res %d\n",
                    get_vm_id(d), subscr_vm_created[n], res);
-            ctx->create_signal_count = n;
-            return -EIO;
+            break;
         }
     }
-    ctx->create_signal_count = subscr_vm_created_count;
-
-    INIT_LIST_HEAD(&ctx->shm_list);
+    vm_destroy_bitmap_init(ctx, n);
+    if ( n != subscr_vm_created_count )
+        return -EIO;
 
     return 0;
 }
 
-static bool is_in_subscr_list(const uint16_t *subscr, uint16_t start,
-                              uint16_t end, uint16_t sp_id)
+static void send_vm_destroyed(struct domain *d)
 {
+    struct ffa_ctx *ctx = d->arch.tee;
     unsigned int n;
+    int32_t res;
 
-    for ( n = start; n < end; n++ )
+    for ( n = 0; n < subscr_vm_destroyed_count; n++ )
     {
-        if ( subscr[n] == sp_id )
-            return true;
-    }
+        if ( !test_bit(n, ctx->vm_destroy_bitmap) )
+            continue;
 
-    return false;
+        res = ffa_direct_req_send_vm(subscr_vm_destroyed[n], get_vm_id(d),
+                                     FFA_MSG_SEND_VM_DESTROYED);
+
+        if ( res )
+        {
+            printk(XENLOG_ERR "%pd: ffa: Failed to report destruction of vm_id %u to %u: res %d\n",
+                   d, get_vm_id(d), subscr_vm_destroyed[n], res);
+        }
+
+        /*
+         * For these two error codes the hypervisor is expected to resend
+         * the destruction message. For the rest it is expected that the
+         * error is permanent and that is doesn't help to resend the
+         * destruction message.
+         */
+        if ( res != FFA_RET_INTERRUPTED && res != FFA_RET_RETRY )
+            clear_bit(n, ctx->vm_destroy_bitmap);
+    }
 }
 
-/* This function is supposed to undo what ffa_domain_init() has done */
-static int ffa_domain_teardown(struct domain *d)
+static void reclaim_shms(struct domain *d)
 {
     struct ffa_ctx *ctx = d->arch.tee;
-    unsigned int n;
+    struct ffa_shm_mem *shm, *tmp;
     int32_t res;
 
-    if ( !ctx )
-        return 0;
+    list_for_each_entry_safe(shm, tmp, &ctx->shm_list, list)
+    {
+        register_t handle_hi;
+        register_t handle_lo;
+
+        uint64_to_regpair(&handle_hi, &handle_lo, shm->handle);
+        res = ffa_mem_reclaim(handle_lo, handle_hi, 0);
+        switch ( res ) {
+        case FFA_RET_OK:
+            printk(XENLOG_G_DEBUG "%pd: ffa: Reclaimed handle %#lx\n",
+                   d, shm->handle);
+            list_del(&shm->list);
+            free_ffa_shm_mem(d, shm);
+            break;
+        case FFA_RET_DENIED:
+            /*
+             * A temporary error that may get resolved a bit later, it's
+             * worth retrying.
+             */
+            printk(XENLOG_G_INFO "%pd: ffa: Failed to reclaim handle %#lx : %d\n",
+                   d, shm->handle, res);
+            break; /* We will retry later */
+        default:
+            /*
+             * The rest of the error codes are not expected and are assumed
+             * to be of a permanent nature. It not in our control to handle
+             * the error properly so the object in this case is to try to
+             * minimize the damage.
+             *
+             * FFA_RET_NO_MEMORY might be a temporary error as it it could
+             * succeed if retried later, but treat it as permanent for now.
+             */
+            printk(XENLOG_G_INFO "%pd: ffa: Permanent failure to reclaim handle %#lx : %d\n",
+                   d, shm->handle, res);
 
-    for ( n = 0; n < subscr_vm_destroyed_count; n++ )
+            /*
+             * Remove the shm from the list and free it, but don't drop
+             * references. This results in having the shared physical pages
+             * permanently allocate and also keeps the domain as a zombie
+             * domain.
+             */
+            list_del(&shm->list);
+            xfree(shm);
+            break;
+        }
+    }
+}
+
+static void ffa_domain_teardown_continue(struct ffa_ctx *ctx, bool first_time)
+{
+    struct ffa_ctx *next_ctx = NULL;
+
+    send_vm_destroyed(ctx->teardown_d);
+    reclaim_shms(ctx->teardown_d);
+
+    if ( ctx->shm_count ||
+         !bitmap_empty(ctx->vm_destroy_bitmap, subscr_vm_destroyed_count) )
+    {
+        printk(XENLOG_G_INFO "%pd: ffa: Remaining cleanup, retrying\n", ctx->teardown_d);
+
+        ctx->teardown_expire = NOW() + FFA_CTX_TEARDOWN_DELAY;
+
+        spin_lock(&ffa_teardown_lock);
+        list_add_tail(&ctx->teardown_list, &ffa_teardown_head);
+        /* Need to set a new timer for the next ctx in line */
+        next_ctx = list_first_entry(&ffa_teardown_head, struct ffa_ctx,
+                                    teardown_list);
+        spin_unlock(&ffa_teardown_lock);
+    }
+    else
     {
         /*
-         * Skip SPs subscribed to the VM created event that never was
-         * notified of the VM creation due to an error during
-         * ffa_domain_init().
+         * domain_destroy() might have been called (via put_domain() in
+         * reclaim_shms()), so we can't touch the domain structure anymore.
          */
-        if ( is_in_subscr_list(subscr_vm_created, ctx->create_signal_count,
-                               subscr_vm_created_count,
-                               subscr_vm_destroyed[n]) )
-            continue;
-
-        res = ffa_direct_req_send_vm(subscr_vm_destroyed[n], get_vm_id(d),
-                                     FFA_MSG_SEND_VM_DESTROYED);
+        xfree(ctx);
 
-        if ( res )
-            printk(XENLOG_ERR "ffa: Failed to report destruction of vm_id %u to  %u: res %d\n",
-                   get_vm_id(d), subscr_vm_destroyed[n], res);
+        /* Only check if there has been a change to the teardown queue */
+        if ( !first_time )
+        {
+            spin_lock(&ffa_teardown_lock);
+            next_ctx = list_first_entry_or_null(&ffa_teardown_head,
+                                                struct ffa_ctx, teardown_list);
+            spin_unlock(&ffa_teardown_lock);
+        }
     }
 
+    if ( next_ctx )
+        set_timer(&ffa_teardown_timer, next_ctx->teardown_expire);
+}
+
+static void ffa_teardown_timer_callback(void *arg)
+{
+    struct ffa_ctx *ctx;
+
+    spin_lock(&ffa_teardown_lock);
+    ctx = list_first_entry_or_null(&ffa_teardown_head, struct ffa_ctx,
+                                   teardown_list);
+    if ( ctx )
+        list_del(&ctx->teardown_list);
+    spin_unlock(&ffa_teardown_lock);
+
+    if ( ctx )
+        ffa_domain_teardown_continue(ctx, false /* !first_time */);
+    else
+        printk(XENLOG_G_ERR "%s: teardown list is empty\n", __func__);
+}
+
+/* This function is supposed to undo what ffa_domain_init() has done */
+static int ffa_domain_teardown(struct domain *d)
+{
+    struct ffa_ctx *ctx = d->arch.tee;
+
+    if ( !ctx )
+        return 0;
+
     if ( ctx->rx )
         rxtx_unmap(ctx);
 
-    XFREE(d->arch.tee);
+    ffa_domain_teardown_continue(ctx, true /* first_time */);
 
     return 0;
 }
@@ -1739,6 +1931,9 @@ static bool ffa_probe(void)
     if ( !init_sps() )
         goto err_free_ffa_tx;
 
+    INIT_LIST_HEAD(&ffa_teardown_head);
+    init_timer(&ffa_teardown_timer, ffa_teardown_timer_callback, NULL, 0);
+
     return true;
 
 err_free_ffa_tx:
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:22:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:22:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687087.1069920 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgMX-0003Eo-Qm; Thu, 29 Feb 2024 13:22:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687087.1069920; Thu, 29 Feb 2024 13:22:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgMX-0003Ee-Nz; Thu, 29 Feb 2024 13:22:13 +0000
Received: by outflank-mailman (input) for mailman id 687087;
 Thu, 29 Feb 2024 13:22:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgMW-0003EW-Dz
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgMW-0004ps-DF
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgMW-0004Bm-Bu
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=GFjb7639fvflgO3tIfxTNQtL0kjTdnF7ABBBnqa//eY=; b=whHw6e7THuhTEHdLF0AVaHpF7b
	yqmSg5GYVuBl3W1Wivd69JAIAsex69JX2RjmRWWPaAWWszz1QWoaN9TImflcUkPqRbFzm5AZzFx/m
	o2wdNfF4sqdGUsFhrQvqOrbrslVCFG2LcQ7NnHHXVXpEgrP+BWuoMLSblVym664/qkKI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86: document how stub exception recovery works
Message-Id: <E1rfgMW-0004Bm-Bu@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:22:12 +0000

commit 28154a245c2b8191854b7cafac6a69ffad4afcf3
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Feb 27 13:48:48 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:48:48 2024 +0100

    x86: document how stub exception recovery works
    
    Describe how it is meant to work, even if one aspect of it will only be
    taken care of subsequently.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/extable.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index 1555b9408f..474a1893f8 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -94,6 +94,22 @@ search_exception_table(const struct cpu_user_regs *regs)
     if ( region && region->ex )
         return search_one_extable(region->ex, region->ex_end, regs->rip);
 
+    /*
+     * Emulation stubs (which are per-CPU) are constructed with a RET at the
+     * end, and are CALLed by the invoking code.
+     *
+     * An exception in the stubs may occur anywhere, so we first match any
+     * %rip in the correct stub, with a sanity check on %rsp too.  But, an
+     * entry in ex_table[] needs to be compile-time constant, so we register
+     * the fixup address using the invoking CALL's return address.
+     *
+     * To recover, we:
+     * 1) Emulate a pseudo-RET to get out of the stub.  We POP the return
+     *    address off the stack(s), use it to look up the fixup address, and
+     *    JMP there, then
+     * 2) Emulate a PUSH of 'token' onto the data stack to pass information
+     *    about the exception back to the invoking code.
+     */
     if ( regs->rip >= stub + STUB_BUF_SIZE / 2 &&
          regs->rip < stub + STUB_BUF_SIZE &&
          regs->rsp > (unsigned long)regs &&
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:22:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:22:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687088.1069924 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgMh-0003Kr-S2; Thu, 29 Feb 2024 13:22:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687088.1069924; Thu, 29 Feb 2024 13:22:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgMh-0003Kk-PO; Thu, 29 Feb 2024 13:22:23 +0000
Received: by outflank-mailman (input) for mailman id 687088;
 Thu, 29 Feb 2024 13:22:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgMg-0003KY-JF
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgMg-0004q5-IO
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgMg-0004DR-FX
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=nFKrfXfIGiXZ0q0CYBP1F9nBYI/nzBhU/gpp+wlratE=; b=t/0IMRKc7PzVaAyayC4xgwJITl
	RN30lHWEKyCcb1AJuJSGKL05lJ8ZAKrMPF3AlU0sK+oqej1YWbxuPE3InfU7TEGsDU2qtbw1Ix13T
	NP0kfsqDk0PfhH5WMtqsOofeibtNaU9PCkSgWziAeSb8F7SUKHGN3vaXoykDEsDsBGgk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86: account for shadow stack in exception-from-stub recovery
Message-Id: <E1rfgMg-0004DR-FX@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:22:22 +0000

commit 91f5f7a9154919a765c3933521760acffeddbf28
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 13:49:22 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:49:22 2024 +0100

    x86: account for shadow stack in exception-from-stub recovery
    
    Dealing with exceptions raised from within emulation stubs involves
    discarding return address (replaced by exception related information).
    Such discarding of course also requires removing the corresponding entry
    from the shadow stack.
    
    Also amend the comment in fixup_exception_return(), to further clarify
    why use of ptr[1] can't be an out-of-bounds access.
    
    While touching do_invalid_op() also add a missing fall-through
    annotation.
    
    This is CVE-2023-46841 / XSA-451.
    
    Fixes: 209fb9919b50 ("x86/extable: Adjust extable handling to be shadow stack compatible")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/extable.c             | 20 +++++++-----
 xen/arch/x86/include/asm/uaccess.h |  3 +-
 xen/arch/x86/traps.c               | 62 +++++++++++++++++++++++++++++++++++---
 3 files changed, 71 insertions(+), 14 deletions(-)

diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index 474a1893f8..fe6c5dbfc7 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -86,13 +86,16 @@ search_one_extable(const struct exception_table_entry *first,
 }
 
 unsigned long
-search_exception_table(const struct cpu_user_regs *regs)
+search_exception_table(const struct cpu_user_regs *regs, unsigned long *stub_ra)
 {
     const struct virtual_region *region = find_text_region(regs->rip);
     unsigned long stub = this_cpu(stubs.addr);
 
     if ( region && region->ex )
+    {
+        *stub_ra = 0;
         return search_one_extable(region->ex, region->ex_end, regs->rip);
+    }
 
     /*
      * Emulation stubs (which are per-CPU) are constructed with a RET at the
@@ -115,13 +118,13 @@ search_exception_table(const struct cpu_user_regs *regs)
          regs->rsp > (unsigned long)regs &&
          regs->rsp < (unsigned long)get_cpu_info() )
     {
-        unsigned long retptr = *(unsigned long *)regs->rsp;
+        unsigned long retaddr = *(unsigned long *)regs->rsp, fixup;
 
-        region = find_text_region(retptr);
-        retptr = region && region->ex
-                 ? search_one_extable(region->ex, region->ex_end, retptr)
-                 : 0;
-        if ( retptr )
+        region = find_text_region(retaddr);
+        fixup = region && region->ex
+                ? search_one_extable(region->ex, region->ex_end, retaddr)
+                : 0;
+        if ( fixup )
         {
             /*
              * Put trap number and error code on the stack (in place of the
@@ -133,7 +136,8 @@ search_exception_table(const struct cpu_user_regs *regs)
             };
 
             *(unsigned long *)regs->rsp = token.raw;
-            return retptr;
+            *stub_ra = retaddr;
+            return fixup;
         }
     }
 
diff --git a/xen/arch/x86/include/asm/uaccess.h b/xen/arch/x86/include/asm/uaccess.h
index 55bc6932fd..48b684c19d 100644
--- a/xen/arch/x86/include/asm/uaccess.h
+++ b/xen/arch/x86/include/asm/uaccess.h
@@ -421,7 +421,8 @@ union stub_exception_token {
     unsigned long raw;
 };
 
-extern unsigned long search_exception_table(const struct cpu_user_regs *regs);
+extern unsigned long search_exception_table(const struct cpu_user_regs *regs,
+                                            unsigned long *stub_ra);
 extern void sort_exception_tables(void);
 extern void sort_exception_table(struct exception_table_entry *start,
                                  const struct exception_table_entry *stop);
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index ff37d97133..d554c9d41e 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -833,7 +833,7 @@ void asmlinkage do_unhandled_trap(struct cpu_user_regs *regs)
 }
 
 static void fixup_exception_return(struct cpu_user_regs *regs,
-                                   unsigned long fixup)
+                                   unsigned long fixup, unsigned long stub_ra)
 {
     if ( IS_ENABLED(CONFIG_XEN_SHSTK) )
     {
@@ -850,7 +850,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
             /*
              * Search for %rip.  The shstk currently looks like this:
              *
-             *   ...  [Likely pointed to by SSP]
+             *   tok  [Supervisor token, == &tok | BUSY, only with FRED inactive]
+             *   ...  [Pointed to by SSP for most exceptions, empty in IST cases]
              *   %cs  [== regs->cs]
              *   %rip [== regs->rip]
              *   SSP  [Likely points to 3 slots higher, above %cs]
@@ -868,7 +869,56 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
              */
             if ( ptr[0] == regs->rip && ptr[1] == regs->cs )
             {
+                unsigned long primary_shstk =
+                    (ssp & ~(STACK_SIZE - 1)) +
+                    (PRIMARY_SHSTK_SLOT + 1) * PAGE_SIZE - 8;
+
                 wrss(fixup, ptr);
+
+                if ( !stub_ra )
+                    goto shstk_done;
+
+                /*
+                 * Stub recovery ought to happen only when the outer context
+                 * was on the main shadow stack.  We need to also "pop" the
+                 * stub's return address from the interrupted context's shadow
+                 * stack.  That is,
+                 * - if we're still on the main stack, we need to move the
+                 *   entire stack (up to and including the exception frame)
+                 *   up by one slot, incrementing the original SSP in the
+                 *   exception frame,
+                 * - if we're on an IST stack, we need to increment the
+                 *   original SSP.
+                 */
+                BUG_ON((ptr[-1] ^ primary_shstk) >> PAGE_SHIFT);
+
+                if ( (ssp ^ primary_shstk) >> PAGE_SHIFT )
+                {
+                    /*
+                     * We're on an IST stack.  First make sure the two return
+                     * addresses actually match.  Then increment the interrupted
+                     * context's SSP.
+                     */
+                    BUG_ON(stub_ra != *(unsigned long*)ptr[-1]);
+                    wrss(ptr[-1] + 8, &ptr[-1]);
+                    goto shstk_done;
+                }
+
+                /* Make sure the two return addresses actually match. */
+                BUG_ON(stub_ra != ptr[2]);
+
+                /* Move exception frame, updating SSP there. */
+                wrss(ptr[1], &ptr[2]); /* %cs */
+                wrss(ptr[0], &ptr[1]); /* %rip */
+                wrss(ptr[-1] + 8, &ptr[0]); /* SSP */
+
+                /* Move all newer entries. */
+                while ( --ptr != _p(ssp) )
+                    wrss(ptr[-1], &ptr[0]);
+
+                /* Finally account for our own stack having shifted up. */
+                asm volatile ( "incsspd %0" :: "r" (2) );
+
                 goto shstk_done;
             }
         }
@@ -889,7 +939,8 @@ static void fixup_exception_return(struct cpu_user_regs *regs,
 
 static bool extable_fixup(struct cpu_user_regs *regs, bool print)
 {
-    unsigned long fixup = search_exception_table(regs);
+    unsigned long stub_ra = 0;
+    unsigned long fixup = search_exception_table(regs, &stub_ra);
 
     if ( unlikely(fixup == 0) )
         return false;
@@ -903,7 +954,7 @@ static bool extable_fixup(struct cpu_user_regs *regs, bool print)
                vector_name(regs->entry_vector), regs->error_code,
                _p(regs->rip), _p(regs->rip), _p(fixup));
 
-    fixup_exception_return(regs, fixup);
+    fixup_exception_return(regs, fixup, stub_ra);
     this_cpu(last_extable_addr) = regs->rip;
 
     return true;
@@ -1166,7 +1217,8 @@ void asmlinkage do_invalid_op(struct cpu_user_regs *regs)
     {
     case BUGFRAME_run_fn:
     case BUGFRAME_warn:
-        fixup_exception_return(regs, (unsigned long)eip);
+        fixup_exception_return(regs, (unsigned long)eip, 0);
+        fallthrough;
     case BUGFRAME_bug:
     case BUGFRAME_assert:
         return;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:22:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:22:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687089.1069928 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgMr-0003Qx-VF; Thu, 29 Feb 2024 13:22:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687089.1069928; Thu, 29 Feb 2024 13:22:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgMr-0003Qp-SI; Thu, 29 Feb 2024 13:22:33 +0000
Received: by outflank-mailman (input) for mailman id 687089;
 Thu, 29 Feb 2024 13:22:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgMq-0003Qc-Mm
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgMq-0004qS-Lm
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgMq-0004Dy-Kc
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=kGvKyMw+9glWC7PuAN5I7ombpKmifWsGy+hpSI/2Nko=; b=Wj6r4sWews1sgE4MEctRoGQRly
	t9B4VvnCYwaq6aCpfSGm6jwzbGpLXvKxjdut96ChRP9y3xVfC8Ugbh7VHPqYIFudWBIyDwwGrNz7G
	VEq+RXIdDHQUC3f9/hVk2LNbTlnr/lzSufy+7sO1mSLtWfZ5xUgUY/FaMU2nF7/bA1pA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86: re-run exception-from-stub recovery selftests with CET-SS enabled
Message-Id: <E1rfgMq-0004Dy-Kc@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:22:32 +0000

commit cfe3ad67127b86e1b1c06993b86422673a51b050
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Feb 27 13:49:52 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 13:49:52 2024 +0100

    x86: re-run exception-from-stub recovery selftests with CET-SS enabled
    
    On the BSP, shadow stacks are enabled only relatively late in the
    booting process. They in particular aren't active yet when initcalls are
    run. Keep the testing there, but invoke that testing a 2nd time when
    shadow stacks are active, to make sure we won't regress that case after
    addressing XSA-451.
    
    While touching this code, switch the guard from NDEBUG to CONFIG_DEBUG,
    such that IS_ENABLED() can validly be used at the new call site.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/extable.c           | 8 +++++---
 xen/arch/x86/include/asm/setup.h | 2 ++
 xen/arch/x86/setup.c             | 4 ++++
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/extable.c b/xen/arch/x86/extable.c
index fe6c5dbfc7..8415cd1fa2 100644
--- a/xen/arch/x86/extable.c
+++ b/xen/arch/x86/extable.c
@@ -144,10 +144,11 @@ search_exception_table(const struct cpu_user_regs *regs, unsigned long *stub_ra)
     return 0;
 }
 
-#ifndef NDEBUG
+#ifdef CONFIG_DEBUG
+#include <asm/setup.h>
 #include <asm/traps.h>
 
-static int __init cf_check stub_selftest(void)
+int __init cf_check stub_selftest(void)
 {
     static const struct {
         uint8_t opc[8];
@@ -171,7 +172,8 @@ static int __init cf_check stub_selftest(void)
     unsigned int i;
     bool fail = false;
 
-    printk("Running stub recovery selftests...\n");
+    printk("%s stub recovery selftests...\n",
+           system_state < SYS_STATE_active ? "Running" : "Re-running");
 
     for ( i = 0; i < ARRAY_SIZE(tests); ++i )
     {
diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h
index 1ced1299c7..1849e60cd6 100644
--- a/xen/arch/x86/include/asm/setup.h
+++ b/xen/arch/x86/include/asm/setup.h
@@ -38,6 +38,8 @@ void *bootstrap_map(const module_t *mod);
 
 int remove_xen_ranges(struct rangeset *r);
 
+int cf_check stub_selftest(void);
+
 extern uint8_t kbd_shift_flags;
 
 #ifdef NDEBUG
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index a0d99f8324..e487591fe0 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -740,6 +740,10 @@ static void noreturn init_done(void)
 
     system_state = SYS_STATE_active;
 
+    /* Re-run stub recovery self-tests with CET-SS active. */
+    if ( IS_ENABLED(CONFIG_DEBUG) && cpu_has_xen_shstk )
+        stub_selftest();
+
     domain_unpause_by_systemcontroller(dom0);
 
     /* MUST be done prior to removing .init data. */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:22:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:22:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687090.1069932 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgN2-0003Vo-0O; Thu, 29 Feb 2024 13:22:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687090.1069932; Thu, 29 Feb 2024 13:22:43 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgN1-0003Vh-To; Thu, 29 Feb 2024 13:22:43 +0000
Received: by outflank-mailman (input) for mailman id 687090;
 Thu, 29 Feb 2024 13:22:42 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgN0-0003VZ-QB
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:42 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgN0-0004qb-PS
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgN0-0004EN-Oa
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:42 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=2dcjZg7fTVEXfyLQLgL8VUoJwbOiTklw+EzazP0EyVI=; b=fB2mgfbWNRo2zdjwZWIoVV/RHi
	KJdzrAY+z+h8xRWH4hO3nvblUozI+DjMZ7wtJJg4HdpQGuInKqivmD1IDjxZrWpmYY/9TkiNhDv+J
	tO2+QGbcwP6GsgravvFFuQUhHTAs+6aRoqP7WQPVeYIHb+XPQlnh9dIAK0XnC1zDjH+8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] vpci: use per-domain PCI lock to protect vpci structure
Message-Id: <E1rfgN0-0004EN-Oa@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:22:42 +0000

commit 4f78438b45e2ee3620e578e30123c777ab864883
Author:     Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
AuthorDate: Tue Feb 27 14:53:15 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:53:15 2024 +0100

    vpci: use per-domain PCI lock to protect vpci structure
    
    Use the per-domain PCI read/write lock to protect the presence of the
    pci device vpci field. This lock can be used (and in a few cases is used
    right away) so that vpci removal can be performed while holding the lock
    in write mode. Previously such removal could race with vpci_read for
    example.
    
    When taking both d->pci_lock and pdev->vpci->lock, they should be
    taken in this exact order: d->pci_lock then pdev->vpci->lock to avoid
    possible deadlock situations.
    
    1. Per-domain's pci_lock is used to protect pdev->vpci structure
    from being removed.
    
    2. Writing the command register and ROM BAR register may trigger
    modify_bars to run, which in turn may access multiple pdevs while
    checking for the existing BAR's overlap. The overlapping check, if
    done under the read lock, requires vpci->lock to be acquired on both
    devices being compared, which may produce a deadlock. It is not
    possible to upgrade read lock to write lock in such a case. So, in
    order to prevent the deadlock, use d->pci_lock in write mode instead.
    
    All other code, which doesn't lead to pdev->vpci destruction and does
    not access multiple pdevs at the same time, can still use a
    combination of the read lock and pdev->vpci->lock.
    
    3. Drop const qualifier where the new rwlock is used and this is
    appropriate.
    
    4. Do not call process_pending_softirqs with any locks held. For that
    unlock prior the call and re-acquire the locks after. After
    re-acquiring the lock there is no need to check if pdev->vpci exists:
     - in apply_map because of the context it is called (no race condition
       possible)
     - for MSI/MSI-X debug code because it is called at the end of
       pdev->vpci access and no further access to pdev->vpci is made
    
    5. Use d->pci_lock around for_each_pdev and pci_get_pdev()
    while accessing pdevs in vpci code.
    
    6. Switch vPCI functions to use per-domain pci_lock for ensuring pdevs
    do not go away. The vPCI functions call several MSI-related functions
    which already have existing non-vPCI callers. Change those MSI-related
    functions to allow using either pcidevs_lock() or d->pci_lock for
    ensuring pdevs do not go away. Holding d->pci_lock in read mode is
    sufficient. Note that this pdev protection mechanism does not protect
    other state or critical sections. These MSI-related functions already
    have other race condition and state protection mechanims (e.g.
    d->event_lock and msixtbl RCU), so we deduce that the use of the global
    pcidevs_lock() is to ensure that pdevs do not go away.
    
    7. Introduce wrapper construct, pdev_list_is_read_locked(), for checking
    that pdevs do not go away. The purpose of this wrapper is to aid
    readability and document the intent of the pdev protection mechanism.
    
    8. When possible, the existing non-vPCI callers of these MSI-related
    functions haven't been switched to use the newly introduced per-domain
    pci_lock, and will continue to use the global pcidevs_lock(). This is
    done to reduce the risk of the new locking scheme introducing
    regressions. Those users will be adjusted in due time. One exception
    is where the pcidevs_lock() in allocate_and_map_msi_pirq() is moved to
    the caller, physdev_map_pirq(): this instance is switched to
    read_lock(&d->pci_lock) right away.
    
    Suggested-by: Roger Pau Monné <roger.pau@citrix.com>
    Suggested-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/hvm/vmsi.c       | 37 +++++++++++++++++++++---------
 xen/arch/x86/hvm/vmx/vmx.c    |  2 +-
 xen/arch/x86/irq.c            |  8 +++----
 xen/arch/x86/msi.c            | 20 +++++++++++------
 xen/arch/x86/physdev.c        |  2 ++
 xen/drivers/passthrough/pci.c |  9 ++++----
 xen/drivers/vpci/header.c     | 18 +++++++++++++++
 xen/drivers/vpci/msi.c        | 27 ++++++++++++++++++----
 xen/drivers/vpci/msix.c       | 52 +++++++++++++++++++++++++++++++++++++------
 xen/drivers/vpci/vpci.c       | 24 ++++++++++++++++++--
 xen/include/xen/pci.h         | 13 +++++++++++
 xen/include/xen/sched.h       |  3 ++-
 12 files changed, 174 insertions(+), 41 deletions(-)

diff --git a/xen/arch/x86/hvm/vmsi.c b/xen/arch/x86/hvm/vmsi.c
index 128f236362..adbac965f9 100644
--- a/xen/arch/x86/hvm/vmsi.c
+++ b/xen/arch/x86/hvm/vmsi.c
@@ -468,7 +468,7 @@ int msixtbl_pt_register(struct domain *d, struct pirq *pirq, uint64_t gtable)
     struct msixtbl_entry *entry, *new_entry;
     int r = -EINVAL;
 
-    ASSERT(pcidevs_locked());
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
     ASSERT(rw_is_write_locked(&d->event_lock));
 
     if ( !msixtbl_initialised(d) )
@@ -538,7 +538,7 @@ void msixtbl_pt_unregister(struct domain *d, struct pirq *pirq)
     struct pci_dev *pdev;
     struct msixtbl_entry *entry;
 
-    ASSERT(pcidevs_locked());
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
     ASSERT(rw_is_write_locked(&d->event_lock));
 
     if ( !msixtbl_initialised(d) )
@@ -684,7 +684,7 @@ static int vpci_msi_update(const struct pci_dev *pdev, uint32_t data,
 {
     unsigned int i;
 
-    ASSERT(pcidevs_locked());
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
 
     if ( (address & MSI_ADDR_BASE_MASK) != MSI_ADDR_HEADER )
     {
@@ -725,8 +725,8 @@ void vpci_msi_arch_update(struct vpci_msi *msi, const struct pci_dev *pdev)
     int rc;
 
     ASSERT(msi->arch.pirq != INVALID_PIRQ);
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
 
-    pcidevs_lock();
     for ( i = 0; i < msi->vectors && msi->arch.bound; i++ )
     {
         struct xen_domctl_bind_pt_irq unbind = {
@@ -745,7 +745,6 @@ void vpci_msi_arch_update(struct vpci_msi *msi, const struct pci_dev *pdev)
 
     msi->arch.bound = !vpci_msi_update(pdev, msi->data, msi->address,
                                        msi->vectors, msi->arch.pirq, msi->mask);
-    pcidevs_unlock();
 }
 
 static int vpci_msi_enable(const struct pci_dev *pdev, unsigned int nr,
@@ -778,15 +777,14 @@ int vpci_msi_arch_enable(struct vpci_msi *msi, const struct pci_dev *pdev,
     int rc;
 
     ASSERT(msi->arch.pirq == INVALID_PIRQ);
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
     rc = vpci_msi_enable(pdev, vectors, 0);
     if ( rc < 0 )
         return rc;
     msi->arch.pirq = rc;
 
-    pcidevs_lock();
     msi->arch.bound = !vpci_msi_update(pdev, msi->data, msi->address, vectors,
                                        msi->arch.pirq, msi->mask);
-    pcidevs_unlock();
 
     return 0;
 }
@@ -797,8 +795,8 @@ static void vpci_msi_disable(const struct pci_dev *pdev, int pirq,
     unsigned int i;
 
     ASSERT(pirq != INVALID_PIRQ);
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
 
-    pcidevs_lock();
     for ( i = 0; i < nr && bound; i++ )
     {
         struct xen_domctl_bind_pt_irq bind = {
@@ -814,7 +812,6 @@ static void vpci_msi_disable(const struct pci_dev *pdev, int pirq,
     write_lock(&pdev->domain->event_lock);
     unmap_domain_pirq(pdev->domain, pirq);
     write_unlock(&pdev->domain->event_lock);
-    pcidevs_unlock();
 }
 
 void vpci_msi_arch_disable(struct vpci_msi *msi, const struct pci_dev *pdev)
@@ -854,6 +851,7 @@ int vpci_msix_arch_enable_entry(struct vpci_msix_entry *entry,
     int rc;
 
     ASSERT(entry->arch.pirq == INVALID_PIRQ);
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
     rc = vpci_msi_enable(pdev, vmsix_entry_nr(pdev->vpci->msix, entry),
                          table_base);
     if ( rc < 0 )
@@ -861,7 +859,6 @@ int vpci_msix_arch_enable_entry(struct vpci_msix_entry *entry,
 
     entry->arch.pirq = rc;
 
-    pcidevs_lock();
     rc = vpci_msi_update(pdev, entry->data, entry->addr, 1, entry->arch.pirq,
                          entry->masked);
     if ( rc )
@@ -869,7 +866,6 @@ int vpci_msix_arch_enable_entry(struct vpci_msix_entry *entry,
         vpci_msi_disable(pdev, entry->arch.pirq, 1, false);
         entry->arch.pirq = INVALID_PIRQ;
     }
-    pcidevs_unlock();
 
     return rc;
 }
@@ -895,6 +891,15 @@ int vpci_msix_arch_print(const struct vpci_msix *msix)
 {
     unsigned int i;
 
+    /*
+     * Assert that pdev_list doesn't change. ASSERT_PDEV_LIST_IS_READ_LOCKED
+     * is not suitable here because it allows either pcidevs_lock() or
+     * pci_lock to be held, but here we rely on pci_lock being held, not
+     * pcidevs_lock() (see the transient lock dropping further down).
+     */
+    ASSERT(rw_is_locked(&msix->pdev->domain->pci_lock));
+    ASSERT(spin_is_locked(&msix->pdev->vpci->lock));
+
     for ( i = 0; i < msix->max_entries; i++ )
     {
         const struct vpci_msix_entry *entry = &msix->entries[i];
@@ -913,13 +918,23 @@ int vpci_msix_arch_print(const struct vpci_msix *msix)
             struct pci_dev *pdev = msix->pdev;
 
             spin_unlock(&msix->pdev->vpci->lock);
+            read_unlock(&pdev->domain->pci_lock);
             process_pending_softirqs();
+
+            if ( !read_trylock(&pdev->domain->pci_lock) )
+                return -EBUSY;
+
             /* NB: we assume that pdev cannot go away for an alive domain. */
             if ( !pdev->vpci || !spin_trylock(&pdev->vpci->lock) )
+            {
+                read_unlock(&pdev->domain->pci_lock);
                 return -EBUSY;
+            }
+
             if ( pdev->vpci->msix != msix )
             {
                 spin_unlock(&pdev->vpci->lock);
+                read_unlock(&pdev->domain->pci_lock);
                 return -EAGAIN;
             }
         }
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 8b27d83c12..23bdf0d195 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -413,7 +413,7 @@ static int cf_check vmx_pi_update_irte(const struct vcpu *v,
 
     spin_unlock_irq(&desc->lock);
 
-    ASSERT(pcidevs_locked());
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(msi_desc->dev->domain);
 
     return iommu_update_ire_from_msi(msi_desc, &msi_desc->msg);
 
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index 7458b89ab3..0487f734a5 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -2162,7 +2162,7 @@ int map_domain_pirq(
         struct pci_dev *pdev;
         unsigned int nr = 0;
 
-        ASSERT(pcidevs_locked());
+        ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
 
         ret = -ENODEV;
         if ( !cpu_has_apic )
@@ -2319,7 +2319,7 @@ int unmap_domain_pirq(struct domain *d, int pirq)
     if ( (pirq < 0) || (pirq >= d->nr_pirqs) )
         return -EINVAL;
 
-    ASSERT(pcidevs_locked());
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
     ASSERT(rw_is_write_locked(&d->event_lock));
 
     info = pirq_info(d, pirq);
@@ -2884,6 +2884,8 @@ int allocate_and_map_msi_pirq(struct domain *d, int index, int *pirq_p,
 {
     int irq, pirq, ret;
 
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
+
     switch ( type )
     {
     case MAP_PIRQ_TYPE_MSI:
@@ -2913,7 +2915,6 @@ int allocate_and_map_msi_pirq(struct domain *d, int index, int *pirq_p,
 
     msi->irq = irq;
 
-    pcidevs_lock();
     /* Verify or get pirq. */
     write_lock(&d->event_lock);
     pirq = allocate_pirq(d, index, *pirq_p, irq, type, &msi->entry_nr);
@@ -2929,7 +2930,6 @@ int allocate_and_map_msi_pirq(struct domain *d, int index, int *pirq_p,
 
  done:
     write_unlock(&d->event_lock);
-    pcidevs_unlock();
     if ( ret )
     {
         switch ( type )
diff --git a/xen/arch/x86/msi.c b/xen/arch/x86/msi.c
index 335c0868a2..e721aaf5c0 100644
--- a/xen/arch/x86/msi.c
+++ b/xen/arch/x86/msi.c
@@ -602,7 +602,7 @@ static int msi_capability_init(struct pci_dev *dev,
     unsigned int i, mpos;
     uint16_t control;
 
-    ASSERT(pcidevs_locked());
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(dev->domain);
     pos = pci_find_cap_offset(dev->sbdf, PCI_CAP_ID_MSI);
     if ( !pos )
         return -ENODEV;
@@ -771,7 +771,7 @@ static int msix_capability_init(struct pci_dev *dev,
     if ( !pos )
         return -ENODEV;
 
-    ASSERT(pcidevs_locked());
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(dev->domain);
 
     control = pci_conf_read16(dev->sbdf, msix_control_reg(pos));
     /*
@@ -988,11 +988,11 @@ static int __pci_enable_msi(struct pci_dev *pdev, struct msi_info *msi,
 {
     struct msi_desc *old_desc;
 
-    ASSERT(pcidevs_locked());
-
     if ( !pdev )
         return -ENODEV;
 
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
+
     old_desc = find_msi_entry(pdev, msi->irq, PCI_CAP_ID_MSI);
     if ( old_desc )
     {
@@ -1043,9 +1043,12 @@ static int __pci_enable_msix(struct pci_dev *pdev, struct msi_info *msi,
 {
     struct msi_desc *old_desc;
 
-    ASSERT(pcidevs_locked());
+    if ( !pdev )
+        return -ENODEV;
+
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
 
-    if ( !pdev || !pdev->msix )
+    if ( !pdev->msix )
         return -ENODEV;
 
     if ( msi->entry_nr >= pdev->msix->nr_entries )
@@ -1154,7 +1157,10 @@ int pci_prepare_msix(u16 seg, u8 bus, u8 devfn, bool off)
 int pci_enable_msi(struct pci_dev *pdev, struct msi_info *msi,
                    struct msi_desc **desc)
 {
-    ASSERT(pcidevs_locked());
+    if ( !pdev )
+        return -ENODEV;
+
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(pdev->domain);
 
     if ( !use_msi )
         return -EPERM;
diff --git a/xen/arch/x86/physdev.c b/xen/arch/x86/physdev.c
index 47c4da0af7..7efa17cf4c 100644
--- a/xen/arch/x86/physdev.c
+++ b/xen/arch/x86/physdev.c
@@ -123,7 +123,9 @@ int physdev_map_pirq(domid_t domid, int type, int *index, int *pirq_p,
 
     case MAP_PIRQ_TYPE_MSI:
     case MAP_PIRQ_TYPE_MULTI_MSI:
+        read_lock(&d->pci_lock);
         ret = allocate_and_map_msi_pirq(d, *index, pirq_p, type, msi);
+        read_unlock(&d->pci_lock);
         break;
 
     default:
diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 47c0eee7bd..c97dd4504a 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -750,7 +750,6 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
         pdev->domain = hardware_domain;
         write_lock(&hardware_domain->pci_lock);
         list_add(&pdev->domain_list, &hardware_domain->pdev_list);
-        write_unlock(&hardware_domain->pci_lock);
 
         /*
          * For devices not discovered by Xen during boot, add vPCI handlers
@@ -759,18 +758,18 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
         ret = vpci_add_handlers(pdev);
         if ( ret )
         {
-            printk(XENLOG_ERR "Setup of vPCI failed: %d\n", ret);
-            write_lock(&hardware_domain->pci_lock);
             list_del(&pdev->domain_list);
             write_unlock(&hardware_domain->pci_lock);
             pdev->domain = NULL;
+            printk(XENLOG_ERR "Setup of vPCI failed: %d\n", ret);
             goto out;
         }
+        write_unlock(&hardware_domain->pci_lock);
         ret = iommu_add_device(pdev);
         if ( ret )
         {
-            vpci_remove_device(pdev);
             write_lock(&hardware_domain->pci_lock);
+            vpci_remove_device(pdev);
             list_del(&pdev->domain_list);
             write_unlock(&hardware_domain->pci_lock);
             pdev->domain = NULL;
@@ -1146,7 +1145,9 @@ static void __hwdom_init setup_one_hwdom_device(const struct setup_hwdom *ctxt,
     } while ( devfn != pdev->devfn &&
               PCI_SLOT(devfn) == PCI_SLOT(pdev->devfn) );
 
+    write_lock(&ctxt->d->pci_lock);
     err = vpci_add_handlers(pdev);
+    write_unlock(&ctxt->d->pci_lock);
     if ( err )
         printk(XENLOG_ERR "setup of vPCI for d%d failed: %d\n",
                ctxt->d->domain_id, err);
diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 58195549d5..8f5850b8cf 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -173,6 +173,7 @@ bool vpci_process_pending(struct vcpu *v)
         if ( rc == -ERESTART )
             return true;
 
+        write_lock(&v->domain->pci_lock);
         spin_lock(&v->vpci.pdev->vpci->lock);
         /* Disable memory decoding unconditionally on failure. */
         modify_decoding(v->vpci.pdev,
@@ -191,6 +192,7 @@ bool vpci_process_pending(struct vcpu *v)
              * failure.
              */
             vpci_remove_device(v->vpci.pdev);
+        write_unlock(&v->domain->pci_lock);
     }
 
     return false;
@@ -202,8 +204,20 @@ static int __init apply_map(struct domain *d, const struct pci_dev *pdev,
     struct map_data data = { .d = d, .map = true };
     int rc;
 
+    ASSERT(rw_is_write_locked(&d->pci_lock));
+
     while ( (rc = rangeset_consume_ranges(mem, map_range, &data)) == -ERESTART )
+    {
+        /*
+         * It's safe to drop and reacquire the lock in this context
+         * without risking pdev disappearing because devices cannot be
+         * removed until the initial domain has been started.
+         */
+        write_unlock(&d->pci_lock);
         process_pending_softirqs();
+        write_lock(&d->pci_lock);
+    }
+
     rangeset_destroy(mem);
     if ( !rc )
         modify_decoding(pdev, cmd, false);
@@ -244,6 +258,8 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
     unsigned int i;
     int rc;
 
+    ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
+
     if ( !mem )
         return -ENOMEM;
 
@@ -524,6 +540,8 @@ static int cf_check init_header(struct pci_dev *pdev)
     int rc;
     bool mask_cap_list = false;
 
+    ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
+
     switch ( pci_conf_read8(pdev->sbdf, PCI_HEADER_TYPE) & 0x7f )
     {
     case PCI_HEADER_TYPE_NORMAL:
diff --git a/xen/drivers/vpci/msi.c b/xen/drivers/vpci/msi.c
index a253ccbd7d..d3aa5df089 100644
--- a/xen/drivers/vpci/msi.c
+++ b/xen/drivers/vpci/msi.c
@@ -263,7 +263,7 @@ REGISTER_VPCI_INIT(init_msi, VPCI_PRIORITY_LOW);
 
 void vpci_dump_msi(void)
 {
-    const struct domain *d;
+    struct domain *d;
 
     rcu_read_lock(&domlist_read_lock);
     for_each_domain ( d )
@@ -275,6 +275,9 @@ void vpci_dump_msi(void)
 
         printk("vPCI MSI/MSI-X d%d\n", d->domain_id);
 
+        if ( !read_trylock(&d->pci_lock) )
+            continue;
+
         for_each_pdev ( d, pdev )
         {
             const struct vpci_msi *msi;
@@ -313,17 +316,33 @@ void vpci_dump_msi(void)
                 {
                     /*
                      * On error vpci_msix_arch_print will always return without
-                     * holding the lock.
+                     * holding the locks.
                      */
                     printk("unable to print all MSI-X entries: %d\n", rc);
-                    process_pending_softirqs();
-                    continue;
+                    goto pdev_done;
                 }
             }
 
+            /*
+             * Unlock locks to process pending softirqs. This is
+             * potentially unsafe, as d->pdev_list can be changed in
+             * meantime.
+             */
             spin_unlock(&pdev->vpci->lock);
+            read_unlock(&d->pci_lock);
+
+        pdev_done:
             process_pending_softirqs();
+            if ( !read_trylock(&d->pci_lock) )
+            {
+                printk("unable to access other devices for the domain\n");
+                goto domain_done;
+            }
         }
+        read_unlock(&d->pci_lock);
+
+    domain_done:
+        ;
     }
     rcu_read_unlock(&domlist_read_lock);
 }
diff --git a/xen/drivers/vpci/msix.c b/xen/drivers/vpci/msix.c
index d1126a417d..58c16ebdf2 100644
--- a/xen/drivers/vpci/msix.c
+++ b/xen/drivers/vpci/msix.c
@@ -147,6 +147,8 @@ static struct vpci_msix *msix_find(const struct domain *d, unsigned long addr)
 {
     struct vpci_msix *msix;
 
+    ASSERT_PDEV_LIST_IS_READ_LOCKED(d);
+
     list_for_each_entry ( msix, &d->arch.hvm.msix_tables, next )
     {
         const struct vpci_bar *bars = msix->pdev->vpci->header.bars;
@@ -163,7 +165,13 @@ static struct vpci_msix *msix_find(const struct domain *d, unsigned long addr)
 
 static int cf_check msix_accept(struct vcpu *v, unsigned long addr)
 {
-    return !!msix_find(v->domain, addr);
+    int rc;
+
+    read_lock(&v->domain->pci_lock);
+    rc = !!msix_find(v->domain, addr);
+    read_unlock(&v->domain->pci_lock);
+
+    return rc;
 }
 
 static bool access_allowed(const struct pci_dev *pdev, unsigned long addr,
@@ -358,21 +366,35 @@ static int adjacent_read(const struct domain *d, const struct vpci_msix *msix,
 static int cf_check msix_read(
     struct vcpu *v, unsigned long addr, unsigned int len, unsigned long *data)
 {
-    const struct domain *d = v->domain;
-    struct vpci_msix *msix = msix_find(d, addr);
+    struct domain *d = v->domain;
+    struct vpci_msix *msix;
     const struct vpci_msix_entry *entry;
     unsigned int offset;
 
     *data = ~0UL;
 
+    read_lock(&d->pci_lock);
+
+    msix = msix_find(d, addr);
     if ( !msix )
+    {
+        read_unlock(&d->pci_lock);
         return X86EMUL_RETRY;
+    }
 
     if ( adjacent_handle(msix, addr) )
-        return adjacent_read(d, msix, addr, len, data);
+    {
+        int rc = adjacent_read(d, msix, addr, len, data);
+
+        read_unlock(&d->pci_lock);
+        return rc;
+    }
 
     if ( !access_allowed(msix->pdev, addr, len) )
+    {
+        read_unlock(&d->pci_lock);
         return X86EMUL_OKAY;
+    }
 
     spin_lock(&msix->pdev->vpci->lock);
     entry = get_entry(msix, addr);
@@ -404,6 +426,7 @@ static int cf_check msix_read(
         break;
     }
     spin_unlock(&msix->pdev->vpci->lock);
+    read_unlock(&d->pci_lock);
 
     return X86EMUL_OKAY;
 }
@@ -491,19 +514,33 @@ static int adjacent_write(const struct domain *d, const struct vpci_msix *msix,
 static int cf_check msix_write(
     struct vcpu *v, unsigned long addr, unsigned int len, unsigned long data)
 {
-    const struct domain *d = v->domain;
-    struct vpci_msix *msix = msix_find(d, addr);
+    struct domain *d = v->domain;
+    struct vpci_msix *msix;
     struct vpci_msix_entry *entry;
     unsigned int offset;
 
+    read_lock(&d->pci_lock);
+
+    msix = msix_find(d, addr);
     if ( !msix )
+    {
+        read_unlock(&d->pci_lock);
         return X86EMUL_RETRY;
+    }
 
     if ( adjacent_handle(msix, addr) )
-        return adjacent_write(d, msix, addr, len, data);
+    {
+        int rc = adjacent_write(d, msix, addr, len, data);
+
+        read_unlock(&d->pci_lock);
+        return rc;
+    }
 
     if ( !access_allowed(msix->pdev, addr, len) )
+    {
+        read_unlock(&d->pci_lock);
         return X86EMUL_OKAY;
+    }
 
     spin_lock(&msix->pdev->vpci->lock);
     entry = get_entry(msix, addr);
@@ -579,6 +616,7 @@ static int cf_check msix_write(
         break;
     }
     spin_unlock(&msix->pdev->vpci->lock);
+    read_unlock(&d->pci_lock);
 
     return X86EMUL_OKAY;
 }
diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index 72ef277c4f..475272b173 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -42,6 +42,8 @@ extern vpci_register_init_t *const __end_vpci_array[];
 
 void vpci_remove_device(struct pci_dev *pdev)
 {
+    ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
+
     if ( !has_vpci(pdev->domain) || !pdev->vpci )
         return;
 
@@ -77,6 +79,8 @@ int vpci_add_handlers(struct pci_dev *pdev)
     const unsigned long *ro_map;
     int rc = 0;
 
+    ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
+
     if ( !has_vpci(pdev->domain) )
         return 0;
 
@@ -361,7 +365,7 @@ static uint32_t merge_result(uint32_t data, uint32_t new, unsigned int size,
 
 uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg, unsigned int size)
 {
-    const struct domain *d = current->domain;
+    struct domain *d = current->domain;
     const struct pci_dev *pdev;
     const struct vpci_register *r;
     unsigned int data_offset = 0;
@@ -376,12 +380,18 @@ uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg, unsigned int size)
     /*
      * Find the PCI dev matching the address, which for hwdom also requires
      * consulting DomXEN.  Passthrough everything that's not trapped.
+     * If this is hwdom and the device is assigned to DomXEN, acquiring hwdom's
+     * pci_lock is sufficient.
      */
+    read_lock(&d->pci_lock);
     pdev = pci_get_pdev(d, sbdf);
     if ( !pdev && is_hardware_domain(d) )
         pdev = pci_get_pdev(dom_xen, sbdf);
     if ( !pdev || !pdev->vpci )
+    {
+        read_unlock(&d->pci_lock);
         return vpci_read_hw(sbdf, reg, size);
+    }
 
     spin_lock(&pdev->vpci->lock);
 
@@ -428,6 +438,7 @@ uint32_t vpci_read(pci_sbdf_t sbdf, unsigned int reg, unsigned int size)
         ASSERT(data_offset < size);
     }
     spin_unlock(&pdev->vpci->lock);
+    read_unlock(&d->pci_lock);
 
     if ( data_offset < size )
     {
@@ -470,7 +481,7 @@ static void vpci_write_helper(const struct pci_dev *pdev,
 void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
                 uint32_t data)
 {
-    const struct domain *d = current->domain;
+    struct domain *d = current->domain;
     const struct pci_dev *pdev;
     const struct vpci_register *r;
     unsigned int data_offset = 0;
@@ -484,7 +495,13 @@ void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
     /*
      * Find the PCI dev matching the address, which for hwdom also requires
      * consulting DomXEN.  Passthrough everything that's not trapped.
+     * If this is hwdom and the device is assigned to DomXEN, acquiring hwdom's
+     * pci_lock is sufficient.
+     *
+     * TODO: We need to take pci_locks in exclusive mode only if we
+     * are modifying BARs, so there is a room for improvement.
      */
+    write_lock(&d->pci_lock);
     pdev = pci_get_pdev(d, sbdf);
     if ( !pdev && is_hardware_domain(d) )
         pdev = pci_get_pdev(dom_xen, sbdf);
@@ -493,6 +510,8 @@ void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
         /* Ignore writes to read-only devices, which have no ->vpci. */
         const unsigned long *ro_map = pci_get_ro_map(sbdf.seg);
 
+        write_unlock(&d->pci_lock);
+
         if ( !ro_map || !test_bit(sbdf.bdf, ro_map) )
             vpci_write_hw(sbdf, reg, size, data);
         return;
@@ -534,6 +553,7 @@ void vpci_write(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
         ASSERT(data_offset < size);
     }
     spin_unlock(&pdev->vpci->lock);
+    write_unlock(&d->pci_lock);
 
     if ( data_offset < size )
         /* Tailing gap, write the remaining. */
diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h
index aabc5465a7..1df1863b13 100644
--- a/xen/include/xen/pci.h
+++ b/xen/include/xen/pci.h
@@ -171,6 +171,19 @@ void pcidevs_lock(void);
 void pcidevs_unlock(void);
 bool __must_check pcidevs_locked(void);
 
+#ifndef NDEBUG
+/*
+ * Check to ensure there will be no changes to the entries in d->pdev_list (but
+ * not the contents of each entry).
+ * This check is not suitable for protecting other state or critical regions.
+ */
+#define ASSERT_PDEV_LIST_IS_READ_LOCKED(d)                               \
+        /* NB: d may be evaluated multiple times, or not at all */       \
+        ASSERT(pcidevs_locked() || ((d) && rw_is_locked(&(d)->pci_lock)))
+#else
+#define ASSERT_PDEV_LIST_IS_READ_LOCKED(d) ((void)(d))
+#endif
+
 bool pci_known_segment(u16 seg);
 bool pci_device_detect(u16 seg, u8 bus, u8 dev, u8 func);
 int scan_pci_devices(void);
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 9da91e0e62..37f5922f32 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -462,7 +462,8 @@ struct domain
 #ifdef CONFIG_HAS_PCI
     struct list_head pdev_list;
     /*
-     * pci_lock protects access to pdev_list.
+     * pci_lock protects access to pdev_list. pci_lock also protects pdev->vpci
+     * structure from being removed.
      *
      * Any user *reading* from pdev_list, or from devices stored in pdev_list,
      * should hold either pcidevs_lock() or pci_lock in read mode. Optionally,
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:22:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:22:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687091.1069935 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgNC-0003bZ-3S; Thu, 29 Feb 2024 13:22:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687091.1069935; Thu, 29 Feb 2024 13:22:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgNC-0003bR-0p; Thu, 29 Feb 2024 13:22:54 +0000
Received: by outflank-mailman (input) for mailman id 687091;
 Thu, 29 Feb 2024 13:22:52 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNA-0003Zf-UE
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:52 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNA-0004qk-TS
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNA-0004Eq-Rc
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:22:52 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=UiBQtpLGvXcjFjoTQh1IlH3D2R+zEDp3Zvjd1Ze/2w4=; b=nHYqF8TpZmsCrrO04ZwejrZkux
	olv/4GNw4iSB6lV5NlfqY6/PnJCMZYLwQTMzy4akgXKRKq07PA7tKWnOAptRfiiE2/bQcFeSk4VXx
	gN9/xrLBY5qy0SLVAhxlvIe2v52oF4ORO2xCepn3O5Lgj5IXaCHeNnaba8ptsB7sL1+Y=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] vpci: restrict unhandled read/write operations for guests
Message-Id: <E1rfgNA-0004Eq-Rc@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:22:52 +0000

commit 80b0eb095aae5aef62cb529e93cba93f687b0b75
Author:     Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
AuthorDate: Tue Feb 27 14:53:50 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:53:50 2024 +0100

    vpci: restrict unhandled read/write operations for guests
    
    A guest would be able to read and write those registers which are not
    emulated and have no respective vPCI handlers, so it will be possible
    for it to access the hardware directly.
    In order to prevent a guest from reads and writes from/to the unhandled
    registers make sure only hardware domain can access the hardware directly
    and restrict guests from doing so.
    
    Suggested-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
---
 xen/drivers/vpci/vpci.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index 475272b173..d545dc633c 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -268,6 +268,10 @@ static uint32_t vpci_read_hw(pci_sbdf_t sbdf, unsigned int reg,
 {
     uint32_t data;
 
+    /* Guest domains are not allowed to read real hardware. */
+    if ( !is_hardware_domain(current->domain) )
+        return ~(uint32_t)0;
+
     switch ( size )
     {
     case 4:
@@ -311,6 +315,10 @@ static uint32_t vpci_read_hw(pci_sbdf_t sbdf, unsigned int reg,
 static void vpci_write_hw(pci_sbdf_t sbdf, unsigned int reg, unsigned int size,
                           uint32_t data)
 {
+    /* Guest domains are not allowed to write real hardware. */
+    if ( !is_hardware_domain(current->domain) )
+        return;
+
     switch ( size )
     {
     case 4:
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:23:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:23:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687092.1069940 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgNM-0003gG-4v; Thu, 29 Feb 2024 13:23:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687092.1069940; Thu, 29 Feb 2024 13:23:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgNM-0003g8-2H; Thu, 29 Feb 2024 13:23:04 +0000
Received: by outflank-mailman (input) for mailman id 687092;
 Thu, 29 Feb 2024 13:23:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNL-0003fN-11
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNL-0004rQ-0M
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNK-0004FU-Vk
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=PnNXJcbvnI5AZC7WT0eVRzUKMs9e1mdA2yfcYp8+5pI=; b=U2MGd4Tu5SR7Pd3D5LcQA1LCka
	3a7gbMZPdQaciawQrXbc6mG3uWdiK9hRK6K40GxgQ2mTM12b+L83+4pcsNAP8DK4fbKpLSZwP/oGz
	izP9hkti2hNFB08WEEh0+aG9jzWesjdQqIyugnZ30yPv+9DPotHgYQBUYeeKXNjURfbM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] vpci: add hooks for PCI device assign/de-assign
Message-Id: <E1rfgNK-0004FU-Vk@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:23:02 +0000

commit f20dde92594ad3fa7a9968cd7bd3d1f5c7c59008
Author:     Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
AuthorDate: Tue Feb 27 14:54:21 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:54:21 2024 +0100

    vpci: add hooks for PCI device assign/de-assign
    
    When a PCI device gets assigned/de-assigned we need to
    initialize/de-initialize vPCI state for the device.
    
    Also, rename vpci_add_handlers() to vpci_assign_device() and
    vpci_remove_device() to vpci_deassign_device() to better reflect role
    of the functions.
    
    Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/drivers/passthrough/pci.c | 28 ++++++++++++++++++++++++----
 xen/drivers/vpci/header.c     |  2 +-
 xen/drivers/vpci/vpci.c       |  6 +++---
 xen/include/xen/vpci.h        | 10 +++++-----
 4 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index c97dd4504a..4c0a836486 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -755,7 +755,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
          * For devices not discovered by Xen during boot, add vPCI handlers
          * when Dom0 first informs Xen about such devices.
          */
-        ret = vpci_add_handlers(pdev);
+        ret = vpci_assign_device(pdev);
         if ( ret )
         {
             list_del(&pdev->domain_list);
@@ -769,7 +769,7 @@ int pci_add_device(u16 seg, u8 bus, u8 devfn,
         if ( ret )
         {
             write_lock(&hardware_domain->pci_lock);
-            vpci_remove_device(pdev);
+            vpci_deassign_device(pdev);
             list_del(&pdev->domain_list);
             write_unlock(&hardware_domain->pci_lock);
             pdev->domain = NULL;
@@ -817,7 +817,7 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn)
     list_for_each_entry ( pdev, &pseg->alldevs_list, alldevs_list )
         if ( pdev->bus == bus && pdev->devfn == devfn )
         {
-            vpci_remove_device(pdev);
+            vpci_deassign_device(pdev);
             pci_cleanup_msi(pdev);
             ret = iommu_remove_device(pdev);
             if ( pdev->domain )
@@ -875,6 +875,10 @@ static int deassign_device(struct domain *d, uint16_t seg, uint8_t bus,
             goto out;
     }
 
+    write_lock(&d->pci_lock);
+    vpci_deassign_device(pdev);
+    write_unlock(&d->pci_lock);
+
     devfn = pdev->devfn;
     ret = iommu_call(hd->platform_ops, reassign_device, d, target, devfn,
                      pci_to_dev(pdev));
@@ -886,6 +890,11 @@ static int deassign_device(struct domain *d, uint16_t seg, uint8_t bus,
 
     pdev->fault.count = 0;
 
+    write_lock(&target->pci_lock);
+    /* Re-assign back to hardware_domain */
+    ret = vpci_assign_device(pdev);
+    write_unlock(&target->pci_lock);
+
  out:
     if ( ret )
         printk(XENLOG_G_ERR "%pd: deassign (%pp) failed (%d)\n",
@@ -1146,7 +1155,7 @@ static void __hwdom_init setup_one_hwdom_device(const struct setup_hwdom *ctxt,
               PCI_SLOT(devfn) == PCI_SLOT(pdev->devfn) );
 
     write_lock(&ctxt->d->pci_lock);
-    err = vpci_add_handlers(pdev);
+    err = vpci_assign_device(pdev);
     write_unlock(&ctxt->d->pci_lock);
     if ( err )
         printk(XENLOG_ERR "setup of vPCI for d%d failed: %d\n",
@@ -1476,6 +1485,10 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)
     if ( pdev->broken && d != hardware_domain && d != dom_io )
         goto done;
 
+    write_lock(&pdev->domain->pci_lock);
+    vpci_deassign_device(pdev);
+    write_unlock(&pdev->domain->pci_lock);
+
     rc = pdev_msix_assign(d, pdev);
     if ( rc )
         goto done;
@@ -1501,6 +1514,13 @@ static int assign_device(struct domain *d, u16 seg, u8 bus, u8 devfn, u32 flag)
                         pci_to_dev(pdev), flag);
     }
 
+    if ( rc )
+        goto done;
+
+    write_lock(&d->pci_lock);
+    rc = vpci_assign_device(pdev);
+    write_unlock(&d->pci_lock);
+
  done:
     if ( rc )
     {
diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 8f5850b8cf..2f2d98ada0 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -191,7 +191,7 @@ bool vpci_process_pending(struct vcpu *v)
              * killed in order to avoid leaking stale p2m mappings on
              * failure.
              */
-            vpci_remove_device(v->vpci.pdev);
+            vpci_deassign_device(v->vpci.pdev);
         write_unlock(&v->domain->pci_lock);
     }
 
diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index d545dc633c..ff48373917 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -40,7 +40,7 @@ extern vpci_register_init_t *const __start_vpci_array[];
 extern vpci_register_init_t *const __end_vpci_array[];
 #define NUM_VPCI_INIT (__end_vpci_array - __start_vpci_array)
 
-void vpci_remove_device(struct pci_dev *pdev)
+void vpci_deassign_device(struct pci_dev *pdev)
 {
     ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
 
@@ -73,7 +73,7 @@ void vpci_remove_device(struct pci_dev *pdev)
     pdev->vpci = NULL;
 }
 
-int vpci_add_handlers(struct pci_dev *pdev)
+int vpci_assign_device(struct pci_dev *pdev)
 {
     unsigned int i;
     const unsigned long *ro_map;
@@ -107,7 +107,7 @@ int vpci_add_handlers(struct pci_dev *pdev)
     }
 
     if ( rc )
-        vpci_remove_device(pdev);
+        vpci_deassign_device(pdev);
 
     return rc;
 }
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index d20c301a3d..99fe76f08a 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -25,11 +25,11 @@ typedef int vpci_register_init_t(struct pci_dev *dev);
   static vpci_register_init_t *const x##_entry  \
                __used_section(".data.vpci." p) = x
 
-/* Add vPCI handlers to device. */
-int __must_check vpci_add_handlers(struct pci_dev *pdev);
+/* Assign vPCI to device by adding handlers. */
+int __must_check vpci_assign_device(struct pci_dev *pdev);
 
 /* Remove all handlers and free vpci related structures. */
-void vpci_remove_device(struct pci_dev *pdev);
+void vpci_deassign_device(struct pci_dev *pdev);
 
 /* Add/remove a register handler. */
 int __must_check vpci_add_register_mask(struct vpci *vpci,
@@ -255,12 +255,12 @@ bool vpci_ecam_read(pci_sbdf_t sbdf, unsigned int reg, unsigned int len,
 #else /* !CONFIG_HAS_VPCI */
 struct vpci_vcpu {};
 
-static inline int vpci_add_handlers(struct pci_dev *pdev)
+static inline int vpci_assign_device(struct pci_dev *pdev)
 {
     return 0;
 }
 
-static inline void vpci_remove_device(struct pci_dev *pdev) { }
+static inline void vpci_deassign_device(struct pci_dev *pdev) { }
 
 static inline void vpci_dump_msi(void) { }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:23:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:23:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687093.1069944 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgNX-0003kQ-6Y; Thu, 29 Feb 2024 13:23:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687093.1069944; Thu, 29 Feb 2024 13:23:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgNX-0003kH-3k; Thu, 29 Feb 2024 13:23:15 +0000
Received: by outflank-mailman (input) for mailman id 687093;
 Thu, 29 Feb 2024 13:23:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNV-0003k5-4K
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNV-0004ra-3S
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNV-0004G0-2W
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=klWnNB8LAFPmhS7spIQK7hFkWNr5uimP1Ne7rUGotAI=; b=iU6Gez8Afk+AmM8N0CT/ZTyCY6
	A1dkiD7+sN5uOSWDg/sVQvnMkhoYSxoT9L8GYW+eSjxGo21PXKb+meGe7UlUd4TVWOpqaTyIJb+5A
	Y+0Ok0X8G9Nx27ACoeI7bVAu4hT+V7pAr+30qqpUQDWuKNMsL99C653qBV8WjvpjOuf4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] vpci/header: rework exit path in init_header()
Message-Id: <E1rfgNV-0004G0-2W@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:23:13 +0000

commit e2628261593b8a1688fa2aaa2049163284c0a918
Author:     Volodymyr Babchuk <volodymyr_babchuk@epam.com>
AuthorDate: Tue Feb 27 14:54:49 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:54:49 2024 +0100

    vpci/header: rework exit path in init_header()
    
    Introduce "fail" label in init_header() function to have the centralized
    error return path. This is the pre-requirement for the future changes
    in this function.
    
    This patch does not introduce functional changes.
    
    Suggested-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Acked-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
---
 xen/drivers/vpci/header.c | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 2f2d98ada0..803fe4bb99 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -656,10 +656,7 @@ static int cf_check init_header(struct pci_dev *pdev)
             rc = vpci_add_register(pdev->vpci, vpci_hw_read32, bar_write, reg,
                                    4, &bars[i]);
             if ( rc )
-            {
-                pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
-                return rc;
-            }
+                goto fail;
 
             continue;
         }
@@ -679,10 +676,7 @@ static int cf_check init_header(struct pci_dev *pdev)
         rc = pci_size_mem_bar(pdev->sbdf, reg, &addr, &size,
                               (i == num_bars - 1) ? PCI_BAR_LAST : 0);
         if ( rc < 0 )
-        {
-            pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
-            return rc;
-        }
+            goto fail;
 
         if ( size == 0 )
         {
@@ -697,10 +691,7 @@ static int cf_check init_header(struct pci_dev *pdev)
         rc = vpci_add_register(pdev->vpci, vpci_hw_read32, bar_write, reg, 4,
                                &bars[i]);
         if ( rc )
-        {
-            pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
-            return rc;
-        }
+            goto fail;
     }
 
     /* Check expansion ROM. */
@@ -722,6 +713,10 @@ static int cf_check init_header(struct pci_dev *pdev)
     }
 
     return (cmd & PCI_COMMAND_MEMORY) ? modify_bars(pdev, cmd, false) : 0;
+
+ fail:
+    pci_conf_write16(pdev->sbdf, PCI_COMMAND, cmd);
+    return rc;
 }
 REGISTER_VPCI_INIT(init_header, VPCI_PRIORITY_MIDDLE);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:23:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:23:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687095.1069958 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgNg-00045d-EP; Thu, 29 Feb 2024 13:23:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687095.1069958; Thu, 29 Feb 2024 13:23:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgNg-00045U-Br; Thu, 29 Feb 2024 13:23:24 +0000
Received: by outflank-mailman (input) for mailman id 687095;
 Thu, 29 Feb 2024 13:23:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNf-00043h-71
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNf-0004rn-6F
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNf-0004Gb-5b
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=lnItVsLYYNtx1pAjgn+fispaZ94GJ2pprBYQTBX+LOs=; b=x9gYOFh7Awz470LXj/uc7+keBj
	BF60MqDnERN2A94pzRDsoBC+giFBt6OjiXM8z3a0ynPhR8dmgoKGtRQWh/so+7ONdF1Xnbg0ACCdm
	ou9lW/rth/uL3bkgL1MvmnsfIJ/+1mMIGKmlEPRetPyCtepY4S0pyXDmp0lZW/0aNJ1A=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] vpci/header: implement guest BAR register handlers
Message-Id: <E1rfgNf-0004Gb-5b@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:23:23 +0000

commit 8c5bca70742cffda33c7f69f6a1c8df74397d562
Author:     Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
AuthorDate: Tue Feb 27 14:55:15 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:55:15 2024 +0100

    vpci/header: implement guest BAR register handlers
    
    Add relevant vpci register handlers when assigning PCI device to a domain
    and remove those when de-assigning. This allows having different
    handlers for different domains, e.g. hwdom and other guests.
    
    Emulate guest BAR register values: this allows creating a guest view
    of the registers and emulates size and properties probe as it is done
    during PCI device enumeration by the guest.
    
    All empty, IO and ROM BARs for guests are emulated by returning 0 on
    reads and ignoring writes: this BARs are special with this respect as
    their lower bits have special meaning, so returning default ~0 on read
    may confuse guest OS.
    
    Introduce is_hwdom convenience variable and convert an existing
    is_hardware_domain() check.
    
    Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
---
 xen/drivers/vpci/header.c | 109 +++++++++++++++++++++++++++++++++++++++++++---
 xen/include/xen/vpci.h    |   3 ++
 2 files changed, 106 insertions(+), 6 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 803fe4bb99..39e11e141b 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -478,6 +478,69 @@ static void cf_check bar_write(
     pci_conf_write32(pdev->sbdf, reg, val);
 }
 
+static void cf_check guest_mem_bar_write(const struct pci_dev *pdev,
+                                         unsigned int reg, uint32_t val,
+                                         void *data)
+{
+    struct vpci_bar *bar = data;
+    bool hi = false;
+    uint64_t guest_addr;
+
+    if ( bar->type == VPCI_BAR_MEM64_HI )
+    {
+        ASSERT(reg > PCI_BASE_ADDRESS_0);
+        bar--;
+        hi = true;
+    }
+    else
+    {
+        val &= PCI_BASE_ADDRESS_MEM_MASK;
+    }
+
+    guest_addr = bar->guest_addr;
+    guest_addr &= ~(0xffffffffULL << (hi ? 32 : 0));
+    guest_addr |= (uint64_t)val << (hi ? 32 : 0);
+
+    /* Allow guest to size BAR correctly */
+    guest_addr &= ~(bar->size - 1);
+
+    /*
+     * Xen only cares whether the BAR is mapped into the p2m, so allow BAR
+     * writes as long as the BAR is not mapped into the p2m.
+     */
+    if ( bar->enabled )
+    {
+        /* If the value written is the current one avoid printing a warning. */
+        if ( guest_addr != bar->guest_addr )
+            gprintk(XENLOG_WARNING,
+                    "%pp: ignored guest BAR %zu write while mapped\n",
+                    &pdev->sbdf, bar - pdev->vpci->header.bars + hi);
+        return;
+    }
+    bar->guest_addr = guest_addr;
+}
+
+static uint32_t cf_check guest_mem_bar_read(const struct pci_dev *pdev,
+                                            unsigned int reg, void *data)
+{
+    const struct vpci_bar *bar = data;
+    uint32_t reg_val;
+
+    if ( bar->type == VPCI_BAR_MEM64_HI )
+    {
+        ASSERT(reg > PCI_BASE_ADDRESS_0);
+        bar--;
+        return bar->guest_addr >> 32;
+    }
+
+    reg_val = bar->guest_addr;
+    reg_val |= bar->type == VPCI_BAR_MEM32 ? PCI_BASE_ADDRESS_MEM_TYPE_32 :
+                                             PCI_BASE_ADDRESS_MEM_TYPE_64;
+    reg_val |= bar->prefetchable ? PCI_BASE_ADDRESS_MEM_PREFETCH : 0;
+
+    return reg_val;
+}
+
 static void cf_check rom_write(
     const struct pci_dev *pdev, unsigned int reg, uint32_t val, void *data)
 {
@@ -539,6 +602,7 @@ static int cf_check init_header(struct pci_dev *pdev)
     struct vpci_bar *bars = header->bars;
     int rc;
     bool mask_cap_list = false;
+    bool is_hwdom = is_hardware_domain(pdev->domain);
 
     ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
 
@@ -564,7 +628,7 @@ static int cf_check init_header(struct pci_dev *pdev)
     if ( rc )
         return rc;
 
-    if ( !is_hardware_domain(pdev->domain) )
+    if ( !is_hwdom )
     {
         if ( pci_conf_read16(pdev->sbdf, PCI_STATUS) & PCI_STATUS_CAP_LIST )
         {
@@ -653,8 +717,11 @@ static int cf_check init_header(struct pci_dev *pdev)
         if ( i && bars[i - 1].type == VPCI_BAR_MEM64_LO )
         {
             bars[i].type = VPCI_BAR_MEM64_HI;
-            rc = vpci_add_register(pdev->vpci, vpci_hw_read32, bar_write, reg,
-                                   4, &bars[i]);
+            rc = vpci_add_register(pdev->vpci,
+                                   is_hwdom ? vpci_hw_read32
+                                            : guest_mem_bar_read,
+                                   is_hwdom ? bar_write : guest_mem_bar_write,
+                                   reg, 4, &bars[i]);
             if ( rc )
                 goto fail;
 
@@ -665,6 +732,14 @@ static int cf_check init_header(struct pci_dev *pdev)
         if ( (val & PCI_BASE_ADDRESS_SPACE) == PCI_BASE_ADDRESS_SPACE_IO )
         {
             bars[i].type = VPCI_BAR_IO;
+            if ( !IS_ENABLED(CONFIG_X86) && !is_hwdom )
+            {
+                rc = vpci_add_register(pdev->vpci, vpci_read_val, NULL,
+                                       reg, 4, (void *)0);
+                if ( rc )
+                    goto fail;
+            }
+
             continue;
         }
         if ( (val & PCI_BASE_ADDRESS_MEM_TYPE_MASK) ==
@@ -681,6 +756,15 @@ static int cf_check init_header(struct pci_dev *pdev)
         if ( size == 0 )
         {
             bars[i].type = VPCI_BAR_EMPTY;
+
+            if ( !is_hwdom )
+            {
+                rc = vpci_add_register(pdev->vpci, vpci_read_val, NULL,
+                                       reg, 4, (void *)0);
+                if ( rc )
+                    goto fail;
+            }
+
             continue;
         }
 
@@ -688,14 +772,18 @@ static int cf_check init_header(struct pci_dev *pdev)
         bars[i].size = size;
         bars[i].prefetchable = val & PCI_BASE_ADDRESS_MEM_PREFETCH;
 
-        rc = vpci_add_register(pdev->vpci, vpci_hw_read32, bar_write, reg, 4,
-                               &bars[i]);
+        rc = vpci_add_register(pdev->vpci,
+                               is_hwdom ? vpci_hw_read32 : guest_mem_bar_read,
+                               is_hwdom ? bar_write : guest_mem_bar_write,
+                               reg, 4, &bars[i]);
         if ( rc )
             goto fail;
     }
 
     /* Check expansion ROM. */
-    rc = pci_size_mem_bar(pdev->sbdf, rom_reg, &addr, &size, PCI_BAR_ROM);
+    rc = is_hwdom ? pci_size_mem_bar(pdev->sbdf, rom_reg, &addr, &size,
+                                     PCI_BAR_ROM)
+                  : 0;
     if ( rc > 0 && size )
     {
         struct vpci_bar *rom = &header->bars[num_bars];
@@ -711,6 +799,15 @@ static int cf_check init_header(struct pci_dev *pdev)
         if ( rc )
             rom->type = VPCI_BAR_EMPTY;
     }
+    else if ( !is_hwdom )
+    {
+        /* TODO: Check expansion ROM, we do not handle ROM for guests for now */
+        header->bars[num_bars].type = VPCI_BAR_EMPTY;
+        rc = vpci_add_register(pdev->vpci, vpci_read_val, NULL,
+                               rom_reg, 4, (void *)0);
+        if ( rc )
+            goto fail;
+    }
 
     return (cmd & PCI_COMMAND_MEMORY) ? modify_bars(pdev, cmd, false) : 0;
 
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index 99fe76f08a..b0e38a5a1a 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -87,7 +87,10 @@ struct vpci {
     struct vpci_header {
         /* Information about the PCI BARs of this device. */
         struct vpci_bar {
+            /* Physical (host) address. */
             uint64_t addr;
+            /* Guest address. */
+            uint64_t guest_addr;
             uint64_t size;
             enum {
                 VPCI_BAR_EMPTY,
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:23:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:23:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687096.1069962 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgNq-0004Da-GI; Thu, 29 Feb 2024 13:23:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687096.1069962; Thu, 29 Feb 2024 13:23:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgNq-0004DT-DP; Thu, 29 Feb 2024 13:23:34 +0000
Received: by outflank-mailman (input) for mailman id 687096;
 Thu, 29 Feb 2024 13:23:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNp-0004Bu-9k
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNp-0004s1-97
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNp-0004H4-8Q
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=s2elX1SFcR3QjK9uNQAIo0digVQsK5tYpXrIBmMmYfE=; b=StZ1POJXxOhUjmZnUCcZctF9y0
	eFPH6quwb9aDDjWd/OqaWlCxr5faaKzcdqWOejmuarGgXfwF+JFkUrjMnq5wyaoWSUCSUSpMrXSTq
	oW7npAoV88SSGtWne667yfOfyc0k0RUtfSoUdXruUjRiJg0BgiSG3AlLTES4wAbDkXUQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] rangeset: add RANGESETF_no_print flag
Message-Id: <E1rfgNp-0004H4-8Q@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:23:33 +0000

commit fe62abfcb28aaf83a9c74b3f4a64a6bb3cd6c998
Author:     Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
AuthorDate: Tue Feb 27 14:55:42 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:55:42 2024 +0100

    rangeset: add RANGESETF_no_print flag
    
    There are range sets which should not be printed, so introduce a flag
    which allows marking those as such. Implement relevant logic to skip
    such entries while printing.
    
    While at it also simplify the definition of the flags by directly
    defining those without helpers.
    
    Suggested-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
---
 xen/common/rangeset.c      | 5 ++++-
 xen/include/xen/rangeset.h | 5 +++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/xen/common/rangeset.c b/xen/common/rangeset.c
index 16a4c3b842..0ccd53caac 100644
--- a/xen/common/rangeset.c
+++ b/xen/common/rangeset.c
@@ -433,7 +433,7 @@ struct rangeset *rangeset_new(
     INIT_LIST_HEAD(&r->range_list);
     r->nr_ranges = -1;
 
-    BUG_ON(flags & ~RANGESETF_prettyprint_hex);
+    BUG_ON(flags & ~(RANGESETF_prettyprint_hex | RANGESETF_no_print));
     r->flags = flags;
 
     safe_strcpy(r->name, name ?: "(no name)");
@@ -575,6 +575,9 @@ void rangeset_domain_printk(
 
     list_for_each_entry ( r, &d->rangesets, rangeset_list )
     {
+        if ( r->flags & RANGESETF_no_print )
+            continue;
+
         printk("    ");
         rangeset_printk(r);
         printk("\n");
diff --git a/xen/include/xen/rangeset.h b/xen/include/xen/rangeset.h
index 8be0722787..87bd956962 100644
--- a/xen/include/xen/rangeset.h
+++ b/xen/include/xen/rangeset.h
@@ -49,8 +49,9 @@ void rangeset_limit(
 
 /* Flags for passing to rangeset_new(). */
  /* Pretty-print range limits in hexadecimal. */
-#define _RANGESETF_prettyprint_hex 0
-#define RANGESETF_prettyprint_hex  (1U << _RANGESETF_prettyprint_hex)
+#define RANGESETF_prettyprint_hex   (1U << 0)
+ /* Do not print entries marked with this flag. */
+#define RANGESETF_no_print          (1U << 1)
 
 bool __must_check rangeset_is_empty(
     const struct rangeset *r);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:23:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:23:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687098.1069965 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgO0-0004Pj-J4; Thu, 29 Feb 2024 13:23:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687098.1069965; Thu, 29 Feb 2024 13:23:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgO0-0004Pc-GI; Thu, 29 Feb 2024 13:23:44 +0000
Received: by outflank-mailman (input) for mailman id 687098;
 Thu, 29 Feb 2024 13:23:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNz-0004PC-Ck
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:43 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNz-0004sA-C1
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgNz-0004HX-BG
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=p8FD7NoptWxleipp9nKcPTYgC/iIXY3cZcPwDOmRzAw=; b=2mszsPYaJTCdROOzImahInau1i
	SpF3qNcUn299bEtVIrZAu9+EGNn3Ctk2XJMYhNWvOJn2Axuw6VSIHaOqlvHeJTWUFc10sgXFH4diX
	u4SjXP3Tgy36Wro+xrYUPgxIs1SjgynnQcGa4d+8HPPJB8NZrKHPZVQkaZHCgRLrZuiM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] rangeset: add rangeset_purge() function
Message-Id: <E1rfgNz-0004HX-BG@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:23:43 +0000

commit 99eeb2eb0b69b65c58e67f669e02004d12ca24f0
Author:     Volodymyr Babchuk <volodymyr_babchuk@epam.com>
AuthorDate: Tue Feb 27 14:56:19 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:56:19 2024 +0100

    rangeset: add rangeset_purge() function
    
    This function can be used when user wants to remove all rangeset
    entries but do not want to destroy rangeset itself.
    
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/common/rangeset.c      | 16 ++++++++++++----
 xen/include/xen/rangeset.h |  3 ++-
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/xen/common/rangeset.c b/xen/common/rangeset.c
index 0ccd53caac..b75590f907 100644
--- a/xen/common/rangeset.c
+++ b/xen/common/rangeset.c
@@ -448,11 +448,20 @@ struct rangeset *rangeset_new(
     return r;
 }
 
-void rangeset_destroy(
-    struct rangeset *r)
+void rangeset_purge(struct rangeset *r)
 {
     struct range *x;
 
+    if ( r == NULL )
+        return;
+
+    while ( (x = first_range(r)) != NULL )
+        destroy_range(r, x);
+}
+
+void rangeset_destroy(
+    struct rangeset *r)
+{
     if ( r == NULL )
         return;
 
@@ -463,8 +472,7 @@ void rangeset_destroy(
         spin_unlock(&r->domain->rangesets_lock);
     }
 
-    while ( (x = first_range(r)) != NULL )
-        destroy_range(r, x);
+    rangeset_purge(r);
 
     xfree(r);
 }
diff --git a/xen/include/xen/rangeset.h b/xen/include/xen/rangeset.h
index 87bd956962..96c9180825 100644
--- a/xen/include/xen/rangeset.h
+++ b/xen/include/xen/rangeset.h
@@ -56,7 +56,7 @@ void rangeset_limit(
 bool __must_check rangeset_is_empty(
     const struct rangeset *r);
 
-/* Add/claim/remove/query a numeric range. */
+/* Add/claim/remove/query/purge a numeric range. */
 int __must_check rangeset_add_range(
     struct rangeset *r, unsigned long s, unsigned long e);
 int __must_check rangeset_claim_range(struct rangeset *r, unsigned long size,
@@ -70,6 +70,7 @@ bool __must_check rangeset_overlaps_range(
 int rangeset_report_ranges(
     struct rangeset *r, unsigned long s, unsigned long e,
     int (*cb)(unsigned long s, unsigned long e, void *data), void *ctxt);
+void rangeset_purge(struct rangeset *r);
 
 /*
  * Note that the consume function can return an error value apart from
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:23:55 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:23:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687100.1069980 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgOA-0004qt-SW; Thu, 29 Feb 2024 13:23:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687100.1069980; Thu, 29 Feb 2024 13:23:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgOA-0004qm-PY; Thu, 29 Feb 2024 13:23:54 +0000
Received: by outflank-mailman (input) for mailman id 687100;
 Thu, 29 Feb 2024 13:23:53 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgO9-0004pr-Fo
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:53 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgO9-0004sN-F2
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:53 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgO9-0004Hy-EF
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:23:53 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=n+6jGHm618K1453dxrgtgJSTY7ESNb4bovNX1c9+48c=; b=JNZO5CrbXcdXS0OK9MXnhhePty
	7n2z3DiZStf9C4pMFXRh6KhL1/9y8b5Ktv10NlW6L0zidtx4+xQ+2MBEIaGX7ybeyX/H7Vlg0DzBV
	2AmMPmYENU/fW9KQeenaleRoAT1j0tX+ZSFUkUSQglC+ERE+n1r46UV8+iFHcqF5lMX4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] vpci/header: handle p2m range sets per BAR
Message-Id: <E1rfgO9-0004Hy-EF@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:23:53 +0000

commit 622bdd9628221fa8aa20fff534c4f500973ee0ff
Author:     Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
AuthorDate: Tue Feb 27 14:56:48 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:56:48 2024 +0100

    vpci/header: handle p2m range sets per BAR
    
    Instead of handling a single range set, that contains all the memory
    regions of all the BARs and ROM, have them per BAR.
    As the range sets are now created when a PCI device is added and destroyed
    when it is removed so make them named and accounted.
    
    Note that rangesets were chosen here despite there being only up to
    3 separate ranges in each set (typically just 1). But rangeset per BAR
    was chosen for the ease of implementation and existing code re-usability.
    
    Also note that error handling of vpci_process_pending() is slightly
    modified, and that vPCI handlers are no longer removed if the creation
    of the mappings in vpci_process_pending() fails, as that's unlikely to
    lead to a functional device in any case.
    
    This is in preparation of making non-identity mappings in p2m for the MMIOs.
    
    Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
---
 xen/drivers/vpci/header.c | 257 ++++++++++++++++++++++++++++++++--------------
 xen/drivers/vpci/vpci.c   |   6 ++
 xen/include/xen/vpci.h    |   2 +-
 3 files changed, 185 insertions(+), 80 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index 39e11e141b..feccd070dd 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -162,63 +162,107 @@ static void modify_decoding(const struct pci_dev *pdev, uint16_t cmd,
 
 bool vpci_process_pending(struct vcpu *v)
 {
-    if ( v->vpci.mem )
+    struct pci_dev *pdev = v->vpci.pdev;
+    struct map_data data = {
+        .d = v->domain,
+        .map = v->vpci.cmd & PCI_COMMAND_MEMORY,
+    };
+    struct vpci_header *header = NULL;
+    unsigned int i;
+
+    if ( !pdev )
+        return false;
+
+    read_lock(&v->domain->pci_lock);
+
+    if ( !pdev->vpci || (v->domain != pdev->domain) )
     {
-        struct map_data data = {
-            .d = v->domain,
-            .map = v->vpci.cmd & PCI_COMMAND_MEMORY,
-        };
-        int rc = rangeset_consume_ranges(v->vpci.mem, map_range, &data);
+        v->vpci.pdev = NULL;
+        read_unlock(&v->domain->pci_lock);
+        return false;
+    }
+
+    header = &pdev->vpci->header;
+    for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
+    {
+        struct vpci_bar *bar = &header->bars[i];
+        int rc;
+
+        if ( rangeset_is_empty(bar->mem) )
+            continue;
+
+        rc = rangeset_consume_ranges(bar->mem, map_range, &data);
 
         if ( rc == -ERESTART )
+        {
+            read_unlock(&v->domain->pci_lock);
             return true;
+        }
 
-        write_lock(&v->domain->pci_lock);
-        spin_lock(&v->vpci.pdev->vpci->lock);
-        /* Disable memory decoding unconditionally on failure. */
-        modify_decoding(v->vpci.pdev,
-                        rc ? v->vpci.cmd & ~PCI_COMMAND_MEMORY : v->vpci.cmd,
-                        !rc && v->vpci.rom_only);
-        spin_unlock(&v->vpci.pdev->vpci->lock);
-
-        rangeset_destroy(v->vpci.mem);
-        v->vpci.mem = NULL;
         if ( rc )
-            /*
-             * FIXME: in case of failure remove the device from the domain.
-             * Note that there might still be leftover mappings. While this is
-             * safe for Dom0, for DomUs the domain will likely need to be
-             * killed in order to avoid leaking stale p2m mappings on
-             * failure.
-             */
-            vpci_deassign_device(v->vpci.pdev);
-        write_unlock(&v->domain->pci_lock);
+        {
+            spin_lock(&pdev->vpci->lock);
+            /* Disable memory decoding unconditionally on failure. */
+            modify_decoding(pdev, v->vpci.cmd & ~PCI_COMMAND_MEMORY,
+                            false);
+            spin_unlock(&pdev->vpci->lock);
+
+            /* Clean all the rangesets */
+            for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
+                if ( !rangeset_is_empty(header->bars[i].mem) )
+                     rangeset_purge(header->bars[i].mem);
+
+            v->vpci.pdev = NULL;
+
+            read_unlock(&v->domain->pci_lock);
+
+            if ( !is_hardware_domain(v->domain) )
+                domain_crash(v->domain);
+
+            return false;
+        }
     }
+    v->vpci.pdev = NULL;
+
+    spin_lock(&pdev->vpci->lock);
+    modify_decoding(pdev, v->vpci.cmd, v->vpci.rom_only);
+    spin_unlock(&pdev->vpci->lock);
+
+    read_unlock(&v->domain->pci_lock);
 
     return false;
 }
 
 static int __init apply_map(struct domain *d, const struct pci_dev *pdev,
-                            struct rangeset *mem, uint16_t cmd)
+                            uint16_t cmd)
 {
     struct map_data data = { .d = d, .map = true };
-    int rc;
+    struct vpci_header *header = &pdev->vpci->header;
+    int rc = 0;
+    unsigned int i;
 
     ASSERT(rw_is_write_locked(&d->pci_lock));
 
-    while ( (rc = rangeset_consume_ranges(mem, map_range, &data)) == -ERESTART )
+    for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
     {
-        /*
-         * It's safe to drop and reacquire the lock in this context
-         * without risking pdev disappearing because devices cannot be
-         * removed until the initial domain has been started.
-         */
-        write_unlock(&d->pci_lock);
-        process_pending_softirqs();
-        write_lock(&d->pci_lock);
-    }
+        struct vpci_bar *bar = &header->bars[i];
 
-    rangeset_destroy(mem);
+        if ( rangeset_is_empty(bar->mem) )
+            continue;
+
+        while ( (rc = rangeset_consume_ranges(bar->mem, map_range,
+                                              &data)) == -ERESTART )
+        {
+            /*
+             * It's safe to drop and reacquire the lock in this context
+             * without risking pdev disappearing because devices cannot be
+             * removed until the initial domain has been started.
+             */
+            write_unlock(&d->pci_lock);
+            process_pending_softirqs();
+            write_lock(&d->pci_lock);
+        }
+    }
     if ( !rc )
         modify_decoding(pdev, cmd, false);
 
@@ -226,7 +270,7 @@ static int __init apply_map(struct domain *d, const struct pci_dev *pdev,
 }
 
 static void defer_map(struct domain *d, struct pci_dev *pdev,
-                      struct rangeset *mem, uint16_t cmd, bool rom_only)
+                      uint16_t cmd, bool rom_only)
 {
     struct vcpu *curr = current;
 
@@ -237,7 +281,6 @@ static void defer_map(struct domain *d, struct pci_dev *pdev,
      * started for the same device if the domain is not well-behaved.
      */
     curr->vpci.pdev = pdev;
-    curr->vpci.mem = mem;
     curr->vpci.cmd = cmd;
     curr->vpci.rom_only = rom_only;
     /*
@@ -251,33 +294,33 @@ static void defer_map(struct domain *d, struct pci_dev *pdev,
 static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
 {
     struct vpci_header *header = &pdev->vpci->header;
-    struct rangeset *mem = rangeset_new(NULL, NULL, 0);
     struct pci_dev *tmp, *dev = NULL;
     const struct domain *d;
     const struct vpci_msix *msix = pdev->vpci->msix;
-    unsigned int i;
+    unsigned int i, j;
     int rc;
 
     ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
 
-    if ( !mem )
-        return -ENOMEM;
-
     /*
-     * Create a rangeset that represents the current device BARs memory region
-     * and compare it against all the currently active BAR memory regions. If
-     * an overlap is found, subtract it from the region to be mapped/unmapped.
+     * Create a rangeset per BAR that represents the current device memory
+     * region and compare it against all the currently active BAR memory
+     * regions. If an overlap is found, subtract it from the region to be
+     * mapped/unmapped.
      *
-     * First fill the rangeset with all the BARs of this device or with the ROM
+     * First fill the rangesets with the BAR of this device or with the ROM
      * BAR only, depending on whether the guest is toggling the memory decode
      * bit of the command register, or the enable bit of the ROM BAR register.
      */
     for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
     {
-        const struct vpci_bar *bar = &header->bars[i];
+        struct vpci_bar *bar = &header->bars[i];
         unsigned long start = PFN_DOWN(bar->addr);
         unsigned long end = PFN_DOWN(bar->addr + bar->size - 1);
 
+        if ( !bar->mem )
+            continue;
+
         if ( !MAPPABLE_BAR(bar) ||
              (rom_only ? bar->type != VPCI_BAR_ROM
                        : (bar->type == VPCI_BAR_ROM && !header->rom_enabled)) ||
@@ -293,14 +336,31 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
             continue;
         }
 
-        rc = rangeset_add_range(mem, start, end);
+        rc = rangeset_add_range(bar->mem, start, end);
         if ( rc )
         {
             printk(XENLOG_G_WARNING "Failed to add [%lx, %lx]: %d\n",
                    start, end, rc);
-            rangeset_destroy(mem);
             return rc;
         }
+
+        /* Check for overlap with the already setup BAR ranges. */
+        for ( j = 0; j < i; j++ )
+        {
+            struct vpci_bar *prev_bar = &header->bars[j];
+
+            if ( rangeset_is_empty(prev_bar->mem) )
+                continue;
+
+            rc = rangeset_remove_range(prev_bar->mem, start, end);
+            if ( rc )
+            {
+                gprintk(XENLOG_WARNING,
+                       "%pp: failed to remove overlapping range [%lx, %lx]: %d\n",
+                        &pdev->sbdf, start, end, rc);
+                return rc;
+            }
+        }
     }
 
     /* Remove any MSIX regions if present. */
@@ -310,14 +370,21 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
         unsigned long end = PFN_DOWN(vmsix_table_addr(pdev->vpci, i) +
                                      vmsix_table_size(pdev->vpci, i) - 1);
 
-        rc = rangeset_remove_range(mem, start, end);
-        if ( rc )
+        for ( j = 0; j < ARRAY_SIZE(header->bars); j++ )
         {
-            printk(XENLOG_G_WARNING
-                   "Failed to remove MSIX table [%lx, %lx]: %d\n",
-                   start, end, rc);
-            rangeset_destroy(mem);
-            return rc;
+            const struct vpci_bar *bar = &header->bars[j];
+
+            if ( rangeset_is_empty(bar->mem) )
+                continue;
+
+            rc = rangeset_remove_range(bar->mem, start, end);
+            if ( rc )
+            {
+                gprintk(XENLOG_WARNING,
+                       "%pp: failed to remove MSIX table [%lx, %lx]: %d\n",
+                        &pdev->sbdf, start, end, rc);
+                return rc;
+            }
         }
     }
 
@@ -357,27 +424,37 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
 
             for ( i = 0; i < ARRAY_SIZE(tmp->vpci->header.bars); i++ )
             {
-                const struct vpci_bar *bar = &tmp->vpci->header.bars[i];
-                unsigned long start = PFN_DOWN(bar->addr);
-                unsigned long end = PFN_DOWN(bar->addr + bar->size - 1);
-
-                if ( !bar->enabled ||
-                     !rangeset_overlaps_range(mem, start, end) ||
-                     /*
-                      * If only the ROM enable bit is toggled check against
-                      * other BARs in the same device for overlaps, but not
-                      * against the same ROM BAR.
-                      */
-                     (rom_only && tmp == pdev && bar->type == VPCI_BAR_ROM) )
+                const struct vpci_bar *remote_bar = &tmp->vpci->header.bars[i];
+                unsigned long start = PFN_DOWN(remote_bar->addr);
+                unsigned long end = PFN_DOWN(remote_bar->addr +
+                                             remote_bar->size - 1);
+
+                if ( !remote_bar->enabled )
                     continue;
 
-                rc = rangeset_remove_range(mem, start, end);
-                if ( rc )
+                for ( j = 0; j < ARRAY_SIZE(header->bars); j++)
                 {
-                    printk(XENLOG_G_WARNING "Failed to remove [%lx, %lx]: %d\n",
-                           start, end, rc);
-                    rangeset_destroy(mem);
-                    return rc;
+                    const struct vpci_bar *bar = &header->bars[j];
+
+                    if ( !rangeset_overlaps_range(bar->mem, start, end) ||
+                         /*
+                          * If only the ROM enable bit is toggled check against
+                          * other BARs in the same device for overlaps, but not
+                          * against the same ROM BAR.
+                          */
+                         (rom_only &&
+                          tmp == pdev &&
+                          bar->type == VPCI_BAR_ROM) )
+                        continue;
+
+                    rc = rangeset_remove_range(bar->mem, start, end);
+                    if ( rc )
+                    {
+                        gprintk(XENLOG_WARNING,
+                                "%pp: failed to remove [%lx, %lx]: %d\n",
+                                &pdev->sbdf, start, end, rc);
+                        return rc;
+                    }
                 }
             }
         }
@@ -401,10 +478,10 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
          * will always be to establish mappings and process all the BARs.
          */
         ASSERT((cmd & PCI_COMMAND_MEMORY) && !rom_only);
-        return apply_map(pdev->domain, pdev, mem, cmd);
+        return apply_map(pdev->domain, pdev, cmd);
     }
 
-    defer_map(dev->domain, dev, mem, cmd, rom_only);
+    defer_map(dev->domain, dev, cmd, rom_only);
 
     return 0;
 }
@@ -593,6 +670,18 @@ static void cf_check rom_write(
         rom->addr = val & PCI_ROM_ADDRESS_MASK;
 }
 
+static int bar_add_rangeset(const struct pci_dev *pdev, struct vpci_bar *bar,
+                            unsigned int i)
+{
+    char str[32];
+
+    snprintf(str, sizeof(str), "%pp:BAR%u", &pdev->sbdf, i);
+
+    bar->mem = rangeset_new(pdev->domain, str, RANGESETF_no_print);
+
+    return !bar->mem ? -ENOMEM : 0;
+}
+
 static int cf_check init_header(struct pci_dev *pdev)
 {
     uint16_t cmd;
@@ -748,6 +837,10 @@ static int cf_check init_header(struct pci_dev *pdev)
         else
             bars[i].type = VPCI_BAR_MEM32;
 
+        rc = bar_add_rangeset(pdev, &bars[i], i);
+        if ( rc )
+            goto fail;
+
         rc = pci_size_mem_bar(pdev->sbdf, reg, &addr, &size,
                               (i == num_bars - 1) ? PCI_BAR_LAST : 0);
         if ( rc < 0 )
@@ -798,6 +891,12 @@ static int cf_check init_header(struct pci_dev *pdev)
                                4, rom);
         if ( rc )
             rom->type = VPCI_BAR_EMPTY;
+        else
+        {
+            rc = bar_add_rangeset(pdev, rom, num_bars);
+            if ( rc )
+                goto fail;
+        }
     }
     else if ( !is_hwdom )
     {
diff --git a/xen/drivers/vpci/vpci.c b/xen/drivers/vpci/vpci.c
index ff48373917..260b72875e 100644
--- a/xen/drivers/vpci/vpci.c
+++ b/xen/drivers/vpci/vpci.c
@@ -42,6 +42,8 @@ extern vpci_register_init_t *const __end_vpci_array[];
 
 void vpci_deassign_device(struct pci_dev *pdev)
 {
+    unsigned int i;
+
     ASSERT(rw_is_write_locked(&pdev->domain->pci_lock));
 
     if ( !has_vpci(pdev->domain) || !pdev->vpci )
@@ -67,6 +69,10 @@ void vpci_deassign_device(struct pci_dev *pdev)
             if ( pdev->vpci->msix->table[i] )
                 iounmap(pdev->vpci->msix->table[i]);
     }
+
+    for ( i = 0; i < ARRAY_SIZE(pdev->vpci->header.bars); i++ )
+        rangeset_destroy(pdev->vpci->header.bars[i].mem);
+
     xfree(pdev->vpci->msix);
     xfree(pdev->vpci->msi);
     xfree(pdev->vpci);
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index b0e38a5a1a..817ee9ee73 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -92,6 +92,7 @@ struct vpci {
             /* Guest address. */
             uint64_t guest_addr;
             uint64_t size;
+            struct rangeset *mem;
             enum {
                 VPCI_BAR_EMPTY,
                 VPCI_BAR_IO,
@@ -176,7 +177,6 @@ struct vpci {
 
 struct vpci_vcpu {
     /* Per-vcpu structure to store state while {un}mapping of PCI BARs. */
-    struct rangeset *mem;
     struct pci_dev *pdev;
     uint16_t cmd;
     bool rom_only : 1;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:24:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:24:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687101.1069984 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgOK-00054H-To; Thu, 29 Feb 2024 13:24:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687101.1069984; Thu, 29 Feb 2024 13:24:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgOK-000548-RA; Thu, 29 Feb 2024 13:24:04 +0000
Received: by outflank-mailman (input) for mailman id 687101;
 Thu, 29 Feb 2024 13:24:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgOJ-00052P-Io
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgOJ-0004t0-I2
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgOJ-0004J1-HH
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=n9+JyKCxqtPmi770j5/6N5AKewwLqZuupDIwI2Xj+DE=; b=ztjCyVuwt94pKRROKwcqnzaRP3
	UIzYdjrDvd71t6y5E3XRkSevs2IPmneIkmHoXEmqv9yOq9zrCSMSdabN/YjJrh2kziLQYHaBID7fz
	xjklEQWBLAdtEWTKmC8nYxBtY+NfWM7GfgEhaCABAjBsleOCmQ/tKs/aWkLe3XGB8E8E=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] vpci/header: program p2m with guest BAR view
Message-Id: <E1rfgOJ-0004J1-HH@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:24:03 +0000

commit 52ebde3cfae240e708571742eb7b6942efbd42a2
Author:     Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
AuthorDate: Tue Feb 27 14:57:16 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:57:16 2024 +0100

    vpci/header: program p2m with guest BAR view
    
    Take into account guest's BAR view and program its p2m accordingly:
    gfn is guest's view of the BAR and mfn is the physical BAR value.
    This way hardware domain sees physical BAR values and guest sees
    emulated ones.
    
    Hardware domain continues getting the BARs identity mapped, while for
    domUs the BARs are mapped at the requested guest address without
    modifying the BAR address in the device PCI config space.
    
    Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
    Signed-off-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/vpci/header.c | 83 ++++++++++++++++++++++++++++++++++++-----------
 xen/include/xen/vpci.h    |  3 +-
 2 files changed, 66 insertions(+), 20 deletions(-)

diff --git a/xen/drivers/vpci/header.c b/xen/drivers/vpci/header.c
index feccd070dd..47648c3951 100644
--- a/xen/drivers/vpci/header.c
+++ b/xen/drivers/vpci/header.c
@@ -34,6 +34,7 @@
 
 struct map_data {
     struct domain *d;
+    const struct vpci_bar *bar;
     bool map;
 };
 
@@ -41,26 +42,37 @@ static int cf_check map_range(
     unsigned long s, unsigned long e, void *data, unsigned long *c)
 {
     const struct map_data *map = data;
+    /* Start address of the BAR as seen by the guest. */
+    unsigned long start_gfn = PFN_DOWN(map->bar->guest_addr);
+    /* Physical start address of the BAR. */
+    unsigned long start_mfn = PFN_DOWN(map->bar->addr);
     int rc;
 
     for ( ; ; )
     {
         unsigned long size = e - s + 1;
+        /*
+         * Ranges to be mapped don't always start at the BAR start address, as
+         * there can be holes or partially consumed ranges. Account for the
+         * offset of the current address from the BAR start.
+         */
+        unsigned long map_mfn = start_mfn + s - start_gfn;
+        unsigned long m_end = map_mfn + size - 1;
 
-        if ( !iomem_access_permitted(map->d, s, e) )
+        if ( !iomem_access_permitted(map->d, map_mfn, m_end) )
         {
             printk(XENLOG_G_WARNING
                    "%pd denied access to MMIO range [%#lx, %#lx]\n",
-                   map->d, s, e);
+                   map->d, map_mfn, m_end);
             return -EPERM;
         }
 
-        rc = xsm_iomem_mapping(XSM_HOOK, map->d, s, e, map->map);
+        rc = xsm_iomem_mapping(XSM_HOOK, map->d, map_mfn, m_end, map->map);
         if ( rc )
         {
             printk(XENLOG_G_WARNING
                    "%pd XSM denied access to MMIO range [%#lx, %#lx]: %d\n",
-                   map->d, s, e, rc);
+                   map->d, map_mfn, m_end, rc);
             return rc;
         }
 
@@ -73,8 +85,8 @@ static int cf_check map_range(
          * - {un}map_mmio_regions doesn't support preemption.
          */
 
-        rc = map->map ? map_mmio_regions(map->d, _gfn(s), size, _mfn(s))
-                      : unmap_mmio_regions(map->d, _gfn(s), size, _mfn(s));
+        rc = map->map ? map_mmio_regions(map->d, _gfn(s), size, _mfn(map_mfn))
+                      : unmap_mmio_regions(map->d, _gfn(s), size, _mfn(map_mfn));
         if ( rc == 0 )
         {
             *c += size;
@@ -83,8 +95,9 @@ static int cf_check map_range(
         if ( rc < 0 )
         {
             printk(XENLOG_G_WARNING
-                   "Failed to identity %smap [%lx, %lx] for d%d: %d\n",
-                   map->map ? "" : "un", s, e, map->d->domain_id, rc);
+                   "Failed to %smap [%lx %lx] -> [%lx %lx] for %pd: %d\n",
+                   map->map ? "" : "un", s, e, map_mfn,
+                   map_mfn + size, map->d, rc);
             break;
         }
         ASSERT(rc < size);
@@ -163,10 +176,6 @@ static void modify_decoding(const struct pci_dev *pdev, uint16_t cmd,
 bool vpci_process_pending(struct vcpu *v)
 {
     struct pci_dev *pdev = v->vpci.pdev;
-    struct map_data data = {
-        .d = v->domain,
-        .map = v->vpci.cmd & PCI_COMMAND_MEMORY,
-    };
     struct vpci_header *header = NULL;
     unsigned int i;
 
@@ -186,6 +195,11 @@ bool vpci_process_pending(struct vcpu *v)
     for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
     {
         struct vpci_bar *bar = &header->bars[i];
+        struct map_data data = {
+            .d = v->domain,
+            .map = v->vpci.cmd & PCI_COMMAND_MEMORY,
+            .bar = bar,
+        };
         int rc;
 
         if ( rangeset_is_empty(bar->mem) )
@@ -236,7 +250,6 @@ bool vpci_process_pending(struct vcpu *v)
 static int __init apply_map(struct domain *d, const struct pci_dev *pdev,
                             uint16_t cmd)
 {
-    struct map_data data = { .d = d, .map = true };
     struct vpci_header *header = &pdev->vpci->header;
     int rc = 0;
     unsigned int i;
@@ -246,6 +259,7 @@ static int __init apply_map(struct domain *d, const struct pci_dev *pdev,
     for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
     {
         struct vpci_bar *bar = &header->bars[i];
+        struct map_data data = { .d = d, .map = true, .bar = bar };
 
         if ( rangeset_is_empty(bar->mem) )
             continue;
@@ -311,12 +325,16 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
      * First fill the rangesets with the BAR of this device or with the ROM
      * BAR only, depending on whether the guest is toggling the memory decode
      * bit of the command register, or the enable bit of the ROM BAR register.
+     *
+     * For non-hardware domain we use guest physical addresses.
      */
     for ( i = 0; i < ARRAY_SIZE(header->bars); i++ )
     {
         struct vpci_bar *bar = &header->bars[i];
         unsigned long start = PFN_DOWN(bar->addr);
         unsigned long end = PFN_DOWN(bar->addr + bar->size - 1);
+        unsigned long start_guest = PFN_DOWN(bar->guest_addr);
+        unsigned long end_guest = PFN_DOWN(bar->guest_addr + bar->size - 1);
 
         if ( !bar->mem )
             continue;
@@ -336,11 +354,26 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
             continue;
         }
 
-        rc = rangeset_add_range(bar->mem, start, end);
+        ASSERT(rangeset_is_empty(bar->mem));
+
+        /*
+         * Make sure that the guest set address has the same page offset
+         * as the physical address on the host or otherwise things won't work as
+         * expected.
+         */
+        if ( PAGE_OFFSET(bar->guest_addr) != PAGE_OFFSET(bar->addr) )
+        {
+            gprintk(XENLOG_G_WARNING,
+                    "%pp: can't map BAR%u - offset mismatch: %#lx vs %#lx\n",
+                    &pdev->sbdf, i, bar->guest_addr, bar->addr);
+            return -EINVAL;
+        }
+
+        rc = rangeset_add_range(bar->mem, start_guest, end_guest);
         if ( rc )
         {
             printk(XENLOG_G_WARNING "Failed to add [%lx, %lx]: %d\n",
-                   start, end, rc);
+                   start_guest, end_guest, rc);
             return rc;
         }
 
@@ -352,12 +385,12 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
             if ( rangeset_is_empty(prev_bar->mem) )
                 continue;
 
-            rc = rangeset_remove_range(prev_bar->mem, start, end);
+            rc = rangeset_remove_range(prev_bar->mem, start_guest, end_guest);
             if ( rc )
             {
                 gprintk(XENLOG_WARNING,
                        "%pp: failed to remove overlapping range [%lx, %lx]: %d\n",
-                        &pdev->sbdf, start, end, rc);
+                        &pdev->sbdf, start_guest, end_guest, rc);
                 return rc;
             }
         }
@@ -425,8 +458,8 @@ static int modify_bars(const struct pci_dev *pdev, uint16_t cmd, bool rom_only)
             for ( i = 0; i < ARRAY_SIZE(tmp->vpci->header.bars); i++ )
             {
                 const struct vpci_bar *remote_bar = &tmp->vpci->header.bars[i];
-                unsigned long start = PFN_DOWN(remote_bar->addr);
-                unsigned long end = PFN_DOWN(remote_bar->addr +
+                unsigned long start = PFN_DOWN(remote_bar->guest_addr);
+                unsigned long end = PFN_DOWN(remote_bar->guest_addr +
                                              remote_bar->size - 1);
 
                 if ( !remote_bar->enabled )
@@ -513,6 +546,8 @@ static void cf_check bar_write(
     struct vpci_bar *bar = data;
     bool hi = false;
 
+    ASSERT(is_hardware_domain(pdev->domain));
+
     if ( bar->type == VPCI_BAR_MEM64_HI )
     {
         ASSERT(reg > PCI_BASE_ADDRESS_0);
@@ -543,6 +578,8 @@ static void cf_check bar_write(
      */
     bar->addr &= ~(0xffffffffULL << (hi ? 32 : 0));
     bar->addr |= (uint64_t)val << (hi ? 32 : 0);
+    /* Update guest address, so hardware domain BAR is identity mapped. */
+    bar->guest_addr = bar->addr;
 
     /* Make sure Xen writes back the same value for the BAR RO bits. */
     if ( !hi )
@@ -639,11 +676,14 @@ static void cf_check rom_write(
     }
 
     if ( !rom->enabled )
+    {
         /*
          * If the ROM BAR is not mapped update the address field so the
          * correct address is mapped into the p2m.
          */
         rom->addr = val & PCI_ROM_ADDRESS_MASK;
+        rom->guest_addr = rom->addr;
+    }
 
     if ( !header->bars_mapped || rom->enabled == new_enabled )
     {
@@ -667,7 +707,10 @@ static void cf_check rom_write(
         return;
 
     if ( !new_enabled )
+    {
         rom->addr = val & PCI_ROM_ADDRESS_MASK;
+        rom->guest_addr = rom->addr;
+    }
 }
 
 static int bar_add_rangeset(const struct pci_dev *pdev, struct vpci_bar *bar,
@@ -862,6 +905,7 @@ static int cf_check init_header(struct pci_dev *pdev)
         }
 
         bars[i].addr = addr;
+        bars[i].guest_addr = addr;
         bars[i].size = size;
         bars[i].prefetchable = val & PCI_BASE_ADDRESS_MEM_PREFETCH;
 
@@ -884,6 +928,7 @@ static int cf_check init_header(struct pci_dev *pdev)
         rom->type = VPCI_BAR_ROM;
         rom->size = size;
         rom->addr = addr;
+        rom->guest_addr = addr;
         header->rom_enabled = pci_conf_read32(pdev->sbdf, rom_reg) &
                               PCI_ROM_ADDRESS_ENABLE;
 
diff --git a/xen/include/xen/vpci.h b/xen/include/xen/vpci.h
index 817ee9ee73..e89c571890 100644
--- a/xen/include/xen/vpci.h
+++ b/xen/include/xen/vpci.h
@@ -216,7 +216,8 @@ int vpci_msix_arch_print(const struct vpci_msix *msix);
  */
 static inline paddr_t vmsix_table_base(const struct vpci *vpci, unsigned int nr)
 {
-    return vpci->header.bars[vpci->msix->tables[nr] & PCI_MSIX_BIRMASK].addr;
+    return vpci->header.bars[vpci->msix->tables[nr] &
+                             PCI_MSIX_BIRMASK].guest_addr;
 }
 
 static inline paddr_t vmsix_table_addr(const struct vpci *vpci, unsigned int nr)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:24:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:24:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687102.1069988 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgOV-0005Fn-16; Thu, 29 Feb 2024 13:24:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687102.1069988; Thu, 29 Feb 2024 13:24:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgOU-0005Ff-US; Thu, 29 Feb 2024 13:24:14 +0000
Received: by outflank-mailman (input) for mailman id 687102;
 Thu, 29 Feb 2024 13:24:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgOT-0005F5-Lc
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgOT-0004tJ-Kr
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgOT-0004K9-KF
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=jmeArOvu6xcHipapGb3dB6sjerBb4VbBcJS+E338u9Q=; b=CbTLK9H/0se49TcWr3KmK0OgUx
	NW9KfZFfVPjB2lAXrJELMfKuYgUJPJrTzw1sbaTZTm8v63vQuWI+O5ZGM9qVaoipXV8ooptFwEMZB
	wWHnvDHzGtYUL3/aHj37ritd02QApaqxjgVTmgr+qn7LHu6nHFr1KCnm9WyY+qUpsGFk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/spec: print the built-in SPECULATIVE_HARDEN_* options
Message-Id: <E1rfgOT-0004K9-KF@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:24:13 +0000

commit 6e9507f7d51fe49df8bc70f83e49ce06c92e4e54
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 14:57:52 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:57:52 2024 +0100

    x86/spec: print the built-in SPECULATIVE_HARDEN_* options
    
    Just like it's done for INDIRECT_THUNK and SHADOW_PAGING.
    
    Reported-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/spec_ctrl.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 503f1c7a37..2d17cbe25f 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -476,13 +476,25 @@ static void __init print_details(enum ind_thunk thunk)
            (e21a & cpufeat_mask(X86_FEATURE_SBPB))           ? " SBPB"           : "");
 
     /* Compiled-in support which pertains to mitigations. */
-    if ( IS_ENABLED(CONFIG_INDIRECT_THUNK) || IS_ENABLED(CONFIG_SHADOW_PAGING) )
+    if ( IS_ENABLED(CONFIG_INDIRECT_THUNK) || IS_ENABLED(CONFIG_SHADOW_PAGING) ||
+         IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_ARRAY) ||
+         IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_BRANCH) ||
+         IS_ENABLED(CONFIG_SPECULATIVE_HARDEN_GUEST_ACCESS) )
         printk("  Compiled-in support:"
 #ifdef CONFIG_INDIRECT_THUNK
                " INDIRECT_THUNK"
 #endif
 #ifdef CONFIG_SHADOW_PAGING
                " SHADOW_PAGING"
+#endif
+#ifdef CONFIG_SPECULATIVE_HARDEN_ARRAY
+               " HARDEN_ARRAY"
+#endif
+#ifdef CONFIG_SPECULATIVE_HARDEN_BRANCH
+               " HARDEN_BRANCH"
+#endif
+#ifdef CONFIG_SPECULATIVE_HARDEN_GUEST_ACCESS
+               " HARDEN_GUEST_ACCESS"
 #endif
                "\n");
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:24:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:24:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687104.1069992 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgOf-0005LT-2N; Thu, 29 Feb 2024 13:24:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687104.1069992; Thu, 29 Feb 2024 13:24:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgOe-0005LK-Vu; Thu, 29 Feb 2024 13:24:24 +0000
Received: by outflank-mailman (input) for mailman id 687104;
 Thu, 29 Feb 2024 13:24:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgOd-0005Jf-Oh
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgOd-0004v2-Nm
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgOd-0004L4-NB
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=1Q9A0KGgbrwXGPM3yDmPJNHzymC+9LAk5UIY5LskZZY=; b=q7KYPZfhEaHmfbdH74cUTcC7nB
	VhBurU0J4DxdGCCfQMwuz89su8NHIzOOhUevdVGpCqhirWCCnuO6yW5N2KyWGsdTtYYOwwd165sM6
	hfjjTRGOBx0hMQzSX/LEqFeMRoLASYftMFw47EJ1/g/TeR2iHyAGyQhadMSAkDP/kEaI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/spec: fix INDIRECT_THUNK option to only be set when build-enabled
Message-Id: <E1rfgOd-0004L4-NB@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:24:23 +0000

commit 8441fa806a3b778867867cd0159fa1722e90397e
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 14:58:20 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:58:20 2024 +0100

    x86/spec: fix INDIRECT_THUNK option to only be set when build-enabled
    
    Attempt to provide a more helpful error message when the user attempts to set
    spec-ctrl=bti-thunk option but the support is build-time disabled.
    
    While there also adjust the command line documentation to mention
    CONFIG_INDIRECT_THUNK instead of INDIRECT_THUNK.
    
    Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 docs/misc/xen-command-line.pandoc | 10 +++++-----
 xen/arch/x86/spec_ctrl.c          |  7 ++++++-
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
index be76be8d53..02896598df 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -2417,11 +2417,11 @@ guests to use.
   performance reasons dom0 is unprotected by default.  If it is necessary to
   protect dom0 too, boot with `spec-ctrl=ibpb-entry`.
 
-If Xen was compiled with INDIRECT_THUNK support, `bti-thunk=` can be used to
-select which of the thunks gets patched into the `__x86_indirect_thunk_%reg`
-locations.  The default thunk is `retpoline` (generally preferred), with the
-alternatives being `jmp` (a `jmp *%reg` gadget, minimal overhead), and
-`lfence` (an `lfence; jmp *%reg` gadget).
+If Xen was compiled with `CONFIG_INDIRECT_THUNK` support, `bti-thunk=` can be
+used to select which of the thunks gets patched into the
+`__x86_indirect_thunk_%reg` locations.  The default thunk is `retpoline`
+(generally preferred), with the alternatives being `jmp` (a `jmp *%reg` gadget,
+minimal overhead), and `lfence` (an `lfence; jmp *%reg` gadget).
 
 On hardware supporting IBRS (Indirect Branch Restricted Speculation), the
 `ibrs=` option can be used to force or prevent Xen using the feature itself.
diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 2d17cbe25f..74d2136d42 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -241,7 +241,12 @@ static int __init cf_check parse_spec_ctrl(const char *s)
         {
             s += 10;
 
-            if ( !cmdline_strcmp(s, "retpoline") )
+            if ( !IS_ENABLED(CONFIG_INDIRECT_THUNK) )
+            {
+                no_config_param("INDIRECT_THUNK", "spec-ctrl", s - 10, ss);
+                rc = -EINVAL;
+            }
+            else if ( !cmdline_strcmp(s, "retpoline") )
                 opt_thunk = THUNK_RETPOLINE;
             else if ( !cmdline_strcmp(s, "lfence") )
                 opt_thunk = THUNK_LFENCE;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:24:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:24:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687105.1069995 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgOp-0005P4-3n; Thu, 29 Feb 2024 13:24:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687105.1069995; Thu, 29 Feb 2024 13:24:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgOp-0005Ow-19; Thu, 29 Feb 2024 13:24:35 +0000
Received: by outflank-mailman (input) for mailman id 687105;
 Thu, 29 Feb 2024 13:24:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgOn-0005Om-RS
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgOn-0004v9-Qk
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgOn-0004Lf-Q3
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=aQpfTBy15aBlEerfxVXxiZAGEWA4MBkaz/ubFjELDrY=; b=NyjKr2HyLaChG/eevWM69o+GTv
	tvKnok+c3r0rNAqKLBW63s/N2ULfDMP7A026MDl6CrOqu0fS/zT9rsE+EfyLU9mxqT3lVmMvVOVVV
	Ap0UlbxaHjjposKKqSxNtDmPWR2sKqYED+QJkKWQFI3CGjf6EGcoJi5NXVWajgBRQUW0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/spec: do not print thunk option selection if not built-in
Message-Id: <E1rfgOn-0004Lf-Q3@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:24:33 +0000

commit 576528a2a742069af203e90c613c5c93e23c9755
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Feb 27 14:58:40 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 14:58:40 2024 +0100

    x86/spec: do not print thunk option selection if not built-in
    
    Since the thunk built-in enable is printed as part of the "Compiled-in
    support:" line, avoid printing anything in "Xen settings:" if the thunk is
    disabled at build time.
    
    Note the BTI-Thunk option printing is also adjusted to print a colon in the
    same way the other options on the line do.
    
    Requested-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/spec_ctrl.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/spec_ctrl.c b/xen/arch/x86/spec_ctrl.c
index 74d2136d42..752225faa6 100644
--- a/xen/arch/x86/spec_ctrl.c
+++ b/xen/arch/x86/spec_ctrl.c
@@ -504,11 +504,12 @@ static void __init print_details(enum ind_thunk thunk)
                "\n");
 
     /* Settings for Xen's protection, irrespective of guests. */
-    printk("  Xen settings: BTI-Thunk %s, SPEC_CTRL: %s%s%s%s%s, Other:%s%s%s%s%s%s\n",
-           thunk == THUNK_NONE      ? "N/A" :
-           thunk == THUNK_RETPOLINE ? "RETPOLINE" :
-           thunk == THUNK_LFENCE    ? "LFENCE" :
-           thunk == THUNK_JMP       ? "JMP" : "?",
+    printk("  Xen settings: %s%sSPEC_CTRL: %s%s%s%s%s, Other:%s%s%s%s%s%s\n",
+           thunk != THUNK_NONE      ? "BTI-Thunk: " : "",
+           thunk == THUNK_NONE      ? "" :
+           thunk == THUNK_RETPOLINE ? "RETPOLINE, " :
+           thunk == THUNK_LFENCE    ? "LFENCE, " :
+           thunk == THUNK_JMP       ? "JMP, " : "?, ",
            (!boot_cpu_has(X86_FEATURE_IBRSB) &&
             !boot_cpu_has(X86_FEATURE_IBRS))         ? "No" :
            (default_xen_spec_ctrl & SPEC_CTRL_IBRS)  ? "IBRS+" :  "IBRS-",
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:24:45 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:24:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687106.1070000 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgOz-0005WF-5M; Thu, 29 Feb 2024 13:24:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687106.1070000; Thu, 29 Feb 2024 13:24:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgOz-0005W8-2e; Thu, 29 Feb 2024 13:24:45 +0000
Received: by outflank-mailman (input) for mailman id 687106;
 Thu, 29 Feb 2024 13:24:43 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgOx-0005Vs-UY
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:43 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgOx-0004vE-Tn
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgOx-0004M5-T2
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=qCSky+gv8EvLnv0H9S6kaSS8UUWmD4Z3Lo/ubT+MQ/g=; b=bvmi6OkzbaBEmKhF7/Fov7fgLs
	oclinuDjC2eWeTvxk18T+lT3gMkkwHtzIRgJSPhbr135ymRkM1M75lbUQfJnCL7S/DCo3B7hvGczN
	x7U1i8d4hnsrttysnG+UUSR06FgTp+tVNtTnXEBC33aW5CGBuK4KqMDXmcsjR+8BuRtE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tests/vpci: fix unit tests after locking change
Message-Id: <E1rfgOx-0004M5-T2@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:24:43 +0000

commit 801c4e72621d5541d249af1938a77466f0dcfe88
Author:     Stewart Hildebrand <stewart.hildebrand@amd.com>
AuthorDate: Tue Feb 27 18:02:01 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Feb 27 18:02:01 2024 +0100

    tests/vpci: fix unit tests after locking change
    
    The recent vPCI locking broke the vPCI unit tests. Fix it to unblock CI.
    
    Fixes: 4f78438b45e2 ("vpci: use per-domain PCI lock to protect vpci structure")
    Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
    Acked-by: Roger Pau Monné <roger.pau@citrix.com>
---
 tools/tests/vpci/emul.h | 9 ++++++++-
 tools/tests/vpci/main.c | 2 +-
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/tools/tests/vpci/emul.h b/tools/tests/vpci/emul.h
index 3c2f66a18f..da446bba86 100644
--- a/tools/tests/vpci/emul.h
+++ b/tools/tests/vpci/emul.h
@@ -37,7 +37,10 @@
 
 #include "list.h"
 
+typedef bool rwlock_t;
+
 struct domain {
+    rwlock_t pci_lock;
 };
 
 struct pci_dev {
@@ -46,7 +49,7 @@ struct pci_dev {
 
 struct vcpu
 {
-    const struct domain *domain;
+    struct domain *domain;
 };
 
 extern const struct vcpu *current;
@@ -56,6 +59,10 @@ typedef bool spinlock_t;
 #define spin_lock_init(l) (*(l) = false)
 #define spin_lock(l) (*(l) = true)
 #define spin_unlock(l) (*(l) = false)
+#define read_lock(l) (*(l) = true)
+#define read_unlock(l) (*(l) = false)
+#define write_lock(l) (*(l) = true)
+#define write_unlock(l) (*(l) = false)
 
 typedef union {
     uint32_t sbdf;
diff --git a/tools/tests/vpci/main.c b/tools/tests/vpci/main.c
index 64d4552936..33223db3eb 100644
--- a/tools/tests/vpci/main.c
+++ b/tools/tests/vpci/main.c
@@ -21,7 +21,7 @@
 /* Single vcpu (current), and single domain with a single PCI device. */
 static struct vpci vpci;
 
-const static struct domain d;
+static struct domain d;
 
 const struct pci_dev test_pdev = {
     .vpci = &vpci,
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:24:55 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:24:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687107.1070004 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgP9-0005Zj-76; Thu, 29 Feb 2024 13:24:55 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687107.1070004; Thu, 29 Feb 2024 13:24:55 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgP9-0005Zb-4F; Thu, 29 Feb 2024 13:24:55 +0000
Received: by outflank-mailman (input) for mailman id 687107;
 Thu, 29 Feb 2024 13:24:54 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgP8-0005ZP-1D
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:54 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgP8-0004vc-0S
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:54 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgP7-0004MY-W6
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:24:53 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Z/kWsi/9gZOoXitlVoW4mDvboIIPBOD/QtLu9TWY0Ik=; b=JelbrO5sdLSk5SvSx1kWUx88zU
	QlXjVKb7NAcCba2Kc53/ksNJwlYdgAbyovys20PyLM8vMAzyYdf78Wj7/WhR3zmX1B3Jn1ti6ht1X
	e/tfIfurSsK0V9g6olQgicxRsZVa9DFPN2VowlGdoNPYD/JH6WL9R9gSG27vn2bUXEgg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/lib: introduce generic find next bit operations
Message-Id: <E1rfgP7-0004MY-W6@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:24:53 +0000

commit ba0d1a7cedc8b282b5b6e780e0846f3189e9cc90
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Fri Feb 9 18:58:30 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Wed Feb 28 11:55:32 2024 +0000

    xen/lib: introduce generic find next bit operations
    
    find-next-bit.c is common for Arm64, PPC and RISCV64,
    so it is moved to xen/lib.
    
    PPC has been transitioned to generic functions from find-next-bit.c
    since it now shares the same implementation as the PPC-specific code.
    
    The MISRA exclude list has been updated to verify
    lib/find-next-bit.c instead of Arm's find_next_bit.c,
    as Arm's find_next_bit.c has been relocated to xen/lib/.
    
    Despite CONFIG_GENERIC_FIND_FIRST_BIT not currently being used in
    Xen and being removed from the Linux kernel [1], it could theoretically
    prove useful for Xen. This is because the Linux kernel transitioned
    Arm to the generic version of find_first_bit() and
    find_first_zero_bit() due to improvements [1] in both performance
    and .text size.
    It would be prudent to investigate whether [1] is applicable to Xen
    as well and, if so, implement the necessary changes in a separate patch.
    
    [1] https://lore.kernel.org/linux-arch/20211005054059.475634-5-yury.norov@gmail.com/
    
    Suggested-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Shawn Anastasio <sanastasio@raptorengineering.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 docs/misra/exclude-list.json            |   8 +-
 xen/arch/arm/arm64/lib/Makefile         |   2 +-
 xen/arch/arm/arm64/lib/find_next_bit.c  | 281 --------------------------------
 xen/arch/arm/include/asm/arm64/bitops.h |  46 +-----
 xen/arch/ppc/include/asm/bitops.h       | 115 -------------
 xen/include/xen/bitops.h                |  48 ++++++
 xen/lib/Makefile                        |   1 +
 xen/lib/find-next-bit.c                 | 281 ++++++++++++++++++++++++++++++++
 8 files changed, 336 insertions(+), 446 deletions(-)

diff --git a/docs/misra/exclude-list.json b/docs/misra/exclude-list.json
index bfd967f0e4..36bad9e54f 100644
--- a/docs/misra/exclude-list.json
+++ b/docs/misra/exclude-list.json
@@ -13,10 +13,6 @@
             "rel_path": "arch/arm/arm64/insn.c",
             "comment": "Imported on Linux, ignore for now"
         },
-        {
-            "rel_path": "arch/arm/arm64/lib/find_next_bit.c",
-            "comment": "Imported from Linux, ignore for now"
-        },
         {
             "rel_path": "arch/x86/acpi/boot.c",
             "comment": "Imported from Linux, ignore for now"
@@ -225,6 +221,10 @@
             "rel_path": "include/xen/decompress.h",
             "comment": "Imported from Linux, ignore for now"
         },
+        {
+            "rel_path": "lib/find-next-bit.c",
+            "comment": "Imported from Linux, ignore for now"
+        },
         {
             "rel_path": "lib/list-sort.c",
             "comment": "Imported from Linux, ignore for now"
diff --git a/xen/arch/arm/arm64/lib/Makefile b/xen/arch/arm/arm64/lib/Makefile
index 1b9c7a95e6..66cfac435a 100644
--- a/xen/arch/arm/arm64/lib/Makefile
+++ b/xen/arch/arm/arm64/lib/Makefile
@@ -1,4 +1,4 @@
 obj-y += memcpy.o memcmp.o memmove.o memset.o memchr.o
 obj-y += clear_page.o
-obj-y += bitops.o find_next_bit.o
+obj-y += bitops.o
 obj-y += strchr.o strcmp.o strlen.o strncmp.o strnlen.o strrchr.o
diff --git a/xen/arch/arm/arm64/lib/find_next_bit.c b/xen/arch/arm/arm64/lib/find_next_bit.c
deleted file mode 100644
index ca6f82277e..0000000000
--- a/xen/arch/arm/arm64/lib/find_next_bit.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/* find_next_bit.c: fallback find next bit implementation
- *
- * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
- * Written by David Howells (dhowells@redhat.com)
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version
- * 2 of the License, or (at your option) any later version.
- */
-#include <xen/bitops.h>
-
-#include <asm/byteorder.h>
-
-#ifndef find_next_bit
-/*
- * Find the next set bit in a memory region.
- */
-unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
-			    unsigned long offset)
-{
-	const unsigned long *p = addr + BIT_WORD(offset);
-	unsigned long result = offset & ~(BITS_PER_LONG-1);
-	unsigned long tmp;
-
-	if (offset >= size)
-		return size;
-	size -= result;
-	offset %= BITS_PER_LONG;
-	if (offset) {
-		tmp = *(p++);
-		tmp &= (~0UL << offset);
-		if (size < BITS_PER_LONG)
-			goto found_first;
-		if (tmp)
-			goto found_middle;
-		size -= BITS_PER_LONG;
-		result += BITS_PER_LONG;
-	}
-	while (size & ~(BITS_PER_LONG-1)) {
-		if ((tmp = *(p++)))
-			goto found_middle;
-		result += BITS_PER_LONG;
-		size -= BITS_PER_LONG;
-	}
-	if (!size)
-		return result;
-	tmp = *p;
-
-found_first:
-	tmp &= (~0UL >> (BITS_PER_LONG - size));
-	if (tmp == 0UL)		/* Are any bits set? */
-		return result + size;	/* Nope. */
-found_middle:
-	return result + __ffs(tmp);
-}
-EXPORT_SYMBOL(find_next_bit);
-#endif
-
-#ifndef find_next_zero_bit
-/*
- * This implementation of find_{first,next}_zero_bit was stolen from
- * Linus' asm-alpha/bitops.h.
- */
-unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
-				 unsigned long offset)
-{
-	const unsigned long *p = addr + BIT_WORD(offset);
-	unsigned long result = offset & ~(BITS_PER_LONG-1);
-	unsigned long tmp;
-
-	if (offset >= size)
-		return size;
-	size -= result;
-	offset %= BITS_PER_LONG;
-	if (offset) {
-		tmp = *(p++);
-		tmp |= ~0UL >> (BITS_PER_LONG - offset);
-		if (size < BITS_PER_LONG)
-			goto found_first;
-		if (~tmp)
-			goto found_middle;
-		size -= BITS_PER_LONG;
-		result += BITS_PER_LONG;
-	}
-	while (size & ~(BITS_PER_LONG-1)) {
-		if (~(tmp = *(p++)))
-			goto found_middle;
-		result += BITS_PER_LONG;
-		size -= BITS_PER_LONG;
-	}
-	if (!size)
-		return result;
-	tmp = *p;
-
-found_first:
-	tmp |= ~0UL << size;
-	if (tmp == ~0UL)	/* Are any bits zero? */
-		return result + size;	/* Nope. */
-found_middle:
-	return result + ffz(tmp);
-}
-EXPORT_SYMBOL(find_next_zero_bit);
-#endif
-
-#ifndef find_first_bit
-/*
- * Find the first set bit in a memory region.
- */
-unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
-{
-	const unsigned long *p = addr;
-	unsigned long result = 0;
-	unsigned long tmp;
-
-	while (size & ~(BITS_PER_LONG-1)) {
-		if ((tmp = *(p++)))
-			goto found;
-		result += BITS_PER_LONG;
-		size -= BITS_PER_LONG;
-	}
-	if (!size)
-		return result;
-
-	tmp = (*p) & (~0UL >> (BITS_PER_LONG - size));
-	if (tmp == 0UL)		/* Are any bits set? */
-		return result + size;	/* Nope. */
-found:
-	return result + __ffs(tmp);
-}
-EXPORT_SYMBOL(find_first_bit);
-#endif
-
-#ifndef find_first_zero_bit
-/*
- * Find the first cleared bit in a memory region.
- */
-unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
-{
-	const unsigned long *p = addr;
-	unsigned long result = 0;
-	unsigned long tmp;
-
-	while (size & ~(BITS_PER_LONG-1)) {
-		if (~(tmp = *(p++)))
-			goto found;
-		result += BITS_PER_LONG;
-		size -= BITS_PER_LONG;
-	}
-	if (!size)
-		return result;
-
-	tmp = (*p) | (~0UL << size);
-	if (tmp == ~0UL)	/* Are any bits zero? */
-		return result + size;	/* Nope. */
-found:
-	return result + ffz(tmp);
-}
-EXPORT_SYMBOL(find_first_zero_bit);
-#endif
-
-#ifdef __BIG_ENDIAN
-
-/* include/linux/byteorder does not support "unsigned long" type */
-static inline unsigned long ext2_swabp(const unsigned long * x)
-{
-#if BITS_PER_LONG == 64
-	return (unsigned long) __swab64p((u64 *) x);
-#elif BITS_PER_LONG == 32
-	return (unsigned long) __swab32p((u32 *) x);
-#else
-#error BITS_PER_LONG not defined
-#endif
-}
-
-/* include/linux/byteorder doesn't support "unsigned long" type */
-static inline unsigned long ext2_swab(const unsigned long y)
-{
-#if BITS_PER_LONG == 64
-	return (unsigned long) __swab64((u64) y);
-#elif BITS_PER_LONG == 32
-	return (unsigned long) __swab32((u32) y);
-#else
-#error BITS_PER_LONG not defined
-#endif
-}
-
-#ifndef find_next_zero_bit_le
-unsigned long find_next_zero_bit_le(const void *addr, unsigned
-		long size, unsigned long offset)
-{
-	const unsigned long *p = addr;
-	unsigned long result = offset & ~(BITS_PER_LONG - 1);
-	unsigned long tmp;
-
-	if (offset >= size)
-		return size;
-	p += BIT_WORD(offset);
-	size -= result;
-	offset &= (BITS_PER_LONG - 1UL);
-	if (offset) {
-		tmp = ext2_swabp(p++);
-		tmp |= (~0UL >> (BITS_PER_LONG - offset));
-		if (size < BITS_PER_LONG)
-			goto found_first;
-		if (~tmp)
-			goto found_middle;
-		size -= BITS_PER_LONG;
-		result += BITS_PER_LONG;
-	}
-
-	while (size & ~(BITS_PER_LONG - 1)) {
-		if (~(tmp = *(p++)))
-			goto found_middle_swap;
-		result += BITS_PER_LONG;
-		size -= BITS_PER_LONG;
-	}
-	if (!size)
-		return result;
-	tmp = ext2_swabp(p);
-found_first:
-	tmp |= ~0UL << size;
-	if (tmp == ~0UL)	/* Are any bits zero? */
-		return result + size; /* Nope. Skip ffz */
-found_middle:
-	return result + ffz(tmp);
-
-found_middle_swap:
-	return result + ffz(ext2_swab(tmp));
-}
-EXPORT_SYMBOL(find_next_zero_bit_le);
-#endif
-
-#ifndef find_next_bit_le
-unsigned long find_next_bit_le(const void *addr, unsigned
-		long size, unsigned long offset)
-{
-	const unsigned long *p = addr;
-	unsigned long result = offset & ~(BITS_PER_LONG - 1);
-	unsigned long tmp;
-
-	if (offset >= size)
-		return size;
-	p += BIT_WORD(offset);
-	size -= result;
-	offset &= (BITS_PER_LONG - 1UL);
-	if (offset) {
-		tmp = ext2_swabp(p++);
-		tmp &= (~0UL << offset);
-		if (size < BITS_PER_LONG)
-			goto found_first;
-		if (tmp)
-			goto found_middle;
-		size -= BITS_PER_LONG;
-		result += BITS_PER_LONG;
-	}
-
-	while (size & ~(BITS_PER_LONG - 1)) {
-		tmp = *(p++);
-		if (tmp)
-			goto found_middle_swap;
-		result += BITS_PER_LONG;
-		size -= BITS_PER_LONG;
-	}
-	if (!size)
-		return result;
-	tmp = ext2_swabp(p);
-found_first:
-	tmp &= (~0UL >> (BITS_PER_LONG - size));
-	if (tmp == 0UL)		/* Are any bits set? */
-		return result + size; /* Nope. */
-found_middle:
-	return result + __ffs(tmp);
-
-found_middle_swap:
-	return result + __ffs(ext2_swab(tmp));
-}
-EXPORT_SYMBOL(find_next_bit_le);
-#endif
-
-#endif /* __BIG_ENDIAN */
diff --git a/xen/arch/arm/include/asm/arm64/bitops.h b/xen/arch/arm/include/asm/arm64/bitops.h
index d85a49bca4..0efde29068 100644
--- a/xen/arch/arm/include/asm/arm64/bitops.h
+++ b/xen/arch/arm/include/asm/arm64/bitops.h
@@ -36,57 +36,13 @@ static inline int flsl(unsigned long x)
 
 /* Based on linux/include/asm-generic/bitops/find.h */
 
-#ifndef find_next_bit
-/**
- * find_next_bit - find the next set bit in a memory region
- * @addr: The address to base the search on
- * @offset: The bitnumber to start searching at
- * @size: The bitmap size in bits
- */
-extern unsigned long find_next_bit(const unsigned long *addr, unsigned long
-		size, unsigned long offset);
-#endif
-
-#ifndef find_next_zero_bit
-/**
- * find_next_zero_bit - find the next cleared bit in a memory region
- * @addr: The address to base the search on
- * @offset: The bitnumber to start searching at
- * @size: The bitmap size in bits
- */
-extern unsigned long find_next_zero_bit(const unsigned long *addr, unsigned
-		long size, unsigned long offset);
-#endif
-
-#ifdef CONFIG_GENERIC_FIND_FIRST_BIT
-
-/**
- * find_first_bit - find the first set bit in a memory region
- * @addr: The address to start the search at
- * @size: The maximum size to search
- *
- * Returns the bit number of the first set bit.
- */
-extern unsigned long find_first_bit(const unsigned long *addr,
-				    unsigned long size);
-
-/**
- * find_first_zero_bit - find the first cleared bit in a memory region
- * @addr: The address to start the search at
- * @size: The maximum size to search
- *
- * Returns the bit number of the first cleared bit.
- */
-extern unsigned long find_first_zero_bit(const unsigned long *addr,
-					 unsigned long size);
-#else /* CONFIG_GENERIC_FIND_FIRST_BIT */
+#ifndef CONFIG_GENERIC_FIND_FIRST_BIT
 
 #define find_first_bit(addr, size) find_next_bit((addr), (size), 0)
 #define find_first_zero_bit(addr, size) find_next_zero_bit((addr), (size), 0)
 
 #endif /* CONFIG_GENERIC_FIND_FIRST_BIT */
 
-
 #endif /* _ARM_ARM64_BITOPS_H */
 /*
  * Local variables:
diff --git a/xen/arch/ppc/include/asm/bitops.h b/xen/arch/ppc/include/asm/bitops.h
index 5e7f36c21d..5820b9ce7b 100644
--- a/xen/arch/ppc/include/asm/bitops.h
+++ b/xen/arch/ppc/include/asm/bitops.h
@@ -217,119 +217,4 @@ static always_inline unsigned long __ffs(unsigned long word)
  */
 #define find_first_set_bit(x) (ffsl(x) - 1)
 
-/*
- * Find the first set bit in a memory region.
- */
-static inline unsigned long find_first_bit(const unsigned long *addr,
-                                           unsigned long size)
-{
-    const unsigned long *p = addr;
-    unsigned long result = 0;
-    unsigned long tmp;
-
-    while ( size & ~(BITS_PER_LONG - 1) )
-    {
-        if ( (tmp = *(p++)) )
-            goto found;
-        result += BITS_PER_LONG;
-        size -= BITS_PER_LONG;
-    }
-    if ( !size )
-        return result;
-
-    tmp = (*p) & (~0UL >> (BITS_PER_LONG - size));
-    if ( tmp == 0UL )         /* Are any bits set? */
-        return result + size; /* Nope. */
- found:
-    return result + __ffs(tmp);
-}
-
-static inline unsigned long find_next_bit(const unsigned long *addr,
-                                          unsigned long size,
-                                          unsigned long offset)
-{
-    const unsigned long *p = addr + BITOP_WORD(offset);
-    unsigned long result = offset & ~(BITS_PER_LONG - 1);
-    unsigned long tmp;
-
-    if ( offset >= size )
-        return size;
-    size -= result;
-    offset %= BITS_PER_LONG;
-    if ( offset )
-    {
-        tmp = *(p++);
-        tmp &= (~0UL << offset);
-        if ( size < BITS_PER_LONG )
-            goto found_first;
-        if ( tmp )
-            goto found_middle;
-        size -= BITS_PER_LONG;
-        result += BITS_PER_LONG;
-    }
-    while ( size & ~(BITS_PER_LONG - 1) )
-    {
-        if ( (tmp = *(p++)) )
-            goto found_middle;
-        result += BITS_PER_LONG;
-        size -= BITS_PER_LONG;
-    }
-    if ( !size )
-        return result;
-    tmp = *p;
-
- found_first:
-    tmp &= (~0UL >> (BITS_PER_LONG - size));
-    if ( tmp == 0UL )         /* Are any bits set? */
-        return result + size; /* Nope. */
- found_middle:
-    return result + __ffs(tmp);
-}
-
-/*
- * This implementation of find_{first,next}_zero_bit was stolen from
- * Linus' asm-alpha/bitops.h.
- */
-static inline unsigned long find_next_zero_bit(const unsigned long *addr,
-                                               unsigned long size,
-                                               unsigned long offset)
-{
-    const unsigned long *p = addr + BITOP_WORD(offset);
-    unsigned long result = offset & ~(BITS_PER_LONG - 1);
-    unsigned long tmp;
-
-    if ( offset >= size )
-        return size;
-    size -= result;
-    offset %= BITS_PER_LONG;
-    if ( offset )
-    {
-        tmp = *(p++);
-        tmp |= ~0UL >> (BITS_PER_LONG - offset);
-        if ( size < BITS_PER_LONG )
-            goto found_first;
-        if ( ~tmp )
-            goto found_middle;
-        size -= BITS_PER_LONG;
-        result += BITS_PER_LONG;
-    }
-    while ( size & ~(BITS_PER_LONG - 1) )
-    {
-        if ( ~(tmp = *(p++)) )
-            goto found_middle;
-        result += BITS_PER_LONG;
-        size -= BITS_PER_LONG;
-    }
-    if ( !size )
-        return result;
-    tmp = *p;
-
- found_first:
-    tmp |= ~0UL << size;
-    if ( tmp == ~0UL )        /* Are any bits zero? */
-        return result + size; /* Nope. */
- found_middle:
-    return result + ffz(tmp);
-}
-
 #endif /* _ASM_PPC_BITOPS_H */
diff --git a/xen/include/xen/bitops.h b/xen/include/xen/bitops.h
index 2cb7892bcc..e3c5a4ccf3 100644
--- a/xen/include/xen/bitops.h
+++ b/xen/include/xen/bitops.h
@@ -105,6 +105,54 @@ static inline int generic_flsl(unsigned long x)
  */
 #include <asm/bitops.h>
 
+#ifndef find_next_bit
+/**
+ * find_next_bit - find the next set bit in a memory region
+ * @addr: The address to base the search on
+ * @offset: The bitnumber to start searching at
+ * @size: The bitmap size in bits
+ */
+extern unsigned long find_next_bit(const unsigned long *addr,
+                                   unsigned long size,
+                                   unsigned long offset);
+#endif
+
+#ifndef find_next_zero_bit
+/**
+ * find_next_zero_bit - find the next cleared bit in a memory region
+ * @addr: The address to base the search on
+ * @offset: The bitnumber to start searching at
+ * @size: The bitmap size in bits
+ */
+extern unsigned long find_next_zero_bit(const unsigned long *addr,
+                                        unsigned long size,
+                                        unsigned long offset);
+#endif
+
+#ifndef find_first_bit
+/**
+ * find_first_bit - find the first set bit in a memory region
+ * @addr: The address to start the search at
+ * @size: The maximum size to search
+ *
+ * Returns the bit number of the first set bit.
+ */
+extern unsigned long find_first_bit(const unsigned long *addr,
+                                    unsigned long size);
+#endif
+
+#ifndef find_first_zero_bit
+/**
+ * find_first_zero_bit - find the first cleared bit in a memory region
+ * @addr: The address to start the search at
+ * @size: The maximum size to search
+ *
+ * Returns the bit number of the first cleared bit.
+ */
+extern unsigned long find_first_zero_bit(const unsigned long *addr,
+                                         unsigned long size);
+#endif
+
 #if BITS_PER_LONG == 64
 # define fls64 flsl
 # define ffs64 ffsl
diff --git a/xen/lib/Makefile b/xen/lib/Makefile
index 2d9ebb945f..e63798e1d4 100644
--- a/xen/lib/Makefile
+++ b/xen/lib/Makefile
@@ -3,6 +3,7 @@ obj-$(CONFIG_X86) += x86/
 lib-y += bsearch.o
 lib-y += ctors.o
 lib-y += ctype.o
+lib-y += find-next-bit.o
 lib-y += list-sort.o
 lib-y += memchr.o
 lib-y += memchr_inv.o
diff --git a/xen/lib/find-next-bit.c b/xen/lib/find-next-bit.c
new file mode 100644
index 0000000000..ca6f82277e
--- /dev/null
+++ b/xen/lib/find-next-bit.c
@@ -0,0 +1,281 @@
+/* find_next_bit.c: fallback find next bit implementation
+ *
+ * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
+ * Written by David Howells (dhowells@redhat.com)
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ */
+#include <xen/bitops.h>
+
+#include <asm/byteorder.h>
+
+#ifndef find_next_bit
+/*
+ * Find the next set bit in a memory region.
+ */
+unsigned long find_next_bit(const unsigned long *addr, unsigned long size,
+			    unsigned long offset)
+{
+	const unsigned long *p = addr + BIT_WORD(offset);
+	unsigned long result = offset & ~(BITS_PER_LONG-1);
+	unsigned long tmp;
+
+	if (offset >= size)
+		return size;
+	size -= result;
+	offset %= BITS_PER_LONG;
+	if (offset) {
+		tmp = *(p++);
+		tmp &= (~0UL << offset);
+		if (size < BITS_PER_LONG)
+			goto found_first;
+		if (tmp)
+			goto found_middle;
+		size -= BITS_PER_LONG;
+		result += BITS_PER_LONG;
+	}
+	while (size & ~(BITS_PER_LONG-1)) {
+		if ((tmp = *(p++)))
+			goto found_middle;
+		result += BITS_PER_LONG;
+		size -= BITS_PER_LONG;
+	}
+	if (!size)
+		return result;
+	tmp = *p;
+
+found_first:
+	tmp &= (~0UL >> (BITS_PER_LONG - size));
+	if (tmp == 0UL)		/* Are any bits set? */
+		return result + size;	/* Nope. */
+found_middle:
+	return result + __ffs(tmp);
+}
+EXPORT_SYMBOL(find_next_bit);
+#endif
+
+#ifndef find_next_zero_bit
+/*
+ * This implementation of find_{first,next}_zero_bit was stolen from
+ * Linus' asm-alpha/bitops.h.
+ */
+unsigned long find_next_zero_bit(const unsigned long *addr, unsigned long size,
+				 unsigned long offset)
+{
+	const unsigned long *p = addr + BIT_WORD(offset);
+	unsigned long result = offset & ~(BITS_PER_LONG-1);
+	unsigned long tmp;
+
+	if (offset >= size)
+		return size;
+	size -= result;
+	offset %= BITS_PER_LONG;
+	if (offset) {
+		tmp = *(p++);
+		tmp |= ~0UL >> (BITS_PER_LONG - offset);
+		if (size < BITS_PER_LONG)
+			goto found_first;
+		if (~tmp)
+			goto found_middle;
+		size -= BITS_PER_LONG;
+		result += BITS_PER_LONG;
+	}
+	while (size & ~(BITS_PER_LONG-1)) {
+		if (~(tmp = *(p++)))
+			goto found_middle;
+		result += BITS_PER_LONG;
+		size -= BITS_PER_LONG;
+	}
+	if (!size)
+		return result;
+	tmp = *p;
+
+found_first:
+	tmp |= ~0UL << size;
+	if (tmp == ~0UL)	/* Are any bits zero? */
+		return result + size;	/* Nope. */
+found_middle:
+	return result + ffz(tmp);
+}
+EXPORT_SYMBOL(find_next_zero_bit);
+#endif
+
+#ifndef find_first_bit
+/*
+ * Find the first set bit in a memory region.
+ */
+unsigned long find_first_bit(const unsigned long *addr, unsigned long size)
+{
+	const unsigned long *p = addr;
+	unsigned long result = 0;
+	unsigned long tmp;
+
+	while (size & ~(BITS_PER_LONG-1)) {
+		if ((tmp = *(p++)))
+			goto found;
+		result += BITS_PER_LONG;
+		size -= BITS_PER_LONG;
+	}
+	if (!size)
+		return result;
+
+	tmp = (*p) & (~0UL >> (BITS_PER_LONG - size));
+	if (tmp == 0UL)		/* Are any bits set? */
+		return result + size;	/* Nope. */
+found:
+	return result + __ffs(tmp);
+}
+EXPORT_SYMBOL(find_first_bit);
+#endif
+
+#ifndef find_first_zero_bit
+/*
+ * Find the first cleared bit in a memory region.
+ */
+unsigned long find_first_zero_bit(const unsigned long *addr, unsigned long size)
+{
+	const unsigned long *p = addr;
+	unsigned long result = 0;
+	unsigned long tmp;
+
+	while (size & ~(BITS_PER_LONG-1)) {
+		if (~(tmp = *(p++)))
+			goto found;
+		result += BITS_PER_LONG;
+		size -= BITS_PER_LONG;
+	}
+	if (!size)
+		return result;
+
+	tmp = (*p) | (~0UL << size);
+	if (tmp == ~0UL)	/* Are any bits zero? */
+		return result + size;	/* Nope. */
+found:
+	return result + ffz(tmp);
+}
+EXPORT_SYMBOL(find_first_zero_bit);
+#endif
+
+#ifdef __BIG_ENDIAN
+
+/* include/linux/byteorder does not support "unsigned long" type */
+static inline unsigned long ext2_swabp(const unsigned long * x)
+{
+#if BITS_PER_LONG == 64
+	return (unsigned long) __swab64p((u64 *) x);
+#elif BITS_PER_LONG == 32
+	return (unsigned long) __swab32p((u32 *) x);
+#else
+#error BITS_PER_LONG not defined
+#endif
+}
+
+/* include/linux/byteorder doesn't support "unsigned long" type */
+static inline unsigned long ext2_swab(const unsigned long y)
+{
+#if BITS_PER_LONG == 64
+	return (unsigned long) __swab64((u64) y);
+#elif BITS_PER_LONG == 32
+	return (unsigned long) __swab32((u32) y);
+#else
+#error BITS_PER_LONG not defined
+#endif
+}
+
+#ifndef find_next_zero_bit_le
+unsigned long find_next_zero_bit_le(const void *addr, unsigned
+		long size, unsigned long offset)
+{
+	const unsigned long *p = addr;
+	unsigned long result = offset & ~(BITS_PER_LONG - 1);
+	unsigned long tmp;
+
+	if (offset >= size)
+		return size;
+	p += BIT_WORD(offset);
+	size -= result;
+	offset &= (BITS_PER_LONG - 1UL);
+	if (offset) {
+		tmp = ext2_swabp(p++);
+		tmp |= (~0UL >> (BITS_PER_LONG - offset));
+		if (size < BITS_PER_LONG)
+			goto found_first;
+		if (~tmp)
+			goto found_middle;
+		size -= BITS_PER_LONG;
+		result += BITS_PER_LONG;
+	}
+
+	while (size & ~(BITS_PER_LONG - 1)) {
+		if (~(tmp = *(p++)))
+			goto found_middle_swap;
+		result += BITS_PER_LONG;
+		size -= BITS_PER_LONG;
+	}
+	if (!size)
+		return result;
+	tmp = ext2_swabp(p);
+found_first:
+	tmp |= ~0UL << size;
+	if (tmp == ~0UL)	/* Are any bits zero? */
+		return result + size; /* Nope. Skip ffz */
+found_middle:
+	return result + ffz(tmp);
+
+found_middle_swap:
+	return result + ffz(ext2_swab(tmp));
+}
+EXPORT_SYMBOL(find_next_zero_bit_le);
+#endif
+
+#ifndef find_next_bit_le
+unsigned long find_next_bit_le(const void *addr, unsigned
+		long size, unsigned long offset)
+{
+	const unsigned long *p = addr;
+	unsigned long result = offset & ~(BITS_PER_LONG - 1);
+	unsigned long tmp;
+
+	if (offset >= size)
+		return size;
+	p += BIT_WORD(offset);
+	size -= result;
+	offset &= (BITS_PER_LONG - 1UL);
+	if (offset) {
+		tmp = ext2_swabp(p++);
+		tmp &= (~0UL << offset);
+		if (size < BITS_PER_LONG)
+			goto found_first;
+		if (tmp)
+			goto found_middle;
+		size -= BITS_PER_LONG;
+		result += BITS_PER_LONG;
+	}
+
+	while (size & ~(BITS_PER_LONG - 1)) {
+		tmp = *(p++);
+		if (tmp)
+			goto found_middle_swap;
+		result += BITS_PER_LONG;
+		size -= BITS_PER_LONG;
+	}
+	if (!size)
+		return result;
+	tmp = ext2_swabp(p);
+found_first:
+	tmp &= (~0UL >> (BITS_PER_LONG - size));
+	if (tmp == 0UL)		/* Are any bits set? */
+		return result + size; /* Nope. */
+found_middle:
+	return result + __ffs(tmp);
+
+found_middle_swap:
+	return result + __ffs(ext2_swab(tmp));
+}
+EXPORT_SYMBOL(find_next_bit_le);
+#endif
+
+#endif /* __BIG_ENDIAN */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:25:05 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:25:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687108.1070010 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgPJ-0005dP-Ad; Thu, 29 Feb 2024 13:25:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687108.1070010; Thu, 29 Feb 2024 13:25:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgPJ-0005dH-7I; Thu, 29 Feb 2024 13:25:05 +0000
Received: by outflank-mailman (input) for mailman id 687108;
 Thu, 29 Feb 2024 13:25:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgPI-0005d1-41
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:25:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgPI-0004w2-3I
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:25:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgPI-0004NN-2i
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:25:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=vb8LSHTD186DEBDzDGzikXslb36J8ukP0dyN2CGz2pk=; b=5aHfJ4D5d1vgzlTtrkwdPHwZND
	0KIuAeehu2nRcivA6KuFXN7wdfvdbii+lSbSXa5R/FbtOd6JGFRYRJPDEnsPTyVdBHeg9zgu6l6V0
	G+49BZefTDbRpHTnRSFhGcrSS61xd8KkS5NyWuAil+ByxuGacjmdXx6rGp46+NhSskXw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: Fix arm32 build failure when early printk is enabled
Message-Id: <E1rfgPI-0004NN-2i@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:25:04 +0000

commit b2b3d40f9a030ba79ce3abadccb5da485af33589
Author:     Michal Orzel <michal.orzel@amd.com>
AuthorDate: Wed Feb 28 11:35:55 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Wed Feb 28 11:56:47 2024 +0000

    xen/arm: Fix arm32 build failure when early printk is enabled
    
    Commit 0441c3acc7e9 forgot to rename FIXMAP_CONSOLE to FIX_CONSOLE in
    TEMPORARY_EARLY_UART_VIRTUAL_ADDRESS macro. This results in a build
    failure on arm32, when early printk is enabled:
    arch/arm/arm32/mmu/head.S:311: Error: invalid operands (*UND* and *ABS* sections) for `*'
    
    Fixes: 0441c3acc7e9 ("xen/arm: fixmap: Rename the fixmap slots to follow the x86 convention")
    Signed-off-by: Michal Orzel <michal.orzel@amd.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/include/asm/early_printk.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/include/asm/early_printk.h b/xen/arch/arm/include/asm/early_printk.h
index f444e89a86..46a5e562dd 100644
--- a/xen/arch/arm/include/asm/early_printk.h
+++ b/xen/arch/arm/include/asm/early_printk.h
@@ -20,7 +20,7 @@
     (FIXMAP_ADDR(FIX_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
 
 #define TEMPORARY_EARLY_UART_VIRTUAL_ADDRESS \
-    (TEMPORARY_FIXMAP_ADDR(FIXMAP_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
+    (TEMPORARY_FIXMAP_ADDR(FIX_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
 
 #endif /* !CONFIG_EARLY_PRINTK */
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 13:25:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 13:25:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687109.1070011 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgPT-0005ga-BE; Thu, 29 Feb 2024 13:25:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687109.1070011; Thu, 29 Feb 2024 13:25:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfgPT-0005gS-8c; Thu, 29 Feb 2024 13:25:15 +0000
Received: by outflank-mailman (input) for mailman id 687109;
 Thu, 29 Feb 2024 13:25:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgPS-0005gI-6i
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:25:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgPS-0004wG-61
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:25:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfgPS-0004Nm-5N
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 13:25:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ksuJN4FMF+wKbRpCRet+BxW/OpR7BZg/9ra3PUZM5lI=; b=wbAudEMKVsAyEDqqsGjQS/6Ok/
	H4oI9oVdwa2TmkDIFRpYvs06RirPzf+vPnZrkqz9IRRuZB1ucUjOLCOB3zyFzO4k7LZ+2E5YLdPE2
	zH0iGGHbEYL6yuaCExQkvzbnFuz+Q++KF6dOpBiJ4XzcubmZD8zcWMJhPW3Gr/2YWroE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86: Resync intel-family.h from Linux
Message-Id: <E1rfgPS-0004Nm-5N@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 13:25:14 +0000

commit 195e75371b13c4f7ecdf7b5c50aed0d02f2d7ce8
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Feb 27 16:07:39 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed Feb 28 13:25:04 2024 +0000

    x86: Resync intel-family.h from Linux
    
    From v6.8-rc6
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/include/asm/intel-family.h | 38 +++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/include/asm/intel-family.h b/xen/arch/x86/include/asm/intel-family.h
index ffc49151be..b65e9c46b9 100644
--- a/xen/arch/x86/include/asm/intel-family.h
+++ b/xen/arch/x86/include/asm/intel-family.h
@@ -26,6 +26,9 @@
  *		_G	- parts with extra graphics on
  *		_X	- regular server parts
  *		_D	- micro server parts
+ *		_N,_P	- other mobile parts
+ *		_H	- premium mobile parts
+ *		_S	- other client parts
  *
  *		Historical OPTDIFFs:
  *
@@ -37,6 +40,9 @@
  * their own names :-(
  */
 
+/* Wildcard match for FAM6 so X86_MATCH_INTEL_FAM6_MODEL(ANY) works */
+#define INTEL_FAM6_ANY			X86_MODEL_ANY
+
 #define INTEL_FAM6_CORE_YONAH		0x0E
 
 #define INTEL_FAM6_CORE2_MEROM		0x0F
@@ -93,8 +99,6 @@
 #define INTEL_FAM6_ICELAKE_L		0x7E	/* Sunny Cove */
 #define INTEL_FAM6_ICELAKE_NNPI		0x9D	/* Sunny Cove */
 
-#define INTEL_FAM6_LAKEFIELD		0x8A	/* Sunny Cove / Tremont */
-
 #define INTEL_FAM6_ROCKETLAKE		0xA7	/* Cypress Cove */
 
 #define INTEL_FAM6_TIGERLAKE_L		0x8C	/* Willow Cove */
@@ -102,12 +106,31 @@
 
 #define INTEL_FAM6_SAPPHIRERAPIDS_X	0x8F	/* Golden Cove */
 
+#define INTEL_FAM6_EMERALDRAPIDS_X	0xCF
+
+#define INTEL_FAM6_GRANITERAPIDS_X	0xAD
+#define INTEL_FAM6_GRANITERAPIDS_D	0xAE
+
+/* "Hybrid" Processors (P-Core/E-Core) */
+
+#define INTEL_FAM6_LAKEFIELD		0x8A	/* Sunny Cove / Tremont */
+
 #define INTEL_FAM6_ALDERLAKE		0x97	/* Golden Cove / Gracemont */
 #define INTEL_FAM6_ALDERLAKE_L		0x9A	/* Golden Cove / Gracemont */
 
-#define INTEL_FAM6_RAPTORLAKE		0xB7
+#define INTEL_FAM6_RAPTORLAKE		0xB7	/* Raptor Cove / Enhanced Gracemont */
+#define INTEL_FAM6_RAPTORLAKE_P		0xBA
+#define INTEL_FAM6_RAPTORLAKE_S		0xBF
+
+#define INTEL_FAM6_METEORLAKE		0xAC
+#define INTEL_FAM6_METEORLAKE_L		0xAA
+
+#define INTEL_FAM6_ARROWLAKE_H		0xC5
+#define INTEL_FAM6_ARROWLAKE		0xC6
+
+#define INTEL_FAM6_LUNARLAKE_M		0xBD
 
-/* "Small Core" Processors (Atom) */
+/* "Small Core" Processors (Atom/E-Core) */
 
 #define INTEL_FAM6_ATOM_BONNELL		0x1C /* Diamondville, Pineview */
 #define INTEL_FAM6_ATOM_BONNELL_MID	0x26 /* Silverthorne, Lincroft */
@@ -134,6 +157,13 @@
 #define INTEL_FAM6_ATOM_TREMONT		0x96 /* Elkhart Lake */
 #define INTEL_FAM6_ATOM_TREMONT_L	0x9C /* Jasper Lake */
 
+#define INTEL_FAM6_ATOM_GRACEMONT	0xBE /* Alderlake N */
+
+#define INTEL_FAM6_ATOM_CRESTMONT_X	0xAF /* Sierra Forest */
+#define INTEL_FAM6_ATOM_CRESTMONT	0xB6 /* Grand Ridge */
+
+#define INTEL_FAM6_ATOM_DARKMONT_X	0xDD /* Clearwater Forest */
+
 /* Xeon Phi */
 
 #define INTEL_FAM6_XEON_PHI_KNL		0x57 /* Knights Landing */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 16:11:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 16:11:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687270.1070478 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfizx-0004Yu-78; Thu, 29 Feb 2024 16:11:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687270.1070478; Thu, 29 Feb 2024 16:11:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfizx-0004Yf-2k; Thu, 29 Feb 2024 16:11:05 +0000
Received: by outflank-mailman (input) for mailman id 687270;
 Thu, 29 Feb 2024 16:11:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfizv-0004XM-UK
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfizv-0000e7-Jt
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfizv-0005km-IX
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=uyAKgSNTuu7Zb8hf24ZLRcNoS7vaS73m/+y5Dh8/xkk=; b=R8gH0l65CXg/YbJNN45qPBbPUL
	vXIbZjwJCoKz/CFaJK3pUQHOpD0boUjfWVakt+KWcomj7oY0tuLTiq4odM1TsN4qHf0J5kFMw4jS1
	0P6Rn7K+udRDM6TpKkNdoUgJCH0GjY23Z4EZO4XNqb7nhbP7FNSQJs2F6sQ1m+/9a8v4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/riscv: introduce nospec.h
Message-Id: <E1rfizv-0005km-IX@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 16:11:03 +0000

commit 7159164beeb582cb57a3142744d747daae7d59b9
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Thu Feb 29 16:58:34 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 29 16:58:34 2024 +0100

    xen/riscv: introduce nospec.h
    
    From the unpriviliged doc:
      No standard hints are presently defined.
      We anticipate standard hints to eventually include memory-system spatial
      and temporal locality hints, branch prediction hints, thread-scheduling
      hints, security tags, and instrumentation flags for simulation/emulation.
    
    Also, there are no speculation execution barriers.
    
    Therefore, functions evaluate_nospec() and block_speculation() should
    remain empty until a specific platform has an extension to deal with
    speculation execution.
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/riscv/include/asm/nospec.h | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/xen/arch/riscv/include/asm/nospec.h b/xen/arch/riscv/include/asm/nospec.h
new file mode 100644
index 0000000000..e30f0a781b
--- /dev/null
+++ b/xen/arch/riscv/include/asm/nospec.h
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/* Copyright (C) 2024 Vates */
+
+#ifndef _ASM_RISCV_NOSPEC_H
+#define _ASM_RISCV_NOSPEC_H
+
+static inline bool evaluate_nospec(bool condition)
+{
+    return condition;
+}
+
+static inline void block_speculation(void)
+{
+}
+
+#endif /* _ASM_RISCV_NOSPEC_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 16:11:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 16:11:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687273.1070480 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfj07-0004hf-6v; Thu, 29 Feb 2024 16:11:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687273.1070480; Thu, 29 Feb 2024 16:11:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfj07-0004hX-48; Thu, 29 Feb 2024 16:11:15 +0000
Received: by outflank-mailman (input) for mailman id 687273;
 Thu, 29 Feb 2024 16:11:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj05-0004hD-OU
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj05-0000eQ-NH
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj05-0005lR-M1
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=VZczUCA3+J6Fw1jkgvIGN0KKOVhnzEIrsXZEidGHr3c=; b=Y5ucjmakBgzrcVAJDsvfgqnYV1
	ZtjW8zmF38uvSzCMRYUBLGXn7rbkgKYXE7cDDd7EIhDZ0tgQ6wH+ovovGNrgRyvqsPR51h7BDDGZW
	8DQTz5Y3puNCCTlp8C9FgP+lpIzLBY6Avojn5Xs7goGAHigFhNsZ5XQ0yCkaqnt6F/dk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] config: update Mini-OS commit
Message-Id: <E1rfj05-0005lR-M1@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 16:11:13 +0000

commit 90c0b97e27fa1ab309fa36096c050464bfb4c5f7
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 29 13:48:25 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 29 16:59:46 2024 +0100

    config: update Mini-OS commit
    
    Update the Mini-OS upstream revision.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 Config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Config.mk b/Config.mk
index 6f6e0425ba..a962f095ca 100644
--- a/Config.mk
+++ b/Config.mk
@@ -224,7 +224,7 @@ QEMU_UPSTREAM_URL ?= https://xenbits.xen.org/git-http/qemu-xen.git
 QEMU_UPSTREAM_REVISION ?= master
 
 MINIOS_UPSTREAM_URL ?= https://xenbits.xen.org/git-http/mini-os.git
-MINIOS_UPSTREAM_REVISION ?= 2bc8dbb9b6111113d27455cbca318ea337309c04
+MINIOS_UPSTREAM_REVISION ?= b6a5b4d72b88e5c4faed01f5a44505de022860fc
 
 SEABIOS_UPSTREAM_URL ?= https://xenbits.xen.org/git-http/seabios.git
 SEABIOS_UPSTREAM_REVISION ?= rel-1.16.3
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 16:11:25 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 16:11:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687274.1070484 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfj0H-0004mV-8H; Thu, 29 Feb 2024 16:11:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687274.1070484; Thu, 29 Feb 2024 16:11:25 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfj0H-0004mN-5a; Thu, 29 Feb 2024 16:11:25 +0000
Received: by outflank-mailman (input) for mailman id 687274;
 Thu, 29 Feb 2024 16:11:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj0F-0004mF-R3
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj0F-0000es-QK
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj0F-0005lz-PN
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=QfrcdUrsYWXJG8Cp/bbNFSEQvP9H88hK6rZSKbidDBA=; b=A1O2mlEzWcF5fpEb4Z7f4eii19
	QxmDScBrbgJP20LSVEbJXDb7L/WSLs4MI5OG7eq7a7376D/n4HL9z5FI8pBMouoljdNfHy7TowABs
	5vtpHDTDxoR8VkVZP1bt9bufNm2OMXsjPdTG7u9HjaZPfuLfnBMGzYOAoymilt/wZgas=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] stubdom: extend xenstore stubdom configs
Message-Id: <E1rfj0F-0005lz-PN@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 16:11:23 +0000

commit 254c6f787cd18929d674c5dd5f3f564a4bb51c72
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 29 13:48:26 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 29 16:59:59 2024 +0100

    stubdom: extend xenstore stubdom configs
    
    Extend the config files of the Xenstore stubdoms to include XENBUS
    and 9PFRONT items in order to support file based logging.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 stubdom/xenstore-minios.cfg    | 2 +-
 stubdom/xenstorepvh-minios.cfg | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/stubdom/xenstore-minios.cfg b/stubdom/xenstore-minios.cfg
index a41704bb6b..239da519b9 100644
--- a/stubdom/xenstore-minios.cfg
+++ b/stubdom/xenstore-minios.cfg
@@ -3,7 +3,7 @@ CONFIG_NETFRONT=n
 CONFIG_FBFRONT=n
 CONFIG_KBDFRONT=n
 CONFIG_CONSFRONT=n
-CONFIG_XENBUS=n
 CONFIG_LWIP=n
+CONFIG_9PFRONT=y
 CONFIG_BALLOON=y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
diff --git a/stubdom/xenstorepvh-minios.cfg b/stubdom/xenstorepvh-minios.cfg
index 6af51f5753..752b90d7d3 100644
--- a/stubdom/xenstorepvh-minios.cfg
+++ b/stubdom/xenstorepvh-minios.cfg
@@ -4,7 +4,7 @@ CONFIG_NETFRONT=n
 CONFIG_FBFRONT=n
 CONFIG_KBDFRONT=n
 CONFIG_CONSFRONT=n
-CONFIG_XENBUS=n
 CONFIG_LWIP=n
+CONFIG_9PFRONT=y
 CONFIG_BALLOON=y
 XEN_INTERFACE_VERSION=__XEN_LATEST_INTERFACE_VERSION__
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 16:11:35 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 16:11:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687275.1070488 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfj0R-0004u2-9T; Thu, 29 Feb 2024 16:11:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687275.1070488; Thu, 29 Feb 2024 16:11:35 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfj0R-0004tu-6y; Thu, 29 Feb 2024 16:11:35 +0000
Received: by outflank-mailman (input) for mailman id 687275;
 Thu, 29 Feb 2024 16:11:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj0P-0004tf-UF
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj0P-0000f1-TS
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj0P-0005mO-SX
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=KpZ02U1/ALpIbwo98gD92Ku+pbRtD3krxaXU5agJqb0=; b=5dRSesZG4u6Z3Bx9wCPihbPAGV
	sxZT2Juop5JmDFKiUuBHtkJ+tZOcff0i6HHYGVyrcCCOJ5PZXQxH0+i7CKjuYwccMEn7UBMQpx3xF
	0f7S12g5fcbBMoFeAk3mHXsFv0zxBHwcPtDZNAEMw2P9jVSAWx1xocEJLnS5eNZk/5bE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xenstored: mount 9pfs device in stubdom
Message-Id: <E1rfj0P-0005mO-SX@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 16:11:33 +0000

commit 0a999849c82e9e3c060280cc6c3362f86d96cf26
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 29 13:48:27 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 29 17:00:04 2024 +0100

    tools/xenstored: mount 9pfs device in stubdom
    
    Mount the 9pfs device in stubdom enabling it to use files.
    
    This has to happen in a worker thread in order to allow the main thread
    handling the required Xenstore accesses in parallel.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstored/core.h   |  6 ++++++
 tools/xenstored/domain.c |  2 ++
 tools/xenstored/minios.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 62 insertions(+)

diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index f6af086f01..fe0ee90581 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -36,6 +36,8 @@
 #include "list.h"
 #include "hashtable.h"
 
+#define XENSTORE_LIB_DIR	XEN_LIB_DIR "/xenstore"
+
 #ifndef O_CLOEXEC
 #define O_CLOEXEC 0
 /* O_CLOEXEC support is needed for Live Update in the daemon case. */
@@ -399,6 +401,10 @@ void handle_special_fds(void);
 int get_socket_fd(void);
 void set_socket_fd(int fd);
 
+#ifdef __MINIOS__
+void mount_9pfs(void);
+#endif
+
 /* Close stdin/stdout/stderr to complete daemonize */
 void finish_daemonize(void);
 
diff --git a/tools/xenstored/domain.c b/tools/xenstored/domain.c
index 1a7d5e9756..64c8fd0cc3 100644
--- a/tools/xenstored/domain.c
+++ b/tools/xenstored/domain.c
@@ -1236,6 +1236,8 @@ void stubdom_init(void)
 		barf_perror("Failed to initialize stubdom");
 
 	xenevtchn_notify(xce_handle, stubdom->port);
+
+	mount_9pfs();
 #endif
 }
 
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index 22ac8defbd..562a9b4972 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -17,10 +17,20 @@
 */
 #include <sys/types.h>
 #include <sys/mman.h>
+#include <syslog.h>
+#include "talloc.h"
 #include "core.h"
 #include "utils.h"
 #include <xen/grant_table.h>
 #include <mini-os/lib.h>
+#include <mini-os/9pfront.h>
+#include <mini-os/sched.h>
+#include <mini-os/xenbus.h>
+#include <mini-os/xmalloc.h>
+
+#define P9_STATE_PATH	"device/9pfs/0/state"
+
+static void *p9_device;
 
 void finish_daemonize(void)
 {
@@ -74,3 +84,47 @@ int get_socket_fd(void)
 void set_socket_fd(int fd)
 {
 }
+
+static void mount_thread(void *p)
+{
+	xenbus_event_queue events = NULL;
+	char *err;
+	char *dummy;
+
+	err = xenbus_watch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs", &events);
+	if (err) {
+		log("error \"%s\" when setting watch on \"%s\"\n", err,
+		    P9_STATE_PATH);
+		free(err);
+		return;
+	}
+
+	for (;;) {
+		xenbus_wait_for_watch(&events);
+
+		/*
+		 * We only care for existence of the state node.
+		 * State changes are handled in init_9pfront().
+		 */
+		err = xenbus_read(XBT_NIL, P9_STATE_PATH, &dummy);
+		if (!err)
+			break;
+		free(err);
+	}
+
+	free(dummy);
+
+	err = xenbus_unwatch_path_token(XBT_NIL, P9_STATE_PATH, "9pfs");
+	if (err) {
+		log("error \"%s\" when unwatching \"%s\", leaking watch\n",
+		    err, P9_STATE_PATH);
+		free(err);
+	}
+
+	p9_device = init_9pfront(0, XENSTORE_LIB_DIR);
+}
+
+void mount_9pfs(void)
+{
+	create_thread("mount-9pfs", mount_thread, NULL);
+}
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 16:11:45 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 16:11:45 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687276.1070491 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfj0b-000506-Ap; Thu, 29 Feb 2024 16:11:45 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687276.1070491; Thu, 29 Feb 2024 16:11:45 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfj0b-0004zz-8M; Thu, 29 Feb 2024 16:11:45 +0000
Received: by outflank-mailman (input) for mailman id 687276;
 Thu, 29 Feb 2024 16:11:44 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj0a-0004yR-15
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:44 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj0a-0000fF-0O
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:44 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj0Z-0005mt-Vv
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=E74cFv1Yes/essFppPr6JnW4Cdg+nsg2nbA6b3z8P/E=; b=ktkq+SUGIO171gJ68h8tODAl1H
	aLt3CodCb6ebV0y7ATfgGdRyyJwcPiebTi2m77G+gtQB7v7XkkwBMyOyI4kdZzMvZL0hHBVa/4BvV
	f4BAro4OADIxsFlYPtpeoKQs+PaVrLZaj5BdyKWRJlR1cXhIHY3r5/Eou77C2BpDcLmc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xenstored: add helpers for filename handling
Message-Id: <E1rfj0Z-0005mt-Vv@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 16:11:43 +0000

commit 2a750fcf7de5d39d1144e9db3bde8a91a3829e4a
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 29 13:48:28 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 29 17:00:09 2024 +0100

    tools/xenstored: add helpers for filename handling
    
    Add some helpers for handling filenames which might need different
    implementations between stubdom and daemon environments:
    
    - expansion of relative filenames (those are not really defined today,
      just expand them to be relative to /var/lib/xen/xenstore)
    - expansion of xenstore_daemon_rundir() (used e.g. for saving the state
      file in case of live update - needs to be unchanged in the daemon
      case, but should result in /var/lib/xen/xenstore for stubdom)
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstored/core.c      | 15 +++++++++++++--
 tools/xenstored/core.h      |  5 ++++-
 tools/xenstored/lu_daemon.c |  4 ++--
 tools/xenstored/minios.c    |  5 +++++
 tools/xenstored/posix.c     |  8 +++++++-
 5 files changed, 31 insertions(+), 6 deletions(-)

diff --git a/tools/xenstored/core.c b/tools/xenstored/core.c
index 48fc787ac1..bada1ad9a2 100644
--- a/tools/xenstored/core.c
+++ b/tools/xenstored/core.c
@@ -63,7 +63,7 @@ char **orig_argv;
 LIST_HEAD(connections);
 int tracefd = -1;
 bool keep_orphans = false;
-char *tracefile = NULL;
+const char *tracefile = NULL;
 static struct hashtable *nodes;
 unsigned int trace_flags = TRACE_OBJ | TRACE_IO;
 
@@ -137,6 +137,17 @@ void trace_destroy(const void *data, const char *type)
 		trace("obj: DESTROY %s %p\n", type, data);
 }
 
+/*
+ * Return an absolute filename.
+ * In case of a relative filename given as input, prepend XENSTORE_LIB_DIR.
+ */
+const char *absolute_filename(const void *ctx, const char *filename)
+{
+	if (filename[0] != '/')
+		return talloc_asprintf(ctx, XENSTORE_LIB_DIR "/%s", filename);
+	return talloc_strdup(ctx, filename);
+}
+
 void close_log(void)
 {
 	if (tracefd >= 0)
@@ -2759,7 +2770,7 @@ int main(int argc, char *argv[])
 #endif
 
 	if (tracefile)
-		tracefile = talloc_strdup(NULL, tracefile);
+		tracefile = absolute_filename(NULL, tracefile);
 
 #ifndef NO_LIVE_UPDATE
 	/* Read state in case of live update. */
diff --git a/tools/xenstored/core.h b/tools/xenstored/core.h
index fe0ee90581..e58779e88c 100644
--- a/tools/xenstored/core.h
+++ b/tools/xenstored/core.h
@@ -341,7 +341,7 @@ void close_log(void);
 extern int orig_argc;
 extern char **orig_argv;
 
-extern char *tracefile;
+extern const char *tracefile;
 extern int tracefd;
 
 /* Trace flag values must be kept in sync with trace_switches[] contents. */
@@ -405,6 +405,9 @@ void set_socket_fd(int fd);
 void mount_9pfs(void);
 #endif
 
+const char *xenstore_rundir(void);
+const char *absolute_filename(const void *ctx, const char *filename);
+
 /* Close stdin/stdout/stderr to complete daemonize */
 void finish_daemonize(void);
 
diff --git a/tools/xenstored/lu_daemon.c b/tools/xenstored/lu_daemon.c
index 71bcabadd3..6351111ab0 100644
--- a/tools/xenstored/lu_daemon.c
+++ b/tools/xenstored/lu_daemon.c
@@ -24,7 +24,7 @@ void lu_get_dump_state(struct lu_dump_state *state)
 	state->size = 0;
 
 	state->filename = talloc_asprintf(NULL, "%s/state_dump",
-					  xenstore_daemon_rundir());
+					  xenstore_rundir());
 	if (!state->filename)
 		barf("Allocation failure");
 
@@ -65,7 +65,7 @@ FILE *lu_dump_open(const void *ctx)
 	int fd;
 
 	filename = talloc_asprintf(ctx, "%s/state_dump",
-				   xenstore_daemon_rundir());
+				   xenstore_rundir());
 	if (!filename)
 		return NULL;
 
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index 562a9b4972..e70386f8c7 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -128,3 +128,8 @@ void mount_9pfs(void)
 {
 	create_thread("mount-9pfs", mount_thread, NULL);
 }
+
+const char *xenstore_rundir(void)
+{
+	return XENSTORE_LIB_DIR;
+}
diff --git a/tools/xenstored/posix.c b/tools/xenstored/posix.c
index 496329dfd1..d88c82d972 100644
--- a/tools/xenstored/posix.c
+++ b/tools/xenstored/posix.c
@@ -326,9 +326,10 @@ void early_init(bool live_update, bool dofork, const char *pidfile)
 {
 	reopen_log();
 
-	/* Make sure xenstored directory exists. */
+	/* Make sure xenstored directories exist. */
 	/* Errors ignored here, will be reported when we open files */
 	mkdir(xenstore_daemon_rundir(), 0755);
+	mkdir(XENSTORE_LIB_DIR, 0755);
 
 	if (dofork) {
 		openlog("xenstored", 0, LOG_DAEMON);
@@ -406,3 +407,8 @@ void set_socket_fd(int fd)
 {
 	sock = fd;
 }
+
+const char *xenstore_rundir(void)
+{
+	return xenstore_daemon_rundir();
+}
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 16:11:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 16:11:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687277.1070496 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfj0k-00056I-Dt; Thu, 29 Feb 2024 16:11:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687277.1070496; Thu, 29 Feb 2024 16:11:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfj0k-00056B-B8; Thu, 29 Feb 2024 16:11:54 +0000
Received: by outflank-mailman (input) for mailman id 687277;
 Thu, 29 Feb 2024 16:11:54 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj0k-000565-47
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:54 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj0k-0000fV-3K
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:54 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj0k-0005nT-2Y
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:11:54 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=3q76p6qlvTQF8yt2jKkNDHkW8ULNU4XXsQehHDOHoI8=; b=B5yEZs2MKcJL1DRCT5bg7MPZm6
	hy4sJ3MwyHO301097TgQI3SM2/5n0QiOBkiamp8O+XAs4PFD3H+JL8W6Q+bob1FWW5A5aipMjCywz
	kQ/zQu1Y2TpfkLewDRdfxgSxQx7wTZxMhOW4ODcgJSihJK8Pw2FbZRXT0MxFbOzFV9F8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xenstored: support complete log capabilities in stubdom
Message-Id: <E1rfj0k-0005nT-2Y@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 16:11:54 +0000

commit 8937d44628f79e0aa6b6a392fe9a18b2efcd9f4c
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 29 13:48:29 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 29 17:00:14 2024 +0100

    tools/xenstored: support complete log capabilities in stubdom
    
    With 9pfs being fully available in Xenstore-stubdom now, there is no
    reason to not fully support all logging capabilities in stubdom.
    
    Open the logfile on stubdom only after the 9pfs file system has been
    mounted.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
    Acked-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/hotplug/Linux/init.d/sysconfig.xencommons.in |  1 -
 tools/hotplug/Linux/launch-xenstore.in             |  1 +
 tools/xenstored/control.c                          | 30 +++++++++++-----------
 tools/xenstored/minios.c                           |  3 +++
 4 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
index 433e4849af..1bdd830d8a 100644
--- a/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
+++ b/tools/hotplug/Linux/init.d/sysconfig.xencommons.in
@@ -58,7 +58,6 @@ XENSTORED_ARGS=
 ## Default: Not defined, tracing off
 #
 # Log xenstored messages
-# Only evaluated if XENSTORETYPE is "daemon".
 #XENSTORED_TRACE=[yes|on|1]
 
 ## Type: integer
diff --git a/tools/hotplug/Linux/launch-xenstore.in b/tools/hotplug/Linux/launch-xenstore.in
index e854ca1eb8..da4eeca7c5 100644
--- a/tools/hotplug/Linux/launch-xenstore.in
+++ b/tools/hotplug/Linux/launch-xenstore.in
@@ -98,6 +98,7 @@ test -f @CONFIG_DIR@/@CONFIG_LEAF_DIR@/xencommons && . @CONFIG_DIR@/@CONFIG_LEAF
 	[ -z "$XENSTORE_DOMAIN_SIZE" ] && XENSTORE_DOMAIN_SIZE=8
 	XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS --memory $XENSTORE_DOMAIN_SIZE"
 	[ -z "$XENSTORE_MAX_DOMAIN_SIZE" ] || XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS --maxmem $XENSTORE_MAX_DOMAIN_SIZE"
+	[ -z "$XENSTORED_TRACE" ] || XENSTORE_DOMAIN_ARGS="$XENSTORE_DOMAIN_ARGS -T xenstored-trace.log"
 
 	echo -n Starting $XENSTORE_DOMAIN_KERNEL...
 	${LIBEXEC_BIN}/init-xenstore-domain $XENSTORE_DOMAIN_ARGS || exit 1
diff --git a/tools/xenstored/control.c b/tools/xenstored/control.c
index b2f64d674f..dae23a5ac0 100644
--- a/tools/xenstored/control.c
+++ b/tools/xenstored/control.c
@@ -201,19 +201,6 @@ static int do_control_quota_s(const void *ctx, struct connection *conn,
 	return EINVAL;
 }
 
-#ifdef __MINIOS__
-static int do_control_memreport(const void *ctx, struct connection *conn,
-				const char **vec, int num)
-{
-	if (num)
-		return EINVAL;
-
-	talloc_report_full(NULL, stdout);
-
-	send_ack(conn, XS_CONTROL);
-	return 0;
-}
-#else
 static int do_control_logfile(const void *ctx, struct connection *conn,
 			      const char **vec, int num)
 {
@@ -222,13 +209,26 @@ static int do_control_logfile(const void *ctx, struct connection *conn,
 
 	close_log();
 	talloc_free(tracefile);
-	tracefile = talloc_strdup(NULL, vec[0]);
+	tracefile = absolute_filename(NULL, vec[0]);
 	reopen_log();
 
 	send_ack(conn, XS_CONTROL);
 	return 0;
 }
 
+#ifdef __MINIOS__
+static int do_control_memreport(const void *ctx, struct connection *conn,
+				const char **vec, int num)
+{
+	if (num)
+		return EINVAL;
+
+	talloc_report_full(NULL, stdout);
+
+	send_ack(conn, XS_CONTROL);
+	return 0;
+}
+#else
 static int do_control_memreport(const void *ctx, struct connection *conn,
 				const char **vec, int num)
 {
@@ -309,10 +309,10 @@ static struct cmd_s cmds[] = {
 		"[-c <cmdline>] [-F] [-t <timeout>] <file>\n"
 		"    Default timeout is 60 seconds.", 5 },
 #endif
+	{ "logfile", do_control_logfile, "<file>" },
 #ifdef __MINIOS__
 	{ "memreport", do_control_memreport, "" },
 #else
-	{ "logfile", do_control_logfile, "<file>" },
 	{ "memreport", do_control_memreport, "[<file>]" },
 #endif
 	{ "print", do_control_print, "<string>" },
diff --git a/tools/xenstored/minios.c b/tools/xenstored/minios.c
index e70386f8c7..a229954cf4 100644
--- a/tools/xenstored/minios.c
+++ b/tools/xenstored/minios.c
@@ -122,6 +122,9 @@ static void mount_thread(void *p)
 	}
 
 	p9_device = init_9pfront(0, XENSTORE_LIB_DIR);
+
+	/* Start logging if selected. */
+	reopen_log();
 }
 
 void mount_9pfs(void)
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 16:12:05 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 16:12:05 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687278.1070500 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfj0v-0005Cs-G1; Thu, 29 Feb 2024 16:12:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687278.1070500; Thu, 29 Feb 2024 16:12:05 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfj0v-0005Ck-D1; Thu, 29 Feb 2024 16:12:05 +0000
Received: by outflank-mailman (input) for mailman id 687278;
 Thu, 29 Feb 2024 16:12:04 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj0u-0005CU-7M
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:12:04 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj0u-0000g8-6b
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:12:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj0u-0005oZ-5R
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:12:04 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=FUEsK/xXDNAgyBoai520g4iDwwJ31V82gSqCRAbA0m8=; b=VdETgRW2jdMzht4+BAAP6050bG
	MrlGeOggTq0eoa/AvYLc+3k14cyMVAxs+99m6eFnKrg39T63r4f0ZkJCLUEC4Vj+HO62pgu3o9HVb
	DwWlWDSTR3C1Brb+T+4eO0ZrgSrDrsyXnDjhc8t1NXALBoPzw8rhu+dNaP+eMAzP2w3I=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xenstored: have a single do_control_memreport()
Message-Id: <E1rfj0u-0005oZ-5R@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 16:12:04 +0000

commit d388673d1ba849de6a7a9a135901ea73db2fcf7a
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Thu Feb 29 13:48:30 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 29 17:00:19 2024 +0100

    tools/xenstored: have a single do_control_memreport()
    
    With 9pfs now available in Xenstore-stubdom, there is no reason to
    have distinct do_control_memreport() variants for the daemon and the
    stubdom implementations.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 tools/xenstored/control.c | 27 +++++++--------------------
 1 file changed, 7 insertions(+), 20 deletions(-)

diff --git a/tools/xenstored/control.c b/tools/xenstored/control.c
index dae23a5ac0..9561289179 100644
--- a/tools/xenstored/control.c
+++ b/tools/xenstored/control.c
@@ -216,23 +216,11 @@ static int do_control_logfile(const void *ctx, struct connection *conn,
 	return 0;
 }
 
-#ifdef __MINIOS__
-static int do_control_memreport(const void *ctx, struct connection *conn,
-				const char **vec, int num)
-{
-	if (num)
-		return EINVAL;
-
-	talloc_report_full(NULL, stdout);
-
-	send_ack(conn, XS_CONTROL);
-	return 0;
-}
-#else
 static int do_control_memreport(const void *ctx, struct connection *conn,
 				const char **vec, int num)
 {
 	FILE *fp;
+	const char *filename;
 	int fd;
 
 	if (num > 1)
@@ -255,8 +243,12 @@ static int do_control_memreport(const void *ctx, struct connection *conn,
 			if (!fp)
 				close(fd);
 		}
-	} else
-		fp = fopen(vec[0], "a");
+	} else {
+		filename = absolute_filename(ctx, vec[0]);
+		if (!filename)
+			return ENOMEM;
+		fp = fopen(filename, "a");
+	}
 
 	if (!fp)
 		return EBADF;
@@ -267,7 +259,6 @@ static int do_control_memreport(const void *ctx, struct connection *conn,
 	send_ack(conn, XS_CONTROL);
 	return 0;
 }
-#endif
 
 static int do_control_print(const void *ctx, struct connection *conn,
 			    const char **vec, int num)
@@ -310,11 +301,7 @@ static struct cmd_s cmds[] = {
 		"    Default timeout is 60 seconds.", 5 },
 #endif
 	{ "logfile", do_control_logfile, "<file>" },
-#ifdef __MINIOS__
-	{ "memreport", do_control_memreport, "" },
-#else
 	{ "memreport", do_control_memreport, "[<file>]" },
-#endif
 	{ "print", do_control_print, "<string>" },
 	{ "quota", do_control_quota,
 		"[set <name> <val>|<domid>|max [-r]]" },
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 16:12:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 16:12:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687279.1070503 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfj15-0005Gv-HI; Thu, 29 Feb 2024 16:12:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687279.1070503; Thu, 29 Feb 2024 16:12:15 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfj15-0005Gp-ES; Thu, 29 Feb 2024 16:12:15 +0000
Received: by outflank-mailman (input) for mailman id 687279;
 Thu, 29 Feb 2024 16:12:14 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj14-0005GO-AP
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:12:14 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj14-0000gL-9d
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:12:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfj14-0005qV-8j
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 16:12:14 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ApM2Sy7QUc5Dksk6jRuWW1hq81crSxqVBv50/RDJtaw=; b=bQ9jwkUfA66WYQgKH9z6xtt1eg
	cgLughJSX0hVllhK7A9ylrkg67v9XKwvjZJHnsJMTuA35vNoMbaLt/v2aPas+U2jaT88Ua0ulXtfj
	BhKD4Z8ga5cyCfH3jz+dLVhwbFpvpn1hkZ0Kikc/OGuQxl9lssg5HEAyO3Bnc+45VUpE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] pci: fix locking around vPCI removal in pci_remove_device()
Message-Id: <E1rfj14-0005qV-8j@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 16:12:14 +0000

commit 635dd1120a01961a39dce6ad3f09692681379378
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Thu Feb 29 17:00:40 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Feb 29 17:00:40 2024 +0100

    pci: fix locking around vPCI removal in pci_remove_device()
    
    Currently vpci_deassign_device() is called without holding the per-domain
    pci_lock in pci_remove_device(), which leads to:
    
    Assertion 'rw_is_write_locked(&pdev->domain->pci_lock)' failed at ../drivers/vpci/vpci.c:47
    [...]
    Xen call trace:
       [<ffff82d040260eac>] R vpci_deassign_device+0x10d/0x1b9
       [<ffff82d04027932f>] S pci_remove_device+0x2b1/0x380
       [<ffff82d040260bd0>] F pci_physdev_op+0x197/0x19e
       [<ffff82d04032272d>] F do_physdev_op+0x342/0x12aa
       [<ffff82d0402f067a>] F pv_hypercall+0x58e/0x62b
       [<ffff82d0402012ba>] F lstar_enter+0x13a/0x140
    
    Move the existing block that removes the device from the domain pdev_list ahead
    and also issue the call to vpci_deassign_device() there.  It's fine to remove
    the device from the domain list of assigned devices, as further functions only
    care that the pdev domain field is correctly set to the owner of the device
    about to be removed.
    
    Moving the vpci_deassign_device() past the pci_cleanup_msi() call can be
    dangerous, as doing the MSI cleanup ahead of having removed the vPCI handlers
    could lead to stale data in vPCI MSI(-X) internal structures.
    
    Fixes: 4f78438b45e2 ('vpci: use per-domain PCI lock to protect vpci structure')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
---
 xen/drivers/passthrough/pci.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 4c0a836486..194701c913 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -817,15 +817,15 @@ int pci_remove_device(u16 seg, u8 bus, u8 devfn)
     list_for_each_entry ( pdev, &pseg->alldevs_list, alldevs_list )
         if ( pdev->bus == bus && pdev->devfn == devfn )
         {
-            vpci_deassign_device(pdev);
-            pci_cleanup_msi(pdev);
-            ret = iommu_remove_device(pdev);
             if ( pdev->domain )
             {
                 write_lock(&pdev->domain->pci_lock);
+                vpci_deassign_device(pdev);
                 list_del(&pdev->domain_list);
                 write_unlock(&pdev->domain->pci_lock);
             }
+            pci_cleanup_msi(pdev);
+            ret = iommu_remove_device(pdev);
             printk(XENLOG_DEBUG "PCI remove device %pp\n", &pdev->sbdf);
             free_pdev(pseg, pdev);
             break;
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 17:33:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 17:33:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687379.1070768 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfkHH-0003DT-92; Thu, 29 Feb 2024 17:33:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687379.1070768; Thu, 29 Feb 2024 17:33:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfkHH-0003DL-6D; Thu, 29 Feb 2024 17:33:03 +0000
Received: by outflank-mailman (input) for mailman id 687379;
 Thu, 29 Feb 2024 17:33:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfkHG-0003DD-AL
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 17:33:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfkHG-0002GA-7M
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 17:33:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfkHG-0005K2-4i
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 17:33:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=B8vNGXPI3SEMrQdgNgl6mCKQxsQBuMFji5133CpDk8o=; b=yCx08Nj3fI1OXqAwENZXE5Lqkd
	N3aAcrn/NBXjtOEfVOG/qN7rciA04XMTnwHr9MRfO4rKTUMRia4mljyvo63hFnRqKeJrERmNxwnW1
	Hx+WesQN6tXWINkb4aEPJDaewAXU6jtTEK5jpxXsTGNve6RenzZuRcVPAaePQEEFWr4A=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] xen/arm: Fix UBSAN failure in start_xen()
Message-Id: <E1rfkHG-0005K2-4i@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 17:33:02 +0000

commit 498b3624d0ecc1267773e6482fd0b732e90c4511
Author:     Michal Orzel <michal.orzel@amd.com>
AuthorDate: Thu Feb 8 11:43:39 2024 +0100
Commit:     Stefano Stabellini <stefano.stabellini@amd.com>
CommitDate: Wed Feb 28 14:43:26 2024 -0800

    xen/arm: Fix UBSAN failure in start_xen()
    
    When running Xen on arm32, in scenario where Xen is loaded at an address
    such as boot_phys_offset >= 2GB, UBSAN reports the following:
    
    (XEN) UBSAN: Undefined behaviour in arch/arm/setup.c:739:58
    (XEN) pointer operation underflowed 00200000 to 86800000
    (XEN) Xen WARN at common/ubsan/ubsan.c:172
    (XEN) ----[ Xen-4.19-unstable  arm32  debug=y ubsan=y  Not tainted ]----
    ...
    (XEN) Xen call trace:
    (XEN)    [<0031b4c0>] ubsan.c#ubsan_epilogue+0x18/0xf0 (PC)
    (XEN)    [<0031d134>] __ubsan_handle_pointer_overflow+0xb8/0xd4 (LR)
    (XEN)    [<0031d134>] __ubsan_handle_pointer_overflow+0xb8/0xd4
    (XEN)    [<004d15a8>] start_xen+0xe0/0xbe0
    (XEN)    [<0020007c>] head.o#primary_switched+0x4/0x30
    
    The failure is reported for the following line:
    (paddr_t)(uintptr_t)(_start + boot_phys_offset)
    
    This occurs because the compiler treats (ptr + size) with size bigger than
    PTRDIFF_MAX as undefined behavior. To address this, switch to macro
    virt_to_maddr(), given the future plans to eliminate boot_phys_offset.
    
    Signed-off-by: Michal Orzel <michal.orzel@amd.com>
    Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
    Tested-by: Luca Fancellu <luca.fancellu@arm.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    (cherry picked from commit e11f5766503c0ff074b4e0f888bbfc931518a169)
---
 xen/arch/arm/setup.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index db748839d3..2ccdde5277 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -1109,7 +1109,7 @@ void __init start_xen(unsigned long boot_phys_offset,
 
     /* Register Xen's load address as a boot module. */
     xen_bootmodule = add_boot_module(BOOTMOD_XEN,
-                             (paddr_t)(uintptr_t)(_start + boot_phys_offset),
+                             virt_to_maddr(_start),
                              (paddr_t)(uintptr_t)(_end - _start), false);
     BUG_ON(!xen_bootmodule);
 
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.18


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 23:33:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 23:33:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687465.1070961 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfptg-0001Aa-AU; Thu, 29 Feb 2024 23:33:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687465.1070961; Thu, 29 Feb 2024 23:33:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfptg-0001AT-7l; Thu, 29 Feb 2024 23:33:04 +0000
Received: by outflank-mailman (input) for mailman id 687465;
 Thu, 29 Feb 2024 23:33:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfptf-0001AN-8b
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 23:33:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfptf-0000J8-6b
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 23:33:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfptf-0007G0-59
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 23:33:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=4PeRWvPsGVijDRmiUeM1EmA0KAUWNDXS/xMDSmGdh7U=; b=tiTxvWoM9l/Ga4lY8S2xBnBxl8
	htqKiE668BdUn/C2mmP4zMMvPM573JkN5xx1kV4O1h8w+7XiHg34wNLKnIjAyEJyuOQbuBAJR6yda
	MtzIbw0psM64tm0dm4GgixK1Cu9efeM1FTj02G5i4xHiopeFmpdCeG0WI2gI2XKcUid8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] automation/eclair: fully deviate MISRA C:2012 Rules 5.7 and 18.7
Message-Id: <E1rfptf-0007G0-59@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 23:33:03 +0000

commit b87697fc1a6fbc3f2e1570af5a58e36a42c333cf
Author:     Federico Serafini <federico.serafini@bugseng.com>
AuthorDate: Fri Feb 23 10:06:59 2024 +0100
Commit:     Stefano Stabellini <stefano.stabellini@amd.com>
CommitDate: Thu Feb 29 15:23:31 2024 -0800

    automation/eclair: fully deviate MISRA C:2012 Rules 5.7 and 18.7
    
    Update ECLAIR configuration to fully deviate Rules 5.7 and 18.7
    as agreed during MISRA meeetings.
    
    Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
 automation/eclair_analysis/ECLAIR/deviations.ecl | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl b/automation/eclair_analysis/ECLAIR/deviations.ecl
index fd32ff8a9c..02eae39786 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -107,6 +107,11 @@ number of guest paging levels."
 -config=MC3R1.R5.6,reports+={deliberate,"any_area(any_loc(file(adopted_r5_6)))"}
 -doc_end
 
+-doc_begin="The project intentionally reuses tag names in order to have identifiers matching the applicable external specifications as well as established internal conventions.
+As there is little possibility for developer confusion not resulting into compilation errors, the risk of renaming outweighs the potential advantages of compliance."
+-config=MC3R1.R5.7,reports+={deliberate,"any()"}
+-doc_end
+
 #
 # Series 7.
 #
@@ -373,6 +378,15 @@ explicit comment indicating the fallthrough intention is present."
 -config=MC3R1.R16.3,reports+={safe, "any_area(end_loc(any_exp(text(^(?s).*/\\* [fF]all ?through.? \\*/.*$,0..1))))"}
 -doc_end
 
+#
+# Series 18.
+#
+
+-doc_begin="Flexible array members are deliberately used and XEN developers are aware of the dangers related to them:
+unexpected result when the structure is given as argument to a sizeof() operator and the truncation in assignment between structures."
+-config=MC3R1.R18.7,reports+={deliberate, "any()"}
+-doc_end
+
 #
 # Series 20.
 #
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 23:33:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 23:33:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687466.1070965 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfptq-0001CP-CL; Thu, 29 Feb 2024 23:33:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687466.1070965; Thu, 29 Feb 2024 23:33:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfptq-0001CH-9G; Thu, 29 Feb 2024 23:33:14 +0000
Received: by outflank-mailman (input) for mailman id 687466;
 Thu, 29 Feb 2024 23:33:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfptp-0001Bz-Es
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 23:33:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfptp-0000JF-Di
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 23:33:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfptp-0007GX-8j
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 23:33:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=nRFh3BLJzXMZFIIYuJhcqYr0JRRpktL/Kqn9F1lSOfQ=; b=gZDxKAijs1mt5tmcu+KDvRXgHz
	WxHwd38yhwryOXDzXkGZKZfYMTh5BBBjbnhLUPcE0XtsqTZHU+CyoISxdiL6qgM5ZED1rdeFXG34+
	UQ9vMM/MLV1iBwN5PEV4xKaD8k5SJ+Ws57nxRk+lU8U1fGJh9rTnxQbOnDs+m+LlvhKs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] automation/eclair: tag MISRA C:2012 Rule 8.2 as clean
Message-Id: <E1rfptp-0007GX-8j@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 23:33:13 +0000

commit e1de3a0536c6b0de86d4e7e262903143d0f7c95c
Author:     Federico Serafini <federico.serafini@bugseng.com>
AuthorDate: Fri Feb 23 10:07:00 2024 +0100
Commit:     Stefano Stabellini <stefano.stabellini@amd.com>
CommitDate: Thu Feb 29 15:23:31 2024 -0800

    automation/eclair: tag MISRA C:2012 Rule 8.2 as clean
    
    Update ECLAIR configuration to consider Rule 8.2 as clean.
    
    Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 automation/eclair_analysis/ECLAIR/tagging.ecl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/automation/eclair_analysis/ECLAIR/tagging.ecl b/automation/eclair_analysis/ECLAIR/tagging.ecl
index 900c532196..a1dea32b21 100644
--- a/automation/eclair_analysis/ECLAIR/tagging.ecl
+++ b/automation/eclair_analysis/ECLAIR/tagging.ecl
@@ -30,7 +30,7 @@
 
 -doc_begin="Clean guidelines: new violations for these guidelines are not accepted."
 
--service_selector={clean_guidelines_common,"MC3R1.D1.1||MC3R1.D2.1||MC3R1.D4.11||MC3R1.D4.14||MC3R1.R1.1||MC3R1.R1.3||MC3R1.R1.4||MC3R1.R2.2||MC3R1.R3.1||MC3R1.R3.2||MC3R1.R4.1||MC3R1.R4.2||MC3R1.R5.1||MC3R1.R5.2||MC3R1.R5.4||MC3R1.R5.6||MC3R1.R6.1||MC3R1.R6.2||MC3R1.R7.1||MC3R1.R8.1||MC3R1.R8.5||MC3R1.R8.6||MC3R1.R8.8||MC3R1.R8.10||MC3R1.R8.12||MC3R1.R8.14||MC3R1.R9.2||MC3R1.R9.4||MC3R1.R9.5||MC3R1.R12.5||MC3R1.R17.3||MC3R1.R17.4||MC3R1.R17.6||MC3R1.R20.13||MC3R1.R20.14||MC3R1.R21.13||MC3R1.R21.19||MC3R1.R21.21||MC3R1.R22.2||MC3R1.R22.4||MC3R1.R22.5||MC3R1.R22.6"
+-service_selector={clean_guidelines_common,"MC3R1.D1.1||MC3R1.D2.1||MC3R1.D4.11||MC3R1.D4.14||MC3R1.R1.1||MC3R1.R1.3||MC3R1.R1.4||MC3R1.R2.2||MC3R1.R3.1||MC3R1.R3.2||MC3R1.R4.1||MC3R1.R4.2||MC3R1.R5.1||MC3R1.R5.2||MC3R1.R5.4||MC3R1.R5.6||MC3R1.R6.1||MC3R1.R6.2||MC3R1.R7.1||MC3R1.R8.1||MC3R1.R8.2||MC3R1.R8.5||MC3R1.R8.6||MC3R1.R8.8||MC3R1.R8.10||MC3R1.R8.12||MC3R1.R8.14||MC3R1.R9.2||MC3R1.R9.4||MC3R1.R9.5||MC3R1.R12.5||MC3R1.R17.3||MC3R1.R17.4||MC3R1.R17.6||MC3R1.R20.13||MC3R1.R20.14||MC3R1.R21.13||MC3R1.R21.19||MC3R1.R21.21||MC3R1.R22.2||MC3R1.R22.4||MC3R1.R22.5||MC3R1.R22.6"
 }
 
 -setq=target,getenv("XEN_TARGET_ARCH")
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu Feb 29 23:33:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 29 Feb 2024 23:33:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.687467.1070970 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfpu0-0001Go-Dd; Thu, 29 Feb 2024 23:33:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 687467.1070970; Thu, 29 Feb 2024 23:33:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rfpu0-0001Gg-Aj; Thu, 29 Feb 2024 23:33:24 +0000
Received: by outflank-mailman (input) for mailman id 687467;
 Thu, 29 Feb 2024 23:33:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfptz-0001GT-He
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 23:33:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfptz-0000JQ-Gb
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 23:33:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rfptz-0007Gy-Fl
 for xen-changelog@lists.xenproject.org; Thu, 29 Feb 2024 23:33:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ZJQ8IYqGPNH2yXpvxWXyncm9+Ort5Ujd5WMna7+EAmw=; b=AycQrK66Vuq6EnYKliu5pBgecz
	iWkFjmIDN7SfCbJMG9WE5twhUv/Hiw0K6C3TwAwHdZsKHuP+KQ5XXfCGqYPIBgZ70oyIlPCnQcEsz
	89JW+a9PHRuxVCxGN9E5KD3vTDmoCvKil0JLE+YULsVuGz9nn7E5s7YouZ/XVkcpCevs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] docs/misra/rules.rst: add rule 16.6 and 20.12
Message-Id: <E1rfptz-0007Gy-Fl@xenbits.xenproject.org>
Date: Thu, 29 Feb 2024 23:33:23 +0000

commit 4cac80e22600d5a38d77c65e9a6507c752efc155
Author:     Stefano Stabellini <stefano.stabellini@amd.com>
AuthorDate: Tue Feb 13 14:33:32 2024 -0800
Commit:     Stefano Stabellini <stefano.stabellini@amd.com>
CommitDate: Thu Feb 29 15:24:39 2024 -0800

    docs/misra/rules.rst: add rule 16.6 and 20.12
    
    Signed-off-by: Stefano Stabellini <stefano.stabellini@amd.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 docs/misra/rules.rst | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst
index 182331089d..c185366966 100644
--- a/docs/misra/rules.rst
+++ b/docs/misra/rules.rst
@@ -478,6 +478,12 @@ maintainers if you want to suggest a change.
        adhere to Rule 16.2 would result in increased complexity and
        maintenance difficulty, and could potentially introduce bugs. 
 
+   * - `Rule 16.6 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_16_06.c>`_
+     - Required
+     - Every switch statement shall have at least two switch-clauses
+     - Single-clause switches are allowed when they do not involve a
+       default label.
+
    * - `Rule 16.7 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_16_07.c>`_
      - Required
      - A switch-expression shall not have essentially Boolean type
@@ -554,6 +560,13 @@ maintainers if you want to suggest a change.
        evaluation
      -
 
+   * - `Rule 20.12 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_20_12.c>`_
+     - A macro parameter used as an operand to the # or ## operators,
+       which is itself subject to further macro replacement, shall only
+       be used as an operand to these operators
+     - Required
+     - Variadic macros are allowed to violate the rule.
+
    * - `Rule 20.13 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_20_13.c>`_
      - Required
      - A line whose first token is # shall be a valid preprocessing
--
generated by git-patchbot for /home/xen/git/xen.git#staging


