From xen-changelog-bounces@lists.xenproject.org Mon May 02 06:55:10 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 02 May 2022 06:55:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.318658.538513 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nlPxa-0001Al-Cp; Mon, 02 May 2022 06:55:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 318658.538513; Mon, 02 May 2022 06: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 1nlPxa-0001Ad-9m; Mon, 02 May 2022 06:55:06 +0000
Received: by outflank-mailman (input) for mailman id 318658;
 Mon, 02 May 2022 06: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 1nlPxZ-0001AS-1p
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 06: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 1nlPxY-0002ck-WF
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 06:55:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nlPxY-0006jZ-V6
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 06: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=YLnSq5pbvjgFUCbPENpJmw69TLXnzw0u7OayL2ZS0Q4=; b=QXXzX0RLkaE+V1d3lun1LgXhL2
	ObL8OmyUTJeUVBY531dQ37JQDeCNjWb0XyLZboHlG+8RaWJC9ricl2Mo93x1IXdUgBQ3sgo6RKewD
	GS1VbwUYiaF5RJ4d514ss7A0/cozSTIyb/Oomb6gOo2Q24mA/FxNVqInWhbKGXC9fSk8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] IOMMU/x86: disallow device assignment to PoD guests
Message-Id: <E1nlPxY-0006jZ-V6@xenbits.xenproject.org>
Date: Mon, 02 May 2022 06:55:04 +0000

commit ad4312d764e8b40a1e45b64aac6d840a60c59f13
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon May 2 08:48:02 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon May 2 08:48:02 2022 +0200

    IOMMU/x86: disallow device assignment to PoD guests
    
    While it is okay for IOMMU page tables to be set up for guests starting
    in PoD mode, actual device assignment may only occur once all PoD
    entries have been removed from the P2M. So far this was enforced only
    for boot-time assignment, and only in the tool stack.
    
    Also use the new function to replace p2m_pod_entry_count(): Its unlocked
    access to p2m->pod.entry_count wasn't really okay (irrespective of the
    result being stale by the time the caller gets to see it). Nor was the
    use of that function in line with the immediately preceding comment: A
    PoD guest isn't just one with a non-zero entry count, but also one with
    a non-empty cache (e.g. prior to actually launching the guest).
    
    To allow the tool stack to see a consistent snapshot of PoD state, move
    the tail of XENMEM_{get,set}_pod_target handling into a function, adding
    proper locking there.
    
    In libxl take the liberty to use the new local variable r also for a
    pre-existing call into libxc.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/include/asm/p2m.h      | 21 +++++++++---------
 xen/arch/x86/mm.c                   |  6 +-----
 xen/arch/x86/mm/p2m-pod.c           | 43 ++++++++++++++++++++++++++++++++++++-
 xen/common/vm_event.c               |  2 +-
 xen/drivers/passthrough/x86/iommu.c |  3 ++-
 5 files changed, 57 insertions(+), 18 deletions(-)

diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h
index 6f14e7b46d..0a0f7114f3 100644
--- a/xen/arch/x86/include/asm/p2m.h
+++ b/xen/arch/x86/include/asm/p2m.h
@@ -701,6 +701,12 @@ int p2m_pod_empty_cache(struct domain *d);
  * domain matches target */
 int p2m_pod_set_mem_target(struct domain *d, unsigned long target);
 
+/* Obtain a consistent snapshot of PoD related domain state. */
+void p2m_pod_get_mem_target(const struct domain *d, xen_pod_target_t *target);
+
+/* Check whether PoD is (still) active in a domain. */
+bool p2m_pod_active(const struct domain *d);
+
 /* Scan pod cache when offline/broken page triggered */
 int
 p2m_pod_offline_or_broken_hit(struct page_info *p);
@@ -709,11 +715,6 @@ p2m_pod_offline_or_broken_hit(struct page_info *p);
 void
 p2m_pod_offline_or_broken_replace(struct page_info *p);
 
-static inline long p2m_pod_entry_count(const struct p2m_domain *p2m)
-{
-    return p2m->pod.entry_count;
-}
-
 #else
 
 static inline bool
@@ -727,6 +728,11 @@ static inline int p2m_pod_empty_cache(struct domain *d)
     return 0;
 }
 
+static inline bool p2m_pod_active(const struct domain *d)
+{
+    return false;
+}
+
 static inline int p2m_pod_offline_or_broken_hit(struct page_info *p)
 {
     return 0;
@@ -737,11 +743,6 @@ static inline void p2m_pod_offline_or_broken_replace(struct page_info *p)
     ASSERT_UNREACHABLE();
 }
 
-static inline long p2m_pod_entry_count(const struct p2m_domain *p2m)
-{
-    return 0;
-}
-
 #endif
 
 
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 74fa9205f4..67c0427963 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -4804,7 +4804,6 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
     {
         xen_pod_target_t target;
         struct domain *d;
-        struct p2m_domain *p2m;
 
         if ( copy_from_guest(&target, arg, 1) )
             return -EFAULT;
@@ -4835,10 +4834,7 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         }
         else if ( rc >= 0 )
         {
-            p2m = p2m_get_hostp2m(d);
-            target.tot_pages       = domain_tot_pages(d);
-            target.pod_cache_pages = p2m->pod.count;
-            target.pod_entries     = p2m->pod.entry_count;
+            p2m_pod_get_mem_target(d, &target);
 
             if ( __copy_to_guest(arg, &target, 1) )
                 rc = -EFAULT;
diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index fd12f8ca73..fc110506dc 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -20,6 +20,7 @@
  */
 
 #include <xen/event.h>
+#include <xen/iocap.h>
 #include <xen/ioreq.h>
 #include <xen/mm.h>
 #include <xen/sched.h>
@@ -360,7 +361,10 @@ p2m_pod_set_mem_target(struct domain *d, unsigned long target)
 
     ASSERT( pod_target >= p2m->pod.count );
 
-    ret = p2m_pod_set_cache_target(p2m, pod_target, 1/*preemptible*/);
+    if ( has_arch_pdevs(d) || cache_flush_permitted(d) )
+        ret = -ENOTEMPTY;
+    else
+        ret = p2m_pod_set_cache_target(p2m, pod_target, 1/*preemptible*/);
 
 out:
     pod_unlock(p2m);
@@ -368,6 +372,23 @@ out:
     return ret;
 }
 
+void p2m_pod_get_mem_target(const struct domain *d, xen_pod_target_t *target)
+{
+    struct p2m_domain *p2m = p2m_get_hostp2m(d);
+
+    ASSERT(is_hvm_domain(d));
+
+    pod_lock(p2m);
+    lock_page_alloc(p2m);
+
+    target->tot_pages       = domain_tot_pages(d);
+    target->pod_cache_pages = p2m->pod.count;
+    target->pod_entries     = p2m->pod.entry_count;
+
+    unlock_page_alloc(p2m);
+    pod_unlock(p2m);
+}
+
 int p2m_pod_empty_cache(struct domain *d)
 {
     struct p2m_domain *p2m = p2m_get_hostp2m(d);
@@ -1391,6 +1412,9 @@ guest_physmap_mark_populate_on_demand(struct domain *d, unsigned long gfn,
     if ( !paging_mode_translate(d) )
         return -EINVAL;
 
+    if ( has_arch_pdevs(d) || cache_flush_permitted(d) )
+        return -ENOTEMPTY;
+
     do {
         rc = mark_populate_on_demand(d, gfn, chunk_order);
 
@@ -1412,3 +1436,20 @@ void p2m_pod_init(struct p2m_domain *p2m)
     for ( i = 0; i < ARRAY_SIZE(p2m->pod.mrp.list); ++i )
         p2m->pod.mrp.list[i] = gfn_x(INVALID_GFN);
 }
+
+bool p2m_pod_active(const struct domain *d)
+{
+    struct p2m_domain *p2m;
+    bool res;
+
+    if ( !is_hvm_domain(d) )
+        return false;
+
+    p2m = p2m_get_hostp2m(d);
+
+    pod_lock(p2m);
+    res = p2m->pod.entry_count | p2m->pod.count;
+    pod_unlock(p2m);
+
+    return res;
+}
diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c
index 4a8f02893e..0b99a6ea72 100644
--- a/xen/common/vm_event.c
+++ b/xen/common/vm_event.c
@@ -655,7 +655,7 @@ int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec)
 
             rc = -EXDEV;
             /* Disallow paging in a PoD guest */
-            if ( p2m_pod_entry_count(p2m_get_hostp2m(d)) )
+            if ( p2m_pod_active(d) )
                 break;
 
             /* domain_pause() not required here, see XSA-99 */
diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c
index d5bf4d3241..616b66e755 100644
--- a/xen/drivers/passthrough/x86/iommu.c
+++ b/xen/drivers/passthrough/x86/iommu.c
@@ -513,11 +513,12 @@ bool arch_iommu_use_permitted(const struct domain *d)
 {
     /*
      * Prevent device assign if mem paging, mem sharing or log-dirty
-     * have been enabled for this domain.
+     * have been enabled for this domain, or if PoD is still in active use.
      */
     return d == dom_io ||
            (likely(!mem_sharing_enabled(d)) &&
             likely(!mem_paging_enabled(d)) &&
+            likely(!p2m_pod_active(d)) &&
             likely(!p2m_is_global_logdirty(d)));
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon May 02 06:55:16 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 02 May 2022 06:55:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.318659.538517 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nlPxk-0001DH-E8; Mon, 02 May 2022 06:55:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 318659.538517; Mon, 02 May 2022 06:55: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 1nlPxk-0001D9-BG; Mon, 02 May 2022 06:55:16 +0000
Received: by outflank-mailman (input) for mailman id 318659;
 Mon, 02 May 2022 06:55: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 1nlPxj-0001Cu-41
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 06:55: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 1nlPxj-0002co-3H
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 06:55:15 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nlPxj-0006kM-2M
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 06:55: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=ApKXFHA92MJvT0EMDU1TTlbMiS2M/Fpr2xVG9oq8YQA=; b=KQfExTzpcwgN7e0PmSd9ItO0fT
	CNEaIqWd3hLHQCdvjgp47Pw4z0tA6jfgsmwXvvNwhV/i49LSVONAVutAe7SfKwpPSVjfSmAHVaS6y
	5/SPyKly/nSFE26Sjk/upD/f53ultXYOSKHvv6vV9wZ0MdaD1my7++QiFQVDiTU5pZBM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/msr: handle reads to MSR_P5_MC_{ADDR,TYPE}
Message-Id: <E1nlPxj-0006kM-2M@xenbits.xenproject.org>
Date: Mon, 02 May 2022 06:55:15 +0000

commit ce59e472b581e4923f6892172dde62b88c8aa8b7
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon May 2 08:49:12 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon May 2 08:49:12 2022 +0200

    x86/msr: handle reads to MSR_P5_MC_{ADDR,TYPE}
    
    Windows Server 2019 Essentials will unconditionally attempt to read
    P5_MC_ADDR MSR at boot and throw a BSOD if injected a #GP.
    
    Fix this by mapping MSR_P5_MC_{ADDR,TYPE} to
    MSR_IA32_MCi_{ADDR,STATUS}, as reported also done by hardware in Intel
    SDM "Mapping of the Pentium Processor Machine-Check Errors to the
    Machine-Check Architecture" section.
    
    Reported-by: Steffen Einsle <einsle@phptrix.de>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/cpu/mcheck/mce.h        |  6 ++++++
 xen/arch/x86/cpu/mcheck/mce_intel.c  | 19 +++++++++++++++++++
 xen/arch/x86/cpu/mcheck/vmce.c       |  2 ++
 xen/arch/x86/include/asm/msr-index.h |  3 +++
 xen/arch/x86/msr.c                   |  2 ++
 5 files changed, 32 insertions(+)

diff --git a/xen/arch/x86/cpu/mcheck/mce.h b/xen/arch/x86/cpu/mcheck/mce.h
index 535d0abf8f..bea08bdc74 100644
--- a/xen/arch/x86/cpu/mcheck/mce.h
+++ b/xen/arch/x86/cpu/mcheck/mce.h
@@ -169,6 +169,12 @@ static inline int mce_vendor_bank_msr(const struct vcpu *v, uint32_t msr)
         if (msr >= MSR_IA32_MC0_CTL2 &&
             msr < MSR_IA32_MCx_CTL2(v->arch.vmce.mcg_cap & MCG_CAP_COUNT) )
             return 1;
+        fallthrough;
+
+    case X86_VENDOR_CENTAUR:
+    case X86_VENDOR_SHANGHAI:
+        if (msr == MSR_P5_MC_ADDR || msr == MSR_P5_MC_TYPE)
+            return 1;
         break;
 
     case X86_VENDOR_AMD:
diff --git a/xen/arch/x86/cpu/mcheck/mce_intel.c b/xen/arch/x86/cpu/mcheck/mce_intel.c
index 50198e0c29..28a605a5cb 100644
--- a/xen/arch/x86/cpu/mcheck/mce_intel.c
+++ b/xen/arch/x86/cpu/mcheck/mce_intel.c
@@ -1008,8 +1008,27 @@ int vmce_intel_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)
 
 int vmce_intel_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)
 {
+    const struct cpuid_policy *cp = v->domain->arch.cpuid;
     unsigned int bank = msr - MSR_IA32_MC0_CTL2;
 
+    switch ( msr )
+    {
+    case MSR_P5_MC_ADDR:
+        /*
+         * Bank 0 is used for the 'bank 0 quirk' on older processors.
+         * See vcpu_fill_mc_msrs() for reference.
+         */
+        *val = v->arch.vmce.bank[1].mci_addr;
+        return 1;
+
+    case MSR_P5_MC_TYPE:
+        *val = v->arch.vmce.bank[1].mci_status;
+        return 1;
+    }
+
+    if ( !(cp->x86_vendor & X86_VENDOR_INTEL) )
+        return 0;
+
     if ( bank < GUEST_MC_BANK_NUM )
     {
         *val = v->arch.vmce.bank[bank].mci_ctl2;
diff --git a/xen/arch/x86/cpu/mcheck/vmce.c b/xen/arch/x86/cpu/mcheck/vmce.c
index 458120f9ad..af30811afd 100644
--- a/xen/arch/x86/cpu/mcheck/vmce.c
+++ b/xen/arch/x86/cpu/mcheck/vmce.c
@@ -150,6 +150,8 @@ static int bank_mce_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)
     default:
         switch ( boot_cpu_data.x86_vendor )
         {
+        case X86_VENDOR_CENTAUR:
+        case X86_VENDOR_SHANGHAI:
         case X86_VENDOR_INTEL:
             ret = vmce_intel_rdmsr(v, msr, val);
             break;
diff --git a/xen/arch/x86/include/asm/msr-index.h b/xen/arch/x86/include/asm/msr-index.h
index 3e038db618..31964b88af 100644
--- a/xen/arch/x86/include/asm/msr-index.h
+++ b/xen/arch/x86/include/asm/msr-index.h
@@ -15,6 +15,9 @@
  * abbreviated name.  Exceptions will be considered on a case-by-case basis.
  */
 
+#define MSR_P5_MC_ADDR                      0
+#define MSR_P5_MC_TYPE                      0x00000001
+
 #define MSR_APIC_BASE                       0x0000001b
 #define  APIC_BASE_BSP                      (_AC(1, ULL) <<  8)
 #define  APIC_BASE_EXTD                     (_AC(1, ULL) << 10)
diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index 01a15857b7..6206529162 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -283,6 +283,8 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val)
         *val = msrs->misc_features_enables.raw;
         break;
 
+    case MSR_P5_MC_ADDR:
+    case MSR_P5_MC_TYPE:
     case MSR_IA32_MCG_CAP     ... MSR_IA32_MCG_CTL:      /* 0x179 -> 0x17b */
     case MSR_IA32_MCx_CTL2(0) ... MSR_IA32_MCx_CTL2(31): /* 0x280 -> 0x29f */
     case MSR_IA32_MCx_CTL(0)  ... MSR_IA32_MCx_MISC(31): /* 0x400 -> 0x47f */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon May 02 06:55:26 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 02 May 2022 06:55:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.318660.538521 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nlPxu-0001GN-FP; Mon, 02 May 2022 06:55:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 318660.538521; Mon, 02 May 2022 06:55: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 1nlPxu-0001GF-Ck; Mon, 02 May 2022 06:55:26 +0000
Received: by outflank-mailman (input) for mailman id 318660;
 Mon, 02 May 2022 06:55: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 1nlPxt-0001Fy-7D
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 06:55: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 1nlPxt-0002d8-6N
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 06:55:25 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nlPxt-0006lK-5P
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 06:55: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=3klTDmLkOa8CXM8GKSfu3NMvbmLSjRJHT3R3AyJphwg=; b=RA5Apd+w2FbVgvJqtd/LFQ8W3V
	+6F9SubB8P7DIpmaFEBiaUDuhaDyleCgIJfji1tD7PXRETnx5tGyil05zKsCybJT8fgtUabVdBUpk
	hSuxPjkTS0Tqoa4s42hXAEJU2HiMqaBWPdTfiG8bexHVoGBpc5uMYBOABNf0X9qN3OeE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] scripts/add_maintainers.pl: add -o as an alternative to --patchdir
Message-Id: <E1nlPxt-0006lK-5P@xenbits.xenproject.org>
Date: Mon, 02 May 2022 06:55:25 +0000

commit 3c245bc3a2f0597e2da2d5e12b5a9372c9360cea
Author:     Elliott Mitchell <ehem+xen@m5p.com>
AuthorDate: Mon May 2 08:50:02 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon May 2 08:50:02 2022 +0200

    scripts/add_maintainers.pl: add -o as an alternative to --patchdir
    
    This matches the output directory option used by `git format-patch`.  I
    suspect I'm not the only one who finds matching `git format-patch` more
    intuitive, than -d for directory.
    
    Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
---
 scripts/add_maintainers.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/add_maintainers.pl b/scripts/add_maintainers.pl
index 5a6d0f631b..380e8da22a 100755
--- a/scripts/add_maintainers.pl
+++ b/scripts/add_maintainers.pl
@@ -32,7 +32,7 @@ $get_maintainer =~ s/add_maintainers/get_maintainer/;
 my $usage = <<EOT;
 OPTIONS:
 --------
-USAGE: $tool [options] (--patchdir | -d) <patchdir>
+USAGE: $tool [options] (--patchdir | -d | -o) <patchdir>
 
   --reroll-count <n> | -v <n>
     Choose patch files for specific version. This results into the
@@ -223,7 +223,7 @@ my $patch_ext           = ".patch";
 my $maintainers         = "MAINTAINERS";
 
 if (!GetOptions(
-                'd|patchdir=s'     => \$patch_dir,
+                'd|o|patchdir=s'   => \$patch_dir,
                 'v|reroll-count=i' => \$rerollcount,
                 'p|patchcc=s'      => \$plocation,
                 'c|covercc=s'      => \$clocation,
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon May 02 06:55:36 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 02 May 2022 06:55:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.318661.538525 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nlPy4-0001JX-H0; Mon, 02 May 2022 06:55:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 318661.538525; Mon, 02 May 2022 06:55: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 1nlPy4-0001JP-EA; Mon, 02 May 2022 06:55:36 +0000
Received: by outflank-mailman (input) for mailman id 318661;
 Mon, 02 May 2022 06:55: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 1nlPy3-0001JB-9z
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 06:55: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 1nlPy3-0002dP-9F
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 06:55:35 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nlPy3-0006lt-8a
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 06:55: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=A4lsrGnnQ1r0pdZLD0zKICAulFTrnt4+FJrDyTuapyE=; b=xsKOMtKAIJzz7qGPPWxh/Ah+Cb
	AsTJnpYjqifpqgLFJYI0KpfvdBI8t7WtQyYeGqryV5Zh86hfMshbwv/ctdnCQy/He/W/fAXeRY4LB
	GDQedHCqnT23/EKYDKhYVeKGAJtPo0M8RmVUAAirBTk0/LHdn+IJawx8VYPqAJXlEEpo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] kconfig: detect LD implementation
Message-Id: <E1nlPy3-0006lt-8a@xenbits.xenproject.org>
Date: Mon, 02 May 2022 06:55:35 +0000

commit c70c4b624f85f7d4e28c70a804a0a3f20d73092b
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon May 2 08:50:39 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon May 2 08:50:39 2022 +0200

    kconfig: detect LD implementation
    
    Detect GNU and LLVM ld implementations. This is required for further
    patches that will introduce diverging behaviour depending on the
    linker implementation in use.
    
    Note that LLVM ld returns "compatible with GNU linkers" as part of the
    version string, so be on the safe side and use '^' to only match at
    the start of the line in case LLVM ever decides to change the text to
    use "compatible with GNU ld" instead.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Michal Orzel <michal.orzel@arm.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/xen/Kconfig b/xen/Kconfig
index ec2bd9fbcf..134e6e68ad 100644
--- a/xen/Kconfig
+++ b/xen/Kconfig
@@ -23,6 +23,12 @@ config CLANG_VERSION
 	int
 	default $(shell,$(srctree)/scripts/clang-version.sh $(CC))
 
+config LD_IS_GNU
+	def_bool $(success,$(LD) --version | head -n 1 | grep -q "^GNU ld")
+
+config LD_IS_LLVM
+	def_bool $(success,$(LD) --version | head -n 1 | grep -q "^LLD")
+
 # -fvisibility=hidden reduces -fpic cost, if it's available
 config CC_HAS_VISIBILITY_ATTRIBUTE
 	def_bool $(cc-option,-fvisibility=hidden)
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon May 02 06:55:46 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 02 May 2022 06:55:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.318662.538529 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nlPyE-0001MS-IX; Mon, 02 May 2022 06:55:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 318662.538529; Mon, 02 May 2022 06:55: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 1nlPyE-0001MK-Fe; Mon, 02 May 2022 06:55:46 +0000
Received: by outflank-mailman (input) for mailman id 318662;
 Mon, 02 May 2022 06:55: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 1nlPyD-0001M9-D5
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 06:55: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 1nlPyD-0002dp-CK
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 06:55:45 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nlPyD-0006md-BP
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 06:55: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=jvGha/t+59yYr6gvAO+ZnA+DfmcgiQVyFizvNjZehK8=; b=15z24gfLHTvLdWeGMmKGXL/yTx
	Y9VAhGGn8habp1+WVOEI24Ecilia8JxqB7EdNZScff080M/ZfEzw9zLz4O17t4KiQD1lVCTaRX/sJ
	oDl4Y/IxT4za0COgQwYhjNbi13IbWJGTRLbXjdnZX2l4DJkTNY22Suxi4fHhONKFx+2g=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] linker/lld: do not generate quoted section names
Message-Id: <E1nlPyD-0006md-BP@xenbits.xenproject.org>
Date: Mon, 02 May 2022 06:55:45 +0000

commit 702c9a800eb3ecd4b8595998d37a769d470c5bb0
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon May 2 08:51:45 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon May 2 08:51:45 2022 +0200

    linker/lld: do not generate quoted section names
    
    LLVM LD doesn't strip the quotes from the section names, and so the
    resulting binary ends up with section names like:
    
      [ 1] ".text"           PROGBITS         ffff82d040200000  00008000
           000000000018cbc1  0000000000000000  AX       0     0     4096
    
    This confuses some tools (like gdb) and prevents proper parsing of the
    binary.
    
    The issue has already been reported and is being fixed in LLD.  In
    order to workaround this issue and keep the GNU ld support define
    different DECL_SECTION macros depending on the used ld
    implementation.
    
    Drop the quotes from the definitions of the debug sections in
    DECL_DEBUG{2}, as those quotes are not required for GNU ld either.
    
    Fixes: 6254920587c3 ('x86: quote section names when defining them in linker script')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/xen.lds.S    | 6 +++++-
 xen/include/xen/xen.lds.h | 8 ++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 6e4abbc1ce..d94915ea7d 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -20,7 +20,11 @@ ENTRY(efi_start)
 #else /* !EFI */
 
 #define FORMAT "elf64-x86-64"
-#define DECL_SECTION(x) #x : AT(ADDR(#x) - __XEN_VIRT_START)
+#ifdef CONFIG_LD_IS_GNU
+# define DECL_SECTION(x) x : AT(ADDR(#x) - __XEN_VIRT_START)
+#else
+# define DECL_SECTION(x) x : AT(ADDR(x) - __XEN_VIRT_START)
+#endif
 
 ENTRY(start_pa)
 
diff --git a/xen/include/xen/xen.lds.h b/xen/include/xen/xen.lds.h
index fc47bb1ccc..06b7110837 100644
--- a/xen/include/xen/xen.lds.h
+++ b/xen/include/xen/xen.lds.h
@@ -18,11 +18,11 @@
  * for PE output, in order to record that we'd prefer these sections to not
  * be loaded into memory.
  */
-#define DECL_DEBUG(x, a) #x ALIGN(a) (NOLOAD) : { *(x) }
-#define DECL_DEBUG2(x, y, a) #x ALIGN(a) (NOLOAD) : { *(x) *(y) }
+#define DECL_DEBUG(x, a) x ALIGN(a) (NOLOAD) : { *(x) }
+#define DECL_DEBUG2(x, y, a) x ALIGN(a) (NOLOAD) : { *(x) *(y) }
 #else
-#define DECL_DEBUG(x, a) #x 0 : { *(x) }
-#define DECL_DEBUG2(x, y, a) #x 0 : { *(x) *(y) }
+#define DECL_DEBUG(x, a) x 0 : { *(x) }
+#define DECL_DEBUG2(x, y, a) x 0 : { *(x) *(y) }
 #endif
 
 /*
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon May 02 20:33:07 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 02 May 2022 20:33:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.319057.539116 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nlcj9-0007pw-2e; Mon, 02 May 2022 20:33:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 319057.539116; Mon, 02 May 2022 20: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 1nlcj8-0007po-Vx; Mon, 02 May 2022 20:33:02 +0000
Received: by outflank-mailman (input) for mailman id 319057;
 Mon, 02 May 2022 20: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 1nlcj7-0007pg-Pz
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 20: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 1nlcj7-0002te-P8
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 20:33:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nlcj7-000550-Nv
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 20: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=L1YoMOahNRa82iVrTqSCGJ8ZdLrCnOaYmwHLw1CtdL8=; b=idkOiiisjTTYws9G0+4Y+BaIKt
	mInY8vGmcO0czhJSTXB4GVUvc7P9cSKCiAgloAzmS5UfXkoqE+NKO005vFmreues1CNhwZ5IQDC9Q
	p0e8JVUVFiadlYlZLyIRcPsjHOaNjsjMNJNdd5I34ChbGB7+s76g/dQ0Qnxcgme+xYbA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] IOMMU/x86: disallow device assignment to PoD guests
Message-Id: <E1nlcj7-000550-Nv@xenbits.xenproject.org>
Date: Mon, 02 May 2022 20:33:01 +0000

commit ad4312d764e8b40a1e45b64aac6d840a60c59f13
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon May 2 08:48:02 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon May 2 08:48:02 2022 +0200

    IOMMU/x86: disallow device assignment to PoD guests
    
    While it is okay for IOMMU page tables to be set up for guests starting
    in PoD mode, actual device assignment may only occur once all PoD
    entries have been removed from the P2M. So far this was enforced only
    for boot-time assignment, and only in the tool stack.
    
    Also use the new function to replace p2m_pod_entry_count(): Its unlocked
    access to p2m->pod.entry_count wasn't really okay (irrespective of the
    result being stale by the time the caller gets to see it). Nor was the
    use of that function in line with the immediately preceding comment: A
    PoD guest isn't just one with a non-zero entry count, but also one with
    a non-empty cache (e.g. prior to actually launching the guest).
    
    To allow the tool stack to see a consistent snapshot of PoD state, move
    the tail of XENMEM_{get,set}_pod_target handling into a function, adding
    proper locking there.
    
    In libxl take the liberty to use the new local variable r also for a
    pre-existing call into libxc.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/include/asm/p2m.h      | 21 +++++++++---------
 xen/arch/x86/mm.c                   |  6 +-----
 xen/arch/x86/mm/p2m-pod.c           | 43 ++++++++++++++++++++++++++++++++++++-
 xen/common/vm_event.c               |  2 +-
 xen/drivers/passthrough/x86/iommu.c |  3 ++-
 5 files changed, 57 insertions(+), 18 deletions(-)

diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h
index 6f14e7b46d..0a0f7114f3 100644
--- a/xen/arch/x86/include/asm/p2m.h
+++ b/xen/arch/x86/include/asm/p2m.h
@@ -701,6 +701,12 @@ int p2m_pod_empty_cache(struct domain *d);
  * domain matches target */
 int p2m_pod_set_mem_target(struct domain *d, unsigned long target);
 
+/* Obtain a consistent snapshot of PoD related domain state. */
+void p2m_pod_get_mem_target(const struct domain *d, xen_pod_target_t *target);
+
+/* Check whether PoD is (still) active in a domain. */
+bool p2m_pod_active(const struct domain *d);
+
 /* Scan pod cache when offline/broken page triggered */
 int
 p2m_pod_offline_or_broken_hit(struct page_info *p);
@@ -709,11 +715,6 @@ p2m_pod_offline_or_broken_hit(struct page_info *p);
 void
 p2m_pod_offline_or_broken_replace(struct page_info *p);
 
-static inline long p2m_pod_entry_count(const struct p2m_domain *p2m)
-{
-    return p2m->pod.entry_count;
-}
-
 #else
 
 static inline bool
@@ -727,6 +728,11 @@ static inline int p2m_pod_empty_cache(struct domain *d)
     return 0;
 }
 
+static inline bool p2m_pod_active(const struct domain *d)
+{
+    return false;
+}
+
 static inline int p2m_pod_offline_or_broken_hit(struct page_info *p)
 {
     return 0;
@@ -737,11 +743,6 @@ static inline void p2m_pod_offline_or_broken_replace(struct page_info *p)
     ASSERT_UNREACHABLE();
 }
 
-static inline long p2m_pod_entry_count(const struct p2m_domain *p2m)
-{
-    return 0;
-}
-
 #endif
 
 
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 74fa9205f4..67c0427963 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -4804,7 +4804,6 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
     {
         xen_pod_target_t target;
         struct domain *d;
-        struct p2m_domain *p2m;
 
         if ( copy_from_guest(&target, arg, 1) )
             return -EFAULT;
@@ -4835,10 +4834,7 @@ long arch_memory_op(unsigned long cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
         }
         else if ( rc >= 0 )
         {
-            p2m = p2m_get_hostp2m(d);
-            target.tot_pages       = domain_tot_pages(d);
-            target.pod_cache_pages = p2m->pod.count;
-            target.pod_entries     = p2m->pod.entry_count;
+            p2m_pod_get_mem_target(d, &target);
 
             if ( __copy_to_guest(arg, &target, 1) )
                 rc = -EFAULT;
diff --git a/xen/arch/x86/mm/p2m-pod.c b/xen/arch/x86/mm/p2m-pod.c
index fd12f8ca73..fc110506dc 100644
--- a/xen/arch/x86/mm/p2m-pod.c
+++ b/xen/arch/x86/mm/p2m-pod.c
@@ -20,6 +20,7 @@
  */
 
 #include <xen/event.h>
+#include <xen/iocap.h>
 #include <xen/ioreq.h>
 #include <xen/mm.h>
 #include <xen/sched.h>
@@ -360,7 +361,10 @@ p2m_pod_set_mem_target(struct domain *d, unsigned long target)
 
     ASSERT( pod_target >= p2m->pod.count );
 
-    ret = p2m_pod_set_cache_target(p2m, pod_target, 1/*preemptible*/);
+    if ( has_arch_pdevs(d) || cache_flush_permitted(d) )
+        ret = -ENOTEMPTY;
+    else
+        ret = p2m_pod_set_cache_target(p2m, pod_target, 1/*preemptible*/);
 
 out:
     pod_unlock(p2m);
@@ -368,6 +372,23 @@ out:
     return ret;
 }
 
+void p2m_pod_get_mem_target(const struct domain *d, xen_pod_target_t *target)
+{
+    struct p2m_domain *p2m = p2m_get_hostp2m(d);
+
+    ASSERT(is_hvm_domain(d));
+
+    pod_lock(p2m);
+    lock_page_alloc(p2m);
+
+    target->tot_pages       = domain_tot_pages(d);
+    target->pod_cache_pages = p2m->pod.count;
+    target->pod_entries     = p2m->pod.entry_count;
+
+    unlock_page_alloc(p2m);
+    pod_unlock(p2m);
+}
+
 int p2m_pod_empty_cache(struct domain *d)
 {
     struct p2m_domain *p2m = p2m_get_hostp2m(d);
@@ -1391,6 +1412,9 @@ guest_physmap_mark_populate_on_demand(struct domain *d, unsigned long gfn,
     if ( !paging_mode_translate(d) )
         return -EINVAL;
 
+    if ( has_arch_pdevs(d) || cache_flush_permitted(d) )
+        return -ENOTEMPTY;
+
     do {
         rc = mark_populate_on_demand(d, gfn, chunk_order);
 
@@ -1412,3 +1436,20 @@ void p2m_pod_init(struct p2m_domain *p2m)
     for ( i = 0; i < ARRAY_SIZE(p2m->pod.mrp.list); ++i )
         p2m->pod.mrp.list[i] = gfn_x(INVALID_GFN);
 }
+
+bool p2m_pod_active(const struct domain *d)
+{
+    struct p2m_domain *p2m;
+    bool res;
+
+    if ( !is_hvm_domain(d) )
+        return false;
+
+    p2m = p2m_get_hostp2m(d);
+
+    pod_lock(p2m);
+    res = p2m->pod.entry_count | p2m->pod.count;
+    pod_unlock(p2m);
+
+    return res;
+}
diff --git a/xen/common/vm_event.c b/xen/common/vm_event.c
index 4a8f02893e..0b99a6ea72 100644
--- a/xen/common/vm_event.c
+++ b/xen/common/vm_event.c
@@ -655,7 +655,7 @@ int vm_event_domctl(struct domain *d, struct xen_domctl_vm_event_op *vec)
 
             rc = -EXDEV;
             /* Disallow paging in a PoD guest */
-            if ( p2m_pod_entry_count(p2m_get_hostp2m(d)) )
+            if ( p2m_pod_active(d) )
                 break;
 
             /* domain_pause() not required here, see XSA-99 */
diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c
index d5bf4d3241..616b66e755 100644
--- a/xen/drivers/passthrough/x86/iommu.c
+++ b/xen/drivers/passthrough/x86/iommu.c
@@ -513,11 +513,12 @@ bool arch_iommu_use_permitted(const struct domain *d)
 {
     /*
      * Prevent device assign if mem paging, mem sharing or log-dirty
-     * have been enabled for this domain.
+     * have been enabled for this domain, or if PoD is still in active use.
      */
     return d == dom_io ||
            (likely(!mem_sharing_enabled(d)) &&
             likely(!mem_paging_enabled(d)) &&
+            likely(!p2m_pod_active(d)) &&
             likely(!p2m_is_global_logdirty(d)));
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Mon May 02 20:33:13 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 02 May 2022 20:33:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.319058.539121 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nlcjJ-0007sn-4R; Mon, 02 May 2022 20:33:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 319058.539121; Mon, 02 May 2022 20: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 1nlcjJ-0007sd-1I; Mon, 02 May 2022 20:33:13 +0000
Received: by outflank-mailman (input) for mailman id 319058;
 Mon, 02 May 2022 20: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 1nlcjH-0007sO-TC
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 20: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 1nlcjH-0002tu-SP
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 20:33:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nlcjH-00055v-RY
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 20: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=BvLZ6eItxhT5Tt7CVacAhlE9fbNiMqsKHCv55TktgNY=; b=VrKyUEbGvmI9QlLZfFJEjAe0h9
	5LVi2NeO4xys3Ctg1+pqfvIjUUhZ5YLTin8rfww+Myo7J4l4J1cbLX2skVgfFJ2MKOkcsVJ2T9vfg
	jAKd5Lrr5MIYt3J9N2avIHqWk/G6/lkTVIKs9nszvueGjB0vatUtj9wodu9MghuvAJJI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/msr: handle reads to MSR_P5_MC_{ADDR,TYPE}
Message-Id: <E1nlcjH-00055v-RY@xenbits.xenproject.org>
Date: Mon, 02 May 2022 20:33:11 +0000

commit ce59e472b581e4923f6892172dde62b88c8aa8b7
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon May 2 08:49:12 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon May 2 08:49:12 2022 +0200

    x86/msr: handle reads to MSR_P5_MC_{ADDR,TYPE}
    
    Windows Server 2019 Essentials will unconditionally attempt to read
    P5_MC_ADDR MSR at boot and throw a BSOD if injected a #GP.
    
    Fix this by mapping MSR_P5_MC_{ADDR,TYPE} to
    MSR_IA32_MCi_{ADDR,STATUS}, as reported also done by hardware in Intel
    SDM "Mapping of the Pentium Processor Machine-Check Errors to the
    Machine-Check Architecture" section.
    
    Reported-by: Steffen Einsle <einsle@phptrix.de>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/cpu/mcheck/mce.h        |  6 ++++++
 xen/arch/x86/cpu/mcheck/mce_intel.c  | 19 +++++++++++++++++++
 xen/arch/x86/cpu/mcheck/vmce.c       |  2 ++
 xen/arch/x86/include/asm/msr-index.h |  3 +++
 xen/arch/x86/msr.c                   |  2 ++
 5 files changed, 32 insertions(+)

diff --git a/xen/arch/x86/cpu/mcheck/mce.h b/xen/arch/x86/cpu/mcheck/mce.h
index 535d0abf8f..bea08bdc74 100644
--- a/xen/arch/x86/cpu/mcheck/mce.h
+++ b/xen/arch/x86/cpu/mcheck/mce.h
@@ -169,6 +169,12 @@ static inline int mce_vendor_bank_msr(const struct vcpu *v, uint32_t msr)
         if (msr >= MSR_IA32_MC0_CTL2 &&
             msr < MSR_IA32_MCx_CTL2(v->arch.vmce.mcg_cap & MCG_CAP_COUNT) )
             return 1;
+        fallthrough;
+
+    case X86_VENDOR_CENTAUR:
+    case X86_VENDOR_SHANGHAI:
+        if (msr == MSR_P5_MC_ADDR || msr == MSR_P5_MC_TYPE)
+            return 1;
         break;
 
     case X86_VENDOR_AMD:
diff --git a/xen/arch/x86/cpu/mcheck/mce_intel.c b/xen/arch/x86/cpu/mcheck/mce_intel.c
index 50198e0c29..28a605a5cb 100644
--- a/xen/arch/x86/cpu/mcheck/mce_intel.c
+++ b/xen/arch/x86/cpu/mcheck/mce_intel.c
@@ -1008,8 +1008,27 @@ int vmce_intel_wrmsr(struct vcpu *v, uint32_t msr, uint64_t val)
 
 int vmce_intel_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)
 {
+    const struct cpuid_policy *cp = v->domain->arch.cpuid;
     unsigned int bank = msr - MSR_IA32_MC0_CTL2;
 
+    switch ( msr )
+    {
+    case MSR_P5_MC_ADDR:
+        /*
+         * Bank 0 is used for the 'bank 0 quirk' on older processors.
+         * See vcpu_fill_mc_msrs() for reference.
+         */
+        *val = v->arch.vmce.bank[1].mci_addr;
+        return 1;
+
+    case MSR_P5_MC_TYPE:
+        *val = v->arch.vmce.bank[1].mci_status;
+        return 1;
+    }
+
+    if ( !(cp->x86_vendor & X86_VENDOR_INTEL) )
+        return 0;
+
     if ( bank < GUEST_MC_BANK_NUM )
     {
         *val = v->arch.vmce.bank[bank].mci_ctl2;
diff --git a/xen/arch/x86/cpu/mcheck/vmce.c b/xen/arch/x86/cpu/mcheck/vmce.c
index 458120f9ad..af30811afd 100644
--- a/xen/arch/x86/cpu/mcheck/vmce.c
+++ b/xen/arch/x86/cpu/mcheck/vmce.c
@@ -150,6 +150,8 @@ static int bank_mce_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)
     default:
         switch ( boot_cpu_data.x86_vendor )
         {
+        case X86_VENDOR_CENTAUR:
+        case X86_VENDOR_SHANGHAI:
         case X86_VENDOR_INTEL:
             ret = vmce_intel_rdmsr(v, msr, val);
             break;
diff --git a/xen/arch/x86/include/asm/msr-index.h b/xen/arch/x86/include/asm/msr-index.h
index 3e038db618..31964b88af 100644
--- a/xen/arch/x86/include/asm/msr-index.h
+++ b/xen/arch/x86/include/asm/msr-index.h
@@ -15,6 +15,9 @@
  * abbreviated name.  Exceptions will be considered on a case-by-case basis.
  */
 
+#define MSR_P5_MC_ADDR                      0
+#define MSR_P5_MC_TYPE                      0x00000001
+
 #define MSR_APIC_BASE                       0x0000001b
 #define  APIC_BASE_BSP                      (_AC(1, ULL) <<  8)
 #define  APIC_BASE_EXTD                     (_AC(1, ULL) << 10)
diff --git a/xen/arch/x86/msr.c b/xen/arch/x86/msr.c
index 01a15857b7..6206529162 100644
--- a/xen/arch/x86/msr.c
+++ b/xen/arch/x86/msr.c
@@ -283,6 +283,8 @@ int guest_rdmsr(struct vcpu *v, uint32_t msr, uint64_t *val)
         *val = msrs->misc_features_enables.raw;
         break;
 
+    case MSR_P5_MC_ADDR:
+    case MSR_P5_MC_TYPE:
     case MSR_IA32_MCG_CAP     ... MSR_IA32_MCG_CTL:      /* 0x179 -> 0x17b */
     case MSR_IA32_MCx_CTL2(0) ... MSR_IA32_MCx_CTL2(31): /* 0x280 -> 0x29f */
     case MSR_IA32_MCx_CTL(0)  ... MSR_IA32_MCx_MISC(31): /* 0x400 -> 0x47f */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Mon May 02 20:33:23 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 02 May 2022 20:33:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.319060.539123 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nlcjT-0007wC-5s; Mon, 02 May 2022 20:33:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 319060.539123; Mon, 02 May 2022 20: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 1nlcjT-0007w5-2n; Mon, 02 May 2022 20:33:23 +0000
Received: by outflank-mailman (input) for mailman id 319060;
 Mon, 02 May 2022 20: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 1nlcjR-0007vq-WF
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 20: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 1nlcjR-0002uF-VV
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 20:33:21 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nlcjR-00056i-UW
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 20:33: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=k4Ck+hgbqfqYN8Xn/6MceBR04Aikj6U9Z6ZnBCVKszM=; b=NxeBW41I9fPgfNAft+iuW63HG6
	T69X+cUbEW6SPFiwA0m1VfzubHIfTb1a6+000GIxjdLTmpZOfslNXKaMn+uzxJvuXKEBGu6X11qaQ
	tyWoXJGHrWj2js/+gG41cO3FMYFsFXReHF0werhmsfR5iZQWMDeM38MUlYTH6qd7djXg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] scripts/add_maintainers.pl: add -o as an alternative to --patchdir
Message-Id: <E1nlcjR-00056i-UW@xenbits.xenproject.org>
Date: Mon, 02 May 2022 20:33:21 +0000

commit 3c245bc3a2f0597e2da2d5e12b5a9372c9360cea
Author:     Elliott Mitchell <ehem+xen@m5p.com>
AuthorDate: Mon May 2 08:50:02 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon May 2 08:50:02 2022 +0200

    scripts/add_maintainers.pl: add -o as an alternative to --patchdir
    
    This matches the output directory option used by `git format-patch`.  I
    suspect I'm not the only one who finds matching `git format-patch` more
    intuitive, than -d for directory.
    
    Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
---
 scripts/add_maintainers.pl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/scripts/add_maintainers.pl b/scripts/add_maintainers.pl
index 5a6d0f631b..380e8da22a 100755
--- a/scripts/add_maintainers.pl
+++ b/scripts/add_maintainers.pl
@@ -32,7 +32,7 @@ $get_maintainer =~ s/add_maintainers/get_maintainer/;
 my $usage = <<EOT;
 OPTIONS:
 --------
-USAGE: $tool [options] (--patchdir | -d) <patchdir>
+USAGE: $tool [options] (--patchdir | -d | -o) <patchdir>
 
   --reroll-count <n> | -v <n>
     Choose patch files for specific version. This results into the
@@ -223,7 +223,7 @@ my $patch_ext           = ".patch";
 my $maintainers         = "MAINTAINERS";
 
 if (!GetOptions(
-                'd|patchdir=s'     => \$patch_dir,
+                'd|o|patchdir=s'   => \$patch_dir,
                 'v|reroll-count=i' => \$rerollcount,
                 'p|patchcc=s'      => \$plocation,
                 'c|covercc=s'      => \$clocation,
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Mon May 02 20:33:33 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 02 May 2022 20:33:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.319061.539130 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nlcjd-0007ze-8Q; Mon, 02 May 2022 20:33:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 319061.539130; Mon, 02 May 2022 20: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 1nlcjd-0007zS-4Q; Mon, 02 May 2022 20:33:33 +0000
Received: by outflank-mailman (input) for mailman id 319061;
 Mon, 02 May 2022 20: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 1nlcjc-0007zG-2u
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 20: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 1nlcjc-0002vx-25
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 20:33:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nlcjc-00057R-1H
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 20: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=Ihh8wGOnj2wupLn/iZTOmx9B0wFUFYvSpVk/w+vsMJk=; b=1xTXtxAL4eAtzhGGwhvPN4xOr3
	vBtTXaaWWLkeUHzR3ESrVdvi10zVMTfk31T2cFWN+VDEqL8JlVgJAxchmR9/NrZXigb7zZrCu0eTD
	WqpaZhfXa74OZ8GYSzCLfYGVMbVl4vlorCfhVTqJD86AEjepPEGopzhXDdkzEwkVEGiQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] kconfig: detect LD implementation
Message-Id: <E1nlcjc-00057R-1H@xenbits.xenproject.org>
Date: Mon, 02 May 2022 20:33:32 +0000

commit c70c4b624f85f7d4e28c70a804a0a3f20d73092b
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon May 2 08:50:39 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon May 2 08:50:39 2022 +0200

    kconfig: detect LD implementation
    
    Detect GNU and LLVM ld implementations. This is required for further
    patches that will introduce diverging behaviour depending on the
    linker implementation in use.
    
    Note that LLVM ld returns "compatible with GNU linkers" as part of the
    version string, so be on the safe side and use '^' to only match at
    the start of the line in case LLVM ever decides to change the text to
    use "compatible with GNU ld" instead.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Michal Orzel <michal.orzel@arm.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/Kconfig | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/xen/Kconfig b/xen/Kconfig
index ec2bd9fbcf..134e6e68ad 100644
--- a/xen/Kconfig
+++ b/xen/Kconfig
@@ -23,6 +23,12 @@ config CLANG_VERSION
 	int
 	default $(shell,$(srctree)/scripts/clang-version.sh $(CC))
 
+config LD_IS_GNU
+	def_bool $(success,$(LD) --version | head -n 1 | grep -q "^GNU ld")
+
+config LD_IS_LLVM
+	def_bool $(success,$(LD) --version | head -n 1 | grep -q "^LLD")
+
 # -fvisibility=hidden reduces -fpic cost, if it's available
 config CC_HAS_VISIBILITY_ATTRIBUTE
 	def_bool $(cc-option,-fvisibility=hidden)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Mon May 02 20:33:43 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 02 May 2022 20:33:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.319062.539132 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nlcjn-00082h-8x; Mon, 02 May 2022 20:33:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 319062.539132; Mon, 02 May 2022 20:33: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 1nlcjn-00082Z-5y; Mon, 02 May 2022 20:33:43 +0000
Received: by outflank-mailman (input) for mailman id 319062;
 Mon, 02 May 2022 20:33: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 1nlcjm-00082M-5h
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 20:33: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 1nlcjm-0002w7-50
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 20:33:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nlcjm-000588-48
 for xen-changelog@lists.xenproject.org; Mon, 02 May 2022 20:33: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=2wLZeJSateZzFERmFhG5oF9JMj0gY2692oimcdUC6Mg=; b=Snyn8FCgS87FvHeCf98vFX07kM
	UclkJPKsEoaor0psRe0Agk/5OnQdCELbRJjxErsb7ZzebxdvYwuK6G7ggDtW/ZzOv9qZcc8RVs8O0
	TLtpNgzR7C4C+//ya+lPbUDcWYGUy72/NeSdKeaxe3wdHrQgcX9JCW3Y/MR/m5bKpUNA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] linker/lld: do not generate quoted section names
Message-Id: <E1nlcjm-000588-48@xenbits.xenproject.org>
Date: Mon, 02 May 2022 20:33:42 +0000

commit 702c9a800eb3ecd4b8595998d37a769d470c5bb0
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon May 2 08:51:45 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon May 2 08:51:45 2022 +0200

    linker/lld: do not generate quoted section names
    
    LLVM LD doesn't strip the quotes from the section names, and so the
    resulting binary ends up with section names like:
    
      [ 1] ".text"           PROGBITS         ffff82d040200000  00008000
           000000000018cbc1  0000000000000000  AX       0     0     4096
    
    This confuses some tools (like gdb) and prevents proper parsing of the
    binary.
    
    The issue has already been reported and is being fixed in LLD.  In
    order to workaround this issue and keep the GNU ld support define
    different DECL_SECTION macros depending on the used ld
    implementation.
    
    Drop the quotes from the definitions of the debug sections in
    DECL_DEBUG{2}, as those quotes are not required for GNU ld either.
    
    Fixes: 6254920587c3 ('x86: quote section names when defining them in linker script')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/xen.lds.S    | 6 +++++-
 xen/include/xen/xen.lds.h | 8 ++++----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 6e4abbc1ce..d94915ea7d 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -20,7 +20,11 @@ ENTRY(efi_start)
 #else /* !EFI */
 
 #define FORMAT "elf64-x86-64"
-#define DECL_SECTION(x) #x : AT(ADDR(#x) - __XEN_VIRT_START)
+#ifdef CONFIG_LD_IS_GNU
+# define DECL_SECTION(x) x : AT(ADDR(#x) - __XEN_VIRT_START)
+#else
+# define DECL_SECTION(x) x : AT(ADDR(x) - __XEN_VIRT_START)
+#endif
 
 ENTRY(start_pa)
 
diff --git a/xen/include/xen/xen.lds.h b/xen/include/xen/xen.lds.h
index fc47bb1ccc..06b7110837 100644
--- a/xen/include/xen/xen.lds.h
+++ b/xen/include/xen/xen.lds.h
@@ -18,11 +18,11 @@
  * for PE output, in order to record that we'd prefer these sections to not
  * be loaded into memory.
  */
-#define DECL_DEBUG(x, a) #x ALIGN(a) (NOLOAD) : { *(x) }
-#define DECL_DEBUG2(x, y, a) #x ALIGN(a) (NOLOAD) : { *(x) *(y) }
+#define DECL_DEBUG(x, a) x ALIGN(a) (NOLOAD) : { *(x) }
+#define DECL_DEBUG2(x, y, a) x ALIGN(a) (NOLOAD) : { *(x) *(y) }
 #else
-#define DECL_DEBUG(x, a) #x 0 : { *(x) }
-#define DECL_DEBUG2(x, y, a) #x 0 : { *(x) *(y) }
+#define DECL_DEBUG(x, a) x 0 : { *(x) }
+#define DECL_DEBUG2(x, y, a) x 0 : { *(x) *(y) }
 #endif
 
 /*
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed May 04 21:44:09 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 04 May 2022 21:44:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.321024.542044 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nmMmz-0007Mk-ED; Wed, 04 May 2022 21:44:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 321024.542044; Wed, 04 May 2022 21: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 1nmMmz-0007Mc-9A; Wed, 04 May 2022 21:44:05 +0000
Received: by outflank-mailman (input) for mailman id 321024;
 Wed, 04 May 2022 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 1nmMmy-0007MV-Lj
 for xen-changelog@lists.xenproject.org; Wed, 04 May 2022 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 1nmMmy-0006IV-Ij
 for xen-changelog@lists.xenproject.org; Wed, 04 May 2022 21:44:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nmMmy-0002XP-GM
 for xen-changelog@lists.xenproject.org; Wed, 04 May 2022 21: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=K1IEYlFHnAaaDvNPXWSsxVJFqXAKE2vdUkNPBx9yqfs=; b=MwlU4aml4V31i9aIRc6gugj4lK
	n44Zb/ptnF1dzLuJbuVZuXip9xv/PHjlABNbcAVP3hAsSVQoP94Q3doDwXJmk4eLSFPuE+jtYre6A
	tW9cTWZQd5zGW/BtDOhr6+fPbuRjlVx6S4MPCZxGHYsUDqF1Gjb0rUntAbe0iqmdyOUQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] optee: immediately free RPC buffers that are released by OP-TEE
Message-Id: <E1nmMmy-0002XP-GM@xenbits.xenproject.org>
Date: Wed, 04 May 2022 21:44:04 +0000

commit 5d2d5365ffadf075fd812038ab0841a3e868f906
Author:     Jens Wiklander <jens.wiklander@linaro.org>
AuthorDate: Wed May 4 07:49:12 2022 +0200
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Wed May 4 14:38:35 2022 -0700

    optee: immediately free RPC buffers that are released by OP-TEE
    
    This commit fixes a case overlooked in [1].
    
    There are two kinds of shared memory buffers used by OP-TEE:
    1. Normal payload buffer
    2. Internal command structure buffers
    
    The internal command structure buffers are represented with a shadow
    copy internally in Xen since this buffer can contain physical addresses
    that may need to be translated between real physical address and guest
    physical address without leaking information to the guest.
    
    [1] fixes the problem when releasing the normal payload buffers. The
    internal command structure buffers must be released in the same way.
    Failure to follow this order opens a window where the guest has freed
    the shared memory but Xen is still tracking the buffer.
    
    During this window the guest may happen to recycle this particular
    shared memory in some other thread and try to use it. Xen will block
    this which will lead to spurious failures to register a new shared
    memory block.
    
    Fix this by freeing the internal command structure buffers first before
    informing the guest that the buffer can be freed.
    
    [1] 5b13eb1d978e ("optee: immediately free buffers that are released by OP-TEE")
    
    Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
    Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    [stefano: minor code style fix]
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
---
 xen/arch/arm/tee/optee.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c
index f49b3c0226..9cb9f16d43 100644
--- a/xen/arch/arm/tee/optee.c
+++ b/xen/arch/arm/tee/optee.c
@@ -1136,6 +1136,13 @@ static int handle_rpc_return(struct optee_domain *ctx,
         }
         unmap_domain_page(shm_rpc->xen_arg);
     }
+    else if ( call->rpc_op == OPTEE_SMC_RPC_FUNC_FREE )
+    {
+        uint64_t cookie = regpair_to_uint64(get_user_reg(regs, 1),
+                                            get_user_reg(regs, 2));
+
+        free_shm_rpc(ctx, cookie);
+    }
 
     return ret;
 }
@@ -1584,13 +1591,6 @@ static void handle_rpc(struct optee_domain *ctx, struct cpu_user_regs *regs)
     case OPTEE_SMC_RPC_FUNC_ALLOC:
         handle_rpc_func_alloc(ctx, regs, call);
         return;
-    case OPTEE_SMC_RPC_FUNC_FREE:
-    {
-        uint64_t cookie = regpair_to_uint64(call->rpc_params[0],
-                                            call->rpc_params[1]);
-        free_shm_rpc(ctx, cookie);
-        break;
-    }
     case OPTEE_SMC_RPC_FUNC_FOREIGN_INTR:
         break;
     case OPTEE_SMC_RPC_FUNC_CMD:
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu May 05 09:33:07 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 05 May 2022 09:33:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.321903.543049 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nmXr4-0002pj-S2; Thu, 05 May 2022 09:33:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 321903.543049; Thu, 05 May 2022 09: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 1nmXr4-0002pb-OH; Thu, 05 May 2022 09:33:02 +0000
Received: by outflank-mailman (input) for mailman id 321903;
 Thu, 05 May 2022 09: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 1nmXr3-0002pV-SR
 for xen-changelog@lists.xenproject.org; Thu, 05 May 2022 09: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 1nmXr3-0001sg-P7
 for xen-changelog@lists.xenproject.org; Thu, 05 May 2022 09:33:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nmXr3-0003rv-O9
 for xen-changelog@lists.xenproject.org; Thu, 05 May 2022 09: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=Tdwyh5cq9c591OSr1wQ/4SEuRrOGb1AFmG6OtFrkOF8=; b=IKcFPGLaimt5Ft+EOYQNimQrjZ
	UqXpnoyQlaRkA47WdqJrYfhgY3sih5eo+9gksXAsYOsQZu6wjJdtAQrndDW81g+wFdBavIjKesbIG
	iJKMW/YLzT9oEpp92zd3Dg8l13PbQX6C23gFwGp3M/bdZdj1r8UwKM3ODyj4H2PD08kU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] optee: immediately free RPC buffers that are released by OP-TEE
Message-Id: <E1nmXr3-0003rv-O9@xenbits.xenproject.org>
Date: Thu, 05 May 2022 09:33:01 +0000

commit 5d2d5365ffadf075fd812038ab0841a3e868f906
Author:     Jens Wiklander <jens.wiklander@linaro.org>
AuthorDate: Wed May 4 07:49:12 2022 +0200
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Wed May 4 14:38:35 2022 -0700

    optee: immediately free RPC buffers that are released by OP-TEE
    
    This commit fixes a case overlooked in [1].
    
    There are two kinds of shared memory buffers used by OP-TEE:
    1. Normal payload buffer
    2. Internal command structure buffers
    
    The internal command structure buffers are represented with a shadow
    copy internally in Xen since this buffer can contain physical addresses
    that may need to be translated between real physical address and guest
    physical address without leaking information to the guest.
    
    [1] fixes the problem when releasing the normal payload buffers. The
    internal command structure buffers must be released in the same way.
    Failure to follow this order opens a window where the guest has freed
    the shared memory but Xen is still tracking the buffer.
    
    During this window the guest may happen to recycle this particular
    shared memory in some other thread and try to use it. Xen will block
    this which will lead to spurious failures to register a new shared
    memory block.
    
    Fix this by freeing the internal command structure buffers first before
    informing the guest that the buffer can be freed.
    
    [1] 5b13eb1d978e ("optee: immediately free buffers that are released by OP-TEE")
    
    Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
    Reviewed-by: Volodymyr Babchuk <volodymyr_babchuk@epam.com>
    [stefano: minor code style fix]
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
---
 xen/arch/arm/tee/optee.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/xen/arch/arm/tee/optee.c b/xen/arch/arm/tee/optee.c
index f49b3c0226..9cb9f16d43 100644
--- a/xen/arch/arm/tee/optee.c
+++ b/xen/arch/arm/tee/optee.c
@@ -1136,6 +1136,13 @@ static int handle_rpc_return(struct optee_domain *ctx,
         }
         unmap_domain_page(shm_rpc->xen_arg);
     }
+    else if ( call->rpc_op == OPTEE_SMC_RPC_FUNC_FREE )
+    {
+        uint64_t cookie = regpair_to_uint64(get_user_reg(regs, 1),
+                                            get_user_reg(regs, 2));
+
+        free_shm_rpc(ctx, cookie);
+    }
 
     return ret;
 }
@@ -1584,13 +1591,6 @@ static void handle_rpc(struct optee_domain *ctx, struct cpu_user_regs *regs)
     case OPTEE_SMC_RPC_FUNC_ALLOC:
         handle_rpc_func_alloc(ctx, regs, call);
         return;
-    case OPTEE_SMC_RPC_FUNC_FREE:
-    {
-        uint64_t cookie = regpair_to_uint64(call->rpc_params[0],
-                                            call->rpc_params[1]);
-        free_shm_rpc(ctx, cookie);
-        break;
-    }
     case OPTEE_SMC_RPC_FUNC_FOREIGN_INTR:
         break;
     case OPTEE_SMC_RPC_FUNC_CMD:
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 05 10:55:10 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 05 May 2022 10:55:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.321985.543150 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nmZ8V-0007IC-1O; Thu, 05 May 2022 10:55:07 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 321985.543150; Thu, 05 May 2022 10:55: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 1nmZ8U-0007I5-V1; Thu, 05 May 2022 10:55:06 +0000
Received: by outflank-mailman (input) for mailman id 321985;
 Thu, 05 May 2022 10: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 1nmZ8T-0007Hz-83
 for xen-changelog@lists.xenproject.org; Thu, 05 May 2022 10: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 1nmZ8T-0003vt-2o
 for xen-changelog@lists.xenproject.org; Thu, 05 May 2022 10:55:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nmZ8T-0001Hv-1v
 for xen-changelog@lists.xenproject.org; Thu, 05 May 2022 10:55: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=zBT/IDAFqSmH+3leLTLY2rbuHQiZ9yjLnXpe5KXXxVc=; b=vVZmB1SIWRL4ovbSgly5AnF6Cu
	YQn1C8ZCUwY5QYIyeufJvCb7ldDpZuGQBKt7k8g6MpMLwnm4AKsIsyyVEOXscUE8NBckfBcSPaFne
	836IwmU4FUQl9450QJwtgKhvf+gkvBqUgoxv62UUug895pCl6jx62BzJ7LuYxzeGwQ8o=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] SUPPORT.MD: Correct the amount of physical memory supported for Arm
Message-Id: <E1nmZ8T-0001Hv-1v@xenbits.xenproject.org>
Date: Thu, 05 May 2022 10:55:05 +0000

commit a5968a553f6a6c170254520038f69cb49ff7d191
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Thu May 5 11:46:57 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu May 5 11:47:09 2022 +0100

    SUPPORT.MD: Correct the amount of physical memory supported for Arm
    
    As part of XSA-385, SUPPORT.MD gained a statement regarding the amount
    of physical memory supported.
    
    However, booting Xen on a Arm platform with that amount of memory would
    result to a breakage because the frametable area is too small.
    
    The wiki [1] (as of April 2022) claims we were able to support up to
    5 TiB on Arm64 and 16 GiB. However, this is not the case because
    the struct page_info has always been bigger than expected (56 bytes
    for 64-bit and 32-bytes for 32-bit).
    
    I don't have any HW with such amount of memory. So rather than
    modifying the code, take the opportunity to use the limit that should
    work on Arm (2 TiB for 64-bit and 12 GiB for 32-bit).
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com> #arm part
---
 SUPPORT.md | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/SUPPORT.md b/SUPPORT.md
index 088dda9561..cdf93181cf 100644
--- a/SUPPORT.md
+++ b/SUPPORT.md
@@ -50,9 +50,10 @@ For the Cortex A57 r0p0 - r1p1, see Errata 832075.
 
 ### Physical Memory
 
-    Status: Supported up to 8 TiB
-
-Hosts with more memory are supported, but not security supported.
+    Status, x86: Supported up to 8 TiB. Hosts with more memory are
+                 supported, but not security supported.
+    Status, Arm32: Supported up to 12 GiB
+    Status, Arm64: Supported up to 2 TiB
 
 ### Physical Memory Hotplug
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu May 05 11:00:06 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 05 May 2022 11:00:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.321995.543177 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nmZDK-0000ku-Sx; Thu, 05 May 2022 11:00:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 321995.543177; Thu, 05 May 2022 11: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 1nmZDK-0000km-Q4; Thu, 05 May 2022 11:00:06 +0000
Received: by outflank-mailman (input) for mailman id 321995;
 Thu, 05 May 2022 11: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 1nmZDJ-0000gB-P4
 for xen-changelog@lists.xenproject.org; Thu, 05 May 2022 11: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 1nmZDJ-000453-OK
 for xen-changelog@lists.xenproject.org; Thu, 05 May 2022 11:00:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nmZDJ-0001n8-MB
 for xen-changelog@lists.xenproject.org; Thu, 05 May 2022 11: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=XObUOFJxOa6MWbzmNeZixSUcs9VgHQc1dJA5h0AriUI=; b=qkCjQ6JTtKxflgDt/nlCgtqShb
	SFG8NCB6cxGLlEwVLFbFhfA/VXqDMqnTTyefBAFSc/u+Q5EQg6eGtDf2vbEKahzJEn1sCMVLISGvR
	5bKfYgjejqrNlHJ/U1nFQ/TIhUx8gv6fASlK1c/4ms48ebIX8CgJXBkhBgYWWlVGUMIE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/arm: Advertise workaround 1 if we apply 3
Message-Id: <E1nmZDJ-0001n8-MB@xenbits.xenproject.org>
Date: Thu, 05 May 2022 11:00:05 +0000

commit af570d1c90f1ed6040d724732f6c582383782e90
Author:     Bertrand Marquis <bertrand.marquis@arm.com>
AuthorDate: Tue May 3 10:38:30 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu May 5 11:50:05 2022 +0100

    xen/arm: Advertise workaround 1 if we apply 3
    
    SMCC_WORKAROUND_3 is handling both Spectre v2 and spectre BHB.
    So when a guest is asking if we support workaround 1, tell yes if we
    apply workaround 3 on exception entry as it handles it.
    
    This will allow guests not supporting Spectre BHB but impacted by
    spectre v2 to still handle it correctly.
    The modified behaviour is coherent with what the Linux kernel does in
    KVM for guests.
    
    While there use ARM_SMCCC_SUCCESS instead of 0 for the return code value
    for workaround detection to be coherent with Workaround 2 handling.
    
    Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/vsmc.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/vsmc.c b/xen/arch/arm/vsmc.c
index b633ff2fe8..676740ef15 100644
--- a/xen/arch/arm/vsmc.c
+++ b/xen/arch/arm/vsmc.c
@@ -104,8 +104,13 @@ static bool handle_arch(struct cpu_user_regs *regs)
         switch ( arch_func_id )
         {
         case ARM_SMCCC_ARCH_WORKAROUND_1_FID:
-            if ( cpus_have_cap(ARM_HARDEN_BRANCH_PREDICTOR) )
-                ret = 0;
+            /*
+             * Workaround 3 is also mitigating spectre v2 so advertise that we
+             * support Workaround 1 if we do Workaround 3 on exception entry.
+             */
+            if ( cpus_have_cap(ARM_HARDEN_BRANCH_PREDICTOR) ||
+                 cpus_have_cap(ARM_WORKAROUND_BHB_SMCC_3) )
+                ret = ARM_SMCCC_SUCCESS;
             break;
         case ARM_SMCCC_ARCH_WORKAROUND_2_FID:
             switch ( get_ssbd_state() )
@@ -126,7 +131,7 @@ static bool handle_arch(struct cpu_user_regs *regs)
             break;
         case ARM_SMCCC_ARCH_WORKAROUND_3_FID:
             if ( cpus_have_cap(ARM_WORKAROUND_BHB_SMCC_3) )
-                ret = 0;
+                ret = ARM_SMCCC_SUCCESS;
             break;
         }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu May 05 11:00:19 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 05 May 2022 11:00:19 +0000
Received: from list by lists.xenproject.org with outflank-mailman.321998.543183 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nmZDU-0000q5-VR; Thu, 05 May 2022 11:00:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 321998.543183; Thu, 05 May 2022 11: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 1nmZDU-0000pw-Rd; Thu, 05 May 2022 11:00:16 +0000
Received: by outflank-mailman (input) for mailman id 321998;
 Thu, 05 May 2022 11:00: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 1nmZDT-0000pS-W2
 for xen-changelog@lists.xenproject.org; Thu, 05 May 2022 11:00: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 1nmZDT-00045E-Rp
 for xen-changelog@lists.xenproject.org; Thu, 05 May 2022 11:00:15 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nmZDT-0001oH-Qq
 for xen-changelog@lists.xenproject.org; Thu, 05 May 2022 11: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=ufM0dijaNgI/7A/3hTtNp0xiU2x+rVY4MoaPYf5jHtQ=; b=tPt+hblLPOVckE9oCSIelrxg+s
	RyBz4tJ06FMmzAwo2NkxQYMmp0d2D2aVIx0Izi/j+yDUJIJE5PpB+TiWa7YrRmPBBzkkMEEm17RmV
	JfalFl4bb5l8kz3n4f18aK3oRwE8ALRPRfry+fAbdACJbwE4e/JvoA4JoGQ9iowgm1is=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xenstore: don't let special watches be children of /
Message-Id: <E1nmZDT-0001oH-Qq@xenbits.xenproject.org>
Date: Thu, 05 May 2022 11:00:15 +0000

commit c1d5e4021c9d3878eab9bb1c65eb3c21ef9d5ddc
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Mon May 2 12:07:22 2022 +0200
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu May 5 11:58:47 2022 +0100

    tools/xenstore: don't let special watches be children of /
    
    When firing special watches (e.g. "@releaseDomain"), they will be
    regarded to be valid children of the "/" node. So a domain having
    registered a watch for "/" and having the privilege to receive
    the special watches will receive those special watch events for the
    registered "/" watch.
    
    Fix that by calling the related fire_watches() with the "exact"
    parameter set to true, causing a mismatch for the "/" node.
    
    Reported-by: Raphael Ning <raphning@amazon.com>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Raphael Ning <raphning@amazon.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstore/xenstored_domain.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
index ae065fcbee..80ba1d627b 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -231,7 +231,7 @@ static int destroy_domain(void *_domain)
 			unmap_interface(domain->interface);
 	}
 
-	fire_watches(NULL, domain, "@releaseDomain", NULL, false, NULL);
+	fire_watches(NULL, domain, "@releaseDomain", NULL, true, NULL);
 
 	wrl_domain_destroy(domain);
 
@@ -282,7 +282,7 @@ void check_domains(void)
 	}
 
 	if (notify)
-		fire_watches(NULL, NULL, "@releaseDomain", NULL, false, NULL);
+		fire_watches(NULL, NULL, "@releaseDomain", NULL, true, NULL);
 }
 
 /* We scan all domains rather than use the information given here. */
@@ -495,7 +495,7 @@ static struct domain *introduce_domain(const void *ctx,
 
 		if (!is_master_domain && !restore)
 			fire_watches(NULL, ctx, "@introduceDomain", NULL,
-				     false, NULL);
+				     true, NULL);
 	} else {
 		/* Use XS_INTRODUCE for recreating the xenbus event-channel. */
 		if (domain->port)
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu May 05 14:33:10 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 05 May 2022 14:33:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.322182.543405 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nmcXR-0006Yz-Vw; Thu, 05 May 2022 14:33:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 322182.543405; Thu, 05 May 2022 14: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 1nmcXR-0006Yr-TA; Thu, 05 May 2022 14:33:05 +0000
Received: by outflank-mailman (input) for mailman id 322182;
 Thu, 05 May 2022 14: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 1nmcXQ-0006Yl-F2
 for xen-changelog@lists.xenproject.org; Thu, 05 May 2022 14: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 1nmcXQ-00083X-CD
 for xen-changelog@lists.xenproject.org; Thu, 05 May 2022 14:33:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nmcXQ-00013W-BQ
 for xen-changelog@lists.xenproject.org; Thu, 05 May 2022 14:33: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=Isyrno8g4JEZjLyZCMYKOmWAkqXO1t1lvyEIacs2q2E=; b=lD5FttZFyrQ4PSRY/HD2q+dy2A
	wvcRREZ0xol10hL9BHhh/CFfos9o9qqwVsMpLpXM8gxRh8MYkLdKboNLfIWGoYJexiJakfDa6ZzBf
	Ir1OH3A+6Tgf3IGqBy4bCfLcKQc+nMnHOgl9GyVjB7x3WSGHNy/6Sn4k97NO2EoJ9m6o=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86: avoid SORT_BY_INIT_PRIORITY with old GNU ld
Message-Id: <E1nmcXQ-00013W-BQ@xenbits.xenproject.org>
Date: Thu, 05 May 2022 14:33:04 +0000

commit 90ba9a2da23fbdb69c8d822f636447e8a42d1eb8
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu May 5 16:26:50 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu May 5 16:26:50 2022 +0200

    x86: avoid SORT_BY_INIT_PRIORITY with old GNU ld
    
    Support for this construct was added in 2.22 only. Avoid the need to
    introduce logic to probe for linker script capabilities by (ab)using the
    probe for a command line option having appeared at about the same time.
    
    Note that this remains x86-specific because Arm is unaffected, by
    requiring GNU ld 2.24 or newer.
    
    Fixes: 4b7fd8153ddf ("x86: fold sections in final binaries")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/arch.mk   | 10 ++++++++++
 xen/arch/x86/xen.lds.S |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk
index fce2ef5b67..fb86cbda46 100644
--- a/xen/arch/x86/arch.mk
+++ b/xen/arch/x86/arch.mk
@@ -73,6 +73,16 @@ ifeq ($(CONFIG_UBSAN),y)
 $(call cc-option-add,CFLAGS_UBSAN,CC,-fno-sanitize=alignment)
 endif
 
+ifeq ($(CONFIG_LD_IS_GNU),y)
+# While not much better than going by raw GNU ld version, utilize that the
+# feature we're after has appeared in the same release as the
+# --print-output-format command line option.
+AFLAGS-$(call ld-option,--print-output-format) += -DHAVE_LD_SORT_BY_INIT_PRIORITY
+else
+# Assume all versions of LLD support this.
+AFLAGS += -DHAVE_LD_SORT_BY_INIT_PRIORITY
+endif
+
 ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y)
 
 efi-check := arch/x86/efi/check
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index d94915ea7d..8930e14fc4 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -36,6 +36,10 @@ ENTRY(start_pa)
 # define SECTION_ALIGN PAGE_SIZE
 #endif
 
+#ifndef HAVE_LD_SORT_BY_INIT_PRIORITY
+# define SORT_BY_INIT_PRIORITY SORT
+#endif
+
 OUTPUT_FORMAT(FORMAT, FORMAT, FORMAT)
 
 OUTPUT_ARCH(i386:x86-64)
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri May 06 00:33:09 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 06 May 2022 00:33:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.322454.543749 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nmlu3-0004o8-7d; Fri, 06 May 2022 00:33:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 322454.543749; Fri, 06 May 2022 00: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 1nmlu3-0004o1-50; Fri, 06 May 2022 00:33:03 +0000
Received: by outflank-mailman (input) for mailman id 322454;
 Fri, 06 May 2022 00: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 1nmlu1-0004nv-Qz
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 00: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 1nmlu1-0002pb-Nv
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 00:33:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nmlu1-0004tT-Mf
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 00: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=HwfE/i0WWOTXHEG/Ahi1cOSOPDFouMk5qxlyz4KWtLc=; b=P4AplLVDLlJ31mXQeqpPFG7R5O
	zrqot97tUJu/9V58XK7qco+TYvdBq2diGQS2kVNqi0Go7xN1uQFm8Av03wuxnX/H8i7DitEJb0YJ1
	9baOwuaspjgqxCabliyOMz/xu7PkrujynZEsGKZMyGjKKQbeaC+0UCb1AIghkFf73Pms=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] SUPPORT.MD: Correct the amount of physical memory supported for Arm
Message-Id: <E1nmlu1-0004tT-Mf@xenbits.xenproject.org>
Date: Fri, 06 May 2022 00:33:01 +0000

commit a5968a553f6a6c170254520038f69cb49ff7d191
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Thu May 5 11:46:57 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu May 5 11:47:09 2022 +0100

    SUPPORT.MD: Correct the amount of physical memory supported for Arm
    
    As part of XSA-385, SUPPORT.MD gained a statement regarding the amount
    of physical memory supported.
    
    However, booting Xen on a Arm platform with that amount of memory would
    result to a breakage because the frametable area is too small.
    
    The wiki [1] (as of April 2022) claims we were able to support up to
    5 TiB on Arm64 and 16 GiB. However, this is not the case because
    the struct page_info has always been bigger than expected (56 bytes
    for 64-bit and 32-bytes for 32-bit).
    
    I don't have any HW with such amount of memory. So rather than
    modifying the code, take the opportunity to use the limit that should
    work on Arm (2 TiB for 64-bit and 12 GiB for 32-bit).
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com> #arm part
---
 SUPPORT.md | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/SUPPORT.md b/SUPPORT.md
index 088dda9561..cdf93181cf 100644
--- a/SUPPORT.md
+++ b/SUPPORT.md
@@ -50,9 +50,10 @@ For the Cortex A57 r0p0 - r1p1, see Errata 832075.
 
 ### Physical Memory
 
-    Status: Supported up to 8 TiB
-
-Hosts with more memory are supported, but not security supported.
+    Status, x86: Supported up to 8 TiB. Hosts with more memory are
+                 supported, but not security supported.
+    Status, Arm32: Supported up to 12 GiB
+    Status, Arm64: Supported up to 2 TiB
 
 ### Physical Memory Hotplug
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri May 06 00:33:13 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 06 May 2022 00:33:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.322455.543753 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nmluD-0004qB-9O; Fri, 06 May 2022 00:33:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 322455.543753; Fri, 06 May 2022 00: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 1nmluD-0004q4-6c; Fri, 06 May 2022 00:33:13 +0000
Received: by outflank-mailman (input) for mailman id 322455;
 Fri, 06 May 2022 00: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 1nmluB-0004ps-SD
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 00: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 1nmluB-0002pf-RR
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 00:33:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nmluB-0004ub-QY
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 00: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=or5T3IXQ6h+DnYOPeWPMGAWhMcAPK9LLnn2UMLPwwQk=; b=eFE8REVaRiiCR+0gOd4JIo5L14
	SeZ1KSUEZOmn7UvNAfBZ1XTSHh9OXkNpoV19KO42XvmNn7OMVus+I+3kF79CmevY9H/Y3lCpNhMS7
	6tohWG7BkB4jOSP5LGK3N6V05mtYzT9DpM/qUTGJJ4M/U96J0r0ZhghtME0QB259YSbk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: Advertise workaround 1 if we apply 3
Message-Id: <E1nmluB-0004ub-QY@xenbits.xenproject.org>
Date: Fri, 06 May 2022 00:33:11 +0000

commit af570d1c90f1ed6040d724732f6c582383782e90
Author:     Bertrand Marquis <bertrand.marquis@arm.com>
AuthorDate: Tue May 3 10:38:30 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu May 5 11:50:05 2022 +0100

    xen/arm: Advertise workaround 1 if we apply 3
    
    SMCC_WORKAROUND_3 is handling both Spectre v2 and spectre BHB.
    So when a guest is asking if we support workaround 1, tell yes if we
    apply workaround 3 on exception entry as it handles it.
    
    This will allow guests not supporting Spectre BHB but impacted by
    spectre v2 to still handle it correctly.
    The modified behaviour is coherent with what the Linux kernel does in
    KVM for guests.
    
    While there use ARM_SMCCC_SUCCESS instead of 0 for the return code value
    for workaround detection to be coherent with Workaround 2 handling.
    
    Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/vsmc.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/vsmc.c b/xen/arch/arm/vsmc.c
index b633ff2fe8..676740ef15 100644
--- a/xen/arch/arm/vsmc.c
+++ b/xen/arch/arm/vsmc.c
@@ -104,8 +104,13 @@ static bool handle_arch(struct cpu_user_regs *regs)
         switch ( arch_func_id )
         {
         case ARM_SMCCC_ARCH_WORKAROUND_1_FID:
-            if ( cpus_have_cap(ARM_HARDEN_BRANCH_PREDICTOR) )
-                ret = 0;
+            /*
+             * Workaround 3 is also mitigating spectre v2 so advertise that we
+             * support Workaround 1 if we do Workaround 3 on exception entry.
+             */
+            if ( cpus_have_cap(ARM_HARDEN_BRANCH_PREDICTOR) ||
+                 cpus_have_cap(ARM_WORKAROUND_BHB_SMCC_3) )
+                ret = ARM_SMCCC_SUCCESS;
             break;
         case ARM_SMCCC_ARCH_WORKAROUND_2_FID:
             switch ( get_ssbd_state() )
@@ -126,7 +131,7 @@ static bool handle_arch(struct cpu_user_regs *regs)
             break;
         case ARM_SMCCC_ARCH_WORKAROUND_3_FID:
             if ( cpus_have_cap(ARM_WORKAROUND_BHB_SMCC_3) )
-                ret = 0;
+                ret = ARM_SMCCC_SUCCESS;
             break;
         }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri May 06 00:33:23 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 06 May 2022 00:33:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.322456.543758 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nmluN-0004sW-Ao; Fri, 06 May 2022 00:33:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 322456.543758; Fri, 06 May 2022 00: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 1nmluN-0004sO-89; Fri, 06 May 2022 00:33:23 +0000
Received: by outflank-mailman (input) for mailman id 322456;
 Fri, 06 May 2022 00: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 1nmluL-0004sA-VZ
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 00:33: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 1nmluL-0002pw-Ur
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 00:33:21 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nmluL-0004v9-Tu
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 00:33: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=5bTITPXqvfIiK4NuUyri5wx3qVvFhIKUJLsbDzP32BE=; b=VMoKsyg9asBUstpLQ34dCrumij
	03KaR2IclFEM6kol6gzJDX14SPiO+DCLZ+GWO5gByNkIUVl64QvrUtrYNwIFFOvdZ+O/DEFj6cBN3
	dWdBrq64ile6D4FXJ5lo+Hj3UpY6BGoZKor7NQjASYU+FToRawRFCh55Raj6fm6Hs5PE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xenstore: don't let special watches be children of /
Message-Id: <E1nmluL-0004v9-Tu@xenbits.xenproject.org>
Date: Fri, 06 May 2022 00:33:21 +0000

commit c1d5e4021c9d3878eab9bb1c65eb3c21ef9d5ddc
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Mon May 2 12:07:22 2022 +0200
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu May 5 11:58:47 2022 +0100

    tools/xenstore: don't let special watches be children of /
    
    When firing special watches (e.g. "@releaseDomain"), they will be
    regarded to be valid children of the "/" node. So a domain having
    registered a watch for "/" and having the privilege to receive
    the special watches will receive those special watch events for the
    registered "/" watch.
    
    Fix that by calling the related fire_watches() with the "exact"
    parameter set to true, causing a mismatch for the "/" node.
    
    Reported-by: Raphael Ning <raphning@amazon.com>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Raphael Ning <raphning@amazon.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 tools/xenstore/xenstored_domain.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
index ae065fcbee..80ba1d627b 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -231,7 +231,7 @@ static int destroy_domain(void *_domain)
 			unmap_interface(domain->interface);
 	}
 
-	fire_watches(NULL, domain, "@releaseDomain", NULL, false, NULL);
+	fire_watches(NULL, domain, "@releaseDomain", NULL, true, NULL);
 
 	wrl_domain_destroy(domain);
 
@@ -282,7 +282,7 @@ void check_domains(void)
 	}
 
 	if (notify)
-		fire_watches(NULL, NULL, "@releaseDomain", NULL, false, NULL);
+		fire_watches(NULL, NULL, "@releaseDomain", NULL, true, NULL);
 }
 
 /* We scan all domains rather than use the information given here. */
@@ -495,7 +495,7 @@ static struct domain *introduce_domain(const void *ctx,
 
 		if (!is_master_domain && !restore)
 			fire_watches(NULL, ctx, "@introduceDomain", NULL,
-				     false, NULL);
+				     true, NULL);
 	} else {
 		/* Use XS_INTRODUCE for recreating the xenbus event-channel. */
 		if (domain->port)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri May 06 09:55:08 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 06 May 2022 09:55:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.322832.544257 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nmufv-0008VE-RA; Fri, 06 May 2022 09:55:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 322832.544257; Fri, 06 May 2022 09: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 1nmufv-0008V6-O4; Fri, 06 May 2022 09:55:03 +0000
Received: by outflank-mailman (input) for mailman id 322832;
 Fri, 06 May 2022 09: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 1nmuft-0008Uy-ND
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 09: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 1nmuft-0003VG-KT
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 09:55:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nmuft-0003oi-JQ
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 09: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=vSrkVqeH1ArPFASl32Q+ymB35w1XNAOxlFZVVZGtfQk=; b=cLgm92ykmHL1tBlMer0mACZFhP
	8oI+gXNB20S4UZ6tdOrfPn2yqt3zQZIWxmyPjEu1qeci8qjP4X/WdxzrvIbIwa5KYtLywgB97Hbct
	BPNfUkspof0A8VPVWkp8Kf7HDP9MME7hgG77AHr5sEHGCtClp7ntLxr/tRKqQlzjdTlk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86: avoid SORT_BY_INIT_PRIORITY with old GNU ld
Message-Id: <E1nmuft-0003oi-JQ@xenbits.xenproject.org>
Date: Fri, 06 May 2022 09:55:01 +0000

commit 90ba9a2da23fbdb69c8d822f636447e8a42d1eb8
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu May 5 16:26:50 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu May 5 16:26:50 2022 +0200

    x86: avoid SORT_BY_INIT_PRIORITY with old GNU ld
    
    Support for this construct was added in 2.22 only. Avoid the need to
    introduce logic to probe for linker script capabilities by (ab)using the
    probe for a command line option having appeared at about the same time.
    
    Note that this remains x86-specific because Arm is unaffected, by
    requiring GNU ld 2.24 or newer.
    
    Fixes: 4b7fd8153ddf ("x86: fold sections in final binaries")
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/arch.mk   | 10 ++++++++++
 xen/arch/x86/xen.lds.S |  4 ++++
 2 files changed, 14 insertions(+)

diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk
index fce2ef5b67..fb86cbda46 100644
--- a/xen/arch/x86/arch.mk
+++ b/xen/arch/x86/arch.mk
@@ -73,6 +73,16 @@ ifeq ($(CONFIG_UBSAN),y)
 $(call cc-option-add,CFLAGS_UBSAN,CC,-fno-sanitize=alignment)
 endif
 
+ifeq ($(CONFIG_LD_IS_GNU),y)
+# While not much better than going by raw GNU ld version, utilize that the
+# feature we're after has appeared in the same release as the
+# --print-output-format command line option.
+AFLAGS-$(call ld-option,--print-output-format) += -DHAVE_LD_SORT_BY_INIT_PRIORITY
+else
+# Assume all versions of LLD support this.
+AFLAGS += -DHAVE_LD_SORT_BY_INIT_PRIORITY
+endif
+
 ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y)
 
 efi-check := arch/x86/efi/check
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index d94915ea7d..8930e14fc4 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -36,6 +36,10 @@ ENTRY(start_pa)
 # define SECTION_ALIGN PAGE_SIZE
 #endif
 
+#ifndef HAVE_LD_SORT_BY_INIT_PRIORITY
+# define SORT_BY_INIT_PRIORITY SORT
+#endif
+
 OUTPUT_FORMAT(FORMAT, FORMAT, FORMAT)
 
 OUTPUT_ARCH(i386:x86-64)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri May 06 12:55:11 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 06 May 2022 12:55:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.323097.544645 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nmxUA-0004kf-Eq; Fri, 06 May 2022 12:55:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 323097.544645; Fri, 06 May 2022 12: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 1nmxUA-0004kY-C7; Fri, 06 May 2022 12:55:06 +0000
Received: by outflank-mailman (input) for mailman id 323097;
 Fri, 06 May 2022 12: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 1nmxU9-0004kS-HB
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 12: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 1nmxU9-0006p8-Di
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 12:55:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nmxU9-0007bD-CZ
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 12:55: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=sv9vf4RwXjSidm/N7zkEdC5dj3gyCTkSHSZDO/WWQtU=; b=1ckuK4dOpk5k3EJJHxrVKO7P4B
	uRiHe/ZMb3xyuF5yqB3yIs7SLHNm4dhFWkGf2gBKeOCvQfmZlSyhZlgmj617zp+IrWFd+D8GGjPMs
	+Iq2M1Aexh/Z4oaAsbbzb8/J4cv+f0cuiPcgbBzHQYrMJS38BBEIVo6sYDPpy+HQVOc0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] bump default SeaBIOS version to 1.16.0
Message-Id: <E1nmxU9-0007bD-CZ@xenbits.xenproject.org>
Date: Fri, 06 May 2022 12:55:05 +0000

commit 944e389daa133dd310d87c4eebacba9f6da76018
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 6 14:46:52 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 6 14:46:52 2022 +0200

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

diff --git a/Config.mk b/Config.mk
index 82832945e5..a806ef0afb 100644
--- a/Config.mk
+++ b/Config.mk
@@ -232,7 +232,7 @@ OVMF_UPSTREAM_REVISION ?= 7b4a99be8a39c12d3a7fc4b8db9f0eab4ac688d5
 QEMU_UPSTREAM_REVISION ?= master
 MINIOS_UPSTREAM_REVISION ?= 83ff43bff4bdd6879539fcb2b3d6ba5e61a64135
 
-SEABIOS_UPSTREAM_REVISION ?= rel-1.15.0
+SEABIOS_UPSTREAM_REVISION ?= rel-1.16.0
 
 ETHERBOOT_NICS ?= rtl8139 8086100e
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri May 06 12:55:16 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 06 May 2022 12:55:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.323098.544650 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nmxUK-0004mi-Gn; Fri, 06 May 2022 12:55:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 323098.544650; Fri, 06 May 2022 12:55: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 1nmxUK-0004ma-Dp; Fri, 06 May 2022 12:55:16 +0000
Received: by outflank-mailman (input) for mailman id 323098;
 Fri, 06 May 2022 12:55: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 1nmxUJ-0004mR-Hy
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 12:55: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 1nmxUJ-0006pE-HD
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 12:55:15 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nmxUJ-0007bw-G8
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 12:55: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=a2WErMUGeLSaUM3nHJgjFIuleeIgj/ZN4bCyTlHMQ8I=; b=Cglu9MY4xJVP1U4GCHDQZhraVx
	+fWRLjhOygsYQyeaJASls5cX7vvHtzZ8WjLa8ubV8ihbcS8U7+kw3o5MULxio1aIQYav27TGeuyPh
	GfbnXHuqoILy/ajRWJBqbl85iJ3pDN+1DurHYV96sRLTwO3xuvsyrREsWNhTe8U5eS9w=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] MAINTAINERS: add myself as reviewer for IOMMU vendor independent code
Message-Id: <E1nmxUJ-0007bw-G8@xenbits.xenproject.org>
Date: Fri, 06 May 2022 12:55:15 +0000

commit ef98495a165030636e43627b3d7351e7b6f66004
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Fri May 6 14:53:31 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 6 14:53:31 2022 +0200

    MAINTAINERS: add myself as reviewer for IOMMU vendor independent code
    
    That also covers the PCI bits which I'm interested on.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index ba0d1c0c1b..96866f626e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -346,6 +346,7 @@ F:	xen/arch/x86/mm/p2m-ept.c
 IOMMU VENDOR INDEPENDENT CODE
 M:	Jan Beulich <jbeulich@suse.com>
 M:	Paul Durrant <paul@xen.org>
+R:	Roger Pau Monné <roger.pau@citrix.com>
 S:	Supported
 F:	xen/drivers/passthrough/
 X:	xen/drivers/passthrough/amd/
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri May 06 16:22:11 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 06 May 2022 16:22:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.323352.544948 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nn0iU-0006RM-AV; Fri, 06 May 2022 16:22:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 323352.544948; Fri, 06 May 2022 16: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 1nn0iU-0006RE-7f; Fri, 06 May 2022 16:22:06 +0000
Received: by outflank-mailman (input) for mailman id 323352;
 Fri, 06 May 2022 16: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 1nn0iT-0006R7-0f
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 16: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 1nn0iS-0002eT-UQ
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 16:22:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nn0iS-0004yy-TS
 for xen-changelog@lists.xenproject.org; Fri, 06 May 2022 16: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=l7MkP+euE11p+dY3FbUbF7EF/stDwQQ9HRizIaxV+6s=; b=k76OxA4pG11hZRdlk8byb5Oddq
	tdSQxysz3C43rUYjOr1x73pEWVRyC1yQ06Z6EW1xES5fgVe0wBbG3vs7N3YDWswDxnYd5s4m6VEqg
	BA5NR9d+6zQXk1cn9OxAuBRhSSeQDUyekOYxLmRzBlLoC9rnQoHpAcxgEoKy6LqbxIpQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen: io: Fix race between sending an I/O and domain shutdown
Message-Id: <E1nn0iS-0004yy-TS@xenbits.xenproject.org>
Date: Fri, 06 May 2022 16:22:04 +0000

commit b7e0d8978810b534725e94a321736496928f00a5
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Thu May 5 18:51:31 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Fri May 6 17:16:22 2022 +0100

    xen: io: Fix race between sending an I/O and domain shutdown
    
    Xen provides hypercalls to shutdown (SCHEDOP_shutdown{,_code}) and
    resume a domain (XEN_DOMCTL_resumedomain). They can be used for checkpoint
    where the expectation is the domain should continue as nothing happened
    afterwards.
    
    hvmemul_do_io() and handle_pio() will act differently if the return
    code of hvm_send_ioreq() (resp. hvmemul_do_pio_buffer()) is X86EMUL_RETRY.
    
    In this case, the I/O state will be reset to STATE_IOREQ_NONE (i.e
    no I/O is pending) and/or the PC will not be advanced.
    
    If the shutdown request happens right after the I/O was sent to the
    IOREQ, then emulation code will end up to re-execute the instruction
    and therefore forward again the same I/O (at least when reading IO port).
    
    This would be problem if the access has a side-effect. A dumb example,
    is a device implementing a counter which is incremented by one for every
    access. When running shutdown/resume in a loop, the value read by the
    OS may not be the old value + 1.
    
    Add an extra boolean in the structure hvm_vcpu_io to indicate whether
    the I/O was suspended. This is then used in place of checking the domain
    is shutting down in hvmemul_do_io() and handle_pio() as they should
    act on suspend (i.e. vcpu_start_shutdown_deferral() returns false) rather
    than shutdown.
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Paul Durrant <paul@xen.org>
---
 xen/arch/arm/ioreq.c       | 3 ++-
 xen/arch/x86/hvm/emulate.c | 3 ++-
 xen/arch/x86/hvm/io.c      | 7 ++++---
 xen/common/ioreq.c         | 4 ++++
 xen/include/xen/sched.h    | 5 +++++
 5 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/ioreq.c b/xen/arch/arm/ioreq.c
index bdd536e873..1338c86adb 100644
--- a/xen/arch/arm/ioreq.c
+++ b/xen/arch/arm/ioreq.c
@@ -92,10 +92,11 @@ enum io_state try_fwd_ioserv(struct cpu_user_regs *regs,
 
     p.data = get_user_reg(regs, info->dabt.reg);
     vio->req = p;
+    vio->suspended = false;
     vio->info.dabt_instr = instr;
 
     rc = ioreq_send(s, &p, 0);
-    if ( rc != IO_RETRY || v->domain->is_shutting_down )
+    if ( rc != IO_RETRY || vio->suspended )
         vio->req.state = STATE_IOREQ_NONE;
     else if ( !ioreq_needs_completion(&vio->req) )
         rc = IO_HANDLED;
diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index e8d510e0be..cb221f70e8 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -236,6 +236,7 @@ static int hvmemul_do_io(
     ASSERT(p.count);
 
     vio->req = p;
+    vio->suspended = false;
 
     rc = hvm_io_intercept(&p);
 
@@ -331,7 +332,7 @@ static int hvmemul_do_io(
         else
         {
             rc = ioreq_send(s, &p, 0);
-            if ( rc != X86EMUL_RETRY || currd->is_shutting_down )
+            if ( rc != X86EMUL_RETRY || vio->suspended )
                 vio->req.state = STATE_IOREQ_NONE;
             else if ( !ioreq_needs_completion(&vio->req) )
                 rc = X86EMUL_OKAY;
diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c
index f70bfde901..0309d05cfd 100644
--- a/xen/arch/x86/hvm/io.c
+++ b/xen/arch/x86/hvm/io.c
@@ -138,10 +138,11 @@ bool handle_pio(uint16_t port, unsigned int size, int dir)
 
     case X86EMUL_RETRY:
         /*
-         * We should not advance RIP/EIP if the domain is shutting down or
-         * if X86EMUL_RETRY has been returned by an internal handler.
+         * We should not advance RIP/EIP if the vio was suspended (e.g.
+         * because the domain is shutting down) or if X86EMUL_RETRY has
+         * been returned by an internal handler.
          */
-        if ( curr->domain->is_shutting_down || !vcpu_ioreq_pending(curr) )
+        if ( vio->suspended || !vcpu_ioreq_pending(curr) )
             return false;
         break;
 
diff --git a/xen/common/ioreq.c b/xen/common/ioreq.c
index 5c94e74293..4617aef29b 100644
--- a/xen/common/ioreq.c
+++ b/xen/common/ioreq.c
@@ -1251,6 +1251,7 @@ int ioreq_send(struct ioreq_server *s, ioreq_t *proto_p,
     struct vcpu *curr = current;
     struct domain *d = curr->domain;
     struct ioreq_vcpu *sv;
+    struct vcpu_io *vio = &curr->io;
 
     ASSERT(s);
 
@@ -1258,7 +1259,10 @@ int ioreq_send(struct ioreq_server *s, ioreq_t *proto_p,
         return ioreq_send_buffered(s, proto_p);
 
     if ( unlikely(!vcpu_start_shutdown_deferral(curr)) )
+    {
+        vio->suspended = true;
         return IOREQ_STATUS_RETRY;
+    }
 
     list_for_each_entry ( sv,
                           &s->ioreq_vcpu_list,
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index ed8539f6d2..6b724e7947 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -159,6 +159,11 @@ enum vio_completion {
 struct vcpu_io {
     /* I/O request in flight to device model. */
     enum vio_completion  completion;
+    /*
+     * Indicate whether the I/O was not handled because the domain
+     * is about to be paused.
+     */
+    bool                 suspended;
     ioreq_t              req;
     /* Arch specific info pertaining to the io request */
     struct arch_vcpu_io  info;
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Sun May 08 05:11:06 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sun, 08 May 2022 05:11:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.323897.545802 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nnZCA-0003B7-Ct; Sun, 08 May 2022 05:11:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 323897.545802; Sun, 08 May 2022 05: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 1nnZCA-0003Az-A6; Sun, 08 May 2022 05:11:02 +0000
Received: by outflank-mailman (input) for mailman id 323897;
 Sun, 08 May 2022 05: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 1nnZC9-0003At-OE
 for xen-changelog@lists.xenproject.org; Sun, 08 May 2022 05: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 1nnZC9-0006py-NL
 for xen-changelog@lists.xenproject.org; Sun, 08 May 2022 05:11:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nnZC9-0003Ed-M0
 for xen-changelog@lists.xenproject.org; Sun, 08 May 2022 05: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=OlKSRu0W8GDRGE6Ju33ogedGed2JQBjtydYg+za8lb4=; b=6GgVOK0B1J3sBh19FkM0+PXpop
	54/YlcUS5kt+f1i7+uk8nHiZ4xuOAsnOUa6rAgXp1z4LoBoqJVjKnvcupCCFF+rsgGESnHZ0hFQMa
	24FIe0ERxcQE8t5hhXoEsIvL/z3okmp422Y/4W/lK9Fpn21kM7CFVBDaM4oJ1zK1IT3A=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] bump default SeaBIOS version to 1.16.0
Message-Id: <E1nnZC9-0003Ed-M0@xenbits.xenproject.org>
Date: Sun, 08 May 2022 05:11:01 +0000

commit 944e389daa133dd310d87c4eebacba9f6da76018
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 6 14:46:52 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 6 14:46:52 2022 +0200

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

diff --git a/Config.mk b/Config.mk
index 82832945e5..a806ef0afb 100644
--- a/Config.mk
+++ b/Config.mk
@@ -232,7 +232,7 @@ OVMF_UPSTREAM_REVISION ?= 7b4a99be8a39c12d3a7fc4b8db9f0eab4ac688d5
 QEMU_UPSTREAM_REVISION ?= master
 MINIOS_UPSTREAM_REVISION ?= 83ff43bff4bdd6879539fcb2b3d6ba5e61a64135
 
-SEABIOS_UPSTREAM_REVISION ?= rel-1.15.0
+SEABIOS_UPSTREAM_REVISION ?= rel-1.16.0
 
 ETHERBOOT_NICS ?= rtl8139 8086100e
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sun May 08 05:11:12 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sun, 08 May 2022 05:11:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.323898.545806 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nnZCK-0003D7-ES; Sun, 08 May 2022 05:11:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 323898.545806; Sun, 08 May 2022 05: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 1nnZCK-0003Cz-Bm; Sun, 08 May 2022 05:11:12 +0000
Received: by outflank-mailman (input) for mailman id 323898;
 Sun, 08 May 2022 05: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 1nnZCJ-0003Cr-Ry
 for xen-changelog@lists.xenproject.org; Sun, 08 May 2022 05: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 1nnZCJ-0006qd-RB
 for xen-changelog@lists.xenproject.org; Sun, 08 May 2022 05:11:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nnZCJ-0003Fb-Q6
 for xen-changelog@lists.xenproject.org; Sun, 08 May 2022 05: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=K6EjP9vxuE0Jgzc+rAjNLS+a5BEwGF7n9Xwr4l/lb3g=; b=Lim+j5mt1C+t+Y3hdCIT5AKsm0
	RaWqJONh788aV6xXQcNm1TXj3hnBuXn+y4Sq/YEfR59/f0Fkw/XplWjiOaS2ZQv/gHHMnRbBVSYaL
	HTtjWcUvUZZ1avMMs/P5HtJ8fmQ+FotH4YBu5lW62LmfuGZ2LZ0a3OFUextI64gnwHFs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] MAINTAINERS: add myself as reviewer for IOMMU vendor independent code
Message-Id: <E1nnZCJ-0003Fb-Q6@xenbits.xenproject.org>
Date: Sun, 08 May 2022 05:11:11 +0000

commit ef98495a165030636e43627b3d7351e7b6f66004
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Fri May 6 14:53:31 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 6 14:53:31 2022 +0200

    MAINTAINERS: add myself as reviewer for IOMMU vendor independent code
    
    That also covers the PCI bits which I'm interested on.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 MAINTAINERS | 1 +
 1 file changed, 1 insertion(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index ba0d1c0c1b..96866f626e 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -346,6 +346,7 @@ F:	xen/arch/x86/mm/p2m-ept.c
 IOMMU VENDOR INDEPENDENT CODE
 M:	Jan Beulich <jbeulich@suse.com>
 M:	Paul Durrant <paul@xen.org>
+R:	Roger Pau Monné <roger.pau@citrix.com>
 S:	Supported
 F:	xen/drivers/passthrough/
 X:	xen/drivers/passthrough/amd/
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sun May 08 05:11:23 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sun, 08 May 2022 05:11:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.323899.545810 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nnZCV-0003Gm-GG; Sun, 08 May 2022 05:11:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 323899.545810; Sun, 08 May 2022 05: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 1nnZCV-0003Gd-DP; Sun, 08 May 2022 05:11:23 +0000
Received: by outflank-mailman (input) for mailman id 323899;
 Sun, 08 May 2022 05: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 1nnZCU-0003GJ-07
 for xen-changelog@lists.xenproject.org; Sun, 08 May 2022 05: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 1nnZCT-0006qv-Vi
 for xen-changelog@lists.xenproject.org; Sun, 08 May 2022 05:11:21 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nnZCT-0003GM-UX
 for xen-changelog@lists.xenproject.org; Sun, 08 May 2022 05:11: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=QeMPZ4ag9i52G5JGM031XouqQcDXyXzQtV1IyFP3sMg=; b=LQbZcNoZifcamGWVCMBmbyLFHK
	Wu6kG1xOKpCAcVKUoEWlPiKEHjKJKK+gkbcupdZoWHPQb9lGpTQY6LkBS3VkbaeLZeQxW5YhYMzdL
	kXFx01jLs3/ONCNBsm9iNDMnEhV/DX+otPjCHlDhbKMFdgk/JF/0wHbfIcnR+n8ZixiY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen: io: Fix race between sending an I/O and domain shutdown
Message-Id: <E1nnZCT-0003GM-UX@xenbits.xenproject.org>
Date: Sun, 08 May 2022 05:11:21 +0000

commit b7e0d8978810b534725e94a321736496928f00a5
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Thu May 5 18:51:31 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Fri May 6 17:16:22 2022 +0100

    xen: io: Fix race between sending an I/O and domain shutdown
    
    Xen provides hypercalls to shutdown (SCHEDOP_shutdown{,_code}) and
    resume a domain (XEN_DOMCTL_resumedomain). They can be used for checkpoint
    where the expectation is the domain should continue as nothing happened
    afterwards.
    
    hvmemul_do_io() and handle_pio() will act differently if the return
    code of hvm_send_ioreq() (resp. hvmemul_do_pio_buffer()) is X86EMUL_RETRY.
    
    In this case, the I/O state will be reset to STATE_IOREQ_NONE (i.e
    no I/O is pending) and/or the PC will not be advanced.
    
    If the shutdown request happens right after the I/O was sent to the
    IOREQ, then emulation code will end up to re-execute the instruction
    and therefore forward again the same I/O (at least when reading IO port).
    
    This would be problem if the access has a side-effect. A dumb example,
    is a device implementing a counter which is incremented by one for every
    access. When running shutdown/resume in a loop, the value read by the
    OS may not be the old value + 1.
    
    Add an extra boolean in the structure hvm_vcpu_io to indicate whether
    the I/O was suspended. This is then used in place of checking the domain
    is shutting down in hvmemul_do_io() and handle_pio() as they should
    act on suspend (i.e. vcpu_start_shutdown_deferral() returns false) rather
    than shutdown.
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Paul Durrant <paul@xen.org>
---
 xen/arch/arm/ioreq.c       | 3 ++-
 xen/arch/x86/hvm/emulate.c | 3 ++-
 xen/arch/x86/hvm/io.c      | 7 ++++---
 xen/common/ioreq.c         | 4 ++++
 xen/include/xen/sched.h    | 5 +++++
 5 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/ioreq.c b/xen/arch/arm/ioreq.c
index bdd536e873..1338c86adb 100644
--- a/xen/arch/arm/ioreq.c
+++ b/xen/arch/arm/ioreq.c
@@ -92,10 +92,11 @@ enum io_state try_fwd_ioserv(struct cpu_user_regs *regs,
 
     p.data = get_user_reg(regs, info->dabt.reg);
     vio->req = p;
+    vio->suspended = false;
     vio->info.dabt_instr = instr;
 
     rc = ioreq_send(s, &p, 0);
-    if ( rc != IO_RETRY || v->domain->is_shutting_down )
+    if ( rc != IO_RETRY || vio->suspended )
         vio->req.state = STATE_IOREQ_NONE;
     else if ( !ioreq_needs_completion(&vio->req) )
         rc = IO_HANDLED;
diff --git a/xen/arch/x86/hvm/emulate.c b/xen/arch/x86/hvm/emulate.c
index e8d510e0be..cb221f70e8 100644
--- a/xen/arch/x86/hvm/emulate.c
+++ b/xen/arch/x86/hvm/emulate.c
@@ -236,6 +236,7 @@ static int hvmemul_do_io(
     ASSERT(p.count);
 
     vio->req = p;
+    vio->suspended = false;
 
     rc = hvm_io_intercept(&p);
 
@@ -331,7 +332,7 @@ static int hvmemul_do_io(
         else
         {
             rc = ioreq_send(s, &p, 0);
-            if ( rc != X86EMUL_RETRY || currd->is_shutting_down )
+            if ( rc != X86EMUL_RETRY || vio->suspended )
                 vio->req.state = STATE_IOREQ_NONE;
             else if ( !ioreq_needs_completion(&vio->req) )
                 rc = X86EMUL_OKAY;
diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c
index f70bfde901..0309d05cfd 100644
--- a/xen/arch/x86/hvm/io.c
+++ b/xen/arch/x86/hvm/io.c
@@ -138,10 +138,11 @@ bool handle_pio(uint16_t port, unsigned int size, int dir)
 
     case X86EMUL_RETRY:
         /*
-         * We should not advance RIP/EIP if the domain is shutting down or
-         * if X86EMUL_RETRY has been returned by an internal handler.
+         * We should not advance RIP/EIP if the vio was suspended (e.g.
+         * because the domain is shutting down) or if X86EMUL_RETRY has
+         * been returned by an internal handler.
          */
-        if ( curr->domain->is_shutting_down || !vcpu_ioreq_pending(curr) )
+        if ( vio->suspended || !vcpu_ioreq_pending(curr) )
             return false;
         break;
 
diff --git a/xen/common/ioreq.c b/xen/common/ioreq.c
index 5c94e74293..4617aef29b 100644
--- a/xen/common/ioreq.c
+++ b/xen/common/ioreq.c
@@ -1251,6 +1251,7 @@ int ioreq_send(struct ioreq_server *s, ioreq_t *proto_p,
     struct vcpu *curr = current;
     struct domain *d = curr->domain;
     struct ioreq_vcpu *sv;
+    struct vcpu_io *vio = &curr->io;
 
     ASSERT(s);
 
@@ -1258,7 +1259,10 @@ int ioreq_send(struct ioreq_server *s, ioreq_t *proto_p,
         return ioreq_send_buffered(s, proto_p);
 
     if ( unlikely(!vcpu_start_shutdown_deferral(curr)) )
+    {
+        vio->suspended = true;
         return IOREQ_STATUS_RETRY;
+    }
 
     list_for_each_entry ( sv,
                           &s->ioreq_vcpu_list,
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index ed8539f6d2..6b724e7947 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -159,6 +159,11 @@ enum vio_completion {
 struct vcpu_io {
     /* I/O request in flight to device model. */
     enum vio_completion  completion;
+    /*
+     * Indicate whether the I/O was not handled because the domain
+     * is about to be paused.
+     */
+    bool                 suspended;
     ioreq_t              req;
     /* Arch specific info pertaining to the io request */
     struct arch_vcpu_io  info;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Mon May 09 18:11:10 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 09 May 2022 18:11:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.324715.546887 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1no7qb-0003AI-KO; Mon, 09 May 2022 18:11:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 324715.546887; Mon, 09 May 2022 18: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 1no7qb-0003AA-Go; Mon, 09 May 2022 18:11:05 +0000
Received: by outflank-mailman (input) for mailman id 324715;
 Mon, 09 May 2022 18: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 1no7qa-00039m-Cw
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 18: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 1no7qa-0002wi-CA
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 18:11:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1no7qa-0004iC-BS
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 18: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=+VYFhAIqhYUgEX2llmFE60isQpaqLHgE5BLGapcJEfA=; b=cQBCfsNfFKR7Q/OsnyNn9kJame
	hVk+ccFHzpEBfCcw6zarNTTZn/1pLq3OoqWbB9UtDpjUB8od8hC6fwYmwKAVKUFW2ly10GED5rEfp
	CezufB2jbxvfOtQuG98SHHJhxrvBvWGdandyc5MOE4Fx8yeRuoE0bexionEJgwmg4lgs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] docs: Fix SUPPORT matrix generation after a5968a553f6a
Message-Id: <E1no7qa-0004iC-BS@xenbits.xenproject.org>
Date: Mon, 09 May 2022 18:11:04 +0000

commit 577797a94a947d34c26670e6dd2e2d6840a4f4cf
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Mon May 9 09:07:07 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon May 9 19:09:52 2022 +0100

    docs: Fix SUPPORT matrix generation after a5968a553f6a
    
    Commit a5968a553f6a "SUPPORT.MD: Correct the amount of physical memory
    supported for Arm" added a support statement split over two lines.
    
    Unfortunately, docs/support-matrix-generate throw an error for it:
    
        Generating support matrix (origin/stable-NN )
        + docs/support-matrix-generate HEAD https://xenbits.xen.org/docs/unstable/SUPPORT.html origin/stable-NN https://xenbits.xen.org/docs/NN-testing/SUPPORT.html
        Status, x86: Supported up to 8 TiB. Hosts with more memory are
                     supported, but not security supported.
        Status, Arm32: Supported up to 12 GiB
        Status, Arm64: Supported up to 2 TiB
        ^ cannot parse status codeblock line:
                     supported, but not security supported.
         ? at docs/parse-support-md line 172, <F> chunk 1.
    
    It would be good to allow split support statement (to keep lines below
    80 characters) but my knowledge of the script is very limited.
    
    Therefore, workaround the error by describing the support statement
    in one long line.
    
    Fixes: a5968a553f6a "SUPPORT.MD: Correct the amount of physical memory supported for Arm"
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Acked-by: George Dunlap <george.dunlap@citrix.com>
---
 SUPPORT.md | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/SUPPORT.md b/SUPPORT.md
index cdf93181cf..ee2cd319e2 100644
--- a/SUPPORT.md
+++ b/SUPPORT.md
@@ -50,8 +50,7 @@ For the Cortex A57 r0p0 - r1p1, see Errata 832075.
 
 ### Physical Memory
 
-    Status, x86: Supported up to 8 TiB. Hosts with more memory are
-                 supported, but not security supported.
+    Status, x86: Supported up to 8 TiB. Hosts with more memory are supported, but not security supported.
     Status, Arm32: Supported up to 12 GiB
     Status, Arm64: Supported up to 2 TiB
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon May 09 18:22:07 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 09 May 2022 18:22:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.324727.546901 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1no81F-0005FF-L0; Mon, 09 May 2022 18:22:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 324727.546901; Mon, 09 May 2022 18: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 1no81F-0005F7-IP; Mon, 09 May 2022 18:22:05 +0000
Received: by outflank-mailman (input) for mailman id 324727;
 Mon, 09 May 2022 18: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 1no81E-0005F1-Qd
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 18: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 1no81E-00038j-OD
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 18:22:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1no81E-0005SK-ND
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 18: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=9DGvgm3TCG2pMhaYzUFTONMaZWfZsxFQbTTA04jZoC4=; b=XKakHJZdVjS91FCmS85uyCpmrz
	+5ZdoMoln18vX+ovdH6o/ahihraRB+/s22w63BzhQOuyvYqqvGYNXvknXQ0UZNb2d7cDi8bZDjOIS
	l/H47z0mH2+EfxmT43qiXuGhIOWnJB68ve7ZB9KigXjvY+sidUm1ppqKlmNWN3yqISsY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] arm/its: enable LPIs before mapping the collection table
Message-Id: <E1no81E-0005SK-ND@xenbits.xenproject.org>
Date: Mon, 09 May 2022 18:22:04 +0000

commit 95604873ccf56eb81e96ed0dc8b4dec3278f40ca
Author:     Rahul Singh <rahul.singh@arm.com>
AuthorDate: Wed May 4 18:15:12 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon May 9 19:12:55 2022 +0100

    arm/its: enable LPIs before mapping the collection table
    
    When Xen boots on the platform that implements the GIC 600, ITS
    MAPC_LPI_OFF uncorrectable command error issue is observed.
    
    As per the GIC-600 TRM (Revision: r1p6) MAPC_LPI_OFF command error can
    be reported if the MAPC command has tried to map a collection to a core
    that does not have LPIs enabled. The definition of GICR.EnableLPIs
    also suggests enabling the LPIs before sending any ITS command that
    involves LPIs
    
    0b0 LPI support is disabled. Any doorbell interrupt generated as a
        result of a write to a virtual LPI register must be discarded,
        and any ITS translation requests or commands involving LPIs in
        this Redistributor are ignored.
    
    0b1 LPI support is enabled.
    
    To fix the MAPC command error issue, enable the LPIs using
    GICR_CTLR.EnableLPIs before mapping the collection table.
    
    gicv3_enable_lpis() is using writel_relaxed(), write to the GICR_CTLR
    register may not be visible before gicv3_its_setup_collection() send the
    MAPC command. Use wmb() after writel_relaxed() to make sure register
    write to enable LPIs is visible.
    
    Signed-off-by: Rahul Singh <rahul.singh@arm.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
---
 xen/arch/arm/gic-v3.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index 3c472ed768..64b36cec25 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -696,6 +696,9 @@ static bool gicv3_enable_lpis(void)
     val = readl_relaxed(GICD_RDIST_BASE + GICR_CTLR);
     writel_relaxed(val | GICR_CTLR_ENABLE_LPIS, GICD_RDIST_BASE + GICR_CTLR);
 
+    /* Make sure the GIC has seen the above */
+    wmb();
+
     return true;
 }
 
@@ -812,11 +815,11 @@ static int gicv3_cpu_init(void)
     /* If the host has any ITSes, enable LPIs now. */
     if ( gicv3_its_host_has_its() )
     {
+        if ( !gicv3_enable_lpis() )
+            return -EBUSY;
         ret = gicv3_its_setup_collection(smp_processor_id());
         if ( ret )
             return ret;
-        if ( !gicv3_enable_lpis() )
-            return -EBUSY;
     }
 
     /* Set priority on PPI and SGI interrupts */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon May 09 20:44:10 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 09 May 2022 20:44:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.324808.547037 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noAEg-0001a5-2t; Mon, 09 May 2022 20:44:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 324808.547037; Mon, 09 May 2022 20:44: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 1noAEf-0001Zx-WA; Mon, 09 May 2022 20:44:05 +0000
Received: by outflank-mailman (input) for mailman id 324808;
 Mon, 09 May 2022 20: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 1noAEe-0001Zr-H8
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20: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 1noAEe-0005gv-Eb
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20:44:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noAEe-0006bK-DV
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20: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=bU5flf78/Q3WqpwqRVi+X5tsEuhS5SDxGPj6nO3WMec=; b=xK2Khio89wmal7ybrz//m0Pbeo
	5DaA6UxVz+SQQmAGIkxGTG0I7aHwOX0NjTZRJYXUZcup6Kfd6DNHqmAKhXOgz2SsqndF5RTNgp+q8
	EPMzw7o2C43aDeQbLnAxfYLN+99YGHoQEVsYrSlr6M1lhuqoxYph3wgXITIlutfEsLsg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/cpupools: Give a name to unnamed cpupools
Message-Id: <E1noAEe-0006bK-DV@xenbits.xenproject.org>
Date: Mon, 09 May 2022 20:44:04 +0000

commit 5b9647f771ce0a80c4de4eeaa55f6cf07a5d1f64
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Fri May 6 13:00:06 2022 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Mon May 9 13:32:05 2022 -0700

    tools/cpupools: Give a name to unnamed cpupools
    
    With the introduction of boot time cpupools, Xen can create many
    different cpupools at boot time other than cpupool with id 0.
    
    Since these newly created cpupools can't have an
    entry in Xenstore, create the entry using xen-init-dom0
    helper with the usual convention: Pool-<cpupool id>.
    
    Given the change, remove the check for poolid == 0 from
    libxl_cpupoolid_to_name(...).
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/helpers/xen-init-dom0.c  | 37 ++++++++++++++++++++++++++++++++++++-
 tools/libs/light/libxl_utils.c |  3 +--
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/tools/helpers/xen-init-dom0.c b/tools/helpers/xen-init-dom0.c
index c99224a4b6..37eff8868f 100644
--- a/tools/helpers/xen-init-dom0.c
+++ b/tools/helpers/xen-init-dom0.c
@@ -43,7 +43,10 @@ int main(int argc, char **argv)
     int rc;
     struct xs_handle *xsh = NULL;
     xc_interface *xch = NULL;
-    char *domname_string = NULL, *domid_string = NULL;
+    char *domname_string = NULL, *domid_string = NULL,
+         *pool_path = NULL, *pool_name = NULL;
+    xc_cpupoolinfo_t *xcinfo;
+    unsigned int pool_id = 0;
     libxl_uuid uuid;
 
     /* Accept 0 or 1 argument */
@@ -114,9 +117,41 @@ int main(int argc, char **argv)
         goto out;
     }
 
+    /* Create an entry in xenstore for each cpupool on the system */
+    do {
+        xcinfo = xc_cpupool_getinfo(xch, pool_id);
+        if (xcinfo != NULL) {
+            if (xcinfo->cpupool_id != pool_id)
+                pool_id = xcinfo->cpupool_id;
+            xc_cpupool_infofree(xch, xcinfo);
+            if (asprintf(&pool_path, "/local/pool/%d/name", pool_id) <= 0) {
+                fprintf(stderr, "cannot allocate memory for pool path\n");
+                rc = 1;
+                goto out;
+            }
+            if (asprintf(&pool_name, "Pool-%d", pool_id) <= 0) {
+                fprintf(stderr, "cannot allocate memory for pool name\n");
+                rc = 1;
+                goto out;
+            }
+            pool_id++;
+            if (!xs_write(xsh, XBT_NULL, pool_path, pool_name,
+                          strlen(pool_name))) {
+                fprintf(stderr, "cannot set pool name\n");
+                rc = 1;
+                goto out;
+            }
+            free(pool_name);
+            free(pool_path);
+            pool_path = pool_name = NULL;
+        }
+    } while(xcinfo != NULL);
+
     printf("Done setting up Dom0\n");
 
 out:
+    free(pool_path);
+    free(pool_name);
     free(domid_string);
     free(domname_string);
     xs_close(xsh);
diff --git a/tools/libs/light/libxl_utils.c b/tools/libs/light/libxl_utils.c
index 1d8a7f64ef..e5e6b2da96 100644
--- a/tools/libs/light/libxl_utils.c
+++ b/tools/libs/light/libxl_utils.c
@@ -146,8 +146,7 @@ char *libxl_cpupoolid_to_name(libxl_ctx *ctx, uint32_t poolid)
 
     snprintf(path, sizeof(path), "/local/pool/%d/name", poolid);
     s = xs_read(ctx->xsh, XBT_NULL, path, &len);
-    if (!s && (poolid == 0))
-        return strdup("Pool-0");
+
     return s;
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon May 09 20:44:16 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 09 May 2022 20:44:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.324809.547041 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noAEq-0001by-4F; Mon, 09 May 2022 20:44:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 324809.547041; Mon, 09 May 2022 20:44: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 1noAEq-0001bq-1U; Mon, 09 May 2022 20:44:16 +0000
Received: by outflank-mailman (input) for mailman id 324809;
 Mon, 09 May 2022 20: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 1noAEo-0001bf-JD
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20: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 1noAEo-0005h1-IO
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20:44:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noAEo-0006bx-Gi
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20: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=CeNdjds0Nld69l9Ix0z/KBuoQyqUFiRfj56Xff4GSxY=; b=tyuwsUaUxxlqcDwIqXx9dslR61
	FVX+1uPcB8Jsn6CC/9+nANWhD/K5hG1soeTynGkQGAb0eqhRZte2dsdP3yRb5OgMau8TDia2XVWGL
	5tj1wYjwIYpjdWilOb2bBp3lb2FTdYAuZgTTruHQQMBHtF9F8Bq0RljrAWnUU7Pdj++k=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/sched: create public function for cpupools creation
Message-Id: <E1noAEo-0006bx-Gi@xenbits.xenproject.org>
Date: Mon, 09 May 2022 20:44:14 +0000

commit a32769dd2469ee4aeaa6371b7a4e1e52d0e0226e
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Fri May 6 13:00:07 2022 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Mon May 9 13:32:08 2022 -0700

    xen/sched: create public function for cpupools creation
    
    Create new public function to create cpupools, can take as parameter
    the scheduler id or a negative value that means the default Xen
    scheduler will be used.
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
---
 xen/common/sched/cpupool.c | 15 +++++++++++++++
 xen/include/xen/sched.h    | 16 ++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/xen/common/sched/cpupool.c b/xen/common/sched/cpupool.c
index a6da497050..89a891af70 100644
--- a/xen/common/sched/cpupool.c
+++ b/xen/common/sched/cpupool.c
@@ -1219,6 +1219,21 @@ static void cpupool_hypfs_init(void)
 
 #endif /* CONFIG_HYPFS */
 
+struct cpupool *__init cpupool_create_pool(unsigned int pool_id, int sched_id)
+{
+    struct cpupool *pool;
+
+    if ( sched_id < 0 )
+        sched_id = scheduler_get_default()->sched_id;
+
+    pool = cpupool_create(pool_id, sched_id);
+
+    BUG_ON(IS_ERR(pool));
+    cpupool_put(pool);
+
+    return pool;
+}
+
 static int __init cf_check cpupool_init(void)
 {
     unsigned int cpu;
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 6b724e7947..a0c87169d9 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -1158,6 +1158,22 @@ int cpupool_move_domain(struct domain *d, struct cpupool *c);
 int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op);
 unsigned int cpupool_get_id(const struct domain *d);
 const cpumask_t *cpupool_valid_cpus(const struct cpupool *pool);
+
+/*
+ * cpupool_create_pool - Creates a cpupool
+ * @pool_id: id of the pool to be created
+ * @sched_id: id of the scheduler to be used for the pool
+ *
+ * Creates a cpupool with pool_id id.
+ * The sched_id parameter identifies the scheduler to be used, if it is
+ * negative, the default scheduler of Xen will be used.
+ *
+ * returns:
+ *     pointer to the struct cpupool just created, or Xen will panic in case of
+ *     error
+ */
+struct cpupool *cpupool_create_pool(unsigned int pool_id, int sched_id);
+
 extern void cf_check dump_runq(unsigned char key);
 
 void arch_do_physinfo(struct xen_sysctl_physinfo *pi);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon May 09 20:44:26 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 09 May 2022 20:44:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.324810.547045 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noAF0-0001fK-5r; Mon, 09 May 2022 20:44:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 324810.547045; Mon, 09 May 2022 20:44: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 1noAF0-0001fD-31; Mon, 09 May 2022 20:44:26 +0000
Received: by outflank-mailman (input) for mailman id 324810;
 Mon, 09 May 2022 20: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 1noAEy-0001eo-MO
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20: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 1noAEy-0005hc-Ld
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20:44:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noAEy-0006cW-Kb
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20: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=RLUMwJkkZSOpWCD2v4B3cSdLf5978Tnuw9nvUDG28S0=; b=hvKzDviUNYW9QK4GxSZS8OuNzW
	4xiilJ+x0a62M362QVP9YbBNmz6HuYJwQnNHLLHO/8k+xVMM++yQ2W3i1RKaGK7XdKjBzHipPmib8
	zJ/Z/N98VWRGczFESyUiCh6QW3BWBNrXWUbtKyDKRGRHDeJNtjzEoq+1O8n14q7Y3hoo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/sched: retrieve scheduler id by name
Message-Id: <E1noAEy-0006cW-Kb@xenbits.xenproject.org>
Date: Mon, 09 May 2022 20:44:24 +0000

commit d54aed35babf1da36e6b3c0715f6cd56761af3f9
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Fri May 6 13:00:08 2022 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Mon May 9 13:32:11 2022 -0700

    xen/sched: retrieve scheduler id by name
    
    Add a static function to retrieve the scheduler pointer using the
    scheduler name.
    
    Add a public function to retrieve the scheduler id by the scheduler
    name that makes use of the new static function.
    
    Take the occasion to replace open coded scheduler search with the
    new static function in scheduler_init.
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Dario Faggioli <dfaggioli@suse.com>
---
 xen/common/sched/core.c | 40 ++++++++++++++++++++++++++--------------
 xen/include/xen/sched.h | 11 +++++++++++
 2 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index 8a8c25bbda..8c73489654 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -2947,10 +2947,30 @@ void scheduler_enable(void)
     scheduler_active = true;
 }
 
+static inline
+const struct scheduler *__init sched_get_by_name(const char *sched_name)
+{
+    unsigned int i;
+
+    for ( i = 0; i < NUM_SCHEDULERS; i++ )
+        if ( schedulers[i] && !strcmp(schedulers[i]->opt_name, sched_name) )
+            return schedulers[i];
+
+    return NULL;
+}
+
+int __init sched_get_id_by_name(const char *sched_name)
+{
+    const struct scheduler *scheduler = sched_get_by_name(sched_name);
+
+    return scheduler ? scheduler->sched_id : -1;
+}
+
 /* Initialise the data structures. */
 void __init scheduler_init(void)
 {
     struct domain *idle_domain;
+    const struct scheduler *scheduler;
     int i;
 
     scheduler_enable();
@@ -2981,25 +3001,17 @@ void __init scheduler_init(void)
                    schedulers[i]->opt_name);
             schedulers[i] = NULL;
         }
-
-        if ( schedulers[i] && !ops.name &&
-             !strcmp(schedulers[i]->opt_name, opt_sched) )
-            ops = *schedulers[i];
     }
 
-    if ( !ops.name )
+    scheduler = sched_get_by_name(opt_sched);
+    if ( !scheduler )
     {
         printk("Could not find scheduler: %s\n", opt_sched);
-        for ( i = 0; i < NUM_SCHEDULERS; i++ )
-            if ( schedulers[i] &&
-                 !strcmp(schedulers[i]->opt_name, CONFIG_SCHED_DEFAULT) )
-            {
-                ops = *schedulers[i];
-                break;
-            }
-        BUG_ON(!ops.name);
-        printk("Using '%s' (%s)\n", ops.name, ops.opt_name);
+        scheduler = sched_get_by_name(CONFIG_SCHED_DEFAULT);
+        BUG_ON(!scheduler);
+        printk("Using '%s' (%s)\n", scheduler->name, scheduler->opt_name);
     }
+    ops = *scheduler;
 
     if ( cpu_schedule_up(0) )
         BUG();
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index a0c87169d9..17cc4b1159 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -769,6 +769,17 @@ void sched_destroy_domain(struct domain *d);
 long sched_adjust(struct domain *, struct xen_domctl_scheduler_op *);
 long sched_adjust_global(struct xen_sysctl_scheduler_op *);
 int  sched_id(void);
+
+/*
+ * sched_get_id_by_name - retrieves a scheduler id given a scheduler name
+ * @sched_name: scheduler name as a string
+ *
+ * returns:
+ *     positive value being the scheduler id, on success
+ *     negative value if the scheduler name is not found.
+ */
+int sched_get_id_by_name(const char *sched_name);
+
 void vcpu_wake(struct vcpu *v);
 long vcpu_yield(void);
 void vcpu_sleep_nosync(struct vcpu *v);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon May 09 20:44:36 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 09 May 2022 20:44:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.324811.547049 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noAFA-0001i4-80; Mon, 09 May 2022 20:44:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 324811.547049; Mon, 09 May 2022 20:44: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 1noAFA-0001hx-4e; Mon, 09 May 2022 20:44:36 +0000
Received: by outflank-mailman (input) for mailman id 324811;
 Mon, 09 May 2022 20: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 1noAF8-0001hl-Pr
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20: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 1noAF8-0005hm-P2
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20:44:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noAF8-0006d9-O4
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20: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=9GrXzYVBiPI44xt+lP5LfY3AFGj6Y/EjNJy7laRG92g=; b=RDqDnyQiJ/IFRDENaXTa86d8+X
	W+JGkmfuPlISYqHELEM8wk0pkGpc3echELnB3y987qtMd5ULejSnn/M7YYPh4CBxGF8GucZccXxvq
	WVlHRP/+XnHJE9rlBlNa0EpYMSSJfCvzcAj8eWw3eLUDklEXgJxfGMGZHrnSfBMAOCLg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/cpupool: Create different cpupools at boot time
Message-Id: <E1noAF8-0006d9-O4@xenbits.xenproject.org>
Date: Mon, 09 May 2022 20:44:34 +0000

commit a6dc3b947cd1ba1ae95ef0a46cf4ab4b8a2d3ebd
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Fri May 6 13:00:09 2022 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Mon May 9 13:32:33 2022 -0700

    xen/cpupool: Create different cpupools at boot time
    
    Introduce a way to create different cpupools at boot time, this is
    particularly useful on ARM big.LITTLE system where there might be the
    need to have different cpupools for each type of core, but also
    systems using NUMA can have different cpu pools for each node.
    
    The feature on arm relies on a specification of the cpupools from the
    device tree to build pools and assign cpus to them.
    
    ACPI is not supported for this feature.
    
    With this patch, cpupool0 can now have less cpus than the number of
    online ones, so update the default case for opt_dom0_max_vcpus.
    
    Documentation is created to explain the feature.
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    Acked-by: George Dunlap <george.dunlap@citrix.com>
---
 MAINTAINERS                            |   2 +-
 docs/misc/arm/device-tree/cpupools.txt | 140 ++++++++++++++++++++++
 xen/arch/arm/domain_build.c            |   5 +-
 xen/arch/arm/include/asm/smp.h         |   3 +
 xen/common/sched/Kconfig               |   7 ++
 xen/common/sched/Makefile              |   1 +
 xen/common/sched/boot-cpupool.c        | 207 +++++++++++++++++++++++++++++++++
 xen/common/sched/cpupool.c             |  12 +-
 xen/include/xen/sched.h                |  14 +++
 9 files changed, 388 insertions(+), 3 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 96866f626e..a0b0d88ea4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -279,7 +279,7 @@ CPU POOLS
 M:	Juergen Gross <jgross@suse.com>
 M:	Dario Faggioli <dfaggioli@suse.com>
 S:	Supported
-F:	xen/common/sched/cpupool.c
+F:	xen/common/sched/*cpupool.c
 
 DEVICE TREE
 M:	Stefano Stabellini <sstabellini@kernel.org>
diff --git a/docs/misc/arm/device-tree/cpupools.txt b/docs/misc/arm/device-tree/cpupools.txt
new file mode 100644
index 0000000000..1f640d6803
--- /dev/null
+++ b/docs/misc/arm/device-tree/cpupools.txt
@@ -0,0 +1,140 @@
+Boot time cpupools
+==================
+
+When BOOT_TIME_CPUPOOLS is enabled in the Xen configuration, it is possible to
+create cpupools during boot phase by specifying them in the device tree.
+ACPI is not supported for this feature.
+
+Cpupools specification nodes shall be direct childs of /chosen node.
+Each cpupool node contains the following properties:
+
+- compatible (mandatory)
+
+    Must always include the compatiblity string: "xen,cpupool".
+
+- cpupool-cpus (mandatory)
+
+    Must be a list of device tree phandle to nodes describing cpus (e.g. having
+    device_type = "cpu"), it can't be empty.
+
+- cpupool-sched (optional)
+
+    Must be a string having the name of a Xen scheduler. Check the sched=<...>
+    boot argument for allowed values [1]. When this property is omitted, the Xen
+    default scheduler will be used.
+
+
+Constraints
+===========
+
+If no cpupools are specified, all cpus will be assigned to one cpupool
+implicitly created (Pool-0).
+
+If cpupools node are specified, but not every cpu brought up by Xen is assigned,
+all the not assigned cpu will be assigned to an additional cpupool.
+
+If a cpu is assigned to a cpupool, but it's not brought up correctly, Xen will
+stop.
+
+The boot cpu must be assigned to Pool-0, so the cpupool containing that core
+will become Pool-0 automatically.
+
+
+Examples
+========
+
+A system having two types of core, the following device tree specification will
+instruct Xen to have two cpupools:
+
+- The cpupool described by node cpupool_a will have 4 cpus assigned.
+- The cpupool described by node cpupool_b will have 2 cpus assigned.
+
+The following example can work only if hmp-unsafe=1 is passed to Xen boot
+arguments, otherwise not all cores will be brought up by Xen and the cpupool
+creation process will stop Xen.
+
+
+a72_1: cpu@0 {
+        compatible = "arm,cortex-a72";
+        reg = <0x0 0x0>;
+        device_type = "cpu";
+        [...]
+};
+
+a72_2: cpu@1 {
+        compatible = "arm,cortex-a72";
+        reg = <0x0 0x1>;
+        device_type = "cpu";
+        [...]
+};
+
+a53_1: cpu@100 {
+        compatible = "arm,cortex-a53";
+        reg = <0x0 0x100>;
+        device_type = "cpu";
+        [...]
+};
+
+a53_2: cpu@101 {
+        compatible = "arm,cortex-a53";
+        reg = <0x0 0x101>;
+        device_type = "cpu";
+        [...]
+};
+
+a53_3: cpu@102 {
+        compatible = "arm,cortex-a53";
+        reg = <0x0 0x102>;
+        device_type = "cpu";
+        [...]
+};
+
+a53_4: cpu@103 {
+        compatible = "arm,cortex-a53";
+        reg = <0x0 0x103>;
+        device_type = "cpu";
+        [...]
+};
+
+chosen {
+
+    cpupool_a {
+        compatible = "xen,cpupool";
+        cpupool-cpus = <&a53_1 &a53_2 &a53_3 &a53_4>;
+    };
+    cpupool_b {
+        compatible = "xen,cpupool";
+        cpupool-cpus = <&a72_1 &a72_2>;
+        cpupool-sched = "credit2";
+    };
+
+    [...]
+
+};
+
+
+A system having the cpupools specification below will instruct Xen to have three
+cpupools:
+
+- The cpupool described by node cpupool_a will have 2 cpus assigned.
+- The cpupool described by node cpupool_b will have 2 cpus assigned.
+- An additional cpupool will be created, having 2 cpus assigned (created by Xen
+  with all the unassigned cpus a53_3 and a53_4).
+
+chosen {
+
+    cpupool_a {
+        compatible = "xen,cpupool";
+        cpupool-cpus = <&a53_1 &a53_2>;
+    };
+    cpupool_b {
+        compatible = "xen,cpupool";
+        cpupool-cpus = <&a72_1 &a72_2>;
+        cpupool-sched = "null";
+    };
+
+    [...]
+
+};
+
+[1] docs/misc/xen-command-line.pandoc
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 1472ca4972..5df5c8ffb8 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -73,7 +73,10 @@ custom_param("dom0_mem", parse_dom0_mem);
 unsigned int __init dom0_max_vcpus(void)
 {
     if ( opt_dom0_max_vcpus == 0 )
-        opt_dom0_max_vcpus = num_online_cpus();
+    {
+        ASSERT(cpupool0);
+        opt_dom0_max_vcpus = cpumask_weight(cpupool_valid_cpus(cpupool0));
+    }
     if ( opt_dom0_max_vcpus > MAX_VIRT_CPUS )
         opt_dom0_max_vcpus = MAX_VIRT_CPUS;
 
diff --git a/xen/arch/arm/include/asm/smp.h b/xen/arch/arm/include/asm/smp.h
index af5a2fe652..83c0cd6976 100644
--- a/xen/arch/arm/include/asm/smp.h
+++ b/xen/arch/arm/include/asm/smp.h
@@ -34,6 +34,9 @@ extern void init_secondary(void);
 extern void smp_init_cpus(void);
 extern void smp_clear_cpu_maps (void);
 extern int smp_get_max_cpus (void);
+
+#define cpu_physical_id(cpu) cpu_logical_map(cpu)
+
 #endif
 
 /*
diff --git a/xen/common/sched/Kconfig b/xen/common/sched/Kconfig
index 3d9f9214b8..b2ef0c99a3 100644
--- a/xen/common/sched/Kconfig
+++ b/xen/common/sched/Kconfig
@@ -64,3 +64,10 @@ config SCHED_DEFAULT
 	default "credit2"
 
 endmenu
+
+config BOOT_TIME_CPUPOOLS
+	bool "Create cpupools at boot time"
+	depends on HAS_DEVICE_TREE
+	help
+	  Creates cpupools during boot time and assigns cpus to them. Cpupools
+	  options can be specified in the device tree.
diff --git a/xen/common/sched/Makefile b/xen/common/sched/Makefile
index 3537f2a68d..697bd54bfe 100644
--- a/xen/common/sched/Makefile
+++ b/xen/common/sched/Makefile
@@ -1,3 +1,4 @@
+obj-$(CONFIG_BOOT_TIME_CPUPOOLS) += boot-cpupool.init.o
 obj-y += cpupool.o
 obj-$(CONFIG_SCHED_ARINC653) += arinc653.o
 obj-$(CONFIG_SCHED_CREDIT) += credit.o
diff --git a/xen/common/sched/boot-cpupool.c b/xen/common/sched/boot-cpupool.c
new file mode 100644
index 0000000000..9429a5025f
--- /dev/null
+++ b/xen/common/sched/boot-cpupool.c
@@ -0,0 +1,207 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * xen/common/boot_cpupools.c
+ *
+ * Code to create cpupools at boot time.
+ *
+ * Copyright (C) 2022 Arm Ltd.
+ */
+
+#include <xen/sched.h>
+#include <asm/acpi.h>
+
+/*
+ * pool_cpu_map:   Index is logical cpu number, content is cpupool id, (-1) for
+ *                 unassigned.
+ * pool_sched_map: Index is cpupool id, content is scheduler id, (-1) for
+ *                 unassigned.
+ */
+static int __initdata pool_cpu_map[NR_CPUS]   = { [0 ... NR_CPUS-1] = -1 };
+static int __initdata pool_sched_map[NR_CPUS] = { [0 ... NR_CPUS-1] = -1 };
+static unsigned int __initdata next_pool_id;
+
+#define BTCPUPOOLS_DT_NODE_NO_REG     (-1)
+#define BTCPUPOOLS_DT_NODE_NO_LOG_CPU (-2)
+
+static int __init get_logical_cpu_from_hw_id(unsigned int hwid)
+{
+    unsigned int i;
+
+    for ( i = 0; i < nr_cpu_ids; i++ )
+    {
+        if ( cpu_physical_id(i) == hwid )
+            return i;
+    }
+
+    return -1;
+}
+
+static int __init
+get_logical_cpu_from_cpu_node(const struct dt_device_node *cpu_node)
+{
+    int cpu_num;
+    const __be32 *prop;
+    unsigned int cpu_reg;
+
+    prop = dt_get_property(cpu_node, "reg", NULL);
+    if ( !prop )
+        return BTCPUPOOLS_DT_NODE_NO_REG;
+
+    cpu_reg = dt_read_number(prop, dt_n_addr_cells(cpu_node));
+
+    cpu_num = get_logical_cpu_from_hw_id(cpu_reg);
+    if ( cpu_num < 0 )
+        return BTCPUPOOLS_DT_NODE_NO_LOG_CPU;
+
+    return cpu_num;
+}
+
+static int __init check_and_get_sched_id(const char* scheduler_name)
+{
+    int sched_id = sched_get_id_by_name(scheduler_name);
+
+    if ( sched_id < 0 )
+        panic("Scheduler %s does not exists!\n", scheduler_name);
+
+    return sched_id;
+}
+
+void __init btcpupools_dtb_parse(void)
+{
+    const struct dt_device_node *chosen, *node;
+
+    if ( !acpi_disabled )
+        return;
+
+    chosen = dt_find_node_by_path("/chosen");
+    if ( !chosen )
+        panic("/chosen missing. Boot time cpupools can't be parsed from DT.\n");
+
+    dt_for_each_child_node(chosen, node)
+    {
+        const struct dt_device_node *phandle_node;
+        int sched_id = -1;
+        const char* scheduler_name;
+        unsigned int i = 0;
+
+        if ( !dt_device_is_compatible(node, "xen,cpupool") )
+            continue;
+
+        if ( !dt_property_read_string(node, "cpupool-sched", &scheduler_name) )
+            sched_id = check_and_get_sched_id(scheduler_name);
+
+        phandle_node = dt_parse_phandle(node, "cpupool-cpus", i++);
+        if ( !phandle_node )
+            panic("Missing or empty cpupool-cpus property!\n");
+
+        while ( phandle_node )
+        {
+            int cpu_num;
+
+            cpu_num = get_logical_cpu_from_cpu_node(phandle_node);
+
+            if ( cpu_num < 0 )
+                panic("Error retrieving logical cpu from node %s (%d)\n",
+                      dt_node_name(node), cpu_num);
+
+            if ( pool_cpu_map[cpu_num] != -1 )
+                panic("Logical cpu %d already added to a cpupool!\n", cpu_num);
+
+            pool_cpu_map[cpu_num] = next_pool_id;
+
+            phandle_node = dt_parse_phandle(node, "cpupool-cpus", i++);
+        }
+
+        /* Save scheduler choice for this cpupool id */
+        pool_sched_map[next_pool_id] = sched_id;
+
+        /* Let Xen generate pool ids */
+        next_pool_id++;
+    }
+}
+
+void __init btcpupools_allocate_pools(void)
+{
+    unsigned int i;
+    bool add_extra_cpupool = false;
+    int swap_id = -1;
+
+    /*
+     * If there are no cpupools, the value of next_pool_id is zero, so the code
+     * below will assign every cpu to cpupool0 as the default behavior.
+     * When there are cpupools, the code below is assigning all the not
+     * assigned cpu to a new pool (next_pool_id value is the last id + 1).
+     * In the same loop we check if there is any assigned cpu that is not
+     * online.
+     */
+    for ( i = 0; i < nr_cpu_ids; i++ )
+    {
+        if ( cpumask_test_cpu(i, &cpu_online_map) )
+        {
+            /* Unassigned cpu gets next_pool_id pool id value */
+            if ( pool_cpu_map[i] < 0 )
+            {
+                pool_cpu_map[i] = next_pool_id;
+                add_extra_cpupool = true;
+            }
+
+            /*
+             * Cpu0 must be in cpupool0, otherwise some operations like moving
+             * cpus between cpupools, cpu hotplug, destroying cpupools, shutdown
+             * of the host, might not work in a sane way.
+             */
+            if ( !i && (pool_cpu_map[0] != 0) )
+                swap_id = pool_cpu_map[0];
+
+            if ( swap_id != -1 )
+            {
+                if ( pool_cpu_map[i] == swap_id )
+                    pool_cpu_map[i] = 0;
+                else if ( pool_cpu_map[i] == 0 )
+                    pool_cpu_map[i] = swap_id;
+            }
+        }
+        else
+        {
+            if ( pool_cpu_map[i] >= 0 )
+                panic("Pool-%d contains cpu%u that is not online!\n",
+                      pool_cpu_map[i], i);
+        }
+    }
+
+    /* A swap happened, swap schedulers between cpupool id 0 and the other */
+    if ( swap_id != -1 )
+    {
+        int swap_sched = pool_sched_map[swap_id];
+
+        pool_sched_map[swap_id] = pool_sched_map[0];
+        pool_sched_map[0] = swap_sched;
+    }
+
+    if ( add_extra_cpupool )
+        next_pool_id++;
+
+    /* Create cpupools with selected schedulers */
+    for ( i = 0; i < next_pool_id; i++ )
+        cpupool_create_pool(i, pool_sched_map[i]);
+}
+
+unsigned int __init btcpupools_get_cpupool_id(unsigned int cpu)
+{
+    ASSERT((cpu < NR_CPUS) && (pool_cpu_map[cpu] >= 0));
+
+    printk(XENLOG_INFO "Logical CPU %u in Pool-%d (Scheduler id: %d).\n",
+           cpu, pool_cpu_map[cpu], pool_sched_map[pool_cpu_map[cpu]]);
+
+    return pool_cpu_map[cpu];
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/common/sched/cpupool.c b/xen/common/sched/cpupool.c
index 89a891af70..86a175f99c 100644
--- a/xen/common/sched/cpupool.c
+++ b/xen/common/sched/cpupool.c
@@ -1247,12 +1247,22 @@ static int __init cf_check cpupool_init(void)
     cpupool_put(cpupool0);
     register_cpu_notifier(&cpu_nfb);
 
+    btcpupools_dtb_parse();
+
+    btcpupools_allocate_pools();
+
     spin_lock(&cpupool_lock);
 
     cpumask_copy(&cpupool_free_cpus, &cpu_online_map);
 
     for_each_cpu ( cpu, &cpupool_free_cpus )
-        cpupool_assign_cpu_locked(cpupool0, cpu);
+    {
+        unsigned int pool_id = btcpupools_get_cpupool_id(cpu);
+        struct cpupool *pool = cpupool_find_by_id(pool_id);
+
+        ASSERT(pool);
+        cpupool_assign_cpu_locked(pool, cpu);
+    }
 
     spin_unlock(&cpupool_lock);
 
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 17cc4b1159..20ff2febac 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -1189,6 +1189,20 @@ extern void cf_check dump_runq(unsigned char key);
 
 void arch_do_physinfo(struct xen_sysctl_physinfo *pi);
 
+#ifdef CONFIG_BOOT_TIME_CPUPOOLS
+void btcpupools_allocate_pools(void);
+unsigned int btcpupools_get_cpupool_id(unsigned int cpu);
+void btcpupools_dtb_parse(void);
+
+#else /* !CONFIG_BOOT_TIME_CPUPOOLS */
+static inline void btcpupools_allocate_pools(void) {}
+static inline void btcpupools_dtb_parse(void) {}
+static inline unsigned int btcpupools_get_cpupool_id(unsigned int cpu)
+{
+    return 0;
+}
+#endif
+
 #endif /* __SCHED_H__ */
 
 /*
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon May 09 20:44:46 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 09 May 2022 20:44:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.324812.547053 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noAFK-0001la-Aj; Mon, 09 May 2022 20:44:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 324812.547053; Mon, 09 May 2022 20:44: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 1noAFK-0001lU-7l; Mon, 09 May 2022 20:44:46 +0000
Received: by outflank-mailman (input) for mailman id 324812;
 Mon, 09 May 2022 20: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 1noAFI-0001l7-SX
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20: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 1noAFI-0005hx-Ro
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20:44:44 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noAFI-0006di-R4
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20: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=FAk5k6Q2c5rmPkL2hsw50aXNDhe7MEQ43UmNk7BMh+s=; b=vZFEe9n7vmvfJf6GYilx1gczaO
	XKreukF02qr9eTDQhaWFPvb9R3XgXFZ/Xg+l3atcsLIDtkvKqNnX0rCHbwN90OlQLkKMHwX5aay7Q
	xyRmOdnAKB20YS5/pMb9NdRo0R/I4ivy0zqXr0acVOX1ddePoMrqhHRyRiKShiXCHRtE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/cpupool: Don't allow removing cpu0 from cpupool0
Message-Id: <E1noAFI-0006di-R4@xenbits.xenproject.org>
Date: Mon, 09 May 2022 20:44:44 +0000

commit 544e8af41e23e0d1e787beaa512877f69e51fd76
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Fri May 6 13:00:10 2022 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Mon May 9 13:32:39 2022 -0700

    xen/cpupool: Don't allow removing cpu0 from cpupool0
    
    Cpu0 must remain in cpupool0, otherwise some operations like moving cpus
    between cpupools, cpu hotplug, destroying cpupools, shutdown of the host,
    might not work in a sane way.
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
---
 xen/common/sched/cpupool.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/xen/common/sched/cpupool.c b/xen/common/sched/cpupool.c
index 86a175f99c..0a93bcc631 100644
--- a/xen/common/sched/cpupool.c
+++ b/xen/common/sched/cpupool.c
@@ -572,6 +572,7 @@ static long cf_check cpupool_unassign_cpu_helper(void *info)
  * possible failures:
  * - last cpu and still active domains in cpupool
  * - cpu just being unplugged
+ * - Attempt to remove boot cpu from cpupool0
  */
 static int cpupool_unassign_cpu(struct cpupool *c, unsigned int cpu)
 {
@@ -582,7 +583,12 @@ static int cpupool_unassign_cpu(struct cpupool *c, unsigned int cpu)
     debugtrace_printk("cpupool_unassign_cpu(pool=%u,cpu=%d)\n",
                       c->cpupool_id, cpu);
 
-    if ( !cpu_online(cpu) )
+    /*
+     * Cpu0 must remain in cpupool0, otherwise some operations like moving cpus
+     * between cpupools, cpu hotplug, destroying cpupools, shutdown of the host,
+     * might not work in a sane way.
+     */
+    if ( (!c->cpupool_id && !cpu) || !cpu_online(cpu) )
         return -EINVAL;
 
     master_cpu = sched_get_resource_cpu(cpu);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon May 09 20:44:56 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 09 May 2022 20:44:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.324813.547056 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noAFU-0001oZ-CA; Mon, 09 May 2022 20:44:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 324813.547056; Mon, 09 May 2022 20:44: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 1noAFU-0001oR-9K; Mon, 09 May 2022 20:44:56 +0000
Received: by outflank-mailman (input) for mailman id 324813;
 Mon, 09 May 2022 20:44: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 1noAFS-0001oD-W4
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20: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 1noAFS-0005i7-VK
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20:44:54 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noAFS-0006eU-UH
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20: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=bQ13JcXjiOHxyoWq1T/Yfk/OIdeVNAlu+iE1etpfZRM=; b=1u4I8R8/fogLYu1k7nOKBqtSl0
	8rGJ++epivCEL5sv1gBHR7Pl51zkNHd0Jfkl0pSd0mJUb6AfLyboWlN3Kjc1LlNS8qB8e7/5lNXKh
	dxt/9mRQ4zFivO+mK9Hs+Sebxaxg1kyBgZQwL52C7UqGYdsg7W5/hYF7qlfZPDE27THg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] arm/dom0less: assign dom0less guests to cpupools
Message-Id: <E1noAFS-0006eU-UH@xenbits.xenproject.org>
Date: Mon, 09 May 2022 20:44:54 +0000

commit 92ea9c54fc81b75154a72168b9a2be969b9d7ff8
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Fri May 6 13:00:11 2022 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Mon May 9 13:32:57 2022 -0700

    arm/dom0less: assign dom0less guests to cpupools
    
    Introduce domain-cpupool property of a xen,domain device tree node,
    that specifies the cpupool device tree handle of a xen,cpupool node
    that identifies a cpupool created at boot time where the guest will
    be assigned on creation.
    
    Add member to the xen_domctl_createdomain public interface so the
    XEN_DOMCTL_INTERFACE_VERSION version is bumped.
    
    Add public function to retrieve a pool id from the device tree
    cpupool node.
    
    Update documentation about the property.
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Juergen Gross <jgross@suse.com>
---
 docs/misc/arm/device-tree/booting.txt |  5 +++++
 xen/arch/arm/domain_build.c           | 14 +++++++++++++-
 xen/common/domain.c                   |  2 +-
 xen/common/sched/boot-cpupool.c       | 24 ++++++++++++++++++++++++
 xen/include/public/domctl.h           |  5 ++++-
 xen/include/xen/sched.h               |  9 +++++++++
 6 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-tree/booting.txt
index a94125394e..7b4a29a2c2 100644
--- a/docs/misc/arm/device-tree/booting.txt
+++ b/docs/misc/arm/device-tree/booting.txt
@@ -188,6 +188,11 @@ with the following properties:
     An empty property to request the memory of the domain to be
     direct-map (guest physical address == physical address).
 
+- domain-cpupool
+
+    Optional. Handle to a xen,cpupool device tree node that identifies the
+    cpupool where the guest will be started at boot.
+
 Under the "xen,domain" compatible node, one or more sub-nodes are present
 for the DomU kernel and ramdisk.
 
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 5df5c8ffb8..aa777741bd 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -3174,7 +3174,8 @@ static int __init construct_domU(struct domain *d,
 void __init create_domUs(void)
 {
     struct dt_device_node *node;
-    const struct dt_device_node *chosen = dt_find_node_by_path("/chosen");
+    const struct dt_device_node *cpupool_node,
+                                *chosen = dt_find_node_by_path("/chosen");
 
     BUG_ON(chosen == NULL);
     dt_for_each_child_node(chosen, node)
@@ -3243,6 +3244,17 @@ void __init create_domUs(void)
                                          vpl011_virq - 32 + 1);
         }
 
+        /* Get the optional property domain-cpupool */
+        cpupool_node = dt_parse_phandle(node, "domain-cpupool", 0);
+        if ( cpupool_node )
+        {
+            int pool_id = btcpupools_get_domain_pool_id(cpupool_node);
+            if ( pool_id < 0 )
+                panic("Error getting cpupool id from domain-cpupool (%d)\n",
+                      pool_id);
+            d_cfg.cpupool_id = pool_id;
+        }
+
         /*
          * The variable max_init_domid is initialized with zero, so here it's
          * very important to use the pre-increment operator to call
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 8d2c2a9897..7570eae91a 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -697,7 +697,7 @@ struct domain *domain_create(domid_t domid,
         if ( !d->pbuf )
             goto fail;
 
-        if ( (err = sched_init_domain(d, 0)) != 0 )
+        if ( (err = sched_init_domain(d, config->cpupool_id)) != 0 )
             goto fail;
 
         if ( (err = late_hwdom_init(d)) != 0 )
diff --git a/xen/common/sched/boot-cpupool.c b/xen/common/sched/boot-cpupool.c
index 9429a5025f..240bae4ceb 100644
--- a/xen/common/sched/boot-cpupool.c
+++ b/xen/common/sched/boot-cpupool.c
@@ -22,6 +22,8 @@ static unsigned int __initdata next_pool_id;
 
 #define BTCPUPOOLS_DT_NODE_NO_REG     (-1)
 #define BTCPUPOOLS_DT_NODE_NO_LOG_CPU (-2)
+#define BTCPUPOOLS_DT_WRONG_NODE      (-3)
+#define BTCPUPOOLS_DT_CORRUPTED_NODE  (-4)
 
 static int __init get_logical_cpu_from_hw_id(unsigned int hwid)
 {
@@ -56,6 +58,28 @@ get_logical_cpu_from_cpu_node(const struct dt_device_node *cpu_node)
     return cpu_num;
 }
 
+int __init btcpupools_get_domain_pool_id(const struct dt_device_node *node)
+{
+    const struct dt_device_node *phandle_node;
+    int cpu_num;
+
+    if ( !dt_device_is_compatible(node, "xen,cpupool") )
+        return BTCPUPOOLS_DT_WRONG_NODE;
+    /*
+     * Get first cpu listed in the cpupool, from its reg it's possible to
+     * retrieve the cpupool id.
+     */
+    phandle_node = dt_parse_phandle(node, "cpupool-cpus", 0);
+    if ( !phandle_node )
+        return BTCPUPOOLS_DT_CORRUPTED_NODE;
+
+    cpu_num = get_logical_cpu_from_cpu_node(phandle_node);
+    if ( cpu_num < 0 )
+        return cpu_num;
+
+    return pool_cpu_map[cpu_num];
+}
+
 static int __init check_and_get_sched_id(const char* scheduler_name)
 {
     int sched_id = sched_get_id_by_name(scheduler_name);
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index b85e6170b0..84e75829b9 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -38,7 +38,7 @@
 #include "hvm/save.h"
 #include "memory.h"
 
-#define XEN_DOMCTL_INTERFACE_VERSION 0x00000014
+#define XEN_DOMCTL_INTERFACE_VERSION 0x00000015
 
 /*
  * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
@@ -106,6 +106,9 @@ struct xen_domctl_createdomain {
     /* Per-vCPU buffer size in bytes.  0 to disable. */
     uint32_t vmtrace_size;
 
+    /* CPU pool to use; specify 0 or a specific existing pool */
+    uint32_t cpupool_id;
+
     struct xen_arch_domainconfig arch;
 };
 
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 20ff2febac..653317cf4d 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -1193,6 +1193,7 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi);
 void btcpupools_allocate_pools(void);
 unsigned int btcpupools_get_cpupool_id(unsigned int cpu);
 void btcpupools_dtb_parse(void);
+int btcpupools_get_domain_pool_id(const struct dt_device_node *node);
 
 #else /* !CONFIG_BOOT_TIME_CPUPOOLS */
 static inline void btcpupools_allocate_pools(void) {}
@@ -1201,6 +1202,14 @@ static inline unsigned int btcpupools_get_cpupool_id(unsigned int cpu)
 {
     return 0;
 }
+#ifdef CONFIG_HAS_DEVICE_TREE
+static inline int
+btcpupools_get_domain_pool_id(const struct dt_device_node *node)
+{
+    return 0;
+}
+#endif
+
 #endif
 
 #endif /* __SCHED_H__ */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon May 09 20:45:06 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 09 May 2022 20:45:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.324814.547060 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noAFe-0001rV-EC; Mon, 09 May 2022 20:45:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 324814.547060; Mon, 09 May 2022 20:45: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 1noAFe-0001rN-Ay; Mon, 09 May 2022 20:45:06 +0000
Received: by outflank-mailman (input) for mailman id 324814;
 Mon, 09 May 2022 20:45: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 1noAFd-0001r8-2w
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20:45: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 1noAFd-0005ih-22
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20:45:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noAFd-0006fc-1G
 for xen-changelog@lists.xenproject.org; Mon, 09 May 2022 20:45: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=jl3ffqtGHCyk5YfU/J1Uz2JQVTKpPleb4lOTxbdRZVs=; b=RZAtOwbdSZ48XyyjqCLnk/vKAv
	AZkEf9625cPe4wK0lYxlx9YOm5VoGrvkPpaESmKBgGKOckhiaMRUdvqucR6qqd4NWTVa0Ipk/KWwv
	ZAViKndsTcrQV1tfuTrqhQVnQC827MKhhEla6sutVB5qlg4vbfB26tRiLUrHSgL2jgmc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/cpupool: Allow cpupool0 to use different scheduler
Message-Id: <E1noAFd-0006fc-1G@xenbits.xenproject.org>
Date: Mon, 09 May 2022 20:45:05 +0000

commit 0badfb110fa33ca9ffd3bdc3a5200cded03e6106
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Fri May 6 13:00:12 2022 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Mon May 9 13:33:03 2022 -0700

    xen/cpupool: Allow cpupool0 to use different scheduler
    
    Currently cpupool0 can use only the default scheduler, and
    cpupool_create has an hardcoded behavior when creating the pool 0
    that doesn't allocate new memory for the scheduler, but uses the
    default scheduler structure in memory.
    
    With this commit it is possible to allocate a different scheduler for
    the cpupool0 when using the boot time cpupool.
    To achieve this the hardcoded behavior in cpupool_create is removed
    and the cpupool0 creation is moved.
    
    When compiling without boot time cpupools enabled, the current
    behavior is maintained (except that cpupool0 scheduler memory will be
    allocated).
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
---
 xen/common/sched/boot-cpupool.c | 5 ++++-
 xen/common/sched/cpupool.c      | 8 +-------
 xen/include/xen/sched.h         | 5 ++++-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/xen/common/sched/boot-cpupool.c b/xen/common/sched/boot-cpupool.c
index 240bae4ceb..5955e6f9a9 100644
--- a/xen/common/sched/boot-cpupool.c
+++ b/xen/common/sched/boot-cpupool.c
@@ -205,8 +205,11 @@ void __init btcpupools_allocate_pools(void)
     if ( add_extra_cpupool )
         next_pool_id++;
 
+    /* Keep track of cpupool id 0 with the global cpupool0 */
+    cpupool0 = cpupool_create_pool(0, pool_sched_map[0]);
+
     /* Create cpupools with selected schedulers */
-    for ( i = 0; i < next_pool_id; i++ )
+    for ( i = 1; i < next_pool_id; i++ )
         cpupool_create_pool(i, pool_sched_map[i]);
 }
 
diff --git a/xen/common/sched/cpupool.c b/xen/common/sched/cpupool.c
index 0a93bcc631..f6e3d97e52 100644
--- a/xen/common/sched/cpupool.c
+++ b/xen/common/sched/cpupool.c
@@ -312,10 +312,7 @@ static struct cpupool *cpupool_create(unsigned int poolid,
         c->cpupool_id = q->cpupool_id + 1;
     }
 
-    if ( poolid == 0 )
-        c->sched = scheduler_get_default();
-    else
-        c->sched = scheduler_alloc(sched_id);
+    c->sched = scheduler_alloc(sched_id);
     if ( IS_ERR(c->sched) )
     {
         ret = PTR_ERR(c->sched);
@@ -1248,9 +1245,6 @@ static int __init cf_check cpupool_init(void)
 
     cpupool_hypfs_init();
 
-    cpupool0 = cpupool_create(0, 0);
-    BUG_ON(IS_ERR(cpupool0));
-    cpupool_put(cpupool0);
     register_cpu_notifier(&cpu_nfb);
 
     btcpupools_dtb_parse();
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 653317cf4d..463d41ffb6 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -1196,7 +1196,10 @@ void btcpupools_dtb_parse(void);
 int btcpupools_get_domain_pool_id(const struct dt_device_node *node);
 
 #else /* !CONFIG_BOOT_TIME_CPUPOOLS */
-static inline void btcpupools_allocate_pools(void) {}
+static inline void btcpupools_allocate_pools(void)
+{
+    cpupool0 = cpupool_create_pool(0, -1);
+}
 static inline void btcpupools_dtb_parse(void) {}
 static inline unsigned int btcpupools_get_cpupool_id(unsigned int cpu)
 {
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue May 10 08:22:13 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 10 May 2022 08:22:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.325285.547780 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noL87-0006PG-UN; Tue, 10 May 2022 08:22:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 325285.547780; Tue, 10 May 2022 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 1noL87-0006P8-RC; Tue, 10 May 2022 08:22:03 +0000
Received: by outflank-mailman (input) for mailman id 325285;
 Tue, 10 May 2022 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 1noL86-0006P2-F5
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 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 1noL86-0000rG-B4
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 08:22:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noL86-0001L3-9v
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 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=XJlyjCDYhFok0BsMhvWLBSvRgoLVXGQLi1eys9lOvV0=; b=ugjq+1XLQt/38b+5X3jklIw3eu
	2l7C3p9XkRjV3BAXPTvLudydF9OrPzTfEqC4xU4tPorYnQ8IzIZHAk6ORupyhdGu0OB/HphAil+ij
	QXK4QruvgIBJKRWPRiyR0Kj8xZhsg86PhZ9B1DQghYUrJPOCOWzjWvPgdTTJoQu4C4PI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] docs: Fix SUPPORT matrix generation after a5968a553f6a
Message-Id: <E1noL86-0001L3-9v@xenbits.xenproject.org>
Date: Tue, 10 May 2022 08:22:02 +0000

commit 577797a94a947d34c26670e6dd2e2d6840a4f4cf
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Mon May 9 09:07:07 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon May 9 19:09:52 2022 +0100

    docs: Fix SUPPORT matrix generation after a5968a553f6a
    
    Commit a5968a553f6a "SUPPORT.MD: Correct the amount of physical memory
    supported for Arm" added a support statement split over two lines.
    
    Unfortunately, docs/support-matrix-generate throw an error for it:
    
        Generating support matrix (origin/stable-NN )
        + docs/support-matrix-generate HEAD https://xenbits.xen.org/docs/unstable/SUPPORT.html origin/stable-NN https://xenbits.xen.org/docs/NN-testing/SUPPORT.html
        Status, x86: Supported up to 8 TiB. Hosts with more memory are
                     supported, but not security supported.
        Status, Arm32: Supported up to 12 GiB
        Status, Arm64: Supported up to 2 TiB
        ^ cannot parse status codeblock line:
                     supported, but not security supported.
         ? at docs/parse-support-md line 172, <F> chunk 1.
    
    It would be good to allow split support statement (to keep lines below
    80 characters) but my knowledge of the script is very limited.
    
    Therefore, workaround the error by describing the support statement
    in one long line.
    
    Fixes: a5968a553f6a "SUPPORT.MD: Correct the amount of physical memory supported for Arm"
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Acked-by: George Dunlap <george.dunlap@citrix.com>
---
 SUPPORT.md | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/SUPPORT.md b/SUPPORT.md
index cdf93181cf..ee2cd319e2 100644
--- a/SUPPORT.md
+++ b/SUPPORT.md
@@ -50,8 +50,7 @@ For the Cortex A57 r0p0 - r1p1, see Errata 832075.
 
 ### Physical Memory
 
-    Status, x86: Supported up to 8 TiB. Hosts with more memory are
-                 supported, but not security supported.
+    Status, x86: Supported up to 8 TiB. Hosts with more memory are supported, but not security supported.
     Status, Arm32: Supported up to 12 GiB
     Status, Arm64: Supported up to 2 TiB
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue May 10 08:22:14 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 10 May 2022 08:22:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.325286.547784 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noL8H-0006Qr-Vk; Tue, 10 May 2022 08:22:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 325286.547784; Tue, 10 May 2022 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 1noL8H-0006Ql-Sq; Tue, 10 May 2022 08:22:13 +0000
Received: by outflank-mailman (input) for mailman id 325286;
 Tue, 10 May 2022 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 1noL8G-0006QR-F0
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 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 1noL8G-0000rK-EF
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 08:22:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noL8G-0001NH-DJ
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 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=XcPbB9PiH1Wh0kxvHNBKLUX3IpKq5uUgFJ7oNtmbRYc=; b=TSQdrbOJ/Dl3xtt38PIsaNXuRQ
	WgGJSdAXwYtiTn5u8BH7lxJmYRTKVDrgjiZFggmGNm4/QneS0RoFc/mVEwiyaOlRs74mLlVntZg03
	P2MnSCMDjqp3hTIY3XoBT/AaKcp+cj7AqcXiabvhAc6qr75aVAHXSR7ir9SXWQB3kJ5A=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] arm/its: enable LPIs before mapping the collection table
Message-Id: <E1noL8G-0001NH-DJ@xenbits.xenproject.org>
Date: Tue, 10 May 2022 08:22:12 +0000

commit 95604873ccf56eb81e96ed0dc8b4dec3278f40ca
Author:     Rahul Singh <rahul.singh@arm.com>
AuthorDate: Wed May 4 18:15:12 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon May 9 19:12:55 2022 +0100

    arm/its: enable LPIs before mapping the collection table
    
    When Xen boots on the platform that implements the GIC 600, ITS
    MAPC_LPI_OFF uncorrectable command error issue is observed.
    
    As per the GIC-600 TRM (Revision: r1p6) MAPC_LPI_OFF command error can
    be reported if the MAPC command has tried to map a collection to a core
    that does not have LPIs enabled. The definition of GICR.EnableLPIs
    also suggests enabling the LPIs before sending any ITS command that
    involves LPIs
    
    0b0 LPI support is disabled. Any doorbell interrupt generated as a
        result of a write to a virtual LPI register must be discarded,
        and any ITS translation requests or commands involving LPIs in
        this Redistributor are ignored.
    
    0b1 LPI support is enabled.
    
    To fix the MAPC command error issue, enable the LPIs using
    GICR_CTLR.EnableLPIs before mapping the collection table.
    
    gicv3_enable_lpis() is using writel_relaxed(), write to the GICR_CTLR
    register may not be visible before gicv3_its_setup_collection() send the
    MAPC command. Use wmb() after writel_relaxed() to make sure register
    write to enable LPIs is visible.
    
    Signed-off-by: Rahul Singh <rahul.singh@arm.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
---
 xen/arch/arm/gic-v3.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index 3c472ed768..64b36cec25 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -696,6 +696,9 @@ static bool gicv3_enable_lpis(void)
     val = readl_relaxed(GICD_RDIST_BASE + GICR_CTLR);
     writel_relaxed(val | GICR_CTLR_ENABLE_LPIS, GICD_RDIST_BASE + GICR_CTLR);
 
+    /* Make sure the GIC has seen the above */
+    wmb();
+
     return true;
 }
 
@@ -812,11 +815,11 @@ static int gicv3_cpu_init(void)
     /* If the host has any ITSes, enable LPIs now. */
     if ( gicv3_its_host_has_its() )
     {
+        if ( !gicv3_enable_lpis() )
+            return -EBUSY;
         ret = gicv3_its_setup_collection(smp_processor_id());
         if ( ret )
             return ret;
-        if ( !gicv3_enable_lpis() )
-            return -EBUSY;
     }
 
     /* Set priority on PPI and SGI interrupts */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue May 10 14:22:10 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 10 May 2022 14:22:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.325720.548414 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noQkY-0004GU-1u; Tue, 10 May 2022 14:22:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 325720.548414; Tue, 10 May 2022 14: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 1noQkX-0004GM-Uq; Tue, 10 May 2022 14:22:05 +0000
Received: by outflank-mailman (input) for mailman id 325720;
 Tue, 10 May 2022 14: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 1noQkW-0004Ex-Cj
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 14: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 1noQkW-0007Nd-AO
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 14:22:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noQkW-0000vS-9R
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 14: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=rSsFIHYP0lWBj/Bj1TS8lrljoegW9b2WKsOmb5H+sws=; b=Tn+AvZtYd44NVia8skvqfF8I7W
	NmMxnT6zMXpNLfXLKAqQvpqzFWTlKkXsHtT4MIaIgX1jlb+PBSbwiX6e/5ZAMxlM/duwoyXXAwMFN
	Zfk6Q7eOqwHcWCcA4v99rMKyp/VBJjThhBxuLqV/FJJVy89WNvhFhyzG01XMWz+ejb7Q=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/arm: p2m don't fall over on FEAT_LPA enabled hw
Message-Id: <E1noQkW-0000vS-9R@xenbits.xenproject.org>
Date: Tue, 10 May 2022 14:22:04 +0000

commit 407b13a71e324aba76b11e5f66f59ce4a304a088
Author:     Alex Bennée <alex.bennee@linaro.org>
AuthorDate: Thu Apr 28 11:34:10 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Tue May 10 15:10:55 2022 +0100

    xen/arm: p2m don't fall over on FEAT_LPA enabled hw
    
    When we introduced FEAT_LPA to QEMU's -cpu max we discovered older
    kernels had a bug where the physical address was copied directly from
    ID_AA64MMFR0_EL1.PARange field. The early cpu_init code of Xen commits
    the same error by blindly copying across the max supported range.
    
    Unsurprisingly when the page tables aren't set up for these greater
    ranges hilarity ensues and the hypervisor crashes fairly early on in
    the boot-up sequence. This happens when we write to the control
    register in enable_mmu().
    
    Attempt to fix this the same way as the Linux kernel does by gating
    PARange to the maximum the hypervisor can handle. I also had to fix up
    code in p2m which panics when it sees an "invalid" entry in PARange.
    
    Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
    Cc: Richard Henderson <richard.henderson@linaro.org>
    Cc: Stefano Stabellini <sstabellini@kernel.org>
    Cc: Julien Grall <julien@xen.org>
    Cc: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
    Cc: Bertrand Marquis <bertrand.marquis@arm.com>
    Tested-by: Luca Fancellu <luca.fancellu@arm.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/arm64/head.S |  6 ++++++
 xen/arch/arm/p2m.c        | 10 +++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index e62c48ec1c..1fd35a8390 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -474,6 +474,12 @@ cpu_init:
         ldr   x0, =(TCR_RES1|TCR_SH0_IS|TCR_ORGN0_WBWA|TCR_IRGN0_WBWA|TCR_T0SZ(64-48))
         /* ID_AA64MMFR0_EL1[3:0] (PARange) corresponds to TCR_EL2[18:16] (PS) */
         mrs   x1, ID_AA64MMFR0_EL1
+        /* Limit to 48 bits, 256TB PA range (#5) */
+        ubfm  x1, x1, #0, #3
+        mov   x2, #5
+        cmp   x1, x2
+        csel  x1, x1, x2, lt
+
         bfi   x0, x1, #16, #3
 
         msr   tcr_el2, x0
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 1d1059f7d2..d00c2e462a 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -32,10 +32,10 @@ static unsigned int __read_mostly max_vmid = MAX_VMID_8_BIT;
 #define P2M_ROOT_PAGES    (1<<P2M_ROOT_ORDER)
 
 /*
- * Set larger than any possible value, so the number of IPA bits can be
+ * Set to the maximum configured support for IPA bits, so the number of IPA bits can be
  * restricted by external entity (e.g. IOMMU).
  */
-unsigned int __read_mostly p2m_ipa_bits = 64;
+unsigned int __read_mostly p2m_ipa_bits = PADDR_BITS;
 
 static mfn_t __read_mostly empty_root_mfn;
 
@@ -2023,7 +2023,7 @@ void __init setup_virt_paging(void)
         unsigned int root_order; /* Page order of the root of the p2m */
         unsigned int sl0;    /* Desired SL0, maximum in comment */
     } pa_range_info[] = {
-        /* T0SZ minimum and SL0 maximum from ARM DDI 0487A.b Table D4-5 */
+        /* T0SZ minimum and SL0 maximum from ARM DDI 0487H.a Table D5-6 */
         /*      PA size, t0sz(min), root-order, sl0(max) */
         [0] = { 32,      32/*32*/,  0,          1 },
         [1] = { 36,      28/*28*/,  0,          1 },
@@ -2031,7 +2031,7 @@ void __init setup_virt_paging(void)
         [3] = { 42,      22/*22*/,  3,          1 },
         [4] = { 44,      20/*20*/,  0,          2 },
         [5] = { 48,      16/*16*/,  0,          2 },
-        [6] = { 0 }, /* Invalid */
+        [6] = { 52,      12/*12*/,  3,          3 },
         [7] = { 0 }  /* Invalid */
     };
 
@@ -2062,7 +2062,7 @@ void __init setup_virt_paging(void)
         }
     }
 
-    /* pa_range is 4 bits, but the defined encodings are only 3 bits */
+    /* pa_range is 4 bits but we don't support all modes */
     if ( pa_range >= ARRAY_SIZE(pa_range_info) || !pa_range_info[pa_range].pabits )
         panic("Unknown encoding of ID_AA64MMFR0_EL1.PARange %x\n", pa_range);
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue May 10 16:55:09 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 10 May 2022 16:55:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.325902.548682 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noT8Z-000374-N8; Tue, 10 May 2022 16:55:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 325902.548682; Tue, 10 May 2022 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 1noT8Z-00036v-Jp; Tue, 10 May 2022 16:55:03 +0000
Received: by outflank-mailman (input) for mailman id 325902;
 Tue, 10 May 2022 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 1noT8X-00036m-Ro
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 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 1noT8X-0002BD-NC
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16:55:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noT8X-000762-MA
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 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=XTkRnOHRfe/X57gAIWWeS2LGa2KiW/jPGM7oBU2PXrQ=; b=Ll/SEcDja8sUuU2u/l2F6n9msc
	6mHpH5RzXlLipBIrjoRM9eXKXihIykxnnT38Tn6cYwh4hhHJkCIG5E9fqwKU8tSXCCimBymO9nulv
	aX9g2h5CCJ05b8SAugKL0qOFc2Yaclbyp7GUXvtKlW1mFDC49imTfgHgY/CTuCRbLucE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/cpupools: Give a name to unnamed cpupools
Message-Id: <E1noT8X-000762-MA@xenbits.xenproject.org>
Date: Tue, 10 May 2022 16:55:01 +0000

commit 5b9647f771ce0a80c4de4eeaa55f6cf07a5d1f64
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Fri May 6 13:00:06 2022 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Mon May 9 13:32:05 2022 -0700

    tools/cpupools: Give a name to unnamed cpupools
    
    With the introduction of boot time cpupools, Xen can create many
    different cpupools at boot time other than cpupool with id 0.
    
    Since these newly created cpupools can't have an
    entry in Xenstore, create the entry using xen-init-dom0
    helper with the usual convention: Pool-<cpupool id>.
    
    Given the change, remove the check for poolid == 0 from
    libxl_cpupoolid_to_name(...).
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/helpers/xen-init-dom0.c  | 37 ++++++++++++++++++++++++++++++++++++-
 tools/libs/light/libxl_utils.c |  3 +--
 2 files changed, 37 insertions(+), 3 deletions(-)

diff --git a/tools/helpers/xen-init-dom0.c b/tools/helpers/xen-init-dom0.c
index c99224a4b6..37eff8868f 100644
--- a/tools/helpers/xen-init-dom0.c
+++ b/tools/helpers/xen-init-dom0.c
@@ -43,7 +43,10 @@ int main(int argc, char **argv)
     int rc;
     struct xs_handle *xsh = NULL;
     xc_interface *xch = NULL;
-    char *domname_string = NULL, *domid_string = NULL;
+    char *domname_string = NULL, *domid_string = NULL,
+         *pool_path = NULL, *pool_name = NULL;
+    xc_cpupoolinfo_t *xcinfo;
+    unsigned int pool_id = 0;
     libxl_uuid uuid;
 
     /* Accept 0 or 1 argument */
@@ -114,9 +117,41 @@ int main(int argc, char **argv)
         goto out;
     }
 
+    /* Create an entry in xenstore for each cpupool on the system */
+    do {
+        xcinfo = xc_cpupool_getinfo(xch, pool_id);
+        if (xcinfo != NULL) {
+            if (xcinfo->cpupool_id != pool_id)
+                pool_id = xcinfo->cpupool_id;
+            xc_cpupool_infofree(xch, xcinfo);
+            if (asprintf(&pool_path, "/local/pool/%d/name", pool_id) <= 0) {
+                fprintf(stderr, "cannot allocate memory for pool path\n");
+                rc = 1;
+                goto out;
+            }
+            if (asprintf(&pool_name, "Pool-%d", pool_id) <= 0) {
+                fprintf(stderr, "cannot allocate memory for pool name\n");
+                rc = 1;
+                goto out;
+            }
+            pool_id++;
+            if (!xs_write(xsh, XBT_NULL, pool_path, pool_name,
+                          strlen(pool_name))) {
+                fprintf(stderr, "cannot set pool name\n");
+                rc = 1;
+                goto out;
+            }
+            free(pool_name);
+            free(pool_path);
+            pool_path = pool_name = NULL;
+        }
+    } while(xcinfo != NULL);
+
     printf("Done setting up Dom0\n");
 
 out:
+    free(pool_path);
+    free(pool_name);
     free(domid_string);
     free(domname_string);
     xs_close(xsh);
diff --git a/tools/libs/light/libxl_utils.c b/tools/libs/light/libxl_utils.c
index 1d8a7f64ef..e5e6b2da96 100644
--- a/tools/libs/light/libxl_utils.c
+++ b/tools/libs/light/libxl_utils.c
@@ -146,8 +146,7 @@ char *libxl_cpupoolid_to_name(libxl_ctx *ctx, uint32_t poolid)
 
     snprintf(path, sizeof(path), "/local/pool/%d/name", poolid);
     s = xs_read(ctx->xsh, XBT_NULL, path, &len);
-    if (!s && (poolid == 0))
-        return strdup("Pool-0");
+
     return s;
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue May 10 16:55:12 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 10 May 2022 16:55:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.325903.548688 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noT8i-00038h-Ox; Tue, 10 May 2022 16:55:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 325903.548688; Tue, 10 May 2022 16: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 1noT8i-00038Z-LS; Tue, 10 May 2022 16:55:12 +0000
Received: by outflank-mailman (input) for mailman id 325903;
 Tue, 10 May 2022 16: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 1noT8h-00038P-RY
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16: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 1noT8h-0002BM-Ql
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16:55:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noT8h-00079t-Pd
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16: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=ouKazZUE6X6ZAEOc6VqykhSxu2+cjwUq1/1wdP6h88w=; b=CgmF6aHyptGaiLkRbVVALYrO63
	HkKLUnLeFlDL6MgETWPXZtw8iKKNo1LaRB00svZl/2STaNaO0brbFZAMdHZ4xSda1O/A/mCJPmP05
	B2enQWtpnD6olw4ls7f/XO7i67XNBz3HSRiAAGR2/1P/lsJslnp1wT35Bs/9WbVc11Zc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/sched: create public function for cpupools creation
Message-Id: <E1noT8h-00079t-Pd@xenbits.xenproject.org>
Date: Tue, 10 May 2022 16:55:11 +0000

commit a32769dd2469ee4aeaa6371b7a4e1e52d0e0226e
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Fri May 6 13:00:07 2022 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Mon May 9 13:32:08 2022 -0700

    xen/sched: create public function for cpupools creation
    
    Create new public function to create cpupools, can take as parameter
    the scheduler id or a negative value that means the default Xen
    scheduler will be used.
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
---
 xen/common/sched/cpupool.c | 15 +++++++++++++++
 xen/include/xen/sched.h    | 16 ++++++++++++++++
 2 files changed, 31 insertions(+)

diff --git a/xen/common/sched/cpupool.c b/xen/common/sched/cpupool.c
index a6da497050..89a891af70 100644
--- a/xen/common/sched/cpupool.c
+++ b/xen/common/sched/cpupool.c
@@ -1219,6 +1219,21 @@ static void cpupool_hypfs_init(void)
 
 #endif /* CONFIG_HYPFS */
 
+struct cpupool *__init cpupool_create_pool(unsigned int pool_id, int sched_id)
+{
+    struct cpupool *pool;
+
+    if ( sched_id < 0 )
+        sched_id = scheduler_get_default()->sched_id;
+
+    pool = cpupool_create(pool_id, sched_id);
+
+    BUG_ON(IS_ERR(pool));
+    cpupool_put(pool);
+
+    return pool;
+}
+
 static int __init cf_check cpupool_init(void)
 {
     unsigned int cpu;
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 6b724e7947..a0c87169d9 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -1158,6 +1158,22 @@ int cpupool_move_domain(struct domain *d, struct cpupool *c);
 int cpupool_do_sysctl(struct xen_sysctl_cpupool_op *op);
 unsigned int cpupool_get_id(const struct domain *d);
 const cpumask_t *cpupool_valid_cpus(const struct cpupool *pool);
+
+/*
+ * cpupool_create_pool - Creates a cpupool
+ * @pool_id: id of the pool to be created
+ * @sched_id: id of the scheduler to be used for the pool
+ *
+ * Creates a cpupool with pool_id id.
+ * The sched_id parameter identifies the scheduler to be used, if it is
+ * negative, the default scheduler of Xen will be used.
+ *
+ * returns:
+ *     pointer to the struct cpupool just created, or Xen will panic in case of
+ *     error
+ */
+struct cpupool *cpupool_create_pool(unsigned int pool_id, int sched_id);
+
 extern void cf_check dump_runq(unsigned char key);
 
 void arch_do_physinfo(struct xen_sysctl_physinfo *pi);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue May 10 16:55:23 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 10 May 2022 16:55:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.325906.548698 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noT8t-0003GV-DL; Tue, 10 May 2022 16:55:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 325906.548698; Tue, 10 May 2022 16: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 1noT8t-0003FT-4a; Tue, 10 May 2022 16:55:23 +0000
Received: by outflank-mailman (input) for mailman id 325906;
 Tue, 10 May 2022 16: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 1noT8r-0003BN-Uy
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16:55: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 1noT8r-0002Bn-UF
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16:55:21 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noT8r-0007iP-TF
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16:55: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=e3Hg7emG3rzQsnpbvpp1D+tJzEtKJ1cuomOQiUqCjGY=; b=blkqTzbVPYZj/It4cZ5SaNeD4V
	qMGIDLmoHl5ElezDKbGl6GDO2vfJqVuT2hsj8gjZ48BUPW8IXdd2cOBC0aWHpdZ/897I0Uk82KZ64
	frf8a+N/9HvLt6A1DEbS8GgsL3Saavhez+0SKnlHBtddtG3AWgGIsnsYfZmWNVq+HQAI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/sched: retrieve scheduler id by name
Message-Id: <E1noT8r-0007iP-TF@xenbits.xenproject.org>
Date: Tue, 10 May 2022 16:55:21 +0000

commit d54aed35babf1da36e6b3c0715f6cd56761af3f9
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Fri May 6 13:00:08 2022 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Mon May 9 13:32:11 2022 -0700

    xen/sched: retrieve scheduler id by name
    
    Add a static function to retrieve the scheduler pointer using the
    scheduler name.
    
    Add a public function to retrieve the scheduler id by the scheduler
    name that makes use of the new static function.
    
    Take the occasion to replace open coded scheduler search with the
    new static function in scheduler_init.
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Dario Faggioli <dfaggioli@suse.com>
---
 xen/common/sched/core.c | 40 ++++++++++++++++++++++++++--------------
 xen/include/xen/sched.h | 11 +++++++++++
 2 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/xen/common/sched/core.c b/xen/common/sched/core.c
index 8a8c25bbda..8c73489654 100644
--- a/xen/common/sched/core.c
+++ b/xen/common/sched/core.c
@@ -2947,10 +2947,30 @@ void scheduler_enable(void)
     scheduler_active = true;
 }
 
+static inline
+const struct scheduler *__init sched_get_by_name(const char *sched_name)
+{
+    unsigned int i;
+
+    for ( i = 0; i < NUM_SCHEDULERS; i++ )
+        if ( schedulers[i] && !strcmp(schedulers[i]->opt_name, sched_name) )
+            return schedulers[i];
+
+    return NULL;
+}
+
+int __init sched_get_id_by_name(const char *sched_name)
+{
+    const struct scheduler *scheduler = sched_get_by_name(sched_name);
+
+    return scheduler ? scheduler->sched_id : -1;
+}
+
 /* Initialise the data structures. */
 void __init scheduler_init(void)
 {
     struct domain *idle_domain;
+    const struct scheduler *scheduler;
     int i;
 
     scheduler_enable();
@@ -2981,25 +3001,17 @@ void __init scheduler_init(void)
                    schedulers[i]->opt_name);
             schedulers[i] = NULL;
         }
-
-        if ( schedulers[i] && !ops.name &&
-             !strcmp(schedulers[i]->opt_name, opt_sched) )
-            ops = *schedulers[i];
     }
 
-    if ( !ops.name )
+    scheduler = sched_get_by_name(opt_sched);
+    if ( !scheduler )
     {
         printk("Could not find scheduler: %s\n", opt_sched);
-        for ( i = 0; i < NUM_SCHEDULERS; i++ )
-            if ( schedulers[i] &&
-                 !strcmp(schedulers[i]->opt_name, CONFIG_SCHED_DEFAULT) )
-            {
-                ops = *schedulers[i];
-                break;
-            }
-        BUG_ON(!ops.name);
-        printk("Using '%s' (%s)\n", ops.name, ops.opt_name);
+        scheduler = sched_get_by_name(CONFIG_SCHED_DEFAULT);
+        BUG_ON(!scheduler);
+        printk("Using '%s' (%s)\n", scheduler->name, scheduler->opt_name);
     }
+    ops = *scheduler;
 
     if ( cpu_schedule_up(0) )
         BUG();
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index a0c87169d9..17cc4b1159 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -769,6 +769,17 @@ void sched_destroy_domain(struct domain *d);
 long sched_adjust(struct domain *, struct xen_domctl_scheduler_op *);
 long sched_adjust_global(struct xen_sysctl_scheduler_op *);
 int  sched_id(void);
+
+/*
+ * sched_get_id_by_name - retrieves a scheduler id given a scheduler name
+ * @sched_name: scheduler name as a string
+ *
+ * returns:
+ *     positive value being the scheduler id, on success
+ *     negative value if the scheduler name is not found.
+ */
+int sched_get_id_by_name(const char *sched_name);
+
 void vcpu_wake(struct vcpu *v);
 long vcpu_yield(void);
 void vcpu_sleep_nosync(struct vcpu *v);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue May 10 16:55:34 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 10 May 2022 16:55:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.325908.548706 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noT94-0003ZF-Az; Tue, 10 May 2022 16:55:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 325908.548706; Tue, 10 May 2022 16: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 1noT94-0003Z6-7m; Tue, 10 May 2022 16:55:34 +0000
Received: by outflank-mailman (input) for mailman id 325908;
 Tue, 10 May 2022 16: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 1noT92-0003Xi-2U
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16: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 1noT92-0002E0-1d
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16:55:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noT92-0007j9-0d
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16: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=mtQnI0k+FQpYkdfRGo4Ya6qN1n6IhS/n2LE+HwjVx08=; b=zTPUV/ZL8OTQPKWEhMFSt4ch0R
	2vw2KMhLSyMQg98gKBuP7zYKxd9fSkCVgC3WhQZE6PbmJCvO2WGH9AuhquogBsFgNXQFGGDBpMI/y
	kwNec7n2z1sNyCzmjwkUZeOWeDSVF1EC/unDCeAWEHuQIUxNDo8dpCoZZ/UfpCG8V2xw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/cpupool: Create different cpupools at boot time
Message-Id: <E1noT92-0007j9-0d@xenbits.xenproject.org>
Date: Tue, 10 May 2022 16:55:32 +0000

commit a6dc3b947cd1ba1ae95ef0a46cf4ab4b8a2d3ebd
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Fri May 6 13:00:09 2022 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Mon May 9 13:32:33 2022 -0700

    xen/cpupool: Create different cpupools at boot time
    
    Introduce a way to create different cpupools at boot time, this is
    particularly useful on ARM big.LITTLE system where there might be the
    need to have different cpupools for each type of core, but also
    systems using NUMA can have different cpu pools for each node.
    
    The feature on arm relies on a specification of the cpupools from the
    device tree to build pools and assign cpus to them.
    
    ACPI is not supported for this feature.
    
    With this patch, cpupool0 can now have less cpus than the number of
    online ones, so update the default case for opt_dom0_max_vcpus.
    
    Documentation is created to explain the feature.
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    Acked-by: George Dunlap <george.dunlap@citrix.com>
---
 MAINTAINERS                            |   2 +-
 docs/misc/arm/device-tree/cpupools.txt | 140 ++++++++++++++++++++++
 xen/arch/arm/domain_build.c            |   5 +-
 xen/arch/arm/include/asm/smp.h         |   3 +
 xen/common/sched/Kconfig               |   7 ++
 xen/common/sched/Makefile              |   1 +
 xen/common/sched/boot-cpupool.c        | 207 +++++++++++++++++++++++++++++++++
 xen/common/sched/cpupool.c             |  12 +-
 xen/include/xen/sched.h                |  14 +++
 9 files changed, 388 insertions(+), 3 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 96866f626e..a0b0d88ea4 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -279,7 +279,7 @@ CPU POOLS
 M:	Juergen Gross <jgross@suse.com>
 M:	Dario Faggioli <dfaggioli@suse.com>
 S:	Supported
-F:	xen/common/sched/cpupool.c
+F:	xen/common/sched/*cpupool.c
 
 DEVICE TREE
 M:	Stefano Stabellini <sstabellini@kernel.org>
diff --git a/docs/misc/arm/device-tree/cpupools.txt b/docs/misc/arm/device-tree/cpupools.txt
new file mode 100644
index 0000000000..1f640d6803
--- /dev/null
+++ b/docs/misc/arm/device-tree/cpupools.txt
@@ -0,0 +1,140 @@
+Boot time cpupools
+==================
+
+When BOOT_TIME_CPUPOOLS is enabled in the Xen configuration, it is possible to
+create cpupools during boot phase by specifying them in the device tree.
+ACPI is not supported for this feature.
+
+Cpupools specification nodes shall be direct childs of /chosen node.
+Each cpupool node contains the following properties:
+
+- compatible (mandatory)
+
+    Must always include the compatiblity string: "xen,cpupool".
+
+- cpupool-cpus (mandatory)
+
+    Must be a list of device tree phandle to nodes describing cpus (e.g. having
+    device_type = "cpu"), it can't be empty.
+
+- cpupool-sched (optional)
+
+    Must be a string having the name of a Xen scheduler. Check the sched=<...>
+    boot argument for allowed values [1]. When this property is omitted, the Xen
+    default scheduler will be used.
+
+
+Constraints
+===========
+
+If no cpupools are specified, all cpus will be assigned to one cpupool
+implicitly created (Pool-0).
+
+If cpupools node are specified, but not every cpu brought up by Xen is assigned,
+all the not assigned cpu will be assigned to an additional cpupool.
+
+If a cpu is assigned to a cpupool, but it's not brought up correctly, Xen will
+stop.
+
+The boot cpu must be assigned to Pool-0, so the cpupool containing that core
+will become Pool-0 automatically.
+
+
+Examples
+========
+
+A system having two types of core, the following device tree specification will
+instruct Xen to have two cpupools:
+
+- The cpupool described by node cpupool_a will have 4 cpus assigned.
+- The cpupool described by node cpupool_b will have 2 cpus assigned.
+
+The following example can work only if hmp-unsafe=1 is passed to Xen boot
+arguments, otherwise not all cores will be brought up by Xen and the cpupool
+creation process will stop Xen.
+
+
+a72_1: cpu@0 {
+        compatible = "arm,cortex-a72";
+        reg = <0x0 0x0>;
+        device_type = "cpu";
+        [...]
+};
+
+a72_2: cpu@1 {
+        compatible = "arm,cortex-a72";
+        reg = <0x0 0x1>;
+        device_type = "cpu";
+        [...]
+};
+
+a53_1: cpu@100 {
+        compatible = "arm,cortex-a53";
+        reg = <0x0 0x100>;
+        device_type = "cpu";
+        [...]
+};
+
+a53_2: cpu@101 {
+        compatible = "arm,cortex-a53";
+        reg = <0x0 0x101>;
+        device_type = "cpu";
+        [...]
+};
+
+a53_3: cpu@102 {
+        compatible = "arm,cortex-a53";
+        reg = <0x0 0x102>;
+        device_type = "cpu";
+        [...]
+};
+
+a53_4: cpu@103 {
+        compatible = "arm,cortex-a53";
+        reg = <0x0 0x103>;
+        device_type = "cpu";
+        [...]
+};
+
+chosen {
+
+    cpupool_a {
+        compatible = "xen,cpupool";
+        cpupool-cpus = <&a53_1 &a53_2 &a53_3 &a53_4>;
+    };
+    cpupool_b {
+        compatible = "xen,cpupool";
+        cpupool-cpus = <&a72_1 &a72_2>;
+        cpupool-sched = "credit2";
+    };
+
+    [...]
+
+};
+
+
+A system having the cpupools specification below will instruct Xen to have three
+cpupools:
+
+- The cpupool described by node cpupool_a will have 2 cpus assigned.
+- The cpupool described by node cpupool_b will have 2 cpus assigned.
+- An additional cpupool will be created, having 2 cpus assigned (created by Xen
+  with all the unassigned cpus a53_3 and a53_4).
+
+chosen {
+
+    cpupool_a {
+        compatible = "xen,cpupool";
+        cpupool-cpus = <&a53_1 &a53_2>;
+    };
+    cpupool_b {
+        compatible = "xen,cpupool";
+        cpupool-cpus = <&a72_1 &a72_2>;
+        cpupool-sched = "null";
+    };
+
+    [...]
+
+};
+
+[1] docs/misc/xen-command-line.pandoc
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 1472ca4972..5df5c8ffb8 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -73,7 +73,10 @@ custom_param("dom0_mem", parse_dom0_mem);
 unsigned int __init dom0_max_vcpus(void)
 {
     if ( opt_dom0_max_vcpus == 0 )
-        opt_dom0_max_vcpus = num_online_cpus();
+    {
+        ASSERT(cpupool0);
+        opt_dom0_max_vcpus = cpumask_weight(cpupool_valid_cpus(cpupool0));
+    }
     if ( opt_dom0_max_vcpus > MAX_VIRT_CPUS )
         opt_dom0_max_vcpus = MAX_VIRT_CPUS;
 
diff --git a/xen/arch/arm/include/asm/smp.h b/xen/arch/arm/include/asm/smp.h
index af5a2fe652..83c0cd6976 100644
--- a/xen/arch/arm/include/asm/smp.h
+++ b/xen/arch/arm/include/asm/smp.h
@@ -34,6 +34,9 @@ extern void init_secondary(void);
 extern void smp_init_cpus(void);
 extern void smp_clear_cpu_maps (void);
 extern int smp_get_max_cpus (void);
+
+#define cpu_physical_id(cpu) cpu_logical_map(cpu)
+
 #endif
 
 /*
diff --git a/xen/common/sched/Kconfig b/xen/common/sched/Kconfig
index 3d9f9214b8..b2ef0c99a3 100644
--- a/xen/common/sched/Kconfig
+++ b/xen/common/sched/Kconfig
@@ -64,3 +64,10 @@ config SCHED_DEFAULT
 	default "credit2"
 
 endmenu
+
+config BOOT_TIME_CPUPOOLS
+	bool "Create cpupools at boot time"
+	depends on HAS_DEVICE_TREE
+	help
+	  Creates cpupools during boot time and assigns cpus to them. Cpupools
+	  options can be specified in the device tree.
diff --git a/xen/common/sched/Makefile b/xen/common/sched/Makefile
index 3537f2a68d..697bd54bfe 100644
--- a/xen/common/sched/Makefile
+++ b/xen/common/sched/Makefile
@@ -1,3 +1,4 @@
+obj-$(CONFIG_BOOT_TIME_CPUPOOLS) += boot-cpupool.init.o
 obj-y += cpupool.o
 obj-$(CONFIG_SCHED_ARINC653) += arinc653.o
 obj-$(CONFIG_SCHED_CREDIT) += credit.o
diff --git a/xen/common/sched/boot-cpupool.c b/xen/common/sched/boot-cpupool.c
new file mode 100644
index 0000000000..9429a5025f
--- /dev/null
+++ b/xen/common/sched/boot-cpupool.c
@@ -0,0 +1,207 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * xen/common/boot_cpupools.c
+ *
+ * Code to create cpupools at boot time.
+ *
+ * Copyright (C) 2022 Arm Ltd.
+ */
+
+#include <xen/sched.h>
+#include <asm/acpi.h>
+
+/*
+ * pool_cpu_map:   Index is logical cpu number, content is cpupool id, (-1) for
+ *                 unassigned.
+ * pool_sched_map: Index is cpupool id, content is scheduler id, (-1) for
+ *                 unassigned.
+ */
+static int __initdata pool_cpu_map[NR_CPUS]   = { [0 ... NR_CPUS-1] = -1 };
+static int __initdata pool_sched_map[NR_CPUS] = { [0 ... NR_CPUS-1] = -1 };
+static unsigned int __initdata next_pool_id;
+
+#define BTCPUPOOLS_DT_NODE_NO_REG     (-1)
+#define BTCPUPOOLS_DT_NODE_NO_LOG_CPU (-2)
+
+static int __init get_logical_cpu_from_hw_id(unsigned int hwid)
+{
+    unsigned int i;
+
+    for ( i = 0; i < nr_cpu_ids; i++ )
+    {
+        if ( cpu_physical_id(i) == hwid )
+            return i;
+    }
+
+    return -1;
+}
+
+static int __init
+get_logical_cpu_from_cpu_node(const struct dt_device_node *cpu_node)
+{
+    int cpu_num;
+    const __be32 *prop;
+    unsigned int cpu_reg;
+
+    prop = dt_get_property(cpu_node, "reg", NULL);
+    if ( !prop )
+        return BTCPUPOOLS_DT_NODE_NO_REG;
+
+    cpu_reg = dt_read_number(prop, dt_n_addr_cells(cpu_node));
+
+    cpu_num = get_logical_cpu_from_hw_id(cpu_reg);
+    if ( cpu_num < 0 )
+        return BTCPUPOOLS_DT_NODE_NO_LOG_CPU;
+
+    return cpu_num;
+}
+
+static int __init check_and_get_sched_id(const char* scheduler_name)
+{
+    int sched_id = sched_get_id_by_name(scheduler_name);
+
+    if ( sched_id < 0 )
+        panic("Scheduler %s does not exists!\n", scheduler_name);
+
+    return sched_id;
+}
+
+void __init btcpupools_dtb_parse(void)
+{
+    const struct dt_device_node *chosen, *node;
+
+    if ( !acpi_disabled )
+        return;
+
+    chosen = dt_find_node_by_path("/chosen");
+    if ( !chosen )
+        panic("/chosen missing. Boot time cpupools can't be parsed from DT.\n");
+
+    dt_for_each_child_node(chosen, node)
+    {
+        const struct dt_device_node *phandle_node;
+        int sched_id = -1;
+        const char* scheduler_name;
+        unsigned int i = 0;
+
+        if ( !dt_device_is_compatible(node, "xen,cpupool") )
+            continue;
+
+        if ( !dt_property_read_string(node, "cpupool-sched", &scheduler_name) )
+            sched_id = check_and_get_sched_id(scheduler_name);
+
+        phandle_node = dt_parse_phandle(node, "cpupool-cpus", i++);
+        if ( !phandle_node )
+            panic("Missing or empty cpupool-cpus property!\n");
+
+        while ( phandle_node )
+        {
+            int cpu_num;
+
+            cpu_num = get_logical_cpu_from_cpu_node(phandle_node);
+
+            if ( cpu_num < 0 )
+                panic("Error retrieving logical cpu from node %s (%d)\n",
+                      dt_node_name(node), cpu_num);
+
+            if ( pool_cpu_map[cpu_num] != -1 )
+                panic("Logical cpu %d already added to a cpupool!\n", cpu_num);
+
+            pool_cpu_map[cpu_num] = next_pool_id;
+
+            phandle_node = dt_parse_phandle(node, "cpupool-cpus", i++);
+        }
+
+        /* Save scheduler choice for this cpupool id */
+        pool_sched_map[next_pool_id] = sched_id;
+
+        /* Let Xen generate pool ids */
+        next_pool_id++;
+    }
+}
+
+void __init btcpupools_allocate_pools(void)
+{
+    unsigned int i;
+    bool add_extra_cpupool = false;
+    int swap_id = -1;
+
+    /*
+     * If there are no cpupools, the value of next_pool_id is zero, so the code
+     * below will assign every cpu to cpupool0 as the default behavior.
+     * When there are cpupools, the code below is assigning all the not
+     * assigned cpu to a new pool (next_pool_id value is the last id + 1).
+     * In the same loop we check if there is any assigned cpu that is not
+     * online.
+     */
+    for ( i = 0; i < nr_cpu_ids; i++ )
+    {
+        if ( cpumask_test_cpu(i, &cpu_online_map) )
+        {
+            /* Unassigned cpu gets next_pool_id pool id value */
+            if ( pool_cpu_map[i] < 0 )
+            {
+                pool_cpu_map[i] = next_pool_id;
+                add_extra_cpupool = true;
+            }
+
+            /*
+             * Cpu0 must be in cpupool0, otherwise some operations like moving
+             * cpus between cpupools, cpu hotplug, destroying cpupools, shutdown
+             * of the host, might not work in a sane way.
+             */
+            if ( !i && (pool_cpu_map[0] != 0) )
+                swap_id = pool_cpu_map[0];
+
+            if ( swap_id != -1 )
+            {
+                if ( pool_cpu_map[i] == swap_id )
+                    pool_cpu_map[i] = 0;
+                else if ( pool_cpu_map[i] == 0 )
+                    pool_cpu_map[i] = swap_id;
+            }
+        }
+        else
+        {
+            if ( pool_cpu_map[i] >= 0 )
+                panic("Pool-%d contains cpu%u that is not online!\n",
+                      pool_cpu_map[i], i);
+        }
+    }
+
+    /* A swap happened, swap schedulers between cpupool id 0 and the other */
+    if ( swap_id != -1 )
+    {
+        int swap_sched = pool_sched_map[swap_id];
+
+        pool_sched_map[swap_id] = pool_sched_map[0];
+        pool_sched_map[0] = swap_sched;
+    }
+
+    if ( add_extra_cpupool )
+        next_pool_id++;
+
+    /* Create cpupools with selected schedulers */
+    for ( i = 0; i < next_pool_id; i++ )
+        cpupool_create_pool(i, pool_sched_map[i]);
+}
+
+unsigned int __init btcpupools_get_cpupool_id(unsigned int cpu)
+{
+    ASSERT((cpu < NR_CPUS) && (pool_cpu_map[cpu] >= 0));
+
+    printk(XENLOG_INFO "Logical CPU %u in Pool-%d (Scheduler id: %d).\n",
+           cpu, pool_cpu_map[cpu], pool_sched_map[pool_cpu_map[cpu]]);
+
+    return pool_cpu_map[cpu];
+}
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * tab-width: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
diff --git a/xen/common/sched/cpupool.c b/xen/common/sched/cpupool.c
index 89a891af70..86a175f99c 100644
--- a/xen/common/sched/cpupool.c
+++ b/xen/common/sched/cpupool.c
@@ -1247,12 +1247,22 @@ static int __init cf_check cpupool_init(void)
     cpupool_put(cpupool0);
     register_cpu_notifier(&cpu_nfb);
 
+    btcpupools_dtb_parse();
+
+    btcpupools_allocate_pools();
+
     spin_lock(&cpupool_lock);
 
     cpumask_copy(&cpupool_free_cpus, &cpu_online_map);
 
     for_each_cpu ( cpu, &cpupool_free_cpus )
-        cpupool_assign_cpu_locked(cpupool0, cpu);
+    {
+        unsigned int pool_id = btcpupools_get_cpupool_id(cpu);
+        struct cpupool *pool = cpupool_find_by_id(pool_id);
+
+        ASSERT(pool);
+        cpupool_assign_cpu_locked(pool, cpu);
+    }
 
     spin_unlock(&cpupool_lock);
 
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 17cc4b1159..20ff2febac 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -1189,6 +1189,20 @@ extern void cf_check dump_runq(unsigned char key);
 
 void arch_do_physinfo(struct xen_sysctl_physinfo *pi);
 
+#ifdef CONFIG_BOOT_TIME_CPUPOOLS
+void btcpupools_allocate_pools(void);
+unsigned int btcpupools_get_cpupool_id(unsigned int cpu);
+void btcpupools_dtb_parse(void);
+
+#else /* !CONFIG_BOOT_TIME_CPUPOOLS */
+static inline void btcpupools_allocate_pools(void) {}
+static inline void btcpupools_dtb_parse(void) {}
+static inline unsigned int btcpupools_get_cpupool_id(unsigned int cpu)
+{
+    return 0;
+}
+#endif
+
 #endif /* __SCHED_H__ */
 
 /*
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue May 10 16:55:43 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 10 May 2022 16:55:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.325911.548709 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noT9D-0003gi-EM; Tue, 10 May 2022 16:55:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 325911.548709; Tue, 10 May 2022 16: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 1noT9D-0003gb-Bl; Tue, 10 May 2022 16:55:43 +0000
Received: by outflank-mailman (input) for mailman id 325911;
 Tue, 10 May 2022 16: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 1noT9C-0003g7-5m
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16: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 1noT9C-0002ED-51
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16:55:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noT9C-0007jj-3r
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16: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=y5AuYnGuEMhtTln7zYqeT59uyatNaoGYxCmq1o1gjLU=; b=GGFZ8hlQciuq7Uuwp+pdBJTNLf
	V7Gcxku+B+xEC+mKM8AlNX4HzQWLPsf9UQAhjJOwJlJIqgypXjKPiz6vIohM9WTtzKSXp7DTFpy1S
	9al2UPIYNH9DL+F8PWVnm0JyAe0KRpOvAe9PGbHA8+oPMIc6WjEMlAOR/v8myTpCsozo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/cpupool: Don't allow removing cpu0 from cpupool0
Message-Id: <E1noT9C-0007jj-3r@xenbits.xenproject.org>
Date: Tue, 10 May 2022 16:55:42 +0000

commit 544e8af41e23e0d1e787beaa512877f69e51fd76
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Fri May 6 13:00:10 2022 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Mon May 9 13:32:39 2022 -0700

    xen/cpupool: Don't allow removing cpu0 from cpupool0
    
    Cpu0 must remain in cpupool0, otherwise some operations like moving cpus
    between cpupools, cpu hotplug, destroying cpupools, shutdown of the host,
    might not work in a sane way.
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
---
 xen/common/sched/cpupool.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/xen/common/sched/cpupool.c b/xen/common/sched/cpupool.c
index 86a175f99c..0a93bcc631 100644
--- a/xen/common/sched/cpupool.c
+++ b/xen/common/sched/cpupool.c
@@ -572,6 +572,7 @@ static long cf_check cpupool_unassign_cpu_helper(void *info)
  * possible failures:
  * - last cpu and still active domains in cpupool
  * - cpu just being unplugged
+ * - Attempt to remove boot cpu from cpupool0
  */
 static int cpupool_unassign_cpu(struct cpupool *c, unsigned int cpu)
 {
@@ -582,7 +583,12 @@ static int cpupool_unassign_cpu(struct cpupool *c, unsigned int cpu)
     debugtrace_printk("cpupool_unassign_cpu(pool=%u,cpu=%d)\n",
                       c->cpupool_id, cpu);
 
-    if ( !cpu_online(cpu) )
+    /*
+     * Cpu0 must remain in cpupool0, otherwise some operations like moving cpus
+     * between cpupools, cpu hotplug, destroying cpupools, shutdown of the host,
+     * might not work in a sane way.
+     */
+    if ( (!c->cpupool_id && !cpu) || !cpu_online(cpu) )
         return -EINVAL;
 
     master_cpu = sched_get_resource_cpu(cpu);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue May 10 16:55:53 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 10 May 2022 16:55:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.325913.548714 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noT9N-0003sd-G6; Tue, 10 May 2022 16:55:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 325913.548714; Tue, 10 May 2022 16: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 1noT9N-0003sV-DN; Tue, 10 May 2022 16:55:53 +0000
Received: by outflank-mailman (input) for mailman id 325913;
 Tue, 10 May 2022 16: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 1noT9M-0003sG-9F
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16: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 1noT9M-0002EQ-8X
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16:55:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noT9M-0007kI-7g
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16: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=TGPlJmlxR1rXACsqeYx9CK3SDbUVUKPwE+xKJfFqz28=; b=bfWmLAEdex7Sfb9zw5suMxILD5
	2iaDK3s65SOMZwL50L/OmA2QVeLMynrQsA8ovkFdu/wa/KTbhLuFXBzxqhaxHewQyH75Lnb+C7Pk2
	sR1shu89KyvMDVnsiIinjbI7zAg9i4smS9tIxA5aKm4L8An+sDp5ULozq/oD4V5fO7Ro=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] arm/dom0less: assign dom0less guests to cpupools
Message-Id: <E1noT9M-0007kI-7g@xenbits.xenproject.org>
Date: Tue, 10 May 2022 16:55:52 +0000

commit 92ea9c54fc81b75154a72168b9a2be969b9d7ff8
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Fri May 6 13:00:11 2022 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Mon May 9 13:32:57 2022 -0700

    arm/dom0less: assign dom0less guests to cpupools
    
    Introduce domain-cpupool property of a xen,domain device tree node,
    that specifies the cpupool device tree handle of a xen,cpupool node
    that identifies a cpupool created at boot time where the guest will
    be assigned on creation.
    
    Add member to the xen_domctl_createdomain public interface so the
    XEN_DOMCTL_INTERFACE_VERSION version is bumped.
    
    Add public function to retrieve a pool id from the device tree
    cpupool node.
    
    Update documentation about the property.
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
    Reviewed-by: Juergen Gross <jgross@suse.com>
---
 docs/misc/arm/device-tree/booting.txt |  5 +++++
 xen/arch/arm/domain_build.c           | 14 +++++++++++++-
 xen/common/domain.c                   |  2 +-
 xen/common/sched/boot-cpupool.c       | 24 ++++++++++++++++++++++++
 xen/include/public/domctl.h           |  5 ++++-
 xen/include/xen/sched.h               |  9 +++++++++
 6 files changed, 56 insertions(+), 3 deletions(-)

diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-tree/booting.txt
index a94125394e..7b4a29a2c2 100644
--- a/docs/misc/arm/device-tree/booting.txt
+++ b/docs/misc/arm/device-tree/booting.txt
@@ -188,6 +188,11 @@ with the following properties:
     An empty property to request the memory of the domain to be
     direct-map (guest physical address == physical address).
 
+- domain-cpupool
+
+    Optional. Handle to a xen,cpupool device tree node that identifies the
+    cpupool where the guest will be started at boot.
+
 Under the "xen,domain" compatible node, one or more sub-nodes are present
 for the DomU kernel and ramdisk.
 
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 5df5c8ffb8..aa777741bd 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -3174,7 +3174,8 @@ static int __init construct_domU(struct domain *d,
 void __init create_domUs(void)
 {
     struct dt_device_node *node;
-    const struct dt_device_node *chosen = dt_find_node_by_path("/chosen");
+    const struct dt_device_node *cpupool_node,
+                                *chosen = dt_find_node_by_path("/chosen");
 
     BUG_ON(chosen == NULL);
     dt_for_each_child_node(chosen, node)
@@ -3243,6 +3244,17 @@ void __init create_domUs(void)
                                          vpl011_virq - 32 + 1);
         }
 
+        /* Get the optional property domain-cpupool */
+        cpupool_node = dt_parse_phandle(node, "domain-cpupool", 0);
+        if ( cpupool_node )
+        {
+            int pool_id = btcpupools_get_domain_pool_id(cpupool_node);
+            if ( pool_id < 0 )
+                panic("Error getting cpupool id from domain-cpupool (%d)\n",
+                      pool_id);
+            d_cfg.cpupool_id = pool_id;
+        }
+
         /*
          * The variable max_init_domid is initialized with zero, so here it's
          * very important to use the pre-increment operator to call
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 8d2c2a9897..7570eae91a 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -697,7 +697,7 @@ struct domain *domain_create(domid_t domid,
         if ( !d->pbuf )
             goto fail;
 
-        if ( (err = sched_init_domain(d, 0)) != 0 )
+        if ( (err = sched_init_domain(d, config->cpupool_id)) != 0 )
             goto fail;
 
         if ( (err = late_hwdom_init(d)) != 0 )
diff --git a/xen/common/sched/boot-cpupool.c b/xen/common/sched/boot-cpupool.c
index 9429a5025f..240bae4ceb 100644
--- a/xen/common/sched/boot-cpupool.c
+++ b/xen/common/sched/boot-cpupool.c
@@ -22,6 +22,8 @@ static unsigned int __initdata next_pool_id;
 
 #define BTCPUPOOLS_DT_NODE_NO_REG     (-1)
 #define BTCPUPOOLS_DT_NODE_NO_LOG_CPU (-2)
+#define BTCPUPOOLS_DT_WRONG_NODE      (-3)
+#define BTCPUPOOLS_DT_CORRUPTED_NODE  (-4)
 
 static int __init get_logical_cpu_from_hw_id(unsigned int hwid)
 {
@@ -56,6 +58,28 @@ get_logical_cpu_from_cpu_node(const struct dt_device_node *cpu_node)
     return cpu_num;
 }
 
+int __init btcpupools_get_domain_pool_id(const struct dt_device_node *node)
+{
+    const struct dt_device_node *phandle_node;
+    int cpu_num;
+
+    if ( !dt_device_is_compatible(node, "xen,cpupool") )
+        return BTCPUPOOLS_DT_WRONG_NODE;
+    /*
+     * Get first cpu listed in the cpupool, from its reg it's possible to
+     * retrieve the cpupool id.
+     */
+    phandle_node = dt_parse_phandle(node, "cpupool-cpus", 0);
+    if ( !phandle_node )
+        return BTCPUPOOLS_DT_CORRUPTED_NODE;
+
+    cpu_num = get_logical_cpu_from_cpu_node(phandle_node);
+    if ( cpu_num < 0 )
+        return cpu_num;
+
+    return pool_cpu_map[cpu_num];
+}
+
 static int __init check_and_get_sched_id(const char* scheduler_name)
 {
     int sched_id = sched_get_id_by_name(scheduler_name);
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index b85e6170b0..84e75829b9 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -38,7 +38,7 @@
 #include "hvm/save.h"
 #include "memory.h"
 
-#define XEN_DOMCTL_INTERFACE_VERSION 0x00000014
+#define XEN_DOMCTL_INTERFACE_VERSION 0x00000015
 
 /*
  * NB. xen_domctl.domain is an IN/OUT parameter for this operation.
@@ -106,6 +106,9 @@ struct xen_domctl_createdomain {
     /* Per-vCPU buffer size in bytes.  0 to disable. */
     uint32_t vmtrace_size;
 
+    /* CPU pool to use; specify 0 or a specific existing pool */
+    uint32_t cpupool_id;
+
     struct xen_arch_domainconfig arch;
 };
 
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 20ff2febac..653317cf4d 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -1193,6 +1193,7 @@ void arch_do_physinfo(struct xen_sysctl_physinfo *pi);
 void btcpupools_allocate_pools(void);
 unsigned int btcpupools_get_cpupool_id(unsigned int cpu);
 void btcpupools_dtb_parse(void);
+int btcpupools_get_domain_pool_id(const struct dt_device_node *node);
 
 #else /* !CONFIG_BOOT_TIME_CPUPOOLS */
 static inline void btcpupools_allocate_pools(void) {}
@@ -1201,6 +1202,14 @@ static inline unsigned int btcpupools_get_cpupool_id(unsigned int cpu)
 {
     return 0;
 }
+#ifdef CONFIG_HAS_DEVICE_TREE
+static inline int
+btcpupools_get_domain_pool_id(const struct dt_device_node *node)
+{
+    return 0;
+}
+#endif
+
 #endif
 
 #endif /* __SCHED_H__ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue May 10 16:56:03 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 10 May 2022 16:56:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.325915.548718 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1noT9X-0003xC-Hv; Tue, 10 May 2022 16:56:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 325915.548718; Tue, 10 May 2022 16: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 1noT9X-0003x4-Ev; Tue, 10 May 2022 16:56:03 +0000
Received: by outflank-mailman (input) for mailman id 325915;
 Tue, 10 May 2022 16: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 1noT9W-0003wi-CR
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16: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 1noT9W-0002En-Bf
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16:56:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1noT9W-0007lE-Ar
 for xen-changelog@lists.xenproject.org; Tue, 10 May 2022 16: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=5xizPj2m1HuXwaofDA1yw4594lYLnAl4gfUJbZzdZY4=; b=z+2Q9E9WoYAviDfMLgJG+9JOE1
	O+RSyXH7Ae/7iY+VVkrM6LYoKPrJXhnDtrHBPFSfbIgaNpkXXDr7sWIPjYS4XrZlTSl4JVDzyPX31
	xvKII7gyLX6QAOpjNhFcYN4PwBHAyJ/6yz20Uit9+oyydgeh71svBlIzohBPIvCvZdys=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/cpupool: Allow cpupool0 to use different scheduler
Message-Id: <E1noT9W-0007lE-Ar@xenbits.xenproject.org>
Date: Tue, 10 May 2022 16:56:02 +0000

commit 0badfb110fa33ca9ffd3bdc3a5200cded03e6106
Author:     Luca Fancellu <luca.fancellu@arm.com>
AuthorDate: Fri May 6 13:00:12 2022 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Mon May 9 13:33:03 2022 -0700

    xen/cpupool: Allow cpupool0 to use different scheduler
    
    Currently cpupool0 can use only the default scheduler, and
    cpupool_create has an hardcoded behavior when creating the pool 0
    that doesn't allocate new memory for the scheduler, but uses the
    default scheduler structure in memory.
    
    With this commit it is possible to allocate a different scheduler for
    the cpupool0 when using the boot time cpupool.
    To achieve this the hardcoded behavior in cpupool_create is removed
    and the cpupool0 creation is moved.
    
    When compiling without boot time cpupools enabled, the current
    behavior is maintained (except that cpupool0 scheduler memory will be
    allocated).
    
    Signed-off-by: Luca Fancellu <luca.fancellu@arm.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
---
 xen/common/sched/boot-cpupool.c | 5 ++++-
 xen/common/sched/cpupool.c      | 8 +-------
 xen/include/xen/sched.h         | 5 ++++-
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/xen/common/sched/boot-cpupool.c b/xen/common/sched/boot-cpupool.c
index 240bae4ceb..5955e6f9a9 100644
--- a/xen/common/sched/boot-cpupool.c
+++ b/xen/common/sched/boot-cpupool.c
@@ -205,8 +205,11 @@ void __init btcpupools_allocate_pools(void)
     if ( add_extra_cpupool )
         next_pool_id++;
 
+    /* Keep track of cpupool id 0 with the global cpupool0 */
+    cpupool0 = cpupool_create_pool(0, pool_sched_map[0]);
+
     /* Create cpupools with selected schedulers */
-    for ( i = 0; i < next_pool_id; i++ )
+    for ( i = 1; i < next_pool_id; i++ )
         cpupool_create_pool(i, pool_sched_map[i]);
 }
 
diff --git a/xen/common/sched/cpupool.c b/xen/common/sched/cpupool.c
index 0a93bcc631..f6e3d97e52 100644
--- a/xen/common/sched/cpupool.c
+++ b/xen/common/sched/cpupool.c
@@ -312,10 +312,7 @@ static struct cpupool *cpupool_create(unsigned int poolid,
         c->cpupool_id = q->cpupool_id + 1;
     }
 
-    if ( poolid == 0 )
-        c->sched = scheduler_get_default();
-    else
-        c->sched = scheduler_alloc(sched_id);
+    c->sched = scheduler_alloc(sched_id);
     if ( IS_ERR(c->sched) )
     {
         ret = PTR_ERR(c->sched);
@@ -1248,9 +1245,6 @@ static int __init cf_check cpupool_init(void)
 
     cpupool_hypfs_init();
 
-    cpupool0 = cpupool_create(0, 0);
-    BUG_ON(IS_ERR(cpupool0));
-    cpupool_put(cpupool0);
     register_cpu_notifier(&cpu_nfb);
 
     btcpupools_dtb_parse();
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 653317cf4d..463d41ffb6 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -1196,7 +1196,10 @@ void btcpupools_dtb_parse(void);
 int btcpupools_get_domain_pool_id(const struct dt_device_node *node);
 
 #else /* !CONFIG_BOOT_TIME_CPUPOOLS */
-static inline void btcpupools_allocate_pools(void) {}
+static inline void btcpupools_allocate_pools(void)
+{
+    cpupool0 = cpupool_create_pool(0, -1);
+}
 static inline void btcpupools_dtb_parse(void) {}
 static inline unsigned int btcpupools_get_cpupool_id(unsigned int cpu)
 {
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed May 11 02:11:09 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 11 May 2022 02:11:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.326139.548986 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nobod-0005NK-I0; Wed, 11 May 2022 02:11:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 326139.548986; Wed, 11 May 2022 02:11: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 1nobod-0005NC-Eb; Wed, 11 May 2022 02:11:03 +0000
Received: by outflank-mailman (input) for mailman id 326139;
 Wed, 11 May 2022 02: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 1noboc-0005N6-1H
 for xen-changelog@lists.xenproject.org; Wed, 11 May 2022 02: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 1nobob-0002SD-Ud
 for xen-changelog@lists.xenproject.org; Wed, 11 May 2022 02:11:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nobob-0000u2-Td
 for xen-changelog@lists.xenproject.org; Wed, 11 May 2022 02: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=yu2GC9rTqRhTONcqHHU9TnphQdhQuVHUMWLPMqdONjc=; b=nEriBH81mSoaakyUvdreNDpAhc
	5FJo5HsrmZzXhKJwz0b3s6zNxR+x1WNJ2WiIaWzuHlB4zETSfqk4LcroiVKlujJxpldRryDWUTmcS
	B4wez2h1DUrZWrLfOZUU3FpbUW3M08h/T3Gb03g7rZepur5B+Skg3sBWpGFnZBaAmLdI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: p2m don't fall over on FEAT_LPA enabled hw
Message-Id: <E1nobob-0000u2-Td@xenbits.xenproject.org>
Date: Wed, 11 May 2022 02:11:01 +0000

commit 407b13a71e324aba76b11e5f66f59ce4a304a088
Author:     Alex Bennée <alex.bennee@linaro.org>
AuthorDate: Thu Apr 28 11:34:10 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Tue May 10 15:10:55 2022 +0100

    xen/arm: p2m don't fall over on FEAT_LPA enabled hw
    
    When we introduced FEAT_LPA to QEMU's -cpu max we discovered older
    kernels had a bug where the physical address was copied directly from
    ID_AA64MMFR0_EL1.PARange field. The early cpu_init code of Xen commits
    the same error by blindly copying across the max supported range.
    
    Unsurprisingly when the page tables aren't set up for these greater
    ranges hilarity ensues and the hypervisor crashes fairly early on in
    the boot-up sequence. This happens when we write to the control
    register in enable_mmu().
    
    Attempt to fix this the same way as the Linux kernel does by gating
    PARange to the maximum the hypervisor can handle. I also had to fix up
    code in p2m which panics when it sees an "invalid" entry in PARange.
    
    Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
    Cc: Richard Henderson <richard.henderson@linaro.org>
    Cc: Stefano Stabellini <sstabellini@kernel.org>
    Cc: Julien Grall <julien@xen.org>
    Cc: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
    Cc: Bertrand Marquis <bertrand.marquis@arm.com>
    Tested-by: Luca Fancellu <luca.fancellu@arm.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/arm64/head.S |  6 ++++++
 xen/arch/arm/p2m.c        | 10 +++++-----
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index e62c48ec1c..1fd35a8390 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -474,6 +474,12 @@ cpu_init:
         ldr   x0, =(TCR_RES1|TCR_SH0_IS|TCR_ORGN0_WBWA|TCR_IRGN0_WBWA|TCR_T0SZ(64-48))
         /* ID_AA64MMFR0_EL1[3:0] (PARange) corresponds to TCR_EL2[18:16] (PS) */
         mrs   x1, ID_AA64MMFR0_EL1
+        /* Limit to 48 bits, 256TB PA range (#5) */
+        ubfm  x1, x1, #0, #3
+        mov   x2, #5
+        cmp   x1, x2
+        csel  x1, x1, x2, lt
+
         bfi   x0, x1, #16, #3
 
         msr   tcr_el2, x0
diff --git a/xen/arch/arm/p2m.c b/xen/arch/arm/p2m.c
index 1d1059f7d2..d00c2e462a 100644
--- a/xen/arch/arm/p2m.c
+++ b/xen/arch/arm/p2m.c
@@ -32,10 +32,10 @@ static unsigned int __read_mostly max_vmid = MAX_VMID_8_BIT;
 #define P2M_ROOT_PAGES    (1<<P2M_ROOT_ORDER)
 
 /*
- * Set larger than any possible value, so the number of IPA bits can be
+ * Set to the maximum configured support for IPA bits, so the number of IPA bits can be
  * restricted by external entity (e.g. IOMMU).
  */
-unsigned int __read_mostly p2m_ipa_bits = 64;
+unsigned int __read_mostly p2m_ipa_bits = PADDR_BITS;
 
 static mfn_t __read_mostly empty_root_mfn;
 
@@ -2023,7 +2023,7 @@ void __init setup_virt_paging(void)
         unsigned int root_order; /* Page order of the root of the p2m */
         unsigned int sl0;    /* Desired SL0, maximum in comment */
     } pa_range_info[] = {
-        /* T0SZ minimum and SL0 maximum from ARM DDI 0487A.b Table D4-5 */
+        /* T0SZ minimum and SL0 maximum from ARM DDI 0487H.a Table D5-6 */
         /*      PA size, t0sz(min), root-order, sl0(max) */
         [0] = { 32,      32/*32*/,  0,          1 },
         [1] = { 36,      28/*28*/,  0,          1 },
@@ -2031,7 +2031,7 @@ void __init setup_virt_paging(void)
         [3] = { 42,      22/*22*/,  3,          1 },
         [4] = { 44,      20/*20*/,  0,          2 },
         [5] = { 48,      16/*16*/,  0,          2 },
-        [6] = { 0 }, /* Invalid */
+        [6] = { 52,      12/*12*/,  3,          3 },
         [7] = { 0 }  /* Invalid */
     };
 
@@ -2062,7 +2062,7 @@ void __init setup_virt_paging(void)
         }
     }
 
-    /* pa_range is 4 bits, but the defined encodings are only 3 bits */
+    /* pa_range is 4 bits but we don't support all modes */
     if ( pa_range >= ARRAY_SIZE(pa_range_info) || !pa_range_info[pa_range].pabits )
         panic("Unknown encoding of ID_AA64MMFR0_EL1.PARange %x\n", pa_range);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 12 17:44:09 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 12 May 2022 17:44:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.327930.550809 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1npCr8-0007XT-6w; Thu, 12 May 2022 17:44:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 327930.550809; Thu, 12 May 2022 17:44: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 1npCr8-0007XL-3n; Thu, 12 May 2022 17:44:06 +0000
Received: by outflank-mailman (input) for mailman id 327930;
 Thu, 12 May 2022 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 1npCr6-0007XF-NW
 for xen-changelog@lists.xenproject.org; Thu, 12 May 2022 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 1npCr6-0004l0-M0
 for xen-changelog@lists.xenproject.org; Thu, 12 May 2022 17:44:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1npCr6-0007q5-L7
 for xen-changelog@lists.xenproject.org; Thu, 12 May 2022 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=bwidCVLJ/qpJXghAeeuqn4WJ9Uq+vZHMnMid2DrgQ1A=; b=zAJesthml+95h2WOOfFR8yzIfH
	SWvb9oDMtZAFDUJ0KNWqEx8zKyHBahnCPBNKW9BivkhJ21o8dqeIyhDqdZ7HVTTHyzcGTbdSfC7Xp
	069n+FdtN47QmTE24UaoZjFwhJ8IoAVV2GRAZCw7Dva1uQPGzyEZ8nl30PY08xU9oFAY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/arm: gnttab: use static inlines for gnttab_{release_}host_mapping*
Message-Id: <E1npCr6-0007q5-L7@xenbits.xenproject.org>
Date: Thu, 12 May 2022 17:44:04 +0000

commit 207abdb38ee987e99385263e3e56b6c500d74cbc
Author:     Michal Orzel <michal.orzel@arm.com>
AuthorDate: Fri May 6 11:42:24 2022 +0200
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu May 12 18:33:27 2022 +0100

    xen/arm: gnttab: use static inlines for gnttab_{release_}host_mapping*
    
    Function unmap_common_complete (common/grant_table.c) defines and sets
    a variable ld that is later on passed to a macro:
    gnttab_host_mapping_get_page_type().
    On Arm this macro does not make use of any arguments causing a compiler
    to warn about unused-but-set variable (when -Wunused-but-set-variable
    is enabled). Fix it by converting this macro to a static inline
    helper and using the boolean return type.
    
    While there, also convert macro gnttab_release_host_mappings.
    
    Signed-off-by: Michal Orzel <michal.orzel@arm.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/include/asm/grant_table.h | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/include/asm/grant_table.h b/xen/arch/arm/include/asm/grant_table.h
index d31a4d6805..a283dd5cd6 100644
--- a/xen/arch/arm/include/asm/grant_table.h
+++ b/xen/arch/arm/include/asm/grant_table.h
@@ -29,12 +29,22 @@ static inline void gnttab_mark_dirty(struct domain *d, mfn_t mfn)
 #endif
 }
 
+static inline bool gnttab_host_mapping_get_page_type(bool ro,
+                                                     const struct domain *ld,
+                                                     const struct domain *rd)
+{
+    return false;
+}
+
+static inline bool gnttab_release_host_mappings(const struct domain *d)
+{
+    return true;
+}
+
 int create_grant_host_mapping(unsigned long gpaddr, mfn_t mfn,
                               unsigned int flags, unsigned int cache_flags);
-#define gnttab_host_mapping_get_page_type(ro, ld, rd) (0)
 int replace_grant_host_mapping(unsigned long gpaddr, mfn_t mfn,
                                unsigned long new_gpaddr, unsigned int flags);
-#define gnttab_release_host_mappings(domain) 1
 
 /*
  * The region used by Xen on the memory will never be mapped in DOM0
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri May 13 08:22:07 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 13 May 2022 08:22:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.328299.551291 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1npQYk-00035Z-VI; Fri, 13 May 2022 08:22:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 328299.551291; Fri, 13 May 2022 08: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 1npQYk-00035Q-S2; Fri, 13 May 2022 08:22:02 +0000
Received: by outflank-mailman (input) for mailman id 328299;
 Fri, 13 May 2022 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 1npQYk-00035I-3Z
 for xen-changelog@lists.xenproject.org; Fri, 13 May 2022 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 1npQYk-0003AQ-2p
 for xen-changelog@lists.xenproject.org; Fri, 13 May 2022 08:22:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1npQYk-00061R-1n
 for xen-changelog@lists.xenproject.org; Fri, 13 May 2022 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=x9ELNcoHtbS7Cs0jwvZN6xCYEvP5hEweBFYiZ8IzLaM=; b=Vwv1ISMfVnjV6NpqXwwUi39EHG
	zsRnW84v8TZBieP0kcgVpKlNDeW6SLEjmUqYP9dOFVjS43L/dlIr3DMy9ATmjXhOi0oAH08zjGpbW
	cOD71NRl+IdesqkX1+aHKGREht1Adamp9qHGE6COoJACca5x5bmv8lzBO8riFnlNiHS4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: gnttab: use static inlines for gnttab_{release_}host_mapping*
Message-Id: <E1npQYk-00061R-1n@xenbits.xenproject.org>
Date: Fri, 13 May 2022 08:22:02 +0000

commit 207abdb38ee987e99385263e3e56b6c500d74cbc
Author:     Michal Orzel <michal.orzel@arm.com>
AuthorDate: Fri May 6 11:42:24 2022 +0200
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu May 12 18:33:27 2022 +0100

    xen/arm: gnttab: use static inlines for gnttab_{release_}host_mapping*
    
    Function unmap_common_complete (common/grant_table.c) defines and sets
    a variable ld that is later on passed to a macro:
    gnttab_host_mapping_get_page_type().
    On Arm this macro does not make use of any arguments causing a compiler
    to warn about unused-but-set variable (when -Wunused-but-set-variable
    is enabled). Fix it by converting this macro to a static inline
    helper and using the boolean return type.
    
    While there, also convert macro gnttab_release_host_mappings.
    
    Signed-off-by: Michal Orzel <michal.orzel@arm.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/include/asm/grant_table.h | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/include/asm/grant_table.h b/xen/arch/arm/include/asm/grant_table.h
index d31a4d6805..a283dd5cd6 100644
--- a/xen/arch/arm/include/asm/grant_table.h
+++ b/xen/arch/arm/include/asm/grant_table.h
@@ -29,12 +29,22 @@ static inline void gnttab_mark_dirty(struct domain *d, mfn_t mfn)
 #endif
 }
 
+static inline bool gnttab_host_mapping_get_page_type(bool ro,
+                                                     const struct domain *ld,
+                                                     const struct domain *rd)
+{
+    return false;
+}
+
+static inline bool gnttab_release_host_mappings(const struct domain *d)
+{
+    return true;
+}
+
 int create_grant_host_mapping(unsigned long gpaddr, mfn_t mfn,
                               unsigned int flags, unsigned int cache_flags);
-#define gnttab_host_mapping_get_page_type(ro, ld, rd) (0)
 int replace_grant_host_mapping(unsigned long gpaddr, mfn_t mfn,
                                unsigned long new_gpaddr, unsigned int flags);
-#define gnttab_release_host_mappings(domain) 1
 
 /*
  * The region used by Xen on the memory will never be mapped in DOM0
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Mon May 16 17:11:10 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 16 May 2022 17:11:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.330187.553519 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nqeFN-0004w3-HO; Mon, 16 May 2022 17:11:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 330187.553519; Mon, 16 May 2022 17: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 1nqeFN-0004vw-EH; Mon, 16 May 2022 17:11:05 +0000
Received: by outflank-mailman (input) for mailman id 330187;
 Mon, 16 May 2022 17: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 1nqeFM-0004vq-5Y
 for xen-changelog@lists.xenproject.org; Mon, 16 May 2022 17: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 1nqeFM-00077j-3o
 for xen-changelog@lists.xenproject.org; Mon, 16 May 2022 17:11:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nqeFM-0006DI-2o
 for xen-changelog@lists.xenproject.org; Mon, 16 May 2022 17: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=YnPp1VVSgdXYDSO2E2cLIhrZhu0CHTiko6ZAr4GQB3I=; b=tGvkLom0O0Wj6jTX6+vuk2rZC0
	JCj7+pndZG5iE1f7+dxlSpT2knZyE2hcC3xlR55ugU2UZIGdXwW4MgDOoRBKwD53vp7mZiwo5RarH
	HVAJlI5YA7CYFu6fl9QitLzCO07uhYrjC1uc03J+lfdoGqBdv9DlAANQc1d8YZLqty+o=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/arm: Defer request_irq on secondary CPUs after local_irq_enable
Message-Id: <E1nqeFM-0006DI-2o@xenbits.xenproject.org>
Date: Mon, 16 May 2022 17:11:04 +0000

commit 0086803a0dfb2ac80c2483cde2fbb87c8df6d254
Author:     Henry Wang <Henry.Wang@arm.com>
AuthorDate: Sat May 7 10:54:33 2022 +0800
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon May 16 18:05:34 2022 +0100

    xen/arm: Defer request_irq on secondary CPUs after local_irq_enable
    
    With the enhanced ASSERT_ALLOC_CONTEXT, calling request_irq before
    local_irq_enable on secondary cores will lead to
    
    (XEN) Xen call trace:
    (XEN) [<000000000021d86c>] alloc_xenheap_pages+0x74/0x194 (PC)
    (XEN) [<000000000021d864>] alloc_xenheap_pages+0x6c/0x194 (LR)
    (XEN) [<0000000000229e90>] xmalloc_tlsf.c#xmalloc_pool_get+0x1c/0x28
    (XEN) [<000000000022a270>] xmem_pool_alloc+0x21c/0x448
    (XEN) [<000000000022a8dc>] _xmalloc+0x8c/0x290
    (XEN) [<000000000026b57c>] request_irq+0x40/0xb8
    (XEN) [<0000000000272780>] init_timer_interrupt+0x74/0xcc
    (XEN) [<000000000027212c>] start_secondary+0x1b4/0x238
    (XEN) [<0000000084000200>] 0000000084000200
    (XEN)
    (XEN)
    (XEN) ****************************************
    (XEN) Panic on CPU 4:
    (XEN) Assertion '!in_irq() && (local_irq_is_enabled() ||
    num_online_cpus() <= 1)' failed at common/page_alloc.c:2212
    (XEN) ****************************************
    
    on systems without a big enough pool for xmalloc() to cater the
    requested size.
    
    Moving the call of request_irq() past local_irq_enable() on
    secondary cores will make sure the assertion condition in
    alloc_xenheap_pages(), i.e. !in_irq && local_irq_enabled() is
    satisfied. It is also safe because the timer and GIC maintenance
    interrupt will not be used until the CPU is fully online.
    
    Reported-by: Wei Chen <Wei.Chen@arm.com>
    Suggested-by: Julien Grall <jgrall@amazon.com>
    Signed-off-by: Henry Wang <Henry.Wang@arm.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/smpboot.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index 7bfd0a73a7..9bb32a301a 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -361,9 +361,6 @@ void start_secondary(void)
 
     init_secondary_IRQ();
 
-    init_maintenance_interrupt();
-    init_timer_interrupt();
-
     set_current(idle_vcpu[cpuid]);
 
     setup_cpu_sibling_map(cpuid);
@@ -380,6 +377,15 @@ void start_secondary(void)
     cpumask_set_cpu(cpuid, &cpu_online_map);
 
     local_irq_enable();
+
+    /*
+     * Calling request_irq() after local_irq_enable() on secondary cores
+     * will make sure the assertion condition in alloc_xenheap_pages(),
+     * i.e. !in_irq && local_irq_enabled() is satisfied.
+     */
+    init_maintenance_interrupt();
+    init_timer_interrupt();
+
     local_abort_enable();
 
     check_local_cpu_errata();
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon May 16 17:22:08 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 16 May 2022 17:22:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.330212.553556 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nqeQ2-0007bO-3W; Mon, 16 May 2022 17:22:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 330212.553556; Mon, 16 May 2022 17: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 1nqeQ2-0007bH-0Y; Mon, 16 May 2022 17:22:06 +0000
Received: by outflank-mailman (input) for mailman id 330212;
 Mon, 16 May 2022 17: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 1nqeQ0-0007b8-Lx
 for xen-changelog@lists.xenproject.org; Mon, 16 May 2022 17: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 1nqeQ0-0007Je-LD
 for xen-changelog@lists.xenproject.org; Mon, 16 May 2022 17:22:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nqeQ0-0006t4-KR
 for xen-changelog@lists.xenproject.org; Mon, 16 May 2022 17: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=M8YHptR5SCwzfx2jvo78IdhGsg+aVfVoUcMOSfVzznw=; b=2Y7WBATC8IMChMbgO4dFb4+H8H
	YCXOVg0wgF5pe0NHGZhJppVFm7btmI+WzPIR0eIOg8DBHFE7SE6fjunxaVgQT+QfFPVfObKa9kdgH
	+6MG48oEZARYCaoDPdubHqS+2vXUK+vcbCdukuat2yjbJ5XIw22R1yVnqsUo5Y8m+gvs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/arm: Print a 64-bit number in hex from early uart
Message-Id: <E1nqeQ0-0006t4-KR@xenbits.xenproject.org>
Date: Mon, 16 May 2022 17:22:04 +0000

commit a250debd2a76e4af058ad611657432f0626922e3
Author:     Wei Chen <wei.chen@arm.com>
AuthorDate: Wed May 11 09:46:31 2022 +0800
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon May 16 18:10:31 2022 +0100

    xen/arm: Print a 64-bit number in hex from early uart
    
    Current putn function that is using for early print
    only can print low 32-bit of AArch64 register. This
    will lose some important messages while debugging
    with early console. For example:
    (XEN) Bringing up CPU5
    - CPU 0000000100000100 booting -
    Will be truncated to
    (XEN) Bringing up CPU5
    - CPU 00000100 booting -
    
    In this patch, we increased the print loops and shift
    bits to make putn print 64-bit number.
    
    Signed-off-by: Wei Chen <wei.chen@arm.com>
    Tested-by: Jiamei Xie <jiamei.xie@arm.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/arm64/head.S | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index 1fd35a8390..109ae7de0c 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -872,17 +872,19 @@ puts:
         ret
 ENDPROC(puts)
 
-/* Print a 32-bit number in hex.  Specific to the PL011 UART.
+/*
+ * Print a 64-bit number in hex.
  * x0: Number to print.
  * x23: Early UART base address
- * Clobbers x0-x3 */
+ * Clobbers x0-x3
+ */
 putn:
         adr   x1, hex
-        mov   x3, #8
+        mov   x3, #16
 1:
         early_uart_ready x23, 2
-        and   x2, x0, #0xf0000000    /* Mask off the top nybble */
-        lsr   x2, x2, #28
+        and   x2, x0, #(0xf<<60)     /* Mask off the top nybble */
+        lsr   x2, x2, #60
         ldrb  w2, [x1, x2]           /* Convert to a char */
         early_uart_transmit x23, w2
         lsl   x0, x0, #4             /* Roll it through one nybble at a time */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon May 16 17:22:16 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 16 May 2022 17:22:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.330213.553560 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nqeQC-0007eL-53; Mon, 16 May 2022 17:22:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 330213.553560; Mon, 16 May 2022 17:22: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 1nqeQC-0007eD-2D; Mon, 16 May 2022 17:22:16 +0000
Received: by outflank-mailman (input) for mailman id 330213;
 Mon, 16 May 2022 17: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 1nqeQA-0007dz-Oz
 for xen-changelog@lists.xenproject.org; Mon, 16 May 2022 17: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 1nqeQA-0007K6-OF
 for xen-changelog@lists.xenproject.org; Mon, 16 May 2022 17:22:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nqeQA-0006vK-NK
 for xen-changelog@lists.xenproject.org; Mon, 16 May 2022 17: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=hrntQ7xUnwg7FrypFV/5avv5hZHIhjydx+j4WO1gw/Y=; b=l8B8BOjQ3GHqcRPXsK7LQIJEbf
	DvKgvs5tgpTqjVWPeKzM/LUD4MDBH6mT6NzN0rkCO1Pp1EXpksyU44pBrgSVbIvEzDmP/NlrYc21m
	dKFh5ULwFwKlonImsirCMN1Pw9Rk11B+ihQvqnuv/XxLa59j2yLqCsOq17G5FDJktbzQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] docs: fix path to code in migration doc
Message-Id: <E1nqeQA-0006vK-NK@xenbits.xenproject.org>
Date: Mon, 16 May 2022 17:22:14 +0000

commit 17060df97c4db79f50ec50a3eda8381a13026356
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Tue May 10 15:05:06 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon May 16 18:16:47 2022 +0100

    docs: fix path to code in migration doc
    
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 docs/features/migration.pandoc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/docs/features/migration.pandoc b/docs/features/migration.pandoc
index 719925818e..5334536d48 100644
--- a/docs/features/migration.pandoc
+++ b/docs/features/migration.pandoc
@@ -54,10 +54,10 @@ legacy stream into a migration v2 stream.
     * `docs/specs/libxc-migration-stream.pandoc`
     * `docs/specs/libxl-migration-stream.pandoc`
 * `libxc`
-    * `tools/libxc/xc_sr_*.[hc]`
+    * `tools/libs/guest/xg_sr_*.[hc]`
 * `libxl`
-    * `tools/libxl/libxl_stream_{read,write}.c`
-    * `tools/libxl/libxl_convert_callout.c`
+    * `tools/libs/light/libxl_stream_{read,write}.c`
+    * `tools/libs/light/libxl_convert_callout.c`
 * Scripts
     * `tools/python/xen/migration/*.py`
     * `tools/python/scripts/convert-legacy-stream`
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Mon May 16 17:22:26 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Mon, 16 May 2022 17:22:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.330214.553564 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nqeQM-0007hA-6M; Mon, 16 May 2022 17:22:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 330214.553564; Mon, 16 May 2022 17:22: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 1nqeQM-0007h3-3f; Mon, 16 May 2022 17:22:26 +0000
Received: by outflank-mailman (input) for mailman id 330214;
 Mon, 16 May 2022 17: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 1nqeQK-0007gn-Rz
 for xen-changelog@lists.xenproject.org; Mon, 16 May 2022 17: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 1nqeQK-0007KG-RC
 for xen-changelog@lists.xenproject.org; Mon, 16 May 2022 17:22:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nqeQK-0006wG-QT
 for xen-changelog@lists.xenproject.org; Mon, 16 May 2022 17: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=WUVVOtuIwBKXODT0EYNB/m6Dtv/YJti0qngKSBdB7BA=; b=X/L47NhUddSqyT+qcak2M8HOeN
	uc5r1J2o7CmfTFqNkrTiO4uASvZ8KPWFdJB87NxHefCySPbkHHeoDyzqI6NV0kYsO64C2lTmeJ8FK
	VBAKK9BYos/uKFqpKKKIBjI/UNfNcs6MEq1OPwv0vxKE1zfb33tAGSE+0tqMGpUhuJ1E=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/arm: Avoid overflow using MIDR_IMPLEMENTOR_MASK
Message-Id: <E1nqeQK-0006wG-QT@xenbits.xenproject.org>
Date: Mon, 16 May 2022 17:22:24 +0000

commit aa1cba100bff84b211f27639bd6efeaf7e701bcc
Author:     Michal Orzel <michal.orzel@arm.com>
AuthorDate: Thu May 5 13:59:06 2022 +0200
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon May 16 18:20:40 2022 +0100

    xen/arm: Avoid overflow using MIDR_IMPLEMENTOR_MASK
    
    Value of macro MIDR_IMPLEMENTOR_MASK exceeds the range of integer
    and can lead to overflow. Currently there is no issue as it is used
    in an expression implicitly casted to u32 in MIDR_IS_CPU_MODEL_RANGE.
    To avoid possible problems, fix the macro.
    
    Signed-off-by: Michal Orzel <michal.orzel@arm.com>
    Link: https://lore.kernel.org/r/20220426070603.56031-1-michal.orzel@arm.com
    Acked-by: Catalin Marinas <catalin.marinas@arm.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/include/asm/processor.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/include/asm/processor.h b/xen/arch/arm/include/asm/processor.h
index 852b5f3c24..7a1c4c4410 100644
--- a/xen/arch/arm/include/asm/processor.h
+++ b/xen/arch/arm/include/asm/processor.h
@@ -39,7 +39,7 @@
 #define MIDR_VARIANT(midr) \
     (((midr) & MIDR_VARIANT_MASK) >> MIDR_VARIANT_SHIFT)
 #define MIDR_IMPLEMENTOR_SHIFT  24
-#define MIDR_IMPLEMENTOR_MASK   (0xff << MIDR_IMPLEMENTOR_SHIFT)
+#define MIDR_IMPLEMENTOR_MASK   (0xffU << MIDR_IMPLEMENTOR_SHIFT)
 #define MIDR_IMPLEMENTOR(midr) \
     (((midr) & MIDR_IMPLEMENTOR_MASK) >> MIDR_IMPLEMENTOR_SHIFT)
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue May 17 06:44:07 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 17 May 2022 06:44:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.330488.553861 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nqqw7-0003DO-3s; Tue, 17 May 2022 06:44:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 330488.553861; Tue, 17 May 2022 06: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 1nqqw7-0003DF-0P; Tue, 17 May 2022 06:44:03 +0000
Received: by outflank-mailman (input) for mailman id 330488;
 Tue, 17 May 2022 06: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 1nqqw6-0003D9-2N
 for xen-changelog@lists.xenproject.org; Tue, 17 May 2022 06: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 1nqqw6-0003wI-1R
 for xen-changelog@lists.xenproject.org; Tue, 17 May 2022 06:44:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nqqw6-0000z2-0M
 for xen-changelog@lists.xenproject.org; Tue, 17 May 2022 06: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=Yt7JeZbypKSqcNVlls0esVjXsYnTENGOaLZWPB4Jwa0=; b=2cKDpjZxorUHs6vxe+5Nekyfat
	oMUsS8OBEBOOE1WY+VZUKktzZRCQ+W1YLZU6PYnFHCyJNTCTjRi7NfCO1p8u+h53oqrejxGVDperV
	JbY4H9cDR/aH7NAyDsPMNL78Q0Q0PY9YU11s1rPwzn6qJu0ZyC4nVGXqU/eVy5PgDbQI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: Defer request_irq on secondary CPUs after local_irq_enable
Message-Id: <E1nqqw6-0000z2-0M@xenbits.xenproject.org>
Date: Tue, 17 May 2022 06:44:02 +0000

commit 0086803a0dfb2ac80c2483cde2fbb87c8df6d254
Author:     Henry Wang <Henry.Wang@arm.com>
AuthorDate: Sat May 7 10:54:33 2022 +0800
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon May 16 18:05:34 2022 +0100

    xen/arm: Defer request_irq on secondary CPUs after local_irq_enable
    
    With the enhanced ASSERT_ALLOC_CONTEXT, calling request_irq before
    local_irq_enable on secondary cores will lead to
    
    (XEN) Xen call trace:
    (XEN) [<000000000021d86c>] alloc_xenheap_pages+0x74/0x194 (PC)
    (XEN) [<000000000021d864>] alloc_xenheap_pages+0x6c/0x194 (LR)
    (XEN) [<0000000000229e90>] xmalloc_tlsf.c#xmalloc_pool_get+0x1c/0x28
    (XEN) [<000000000022a270>] xmem_pool_alloc+0x21c/0x448
    (XEN) [<000000000022a8dc>] _xmalloc+0x8c/0x290
    (XEN) [<000000000026b57c>] request_irq+0x40/0xb8
    (XEN) [<0000000000272780>] init_timer_interrupt+0x74/0xcc
    (XEN) [<000000000027212c>] start_secondary+0x1b4/0x238
    (XEN) [<0000000084000200>] 0000000084000200
    (XEN)
    (XEN)
    (XEN) ****************************************
    (XEN) Panic on CPU 4:
    (XEN) Assertion '!in_irq() && (local_irq_is_enabled() ||
    num_online_cpus() <= 1)' failed at common/page_alloc.c:2212
    (XEN) ****************************************
    
    on systems without a big enough pool for xmalloc() to cater the
    requested size.
    
    Moving the call of request_irq() past local_irq_enable() on
    secondary cores will make sure the assertion condition in
    alloc_xenheap_pages(), i.e. !in_irq && local_irq_enabled() is
    satisfied. It is also safe because the timer and GIC maintenance
    interrupt will not be used until the CPU is fully online.
    
    Reported-by: Wei Chen <Wei.Chen@arm.com>
    Suggested-by: Julien Grall <jgrall@amazon.com>
    Signed-off-by: Henry Wang <Henry.Wang@arm.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/smpboot.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index 7bfd0a73a7..9bb32a301a 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -361,9 +361,6 @@ void start_secondary(void)
 
     init_secondary_IRQ();
 
-    init_maintenance_interrupt();
-    init_timer_interrupt();
-
     set_current(idle_vcpu[cpuid]);
 
     setup_cpu_sibling_map(cpuid);
@@ -380,6 +377,15 @@ void start_secondary(void)
     cpumask_set_cpu(cpuid, &cpu_online_map);
 
     local_irq_enable();
+
+    /*
+     * Calling request_irq() after local_irq_enable() on secondary cores
+     * will make sure the assertion condition in alloc_xenheap_pages(),
+     * i.e. !in_irq && local_irq_enabled() is satisfied.
+     */
+    init_maintenance_interrupt();
+    init_timer_interrupt();
+
     local_abort_enable();
 
     check_local_cpu_errata();
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue May 17 06:44:13 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 17 May 2022 06:44:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.330489.553864 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nqqwH-0003Fh-50; Tue, 17 May 2022 06:44:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 330489.553864; Tue, 17 May 2022 06: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 1nqqwH-0003FX-1y; Tue, 17 May 2022 06:44:13 +0000
Received: by outflank-mailman (input) for mailman id 330489;
 Tue, 17 May 2022 06: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 1nqqwG-0003FL-5P
 for xen-changelog@lists.xenproject.org; Tue, 17 May 2022 06: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 1nqqwG-0003wi-4a
 for xen-changelog@lists.xenproject.org; Tue, 17 May 2022 06:44:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nqqwG-0000zh-3c
 for xen-changelog@lists.xenproject.org; Tue, 17 May 2022 06: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=2YkogW8o/p718MM/RPv6wknr1zssBIRdVkTL0gXKnMc=; b=eZBHmHQKGsiqmD5bWPkkLMWZeg
	KQnYZDUdfOjiyjgEbvk7ZCcFrLgEGeMtFfN8/cMa05rb6XR0Y7P5KQ00NQeGjRH8zq2hk2xKtEsNa
	q3i7mCgN6WHn0mOJFpZ/66Q9rt86FaUdDq0bvJrJU/WmYLDKytdZfW2wHkOIQCa8QhL8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: Print a 64-bit number in hex from early uart
Message-Id: <E1nqqwG-0000zh-3c@xenbits.xenproject.org>
Date: Tue, 17 May 2022 06:44:12 +0000

commit a250debd2a76e4af058ad611657432f0626922e3
Author:     Wei Chen <wei.chen@arm.com>
AuthorDate: Wed May 11 09:46:31 2022 +0800
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon May 16 18:10:31 2022 +0100

    xen/arm: Print a 64-bit number in hex from early uart
    
    Current putn function that is using for early print
    only can print low 32-bit of AArch64 register. This
    will lose some important messages while debugging
    with early console. For example:
    (XEN) Bringing up CPU5
    - CPU 0000000100000100 booting -
    Will be truncated to
    (XEN) Bringing up CPU5
    - CPU 00000100 booting -
    
    In this patch, we increased the print loops and shift
    bits to make putn print 64-bit number.
    
    Signed-off-by: Wei Chen <wei.chen@arm.com>
    Tested-by: Jiamei Xie <jiamei.xie@arm.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/arm64/head.S | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index 1fd35a8390..109ae7de0c 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -872,17 +872,19 @@ puts:
         ret
 ENDPROC(puts)
 
-/* Print a 32-bit number in hex.  Specific to the PL011 UART.
+/*
+ * Print a 64-bit number in hex.
  * x0: Number to print.
  * x23: Early UART base address
- * Clobbers x0-x3 */
+ * Clobbers x0-x3
+ */
 putn:
         adr   x1, hex
-        mov   x3, #8
+        mov   x3, #16
 1:
         early_uart_ready x23, 2
-        and   x2, x0, #0xf0000000    /* Mask off the top nybble */
-        lsr   x2, x2, #28
+        and   x2, x0, #(0xf<<60)     /* Mask off the top nybble */
+        lsr   x2, x2, #60
         ldrb  w2, [x1, x2]           /* Convert to a char */
         early_uart_transmit x23, w2
         lsl   x0, x0, #4             /* Roll it through one nybble at a time */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue May 17 06:44:23 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 17 May 2022 06:44:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.330490.553869 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nqqwR-0003Io-6l; Tue, 17 May 2022 06:44:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 330490.553869; Tue, 17 May 2022 06: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 1nqqwR-0003Ig-3b; Tue, 17 May 2022 06:44:23 +0000
Received: by outflank-mailman (input) for mailman id 330490;
 Tue, 17 May 2022 06: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 1nqqwQ-0003IO-8E
 for xen-changelog@lists.xenproject.org; Tue, 17 May 2022 06: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 1nqqwQ-0003x0-7T
 for xen-changelog@lists.xenproject.org; Tue, 17 May 2022 06:44:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nqqwQ-00010K-6Z
 for xen-changelog@lists.xenproject.org; Tue, 17 May 2022 06: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=btJTvyo/SE/nahopDshXOVBvnGXjJI7JtflYoU+QWAU=; b=EM1JsUHLTb41Gmfx7s2lYoQD95
	iltuqjw9yWDhsyeJ0sSYFlbp9iDYXyuPSAo5w1/gN0aikopPktZZuCzCGJdzPCWy/GcIpam1WN3pM
	RP9eO62XK/HjPNaskQ+LiR1BDSFUDte17A3rH18aIfo+CIP/rzk7R3OBhMFlyFfBms4U=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] docs: fix path to code in migration doc
Message-Id: <E1nqqwQ-00010K-6Z@xenbits.xenproject.org>
Date: Tue, 17 May 2022 06:44:22 +0000

commit 17060df97c4db79f50ec50a3eda8381a13026356
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Tue May 10 15:05:06 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon May 16 18:16:47 2022 +0100

    docs: fix path to code in migration doc
    
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 docs/features/migration.pandoc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/docs/features/migration.pandoc b/docs/features/migration.pandoc
index 719925818e..5334536d48 100644
--- a/docs/features/migration.pandoc
+++ b/docs/features/migration.pandoc
@@ -54,10 +54,10 @@ legacy stream into a migration v2 stream.
     * `docs/specs/libxc-migration-stream.pandoc`
     * `docs/specs/libxl-migration-stream.pandoc`
 * `libxc`
-    * `tools/libxc/xc_sr_*.[hc]`
+    * `tools/libs/guest/xg_sr_*.[hc]`
 * `libxl`
-    * `tools/libxl/libxl_stream_{read,write}.c`
-    * `tools/libxl/libxl_convert_callout.c`
+    * `tools/libs/light/libxl_stream_{read,write}.c`
+    * `tools/libs/light/libxl_convert_callout.c`
 * Scripts
     * `tools/python/xen/migration/*.py`
     * `tools/python/scripts/convert-legacy-stream`
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue May 17 06:44:33 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 17 May 2022 06:44:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.330491.553873 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nqqwb-0003Ld-8j; Tue, 17 May 2022 06:44:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 330491.553873; Tue, 17 May 2022 06: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 1nqqwb-0003LW-5E; Tue, 17 May 2022 06:44:33 +0000
Received: by outflank-mailman (input) for mailman id 330491;
 Tue, 17 May 2022 06: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 1nqqwa-0003LP-BH
 for xen-changelog@lists.xenproject.org; Tue, 17 May 2022 06: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 1nqqwa-0003xC-AZ
 for xen-changelog@lists.xenproject.org; Tue, 17 May 2022 06:44:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nqqwa-00010t-9b
 for xen-changelog@lists.xenproject.org; Tue, 17 May 2022 06: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=cMOnMa8XqYembb4AmQKo67WmJ3X2jbUFlFzZhBDbXVI=; b=OC0p035tJBaD04Nf3PzUBNZh4E
	ZI9le4CNJd2s/cUooIpx3jLx4/rIe1L5qvKmW43ghrLU6ruujYT1U/ZhIKwLKG45/cCjV6Vm6qH3X
	ClS1SH/iZhGwtXwBRXglPOBWTHIM8knNH1FJUzS5Zt+8xXk+eadw+gT7lWYQUraXYLUg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: Avoid overflow using MIDR_IMPLEMENTOR_MASK
Message-Id: <E1nqqwa-00010t-9b@xenbits.xenproject.org>
Date: Tue, 17 May 2022 06:44:32 +0000

commit aa1cba100bff84b211f27639bd6efeaf7e701bcc
Author:     Michal Orzel <michal.orzel@arm.com>
AuthorDate: Thu May 5 13:59:06 2022 +0200
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon May 16 18:20:40 2022 +0100

    xen/arm: Avoid overflow using MIDR_IMPLEMENTOR_MASK
    
    Value of macro MIDR_IMPLEMENTOR_MASK exceeds the range of integer
    and can lead to overflow. Currently there is no issue as it is used
    in an expression implicitly casted to u32 in MIDR_IS_CPU_MODEL_RANGE.
    To avoid possible problems, fix the macro.
    
    Signed-off-by: Michal Orzel <michal.orzel@arm.com>
    Link: https://lore.kernel.org/r/20220426070603.56031-1-michal.orzel@arm.com
    Acked-by: Catalin Marinas <catalin.marinas@arm.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/include/asm/processor.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/include/asm/processor.h b/xen/arch/arm/include/asm/processor.h
index 852b5f3c24..7a1c4c4410 100644
--- a/xen/arch/arm/include/asm/processor.h
+++ b/xen/arch/arm/include/asm/processor.h
@@ -39,7 +39,7 @@
 #define MIDR_VARIANT(midr) \
     (((midr) & MIDR_VARIANT_MASK) >> MIDR_VARIANT_SHIFT)
 #define MIDR_IMPLEMENTOR_SHIFT  24
-#define MIDR_IMPLEMENTOR_MASK   (0xff << MIDR_IMPLEMENTOR_SHIFT)
+#define MIDR_IMPLEMENTOR_MASK   (0xffU << MIDR_IMPLEMENTOR_SHIFT)
 #define MIDR_IMPLEMENTOR(midr) \
     (((midr) & MIDR_IMPLEMENTOR_MASK) >> MIDR_IMPLEMENTOR_SHIFT)
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue May 17 17:22:10 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 17 May 2022 17:22:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.331335.554823 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nr0tZ-0005wG-Cn; Tue, 17 May 2022 17:22:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 331335.554823; Tue, 17 May 2022 17: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 1nr0tZ-0005w8-9L; Tue, 17 May 2022 17:22:05 +0000
Received: by outflank-mailman (input) for mailman id 331335;
 Tue, 17 May 2022 17: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 1nr0tY-0005uj-6H
 for xen-changelog@lists.xenproject.org; Tue, 17 May 2022 17: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 1nr0tY-0000bO-5O
 for xen-changelog@lists.xenproject.org; Tue, 17 May 2022 17:22:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nr0tY-0007At-3X
 for xen-changelog@lists.xenproject.org; Tue, 17 May 2022 17: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=mduNm6Pc6p3oIzKPSV4szfSVUN0Q0/sEINwzAwD5V6Q=; b=inVqOYnnAk579pHbc1XhxGQojN
	8JNu5FjSIk/SFImj08xjc6J6I0Cxpuo9htHfmoUAZnFW6WFkf4CBiyVzC3c7YB0H7cvuR2M0GgrM0
	KSSdgsIHBtk/cXNGnYyPK/H7Pc9kB+FxaEgyHurToLs4LzgxKoAkyWvMVvtYeOvnQmAk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/arm: gic-v3-lpi: Allocate the pending table while preparing the CPU
Message-Id: <E1nr0tY-0007At-3X@xenbits.xenproject.org>
Date: Tue, 17 May 2022 17:22:04 +0000

commit 69589c374a92d1b4f97db24623e5f760990eaf82
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Tue May 17 18:18:46 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Tue May 17 18:19:22 2022 +0100

    xen/arm: gic-v3-lpi: Allocate the pending table while preparing the CPU
    
    Commit 88a037e2cfe1 "page_alloc: assert IRQs are enabled in heap
    alloc/free" extended the checks in the buddy allocator to catch any
    use of the helpers from context with interrupts disabled.
    
    Unfortunately, the rule is not followed in the LPI code when allocating
    the pending table:
    
    (XEN) Xen call trace:
    (XEN)    [<000000000022a678>] alloc_xenheap_pages+0x178/0x194 (PC)
    (XEN)    [<000000000022a670>] alloc_xenheap_pages+0x170/0x194 (LR)
    (XEN)    [<0000000000237770>] _xmalloc+0x144/0x294
    (XEN)    [<00000000002378d4>] _xzalloc+0x14/0x30
    (XEN)    [<000000000027b4e4>] gicv3_lpi_init_rdist+0x54/0x324
    (XEN)    [<0000000000279898>] arch/arm/gic-v3.c#gicv3_cpu_init+0x128/0x46
    (XEN)    [<0000000000279bfc>] arch/arm/gic-v3.c#gicv3_secondary_cpu_init+0x20/0x50
    (XEN)    [<0000000000277054>] gic_init_secondary_cpu+0x18/0x30
    (XEN)    [<0000000000284518>] start_secondary+0x1a8/0x234
    (XEN)    [<0000010722aa4200>] 0000010722aa4200
    (XEN)
    (XEN)
    (XEN) ****************************************
    (XEN) Panic on CPU 2:
    (XEN) Assertion '!in_irq() && (local_irq_is_enabled() || num_online_cpus() <= 1)' failed at common/page_alloc.c:2212
    (XEN) ****************************************
    
    For now the patch extending the checks has been reverted, but it would
    be good to re-introduce it (allocation with interrupt is not desirable).
    
    The logic is reworked to allocate the pending table when preparing the
    CPU.
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
---
 xen/arch/arm/gic-v3-lpi.c | 91 +++++++++++++++++++++++++++++++++++------------
 1 file changed, 69 insertions(+), 22 deletions(-)

diff --git a/xen/arch/arm/gic-v3-lpi.c b/xen/arch/arm/gic-v3-lpi.c
index e1594dd20e..61d90eb386 100644
--- a/xen/arch/arm/gic-v3-lpi.c
+++ b/xen/arch/arm/gic-v3-lpi.c
@@ -18,6 +18,7 @@
  * along with this program; If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <xen/cpu.h>
 #include <xen/lib.h>
 #include <xen/mm.h>
 #include <xen/param.h>
@@ -234,18 +235,13 @@ void gicv3_lpi_update_host_entry(uint32_t host_lpi, int domain_id,
     write_u64_atomic(&hlpip->data, hlpi.data);
 }
 
-static int gicv3_lpi_allocate_pendtable(uint64_t *reg)
+static int gicv3_lpi_allocate_pendtable(unsigned int cpu)
 {
-    uint64_t val;
     void *pendtable;
 
-    if ( this_cpu(lpi_redist).pending_table )
+    if ( per_cpu(lpi_redist, cpu).pending_table )
         return -EBUSY;
 
-    val  = GIC_BASER_CACHE_RaWaWb << GICR_PENDBASER_INNER_CACHEABILITY_SHIFT;
-    val |= GIC_BASER_CACHE_SameAsInner << GICR_PENDBASER_OUTER_CACHEABILITY_SHIFT;
-    val |= GIC_BASER_InnerShareable << GICR_PENDBASER_SHAREABILITY_SHIFT;
-
     /*
      * The pending table holds one bit per LPI and even covers bits for
      * interrupt IDs below 8192, so we allocate the full range.
@@ -265,13 +261,45 @@ static int gicv3_lpi_allocate_pendtable(uint64_t *reg)
     clean_and_invalidate_dcache_va_range(pendtable,
                                          lpi_data.max_host_lpi_ids / 8);
 
-    this_cpu(lpi_redist).pending_table = pendtable;
+    per_cpu(lpi_redist, cpu).pending_table = pendtable;
 
-    val |= GICR_PENDBASER_PTZ;
+    return 0;
+}
+
+static int gicv3_lpi_set_pendtable(void __iomem *rdist_base)
+{
+    const void *pendtable = this_cpu(lpi_redist).pending_table;
+    uint64_t val;
+
+    /*
+     * The memory should have been allocated while preparing the CPU (or
+     * before calling this function for the boot CPU).
+     */
+    if ( !pendtable )
+    {
+        ASSERT_UNREACHABLE();
+        return -ENOMEM;
+    }
 
+    ASSERT(!(virt_to_maddr(pendtable) & ~GENMASK(51, 16)));
+
+    val  = GIC_BASER_CACHE_RaWaWb << GICR_PENDBASER_INNER_CACHEABILITY_SHIFT;
+    val |= GIC_BASER_CACHE_SameAsInner << GICR_PENDBASER_OUTER_CACHEABILITY_SHIFT;
+    val |= GIC_BASER_InnerShareable << GICR_PENDBASER_SHAREABILITY_SHIFT;
+    val |= GICR_PENDBASER_PTZ;
     val |= virt_to_maddr(pendtable);
 
-    *reg = val;
+    writeq_relaxed(val, rdist_base + GICR_PENDBASER);
+    val = readq_relaxed(rdist_base + GICR_PENDBASER);
+
+    /* If the hardware reports non-shareable, drop cacheability as well. */
+    if ( !(val & GICR_PENDBASER_SHAREABILITY_MASK) )
+    {
+        val &= ~GICR_PENDBASER_INNER_CACHEABILITY_MASK;
+        val |= GIC_BASER_CACHE_nC << GICR_PENDBASER_INNER_CACHEABILITY_SHIFT;
+
+        writeq_relaxed(val, rdist_base + GICR_PENDBASER);
+    }
 
     return 0;
 }
@@ -340,7 +368,6 @@ static int gicv3_lpi_set_proptable(void __iomem * rdist_base)
 int gicv3_lpi_init_rdist(void __iomem * rdist_base)
 {
     uint32_t reg;
-    uint64_t table_reg;
     int ret;
 
     /* We don't support LPIs without an ITS. */
@@ -352,24 +379,36 @@ int gicv3_lpi_init_rdist(void __iomem * rdist_base)
     if ( reg & GICR_CTLR_ENABLE_LPIS )
         return -EBUSY;
 
-    ret = gicv3_lpi_allocate_pendtable(&table_reg);
+    ret = gicv3_lpi_set_pendtable(rdist_base);
     if ( ret )
         return ret;
-    writeq_relaxed(table_reg, rdist_base + GICR_PENDBASER);
-    table_reg = readq_relaxed(rdist_base + GICR_PENDBASER);
 
-    /* If the hardware reports non-shareable, drop cacheability as well. */
-    if ( !(table_reg & GICR_PENDBASER_SHAREABILITY_MASK) )
-    {
-        table_reg &= ~GICR_PENDBASER_INNER_CACHEABILITY_MASK;
-        table_reg |= GIC_BASER_CACHE_nC << GICR_PENDBASER_INNER_CACHEABILITY_SHIFT;
+    return gicv3_lpi_set_proptable(rdist_base);
+}
 
-        writeq_relaxed(table_reg, rdist_base + GICR_PENDBASER);
+static int cpu_callback(struct notifier_block *nfb, unsigned long action,
+                        void *hcpu)
+{
+    unsigned long cpu = (unsigned long)hcpu;
+    int rc = 0;
+
+    switch ( action )
+    {
+    case CPU_UP_PREPARE:
+        rc = gicv3_lpi_allocate_pendtable(cpu);
+        if ( rc )
+            printk(XENLOG_ERR "Unable to allocate the pendtable for CPU%lu\n",
+                   cpu);
+        break;
     }
 
-    return gicv3_lpi_set_proptable(rdist_base);
+    return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
 }
 
+static struct notifier_block cpu_nfb = {
+    .notifier_call = cpu_callback,
+};
+
 static unsigned int max_lpi_bits = 20;
 integer_param("max_lpi_bits", max_lpi_bits);
 
@@ -381,6 +420,7 @@ integer_param("max_lpi_bits", max_lpi_bits);
 int gicv3_lpi_init_host_lpis(unsigned int host_lpi_bits)
 {
     unsigned int nr_lpi_ptrs;
+    int rc;
 
     /* We rely on the data structure being atomically accessible. */
     BUILD_BUG_ON(sizeof(union host_lpi) > sizeof(unsigned long));
@@ -413,7 +453,14 @@ int gicv3_lpi_init_host_lpis(unsigned int host_lpi_bits)
 
     printk("GICv3: using at most %lu LPIs on the host.\n", MAX_NR_HOST_LPIS);
 
-    return 0;
+    /* Register the CPU notifier and allocate memory for the boot CPU */
+    register_cpu_notifier(&cpu_nfb);
+    rc = gicv3_lpi_allocate_pendtable(smp_processor_id());
+    if ( rc )
+        printk(XENLOG_ERR "Unable to allocate the pendtable for CPU%u\n",
+               smp_processor_id());
+
+    return rc;
 }
 
 static int find_unused_host_lpi(uint32_t start, uint32_t *index)
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed May 18 05:33:08 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 18 May 2022 05:33:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.331630.555169 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrCIx-00020S-BU; Wed, 18 May 2022 05:33:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 331630.555169; Wed, 18 May 2022 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 1nrCIx-00020K-7W; Wed, 18 May 2022 05:33:03 +0000
Received: by outflank-mailman (input) for mailman id 331630;
 Wed, 18 May 2022 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 1nrCIv-00020E-Li
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 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 1nrCIv-0004iS-E3
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 05:33:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrCIv-0001wm-Cs
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 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=aDV/oysBaWj0u53yyc/cxTj735uDlsuvR0cDg9gYpH0=; b=Zwmdl/Be5nOAWhZADrg5dlpSGo
	jb+eryMR+2uwjOy09qc0EoaWbsCdIOMaJFMzNd8vFW3Odljt3F6yjM+xHh3pC4lpVPyATJvqzmy+8
	huefrsPtWRtNPQaqmdf/TaBnM1es6L4ucP5B7h1ZSqWh8+6L/mCCuGjq+rl/5Txe8Ufs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: gic-v3-lpi: Allocate the pending table while preparing the CPU
Message-Id: <E1nrCIv-0001wm-Cs@xenbits.xenproject.org>
Date: Wed, 18 May 2022 05:33:01 +0000

commit 69589c374a92d1b4f97db24623e5f760990eaf82
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Tue May 17 18:18:46 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Tue May 17 18:19:22 2022 +0100

    xen/arm: gic-v3-lpi: Allocate the pending table while preparing the CPU
    
    Commit 88a037e2cfe1 "page_alloc: assert IRQs are enabled in heap
    alloc/free" extended the checks in the buddy allocator to catch any
    use of the helpers from context with interrupts disabled.
    
    Unfortunately, the rule is not followed in the LPI code when allocating
    the pending table:
    
    (XEN) Xen call trace:
    (XEN)    [<000000000022a678>] alloc_xenheap_pages+0x178/0x194 (PC)
    (XEN)    [<000000000022a670>] alloc_xenheap_pages+0x170/0x194 (LR)
    (XEN)    [<0000000000237770>] _xmalloc+0x144/0x294
    (XEN)    [<00000000002378d4>] _xzalloc+0x14/0x30
    (XEN)    [<000000000027b4e4>] gicv3_lpi_init_rdist+0x54/0x324
    (XEN)    [<0000000000279898>] arch/arm/gic-v3.c#gicv3_cpu_init+0x128/0x46
    (XEN)    [<0000000000279bfc>] arch/arm/gic-v3.c#gicv3_secondary_cpu_init+0x20/0x50
    (XEN)    [<0000000000277054>] gic_init_secondary_cpu+0x18/0x30
    (XEN)    [<0000000000284518>] start_secondary+0x1a8/0x234
    (XEN)    [<0000010722aa4200>] 0000010722aa4200
    (XEN)
    (XEN)
    (XEN) ****************************************
    (XEN) Panic on CPU 2:
    (XEN) Assertion '!in_irq() && (local_irq_is_enabled() || num_online_cpus() <= 1)' failed at common/page_alloc.c:2212
    (XEN) ****************************************
    
    For now the patch extending the checks has been reverted, but it would
    be good to re-introduce it (allocation with interrupt is not desirable).
    
    The logic is reworked to allocate the pending table when preparing the
    CPU.
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
---
 xen/arch/arm/gic-v3-lpi.c | 91 +++++++++++++++++++++++++++++++++++------------
 1 file changed, 69 insertions(+), 22 deletions(-)

diff --git a/xen/arch/arm/gic-v3-lpi.c b/xen/arch/arm/gic-v3-lpi.c
index e1594dd20e..61d90eb386 100644
--- a/xen/arch/arm/gic-v3-lpi.c
+++ b/xen/arch/arm/gic-v3-lpi.c
@@ -18,6 +18,7 @@
  * along with this program; If not, see <http://www.gnu.org/licenses/>.
  */
 
+#include <xen/cpu.h>
 #include <xen/lib.h>
 #include <xen/mm.h>
 #include <xen/param.h>
@@ -234,18 +235,13 @@ void gicv3_lpi_update_host_entry(uint32_t host_lpi, int domain_id,
     write_u64_atomic(&hlpip->data, hlpi.data);
 }
 
-static int gicv3_lpi_allocate_pendtable(uint64_t *reg)
+static int gicv3_lpi_allocate_pendtable(unsigned int cpu)
 {
-    uint64_t val;
     void *pendtable;
 
-    if ( this_cpu(lpi_redist).pending_table )
+    if ( per_cpu(lpi_redist, cpu).pending_table )
         return -EBUSY;
 
-    val  = GIC_BASER_CACHE_RaWaWb << GICR_PENDBASER_INNER_CACHEABILITY_SHIFT;
-    val |= GIC_BASER_CACHE_SameAsInner << GICR_PENDBASER_OUTER_CACHEABILITY_SHIFT;
-    val |= GIC_BASER_InnerShareable << GICR_PENDBASER_SHAREABILITY_SHIFT;
-
     /*
      * The pending table holds one bit per LPI and even covers bits for
      * interrupt IDs below 8192, so we allocate the full range.
@@ -265,13 +261,45 @@ static int gicv3_lpi_allocate_pendtable(uint64_t *reg)
     clean_and_invalidate_dcache_va_range(pendtable,
                                          lpi_data.max_host_lpi_ids / 8);
 
-    this_cpu(lpi_redist).pending_table = pendtable;
+    per_cpu(lpi_redist, cpu).pending_table = pendtable;
 
-    val |= GICR_PENDBASER_PTZ;
+    return 0;
+}
+
+static int gicv3_lpi_set_pendtable(void __iomem *rdist_base)
+{
+    const void *pendtable = this_cpu(lpi_redist).pending_table;
+    uint64_t val;
+
+    /*
+     * The memory should have been allocated while preparing the CPU (or
+     * before calling this function for the boot CPU).
+     */
+    if ( !pendtable )
+    {
+        ASSERT_UNREACHABLE();
+        return -ENOMEM;
+    }
 
+    ASSERT(!(virt_to_maddr(pendtable) & ~GENMASK(51, 16)));
+
+    val  = GIC_BASER_CACHE_RaWaWb << GICR_PENDBASER_INNER_CACHEABILITY_SHIFT;
+    val |= GIC_BASER_CACHE_SameAsInner << GICR_PENDBASER_OUTER_CACHEABILITY_SHIFT;
+    val |= GIC_BASER_InnerShareable << GICR_PENDBASER_SHAREABILITY_SHIFT;
+    val |= GICR_PENDBASER_PTZ;
     val |= virt_to_maddr(pendtable);
 
-    *reg = val;
+    writeq_relaxed(val, rdist_base + GICR_PENDBASER);
+    val = readq_relaxed(rdist_base + GICR_PENDBASER);
+
+    /* If the hardware reports non-shareable, drop cacheability as well. */
+    if ( !(val & GICR_PENDBASER_SHAREABILITY_MASK) )
+    {
+        val &= ~GICR_PENDBASER_INNER_CACHEABILITY_MASK;
+        val |= GIC_BASER_CACHE_nC << GICR_PENDBASER_INNER_CACHEABILITY_SHIFT;
+
+        writeq_relaxed(val, rdist_base + GICR_PENDBASER);
+    }
 
     return 0;
 }
@@ -340,7 +368,6 @@ static int gicv3_lpi_set_proptable(void __iomem * rdist_base)
 int gicv3_lpi_init_rdist(void __iomem * rdist_base)
 {
     uint32_t reg;
-    uint64_t table_reg;
     int ret;
 
     /* We don't support LPIs without an ITS. */
@@ -352,24 +379,36 @@ int gicv3_lpi_init_rdist(void __iomem * rdist_base)
     if ( reg & GICR_CTLR_ENABLE_LPIS )
         return -EBUSY;
 
-    ret = gicv3_lpi_allocate_pendtable(&table_reg);
+    ret = gicv3_lpi_set_pendtable(rdist_base);
     if ( ret )
         return ret;
-    writeq_relaxed(table_reg, rdist_base + GICR_PENDBASER);
-    table_reg = readq_relaxed(rdist_base + GICR_PENDBASER);
 
-    /* If the hardware reports non-shareable, drop cacheability as well. */
-    if ( !(table_reg & GICR_PENDBASER_SHAREABILITY_MASK) )
-    {
-        table_reg &= ~GICR_PENDBASER_INNER_CACHEABILITY_MASK;
-        table_reg |= GIC_BASER_CACHE_nC << GICR_PENDBASER_INNER_CACHEABILITY_SHIFT;
+    return gicv3_lpi_set_proptable(rdist_base);
+}
 
-        writeq_relaxed(table_reg, rdist_base + GICR_PENDBASER);
+static int cpu_callback(struct notifier_block *nfb, unsigned long action,
+                        void *hcpu)
+{
+    unsigned long cpu = (unsigned long)hcpu;
+    int rc = 0;
+
+    switch ( action )
+    {
+    case CPU_UP_PREPARE:
+        rc = gicv3_lpi_allocate_pendtable(cpu);
+        if ( rc )
+            printk(XENLOG_ERR "Unable to allocate the pendtable for CPU%lu\n",
+                   cpu);
+        break;
     }
 
-    return gicv3_lpi_set_proptable(rdist_base);
+    return !rc ? NOTIFY_DONE : notifier_from_errno(rc);
 }
 
+static struct notifier_block cpu_nfb = {
+    .notifier_call = cpu_callback,
+};
+
 static unsigned int max_lpi_bits = 20;
 integer_param("max_lpi_bits", max_lpi_bits);
 
@@ -381,6 +420,7 @@ integer_param("max_lpi_bits", max_lpi_bits);
 int gicv3_lpi_init_host_lpis(unsigned int host_lpi_bits)
 {
     unsigned int nr_lpi_ptrs;
+    int rc;
 
     /* We rely on the data structure being atomically accessible. */
     BUILD_BUG_ON(sizeof(union host_lpi) > sizeof(unsigned long));
@@ -413,7 +453,14 @@ int gicv3_lpi_init_host_lpis(unsigned int host_lpi_bits)
 
     printk("GICv3: using at most %lu LPIs on the host.\n", MAX_NR_HOST_LPIS);
 
-    return 0;
+    /* Register the CPU notifier and allocate memory for the boot CPU */
+    register_cpu_notifier(&cpu_nfb);
+    rc = gicv3_lpi_allocate_pendtable(smp_processor_id());
+    if ( rc )
+        printk(XENLOG_ERR "Unable to allocate the pendtable for CPU%u\n",
+               smp_processor_id());
+
+    return rc;
 }
 
 static int find_unused_host_lpi(uint32_t start, uint32_t *index)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed May 18 09:33:09 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 18 May 2022 09:33:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.331796.555370 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrG3F-0003O6-6g; Wed, 18 May 2022 09:33:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 331796.555370; Wed, 18 May 2022 09: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 1nrG3F-0003Nz-3L; Wed, 18 May 2022 09:33:05 +0000
Received: by outflank-mailman (input) for mailman id 331796;
 Wed, 18 May 2022 09: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 1nrG3E-0003Nr-5F
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 09: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 1nrG3E-00019M-4O
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 09:33:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrG3E-0002mj-3O
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 09:33: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=5U0uHi5Pf4TUoYTHqpHuOMOxCLDX8zKYPGE2XDtJ85Q=; b=CfF+eCFgcfTQ7Ko+FvpG8VkkO4
	OjWsM9vgeX9KqKjWdlhgQhn25jIOmmy54TsLIQK5OQXyZETMQiUwin9Y00wpuJRnNCKBpmrGFoCXQ
	T4jX4dWLwOJvVT9DGiRojaIxYsSsYSUz1CUQveucI8NMeTtEwxNaNgiaPBnTBlAFo3r4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] build: suppress GNU ld warning about RWX load segments
Message-Id: <E1nrG3E-0002mj-3O@xenbits.xenproject.org>
Date: Wed, 18 May 2022 09:33:04 +0000

commit 68f5aac012b9ae36ce9b65d9ca9cc9f232191ad3
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Wed May 18 11:17:19 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 18 11:17:19 2022 +0200

    build: suppress GNU ld warning about RWX load segments
    
    We cannot really avoid such and we're also not really at risk because of
    them, as we control page table permissions ourselves rather than relying
    on a loader of some sort. Present GNU ld master started warning about
    such, and hence 2.39 is anticipated to have this warning.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/Makefile b/xen/Makefile
index 735d5f6e45..2ac6ec5adc 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -397,6 +397,8 @@ endif
 
 AFLAGS += -D__ASSEMBLY__
 
+LDFLAGS-$(call ld-option,--warn-rwx-segments) += --no-warn-rwx-segments
+
 CFLAGS += $(CFLAGS-y)
 # allow extra CFLAGS externally via EXTRA_CFLAGS_XEN_CORE
 CFLAGS += $(EXTRA_CFLAGS_XEN_CORE)
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed May 18 09:33:16 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 18 May 2022 09:33:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.331797.555374 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrG3Q-0003Q9-83; Wed, 18 May 2022 09:33:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 331797.555374; Wed, 18 May 2022 09:33: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 1nrG3Q-0003Q1-5G; Wed, 18 May 2022 09:33:16 +0000
Received: by outflank-mailman (input) for mailman id 331797;
 Wed, 18 May 2022 09: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 1nrG3O-0003Pr-82
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 09: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 1nrG3O-00019Y-7I
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 09:33:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrG3O-0002nU-6L
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 09: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=qKvoA25xoHtlTHqifEjZJU2uDAKZjq1dc7kVaFUnP48=; b=S5w3hImt8QdqMET4UlzXb0q55J
	1FNLXOnBkrA/e83R17PzjC0teBLzjWUzghJy+bEhKmgARni4mbjJyAOqspPNWBWMfQ3LNWLSw8eY5
	8SqLBmEjRO+8ISG8zG+T1Bu8WctRjKD1Wu9a3WuBpNZGGDCtfmKQfdrmtDMbYRQYeAfk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] build: silence GNU ld warning about executable stacks
Message-Id: <E1nrG3O-0002nU-6L@xenbits.xenproject.org>
Date: Wed, 18 May 2022 09:33:14 +0000

commit 62d22296a95d259c934ca2f39ac511d729cfbb68
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Wed May 18 11:18:45 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 18 11:18:45 2022 +0200

    build: silence GNU ld warning about executable stacks
    
    While for C files the compiler is supposed to arrange for emitting
    respective information, for assembly sources we're responsible ourselves.
    Present GNU ld master started warning about such, and hence 2.39 is
    anticipated to have this warning.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/Makefile b/xen/Makefile
index 2ac6ec5adc..30db57cc3c 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -397,6 +397,8 @@ endif
 
 AFLAGS += -D__ASSEMBLY__
 
+$(call cc-option-add,AFLAGS,CC,-Wa$(comma)--noexecstack)
+
 LDFLAGS-$(call ld-option,--warn-rwx-segments) += --no-warn-rwx-segments
 
 CFLAGS += $(CFLAGS-y)
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed May 18 09:33:26 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 18 May 2022 09:33:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.331798.555378 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrG3a-0003Ul-AF; Wed, 18 May 2022 09:33:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 331798.555378; Wed, 18 May 2022 09: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 1nrG3a-0003Ue-6n; Wed, 18 May 2022 09:33:26 +0000
Received: by outflank-mailman (input) for mailman id 331798;
 Wed, 18 May 2022 09: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 1nrG3Y-0003UC-Az
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 09: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 1nrG3Y-00019q-AE
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 09:33:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrG3Y-0002o9-9Q
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 09: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=Znc7wJHS512S6opt1JS2uAH2bnN3nFNAt+OEShlWoG8=; b=f1n7niZnKv9sYYPFH+3E834aA/
	sHGCzp7SuDPTQylc549OkJbcme2s6WKZdJFIDQrndzNsv9UFxcljEC0SdW21cPgRVcAUjW8RZKQLL
	g3zXeg3MzTXJq/Oh+XD0T8Kz5MKDo4l6330ptWFo0WsoVqQZxx6qN55ccX7EMSwG4aTk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] ns16550: add more device IDs for Intel LPSS UART
Message-Id: <E1nrG3Y-0002o9-9Q@xenbits.xenproject.org>
Date: Wed, 18 May 2022 09:33:24 +0000

commit 1f0b1f5cce9d5ff0ac1df8145847763b4bf8ef97
Author:     Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
AuthorDate: Wed May 18 11:19:25 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 18 11:19:25 2022 +0200

    ns16550: add more device IDs for Intel LPSS UART
    
    This is purely based on the spec:
    - Intel 500 Series PCH: 635218-006
    - Intel 600 Series PCH: 691222-001, 648364-003
    
    This is tested only on TGL-LP added initially, but according to the
    spec, they should behave the same.
    
    Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/drivers/char/ns16550.c | 80 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 79 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index fb75cee4a1..c133f1f466 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -1077,12 +1077,90 @@ static const struct ns16550_config __initconst uart_config[] =
         .dev_id = 0x0358,
         .param = param_exar_xr17v358
     },
-    /* Intel Corp. TGL-LP LPSS PCI */
+    /* Intel Corp. TGL-LP LPSS PCI UART #0 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0xa0a8,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. TGL-LP LPSS PCI UART #1 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0xa0a9,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. TGL-LP LPSS PCI UART #2 */
     {
         .vendor_id = PCI_VENDOR_ID_INTEL,
         .dev_id = 0xa0c7,
         .param = param_intel_lpss
     },
+    /* Intel Corp. TGL-H LPSS PCI UART #0 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x43a8,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. TGL-H LPSS PCI UART #1 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x43a9,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. TGL-H LPSS PCI UART #2 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x43a7,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-P LPSS PCI UART #0 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x51a8,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-P LPSS PCI UART #1 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x51a9,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-P LPSS PCI UART #2 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x51c7,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-P LPSS PCI UART #3 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x51da,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-S LPSS PCI UART #0 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x7aa8,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-S LPSS PCI UART #1 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x7aa9,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-S LPSS PCI UART #2 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x7afe,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-S LPSS PCI UART #3 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x7adc,
+        .param = param_intel_lpss
+    },
 };
 
 static int __init
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed May 18 09:33:36 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 18 May 2022 09:33:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.331799.555383 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrG3k-0003YB-EN; Wed, 18 May 2022 09:33:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 331799.555383; Wed, 18 May 2022 09: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 1nrG3k-0003Y1-AE; Wed, 18 May 2022 09:33:36 +0000
Received: by outflank-mailman (input) for mailman id 331799;
 Wed, 18 May 2022 09: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 1nrG3i-0003Xp-EA
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 09: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 1nrG3i-0001AH-DH
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 09:33:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrG3i-0002p9-CK
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 09: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=VVY7ZMgaFtatmIuivIRke0wfKETeIK4DLQBch8Kaf3c=; b=XCkx+8RWMGoYuxM27Kfe0mvc30
	aTQ0wZULE6/59x0hzUiQLOuBG5vyHkC63URp30Istod/i27Ckj62xgbenrw2LszPeHaypM/LhASne
	B+OLsUH6PxPfwHs3Y/mfux3xYt3PT6AVSH+BHs0lgt3/gcuWeH1XKgxJLGv1bMKejflE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/cpuid: expose MCDT_NO to guests
Message-Id: <E1nrG3i-0002p9-CK@xenbits.xenproject.org>
Date: Wed, 18 May 2022 09:33:34 +0000

commit ae49ee66cfda4ab6b8ef85cae5d59f8f020615c0
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Wed May 18 11:21:49 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 18 11:21:49 2022 +0200

    x86/cpuid: expose MCDT_NO to guests
    
    Expose the MCDT_NO CPUID flag to guests if available.  The bit signals
    that the CPU does not exhibit MCDT behavior, and as such can be
    exposed without requiring any additional work.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 tools/libs/light/libxl_cpuid.c              | 1 +
 tools/misc/xen-cpuid.c                      | 2 ++
 xen/include/public/arch-x86/cpufeatureset.h | 1 +
 3 files changed, 4 insertions(+)

diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c
index d462f9e421..67ba72dd84 100644
--- a/tools/libs/light/libxl_cpuid.c
+++ b/tools/libs/light/libxl_cpuid.c
@@ -235,6 +235,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str)
         {"fsrcs",        0x00000007,  1, CPUID_REG_EAX, 12,  1},
 
         {"intel-psfd",   0x00000007,  2, CPUID_REG_EDX,  0,  1},
+        {"mcdt-no",      0x00000007,  2, CPUID_REG_EDX,  5,  1},
 
         {"lahfsahf",     0x80000001, NA, CPUID_REG_ECX,  0,  1},
         {"cmplegacy",    0x80000001, NA, CPUID_REG_ECX,  1,  1},
diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
index 0b1b3333fe..a9e0fb5d17 100644
--- a/tools/misc/xen-cpuid.c
+++ b/tools/misc/xen-cpuid.c
@@ -203,6 +203,8 @@ static const char *const str_7b1[32] =
 static const char *const str_7d2[32] =
 {
     [ 0] = "intel-psfd",
+
+    /* 4 */                 [ 5] = "mcdt-no",
 };
 
 static const struct {
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index 9cee4b439e..0c27f5bbaf 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -304,6 +304,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(MCDT_NO,            13*32+ 5) /*A  MCDT_NO */
 
 #endif /* XEN_CPUFEATURE */
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed May 18 09:33:46 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 18 May 2022 09:33:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.331800.555386 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrG3u-0003ay-EU; Wed, 18 May 2022 09:33:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 331800.555386; Wed, 18 May 2022 09: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 1nrG3u-0003ar-Bl; Wed, 18 May 2022 09:33:46 +0000
Received: by outflank-mailman (input) for mailman id 331800;
 Wed, 18 May 2022 09: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 1nrG3s-0003aY-Gu
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 09: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 1nrG3s-0001AU-GG
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 09:33:44 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrG3s-0002pq-FI
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 09: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=VEnjXRiMp2YhVuDNCoUZQYXZ3Dip0EQVTxuXArhlBi4=; b=xSxXcMDbiGljUw87kXkaBx0Mja
	hILUMSYnQqrs/oU5o61LyOCfBpskZZDCATVEhMNZqpeZGEREZ6aJc8mbdu+fqmSjD/zyq7xiQKcpR
	CATsedQcSwIEwJ9MepbkkaKe0QbDkj8deokEpqG/orBhRq5ROSkdWt0fiMiDGNS+fBQI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/mwait-idle: add missing newline
Message-Id: <E1nrG3s-0002pq-FI@xenbits.xenproject.org>
Date: Wed, 18 May 2022 09:33:44 +0000

commit 25c160a74f4489f031ac79a24078cc12efd5c96b
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Wed May 18 11:22:24 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 18 11:22:24 2022 +0200

    x86/mwait-idle: add missing newline
    
    Fixes: 5a211704e8 ('mwait-idle: prevent SKL-H boot failure when C8+C9+C10 enabled')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/cpu/mwait-idle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/cpu/mwait-idle.c b/xen/arch/x86/cpu/mwait-idle.c
index 6add64dc5f..5d77672f6b 100644
--- a/xen/arch/x86/cpu/mwait-idle.c
+++ b/xen/arch/x86/cpu/mwait-idle.c
@@ -1363,7 +1363,7 @@ static int cf_check mwait_idle_cpu_init(
 		/* if state marked as disabled, skip it */
 		if (cpuidle_state_table[cstate].flags &
 		    CPUIDLE_FLAG_DISABLED) {
-			printk(XENLOG_DEBUG PREFIX "state %s is disabled",
+			printk(XENLOG_DEBUG PREFIX "state %s is disabled\n",
 			       cpuidle_state_table[cstate].name);
 			continue;
 		}
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed May 18 14:33:11 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 18 May 2022 14:33:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.332261.555923 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrKjZ-0002Yc-H9; Wed, 18 May 2022 14:33:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 332261.555923; Wed, 18 May 2022 14: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 1nrKjZ-0002YV-Dp; Wed, 18 May 2022 14:33:05 +0000
Received: by outflank-mailman (input) for mailman id 332261;
 Wed, 18 May 2022 14: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 1nrKjY-0002YN-PM
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 14: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 1nrKjY-0006Sf-Me
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 14:33:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrKjY-0006Hx-Ld
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 14:33: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=c69nuUjtlO+AnMADvBZfdoY2uZ+UF5eMsjSoj0EuKLY=; b=iZP9RFsit+it6xYRbP9lFFCzPx
	kN1STaTd/HhYmnwW1Cc7LwTt/G+wlBkoSN3nIhwkrHM7JQDhu9fJ1+8z6Lsxo4n9ymGNF63r2FcqC
	Dn1qRWnGjKzXDQOu4BA2v8+iufkyZhTlt7MUTjtU+8f/ktb96h5ylhHoqtaW1C7Ya1Ks=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/mm: Remove unnecessary mfn_valid() call from get_page_from_l1e()
Message-Id: <E1nrKjY-0006Hx-Ld@xenbits.xenproject.org>
Date: Wed, 18 May 2022 14:33:04 +0000

commit c154abe99d45fad110384e1ea75fad50b65962b3
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Apr 27 14:43:28 2022 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed May 18 15:05:18 2022 +0100

    x86/mm: Remove unnecessary mfn_valid() call from get_page_from_l1e()
    
    mfn_valid() is not a trivially simple, and contains an evaluate_nospec() for
    speculative defence.  Avoid calling it redundantly, and just store the result
    of the first call.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/mm.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 67c0427963..796faca641 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -887,7 +887,7 @@ get_page_from_l1e(
     uint32_t l1f = l1e_get_flags(l1e);
     struct vcpu *curr = current;
     struct domain *real_pg_owner;
-    bool write;
+    bool write, valid;
 
     if ( unlikely(!(l1f & _PAGE_PRESENT)) )
     {
@@ -902,13 +902,15 @@ get_page_from_l1e(
         return -EINVAL;
     }
 
-    if ( !mfn_valid(_mfn(mfn)) ||
+    valid = mfn_valid(_mfn(mfn));
+
+    if ( !valid ||
          (real_pg_owner = page_get_owner_and_reference(page)) == dom_io )
     {
         int flip = 0;
 
         /* Only needed the reference to confirm dom_io ownership. */
-        if ( mfn_valid(_mfn(mfn)) )
+        if ( valid )
             put_page(page);
 
         /* DOMID_IO reverts to caller for privilege checks. */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed May 18 14:33:15 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 18 May 2022 14:33:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.332264.555927 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrKjj-0002bS-Il; Wed, 18 May 2022 14:33:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 332264.555927; Wed, 18 May 2022 14: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 1nrKjj-0002bK-Fv; Wed, 18 May 2022 14:33:15 +0000
Received: by outflank-mailman (input) for mailman id 332264;
 Wed, 18 May 2022 14: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 1nrKji-0002b8-QQ
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 14: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 1nrKji-0006Su-Pb
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 14:33:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrKji-0006Ib-Oc
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 14: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=WvwpmlMNeG0JuWBqlbB739hKNwx3I4Ka5+wtgThabjI=; b=Ku29tr5yY8qz1PtihJ7sWYJe5g
	3Tzf8nKHxj+gkoq7QoWZDInPPp464KOXCDKK/YSKJA0rDByV5r6333wkqUI5qPRY3cFdjxMkXrW+S
	r130dqt29H0hyOg7vWzcMrrk1Z5vTAZgTwVtQz7I7HzemQMH0NAS2KxywBOj7hDzngdo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] cirrus-ci: add FreeBSD 14 task
Message-Id: <E1nrKji-0006Ib-Oc@xenbits.xenproject.org>
Date: Wed, 18 May 2022 14:33:14 +0000

commit 6f988321334b7c8c6f955154c729a172b729b06b
Author:     Roger Pau Monne <roger.pau@citrix.com>
AuthorDate: Wed Apr 27 17:50:23 2022 +0200
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed May 18 15:05:18 2022 +0100

    cirrus-ci: add FreeBSD 14 task
    
    Introduce a task that uses a FreeBSD 14 (HEAD) snapshot.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 .cirrus.yml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/.cirrus.yml b/.cirrus.yml
index 4ae719136e..c38333e736 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -24,3 +24,9 @@ task:
   freebsd_instance:
     image_family: freebsd-13-0
   << : *FREEBSD_TEMPLATE
+
+task:
+  name: 'FreeBSD 14'
+  freebsd_instance:
+    image_family: freebsd-14-0-snap
+  << : *FREEBSD_TEMPLATE
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed May 18 14:33:25 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 18 May 2022 14:33:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.332265.555931 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrKjt-0002gc-Ke; Wed, 18 May 2022 14:33:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 332265.555931; Wed, 18 May 2022 14: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 1nrKjt-0002gU-HR; Wed, 18 May 2022 14:33:25 +0000
Received: by outflank-mailman (input) for mailman id 332265;
 Wed, 18 May 2022 14: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 1nrKjs-0002gB-TW
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 14: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 1nrKjs-0006TB-Sl
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 14:33:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrKjs-0006J9-Ri
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 14: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=uYdg9IK0S6enI5mWzvGSO+XNZf5lZ2IPYgL6KORqS3g=; b=0Hhd9bqSEHbLZ/5ZgJC4HXtgIR
	zrypp3VgfmvnH8MVzKqnOokg8af/R7HvQA8Q8g2MLQP2oXXNIPcoovZ5kdfIzv7OHJ++qLi3jFBgV
	yzTGR/Pjn0I9zey7NHfJJYf4lg7lCNTTBcIL6uTDIqtyd02F5S324L/cqBfKkU3w3mWo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/cpupool: Reject attempts to add a domain to CPUPOOLID_NONE
Message-Id: <E1nrKjs-0006J9-Ri@xenbits.xenproject.org>
Date: Wed, 18 May 2022 14:33:24 +0000

commit 2fa561c5d3317bb4b0d6b476800ff9ac281aab3c
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue May 17 19:42:07 2022 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed May 18 15:05:18 2022 +0100

    xen/cpupool: Reject attempts to add a domain to CPUPOOLID_NONE
    
    c/s cfc52148444f ("xen/domain: Reduce the quantity of initialisation for
    system domains") removed the path in domain_create() which called
    sched_init_domain() with CPUPOOLID_NONE for system domains.
    
    Arguably, that changeset should have cleaned up this path too.
    
    However, c/s 92ea9c54fc81 ("arm/dom0less: assign dom0less guests to cpupools")
    changed domain_create() from using a hardcoded poolid of 0, to using a value
    passed by the toolstack.
    
    While CPUPOOLID_NONE is an internal constant, userspace can pass -1 for the
    cpupool_id parameter and attempt to construct a real domain using default ops,
    which at a minimum will fail the assertion in dom_scheduler().
    
    Fixes: 92ea9c54fc81 ("arm/dom0less: assign dom0less guests to cpupools")
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
    Tested-by: Luca Fancellu <luca.fancellu@arm.com>
---
 xen/common/sched/cpupool.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/xen/common/sched/cpupool.c b/xen/common/sched/cpupool.c
index f6e3d97e52..f1aa2db5f4 100644
--- a/xen/common/sched/cpupool.c
+++ b/xen/common/sched/cpupool.c
@@ -619,8 +619,6 @@ int cpupool_add_domain(struct domain *d, unsigned int poolid)
     int rc;
     int n_dom = 0;
 
-    if ( poolid == CPUPOOLID_NONE )
-        return 0;
     spin_lock(&cpupool_lock);
     c = cpupool_find_by_id(poolid);
     if ( c == NULL )
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed May 18 14:33:36 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 18 May 2022 14:33:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.332266.555935 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrKk4-0002k5-MU; Wed, 18 May 2022 14:33:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 332266.555935; Wed, 18 May 2022 14: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 1nrKk4-0002jx-JJ; Wed, 18 May 2022 14:33:36 +0000
Received: by outflank-mailman (input) for mailman id 332266;
 Wed, 18 May 2022 14:33: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 1nrKk3-0002jc-13
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 14:33: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 1nrKk3-0006Tc-0H
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 14:33:35 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrKk2-0006KB-VG
 for xen-changelog@lists.xenproject.org; Wed, 18 May 2022 14: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=bv/gPu7FrLHqVGuZcEra9kVR5aK0GgTPHGAsB/6rVw8=; b=d/gDC6mOUsRbZpLme7gfmNCtkw
	Bt4CUT76Megj461BChYnLdDD7Oav0ciotPdTtcdxlkUef8ScceyGIa1Z4P85ekI6QfL8vxxrPRXeD
	bPO2LQAQLhh27Z7l2oFuaZPgNvM5IsTAPPGRY70kOuAIAgE+oTc+c9nYPr3s5gO1IkfQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/ocaml: Fix stubs the introduction of domain_create.cpupool_id
Message-Id: <E1nrKk2-0006KB-VG@xenbits.xenproject.org>
Date: Wed, 18 May 2022 14:33:34 +0000

commit c8040aefe66edb9a9f9a54cc0541a77b4103c9f9
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue May 17 20:13:50 2022 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed May 18 15:05:18 2022 +0100

    tools/ocaml: Fix stubs the introduction of domain_create.cpupool_id
    
    Sadly, cpupool IDs are chosen by the caller, not assigned sequentially, so
    this does need to have a full 32 bits of range.
    
    Also leave a BUILD_BUG_ON() to catch more obvious ABI changes in the future.
    
    Fixes: 92ea9c54fc81 ("arm/dom0less: assign dom0less guests to cpupools")
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Christian Lindig <christian.lindig@citrix.com>
---
 tools/ocaml/libs/xc/xenctrl.ml      | 1 +
 tools/ocaml/libs/xc/xenctrl.mli     | 1 +
 tools/ocaml/libs/xc/xenctrl_stubs.c | 8 +++++++-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml
index 7503031d8f..8eab6f60eb 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;
+	cpupool_id: int32;
 	arch: arch_domainconfig;
 }
 
diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli
index d1d9c9247a..d3014a2708 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;
+  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 5b4fe72c8d..513ee142d2 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -189,7 +189,8 @@ CAMLprim value stub_xc_domain_create(value xch, value wanted_domid, value config
 #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_ARCH                Field(config, 9)
+#define VAL_CPUPOOL_ID          Field(config, 9)
+#define VAL_ARCH                Field(config, 10)
 
 	uint32_t domid = Int_val(wanted_domid);
 	int result;
@@ -201,6 +202,7 @@ CAMLprim value stub_xc_domain_create(value xch, value wanted_domid, value config
 		.max_maptrack_frames = Int_val(VAL_MAX_MAPTRACK_FRAMES),
 		.grant_opts =
 		    XEN_DOMCTL_GRANT_version(Int_val(VAL_MAX_GRANT_VERSION)),
+		.cpupool_id = Int32_val(VAL_CPUPOOL_ID),
 	};
 
 	domain_handle_of_uuid_string(cfg.handle, String_val(VAL_HANDLE));
@@ -225,6 +227,9 @@ CAMLprim value stub_xc_domain_create(value xch, value wanted_domid, value config
 	case 1: /* X86 - emulation flags in the block */
 #if defined(__i386__) || defined(__x86_64__)
 
+		/* Quick & dirty check for ABI changes. */
+		BUILD_BUG_ON(sizeof(cfg) != 64);
+
         /* Mnemonics for the named fields inside xen_x86_arch_domainconfig */
 #define VAL_EMUL_FLAGS          Field(arch_domconfig, 0)
 
@@ -254,6 +259,7 @@ CAMLprim value stub_xc_domain_create(value xch, value wanted_domid, value config
 	}
 
 #undef VAL_ARCH
+#undef VAL_CPUPOOL_ID
 #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#staging


From xen-changelog-bounces@lists.xenproject.org Thu May 19 00:22:10 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 19 May 2022 00:22:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.332542.556239 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrTvZ-0001a1-SJ; Thu, 19 May 2022 00:22:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 332542.556239; Thu, 19 May 2022 00: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 1nrTvZ-0001Zt-PB; Thu, 19 May 2022 00:22:05 +0000
Received: by outflank-mailman (input) for mailman id 332542;
 Thu, 19 May 2022 00: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 1nrTvY-0001ZU-V5
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 00: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 1nrTvY-0000kR-Ri
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 00:22:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrTvY-0000lO-Q2
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 00: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=k/lDiJ/HlM/AHIL1e9UXn7rR1Smzc/BUO863alDgUDo=; b=s3b05nGT88uReGwJiWwy7GnLZs
	a6bTaZXAAHIBM/PlKM8wDG9ZnCL3f2OtxHsJ/MsSczDkfLm6y6GToomBWRhzGMWHbS0qzDJVMYT94
	CMB+P8eT3IG6//u5wq7Z30iOlH+1qnKIGn6ZX7n4wkwxvVXGZkBVQXu4wd/F7CEJjZQ0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/libxc: change xc_memshr_fork_reset API to match hypervisor
Message-Id: <E1nrTvY-0000lO-Q2@xenbits.xenproject.org>
Date: Thu, 19 May 2022 00:22:04 +0000

commit b7d885695f91d4aa6fc498d27cfa1fefef53b2f2
Author:     Tamas K Lengyel <tamas.lengyel@intel.com>
AuthorDate: Tue Apr 26 14:25:54 2022 -0400
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed May 18 18:31:11 2022 +0100

    tools/libxc: change xc_memshr_fork_reset API to match hypervisor
    
    Need to separately specify if the reset is for the memory or for the VM state,
    or both.
    
    Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 tools/include/xenctrl.h     | 3 ++-
 tools/libs/ctrl/xc_memshr.c | 7 ++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index 95bd5eca67..1b089a2c02 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -2290,7 +2290,8 @@ int xc_memshr_fork(xc_interface *xch,
  *
  * With VMs that have a lot of memory this call may block for a long time.
  */
-int xc_memshr_fork_reset(xc_interface *xch, uint32_t forked_domain);
+int xc_memshr_fork_reset(xc_interface *xch, uint32_t forked_domain,
+                         bool reset_state, bool reset_memory);
 
 /* Debug calls: return the number of pages referencing the shared frame backing
  * the input argument. Should be one or greater.
diff --git a/tools/libs/ctrl/xc_memshr.c b/tools/libs/ctrl/xc_memshr.c
index a6cfd7dccf..a0d0b894e2 100644
--- a/tools/libs/ctrl/xc_memshr.c
+++ b/tools/libs/ctrl/xc_memshr.c
@@ -257,12 +257,17 @@ int xc_memshr_fork(xc_interface *xch, uint32_t pdomid, uint32_t domid,
     return xc_memshr_memop(xch, domid, &mso);
 }
 
-int xc_memshr_fork_reset(xc_interface *xch, uint32_t domid)
+int xc_memshr_fork_reset(xc_interface *xch, uint32_t domid, bool reset_state,
+                         bool reset_memory)
 {
     xen_mem_sharing_op_t mso;
 
     memset(&mso, 0, sizeof(mso));
     mso.op = XENMEM_sharing_op_fork_reset;
+    if ( reset_state )
+        mso.u.fork.flags |= XENMEM_FORK_RESET_STATE;
+    if ( reset_memory )
+        mso.u.fork.flags |= XENMEM_FORK_RESET_MEMORY;
 
     return xc_memshr_memop(xch, domid, &mso);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu May 19 00:22:15 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 19 May 2022 00:22:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.332543.556246 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrTvj-0001bv-Uw; Thu, 19 May 2022 00:22:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 332543.556246; Thu, 19 May 2022 00: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 1nrTvj-0001bl-R2; Thu, 19 May 2022 00:22:15 +0000
Received: by outflank-mailman (input) for mailman id 332543;
 Thu, 19 May 2022 00:22: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 1nrTvj-0001bc-08
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 00:22: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 1nrTvi-0000kV-VX
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 00:22:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrTvi-0000nR-UY
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 00: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=8PRocRrPXpShnOQO+QCxaG005CHmDpvLSYiQRXqyxMc=; b=N0MJ7yN8qEhq8MnzeZV0um3Blz
	GVW6oaRq3qaTezxUjQsszIEy79MNxMgGCBkh2DmMGRUXBHyq++iZKxKpuvZut83JISISOub9ycLKD
	M/16Wv4ldStdue89RMtlLlkcEysig3nuuCwsboVweKmqTif0YZlUvKZaO1+WxCieQCzw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/monitor: Add new monitor event to catch all vmexits
Message-Id: <E1nrTvi-0000nR-UY@xenbits.xenproject.org>
Date: Thu, 19 May 2022 00:22:14 +0000

commit 540645212a1485d5adfb75dc6f93c2af8f06de9d
Author:     Tamas K Lengyel <tamas.lengyel@intel.com>
AuthorDate: Fri Mar 11 20:43:55 2022 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed May 18 18:31:11 2022 +0100

    x86/monitor: Add new monitor event to catch all vmexits
    
    Add monitor event that hooks the vmexit handler allowing for both sync and
    async monitoring of events. With async monitoring an event is placed on the
    monitor ring for each exit and the rest of the vmexit handler resumes normally.
    If there are additional monitor events configured those will also place their
    respective events on the monitor ring.
    
    With the sync version an event is placed on the monitor ring but the handler
    does not get resumed, thus the sync version is only useful when the VM is not
    expected to resume normally after the vmexit. Our use-case is primarily with
    the sync version with VM forks where the fork gets reset after sync vmexit
    event, thus the rest of the vmexit handler can be safely skipped. This is
    very useful when we want to avoid Xen crashing the VM under any circumstance,
    for example during fuzzing. Collecting all vmexit information regardless of
    the root cause makes it easier to reason about the state of the VM on the
    monitor side, hence we opt to receive all events, even for external interrupt
    and NMI exits and let the monitor agent decide how to proceed.
    
    Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 tools/include/xenctrl.h                |  2 ++
 tools/libs/ctrl/xc_monitor.c           | 15 +++++++++++++++
 xen/arch/x86/hvm/monitor.c             | 18 ++++++++++++++++++
 xen/arch/x86/hvm/vmx/vmx.c             | 12 ++++++++++++
 xen/arch/x86/include/asm/domain.h      |  2 ++
 xen/arch/x86/include/asm/hvm/monitor.h |  2 ++
 xen/arch/x86/include/asm/monitor.h     |  3 ++-
 xen/arch/x86/monitor.c                 | 14 ++++++++++++++
 xen/include/public/domctl.h            |  6 ++++++
 xen/include/public/vm_event.h          | 12 ++++++++++++
 10 files changed, 85 insertions(+), 1 deletion(-)

diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index 1b089a2c02..159eaac050 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -2096,6 +2096,8 @@ int xc_monitor_privileged_call(xc_interface *xch, uint32_t domain_id,
                                bool enable);
 int xc_monitor_emul_unimplemented(xc_interface *xch, uint32_t domain_id,
                                   bool enable);
+int xc_monitor_vmexit(xc_interface *xch, uint32_t domain_id, bool enable,
+                      bool sync);
 /**
  * This function enables / disables emulation for each REP for a
  * REP-compatible instruction.
diff --git a/tools/libs/ctrl/xc_monitor.c b/tools/libs/ctrl/xc_monitor.c
index 4ac823e775..c5fa62ff30 100644
--- a/tools/libs/ctrl/xc_monitor.c
+++ b/tools/libs/ctrl/xc_monitor.c
@@ -246,6 +246,21 @@ int xc_monitor_emul_unimplemented(xc_interface *xch, uint32_t domain_id,
     return do_domctl(xch, &domctl);
 }
 
+int xc_monitor_vmexit(xc_interface *xch, uint32_t domain_id, bool enable,
+                      bool sync)
+{
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_monitor_op;
+    domctl.domain = domain_id;
+    domctl.u.monitor_op.op = enable ? XEN_DOMCTL_MONITOR_OP_ENABLE
+                                    : XEN_DOMCTL_MONITOR_OP_DISABLE;
+    domctl.u.monitor_op.event = XEN_DOMCTL_MONITOR_EVENT_VMEXIT;
+    domctl.u.monitor_op.u.vmexit.sync = sync;
+
+    return do_domctl(xch, &domctl);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/x86/hvm/monitor.c b/xen/arch/x86/hvm/monitor.c
index b44a1e1dfe..a11cd76f4d 100644
--- a/xen/arch/x86/hvm/monitor.c
+++ b/xen/arch/x86/hvm/monitor.c
@@ -328,6 +328,24 @@ bool hvm_monitor_check_p2m(unsigned long gla, gfn_t gfn, uint32_t pfec,
     return monitor_traps(curr, true, &req) >= 0;
 }
 
+int hvm_monitor_vmexit(unsigned long exit_reason,
+                       unsigned long exit_qualification)
+{
+    struct vcpu *curr = current;
+    struct arch_domain *ad = &curr->domain->arch;
+    vm_event_request_t req = {};
+
+    ASSERT(ad->monitor.vmexit_enabled);
+
+    req.reason = VM_EVENT_REASON_VMEXIT;
+    req.u.vmexit.arch.vmx.reason = exit_reason;
+    req.u.vmexit.arch.vmx.qualification = exit_qualification;
+
+    set_npt_base(curr, &req);
+
+    return monitor_traps(curr, ad->monitor.vmexit_sync, &req);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index d03e78bf0d..f08a00dcbb 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -4040,6 +4040,18 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
         }
     }
 
+    if ( unlikely(currd->arch.monitor.vmexit_enabled) )
+    {
+        int rc;
+
+        __vmread(EXIT_QUALIFICATION, &exit_qualification);
+        rc = hvm_monitor_vmexit(exit_reason, exit_qualification);
+        if ( rc < 0 )
+            goto exit_and_crash;
+        if ( rc )
+            return;
+    }
+
     /* XXX: This looks ugly, but we need a mechanism to ensure
      * any pending vmresume has really happened
      */
diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h
index 35898d725f..3aa0919fa6 100644
--- a/xen/arch/x86/include/asm/domain.h
+++ b/xen/arch/x86/include/asm/domain.h
@@ -430,6 +430,8 @@ struct arch_domain
          */
         unsigned int inguest_pagefault_disabled                            : 1;
         unsigned int control_register_values                               : 1;
+        unsigned int vmexit_enabled                                        : 1;
+        unsigned int vmexit_sync                                           : 1;
         struct monitor_msr_bitmap *msr_bitmap;
         uint64_t write_ctrlreg_mask[4];
     } monitor;
diff --git a/xen/arch/x86/include/asm/hvm/monitor.h b/xen/arch/x86/include/asm/hvm/monitor.h
index a75cd8545c..639f6dfa37 100644
--- a/xen/arch/x86/include/asm/hvm/monitor.h
+++ b/xen/arch/x86/include/asm/hvm/monitor.h
@@ -51,6 +51,8 @@ bool hvm_monitor_emul_unimplemented(void);
 
 bool hvm_monitor_check_p2m(unsigned long gla, gfn_t gfn, uint32_t pfec,
                            uint16_t kind);
+int hvm_monitor_vmexit(unsigned long exit_reason,
+                       unsigned long exit_qualification);
 
 #endif /* __ASM_X86_HVM_MONITOR_H__ */
 
diff --git a/xen/arch/x86/include/asm/monitor.h b/xen/arch/x86/include/asm/monitor.h
index 01c6d63bb9..d8d54c5f23 100644
--- a/xen/arch/x86/include/asm/monitor.h
+++ b/xen/arch/x86/include/asm/monitor.h
@@ -89,7 +89,8 @@ static inline uint32_t arch_monitor_get_capabilities(struct domain *d)
                     (1U << XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION) |
                     (1U << XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG) |
                     (1U << XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED) |
-                    (1U << XEN_DOMCTL_MONITOR_EVENT_INGUEST_PAGEFAULT));
+                    (1U << XEN_DOMCTL_MONITOR_EVENT_INGUEST_PAGEFAULT) |
+                    (1U << XEN_DOMCTL_MONITOR_EVENT_VMEXIT));
 
     if ( hvm_is_singlestep_supported() )
         capabilities |= (1U << XEN_DOMCTL_MONITOR_EVENT_SINGLESTEP);
diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c
index 3079726a8b..30ca71432c 100644
--- a/xen/arch/x86/monitor.c
+++ b/xen/arch/x86/monitor.c
@@ -332,6 +332,20 @@ int arch_monitor_domctl_event(struct domain *d,
         break;
     }
 
+    case XEN_DOMCTL_MONITOR_EVENT_VMEXIT:
+    {
+        bool old_status = ad->monitor.vmexit_enabled;
+
+        if ( unlikely(old_status == requested_status) )
+            return -EEXIST;
+
+        domain_pause(d);
+        ad->monitor.vmexit_enabled = requested_status;
+        ad->monitor.vmexit_sync = mop->u.vmexit.sync;
+        domain_unpause(d);
+        break;
+    }
+
     default:
         /*
          * Should not be reached unless arch_monitor_get_capabilities() is
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index 84e75829b9..b2ae839c36 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -1060,6 +1060,7 @@ struct xen_domctl_psr_cmt_op {
 #define XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED    10
 /* Enabled by default */
 #define XEN_DOMCTL_MONITOR_EVENT_INGUEST_PAGEFAULT     11
+#define XEN_DOMCTL_MONITOR_EVENT_VMEXIT                12
 
 struct xen_domctl_monitor_op {
     uint32_t op; /* XEN_DOMCTL_MONITOR_OP_* */
@@ -1110,6 +1111,11 @@ struct xen_domctl_monitor_op {
             /* Pause vCPU until response */
             uint8_t sync;
         } debug_exception;
+
+        struct {
+            /* Send event and don't process vmexit */
+            uint8_t sync;
+        } vmexit;
     } u;
 };
 
diff --git a/xen/include/public/vm_event.h b/xen/include/public/vm_event.h
index 1673bb8703..56b429a975 100644
--- a/xen/include/public/vm_event.h
+++ b/xen/include/public/vm_event.h
@@ -175,6 +175,8 @@
 #define VM_EVENT_REASON_DESCRIPTOR_ACCESS       13
 /* Current instruction is not implemented by the emulator */
 #define VM_EVENT_REASON_EMUL_UNIMPLEMENTED      14
+/* VMEXIT */
+#define VM_EVENT_REASON_VMEXIT                  15
 
 /* Supported values for the vm_event_write_ctrlreg index. */
 #define VM_EVENT_X86_CR0    0
@@ -394,6 +396,15 @@ struct vm_event_emul_insn_data {
     uint8_t data[16]; /* Has to be completely filled */
 };
 
+struct vm_event_vmexit {
+    struct {
+        struct {
+            uint64_t reason;
+            uint64_t qualification;
+        } vmx;
+    } arch;
+};
+
 typedef struct vm_event_st {
     uint32_t version;   /* VM_EVENT_INTERFACE_VERSION */
     uint32_t flags;     /* VM_EVENT_FLAG_* */
@@ -414,6 +425,7 @@ typedef struct vm_event_st {
         struct vm_event_debug                 software_breakpoint;
         struct vm_event_debug                 debug_exception;
         struct vm_event_cpuid                 cpuid;
+        struct vm_event_vmexit                vmexit;
         union {
             struct vm_event_interrupt_x86     x86;
         } interrupt;
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu May 19 00:55:11 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 19 May 2022 00:55:11 +0000
Received: from list by lists.xenproject.org with outflank-mailman.332544.556248 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrURV-0004Lq-Df; Thu, 19 May 2022 00:55:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 332544.556248; Thu, 19 May 2022 00: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 1nrURV-0004Lj-9f; Thu, 19 May 2022 00:55:05 +0000
Received: by outflank-mailman (input) for mailman id 332544;
 Thu, 19 May 2022 00: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 1nrURU-0004Ld-7s
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 00: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 1nrURU-0001G4-4a
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 00:55:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrURU-0002rc-3W
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 00: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=Ohs82CVQFZ0YJtdcKeRxqmuygD8A9Lg8fdbrUdJOWrs=; b=O1XDkmU4MbeOE/ThN3B6UhujOx
	M2hGolkZ4wbJCwfXMoyvVS08yBM/GPvw0IgFH4KDrMiez0JUMrlb3DFwxbAA6fYwn15LJjbREC5dX
	lVHYb1Wmlo5Ann+21dMot20y+6jIqa5keji92E8cWEyHB6Y9FvhwwJTpalf+zmBwldXs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/build: Add cppcheck and cppcheck-html make rules
Message-Id: <E1nrURU-0002rc-3W@xenbits.xenproject.org>
Date: Thu, 19 May 2022 00:55:04 +0000

commit 43aa3f6e72d340a85d3943b86350f6196a87289c
Author:     Bertrand Marquis <bertrand.marquis@arm.com>
AuthorDate: Tue Apr 26 13:38:41 2022 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Wed May 18 17:53:03 2022 -0700

    xen/build: Add cppcheck and cppcheck-html make rules
    
    cppcheck can be used to check Xen code quality.
    
    To create a report do "make cppcheck" on a built tree adding any options
    you added during the process you used to build xen (like CROSS_COMPILE
    or XEN_TARGET_ARCH). This will generate an xml report xen-cppcheck.xml.
    
    To create a html report do "make cppcheck-html" in the same way and a
    full report to be seen in a browser will be generated in
    cppcheck-htmlreport/index.html.
    
    For better results it is recommended to build your own cppcheck from the
    latest sources that you can find at [1].
    Development and result analysis has been done with cppcheck 2.7.
    
    The Makefile rule is searching for all C files which have been compiled
    (ie which have a generated .o file) and is running cppcheck on all of
    them using the current configuration of xen so only the code actually
    compiled is checked.
    
    A new tool is introduced to merge all cppcheck reports into one global
    report including all findings and removing duplicates.
    
    Some extra variables can be used to customize the report:
    - CPPCHECK can be used to give the full path to the cppcheck binary to
    use (default is to use the one from the standard path).
    - CPPCHECK_HTMLREPORT can be used to give the full path to
    cppcheck-htmlreport (default is to use the one from the standard path).
    
    This has been tested on several arm configurations (x86 should work but
    has not been tested).
    
    [1] https://cppcheck.sourceforge.io/
    
    Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
    Signed-off-by: Michal Orzel <michal.orzel@arm.com>
    [stefano: add in-code comment on commit]
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
    Tested-by: Stefano Stabellini <sstabellini@kernel.org>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 .gitignore                           |  3 ++
 xen/Makefile                         | 84 ++++++++++++++++++++++++++++++++++-
 xen/arch/arm/include/asm/processor.h |  6 +++
 xen/include/xen/config.h             |  4 ++
 xen/include/xen/kconfig.h            |  5 +++
 xen/tools/merge_cppcheck_reports.py  | 86 ++++++++++++++++++++++++++++++++++++
 6 files changed, 186 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index c6d2c4b4f1..18ef56a780 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@
 *.o
 *.d
 *.d2
+*.c.cppcheck
 *.opic
 *.a
 *.so
@@ -296,6 +297,7 @@ xen/.banner
 xen/.config
 xen/.config.old
 xen/.xen.elf32
+xen/xen-cppcheck.xml
 xen/System.map
 xen/arch/x86/boot/mkelf32
 xen/arch/x86/boot/cmdline.S
@@ -316,6 +318,7 @@ xen/arch/*/efi/runtime.c
 xen/arch/*/include/asm/asm-offsets.h
 xen/common/config_data.S
 xen/common/config.gz
+xen/cppcheck-htmlreport
 xen/include/headers*.chk
 xen/include/compat/*
 xen/include/config/
diff --git a/xen/Makefile b/xen/Makefile
index 30db57cc3c..15388703bc 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -453,7 +453,7 @@ endif # need-config
 
 __all: build
 
-main-targets := build install uninstall clean distclean MAP
+main-targets := build install uninstall clean distclean MAP cppcheck cppcheck-html
 .PHONY: $(main-targets)
 ifneq ($(XEN_TARGET_ARCH),x86_32)
 $(main-targets): %: _% ;
@@ -543,15 +543,17 @@ _clean:
 	$(Q)$(MAKE) $(clean)=tools/kconfig
 	find . \( -name "*.o" -o -name ".*.d" -o -name ".*.d2" \
 		-o -name ".*.o.tmp" -o -name "*~" -o -name "core" \
-		-o -name '*.lex.c' -o -name '*.tab.[ch]' \
+		-o -name '*.lex.c' -o -name '*.tab.[ch]' -o -name '*.c.cppcheck' \
 		-o -name "*.gcno" -o -name ".*.cmd" -o -name "lib.a" \) -exec rm -f {} \;
 	rm -f include/asm $(TARGET) $(TARGET).gz $(TARGET).efi $(TARGET).efi.map $(TARGET)-syms $(TARGET)-syms.map
 	rm -f asm-offsets.s arch/*/include/asm/asm-offsets.h
 	rm -f .banner .allconfig.tmp include/xen/compile.h
+	rm -f xen-cppcheck.xml
 
 .PHONY: _distclean
 _distclean: clean
 	rm -f tags TAGS cscope.files cscope.in.out cscope.out cscope.po.out GTAGS GPATH GRTAGS GSYMS .config source
+	rm -rf $(CPPCHECK_HTMLREPORT_OUTDIR)
 
 $(TARGET).gz: $(TARGET)
 	gzip -n -f -9 < $< > $@.new
@@ -625,6 +627,84 @@ cloc:
 	    done; \
 	done | cloc --list-file=-
 
+# What cppcheck command to use.
+# To get proper results, it is recommended to build cppcheck manually from the
+# latest source and use CPPCHECK to give the full path to the built version.
+CPPCHECK ?= cppcheck
+
+# What cppcheck-htmlreport to use.
+# If you give the full path to a self compiled cppcheck, this should be set
+# to the full path to cppcheck-html in the htmlreport directory of cppcheck.
+# On recent distribution, this is available in the standard path.
+CPPCHECK_HTMLREPORT ?= cppcheck-htmlreport
+
+# By default we generate the report in cppcheck-htmlreport directory in the
+# build directory. This can be changed by giving a directory in this variable.
+CPPCHECK_HTMLREPORT_OUTDIR ?= cppcheck-htmlreport
+
+# Compile flags to pass to cppcheck:
+# - include directories and defines Xen Makefile is passing (from CFLAGS)
+# - include config.h as this is passed directly to the compiler.
+# - define CPPCHECK as we use to disable or enable some specific part of the
+#   code to solve some cppcheck issues.
+# - explicitely enable some cppcheck checks as we do not want to use "all"
+#   which includes unusedFunction which gives wrong positives as we check file
+#   per file.
+#
+# Compiler defines are in compiler-def.h which is included in config.h
+#
+CPPCHECKFLAGS := -DCPPCHECK --max-ctu-depth=10 \
+                 --enable=style,information,missingInclude \
+                 --include=$(srctree)/include/xen/config.h \
+                 -I $(srctree)/xsm/flask/include \
+                 -I $(srctree)/include/xen/libfdt \
+                 $(filter -D% -I%,$(CFLAGS))
+
+# We need to find all C files (as we are not checking assembly files) so
+# we find all generated .o files which have a .c corresponding file.
+CPPCHECKFILES := $(wildcard $(patsubst $(objtree)/%.o,$(srctree)/%.c, \
+                 $(filter-out $(objtree)/tools/%, \
+                 $(shell find $(objtree) -name "*.o"))))
+
+quiet_cmd_cppcheck_xml = CPPCHECK $(patsubst $(srctree)/%,%,$<)
+cmd_cppcheck_xml = $(CPPCHECK) -v -q --xml $(CPPCHECKFLAGS) \
+                   --output-file=$@ $<
+
+quiet_cmd_merge_cppcheck_reports = CPPCHECK-MERGE $@
+cmd_merge_cppcheck_reports = $(srctree)/tools/merge_cppcheck_reports.py $^ $@
+
+quiet_cmd_cppcheck_html = CPPCHECK-HTML $<
+cmd_cppcheck_html = $(CPPCHECK_HTMLREPORT) --file=$< --source-dir=$(srctree) \
+                    --report-dir=$(CPPCHECK_HTMLREPORT_OUTDIR) --title=Xen
+
+PHONY += _cppcheck _cppcheck-html cppcheck-version
+
+_cppcheck-html: xen-cppcheck.xml
+	$(call if_changed,cppcheck_html)
+
+_cppcheck: xen-cppcheck.xml
+
+xen-cppcheck.xml: $(patsubst $(srctree)/%.c,$(objtree)/%.c.cppcheck,$(CPPCHECKFILES))
+ifeq ($(CPPCHECKFILES),)
+	$(error Please build Xen before running cppcheck)
+endif
+	$(call if_changed,merge_cppcheck_reports)
+
+$(objtree)/%.c.cppcheck: $(srctree)/%.c $(objtree)/include/generated/autoconf.h $(objtree)/include/generated/compiler-def.h | cppcheck-version
+	$(call if_changed,cppcheck_xml)
+
+cppcheck-version:
+ifeq ($(shell which $(CPPCHECK)),)
+	$(error Cannot find cppcheck executable: $(CPPCHECK))
+endif
+ifeq ($(shell $(CPPCHECK) --version | awk '{print ($$2 < 2.7)}'),1)
+	$(error Please upgrade your cppcheck to version 2.7 or greater)
+endif
+
+# Put this in generated headers this way it is cleaned by include/Makefile
+$(objtree)/include/generated/compiler-def.h:
+	$(Q)$(CC) -dM -E -o $@ - < /dev/null
+
 endif #config-build
 endif # need-sub-make
 
diff --git a/xen/arch/arm/include/asm/processor.h b/xen/arch/arm/include/asm/processor.h
index 7a1c4c4410..4188ec6bfb 100644
--- a/xen/arch/arm/include/asm/processor.h
+++ b/xen/arch/arm/include/asm/processor.h
@@ -219,9 +219,15 @@
                          SCTLR_Axx_ELx_A    | SCTLR_Axx_ELx_C   |\
                          SCTLR_Axx_ELx_WXN  | SCTLR_Axx_ELx_EE)
 
+/*
+ * Cppcheck preprocessor is wrongly throwing the error here so disable
+ * this check for cppcheck runs.
+ */
+#ifndef CPPCHECK
 #if (SCTLR_EL2_SET ^ SCTLR_EL2_CLEAR) != 0xffffffffffffffffUL
 #error "Inconsistent SCTLR_EL2 set/clear bits"
 #endif
+#endif
 
 #endif
 
diff --git a/xen/include/xen/config.h b/xen/include/xen/config.h
index 85c6f59be9..d888b2314d 100644
--- a/xen/include/xen/config.h
+++ b/xen/include/xen/config.h
@@ -7,6 +7,10 @@
 #ifndef __XEN_CONFIG_H__
 #define __XEN_CONFIG_H__
 
+#ifdef CPPCHECK
+#include <generated/compiler-def.h>
+#endif
+
 #include <xen/kconfig.h>
 
 #ifndef __ASSEMBLY__
diff --git a/xen/include/xen/kconfig.h b/xen/include/xen/kconfig.h
index 4d58c5bb3c..a717b0819c 100644
--- a/xen/include/xen/kconfig.h
+++ b/xen/include/xen/kconfig.h
@@ -8,6 +8,10 @@
  * these only work with boolean option.
  */
 
+/* cppcheck is failing to parse the macro so use a dummy one */
+#ifdef CPPCHECK
+#define IS_ENABLED(option) option
+#else
 /*
  * Getting something that works in C and CPP for an arg that may or may
  * not be defined is tricky.  Here, if we have "#define CONFIG_BOOGER 1"
@@ -27,5 +31,6 @@
  * otherwise.
  */
 #define IS_ENABLED(option) config_enabled(option)
+#endif
 
 #endif /* __XEN_KCONFIG_H */
diff --git a/xen/tools/merge_cppcheck_reports.py b/xen/tools/merge_cppcheck_reports.py
new file mode 100755
index 0000000000..1c1b63ba56
--- /dev/null
+++ b/xen/tools/merge_cppcheck_reports.py
@@ -0,0 +1,86 @@
+#!/usr/bin/env python
+
+"""
+This script acts as a tool to merge XML files created by cppcheck.
+Usage:
+    merge_cppcheck_reports.py [FILES] [OUTPUT]
+
+    FILES  - list of XML files with extension .cppcheck
+    OUTPUT - file to store results (with .xml extension).
+             If not specified, the script will print results to stdout.
+"""
+
+import sys
+from xml.etree import ElementTree
+
+def elements_equal(el1, el2):
+    if type(el1) != type(el2): return False
+
+    if el1.find('location') is None: return False
+    if el2.find('location') is None: return False
+
+    el1_location = str(el1.find('location').attrib)
+    el2_location = str(el2.find('location').attrib)
+
+    if el1_location != el2_location: return False
+
+    return True
+
+def contain_element(new, lst):
+    for elem in lst:
+        if elements_equal(new, elem):
+            return True
+    return False
+
+def merge(files):
+    try:
+        result_xml_root = ElementTree.parse(files[0]).getroot()
+    except:
+        print("Xml parsing error in %s\n" % (files[0]))
+        print("Please upgrade your cppcheck to version 2.7 or greater")
+        sys.exit(1)
+    insert_point = result_xml_root.findall("errors")[0]
+    curr = 1
+    total = len(files)
+    numelem = len(insert_point)
+    for xml_file in files[1:]:
+        try:
+            xml_root = ElementTree.parse(xml_file).getroot()
+        except:
+            print("Xml parsing error in %s\n" % (xml_file))
+            print("Please upgrade your cppcheck to version 2.7 or greater")
+            sys.exit(1)
+        curr_elem_list = list(insert_point)
+        new_elem_list = list(xml_root.findall("errors")[0])
+        for xml_error_elem in new_elem_list:
+            if not contain_element(xml_error_elem, curr_elem_list):
+                insert_point.insert(1,xml_error_elem)
+                numelem = numelem + 1
+        curr = curr + 1
+        sys.stdout.write('\r')
+        sys.stdout.write(" %d / %d" % (curr,total))
+        sys.stdout.flush()
+
+    sys.stdout.write('\r\n')
+    print("Done: %d elements" % (numelem))
+    return result_xml_root
+
+def run():
+    files = []
+    output = None
+    for i in sys.argv[1:]:
+        output = i if '.xml' in i else None
+        files.append(i) if '.cppcheck' in i else None
+
+    result = merge(files)
+
+    if result is None:
+        return
+
+    if output is not None:
+        ElementTree.ElementTree(result).write(output)
+    else:
+        print(ElementTree.tostring(result).decode('utf-8'))
+
+if __name__ == '__main__':
+    run()
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Thu May 19 06:33:07 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 19 May 2022 06:33:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.332722.556461 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrZiY-00030h-B1; Thu, 19 May 2022 06:33:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 332722.556461; Thu, 19 May 2022 06: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 1nrZiY-00030Z-6n; Thu, 19 May 2022 06:33:02 +0000
Received: by outflank-mailman (input) for mailman id 332722;
 Thu, 19 May 2022 06: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 1nrZiX-00030T-Mz
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 06: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 1nrZiX-0005nM-M7
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 06:33:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrZiX-0000pi-L1
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 06: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=FiIULDqivydys+k8kJwtWKaj071zPqNhVrEV1kKI4Xw=; b=fp0jm+W/OGw9wnmTeZGINuArbs
	X8m9bnwCKDNZkSjPMep1SYio2MdqQZHDsx2wejvxALzx1C0oA2CleDauh2e/4IlICw9jcSnh4cgju
	yhUazkS6oD6IX4StvBYxfv+t4ipbUuvdkerhnGb99yHXM5Us89FARimMxJb4/tPrEw+A=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] build: suppress GNU ld warning about RWX load segments
Message-Id: <E1nrZiX-0000pi-L1@xenbits.xenproject.org>
Date: Thu, 19 May 2022 06:33:01 +0000

commit 68f5aac012b9ae36ce9b65d9ca9cc9f232191ad3
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Wed May 18 11:17:19 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 18 11:17:19 2022 +0200

    build: suppress GNU ld warning about RWX load segments
    
    We cannot really avoid such and we're also not really at risk because of
    them, as we control page table permissions ourselves rather than relying
    on a loader of some sort. Present GNU ld master started warning about
    such, and hence 2.39 is anticipated to have this warning.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/Makefile b/xen/Makefile
index 735d5f6e45..2ac6ec5adc 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -397,6 +397,8 @@ endif
 
 AFLAGS += -D__ASSEMBLY__
 
+LDFLAGS-$(call ld-option,--warn-rwx-segments) += --no-warn-rwx-segments
+
 CFLAGS += $(CFLAGS-y)
 # allow extra CFLAGS externally via EXTRA_CFLAGS_XEN_CORE
 CFLAGS += $(EXTRA_CFLAGS_XEN_CORE)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 19 06:33:12 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 19 May 2022 06:33:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.332723.556465 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrZii-00032v-BS; Thu, 19 May 2022 06:33:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 332723.556465; Thu, 19 May 2022 06:33: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 1nrZii-00032n-8m; Thu, 19 May 2022 06:33:12 +0000
Received: by outflank-mailman (input) for mailman id 332723;
 Thu, 19 May 2022 06: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 1nrZih-00032f-Q3
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 06: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 1nrZih-0005nY-PE
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 06:33:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrZih-0000qJ-OA
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 06: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=ofaekqgK3+I6hzhJ7uv3vin1euRRwWr+L1eR6K9p8kM=; b=WPRo47/pTVjRHO+qtgFJPZINED
	wxuCesQBRf/r6v2jwaLAzoMj8kEBVct48aca/jyqYganj/ZN2dY6jy0E9x6H46Soz2kQAA5vmIJYw
	ndaDuqQpwLI6PI3d0RwrzoOBSs3PEqalr8ljAXP//voowsu6vU4U6X6dfddGNepYe9cM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] build: silence GNU ld warning about executable stacks
Message-Id: <E1nrZih-0000qJ-OA@xenbits.xenproject.org>
Date: Thu, 19 May 2022 06:33:11 +0000

commit 62d22296a95d259c934ca2f39ac511d729cfbb68
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Wed May 18 11:18:45 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 18 11:18:45 2022 +0200

    build: silence GNU ld warning about executable stacks
    
    While for C files the compiler is supposed to arrange for emitting
    respective information, for assembly sources we're responsible ourselves.
    Present GNU ld master started warning about such, and hence 2.39 is
    anticipated to have this warning.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/Makefile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/Makefile b/xen/Makefile
index 2ac6ec5adc..30db57cc3c 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -397,6 +397,8 @@ endif
 
 AFLAGS += -D__ASSEMBLY__
 
+$(call cc-option-add,AFLAGS,CC,-Wa$(comma)--noexecstack)
+
 LDFLAGS-$(call ld-option,--warn-rwx-segments) += --no-warn-rwx-segments
 
 CFLAGS += $(CFLAGS-y)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 19 06:33:23 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 19 May 2022 06:33:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.332724.556469 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrZit-00037k-DW; Thu, 19 May 2022 06:33:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 332724.556469; Thu, 19 May 2022 06: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 1nrZit-00037d-AR; Thu, 19 May 2022 06:33:23 +0000
Received: by outflank-mailman (input) for mailman id 332724;
 Thu, 19 May 2022 06:33: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 1nrZir-00037D-T3
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 06:33: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 1nrZir-0005no-SF
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 06:33:21 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrZir-0000r6-RI
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 06:33: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=ehHZvT+pQedy4qbuWC1mMU1LuRMjXFYKX6QOfiZIuh0=; b=F0UrPE7IwSS2mSacNXj5Dhqfr/
	w/cwIuB0AruwByZZmXh9QlJv7tzetqz4FlZgOAR9q5sALO0hFL3qM1msPtCaqzfgwSIXbv8RZ3i3N
	8wCO51P9v0tlrE2blh9C4qA9jHt1ukVVF0RIBNVWuYHhesG5Yy1C+5RY9R3mQg+l2t0c=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] ns16550: add more device IDs for Intel LPSS UART
Message-Id: <E1nrZir-0000r6-RI@xenbits.xenproject.org>
Date: Thu, 19 May 2022 06:33:21 +0000

commit 1f0b1f5cce9d5ff0ac1df8145847763b4bf8ef97
Author:     Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
AuthorDate: Wed May 18 11:19:25 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 18 11:19:25 2022 +0200

    ns16550: add more device IDs for Intel LPSS UART
    
    This is purely based on the spec:
    - Intel 500 Series PCH: 635218-006
    - Intel 600 Series PCH: 691222-001, 648364-003
    
    This is tested only on TGL-LP added initially, but according to the
    spec, they should behave the same.
    
    Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/drivers/char/ns16550.c | 80 +++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 79 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index fb75cee4a1..c133f1f466 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -1077,12 +1077,90 @@ static const struct ns16550_config __initconst uart_config[] =
         .dev_id = 0x0358,
         .param = param_exar_xr17v358
     },
-    /* Intel Corp. TGL-LP LPSS PCI */
+    /* Intel Corp. TGL-LP LPSS PCI UART #0 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0xa0a8,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. TGL-LP LPSS PCI UART #1 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0xa0a9,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. TGL-LP LPSS PCI UART #2 */
     {
         .vendor_id = PCI_VENDOR_ID_INTEL,
         .dev_id = 0xa0c7,
         .param = param_intel_lpss
     },
+    /* Intel Corp. TGL-H LPSS PCI UART #0 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x43a8,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. TGL-H LPSS PCI UART #1 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x43a9,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. TGL-H LPSS PCI UART #2 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x43a7,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-P LPSS PCI UART #0 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x51a8,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-P LPSS PCI UART #1 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x51a9,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-P LPSS PCI UART #2 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x51c7,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-P LPSS PCI UART #3 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x51da,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-S LPSS PCI UART #0 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x7aa8,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-S LPSS PCI UART #1 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x7aa9,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-S LPSS PCI UART #2 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x7afe,
+        .param = param_intel_lpss
+    },
+    /* Intel Corp. ADL-S LPSS PCI UART #3 */
+    {
+        .vendor_id = PCI_VENDOR_ID_INTEL,
+        .dev_id = 0x7adc,
+        .param = param_intel_lpss
+    },
 };
 
 static int __init
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 19 06:33:33 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 19 May 2022 06:33:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.332725.556473 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrZj3-0003Ac-El; Thu, 19 May 2022 06:33:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 332725.556473; Thu, 19 May 2022 06: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 1nrZj3-0003AU-C1; Thu, 19 May 2022 06:33:33 +0000
Received: by outflank-mailman (input) for mailman id 332725;
 Thu, 19 May 2022 06: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 1nrZj2-0003AL-0k
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 06: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 1nrZj1-0005ny-WC
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 06:33:31 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrZj1-0000ry-UW
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 06:33: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=ayJi6R93axEHTZ0I8eON/o3gob60lMjae02xV1xocCU=; b=rdiyjQP7Uxe6IQp+JKQpWAdkOf
	2HRu068+SnTkciUIz9s1QMuQoDcicdrm+aUfnL+4Vrl6ejY1duMDFHpUKxL8aMw32M7Ooqxkw3tGc
	7QJJDc6wv2dvYFr55HUs08enSqqSQGjsXpVCz4EsIRYMu5H5y1CQhC5lSmAQlZ2x6nf0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/cpuid: expose MCDT_NO to guests
Message-Id: <E1nrZj1-0000ry-UW@xenbits.xenproject.org>
Date: Thu, 19 May 2022 06:33:31 +0000

commit ae49ee66cfda4ab6b8ef85cae5d59f8f020615c0
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Wed May 18 11:21:49 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 18 11:21:49 2022 +0200

    x86/cpuid: expose MCDT_NO to guests
    
    Expose the MCDT_NO CPUID flag to guests if available.  The bit signals
    that the CPU does not exhibit MCDT behavior, and as such can be
    exposed without requiring any additional work.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 tools/libs/light/libxl_cpuid.c              | 1 +
 tools/misc/xen-cpuid.c                      | 2 ++
 xen/include/public/arch-x86/cpufeatureset.h | 1 +
 3 files changed, 4 insertions(+)

diff --git a/tools/libs/light/libxl_cpuid.c b/tools/libs/light/libxl_cpuid.c
index d462f9e421..67ba72dd84 100644
--- a/tools/libs/light/libxl_cpuid.c
+++ b/tools/libs/light/libxl_cpuid.c
@@ -235,6 +235,7 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str)
         {"fsrcs",        0x00000007,  1, CPUID_REG_EAX, 12,  1},
 
         {"intel-psfd",   0x00000007,  2, CPUID_REG_EDX,  0,  1},
+        {"mcdt-no",      0x00000007,  2, CPUID_REG_EDX,  5,  1},
 
         {"lahfsahf",     0x80000001, NA, CPUID_REG_ECX,  0,  1},
         {"cmplegacy",    0x80000001, NA, CPUID_REG_ECX,  1,  1},
diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
index 0b1b3333fe..a9e0fb5d17 100644
--- a/tools/misc/xen-cpuid.c
+++ b/tools/misc/xen-cpuid.c
@@ -203,6 +203,8 @@ static const char *const str_7b1[32] =
 static const char *const str_7d2[32] =
 {
     [ 0] = "intel-psfd",
+
+    /* 4 */                 [ 5] = "mcdt-no",
 };
 
 static const struct {
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index 9cee4b439e..0c27f5bbaf 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -304,6 +304,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(MCDT_NO,            13*32+ 5) /*A  MCDT_NO */
 
 #endif /* XEN_CPUFEATURE */
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 19 06:33:44 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 19 May 2022 06:33:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.332726.556477 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrZjD-0003EF-Hl; Thu, 19 May 2022 06:33:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 332726.556477; Thu, 19 May 2022 06:33: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 1nrZjD-0003E7-F4; Thu, 19 May 2022 06:33:43 +0000
Received: by outflank-mailman (input) for mailman id 332726;
 Thu, 19 May 2022 06:33: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 1nrZjC-0003Dq-6U
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 06:33: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 1nrZjC-0005oR-2u
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 06:33:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrZjC-0000tG-2A
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 06:33: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=WFHoCTLfyq+FNrfypIfsBRN+znwfoEk3pU52YXnmQZ8=; b=MmUWrBjPAHHEqgZ/46Et7nq32h
	XafHWL97V18aZyKqGAm3+SCkRDsXkF9bwTQ21e6YxInmYpe/Rv27SAQVDwV3jJoiaUY5sG60ZPSTF
	lvuNKsLpVLw6bzRQ3MzRx3vtxGcHHd/Ik1UIbaFFqP44gAtckS01Pe36YqJuIp8Cxj24=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/mwait-idle: add missing newline
Message-Id: <E1nrZjC-0000tG-2A@xenbits.xenproject.org>
Date: Thu, 19 May 2022 06:33:42 +0000

commit 25c160a74f4489f031ac79a24078cc12efd5c96b
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Wed May 18 11:22:24 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 18 11:22:24 2022 +0200

    x86/mwait-idle: add missing newline
    
    Fixes: 5a211704e8 ('mwait-idle: prevent SKL-H boot failure when C8+C9+C10 enabled')
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/cpu/mwait-idle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/cpu/mwait-idle.c b/xen/arch/x86/cpu/mwait-idle.c
index 6add64dc5f..5d77672f6b 100644
--- a/xen/arch/x86/cpu/mwait-idle.c
+++ b/xen/arch/x86/cpu/mwait-idle.c
@@ -1363,7 +1363,7 @@ static int cf_check mwait_idle_cpu_init(
 		/* if state marked as disabled, skip it */
 		if (cpuidle_state_table[cstate].flags &
 		    CPUIDLE_FLAG_DISABLED) {
-			printk(XENLOG_DEBUG PREFIX "state %s is disabled",
+			printk(XENLOG_DEBUG PREFIX "state %s is disabled\n",
 			       cpuidle_state_table[cstate].name);
 			continue;
 		}
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 19 19:44:08 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 19 May 2022 19:44:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333266.557055 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrm43-0004bQ-Hd; Thu, 19 May 2022 19:44:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333266.557055; Thu, 19 May 2022 19: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 1nrm43-0004bI-E4; Thu, 19 May 2022 19:44:03 +0000
Received: by outflank-mailman (input) for mailman id 333266;
 Thu, 19 May 2022 19: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 1nrm42-0004bA-Af
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19: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 1nrm42-0005Z0-9n
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19:44:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrm42-0006l1-8Y
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19: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=TMXqrNYikP6kyJPzDJgX9TVbjjH/XZZpTnNC7tnIx+I=; b=GMIx76J8b8a6nxBhXL6+fnYMGf
	9Ka8EruO6gWXRsT4KX6chkXLND5hycUXbPDip+fIgx5i7NWucft7muaMbTm+wrbME/6WGf4Hxikm+
	FDh6JBl+RgAy4k2fe2irtz6Ix6jSfL3HJbh29jWyxJGyj3fpRgA4rDoAjdnKZjGkTXmc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/mm: Remove unnecessary mfn_valid() call from get_page_from_l1e()
Message-Id: <E1nrm42-0006l1-8Y@xenbits.xenproject.org>
Date: Thu, 19 May 2022 19:44:02 +0000

commit c154abe99d45fad110384e1ea75fad50b65962b3
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Apr 27 14:43:28 2022 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed May 18 15:05:18 2022 +0100

    x86/mm: Remove unnecessary mfn_valid() call from get_page_from_l1e()
    
    mfn_valid() is not a trivially simple, and contains an evaluate_nospec() for
    speculative defence.  Avoid calling it redundantly, and just store the result
    of the first call.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/mm.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 67c0427963..796faca641 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -887,7 +887,7 @@ get_page_from_l1e(
     uint32_t l1f = l1e_get_flags(l1e);
     struct vcpu *curr = current;
     struct domain *real_pg_owner;
-    bool write;
+    bool write, valid;
 
     if ( unlikely(!(l1f & _PAGE_PRESENT)) )
     {
@@ -902,13 +902,15 @@ get_page_from_l1e(
         return -EINVAL;
     }
 
-    if ( !mfn_valid(_mfn(mfn)) ||
+    valid = mfn_valid(_mfn(mfn));
+
+    if ( !valid ||
          (real_pg_owner = page_get_owner_and_reference(page)) == dom_io )
     {
         int flip = 0;
 
         /* Only needed the reference to confirm dom_io ownership. */
-        if ( mfn_valid(_mfn(mfn)) )
+        if ( valid )
             put_page(page);
 
         /* DOMID_IO reverts to caller for privilege checks. */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 19 19:44:13 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 19 May 2022 19:44:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333267.557059 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrm4D-0004dl-JQ; Thu, 19 May 2022 19:44:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333267.557059; Thu, 19 May 2022 19: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 1nrm4D-0004dc-Fw; Thu, 19 May 2022 19:44:13 +0000
Received: by outflank-mailman (input) for mailman id 333267;
 Thu, 19 May 2022 19: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 1nrm4C-0004dU-DU
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19: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 1nrm4C-0005Z7-Co
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19:44:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrm4C-0006lc-Bp
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19: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=GAoppAVvlAfaX3sl6T2sBwDynHWwwfgbwz0l/+c1A2k=; b=rpa/jtD+9Xm7eVp/Lv9DIriN3l
	/fOYRB6WjyhFBCHg5hJeljW8OuYj5GR5019wgyG31e30gKyqSMkBNOd6I3jXuyejN/Mz6CI12phU4
	JtYFbs6aUuxfPhscUiMjfn/a4J/N4AvurxCm5lRaptAUqyBR5Wrmo1tNsqdAhoyAD/PQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] cirrus-ci: add FreeBSD 14 task
Message-Id: <E1nrm4C-0006lc-Bp@xenbits.xenproject.org>
Date: Thu, 19 May 2022 19:44:12 +0000

commit 6f988321334b7c8c6f955154c729a172b729b06b
Author:     Roger Pau Monne <roger.pau@citrix.com>
AuthorDate: Wed Apr 27 17:50:23 2022 +0200
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed May 18 15:05:18 2022 +0100

    cirrus-ci: add FreeBSD 14 task
    
    Introduce a task that uses a FreeBSD 14 (HEAD) snapshot.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 .cirrus.yml | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/.cirrus.yml b/.cirrus.yml
index 4ae719136e..c38333e736 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -24,3 +24,9 @@ task:
   freebsd_instance:
     image_family: freebsd-13-0
   << : *FREEBSD_TEMPLATE
+
+task:
+  name: 'FreeBSD 14'
+  freebsd_instance:
+    image_family: freebsd-14-0-snap
+  << : *FREEBSD_TEMPLATE
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 19 19:44:23 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 19 May 2022 19:44:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333268.557063 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrm4N-0004gu-L1; Thu, 19 May 2022 19:44:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333268.557063; Thu, 19 May 2022 19: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 1nrm4N-0004gm-I9; Thu, 19 May 2022 19:44:23 +0000
Received: by outflank-mailman (input) for mailman id 333268;
 Thu, 19 May 2022 19: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 1nrm4M-0004gb-GJ
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19: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 1nrm4M-0005ZM-Fc
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19:44:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrm4M-0006mL-Ew
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19: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=0vUqJKCvbO+JTxtx8vh2ukcAEvVFfN1mkCtqUB50C3U=; b=wLnYmM1I8CL7Jk5Ra6aIV/ECC3
	V0ya46kdCUQDykaRpRntH3uIV2lmNrNTzzWShtn3F/g9gP+io81ZW2e2GrhE5485AVhiS4FD78A5c
	39xGmRXmNZrUBz8rAUlD+GZ0RljPoh4mVCDNLuyOZq9cJHR/zF4f1PjWWF6YTbKTeas0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/cpupool: Reject attempts to add a domain to CPUPOOLID_NONE
Message-Id: <E1nrm4M-0006mL-Ew@xenbits.xenproject.org>
Date: Thu, 19 May 2022 19:44:22 +0000

commit 2fa561c5d3317bb4b0d6b476800ff9ac281aab3c
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue May 17 19:42:07 2022 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed May 18 15:05:18 2022 +0100

    xen/cpupool: Reject attempts to add a domain to CPUPOOLID_NONE
    
    c/s cfc52148444f ("xen/domain: Reduce the quantity of initialisation for
    system domains") removed the path in domain_create() which called
    sched_init_domain() with CPUPOOLID_NONE for system domains.
    
    Arguably, that changeset should have cleaned up this path too.
    
    However, c/s 92ea9c54fc81 ("arm/dom0less: assign dom0less guests to cpupools")
    changed domain_create() from using a hardcoded poolid of 0, to using a value
    passed by the toolstack.
    
    While CPUPOOLID_NONE is an internal constant, userspace can pass -1 for the
    cpupool_id parameter and attempt to construct a real domain using default ops,
    which at a minimum will fail the assertion in dom_scheduler().
    
    Fixes: 92ea9c54fc81 ("arm/dom0less: assign dom0less guests to cpupools")
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
    Tested-by: Luca Fancellu <luca.fancellu@arm.com>
---
 xen/common/sched/cpupool.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/xen/common/sched/cpupool.c b/xen/common/sched/cpupool.c
index f6e3d97e52..f1aa2db5f4 100644
--- a/xen/common/sched/cpupool.c
+++ b/xen/common/sched/cpupool.c
@@ -619,8 +619,6 @@ int cpupool_add_domain(struct domain *d, unsigned int poolid)
     int rc;
     int n_dom = 0;
 
-    if ( poolid == CPUPOOLID_NONE )
-        return 0;
     spin_lock(&cpupool_lock);
     c = cpupool_find_by_id(poolid);
     if ( c == NULL )
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 19 19:44:33 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 19 May 2022 19:44:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333269.557067 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrm4X-0004k4-Mg; Thu, 19 May 2022 19:44:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333269.557067; Thu, 19 May 2022 19: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 1nrm4X-0004jw-Jn; Thu, 19 May 2022 19:44:33 +0000
Received: by outflank-mailman (input) for mailman id 333269;
 Thu, 19 May 2022 19: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 1nrm4W-0004jh-JW
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19: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 1nrm4W-0005Zf-Il
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19:44:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrm4W-0006mw-Hl
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19: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=udU3HT8qDAWwn37F74H6vIq6P0ekk2IJdUO7+0qnUo0=; b=bJ3AeXtMRgUmieLLTMU+V76guj
	jF/uDCMWm+Sr8ZMv93KLEF+7pz1p0gVK3pNye/UIZ/S1lgxiOg1GEsjRJOyy9PjAmmJ9Uc4VHrCRY
	O4YkMhsnRRFEZsaRrJMkzppYuZUc7J+i7lvNlvV+vbejwjXznka4FnWeepPM4TQweAO0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/ocaml: Fix stubs the introduction of domain_create.cpupool_id
Message-Id: <E1nrm4W-0006mw-Hl@xenbits.xenproject.org>
Date: Thu, 19 May 2022 19:44:32 +0000

commit c8040aefe66edb9a9f9a54cc0541a77b4103c9f9
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue May 17 20:13:50 2022 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed May 18 15:05:18 2022 +0100

    tools/ocaml: Fix stubs the introduction of domain_create.cpupool_id
    
    Sadly, cpupool IDs are chosen by the caller, not assigned sequentially, so
    this does need to have a full 32 bits of range.
    
    Also leave a BUILD_BUG_ON() to catch more obvious ABI changes in the future.
    
    Fixes: 92ea9c54fc81 ("arm/dom0less: assign dom0less guests to cpupools")
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Christian Lindig <christian.lindig@citrix.com>
---
 tools/ocaml/libs/xc/xenctrl.ml      | 1 +
 tools/ocaml/libs/xc/xenctrl.mli     | 1 +
 tools/ocaml/libs/xc/xenctrl_stubs.c | 8 +++++++-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml
index 7503031d8f..8eab6f60eb 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;
+	cpupool_id: int32;
 	arch: arch_domainconfig;
 }
 
diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.mli
index d1d9c9247a..d3014a2708 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;
+  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 5b4fe72c8d..513ee142d2 100644
--- a/tools/ocaml/libs/xc/xenctrl_stubs.c
+++ b/tools/ocaml/libs/xc/xenctrl_stubs.c
@@ -189,7 +189,8 @@ CAMLprim value stub_xc_domain_create(value xch, value wanted_domid, value config
 #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_ARCH                Field(config, 9)
+#define VAL_CPUPOOL_ID          Field(config, 9)
+#define VAL_ARCH                Field(config, 10)
 
 	uint32_t domid = Int_val(wanted_domid);
 	int result;
@@ -201,6 +202,7 @@ CAMLprim value stub_xc_domain_create(value xch, value wanted_domid, value config
 		.max_maptrack_frames = Int_val(VAL_MAX_MAPTRACK_FRAMES),
 		.grant_opts =
 		    XEN_DOMCTL_GRANT_version(Int_val(VAL_MAX_GRANT_VERSION)),
+		.cpupool_id = Int32_val(VAL_CPUPOOL_ID),
 	};
 
 	domain_handle_of_uuid_string(cfg.handle, String_val(VAL_HANDLE));
@@ -225,6 +227,9 @@ CAMLprim value stub_xc_domain_create(value xch, value wanted_domid, value config
 	case 1: /* X86 - emulation flags in the block */
 #if defined(__i386__) || defined(__x86_64__)
 
+		/* Quick & dirty check for ABI changes. */
+		BUILD_BUG_ON(sizeof(cfg) != 64);
+
         /* Mnemonics for the named fields inside xen_x86_arch_domainconfig */
 #define VAL_EMUL_FLAGS          Field(arch_domconfig, 0)
 
@@ -254,6 +259,7 @@ CAMLprim value stub_xc_domain_create(value xch, value wanted_domid, value config
 	}
 
 #undef VAL_ARCH
+#undef VAL_CPUPOOL_ID
 #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 Thu May 19 19:44:43 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 19 May 2022 19:44:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333270.557071 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrm4h-0004md-OE; Thu, 19 May 2022 19:44:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333270.557071; Thu, 19 May 2022 19: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 1nrm4h-0004mW-LT; Thu, 19 May 2022 19:44:43 +0000
Received: by outflank-mailman (input) for mailman id 333270;
 Thu, 19 May 2022 19: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 1nrm4g-0004mM-MT
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19: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 1nrm4g-0005Zp-Lj
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19:44:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrm4g-0006nZ-Kr
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19: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=L29vxerDwGY+E6q5Rn66HQ+/bgma2DQLk6AwG8PjeGo=; b=ijMv5jGasQHQpW0/a/OqRKCQrx
	Y7fJqUQRiPuXbTnD1UoKJpskfID6/6mqU87P77erm4hMEENp2d22rcmrm7z1MH491ONlRG7QqEV5f
	DKC0xMTp+rpihGoOs4CqiXl0eOwLnhQTwEJ2NH8dVIy7K5Tq1Z8viIx0TtYe8MEo2/Q4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/libxc: change xc_memshr_fork_reset API to match hypervisor
Message-Id: <E1nrm4g-0006nZ-Kr@xenbits.xenproject.org>
Date: Thu, 19 May 2022 19:44:42 +0000

commit b7d885695f91d4aa6fc498d27cfa1fefef53b2f2
Author:     Tamas K Lengyel <tamas.lengyel@intel.com>
AuthorDate: Tue Apr 26 14:25:54 2022 -0400
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed May 18 18:31:11 2022 +0100

    tools/libxc: change xc_memshr_fork_reset API to match hypervisor
    
    Need to separately specify if the reset is for the memory or for the VM state,
    or both.
    
    Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 tools/include/xenctrl.h     | 3 ++-
 tools/libs/ctrl/xc_memshr.c | 7 ++++++-
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index 95bd5eca67..1b089a2c02 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -2290,7 +2290,8 @@ int xc_memshr_fork(xc_interface *xch,
  *
  * With VMs that have a lot of memory this call may block for a long time.
  */
-int xc_memshr_fork_reset(xc_interface *xch, uint32_t forked_domain);
+int xc_memshr_fork_reset(xc_interface *xch, uint32_t forked_domain,
+                         bool reset_state, bool reset_memory);
 
 /* Debug calls: return the number of pages referencing the shared frame backing
  * the input argument. Should be one or greater.
diff --git a/tools/libs/ctrl/xc_memshr.c b/tools/libs/ctrl/xc_memshr.c
index a6cfd7dccf..a0d0b894e2 100644
--- a/tools/libs/ctrl/xc_memshr.c
+++ b/tools/libs/ctrl/xc_memshr.c
@@ -257,12 +257,17 @@ int xc_memshr_fork(xc_interface *xch, uint32_t pdomid, uint32_t domid,
     return xc_memshr_memop(xch, domid, &mso);
 }
 
-int xc_memshr_fork_reset(xc_interface *xch, uint32_t domid)
+int xc_memshr_fork_reset(xc_interface *xch, uint32_t domid, bool reset_state,
+                         bool reset_memory)
 {
     xen_mem_sharing_op_t mso;
 
     memset(&mso, 0, sizeof(mso));
     mso.op = XENMEM_sharing_op_fork_reset;
+    if ( reset_state )
+        mso.u.fork.flags |= XENMEM_FORK_RESET_STATE;
+    if ( reset_memory )
+        mso.u.fork.flags |= XENMEM_FORK_RESET_MEMORY;
 
     return xc_memshr_memop(xch, domid, &mso);
 }
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 19 19:44:53 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 19 May 2022 19:44:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333271.557075 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrm4r-0004pc-Pn; Thu, 19 May 2022 19:44:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333271.557075; Thu, 19 May 2022 19: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 1nrm4r-0004pV-N8; Thu, 19 May 2022 19:44:53 +0000
Received: by outflank-mailman (input) for mailman id 333271;
 Thu, 19 May 2022 19: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 1nrm4q-0004pK-Q0
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19: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 1nrm4q-0005aF-PI
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19:44:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrm4q-0006oJ-OL
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19: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=mp1SZLq2i78y3rhH0/Dmz1I6gHLPoEIUUJ3SYJWtgT0=; b=P3BLycTHbNniLmNPT8PiSyG2ii
	6LHf1eW3PB5f8zqUmIXIqQ+86TOaywKeQVu+uTfW9lJT3nSEtOHx2hxbjmAw3I/PcbCuu5iPvg8l5
	BY226ueHUTKlF0bn4IiobK+UTtORz216QINML8gjMkPOE8o+yMWBk8RZRO+w/0fo0eY4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/monitor: Add new monitor event to catch all vmexits
Message-Id: <E1nrm4q-0006oJ-OL@xenbits.xenproject.org>
Date: Thu, 19 May 2022 19:44:52 +0000

commit 540645212a1485d5adfb75dc6f93c2af8f06de9d
Author:     Tamas K Lengyel <tamas.lengyel@intel.com>
AuthorDate: Fri Mar 11 20:43:55 2022 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Wed May 18 18:31:11 2022 +0100

    x86/monitor: Add new monitor event to catch all vmexits
    
    Add monitor event that hooks the vmexit handler allowing for both sync and
    async monitoring of events. With async monitoring an event is placed on the
    monitor ring for each exit and the rest of the vmexit handler resumes normally.
    If there are additional monitor events configured those will also place their
    respective events on the monitor ring.
    
    With the sync version an event is placed on the monitor ring but the handler
    does not get resumed, thus the sync version is only useful when the VM is not
    expected to resume normally after the vmexit. Our use-case is primarily with
    the sync version with VM forks where the fork gets reset after sync vmexit
    event, thus the rest of the vmexit handler can be safely skipped. This is
    very useful when we want to avoid Xen crashing the VM under any circumstance,
    for example during fuzzing. Collecting all vmexit information regardless of
    the root cause makes it easier to reason about the state of the VM on the
    monitor side, hence we opt to receive all events, even for external interrupt
    and NMI exits and let the monitor agent decide how to proceed.
    
    Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 tools/include/xenctrl.h                |  2 ++
 tools/libs/ctrl/xc_monitor.c           | 15 +++++++++++++++
 xen/arch/x86/hvm/monitor.c             | 18 ++++++++++++++++++
 xen/arch/x86/hvm/vmx/vmx.c             | 12 ++++++++++++
 xen/arch/x86/include/asm/domain.h      |  2 ++
 xen/arch/x86/include/asm/hvm/monitor.h |  2 ++
 xen/arch/x86/include/asm/monitor.h     |  3 ++-
 xen/arch/x86/monitor.c                 | 14 ++++++++++++++
 xen/include/public/domctl.h            |  6 ++++++
 xen/include/public/vm_event.h          | 12 ++++++++++++
 10 files changed, 85 insertions(+), 1 deletion(-)

diff --git a/tools/include/xenctrl.h b/tools/include/xenctrl.h
index 1b089a2c02..159eaac050 100644
--- a/tools/include/xenctrl.h
+++ b/tools/include/xenctrl.h
@@ -2096,6 +2096,8 @@ int xc_monitor_privileged_call(xc_interface *xch, uint32_t domain_id,
                                bool enable);
 int xc_monitor_emul_unimplemented(xc_interface *xch, uint32_t domain_id,
                                   bool enable);
+int xc_monitor_vmexit(xc_interface *xch, uint32_t domain_id, bool enable,
+                      bool sync);
 /**
  * This function enables / disables emulation for each REP for a
  * REP-compatible instruction.
diff --git a/tools/libs/ctrl/xc_monitor.c b/tools/libs/ctrl/xc_monitor.c
index 4ac823e775..c5fa62ff30 100644
--- a/tools/libs/ctrl/xc_monitor.c
+++ b/tools/libs/ctrl/xc_monitor.c
@@ -246,6 +246,21 @@ int xc_monitor_emul_unimplemented(xc_interface *xch, uint32_t domain_id,
     return do_domctl(xch, &domctl);
 }
 
+int xc_monitor_vmexit(xc_interface *xch, uint32_t domain_id, bool enable,
+                      bool sync)
+{
+    DECLARE_DOMCTL;
+
+    domctl.cmd = XEN_DOMCTL_monitor_op;
+    domctl.domain = domain_id;
+    domctl.u.monitor_op.op = enable ? XEN_DOMCTL_MONITOR_OP_ENABLE
+                                    : XEN_DOMCTL_MONITOR_OP_DISABLE;
+    domctl.u.monitor_op.event = XEN_DOMCTL_MONITOR_EVENT_VMEXIT;
+    domctl.u.monitor_op.u.vmexit.sync = sync;
+
+    return do_domctl(xch, &domctl);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/x86/hvm/monitor.c b/xen/arch/x86/hvm/monitor.c
index b44a1e1dfe..a11cd76f4d 100644
--- a/xen/arch/x86/hvm/monitor.c
+++ b/xen/arch/x86/hvm/monitor.c
@@ -328,6 +328,24 @@ bool hvm_monitor_check_p2m(unsigned long gla, gfn_t gfn, uint32_t pfec,
     return monitor_traps(curr, true, &req) >= 0;
 }
 
+int hvm_monitor_vmexit(unsigned long exit_reason,
+                       unsigned long exit_qualification)
+{
+    struct vcpu *curr = current;
+    struct arch_domain *ad = &curr->domain->arch;
+    vm_event_request_t req = {};
+
+    ASSERT(ad->monitor.vmexit_enabled);
+
+    req.reason = VM_EVENT_REASON_VMEXIT;
+    req.u.vmexit.arch.vmx.reason = exit_reason;
+    req.u.vmexit.arch.vmx.qualification = exit_qualification;
+
+    set_npt_base(curr, &req);
+
+    return monitor_traps(curr, ad->monitor.vmexit_sync, &req);
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index d03e78bf0d..f08a00dcbb 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -4040,6 +4040,18 @@ void vmx_vmexit_handler(struct cpu_user_regs *regs)
         }
     }
 
+    if ( unlikely(currd->arch.monitor.vmexit_enabled) )
+    {
+        int rc;
+
+        __vmread(EXIT_QUALIFICATION, &exit_qualification);
+        rc = hvm_monitor_vmexit(exit_reason, exit_qualification);
+        if ( rc < 0 )
+            goto exit_and_crash;
+        if ( rc )
+            return;
+    }
+
     /* XXX: This looks ugly, but we need a mechanism to ensure
      * any pending vmresume has really happened
      */
diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/domain.h
index 35898d725f..3aa0919fa6 100644
--- a/xen/arch/x86/include/asm/domain.h
+++ b/xen/arch/x86/include/asm/domain.h
@@ -430,6 +430,8 @@ struct arch_domain
          */
         unsigned int inguest_pagefault_disabled                            : 1;
         unsigned int control_register_values                               : 1;
+        unsigned int vmexit_enabled                                        : 1;
+        unsigned int vmexit_sync                                           : 1;
         struct monitor_msr_bitmap *msr_bitmap;
         uint64_t write_ctrlreg_mask[4];
     } monitor;
diff --git a/xen/arch/x86/include/asm/hvm/monitor.h b/xen/arch/x86/include/asm/hvm/monitor.h
index a75cd8545c..639f6dfa37 100644
--- a/xen/arch/x86/include/asm/hvm/monitor.h
+++ b/xen/arch/x86/include/asm/hvm/monitor.h
@@ -51,6 +51,8 @@ bool hvm_monitor_emul_unimplemented(void);
 
 bool hvm_monitor_check_p2m(unsigned long gla, gfn_t gfn, uint32_t pfec,
                            uint16_t kind);
+int hvm_monitor_vmexit(unsigned long exit_reason,
+                       unsigned long exit_qualification);
 
 #endif /* __ASM_X86_HVM_MONITOR_H__ */
 
diff --git a/xen/arch/x86/include/asm/monitor.h b/xen/arch/x86/include/asm/monitor.h
index 01c6d63bb9..d8d54c5f23 100644
--- a/xen/arch/x86/include/asm/monitor.h
+++ b/xen/arch/x86/include/asm/monitor.h
@@ -89,7 +89,8 @@ static inline uint32_t arch_monitor_get_capabilities(struct domain *d)
                     (1U << XEN_DOMCTL_MONITOR_EVENT_DEBUG_EXCEPTION) |
                     (1U << XEN_DOMCTL_MONITOR_EVENT_WRITE_CTRLREG) |
                     (1U << XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED) |
-                    (1U << XEN_DOMCTL_MONITOR_EVENT_INGUEST_PAGEFAULT));
+                    (1U << XEN_DOMCTL_MONITOR_EVENT_INGUEST_PAGEFAULT) |
+                    (1U << XEN_DOMCTL_MONITOR_EVENT_VMEXIT));
 
     if ( hvm_is_singlestep_supported() )
         capabilities |= (1U << XEN_DOMCTL_MONITOR_EVENT_SINGLESTEP);
diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c
index 3079726a8b..30ca71432c 100644
--- a/xen/arch/x86/monitor.c
+++ b/xen/arch/x86/monitor.c
@@ -332,6 +332,20 @@ int arch_monitor_domctl_event(struct domain *d,
         break;
     }
 
+    case XEN_DOMCTL_MONITOR_EVENT_VMEXIT:
+    {
+        bool old_status = ad->monitor.vmexit_enabled;
+
+        if ( unlikely(old_status == requested_status) )
+            return -EEXIST;
+
+        domain_pause(d);
+        ad->monitor.vmexit_enabled = requested_status;
+        ad->monitor.vmexit_sync = mop->u.vmexit.sync;
+        domain_unpause(d);
+        break;
+    }
+
     default:
         /*
          * Should not be reached unless arch_monitor_get_capabilities() is
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index 84e75829b9..b2ae839c36 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -1060,6 +1060,7 @@ struct xen_domctl_psr_cmt_op {
 #define XEN_DOMCTL_MONITOR_EVENT_EMUL_UNIMPLEMENTED    10
 /* Enabled by default */
 #define XEN_DOMCTL_MONITOR_EVENT_INGUEST_PAGEFAULT     11
+#define XEN_DOMCTL_MONITOR_EVENT_VMEXIT                12
 
 struct xen_domctl_monitor_op {
     uint32_t op; /* XEN_DOMCTL_MONITOR_OP_* */
@@ -1110,6 +1111,11 @@ struct xen_domctl_monitor_op {
             /* Pause vCPU until response */
             uint8_t sync;
         } debug_exception;
+
+        struct {
+            /* Send event and don't process vmexit */
+            uint8_t sync;
+        } vmexit;
     } u;
 };
 
diff --git a/xen/include/public/vm_event.h b/xen/include/public/vm_event.h
index 1673bb8703..56b429a975 100644
--- a/xen/include/public/vm_event.h
+++ b/xen/include/public/vm_event.h
@@ -175,6 +175,8 @@
 #define VM_EVENT_REASON_DESCRIPTOR_ACCESS       13
 /* Current instruction is not implemented by the emulator */
 #define VM_EVENT_REASON_EMUL_UNIMPLEMENTED      14
+/* VMEXIT */
+#define VM_EVENT_REASON_VMEXIT                  15
 
 /* Supported values for the vm_event_write_ctrlreg index. */
 #define VM_EVENT_X86_CR0    0
@@ -394,6 +396,15 @@ struct vm_event_emul_insn_data {
     uint8_t data[16]; /* Has to be completely filled */
 };
 
+struct vm_event_vmexit {
+    struct {
+        struct {
+            uint64_t reason;
+            uint64_t qualification;
+        } vmx;
+    } arch;
+};
+
 typedef struct vm_event_st {
     uint32_t version;   /* VM_EVENT_INTERFACE_VERSION */
     uint32_t flags;     /* VM_EVENT_FLAG_* */
@@ -414,6 +425,7 @@ typedef struct vm_event_st {
         struct vm_event_debug                 software_breakpoint;
         struct vm_event_debug                 debug_exception;
         struct vm_event_cpuid                 cpuid;
+        struct vm_event_vmexit                vmexit;
         union {
             struct vm_event_interrupt_x86     x86;
         } interrupt;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 19 19:45:03 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 19 May 2022 19:45:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333272.557079 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrm51-0004tA-Tc; Thu, 19 May 2022 19:45:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333272.557079; Thu, 19 May 2022 19: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 1nrm51-0004t3-QY; Thu, 19 May 2022 19:45:03 +0000
Received: by outflank-mailman (input) for mailman id 333272;
 Thu, 19 May 2022 19: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 1nrm50-0004su-TD
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19: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 1nrm50-0005ap-SN
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19:45:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrm50-0006pB-RX
 for xen-changelog@lists.xenproject.org; Thu, 19 May 2022 19: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=iP3BV43Ps9pI+e1ZFlxRDFR21iUkJzABitdZFX/dEi8=; b=YTL+kfHUOJL/q4/luBUcj58pAi
	OiTd93DphLs9F9OhNxoSOOKwUxKD79vcgb/I2qmtPP/nRS2PDPW5dM53V8UAs3egx01dUJDUfWTXC
	EVpLdntRJyf9FHpbhu63jTIeRIMYp+ySAd3QeelDK1cWWlYKFUIBsZOHyHo8v9ryEiQU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/build: Add cppcheck and cppcheck-html make rules
Message-Id: <E1nrm50-0006pB-RX@xenbits.xenproject.org>
Date: Thu, 19 May 2022 19:45:02 +0000

commit 43aa3f6e72d340a85d3943b86350f6196a87289c
Author:     Bertrand Marquis <bertrand.marquis@arm.com>
AuthorDate: Tue Apr 26 13:38:41 2022 +0100
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Wed May 18 17:53:03 2022 -0700

    xen/build: Add cppcheck and cppcheck-html make rules
    
    cppcheck can be used to check Xen code quality.
    
    To create a report do "make cppcheck" on a built tree adding any options
    you added during the process you used to build xen (like CROSS_COMPILE
    or XEN_TARGET_ARCH). This will generate an xml report xen-cppcheck.xml.
    
    To create a html report do "make cppcheck-html" in the same way and a
    full report to be seen in a browser will be generated in
    cppcheck-htmlreport/index.html.
    
    For better results it is recommended to build your own cppcheck from the
    latest sources that you can find at [1].
    Development and result analysis has been done with cppcheck 2.7.
    
    The Makefile rule is searching for all C files which have been compiled
    (ie which have a generated .o file) and is running cppcheck on all of
    them using the current configuration of xen so only the code actually
    compiled is checked.
    
    A new tool is introduced to merge all cppcheck reports into one global
    report including all findings and removing duplicates.
    
    Some extra variables can be used to customize the report:
    - CPPCHECK can be used to give the full path to the cppcheck binary to
    use (default is to use the one from the standard path).
    - CPPCHECK_HTMLREPORT can be used to give the full path to
    cppcheck-htmlreport (default is to use the one from the standard path).
    
    This has been tested on several arm configurations (x86 should work but
    has not been tested).
    
    [1] https://cppcheck.sourceforge.io/
    
    Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
    Signed-off-by: Michal Orzel <michal.orzel@arm.com>
    [stefano: add in-code comment on commit]
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
    Tested-by: Stefano Stabellini <sstabellini@kernel.org>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 .gitignore                           |  3 ++
 xen/Makefile                         | 84 ++++++++++++++++++++++++++++++++++-
 xen/arch/arm/include/asm/processor.h |  6 +++
 xen/include/xen/config.h             |  4 ++
 xen/include/xen/kconfig.h            |  5 +++
 xen/tools/merge_cppcheck_reports.py  | 86 ++++++++++++++++++++++++++++++++++++
 6 files changed, 186 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index c6d2c4b4f1..18ef56a780 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@
 *.o
 *.d
 *.d2
+*.c.cppcheck
 *.opic
 *.a
 *.so
@@ -296,6 +297,7 @@ xen/.banner
 xen/.config
 xen/.config.old
 xen/.xen.elf32
+xen/xen-cppcheck.xml
 xen/System.map
 xen/arch/x86/boot/mkelf32
 xen/arch/x86/boot/cmdline.S
@@ -316,6 +318,7 @@ xen/arch/*/efi/runtime.c
 xen/arch/*/include/asm/asm-offsets.h
 xen/common/config_data.S
 xen/common/config.gz
+xen/cppcheck-htmlreport
 xen/include/headers*.chk
 xen/include/compat/*
 xen/include/config/
diff --git a/xen/Makefile b/xen/Makefile
index 30db57cc3c..15388703bc 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -453,7 +453,7 @@ endif # need-config
 
 __all: build
 
-main-targets := build install uninstall clean distclean MAP
+main-targets := build install uninstall clean distclean MAP cppcheck cppcheck-html
 .PHONY: $(main-targets)
 ifneq ($(XEN_TARGET_ARCH),x86_32)
 $(main-targets): %: _% ;
@@ -543,15 +543,17 @@ _clean:
 	$(Q)$(MAKE) $(clean)=tools/kconfig
 	find . \( -name "*.o" -o -name ".*.d" -o -name ".*.d2" \
 		-o -name ".*.o.tmp" -o -name "*~" -o -name "core" \
-		-o -name '*.lex.c' -o -name '*.tab.[ch]' \
+		-o -name '*.lex.c' -o -name '*.tab.[ch]' -o -name '*.c.cppcheck' \
 		-o -name "*.gcno" -o -name ".*.cmd" -o -name "lib.a" \) -exec rm -f {} \;
 	rm -f include/asm $(TARGET) $(TARGET).gz $(TARGET).efi $(TARGET).efi.map $(TARGET)-syms $(TARGET)-syms.map
 	rm -f asm-offsets.s arch/*/include/asm/asm-offsets.h
 	rm -f .banner .allconfig.tmp include/xen/compile.h
+	rm -f xen-cppcheck.xml
 
 .PHONY: _distclean
 _distclean: clean
 	rm -f tags TAGS cscope.files cscope.in.out cscope.out cscope.po.out GTAGS GPATH GRTAGS GSYMS .config source
+	rm -rf $(CPPCHECK_HTMLREPORT_OUTDIR)
 
 $(TARGET).gz: $(TARGET)
 	gzip -n -f -9 < $< > $@.new
@@ -625,6 +627,84 @@ cloc:
 	    done; \
 	done | cloc --list-file=-
 
+# What cppcheck command to use.
+# To get proper results, it is recommended to build cppcheck manually from the
+# latest source and use CPPCHECK to give the full path to the built version.
+CPPCHECK ?= cppcheck
+
+# What cppcheck-htmlreport to use.
+# If you give the full path to a self compiled cppcheck, this should be set
+# to the full path to cppcheck-html in the htmlreport directory of cppcheck.
+# On recent distribution, this is available in the standard path.
+CPPCHECK_HTMLREPORT ?= cppcheck-htmlreport
+
+# By default we generate the report in cppcheck-htmlreport directory in the
+# build directory. This can be changed by giving a directory in this variable.
+CPPCHECK_HTMLREPORT_OUTDIR ?= cppcheck-htmlreport
+
+# Compile flags to pass to cppcheck:
+# - include directories and defines Xen Makefile is passing (from CFLAGS)
+# - include config.h as this is passed directly to the compiler.
+# - define CPPCHECK as we use to disable or enable some specific part of the
+#   code to solve some cppcheck issues.
+# - explicitely enable some cppcheck checks as we do not want to use "all"
+#   which includes unusedFunction which gives wrong positives as we check file
+#   per file.
+#
+# Compiler defines are in compiler-def.h which is included in config.h
+#
+CPPCHECKFLAGS := -DCPPCHECK --max-ctu-depth=10 \
+                 --enable=style,information,missingInclude \
+                 --include=$(srctree)/include/xen/config.h \
+                 -I $(srctree)/xsm/flask/include \
+                 -I $(srctree)/include/xen/libfdt \
+                 $(filter -D% -I%,$(CFLAGS))
+
+# We need to find all C files (as we are not checking assembly files) so
+# we find all generated .o files which have a .c corresponding file.
+CPPCHECKFILES := $(wildcard $(patsubst $(objtree)/%.o,$(srctree)/%.c, \
+                 $(filter-out $(objtree)/tools/%, \
+                 $(shell find $(objtree) -name "*.o"))))
+
+quiet_cmd_cppcheck_xml = CPPCHECK $(patsubst $(srctree)/%,%,$<)
+cmd_cppcheck_xml = $(CPPCHECK) -v -q --xml $(CPPCHECKFLAGS) \
+                   --output-file=$@ $<
+
+quiet_cmd_merge_cppcheck_reports = CPPCHECK-MERGE $@
+cmd_merge_cppcheck_reports = $(srctree)/tools/merge_cppcheck_reports.py $^ $@
+
+quiet_cmd_cppcheck_html = CPPCHECK-HTML $<
+cmd_cppcheck_html = $(CPPCHECK_HTMLREPORT) --file=$< --source-dir=$(srctree) \
+                    --report-dir=$(CPPCHECK_HTMLREPORT_OUTDIR) --title=Xen
+
+PHONY += _cppcheck _cppcheck-html cppcheck-version
+
+_cppcheck-html: xen-cppcheck.xml
+	$(call if_changed,cppcheck_html)
+
+_cppcheck: xen-cppcheck.xml
+
+xen-cppcheck.xml: $(patsubst $(srctree)/%.c,$(objtree)/%.c.cppcheck,$(CPPCHECKFILES))
+ifeq ($(CPPCHECKFILES),)
+	$(error Please build Xen before running cppcheck)
+endif
+	$(call if_changed,merge_cppcheck_reports)
+
+$(objtree)/%.c.cppcheck: $(srctree)/%.c $(objtree)/include/generated/autoconf.h $(objtree)/include/generated/compiler-def.h | cppcheck-version
+	$(call if_changed,cppcheck_xml)
+
+cppcheck-version:
+ifeq ($(shell which $(CPPCHECK)),)
+	$(error Cannot find cppcheck executable: $(CPPCHECK))
+endif
+ifeq ($(shell $(CPPCHECK) --version | awk '{print ($$2 < 2.7)}'),1)
+	$(error Please upgrade your cppcheck to version 2.7 or greater)
+endif
+
+# Put this in generated headers this way it is cleaned by include/Makefile
+$(objtree)/include/generated/compiler-def.h:
+	$(Q)$(CC) -dM -E -o $@ - < /dev/null
+
 endif #config-build
 endif # need-sub-make
 
diff --git a/xen/arch/arm/include/asm/processor.h b/xen/arch/arm/include/asm/processor.h
index 7a1c4c4410..4188ec6bfb 100644
--- a/xen/arch/arm/include/asm/processor.h
+++ b/xen/arch/arm/include/asm/processor.h
@@ -219,9 +219,15 @@
                          SCTLR_Axx_ELx_A    | SCTLR_Axx_ELx_C   |\
                          SCTLR_Axx_ELx_WXN  | SCTLR_Axx_ELx_EE)
 
+/*
+ * Cppcheck preprocessor is wrongly throwing the error here so disable
+ * this check for cppcheck runs.
+ */
+#ifndef CPPCHECK
 #if (SCTLR_EL2_SET ^ SCTLR_EL2_CLEAR) != 0xffffffffffffffffUL
 #error "Inconsistent SCTLR_EL2 set/clear bits"
 #endif
+#endif
 
 #endif
 
diff --git a/xen/include/xen/config.h b/xen/include/xen/config.h
index 85c6f59be9..d888b2314d 100644
--- a/xen/include/xen/config.h
+++ b/xen/include/xen/config.h
@@ -7,6 +7,10 @@
 #ifndef __XEN_CONFIG_H__
 #define __XEN_CONFIG_H__
 
+#ifdef CPPCHECK
+#include <generated/compiler-def.h>
+#endif
+
 #include <xen/kconfig.h>
 
 #ifndef __ASSEMBLY__
diff --git a/xen/include/xen/kconfig.h b/xen/include/xen/kconfig.h
index 4d58c5bb3c..a717b0819c 100644
--- a/xen/include/xen/kconfig.h
+++ b/xen/include/xen/kconfig.h
@@ -8,6 +8,10 @@
  * these only work with boolean option.
  */
 
+/* cppcheck is failing to parse the macro so use a dummy one */
+#ifdef CPPCHECK
+#define IS_ENABLED(option) option
+#else
 /*
  * Getting something that works in C and CPP for an arg that may or may
  * not be defined is tricky.  Here, if we have "#define CONFIG_BOOGER 1"
@@ -27,5 +31,6 @@
  * otherwise.
  */
 #define IS_ENABLED(option) config_enabled(option)
+#endif
 
 #endif /* __XEN_KCONFIG_H */
diff --git a/xen/tools/merge_cppcheck_reports.py b/xen/tools/merge_cppcheck_reports.py
new file mode 100755
index 0000000000..1c1b63ba56
--- /dev/null
+++ b/xen/tools/merge_cppcheck_reports.py
@@ -0,0 +1,86 @@
+#!/usr/bin/env python
+
+"""
+This script acts as a tool to merge XML files created by cppcheck.
+Usage:
+    merge_cppcheck_reports.py [FILES] [OUTPUT]
+
+    FILES  - list of XML files with extension .cppcheck
+    OUTPUT - file to store results (with .xml extension).
+             If not specified, the script will print results to stdout.
+"""
+
+import sys
+from xml.etree import ElementTree
+
+def elements_equal(el1, el2):
+    if type(el1) != type(el2): return False
+
+    if el1.find('location') is None: return False
+    if el2.find('location') is None: return False
+
+    el1_location = str(el1.find('location').attrib)
+    el2_location = str(el2.find('location').attrib)
+
+    if el1_location != el2_location: return False
+
+    return True
+
+def contain_element(new, lst):
+    for elem in lst:
+        if elements_equal(new, elem):
+            return True
+    return False
+
+def merge(files):
+    try:
+        result_xml_root = ElementTree.parse(files[0]).getroot()
+    except:
+        print("Xml parsing error in %s\n" % (files[0]))
+        print("Please upgrade your cppcheck to version 2.7 or greater")
+        sys.exit(1)
+    insert_point = result_xml_root.findall("errors")[0]
+    curr = 1
+    total = len(files)
+    numelem = len(insert_point)
+    for xml_file in files[1:]:
+        try:
+            xml_root = ElementTree.parse(xml_file).getroot()
+        except:
+            print("Xml parsing error in %s\n" % (xml_file))
+            print("Please upgrade your cppcheck to version 2.7 or greater")
+            sys.exit(1)
+        curr_elem_list = list(insert_point)
+        new_elem_list = list(xml_root.findall("errors")[0])
+        for xml_error_elem in new_elem_list:
+            if not contain_element(xml_error_elem, curr_elem_list):
+                insert_point.insert(1,xml_error_elem)
+                numelem = numelem + 1
+        curr = curr + 1
+        sys.stdout.write('\r')
+        sys.stdout.write(" %d / %d" % (curr,total))
+        sys.stdout.flush()
+
+    sys.stdout.write('\r\n')
+    print("Done: %d elements" % (numelem))
+    return result_xml_root
+
+def run():
+    files = []
+    output = None
+    for i in sys.argv[1:]:
+        output = i if '.xml' in i else None
+        files.append(i) if '.cppcheck' in i else None
+
+    result = merge(files)
+
+    if result is None:
+        return
+
+    if output is not None:
+        ElementTree.ElementTree(result).write(output)
+    else:
+        print(ElementTree.tostring(result).decode('utf-8'))
+
+if __name__ == '__main__':
+    run()
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri May 20 10:33:08 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 20 May 2022 10:33:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333710.557582 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrzwP-00025i-3t; Fri, 20 May 2022 10:33:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333710.557582; Fri, 20 May 2022 10: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 1nrzwO-00025Y-W3; Fri, 20 May 2022 10:33:04 +0000
Received: by outflank-mailman (input) for mailman id 333710;
 Fri, 20 May 2022 10: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 1nrzwO-00025D-ED
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10: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 1nrzwO-0003zI-DS
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:33:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrzwO-00036l-Bv
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:33: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=/pCzgcTv+L0GydfV40DzZ+SYS2sUa+R4n2NfhNNI9B8=; b=yyIljYHIJwYIDwlDpkUxdonmyD
	SONY+/8TLbCx0hHxWBnyQ19jdGUrD1i5PZuV4ulbTH9MericzMCGP8bCW3kVOsyi1ybFBS+4kblT4
	2039PvMZ1K4BxRDiLiFIwIb1KlLCL5qABUxVaisOEuNFso5Dpxw2CEQi4YlwFcC6vNJQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] VT-d: fix !HVM build
Message-Id: <E1nrzwO-00036l-Bv@xenbits.xenproject.org>
Date: Fri, 20 May 2022 10:33:04 +0000

commit c038304b46ffb3d3d314819d1331ca61e9ff668b
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 20 12:17:52 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:17:52 2022 +0200

    VT-d: fix !HVM build
    
    EPT is of no interest when !HVM. While I'm observing gcc11 to fully
    eliminate the function, older gcc's DCE looks to not be as good.
    CONFIG_UBSAN apparently also limits how aggressively dead code is
    eliminated. Aid the compiler in eliminating the accesses of
    opt_hap_{2mb,1gb}, which otherwise cause undefined symbol errors when
    linking.
    
    While there adjust types.
    
    Fixes: c479415610f0 ("x86/P2M: p2m.c is HVM-only")
    Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Kevin Tian <kevin.tian@intel.com>
---
 xen/drivers/passthrough/vtd/iommu.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index f22caf269d..4ceb20632f 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -2206,14 +2206,17 @@ static int cf_check intel_iommu_lookup_page(
     return 0;
 }
 
-static int __init vtd_ept_page_compatible(struct vtd_iommu *iommu)
+static bool __init vtd_ept_page_compatible(const struct vtd_iommu *iommu)
 {
-    u64 ept_cap, vtd_cap = iommu->cap;
+    uint64_t ept_cap, vtd_cap = iommu->cap;
+
+    if ( !IS_ENABLED(CONFIG_HVM) )
+        return false;
 
     /* EPT is not initialised yet, so we must check the capability in
      * the MSR explicitly rather than use cpu_has_vmx_ept_*() */
     if ( rdmsr_safe(MSR_IA32_VMX_EPT_VPID_CAP, ept_cap) != 0 ) 
-        return 0;
+        return false;
 
     return (ept_has_2mb(ept_cap) && opt_hap_2mb) <= cap_sps_2mb(vtd_cap) &&
            (ept_has_1gb(ept_cap) && opt_hap_1gb) <= cap_sps_1gb(vtd_cap);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri May 20 10:33:16 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 20 May 2022 10:33:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333713.557585 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrzwa-0002Gg-44; Fri, 20 May 2022 10:33:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333713.557585; Fri, 20 May 2022 10:33: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 1nrzwa-0002GY-1S; Fri, 20 May 2022 10:33:16 +0000
Received: by outflank-mailman (input) for mailman id 333713;
 Fri, 20 May 2022 10: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 1nrzwY-0002Eu-HY
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10: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 1nrzwY-0003zX-Gf
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:33:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrzwY-00037Q-Fd
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10: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=J6eR2zv8WcO2fHCv+LEncqtxsnRa3bOdhhlFGPEZcU4=; b=kYP45DgybNdSmGmXksJ1EJW52T
	STd73oKZrtPyZYglHjGOHGpxjQbQrLLBlzNq6lV2cLD/5xsTC56+PLCtdXrmddItqXswGGYMpRb9v
	+3eGNWCferXuNV1fR4YTX/0MVPC4M9tBQggpSRY59VReRogNlPBP/7eUjWbSflNZH5iM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/libs/light: update xenstore entry when setting max domain memory
Message-Id: <E1nrzwY-00037Q-Fd@xenbits.xenproject.org>
Date: Fri, 20 May 2022 10:33:14 +0000

commit 77bbea1bafe2d5155e6325bdd782c9f19f8a6aea
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri May 20 12:18:50 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:18:50 2022 +0200

    tools/libs/light: update xenstore entry when setting max domain memory
    
    libxl_domain_setmaxmem() called during "xl mem-max" should update the
    domain's memory/static-max Xenstore node, as otherwise "xl mem-set"
    won't be able to set the memory size to the new maximum.
    
    Adjust the related comments and documentation accordingly.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 docs/man/xl.1.pod.in         | 11 +++++------
 tools/libs/light/libxl_mem.c | 12 ++++++++++--
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/docs/man/xl.1.pod.in b/docs/man/xl.1.pod.in
index e2176bd696..101e14241d 100644
--- a/docs/man/xl.1.pod.in
+++ b/docs/man/xl.1.pod.in
@@ -442,15 +442,14 @@ allocate.
 The default unit is kiB.  Add 't' for TiB, 'g' for GiB, 'm' for
 MiB, 'k' for kiB, and 'b' for bytes (e.g., `2048m` for 2048 MiB).
 
-NB that users normally shouldn't need this command; B<xl mem-set> will
-set this as appropriate automatically.
-
 I<mem> can't be set lower than the current memory target for
 I<domain-id>.  It is allowed to be higher than the configured maximum
 memory size of the domain (B<maxmem> parameter in the domain's
-configuration). Note however that the initial B<maxmem> value is still
-used as an upper limit for B<xl mem-set>.  Also note that calling B<xl
-mem-set> will reset this value.
+configuration).
+
+Setting the maximum memory size above the configured maximum memory size
+will require special guest support (memory hotplug) in order to be usable
+by the guest.
 
 The domain will not receive any signal regarding the changed memory
 limit.
diff --git a/tools/libs/light/libxl_mem.c b/tools/libs/light/libxl_mem.c
index c739d00f39..92ec09f4cf 100644
--- a/tools/libs/light/libxl_mem.c
+++ b/tools/libs/light/libxl_mem.c
@@ -20,8 +20,7 @@
 /*
  * Set the maximum memory size of the domain in the hypervisor. There is no
  * change of the current memory size involved. The specified memory size can
- * even be above the configured maxmem size of the domain, but the related
- * Xenstore entry memory/static-max isn't modified!
+ * even be above the configured maxmem size of the domain.
  */
 int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint64_t max_memkb)
 {
@@ -82,6 +81,15 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint64_t max_memkb)
         goto out;
     }
 
+    rc = libxl__xs_printf(gc, XBT_NULL,
+                          GCSPRINTF("%s/memory/static-max", dompath),
+                          "%"PRIu64, max_memkb);
+    if (rc != 0) {
+        LOGED(ERROR, domid, "Couldn't set %s/memory/static-max, rc=%d\n",
+              dompath, rc);
+        goto out;
+    }
+
     rc = 0;
 out:
     libxl_domain_config_dispose(&d_config);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri May 20 10:33:26 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 20 May 2022 10:33:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333718.557589 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrzwk-0002M0-70; Fri, 20 May 2022 10:33:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333718.557589; Fri, 20 May 2022 10: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 1nrzwk-0002Ls-3B; Fri, 20 May 2022 10:33:26 +0000
Received: by outflank-mailman (input) for mailman id 333718;
 Fri, 20 May 2022 10: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 1nrzwi-0002LT-KR
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10: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 1nrzwi-0003zj-Je
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:33:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrzwi-000385-Ig
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10: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=j37Itbj3Yhdm6iwYA8grxrb/pqf4cDflywLZ0jPSGc0=; b=f9PJBvHBTsn7oSPbtu7bAV/uqv
	GF7nMnBLWI3KfFR4XTFC2B1bhpAnl0WGpqJSeM+NyT3nFNNGGdXX9JXCZHt3e+gNWpNbBS4TZ4vAZ
	TEOdetMhVFxSLhTmJ0NertNFYT4JMNinPPYfaxjHGiJyVLtOA4kngAI8B2py+rZ1hqAQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/cpupool: limit number of cpupools
Message-Id: <E1nrzwi-000385-Ig@xenbits.xenproject.org>
Date: Fri, 20 May 2022 10:33:24 +0000

commit 488a15a669e5b83267590ed8dad2428a5216ee87
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri May 20 12:19:06 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:19:06 2022 +0200

    xen/cpupool: limit number of cpupools
    
    Today the number of cpupools in a system is unlimited. This can lead to
    multiple problems (e.g. duplicate cpupool-id or scalability issues).
    
    Limit the number of cpupools to twice the number of maximum possible
    cpus, allowing to have one cpupool per physical cpu plus some spare
    cpupools for special means (there are already existing use cases for
    such spare cpupools).
    
    Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/common/sched/cpupool.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/xen/common/sched/cpupool.c b/xen/common/sched/cpupool.c
index f1aa2db5f4..a20e3a5fcb 100644
--- a/xen/common/sched/cpupool.c
+++ b/xen/common/sched/cpupool.c
@@ -30,6 +30,7 @@ struct cpupool *cpupool0;                /* Initial cpupool with Dom0 */
 cpumask_t cpupool_free_cpus;             /* cpus not in any cpupool */
 
 static LIST_HEAD(cpupool_list);          /* linked list, sorted by poolid */
+static unsigned int n_cpupools;
 
 static int cpupool_moving_cpu = -1;
 static struct cpupool *cpupool_cpu_moving = NULL;
@@ -276,6 +277,14 @@ static struct cpupool *cpupool_create(unsigned int poolid,
 
     spin_lock(&cpupool_lock);
 
+    /* Don't allow too many cpupools. */
+    if ( n_cpupools >= 2 * nr_cpu_ids )
+    {
+        ret = -ENOSPC;
+        goto unlock;
+    }
+    n_cpupools++;
+
     if ( poolid != CPUPOOLID_NONE )
     {
         q = __cpupool_find_by_id(poolid, false);
@@ -332,7 +341,9 @@ static struct cpupool *cpupool_create(unsigned int poolid,
 
  err:
     list_del(&c->list);
+    n_cpupools--;
 
+ unlock:
     spin_unlock(&cpupool_lock);
 
     free_cpupool_struct(c);
@@ -356,6 +367,7 @@ static int cpupool_destroy(struct cpupool *c)
         return -EBUSY;
     }
 
+    n_cpupools--;
     list_del(&c->list);
 
     spin_unlock(&cpupool_lock);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri May 20 10:33:36 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 20 May 2022 10:33:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333719.557593 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrzwu-0002RE-7o; Fri, 20 May 2022 10:33:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333719.557593; Fri, 20 May 2022 10: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 1nrzwu-0002R7-4q; Fri, 20 May 2022 10:33:36 +0000
Received: by outflank-mailman (input) for mailman id 333719;
 Fri, 20 May 2022 10: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 1nrzws-0002Qt-Ne
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10: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 1nrzws-0003zt-Mq
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:33:34 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrzws-00038x-Lu
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10: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=COsHK6Sl/oWwjkM1UdJAG0AB1uKAmuVhalh4mxKq82M=; b=L87aat10i6cuNLHu4gKE36Rfc8
	ExP9ubkRZHxy4kWDUauLYxuFnpF7Zych8g6rFLFyQ+elsVvvanyX5kKI3no+X5N+/+aIrs5qVN1zS
	Perpo6fyJuIylAR6BHfIMs1WrEd/RxV85w4PUF0iPljCG1R6pVkWPd/NDSpF8IJrtBLc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] ns16550: use poll mode if INTERRUPT_LINE is 0xff
Message-Id: <E1nrzws-00038x-Lu@xenbits.xenproject.org>
Date: Fri, 20 May 2022 10:33:34 +0000

commit 6a2ea1a2370a0c8a0210accac0ae62e68c185134
Author:     Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
AuthorDate: Fri May 20 12:19:45 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:19:45 2022 +0200

    ns16550: use poll mode if INTERRUPT_LINE is 0xff
    
    Intel LPSS has INTERRUPT_LINE set to 0xff by default, that is declared
    by the PCI Local Bus Specification Revision 3.0 (from 2004) as
    "unknown"/"no connection". Fallback to poll mode in this case.
    The 0xff handling is x86-specific, the surrounding code is guarded with
    CONFIG_X86 anyway.
    
    Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/char/ns16550.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index c133f1f466..cd3573e43d 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -1316,6 +1316,19 @@ pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx)
                             pci_conf_read8(PCI_SBDF(0, b, d, f),
                                            PCI_INTERRUPT_LINE) : 0;
 
+#ifdef CONFIG_X86
+                /*
+                 * PCI Local Bus Specification Revision 3.0 defines 0xff value
+                 * as special only for X86.
+                 */
+                if ( uart->irq == 0xff )
+                    uart->irq = 0;
+#endif
+                if ( !uart->irq )
+                    printk(XENLOG_INFO
+                           "ns16550: %pp: no legacy IRQ, using poll mode\n",
+                           &PCI_SBDF(0, b, d, f));
+
                 return 0;
             }
         }
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri May 20 10:33:46 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 20 May 2022 10:33:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333721.557597 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrzx4-0002VW-Ap; Fri, 20 May 2022 10:33:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333721.557597; Fri, 20 May 2022 10: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 1nrzx4-0002VO-7y; Fri, 20 May 2022 10:33:46 +0000
Received: by outflank-mailman (input) for mailman id 333721;
 Fri, 20 May 2022 10: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 1nrzx2-0002Uy-Qw
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10: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 1nrzx2-000400-QE
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:33:44 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrzx2-00039v-P6
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10: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=3E27qfN6vWctrz0Tcydo6czMVYMI+PrH36W+YDTtyqI=; b=5zRrppxoRDYXn5TC7X1KsfcgK0
	a9QOCex5bQC3ySm+wjVFzNmtoreKWtK0FTguFw5szFR/eYva9fDYzb9l4q7fWOgZTH1JPIA09HWqy
	Haoj3r/mSvSKcHMUb5GXZiC+MNJHRpNTyPDxWt00rMuHQrp3gp3yq9ziNBQBthRvyj1s=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] PCI: don't allow "pci-phantom=" to mark real devices as phantom functions
Message-Id: <E1nrzx2-00039v-P6@xenbits.xenproject.org>
Date: Fri, 20 May 2022 10:33:44 +0000

commit 444b555dc9e09fa3ce90f066e0c88dec9b47f422
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 20 12:20:35 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:20:35 2022 +0200

    PCI: don't allow "pci-phantom=" to mark real devices as phantom functions
    
    IOMMU code mapping / unmapping devices and interrupts will misbehave if
    a wrong command line option declared a function "phantom" when there's a
    real device at that position. Warn about this and adjust the specified
    stride (in the worst case ignoring the option altogether).
    
    Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/passthrough/pci.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index a8081576b3..938821e593 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -451,7 +451,24 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg, u8 bus, u8 devfn)
                          phantom_devs[i].slot == PCI_SLOT(devfn) &&
                          phantom_devs[i].stride > PCI_FUNC(devfn) )
                     {
-                        pdev->phantom_stride = phantom_devs[i].stride;
+                        pci_sbdf_t sbdf = pdev->sbdf;
+                        unsigned int stride = phantom_devs[i].stride;
+
+                        while ( (sbdf.fn += stride) > PCI_FUNC(devfn) )
+                        {
+                            if ( pci_conf_read16(sbdf, PCI_VENDOR_ID) == 0xffff &&
+                                 pci_conf_read16(sbdf, PCI_DEVICE_ID) == 0xffff )
+                                continue;
+                            stride <<= 1;
+                            printk(XENLOG_WARNING
+                                   "%pp looks to be a real device; bumping %04x:%02x:%02x stride to %u\n",
+                                   &sbdf, phantom_devs[i].seg,
+                                   phantom_devs[i].bus, phantom_devs[i].slot,
+                                   stride);
+                            sbdf = pdev->sbdf;
+                        }
+                        if ( PCI_FUNC(stride) )
+                           pdev->phantom_stride = stride;
                         break;
                     }
             }
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri May 20 10:33:56 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 20 May 2022 10:33:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333722.557600 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrzxE-0002YQ-CB; Fri, 20 May 2022 10:33:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333722.557600; Fri, 20 May 2022 10:33: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 1nrzxE-0002YJ-9Y; Fri, 20 May 2022 10:33:56 +0000
Received: by outflank-mailman (input) for mailman id 333722;
 Fri, 20 May 2022 10:33: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 1nrzxC-0002YA-Ty
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:33: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 1nrzxC-000404-TC
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:33:54 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrzxC-0003Ag-SL
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:33: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=oHw5BNAjk0UDyAePi9coUJyVIJU3BkjPtszE1fYHzlw=; b=ql+ZNK6esUHWmeQMnxKLIDdaEU
	kl4k6MjzBUyWoJSoOVu+hc3H79aeFmk6rlmPMbJJ+x+0KAN9+MNCRI/66W/hvaCN7T8NpD058ZQe6
	TcUCNi8rvySrb2sMtTQeGwnRAJosq+qGyn8ikFj1JSYPK4dXvEU5nuQRsJ1nnnEbKEss=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] AMD/IOMMU: correct potentially-UB shifts
Message-Id: <E1nrzxC-0003Ag-SL@xenbits.xenproject.org>
Date: Fri, 20 May 2022 10:33:54 +0000

commit d029b9cf13875823532ee6e4201421dba16c81d4
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 20 12:21:10 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:21:10 2022 +0200

    AMD/IOMMU: correct potentially-UB shifts
    
    Recent changes (likely 5fafa6cf529a ["AMD/IOMMU: have callers specify
    the target level for page table walks"]) have made Coverity notice a
    shift count in iommu_pde_from_dfn() which might in theory grow too
    large. While this isn't a problem in practice, address the concern
    nevertheless to not leave dangling breakage in case very large
    superpages would be enabled at some point.
    
    Coverity ID: 1504264
    
    While there also address a similar issue in set_iommu_ptes_present().
    It's not clear to me why Coverity hasn't spotted that one.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/passthrough/amd/iommu_map.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_map.c b/xen/drivers/passthrough/amd/iommu_map.c
index 4a33df8c5e..963dcc7a4f 100644
--- a/xen/drivers/passthrough/amd/iommu_map.c
+++ b/xen/drivers/passthrough/amd/iommu_map.c
@@ -89,11 +89,11 @@ static unsigned int set_iommu_ptes_present(unsigned long pt_mfn,
                                            bool iw, bool ir)
 {
     union amd_iommu_pte *table, *pde;
-    unsigned int page_sz, flush_flags = 0;
+    unsigned long page_sz = 1UL << (PTE_PER_TABLE_SHIFT * (pde_level - 1));
+    unsigned int flush_flags = 0;
 
     table = map_domain_page(_mfn(pt_mfn));
     pde = &table[pfn_to_pde_idx(dfn, pde_level)];
-    page_sz = 1U << (PTE_PER_TABLE_SHIFT * (pde_level - 1));
 
     if ( (void *)(pde + nr_ptes) > (void *)table + PAGE_SIZE )
     {
@@ -281,7 +281,7 @@ static int iommu_pde_from_dfn(struct domain *d, unsigned long dfn,
         {
             unsigned long mfn, pfn;
 
-            pfn =  dfn & ~((1 << (PTE_PER_TABLE_SHIFT * next_level)) - 1);
+            pfn = dfn & ~((1UL << (PTE_PER_TABLE_SHIFT * next_level)) - 1);
             mfn = next_table_mfn;
 
             /* allocate lower level page table */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri May 20 10:34:06 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 20 May 2022 10:34:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333725.557616 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrzxO-0002uz-NO; Fri, 20 May 2022 10:34:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333725.557616; Fri, 20 May 2022 10:34: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 1nrzxO-0002us-KH; Fri, 20 May 2022 10:34:06 +0000
Received: by outflank-mailman (input) for mailman id 333725;
 Fri, 20 May 2022 10:34: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 1nrzxN-0002tm-0h
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:34: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 1nrzxN-00040b-03
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:34:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrzxM-0003Bd-VE
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:34: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=tAeHBFDylvX5egdEeQC+tyCzX7U2jJQvElGOPH5F2XQ=; b=iAzGEyukrBZ7AY4sU9ZwImf/t4
	vvI4kPuPgo+sB0oNSO4xAyjRCLRrTlvFFeiQjCJ/JtrO13QBOUWB/hl+M1WNOiygb5BLCBlcWfPQ0
	FM6pt34M8J9Icj2y0Ibtn4oJb46JS854EsSLV4yl4t9pA96m3hKzFI4qerTvouYrnchY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] IOMMU: simplify unmap-on-error in iommu_map()
Message-Id: <E1nrzxM-0003Bd-VE@xenbits.xenproject.org>
Date: Fri, 20 May 2022 10:34:04 +0000

commit 09e4ac7bc071ad0549adcb24d82d8a3c4e72d05c
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 20 12:21:49 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:21:49 2022 +0200

    IOMMU: simplify unmap-on-error in iommu_map()
    
    As of 68a8aa5d7264 ("iommu: make map and unmap take a page count,
    similar to flush") there's no need anymore to have a loop here.
    
    Suggested-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/passthrough/iommu.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index 67ffe6635e..3762d0bd86 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -308,11 +308,9 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn,
                    d->domain_id, dfn_x(dfn_add(dfn, i)),
                    mfn_x(mfn_add(mfn, i)), rc);
 
-        while ( i-- )
-            /* if statement to satisfy __must_check */
-            if ( iommu_call(hd->platform_ops, unmap_page, d, dfn_add(dfn, i),
-                            flush_flags) )
-                continue;
+        /* while statement to satisfy __must_check */
+        while ( iommu_unmap(d, dfn, i, flush_flags) )
+            break;
 
         if ( !is_hardware_domain(d) )
             domain_crash(d);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri May 20 10:34:16 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 20 May 2022 10:34:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333732.557620 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrzxY-00036j-Ol; Fri, 20 May 2022 10:34:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333732.557620; Fri, 20 May 2022 10:34: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 1nrzxY-00036b-Lx; Fri, 20 May 2022 10:34:16 +0000
Received: by outflank-mailman (input) for mailman id 333732;
 Fri, 20 May 2022 10:34: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 1nrzxX-000367-4Z
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:34: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 1nrzxX-00040r-3o
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:34:15 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrzxX-0003Cn-2u
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:34: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=BPsJxP/rRxKG+FQ403NaQtOFMqFCgvPu1Q2Z6cEwn5E=; b=jfMidH/XNSWH/S1GsbMqfRuzef
	T2PiYIrMk2yhZJ7Msf99Cm57hFLV9cFZ7fue4vDq+n7dcQfMQZsxb7+SRiHXfSIKVIR6kZi7w4bFn
	PWK3/0nmx7Lpl7ZIFPeZEdVRJDDof+KMzwywJM0gjGNfau5+8ihnypT83nq2wVisfmRY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] IOMMU: add order parameter to ->{,un}map_page() hooks
Message-Id: <E1nrzxX-0003Cn-2u@xenbits.xenproject.org>
Date: Fri, 20 May 2022 10:34:15 +0000

commit e0de7c2ee63dc440b41c79c203707abde3a473dc
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 20 12:22:24 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:22:24 2022 +0200

    IOMMU: add order parameter to ->{,un}map_page() hooks
    
    Or really, in the case of ->map_page(), accommodate it in the existing
    "flags" parameter. All call sites will pass 0 for now.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Kevin Tian <kevin.tian@intel.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Julien Grall <jgrall@amazon.com> # Arm
---
 xen/arch/arm/include/asm/iommu.h            | 1 +
 xen/drivers/passthrough/amd/iommu.h         | 3 ++-
 xen/drivers/passthrough/amd/iommu_map.c     | 2 +-
 xen/drivers/passthrough/arm/iommu_helpers.c | 7 +++++--
 xen/drivers/passthrough/iommu.c             | 4 +++-
 xen/drivers/passthrough/vtd/iommu.c         | 4 ++--
 xen/include/xen/iommu.h                     | 6 ++++--
 7 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/xen/arch/arm/include/asm/iommu.h b/xen/arch/arm/include/asm/iommu.h
index 937edc8373..d57bd8a38c 100644
--- a/xen/arch/arm/include/asm/iommu.h
+++ b/xen/arch/arm/include/asm/iommu.h
@@ -31,6 +31,7 @@ int __must_check arm_iommu_map_page(struct domain *d, dfn_t dfn, mfn_t mfn,
                                     unsigned int flags,
                                     unsigned int *flush_flags);
 int __must_check arm_iommu_unmap_page(struct domain *d, dfn_t dfn,
+                                      unsigned int order,
                                       unsigned int *flush_flags);
 
 #endif /* __ARCH_ARM_IOMMU_H__ */
diff --git a/xen/drivers/passthrough/amd/iommu.h b/xen/drivers/passthrough/amd/iommu.h
index 64e4bbf33c..0a19d6a662 100644
--- a/xen/drivers/passthrough/amd/iommu.h
+++ b/xen/drivers/passthrough/amd/iommu.h
@@ -245,7 +245,8 @@ int __must_check cf_check amd_iommu_map_page(
     struct domain *d, dfn_t dfn, mfn_t mfn, unsigned int flags,
     unsigned int *flush_flags);
 int __must_check cf_check amd_iommu_unmap_page(
-    struct domain *d, dfn_t dfn, unsigned int *flush_flags);
+    struct domain *d, dfn_t dfn, unsigned int order,
+    unsigned int *flush_flags);
 int __must_check amd_iommu_alloc_root(struct domain *d);
 int amd_iommu_reserve_domain_unity_map(struct domain *domain,
                                        const struct ivrs_unity_map *map,
diff --git a/xen/drivers/passthrough/amd/iommu_map.c b/xen/drivers/passthrough/amd/iommu_map.c
index 963dcc7a4f..a63eec477a 100644
--- a/xen/drivers/passthrough/amd/iommu_map.c
+++ b/xen/drivers/passthrough/amd/iommu_map.c
@@ -395,7 +395,7 @@ int cf_check amd_iommu_map_page(
 }
 
 int cf_check amd_iommu_unmap_page(
-    struct domain *d, dfn_t dfn, unsigned int *flush_flags)
+    struct domain *d, dfn_t dfn, unsigned int order, unsigned int *flush_flags)
 {
     unsigned long pt_mfn = 0;
     struct domain_iommu *hd = dom_iommu(d);
diff --git a/xen/drivers/passthrough/arm/iommu_helpers.c b/xen/drivers/passthrough/arm/iommu_helpers.c
index a36e2b8e6c..5cb1987481 100644
--- a/xen/drivers/passthrough/arm/iommu_helpers.c
+++ b/xen/drivers/passthrough/arm/iommu_helpers.c
@@ -57,11 +57,13 @@ int __must_check arm_iommu_map_page(struct domain *d, dfn_t dfn, mfn_t mfn,
      * The function guest_physmap_add_entry replaces the current mapping
      * if there is already one...
      */
-    return guest_physmap_add_entry(d, _gfn(dfn_x(dfn)), _mfn(dfn_x(dfn)), 0, t);
+    return guest_physmap_add_entry(d, _gfn(dfn_x(dfn)), _mfn(dfn_x(dfn)),
+                                   IOMMUF_order(flags), t);
 }
 
 /* Should only be used if P2M Table is shared between the CPU and the IOMMU. */
 int __must_check arm_iommu_unmap_page(struct domain *d, dfn_t dfn,
+                                      unsigned int order,
                                       unsigned int *flush_flags)
 {
     /*
@@ -71,7 +73,8 @@ int __must_check arm_iommu_unmap_page(struct domain *d, dfn_t dfn,
     if ( !is_domain_direct_mapped(d) )
         return -EINVAL;
 
-    return guest_physmap_remove_page(d, _gfn(dfn_x(dfn)), _mfn(dfn_x(dfn)), 0);
+    return guest_physmap_remove_page(d, _gfn(dfn_x(dfn)), _mfn(dfn_x(dfn)),
+                                     order);
 }
 
 /*
diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index 3762d0bd86..5553e1f106 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -294,6 +294,8 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn,
     if ( !is_iommu_enabled(d) )
         return 0;
 
+    ASSERT(!IOMMUF_order(flags));
+
     for ( i = 0; i < page_count; i++ )
     {
         rc = iommu_call(hd->platform_ops, map_page, d, dfn_add(dfn, i),
@@ -354,7 +356,7 @@ int iommu_unmap(struct domain *d, dfn_t dfn, unsigned long page_count,
     for ( i = 0; i < page_count; i++ )
     {
         int err = iommu_call(hd->platform_ops, unmap_page, d, dfn_add(dfn, i),
-                             flush_flags);
+                             0, flush_flags);
 
         if ( likely(!err) )
             continue;
diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index 4ceb20632f..6d9513ef41 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -2163,7 +2163,7 @@ static int __must_check cf_check intel_iommu_map_page(
 }
 
 static int __must_check cf_check intel_iommu_unmap_page(
-    struct domain *d, dfn_t dfn, unsigned int *flush_flags)
+    struct domain *d, dfn_t dfn, unsigned int order, unsigned int *flush_flags)
 {
     /* Do nothing if VT-d shares EPT page table */
     if ( iommu_use_hap_pt(d) )
@@ -2173,7 +2173,7 @@ static int __must_check cf_check intel_iommu_unmap_page(
     if ( iommu_hwdom_passthrough && is_hardware_domain(d) )
         return 0;
 
-    return dma_pte_clear_one(d, dfn_to_daddr(dfn), 0, flush_flags);
+    return dma_pte_clear_one(d, dfn_to_daddr(dfn), order, flush_flags);
 }
 
 static int cf_check intel_iommu_lookup_page(
diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
index db72d9e644..e0f82712ed 100644
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -127,9 +127,10 @@ void arch_iommu_hwdom_init(struct domain *d);
  * The following flags are passed to map operations and passed by lookup
  * operations.
  */
-#define _IOMMUF_readable 0
+#define IOMMUF_order(n)  ((n) & 0x3f)
+#define _IOMMUF_readable 6
 #define IOMMUF_readable  (1u<<_IOMMUF_readable)
-#define _IOMMUF_writable 1
+#define _IOMMUF_writable 7
 #define IOMMUF_writable  (1u<<_IOMMUF_writable)
 
 /*
@@ -255,6 +256,7 @@ struct iommu_ops {
                                  unsigned int flags,
                                  unsigned int *flush_flags);
     int __must_check (*unmap_page)(struct domain *d, dfn_t dfn,
+                                   unsigned int order,
                                    unsigned int *flush_flags);
     int __must_check (*lookup_page)(struct domain *d, dfn_t dfn, mfn_t *mfn,
                                     unsigned int *flags);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri May 20 10:34:26 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 20 May 2022 10:34:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333734.557623 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrzxi-0003D4-QG; Fri, 20 May 2022 10:34:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333734.557623; Fri, 20 May 2022 10:34: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 1nrzxi-0003Cy-NX; Fri, 20 May 2022 10:34:26 +0000
Received: by outflank-mailman (input) for mailman id 333734;
 Fri, 20 May 2022 10:34: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 1nrzxh-0003Ch-84
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:34: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 1nrzxh-00040v-7N
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:34:25 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrzxh-0003Dm-5y
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:34: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=99Ti5437Je0t8QVgRkk2rjPsT4sctbbGQ/mR5L7zywk=; b=3AIt2gp1GeVKOsJqO4yRupQ6SH
	rGxkf6czVLgFA1JwgiuD8LcIFp9oyZGCK0+vZX8GeYMHo5jcaaGzWE7BTSrBFXhHiAadmvMihJ+dO
	68TVuv6HuW3jP6bht39GLcsIiICdYefPvTGD06B3tCx7ucXKpjtUfmJCxBy1NF7VKLXU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] IOMMU: have iommu_{,un}map() split requests into largest possible chunks
Message-Id: <E1nrzxh-0003Dm-5y@xenbits.xenproject.org>
Date: Fri, 20 May 2022 10:34:25 +0000

commit ba3fcb5f52eb2d3cc43b64bad2fc78507ad4fc7a
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 20 12:23:31 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:23:31 2022 +0200

    IOMMU: have iommu_{,un}map() split requests into largest possible chunks
    
    Introduce a helper function to determine the largest possible mapping
    that allows covering a request (or the next part of it that is left to
    be processed).
    
    In order to not add yet more recurring dfn_add() / mfn_add() to the two
    callers of the new helper, also introduce local variables holding the
    values presently operated on.
    
    Note that strictly speaking iommu_unmap() doen't need to consult
    mapping_order(), as unmapping doesn't require superpage support. This,
    however, prevents freeing of deep hierarchies of page tables in vendor
    code (once suitably enabled), which otherwise would require dealing with
    preemption needs.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/passthrough/iommu.c | 59 ++++++++++++++++++++++++++++++++---------
 1 file changed, 47 insertions(+), 12 deletions(-)

diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index 5553e1f106..9393d987c7 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -283,12 +283,38 @@ void iommu_domain_destroy(struct domain *d)
     arch_iommu_domain_destroy(d);
 }
 
-int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn,
+static unsigned int mapping_order(const struct domain_iommu *hd,
+                                  dfn_t dfn, mfn_t mfn, unsigned long nr)
+{
+    unsigned long res = dfn_x(dfn) | mfn_x(mfn);
+    unsigned long sizes = hd->platform_ops->page_sizes;
+    unsigned int bit = find_first_set_bit(sizes), order = 0;
+
+    ASSERT(bit == PAGE_SHIFT);
+
+    while ( (sizes = (sizes >> bit) & ~1) )
+    {
+        unsigned long mask;
+
+        bit = find_first_set_bit(sizes);
+        mask = (1UL << bit) - 1;
+        if ( nr <= mask || (res & mask) )
+            break;
+        order += bit;
+        nr >>= bit;
+        res >>= bit;
+    }
+
+    return order;
+}
+
+int iommu_map(struct domain *d, dfn_t dfn0, mfn_t mfn0,
               unsigned long page_count, unsigned int flags,
               unsigned int *flush_flags)
 {
     const struct domain_iommu *hd = dom_iommu(d);
     unsigned long i;
+    unsigned int order;
     int rc = 0;
 
     if ( !is_iommu_enabled(d) )
@@ -296,10 +322,15 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn,
 
     ASSERT(!IOMMUF_order(flags));
 
-    for ( i = 0; i < page_count; i++ )
+    for ( i = 0; i < page_count; i += 1UL << order )
     {
-        rc = iommu_call(hd->platform_ops, map_page, d, dfn_add(dfn, i),
-                        mfn_add(mfn, i), flags, flush_flags);
+        dfn_t dfn = dfn_add(dfn0, i);
+        mfn_t mfn = mfn_add(mfn0, i);
+
+        order = mapping_order(hd, dfn, mfn, page_count - i);
+
+        rc = iommu_call(hd->platform_ops, map_page, d, dfn, mfn,
+                        flags | IOMMUF_order(order), flush_flags);
 
         if ( likely(!rc) )
             continue;
@@ -307,11 +338,10 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn,
         if ( !d->is_shutting_down && printk_ratelimit() )
             printk(XENLOG_ERR
                    "d%d: IOMMU mapping dfn %"PRI_dfn" to mfn %"PRI_mfn" failed: %d\n",
-                   d->domain_id, dfn_x(dfn_add(dfn, i)),
-                   mfn_x(mfn_add(mfn, i)), rc);
+                   d->domain_id, dfn_x(dfn), mfn_x(mfn), rc);
 
         /* while statement to satisfy __must_check */
-        while ( iommu_unmap(d, dfn, i, flush_flags) )
+        while ( iommu_unmap(d, dfn0, i, flush_flags) )
             break;
 
         if ( !is_hardware_domain(d) )
@@ -343,20 +373,25 @@ int iommu_legacy_map(struct domain *d, dfn_t dfn, mfn_t mfn,
     return rc;
 }
 
-int iommu_unmap(struct domain *d, dfn_t dfn, unsigned long page_count,
+int iommu_unmap(struct domain *d, dfn_t dfn0, unsigned long page_count,
                 unsigned int *flush_flags)
 {
     const struct domain_iommu *hd = dom_iommu(d);
     unsigned long i;
+    unsigned int order;
     int rc = 0;
 
     if ( !is_iommu_enabled(d) )
         return 0;
 
-    for ( i = 0; i < page_count; i++ )
+    for ( i = 0; i < page_count; i += 1UL << order )
     {
-        int err = iommu_call(hd->platform_ops, unmap_page, d, dfn_add(dfn, i),
-                             0, flush_flags);
+        dfn_t dfn = dfn_add(dfn0, i);
+        int err;
+
+        order = mapping_order(hd, dfn, _mfn(0), page_count - i);
+        err = iommu_call(hd->platform_ops, unmap_page, d, dfn,
+                         order, flush_flags);
 
         if ( likely(!err) )
             continue;
@@ -364,7 +399,7 @@ int iommu_unmap(struct domain *d, dfn_t dfn, unsigned long page_count,
         if ( !d->is_shutting_down && printk_ratelimit() )
             printk(XENLOG_ERR
                    "d%d: IOMMU unmapping dfn %"PRI_dfn" failed: %d\n",
-                   d->domain_id, dfn_x(dfn_add(dfn, i)), err);
+                   d->domain_id, dfn_x(dfn), err);
 
         if ( !rc )
             rc = err;
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri May 20 10:34:36 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 20 May 2022 10:34:36 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333737.557628 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrzxs-0003IZ-S0; Fri, 20 May 2022 10:34:36 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333737.557628; Fri, 20 May 2022 10:34: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 1nrzxs-0003IQ-P3; Fri, 20 May 2022 10:34:36 +0000
Received: by outflank-mailman (input) for mailman id 333737;
 Fri, 20 May 2022 10:34: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 1nrzxr-0003I1-B9
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:34: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 1nrzxr-000415-AT
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:34:35 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrzxr-0003Et-9b
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:34: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=ctUFR81yCEkYbPPBmT4OyEjjMSFPzcozvQPidh+g7TU=; b=W8nBBbDLeQ/gKo77qmDQg7Xa/D
	W/aaMjCxmTbU1kg542PvXcZI7fmn1IQxPbsGfBk1DI/jlevDH+I3xwxUhSf8O0KJ1sB16nz7kFB6Y
	lp1vck1DrWL4LAwCG6Tew3/2dDt3t8xKe80UZr0PaT3HvY7DJCPIjgktXJVrmGreb8Ig=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] AMD/IOMMU: walk trees upon page fault
Message-Id: <E1nrzxr-0003Et-9b@xenbits.xenproject.org>
Date: Fri, 20 May 2022 10:34:35 +0000

commit 0e461c2d7f45c50fcf4d26c7730cdd7cde77eb1f
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 20 12:24:11 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:24:11 2022 +0200

    AMD/IOMMU: walk trees upon page fault
    
    This is to aid diagnosing issues and largely matches VT-d's behavior.
    Since I'm adding permissions output here as well, take the opportunity
    and also add their displaying to amd_dump_page_table_level().
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/passthrough/amd/iommu.h         |  2 ++
 xen/drivers/passthrough/amd/iommu_init.c    |  3 ++
 xen/drivers/passthrough/amd/iommu_map.c     | 44 +++++++++++++++++++++++++++++
 xen/drivers/passthrough/amd/pci_amd_iommu.c |  5 ++--
 4 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu.h b/xen/drivers/passthrough/amd/iommu.h
index 0a19d6a662..a05dd112bc 100644
--- a/xen/drivers/passthrough/amd/iommu.h
+++ b/xen/drivers/passthrough/amd/iommu.h
@@ -259,6 +259,8 @@ int __must_check cf_check amd_iommu_flush_iotlb_pages(
     struct domain *d, dfn_t dfn, unsigned long page_count,
     unsigned int flush_flags);
 int __must_check cf_check amd_iommu_flush_iotlb_all(struct domain *d);
+void amd_iommu_print_entries(const struct amd_iommu *iommu, unsigned int dev_id,
+                             dfn_t dfn);
 
 /* device table functions */
 int get_dma_requestor_id(uint16_t seg, uint16_t bdf);
diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthrough/amd/iommu_init.c
index 7d074ca843..e2166f534f 100644
--- a/xen/drivers/passthrough/amd/iommu_init.c
+++ b/xen/drivers/passthrough/amd/iommu_init.c
@@ -575,6 +575,9 @@ static void cf_check parse_event_log_entry(struct amd_iommu *iommu, u32 entry[])
                (flags & 0x002) ? " NX" : "",
                (flags & 0x001) ? " GN" : "");
 
+        if ( iommu_verbose )
+            amd_iommu_print_entries(iommu, device_id, daddr_to_dfn(addr));
+
         for ( bdf = 0; bdf < ivrs_bdf_entries; bdf++ )
             if ( get_dma_requestor_id(iommu->seg, bdf) == device_id )
                 pci_check_disable_device(iommu->seg, PCI_BUS(bdf),
diff --git a/xen/drivers/passthrough/amd/iommu_map.c b/xen/drivers/passthrough/amd/iommu_map.c
index a63eec477a..5ad33340e8 100644
--- a/xen/drivers/passthrough/amd/iommu_map.c
+++ b/xen/drivers/passthrough/amd/iommu_map.c
@@ -428,6 +428,50 @@ int cf_check amd_iommu_unmap_page(
     return 0;
 }
 
+void amd_iommu_print_entries(const struct amd_iommu *iommu, unsigned int dev_id,
+                             dfn_t dfn)
+{
+    mfn_t pt_mfn;
+    unsigned int level;
+    const struct amd_iommu_dte *dt = iommu->dev_table.buffer;
+
+    if ( !dt[dev_id].tv )
+    {
+        printk("%pp: no root\n", &PCI_SBDF(iommu->seg, dev_id));
+        return;
+    }
+
+    pt_mfn = _mfn(dt[dev_id].pt_root);
+    level = dt[dev_id].paging_mode;
+    printk("%pp root @ %"PRI_mfn" (%u levels) dfn=%"PRI_dfn"\n",
+           &PCI_SBDF(iommu->seg, dev_id), mfn_x(pt_mfn), level, dfn_x(dfn));
+
+    while ( level )
+    {
+        const union amd_iommu_pte *pt = map_domain_page(pt_mfn);
+        unsigned int idx = pfn_to_pde_idx(dfn_x(dfn), level);
+        union amd_iommu_pte pte = pt[idx];
+
+        unmap_domain_page(pt);
+
+        printk("  L%u[%03x] = %"PRIx64" %c%c\n", level, idx, pte.raw,
+               pte.pr ? pte.ir ? 'r' : '-' : 'n',
+               pte.pr ? pte.iw ? 'w' : '-' : 'p');
+
+        if ( !pte.pr )
+            break;
+
+        if ( pte.next_level >= level )
+        {
+            printk("  L%u[%03x]: next: %u\n", level, idx, pte.next_level);
+            break;
+        }
+
+        pt_mfn = _mfn(pte.mfn);
+        level = pte.next_level;
+    }
+}
+
 static unsigned long flush_count(unsigned long dfn, unsigned long page_count,
                                  unsigned int order)
 {
diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c
index 8c5d69a46a..4bf87e8c03 100644
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c
@@ -724,10 +724,11 @@ static void amd_dump_page_table_level(struct page_info *pg, int level,
                 mfn_to_page(_mfn(pde->mfn)), pde->next_level,
                 address, indent + 1);
         else
-            printk("%*sdfn: %08lx  mfn: %08lx\n",
+            printk("%*sdfn: %08lx  mfn: %08lx  %c%c\n",
                    indent, "",
                    (unsigned long)PFN_DOWN(address),
-                   (unsigned long)PFN_DOWN(pfn_to_paddr(pde->mfn)));
+                   (unsigned long)PFN_DOWN(pfn_to_paddr(pde->mfn)),
+                   pde->ir ? 'r' : '-', pde->iw ? 'w' : '-');
     }
 
     unmap_domain_page(table_vaddr);
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Fri May 20 10:34:47 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 20 May 2022 10:34:47 +0000
Received: from list by lists.xenproject.org with outflank-mailman.333738.557632 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nrzy2-0003MN-W1; Fri, 20 May 2022 10:34:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 333738.557632; Fri, 20 May 2022 10:34: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 1nrzy2-0003MF-Sz; Fri, 20 May 2022 10:34:46 +0000
Received: by outflank-mailman (input) for mailman id 333738;
 Fri, 20 May 2022 10:34: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 1nrzy1-0003Lt-E7
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:34: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 1nrzy1-00041F-DP
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:34:45 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nrzy1-0003Fz-Cc
 for xen-changelog@lists.xenproject.org; Fri, 20 May 2022 10:34: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=4WEiIxHqk7uFuSLZEJ6ta676RD56gsj6q6KY/A79cdY=; b=BXm2Za85yxb0GEReuVFmFkhYB3
	Fui8j5ZV/hsB3a7tQilPg/I6Mkuvf+jwjGFzPN3uwFk+4xf4VxRCwBtu1SfobtHgRWSogU5cMvkhz
	PQZHC+ztYnxdH1XGcmFPWbbP5K3ENRKiFggMQo8zwxFmMnWagv0kJODtxoRM4Ss6L7o0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] AMD/IOMMU: return old PTE from {set,clear}_iommu_pte_present()
Message-Id: <E1nrzy1-0003Fz-Cc@xenbits.xenproject.org>
Date: Fri, 20 May 2022 10:34:45 +0000

commit ec0cce125b8b9fccde3fa825b8ee963083b5de3b
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 20 12:24:43 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:24:43 2022 +0200

    AMD/IOMMU: return old PTE from {set,clear}_iommu_pte_present()
    
    In order to free intermediate page tables when replacing smaller
    mappings by a single larger one callers will need to know the full PTE.
    Flush indicators can be derived from this in the callers (and outside
    the locked regions). First split set_iommu_pte_present() from
    set_iommu_ptes_present(): Only the former needs to return the old PTE,
    while the latter (like also set_iommu_pde_present()) doesn't even need
    to return flush indicators. Then change return types/values and callers
    accordingly.
    
    Note that for subsequent changes returning merely a boolean (old.pr) is
    not going to be sufficient; the next_level field will also be required.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/passthrough/amd/iommu_map.c | 88 ++++++++++++++++++++-------------
 1 file changed, 53 insertions(+), 35 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_map.c b/xen/drivers/passthrough/amd/iommu_map.c
index 5ad33340e8..9dbd44812d 100644
--- a/xen/drivers/passthrough/amd/iommu_map.c
+++ b/xen/drivers/passthrough/amd/iommu_map.c
@@ -31,30 +31,28 @@ static unsigned int pfn_to_pde_idx(unsigned long pfn, unsigned int level)
     return idx;
 }
 
-static unsigned int clear_iommu_pte_present(unsigned long l1_mfn,
-                                            unsigned long dfn)
+static union amd_iommu_pte clear_iommu_pte_present(unsigned long l1_mfn,
+                                                   unsigned long dfn)
 {
-    union amd_iommu_pte *table, *pte;
-    unsigned int flush_flags;
+    union amd_iommu_pte *table, *pte, old;
 
     table = map_domain_page(_mfn(l1_mfn));
     pte = &table[pfn_to_pde_idx(dfn, 1)];
+    old = *pte;
 
-    flush_flags = pte->pr ? IOMMU_FLUSHF_modified : 0;
     write_atomic(&pte->raw, 0);
 
     unmap_domain_page(table);
 
-    return flush_flags;
+    return old;
 }
 
-static unsigned int set_iommu_pde_present(union amd_iommu_pte *pte,
-                                          unsigned long next_mfn,
-                                          unsigned int next_level, bool iw,
-                                          bool ir)
+static void set_iommu_pde_present(union amd_iommu_pte *pte,
+                                  unsigned long next_mfn,
+                                  unsigned int next_level,
+                                  bool iw, bool ir)
 {
-    union amd_iommu_pte new = {}, old;
-    unsigned int flush_flags = IOMMU_FLUSHF_added;
+    union amd_iommu_pte new = {};
 
     /*
      * FC bit should be enabled in PTE, this helps to solve potential
@@ -68,29 +66,42 @@ static unsigned int set_iommu_pde_present(union amd_iommu_pte *pte,
     new.next_level = next_level;
     new.pr = true;
 
-    old.raw = read_atomic(&pte->raw);
-    old.ign0 = 0;
-    old.ign1 = 0;
-    old.ign2 = 0;
+    write_atomic(&pte->raw, new.raw);
+}
 
-    if ( old.pr && old.raw != new.raw )
-        flush_flags |= IOMMU_FLUSHF_modified;
+static union amd_iommu_pte set_iommu_pte_present(unsigned long pt_mfn,
+                                                 unsigned long dfn,
+                                                 unsigned long next_mfn,
+                                                 unsigned int level,
+                                                 bool iw, bool ir)
+{
+    union amd_iommu_pte *table, *pde, old;
 
-    write_atomic(&pte->raw, new.raw);
+    table = map_domain_page(_mfn(pt_mfn));
+    pde = &table[pfn_to_pde_idx(dfn, level)];
+
+    old = *pde;
+    if ( !old.pr || old.next_level ||
+         old.mfn != next_mfn ||
+         old.iw != iw || old.ir != ir )
+        set_iommu_pde_present(pde, next_mfn, 0, iw, ir);
+    else
+        old.pr = false; /* signal "no change" to the caller */
 
-    return flush_flags;
+    unmap_domain_page(table);
+
+    return old;
 }
 
-static unsigned int set_iommu_ptes_present(unsigned long pt_mfn,
-                                           unsigned long dfn,
-                                           unsigned long next_mfn,
-                                           unsigned int nr_ptes,
-                                           unsigned int pde_level,
-                                           bool iw, bool ir)
+static void set_iommu_ptes_present(unsigned long pt_mfn,
+                                   unsigned long dfn,
+                                   unsigned long next_mfn,
+                                   unsigned int nr_ptes,
+                                   unsigned int pde_level,
+                                   bool iw, bool ir)
 {
     union amd_iommu_pte *table, *pde;
     unsigned long page_sz = 1UL << (PTE_PER_TABLE_SHIFT * (pde_level - 1));
-    unsigned int flush_flags = 0;
 
     table = map_domain_page(_mfn(pt_mfn));
     pde = &table[pfn_to_pde_idx(dfn, pde_level)];
@@ -98,20 +109,18 @@ static unsigned int set_iommu_ptes_present(unsigned long pt_mfn,
     if ( (void *)(pde + nr_ptes) > (void *)table + PAGE_SIZE )
     {
         ASSERT_UNREACHABLE();
-        return 0;
+        return;
     }
 
     while ( nr_ptes-- )
     {
-        flush_flags |= set_iommu_pde_present(pde, next_mfn, 0, iw, ir);
+        set_iommu_pde_present(pde, next_mfn, 0, iw, ir);
 
         ++pde;
         next_mfn += page_sz;
     }
 
     unmap_domain_page(table);
-
-    return flush_flags;
 }
 
 /*
@@ -349,6 +358,7 @@ int cf_check amd_iommu_map_page(
     struct domain_iommu *hd = dom_iommu(d);
     int rc;
     unsigned long pt_mfn = 0;
+    union amd_iommu_pte old;
 
     spin_lock(&hd->arch.mapping_lock);
 
@@ -385,12 +395,16 @@ int cf_check amd_iommu_map_page(
     }
 
     /* Install 4k mapping */
-    *flush_flags |= set_iommu_ptes_present(pt_mfn, dfn_x(dfn), mfn_x(mfn),
-                                           1, 1, (flags & IOMMUF_writable),
-                                           (flags & IOMMUF_readable));
+    old = set_iommu_pte_present(pt_mfn, dfn_x(dfn), mfn_x(mfn), 1,
+                                (flags & IOMMUF_writable),
+                                (flags & IOMMUF_readable));
 
     spin_unlock(&hd->arch.mapping_lock);
 
+    *flush_flags |= IOMMU_FLUSHF_added;
+    if ( old.pr )
+        *flush_flags |= IOMMU_FLUSHF_modified;
+
     return 0;
 }
 
@@ -399,6 +413,7 @@ int cf_check amd_iommu_unmap_page(
 {
     unsigned long pt_mfn = 0;
     struct domain_iommu *hd = dom_iommu(d);
+    union amd_iommu_pte old = {};
 
     spin_lock(&hd->arch.mapping_lock);
 
@@ -420,11 +435,14 @@ int cf_check amd_iommu_unmap_page(
     if ( pt_mfn )
     {
         /* Mark PTE as 'page not present'. */
-        *flush_flags |= clear_iommu_pte_present(pt_mfn, dfn_x(dfn));
+        old = clear_iommu_pte_present(pt_mfn, dfn_x(dfn));
     }
 
     spin_unlock(&hd->arch.mapping_lock);
 
+    if ( old.pr )
+        *flush_flags |= IOMMU_FLUSHF_modified;
+
     return 0;
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Sat May 21 23:55:07 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 21 May 2022 23:55:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.334920.559009 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nsYw3-0000dx-4p; Sat, 21 May 2022 23:55:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 334920.559009; Sat, 21 May 2022 23: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 1nsYw3-0000dp-1G; Sat, 21 May 2022 23:55:03 +0000
Received: by outflank-mailman (input) for mailman id 334920;
 Sat, 21 May 2022 23: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 1nsYw2-0000dh-2E
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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 1nsYw2-0002ro-18
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23:55:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nsYw1-0000Xr-WE
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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=pJeXrL6RT83oLv3D3r5gu6yTjnC2i3lSofL5dYYhQec=; b=r3VrQDg0c1zg8aMmXsF6697kvg
	WbtYi9nBXbwxWlfttqb4EtBD3n1Z0w4IeGKuJ0bKqmS944hZGH2VDYjK9bRjDhOC/vQE3h7oWUWxF
	n+eKLtDr21j0n7EalG36WXIIlJTkw0f8wpFdDIbl6zpDQxtgqWV0glrl0zrpwzG/bLYk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] VT-d: fix !HVM build
Message-Id: <E1nsYw1-0000Xr-WE@xenbits.xenproject.org>
Date: Sat, 21 May 2022 23:55:01 +0000

commit c038304b46ffb3d3d314819d1331ca61e9ff668b
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 20 12:17:52 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:17:52 2022 +0200

    VT-d: fix !HVM build
    
    EPT is of no interest when !HVM. While I'm observing gcc11 to fully
    eliminate the function, older gcc's DCE looks to not be as good.
    CONFIG_UBSAN apparently also limits how aggressively dead code is
    eliminated. Aid the compiler in eliminating the accesses of
    opt_hap_{2mb,1gb}, which otherwise cause undefined symbol errors when
    linking.
    
    While there adjust types.
    
    Fixes: c479415610f0 ("x86/P2M: p2m.c is HVM-only")
    Reported-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Kevin Tian <kevin.tian@intel.com>
---
 xen/drivers/passthrough/vtd/iommu.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index f22caf269d..4ceb20632f 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -2206,14 +2206,17 @@ static int cf_check intel_iommu_lookup_page(
     return 0;
 }
 
-static int __init vtd_ept_page_compatible(struct vtd_iommu *iommu)
+static bool __init vtd_ept_page_compatible(const struct vtd_iommu *iommu)
 {
-    u64 ept_cap, vtd_cap = iommu->cap;
+    uint64_t ept_cap, vtd_cap = iommu->cap;
+
+    if ( !IS_ENABLED(CONFIG_HVM) )
+        return false;
 
     /* EPT is not initialised yet, so we must check the capability in
      * the MSR explicitly rather than use cpu_has_vmx_ept_*() */
     if ( rdmsr_safe(MSR_IA32_VMX_EPT_VPID_CAP, ept_cap) != 0 ) 
-        return 0;
+        return false;
 
     return (ept_has_2mb(ept_cap) && opt_hap_2mb) <= cap_sps_2mb(vtd_cap) &&
            (ept_has_1gb(ept_cap) && opt_hap_1gb) <= cap_sps_1gb(vtd_cap);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat May 21 23:55:13 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 21 May 2022 23:55:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.334921.559013 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nsYwD-0000fy-5s; Sat, 21 May 2022 23:55:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 334921.559013; Sat, 21 May 2022 23: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 1nsYwD-0000fq-35; Sat, 21 May 2022 23:55:13 +0000
Received: by outflank-mailman (input) for mailman id 334921;
 Sat, 21 May 2022 23: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 1nsYwC-0000fg-5h
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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 1nsYwC-0002ry-4r
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23:55:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nsYwC-0000Yd-3d
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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=z+Nds5lOD/zqLKMAGGYEQuZs6KESQNXqw5q75Br4N1U=; b=CIqBeCV/6S+hxO3s3/rDnXD3J6
	ZfljLEphOI0gjqyLe6VqHr/b+MRcau1wnbGPxJQ2Yygsz0NxY6hxh+HEXuDJvQ3DglcQxpOFVPFHf
	x64nbbHTejAdTnmJAyheV3UsHnxeuB7MNRcwb8GusJNnRRm4459eVAQ0gQj3gE0NwOtY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/libs/light: update xenstore entry when setting max domain memory
Message-Id: <E1nsYwC-0000Yd-3d@xenbits.xenproject.org>
Date: Sat, 21 May 2022 23:55:12 +0000

commit 77bbea1bafe2d5155e6325bdd782c9f19f8a6aea
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri May 20 12:18:50 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:18:50 2022 +0200

    tools/libs/light: update xenstore entry when setting max domain memory
    
    libxl_domain_setmaxmem() called during "xl mem-max" should update the
    domain's memory/static-max Xenstore node, as otherwise "xl mem-set"
    won't be able to set the memory size to the new maximum.
    
    Adjust the related comments and documentation accordingly.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 docs/man/xl.1.pod.in         | 11 +++++------
 tools/libs/light/libxl_mem.c | 12 ++++++++++--
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/docs/man/xl.1.pod.in b/docs/man/xl.1.pod.in
index e2176bd696..101e14241d 100644
--- a/docs/man/xl.1.pod.in
+++ b/docs/man/xl.1.pod.in
@@ -442,15 +442,14 @@ allocate.
 The default unit is kiB.  Add 't' for TiB, 'g' for GiB, 'm' for
 MiB, 'k' for kiB, and 'b' for bytes (e.g., `2048m` for 2048 MiB).
 
-NB that users normally shouldn't need this command; B<xl mem-set> will
-set this as appropriate automatically.
-
 I<mem> can't be set lower than the current memory target for
 I<domain-id>.  It is allowed to be higher than the configured maximum
 memory size of the domain (B<maxmem> parameter in the domain's
-configuration). Note however that the initial B<maxmem> value is still
-used as an upper limit for B<xl mem-set>.  Also note that calling B<xl
-mem-set> will reset this value.
+configuration).
+
+Setting the maximum memory size above the configured maximum memory size
+will require special guest support (memory hotplug) in order to be usable
+by the guest.
 
 The domain will not receive any signal regarding the changed memory
 limit.
diff --git a/tools/libs/light/libxl_mem.c b/tools/libs/light/libxl_mem.c
index c739d00f39..92ec09f4cf 100644
--- a/tools/libs/light/libxl_mem.c
+++ b/tools/libs/light/libxl_mem.c
@@ -20,8 +20,7 @@
 /*
  * Set the maximum memory size of the domain in the hypervisor. There is no
  * change of the current memory size involved. The specified memory size can
- * even be above the configured maxmem size of the domain, but the related
- * Xenstore entry memory/static-max isn't modified!
+ * even be above the configured maxmem size of the domain.
  */
 int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint64_t max_memkb)
 {
@@ -82,6 +81,15 @@ int libxl_domain_setmaxmem(libxl_ctx *ctx, uint32_t domid, uint64_t max_memkb)
         goto out;
     }
 
+    rc = libxl__xs_printf(gc, XBT_NULL,
+                          GCSPRINTF("%s/memory/static-max", dompath),
+                          "%"PRIu64, max_memkb);
+    if (rc != 0) {
+        LOGED(ERROR, domid, "Couldn't set %s/memory/static-max, rc=%d\n",
+              dompath, rc);
+        goto out;
+    }
+
     rc = 0;
 out:
     libxl_domain_config_dispose(&d_config);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat May 21 23:55:23 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 21 May 2022 23:55:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.334922.559016 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nsYwN-0000jC-7c; Sat, 21 May 2022 23:55:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 334922.559016; Sat, 21 May 2022 23: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 1nsYwN-0000j4-4h; Sat, 21 May 2022 23:55:23 +0000
Received: by outflank-mailman (input) for mailman id 334922;
 Sat, 21 May 2022 23: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 1nsYwM-0000ir-8p
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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 1nsYwM-0002sc-89
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23:55:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nsYwM-0000ZI-72
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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=kWfKO9m6AmKb8Ja1GQQkVr8st7zni5EkBh52AadleJA=; b=JGrKN3tB2W280LIW8OPUSlgzPY
	BAkXzSDPrEX/JkrbKsu12kI2UqCenevzHGIY/H4jfYzl4+QCqXUlFWUySTbhsOZZfkSHGPx3AGLLm
	5dsxfQ0oyuDJLRwcX4CDTQKAQU4QkXOIGSqNzX0R56Y1zqsEBYl2kQmsqABy89gztGdQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/cpupool: limit number of cpupools
Message-Id: <E1nsYwM-0000ZI-72@xenbits.xenproject.org>
Date: Sat, 21 May 2022 23:55:22 +0000

commit 488a15a669e5b83267590ed8dad2428a5216ee87
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Fri May 20 12:19:06 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:19:06 2022 +0200

    xen/cpupool: limit number of cpupools
    
    Today the number of cpupools in a system is unlimited. This can lead to
    multiple problems (e.g. duplicate cpupool-id or scalability issues).
    
    Limit the number of cpupools to twice the number of maximum possible
    cpus, allowing to have one cpupool per physical cpu plus some spare
    cpupools for special means (there are already existing use cases for
    such spare cpupools).
    
    Suggested-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/common/sched/cpupool.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/xen/common/sched/cpupool.c b/xen/common/sched/cpupool.c
index f1aa2db5f4..a20e3a5fcb 100644
--- a/xen/common/sched/cpupool.c
+++ b/xen/common/sched/cpupool.c
@@ -30,6 +30,7 @@ struct cpupool *cpupool0;                /* Initial cpupool with Dom0 */
 cpumask_t cpupool_free_cpus;             /* cpus not in any cpupool */
 
 static LIST_HEAD(cpupool_list);          /* linked list, sorted by poolid */
+static unsigned int n_cpupools;
 
 static int cpupool_moving_cpu = -1;
 static struct cpupool *cpupool_cpu_moving = NULL;
@@ -276,6 +277,14 @@ static struct cpupool *cpupool_create(unsigned int poolid,
 
     spin_lock(&cpupool_lock);
 
+    /* Don't allow too many cpupools. */
+    if ( n_cpupools >= 2 * nr_cpu_ids )
+    {
+        ret = -ENOSPC;
+        goto unlock;
+    }
+    n_cpupools++;
+
     if ( poolid != CPUPOOLID_NONE )
     {
         q = __cpupool_find_by_id(poolid, false);
@@ -332,7 +341,9 @@ static struct cpupool *cpupool_create(unsigned int poolid,
 
  err:
     list_del(&c->list);
+    n_cpupools--;
 
+ unlock:
     spin_unlock(&cpupool_lock);
 
     free_cpupool_struct(c);
@@ -356,6 +367,7 @@ static int cpupool_destroy(struct cpupool *c)
         return -EBUSY;
     }
 
+    n_cpupools--;
     list_del(&c->list);
 
     spin_unlock(&cpupool_lock);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat May 21 23:55:33 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 21 May 2022 23:55:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.334923.559023 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nsYwX-0000mB-9q; Sat, 21 May 2022 23:55:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 334923.559023; Sat, 21 May 2022 23: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 1nsYwX-0000m3-6F; Sat, 21 May 2022 23:55:33 +0000
Received: by outflank-mailman (input) for mailman id 334923;
 Sat, 21 May 2022 23: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 1nsYwW-0000lr-C7
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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 1nsYwW-0002uT-BH
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23:55:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nsYwW-0000a0-AL
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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=qHZiYUZHIynaaPMMfxx67ARJrVB+hjzOnsyN0+G8DVc=; b=CRCMMZHNSNAO31lboNs/uK7RYu
	nbb6ao5AxPsNNB+9y4aofl2YEFYDD5BDmSRPILJpzQp4FQqra2/kZOqRpzawUEybFdYBWz6ztwKKl
	jvtJRFuM1U7Pn0rCeQA6+yJL9hoUj0sgNpeVnJUtmq30GjAmLO2NMBDUQI4xoQTQ4vVk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] ns16550: use poll mode if INTERRUPT_LINE is 0xff
Message-Id: <E1nsYwW-0000a0-AL@xenbits.xenproject.org>
Date: Sat, 21 May 2022 23:55:32 +0000

commit 6a2ea1a2370a0c8a0210accac0ae62e68c185134
Author:     Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
AuthorDate: Fri May 20 12:19:45 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:19:45 2022 +0200

    ns16550: use poll mode if INTERRUPT_LINE is 0xff
    
    Intel LPSS has INTERRUPT_LINE set to 0xff by default, that is declared
    by the PCI Local Bus Specification Revision 3.0 (from 2004) as
    "unknown"/"no connection". Fallback to poll mode in this case.
    The 0xff handling is x86-specific, the surrounding code is guarded with
    CONFIG_X86 anyway.
    
    Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/char/ns16550.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
index c133f1f466..cd3573e43d 100644
--- a/xen/drivers/char/ns16550.c
+++ b/xen/drivers/char/ns16550.c
@@ -1316,6 +1316,19 @@ pci_uart_config(struct ns16550 *uart, bool_t skip_amt, unsigned int idx)
                             pci_conf_read8(PCI_SBDF(0, b, d, f),
                                            PCI_INTERRUPT_LINE) : 0;
 
+#ifdef CONFIG_X86
+                /*
+                 * PCI Local Bus Specification Revision 3.0 defines 0xff value
+                 * as special only for X86.
+                 */
+                if ( uart->irq == 0xff )
+                    uart->irq = 0;
+#endif
+                if ( !uart->irq )
+                    printk(XENLOG_INFO
+                           "ns16550: %pp: no legacy IRQ, using poll mode\n",
+                           &PCI_SBDF(0, b, d, f));
+
                 return 0;
             }
         }
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat May 21 23:55:43 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 21 May 2022 23:55:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.334924.559026 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nsYwh-0000pT-Ah; Sat, 21 May 2022 23:55:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 334924.559026; Sat, 21 May 2022 23: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 1nsYwh-0000pL-7h; Sat, 21 May 2022 23:55:43 +0000
Received: by outflank-mailman (input) for mailman id 334924;
 Sat, 21 May 2022 23: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 1nsYwg-0000pD-F3
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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 1nsYwg-0002ud-EK
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23:55:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nsYwg-0000ai-DR
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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=RIGhOCdVNtegw6aejHr1CO8MXYRI3lWL0UrzGNEODVQ=; b=RZ5uK8ocrwtJLijN+/PR3IIkK0
	QBYrZwuxIoj40ZAd4xgQ5P8Riw8uZo+J4o4vtJ36LBRgJDmPUYUJSY0kjILxHdGVmYnzNpE/U+S8o
	swuA2TcQZ+9aj258IC+bNhiZ0+7tws410sKveVwGLE5Ywf8oMFjkqQD9PZAjhaeXFqRE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] PCI: don't allow "pci-phantom=" to mark real devices as phantom functions
Message-Id: <E1nsYwg-0000ai-DR@xenbits.xenproject.org>
Date: Sat, 21 May 2022 23:55:42 +0000

commit 444b555dc9e09fa3ce90f066e0c88dec9b47f422
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 20 12:20:35 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:20:35 2022 +0200

    PCI: don't allow "pci-phantom=" to mark real devices as phantom functions
    
    IOMMU code mapping / unmapping devices and interrupts will misbehave if
    a wrong command line option declared a function "phantom" when there's a
    real device at that position. Warn about this and adjust the specified
    stride (in the worst case ignoring the option altogether).
    
    Requested-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/passthrough/pci.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index a8081576b3..938821e593 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -451,7 +451,24 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg, u8 bus, u8 devfn)
                          phantom_devs[i].slot == PCI_SLOT(devfn) &&
                          phantom_devs[i].stride > PCI_FUNC(devfn) )
                     {
-                        pdev->phantom_stride = phantom_devs[i].stride;
+                        pci_sbdf_t sbdf = pdev->sbdf;
+                        unsigned int stride = phantom_devs[i].stride;
+
+                        while ( (sbdf.fn += stride) > PCI_FUNC(devfn) )
+                        {
+                            if ( pci_conf_read16(sbdf, PCI_VENDOR_ID) == 0xffff &&
+                                 pci_conf_read16(sbdf, PCI_DEVICE_ID) == 0xffff )
+                                continue;
+                            stride <<= 1;
+                            printk(XENLOG_WARNING
+                                   "%pp looks to be a real device; bumping %04x:%02x:%02x stride to %u\n",
+                                   &sbdf, phantom_devs[i].seg,
+                                   phantom_devs[i].bus, phantom_devs[i].slot,
+                                   stride);
+                            sbdf = pdev->sbdf;
+                        }
+                        if ( PCI_FUNC(stride) )
+                           pdev->phantom_stride = stride;
                         break;
                     }
             }
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat May 21 23:55:53 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 21 May 2022 23:55:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.334925.559029 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nsYwr-0000sW-Bq; Sat, 21 May 2022 23:55:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 334925.559029; Sat, 21 May 2022 23: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 1nsYwr-0000sO-9A; Sat, 21 May 2022 23:55:53 +0000
Received: by outflank-mailman (input) for mailman id 334925;
 Sat, 21 May 2022 23: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 1nsYwq-0000rx-I4
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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 1nsYwq-0002un-HK
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23:55:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nsYwq-0000bL-GR
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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=CrWUVjlulMupKbmgNkezgGjDStOHdJoLiswYBvqb9D8=; b=VaAgwaVMMQe6vr0WlQlwbsAFgO
	jcv6luFgP/LVPGMcE0dyg41hSMgtbfFq6TBcl7wyakfSQXeOfelgYynNXvEybIhxHvSP28drmcX/e
	fFVUhRToo+PQgmWUhLAak5/zGrTNbY+ldPhN2SEoPIfX0WKZZmh7ZPLt+eb4ond5MhaI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] AMD/IOMMU: correct potentially-UB shifts
Message-Id: <E1nsYwq-0000bL-GR@xenbits.xenproject.org>
Date: Sat, 21 May 2022 23:55:52 +0000

commit d029b9cf13875823532ee6e4201421dba16c81d4
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 20 12:21:10 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:21:10 2022 +0200

    AMD/IOMMU: correct potentially-UB shifts
    
    Recent changes (likely 5fafa6cf529a ["AMD/IOMMU: have callers specify
    the target level for page table walks"]) have made Coverity notice a
    shift count in iommu_pde_from_dfn() which might in theory grow too
    large. While this isn't a problem in practice, address the concern
    nevertheless to not leave dangling breakage in case very large
    superpages would be enabled at some point.
    
    Coverity ID: 1504264
    
    While there also address a similar issue in set_iommu_ptes_present().
    It's not clear to me why Coverity hasn't spotted that one.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/passthrough/amd/iommu_map.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_map.c b/xen/drivers/passthrough/amd/iommu_map.c
index 4a33df8c5e..963dcc7a4f 100644
--- a/xen/drivers/passthrough/amd/iommu_map.c
+++ b/xen/drivers/passthrough/amd/iommu_map.c
@@ -89,11 +89,11 @@ static unsigned int set_iommu_ptes_present(unsigned long pt_mfn,
                                            bool iw, bool ir)
 {
     union amd_iommu_pte *table, *pde;
-    unsigned int page_sz, flush_flags = 0;
+    unsigned long page_sz = 1UL << (PTE_PER_TABLE_SHIFT * (pde_level - 1));
+    unsigned int flush_flags = 0;
 
     table = map_domain_page(_mfn(pt_mfn));
     pde = &table[pfn_to_pde_idx(dfn, pde_level)];
-    page_sz = 1U << (PTE_PER_TABLE_SHIFT * (pde_level - 1));
 
     if ( (void *)(pde + nr_ptes) > (void *)table + PAGE_SIZE )
     {
@@ -281,7 +281,7 @@ static int iommu_pde_from_dfn(struct domain *d, unsigned long dfn,
         {
             unsigned long mfn, pfn;
 
-            pfn =  dfn & ~((1 << (PTE_PER_TABLE_SHIFT * next_level)) - 1);
+            pfn = dfn & ~((1UL << (PTE_PER_TABLE_SHIFT * next_level)) - 1);
             mfn = next_table_mfn;
 
             /* allocate lower level page table */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat May 21 23:56:03 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 21 May 2022 23:56:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.334926.559032 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nsYx1-0000vR-Db; Sat, 21 May 2022 23:56:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 334926.559032; Sat, 21 May 2022 23: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 1nsYx1-0000vJ-Al; Sat, 21 May 2022 23:56:03 +0000
Received: by outflank-mailman (input) for mailman id 334926;
 Sat, 21 May 2022 23: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 1nsYx0-0000vB-LE
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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 1nsYx0-0002vA-KS
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23:56:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nsYx0-0000cJ-JU
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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=8D8e4KMwCfjGG4abZ5eg6bs+KxWFiQGgMOv0l3WLGy4=; b=4jK+G1/gh4wo22UDy4xtKKMImS
	FjRBP4I7RPuaH+pRUQJrkhSixrh7J65IHbFh25TP6PF5MNid3BbGhDbHcHuXHCioxt5aO8NT5glPE
	p5n3am/RaIvXjadwSTsO166jnN8QihbpbI/zMlJbp9xdSEGZeXUIA//U6kpTf6Xlbjz4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] IOMMU: simplify unmap-on-error in iommu_map()
Message-Id: <E1nsYx0-0000cJ-JU@xenbits.xenproject.org>
Date: Sat, 21 May 2022 23:56:02 +0000

commit 09e4ac7bc071ad0549adcb24d82d8a3c4e72d05c
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 20 12:21:49 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:21:49 2022 +0200

    IOMMU: simplify unmap-on-error in iommu_map()
    
    As of 68a8aa5d7264 ("iommu: make map and unmap take a page count,
    similar to flush") there's no need anymore to have a loop here.
    
    Suggested-by: Roger Pau Monné <roger.pau@citrix.com>
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/passthrough/iommu.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index 67ffe6635e..3762d0bd86 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -308,11 +308,9 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn,
                    d->domain_id, dfn_x(dfn_add(dfn, i)),
                    mfn_x(mfn_add(mfn, i)), rc);
 
-        while ( i-- )
-            /* if statement to satisfy __must_check */
-            if ( iommu_call(hd->platform_ops, unmap_page, d, dfn_add(dfn, i),
-                            flush_flags) )
-                continue;
+        /* while statement to satisfy __must_check */
+        while ( iommu_unmap(d, dfn, i, flush_flags) )
+            break;
 
         if ( !is_hardware_domain(d) )
             domain_crash(d);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat May 21 23:56:13 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 21 May 2022 23:56:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.334927.559037 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nsYxB-0000z5-Et; Sat, 21 May 2022 23:56:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 334927.559037; Sat, 21 May 2022 23: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 1nsYxB-0000yy-CK; Sat, 21 May 2022 23:56:13 +0000
Received: by outflank-mailman (input) for mailman id 334927;
 Sat, 21 May 2022 23: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 1nsYxA-0000yq-OU
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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 1nsYxA-0002vK-Ne
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23:56:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nsYxA-0000d7-Mr
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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=tJ88xDs6M4oJZ3rh2fBTOKyZWvrNDKZeJhATAfKknbU=; b=iMNVrRGOG3h7kQSXGbNteOZXPR
	HB5zMyF8YLjIpWHqnYSWvIkAlarMzbzgOPKnlYHcd5dkYf3ltSIdb4zAHqAxJN/vO9idMqbOo1naN
	cBggECtzaZPnniP7+93ENsVdH98uj89sf1j6uPmc5zlzfdW+PmDkqdrN3iIg2XMbUdJI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] IOMMU: add order parameter to ->{,un}map_page() hooks
Message-Id: <E1nsYxA-0000d7-Mr@xenbits.xenproject.org>
Date: Sat, 21 May 2022 23:56:12 +0000

commit e0de7c2ee63dc440b41c79c203707abde3a473dc
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 20 12:22:24 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:22:24 2022 +0200

    IOMMU: add order parameter to ->{,un}map_page() hooks
    
    Or really, in the case of ->map_page(), accommodate it in the existing
    "flags" parameter. All call sites will pass 0 for now.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Kevin Tian <kevin.tian@intel.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Julien Grall <jgrall@amazon.com> # Arm
---
 xen/arch/arm/include/asm/iommu.h            | 1 +
 xen/drivers/passthrough/amd/iommu.h         | 3 ++-
 xen/drivers/passthrough/amd/iommu_map.c     | 2 +-
 xen/drivers/passthrough/arm/iommu_helpers.c | 7 +++++--
 xen/drivers/passthrough/iommu.c             | 4 +++-
 xen/drivers/passthrough/vtd/iommu.c         | 4 ++--
 xen/include/xen/iommu.h                     | 6 ++++--
 7 files changed, 18 insertions(+), 9 deletions(-)

diff --git a/xen/arch/arm/include/asm/iommu.h b/xen/arch/arm/include/asm/iommu.h
index 937edc8373..d57bd8a38c 100644
--- a/xen/arch/arm/include/asm/iommu.h
+++ b/xen/arch/arm/include/asm/iommu.h
@@ -31,6 +31,7 @@ int __must_check arm_iommu_map_page(struct domain *d, dfn_t dfn, mfn_t mfn,
                                     unsigned int flags,
                                     unsigned int *flush_flags);
 int __must_check arm_iommu_unmap_page(struct domain *d, dfn_t dfn,
+                                      unsigned int order,
                                       unsigned int *flush_flags);
 
 #endif /* __ARCH_ARM_IOMMU_H__ */
diff --git a/xen/drivers/passthrough/amd/iommu.h b/xen/drivers/passthrough/amd/iommu.h
index 64e4bbf33c..0a19d6a662 100644
--- a/xen/drivers/passthrough/amd/iommu.h
+++ b/xen/drivers/passthrough/amd/iommu.h
@@ -245,7 +245,8 @@ int __must_check cf_check amd_iommu_map_page(
     struct domain *d, dfn_t dfn, mfn_t mfn, unsigned int flags,
     unsigned int *flush_flags);
 int __must_check cf_check amd_iommu_unmap_page(
-    struct domain *d, dfn_t dfn, unsigned int *flush_flags);
+    struct domain *d, dfn_t dfn, unsigned int order,
+    unsigned int *flush_flags);
 int __must_check amd_iommu_alloc_root(struct domain *d);
 int amd_iommu_reserve_domain_unity_map(struct domain *domain,
                                        const struct ivrs_unity_map *map,
diff --git a/xen/drivers/passthrough/amd/iommu_map.c b/xen/drivers/passthrough/amd/iommu_map.c
index 963dcc7a4f..a63eec477a 100644
--- a/xen/drivers/passthrough/amd/iommu_map.c
+++ b/xen/drivers/passthrough/amd/iommu_map.c
@@ -395,7 +395,7 @@ int cf_check amd_iommu_map_page(
 }
 
 int cf_check amd_iommu_unmap_page(
-    struct domain *d, dfn_t dfn, unsigned int *flush_flags)
+    struct domain *d, dfn_t dfn, unsigned int order, unsigned int *flush_flags)
 {
     unsigned long pt_mfn = 0;
     struct domain_iommu *hd = dom_iommu(d);
diff --git a/xen/drivers/passthrough/arm/iommu_helpers.c b/xen/drivers/passthrough/arm/iommu_helpers.c
index a36e2b8e6c..5cb1987481 100644
--- a/xen/drivers/passthrough/arm/iommu_helpers.c
+++ b/xen/drivers/passthrough/arm/iommu_helpers.c
@@ -57,11 +57,13 @@ int __must_check arm_iommu_map_page(struct domain *d, dfn_t dfn, mfn_t mfn,
      * The function guest_physmap_add_entry replaces the current mapping
      * if there is already one...
      */
-    return guest_physmap_add_entry(d, _gfn(dfn_x(dfn)), _mfn(dfn_x(dfn)), 0, t);
+    return guest_physmap_add_entry(d, _gfn(dfn_x(dfn)), _mfn(dfn_x(dfn)),
+                                   IOMMUF_order(flags), t);
 }
 
 /* Should only be used if P2M Table is shared between the CPU and the IOMMU. */
 int __must_check arm_iommu_unmap_page(struct domain *d, dfn_t dfn,
+                                      unsigned int order,
                                       unsigned int *flush_flags)
 {
     /*
@@ -71,7 +73,8 @@ int __must_check arm_iommu_unmap_page(struct domain *d, dfn_t dfn,
     if ( !is_domain_direct_mapped(d) )
         return -EINVAL;
 
-    return guest_physmap_remove_page(d, _gfn(dfn_x(dfn)), _mfn(dfn_x(dfn)), 0);
+    return guest_physmap_remove_page(d, _gfn(dfn_x(dfn)), _mfn(dfn_x(dfn)),
+                                     order);
 }
 
 /*
diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index 3762d0bd86..5553e1f106 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -294,6 +294,8 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn,
     if ( !is_iommu_enabled(d) )
         return 0;
 
+    ASSERT(!IOMMUF_order(flags));
+
     for ( i = 0; i < page_count; i++ )
     {
         rc = iommu_call(hd->platform_ops, map_page, d, dfn_add(dfn, i),
@@ -354,7 +356,7 @@ int iommu_unmap(struct domain *d, dfn_t dfn, unsigned long page_count,
     for ( i = 0; i < page_count; i++ )
     {
         int err = iommu_call(hd->platform_ops, unmap_page, d, dfn_add(dfn, i),
-                             flush_flags);
+                             0, flush_flags);
 
         if ( likely(!err) )
             continue;
diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index 4ceb20632f..6d9513ef41 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -2163,7 +2163,7 @@ static int __must_check cf_check intel_iommu_map_page(
 }
 
 static int __must_check cf_check intel_iommu_unmap_page(
-    struct domain *d, dfn_t dfn, unsigned int *flush_flags)
+    struct domain *d, dfn_t dfn, unsigned int order, unsigned int *flush_flags)
 {
     /* Do nothing if VT-d shares EPT page table */
     if ( iommu_use_hap_pt(d) )
@@ -2173,7 +2173,7 @@ static int __must_check cf_check intel_iommu_unmap_page(
     if ( iommu_hwdom_passthrough && is_hardware_domain(d) )
         return 0;
 
-    return dma_pte_clear_one(d, dfn_to_daddr(dfn), 0, flush_flags);
+    return dma_pte_clear_one(d, dfn_to_daddr(dfn), order, flush_flags);
 }
 
 static int cf_check intel_iommu_lookup_page(
diff --git a/xen/include/xen/iommu.h b/xen/include/xen/iommu.h
index db72d9e644..e0f82712ed 100644
--- a/xen/include/xen/iommu.h
+++ b/xen/include/xen/iommu.h
@@ -127,9 +127,10 @@ void arch_iommu_hwdom_init(struct domain *d);
  * The following flags are passed to map operations and passed by lookup
  * operations.
  */
-#define _IOMMUF_readable 0
+#define IOMMUF_order(n)  ((n) & 0x3f)
+#define _IOMMUF_readable 6
 #define IOMMUF_readable  (1u<<_IOMMUF_readable)
-#define _IOMMUF_writable 1
+#define _IOMMUF_writable 7
 #define IOMMUF_writable  (1u<<_IOMMUF_writable)
 
 /*
@@ -255,6 +256,7 @@ struct iommu_ops {
                                  unsigned int flags,
                                  unsigned int *flush_flags);
     int __must_check (*unmap_page)(struct domain *d, dfn_t dfn,
+                                   unsigned int order,
                                    unsigned int *flush_flags);
     int __must_check (*lookup_page)(struct domain *d, dfn_t dfn, mfn_t *mfn,
                                     unsigned int *flags);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat May 21 23:56:23 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 21 May 2022 23:56:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.334928.559041 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nsYxL-00012A-IF; Sat, 21 May 2022 23:56:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 334928.559041; Sat, 21 May 2022 23:56: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 1nsYxL-000122-FH; Sat, 21 May 2022 23:56:23 +0000
Received: by outflank-mailman (input) for mailman id 334928;
 Sat, 21 May 2022 23:56: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 1nsYxK-00011s-RD
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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 1nsYxK-0002vk-QY
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23:56:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nsYxK-0000dm-Pk
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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=6QNOEdY1uzQ7oIbIZ/ps1gk/yM5EKjd3aQJh6QkhZX4=; b=fiHqKBRPAyr+o/rW9ex9rM1oKW
	Xl/j35v9eWpFwQ2IZdXhhhPJRX3MJpdZ5oT6vYa1nqQTf1hQU6JdSxwMQ7vK1PVc/FfPY9WwtCfFc
	I0hhcAIoqwyTDPjsxJU6nJbB5GlbOSUYlwyICZoTJzYey9VrMS7HGuKqeqVC2PO7ZHMA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] IOMMU: have iommu_{,un}map() split requests into largest possible chunks
Message-Id: <E1nsYxK-0000dm-Pk@xenbits.xenproject.org>
Date: Sat, 21 May 2022 23:56:22 +0000

commit ba3fcb5f52eb2d3cc43b64bad2fc78507ad4fc7a
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 20 12:23:31 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:23:31 2022 +0200

    IOMMU: have iommu_{,un}map() split requests into largest possible chunks
    
    Introduce a helper function to determine the largest possible mapping
    that allows covering a request (or the next part of it that is left to
    be processed).
    
    In order to not add yet more recurring dfn_add() / mfn_add() to the two
    callers of the new helper, also introduce local variables holding the
    values presently operated on.
    
    Note that strictly speaking iommu_unmap() doen't need to consult
    mapping_order(), as unmapping doesn't require superpage support. This,
    however, prevents freeing of deep hierarchies of page tables in vendor
    code (once suitably enabled), which otherwise would require dealing with
    preemption needs.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/passthrough/iommu.c | 59 ++++++++++++++++++++++++++++++++---------
 1 file changed, 47 insertions(+), 12 deletions(-)

diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index 5553e1f106..9393d987c7 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -283,12 +283,38 @@ void iommu_domain_destroy(struct domain *d)
     arch_iommu_domain_destroy(d);
 }
 
-int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn,
+static unsigned int mapping_order(const struct domain_iommu *hd,
+                                  dfn_t dfn, mfn_t mfn, unsigned long nr)
+{
+    unsigned long res = dfn_x(dfn) | mfn_x(mfn);
+    unsigned long sizes = hd->platform_ops->page_sizes;
+    unsigned int bit = find_first_set_bit(sizes), order = 0;
+
+    ASSERT(bit == PAGE_SHIFT);
+
+    while ( (sizes = (sizes >> bit) & ~1) )
+    {
+        unsigned long mask;
+
+        bit = find_first_set_bit(sizes);
+        mask = (1UL << bit) - 1;
+        if ( nr <= mask || (res & mask) )
+            break;
+        order += bit;
+        nr >>= bit;
+        res >>= bit;
+    }
+
+    return order;
+}
+
+int iommu_map(struct domain *d, dfn_t dfn0, mfn_t mfn0,
               unsigned long page_count, unsigned int flags,
               unsigned int *flush_flags)
 {
     const struct domain_iommu *hd = dom_iommu(d);
     unsigned long i;
+    unsigned int order;
     int rc = 0;
 
     if ( !is_iommu_enabled(d) )
@@ -296,10 +322,15 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn,
 
     ASSERT(!IOMMUF_order(flags));
 
-    for ( i = 0; i < page_count; i++ )
+    for ( i = 0; i < page_count; i += 1UL << order )
     {
-        rc = iommu_call(hd->platform_ops, map_page, d, dfn_add(dfn, i),
-                        mfn_add(mfn, i), flags, flush_flags);
+        dfn_t dfn = dfn_add(dfn0, i);
+        mfn_t mfn = mfn_add(mfn0, i);
+
+        order = mapping_order(hd, dfn, mfn, page_count - i);
+
+        rc = iommu_call(hd->platform_ops, map_page, d, dfn, mfn,
+                        flags | IOMMUF_order(order), flush_flags);
 
         if ( likely(!rc) )
             continue;
@@ -307,11 +338,10 @@ int iommu_map(struct domain *d, dfn_t dfn, mfn_t mfn,
         if ( !d->is_shutting_down && printk_ratelimit() )
             printk(XENLOG_ERR
                    "d%d: IOMMU mapping dfn %"PRI_dfn" to mfn %"PRI_mfn" failed: %d\n",
-                   d->domain_id, dfn_x(dfn_add(dfn, i)),
-                   mfn_x(mfn_add(mfn, i)), rc);
+                   d->domain_id, dfn_x(dfn), mfn_x(mfn), rc);
 
         /* while statement to satisfy __must_check */
-        while ( iommu_unmap(d, dfn, i, flush_flags) )
+        while ( iommu_unmap(d, dfn0, i, flush_flags) )
             break;
 
         if ( !is_hardware_domain(d) )
@@ -343,20 +373,25 @@ int iommu_legacy_map(struct domain *d, dfn_t dfn, mfn_t mfn,
     return rc;
 }
 
-int iommu_unmap(struct domain *d, dfn_t dfn, unsigned long page_count,
+int iommu_unmap(struct domain *d, dfn_t dfn0, unsigned long page_count,
                 unsigned int *flush_flags)
 {
     const struct domain_iommu *hd = dom_iommu(d);
     unsigned long i;
+    unsigned int order;
     int rc = 0;
 
     if ( !is_iommu_enabled(d) )
         return 0;
 
-    for ( i = 0; i < page_count; i++ )
+    for ( i = 0; i < page_count; i += 1UL << order )
     {
-        int err = iommu_call(hd->platform_ops, unmap_page, d, dfn_add(dfn, i),
-                             0, flush_flags);
+        dfn_t dfn = dfn_add(dfn0, i);
+        int err;
+
+        order = mapping_order(hd, dfn, _mfn(0), page_count - i);
+        err = iommu_call(hd->platform_ops, unmap_page, d, dfn,
+                         order, flush_flags);
 
         if ( likely(!err) )
             continue;
@@ -364,7 +399,7 @@ int iommu_unmap(struct domain *d, dfn_t dfn, unsigned long page_count,
         if ( !d->is_shutting_down && printk_ratelimit() )
             printk(XENLOG_ERR
                    "d%d: IOMMU unmapping dfn %"PRI_dfn" failed: %d\n",
-                   d->domain_id, dfn_x(dfn_add(dfn, i)), err);
+                   d->domain_id, dfn_x(dfn), err);
 
         if ( !rc )
             rc = err;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat May 21 23:56:33 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 21 May 2022 23:56:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.334929.559045 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nsYxV-00015I-JW; Sat, 21 May 2022 23:56:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 334929.559045; Sat, 21 May 2022 23:56: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 1nsYxV-00015B-Gq; Sat, 21 May 2022 23:56:33 +0000
Received: by outflank-mailman (input) for mailman id 334929;
 Sat, 21 May 2022 23:56: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 1nsYxU-000154-UM
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23:56: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 1nsYxU-0002vv-Tg
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23:56:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nsYxU-0000eN-Si
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23:56: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=ljPEqiC6wQS408BTpdwjIxBKp3wKcRfXaB20If2lkZo=; b=yZQUKCOok8c6Wc6DsfRQs2VD1B
	KcCyZcMmo98O/o+j5V1tg6EeVKfryowVROgWFgl2kqJTnlCtpPOwuT5GOMupdMiX5XLZzxO1E7D91
	bH9EUv+/vLSbLI9WXIzRKQoGNhgJiuDWjx1sGSgbnVtJMmdghGDiAbe4FmVfSDslMGHk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] AMD/IOMMU: walk trees upon page fault
Message-Id: <E1nsYxU-0000eN-Si@xenbits.xenproject.org>
Date: Sat, 21 May 2022 23:56:32 +0000

commit 0e461c2d7f45c50fcf4d26c7730cdd7cde77eb1f
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 20 12:24:11 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:24:11 2022 +0200

    AMD/IOMMU: walk trees upon page fault
    
    This is to aid diagnosing issues and largely matches VT-d's behavior.
    Since I'm adding permissions output here as well, take the opportunity
    and also add their displaying to amd_dump_page_table_level().
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/passthrough/amd/iommu.h         |  2 ++
 xen/drivers/passthrough/amd/iommu_init.c    |  3 ++
 xen/drivers/passthrough/amd/iommu_map.c     | 44 +++++++++++++++++++++++++++++
 xen/drivers/passthrough/amd/pci_amd_iommu.c |  5 ++--
 4 files changed, 52 insertions(+), 2 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu.h b/xen/drivers/passthrough/amd/iommu.h
index 0a19d6a662..a05dd112bc 100644
--- a/xen/drivers/passthrough/amd/iommu.h
+++ b/xen/drivers/passthrough/amd/iommu.h
@@ -259,6 +259,8 @@ int __must_check cf_check amd_iommu_flush_iotlb_pages(
     struct domain *d, dfn_t dfn, unsigned long page_count,
     unsigned int flush_flags);
 int __must_check cf_check amd_iommu_flush_iotlb_all(struct domain *d);
+void amd_iommu_print_entries(const struct amd_iommu *iommu, unsigned int dev_id,
+                             dfn_t dfn);
 
 /* device table functions */
 int get_dma_requestor_id(uint16_t seg, uint16_t bdf);
diff --git a/xen/drivers/passthrough/amd/iommu_init.c b/xen/drivers/passthrough/amd/iommu_init.c
index 7d074ca843..e2166f534f 100644
--- a/xen/drivers/passthrough/amd/iommu_init.c
+++ b/xen/drivers/passthrough/amd/iommu_init.c
@@ -575,6 +575,9 @@ static void cf_check parse_event_log_entry(struct amd_iommu *iommu, u32 entry[])
                (flags & 0x002) ? " NX" : "",
                (flags & 0x001) ? " GN" : "");
 
+        if ( iommu_verbose )
+            amd_iommu_print_entries(iommu, device_id, daddr_to_dfn(addr));
+
         for ( bdf = 0; bdf < ivrs_bdf_entries; bdf++ )
             if ( get_dma_requestor_id(iommu->seg, bdf) == device_id )
                 pci_check_disable_device(iommu->seg, PCI_BUS(bdf),
diff --git a/xen/drivers/passthrough/amd/iommu_map.c b/xen/drivers/passthrough/amd/iommu_map.c
index a63eec477a..5ad33340e8 100644
--- a/xen/drivers/passthrough/amd/iommu_map.c
+++ b/xen/drivers/passthrough/amd/iommu_map.c
@@ -428,6 +428,50 @@ int cf_check amd_iommu_unmap_page(
     return 0;
 }
 
+void amd_iommu_print_entries(const struct amd_iommu *iommu, unsigned int dev_id,
+                             dfn_t dfn)
+{
+    mfn_t pt_mfn;
+    unsigned int level;
+    const struct amd_iommu_dte *dt = iommu->dev_table.buffer;
+
+    if ( !dt[dev_id].tv )
+    {
+        printk("%pp: no root\n", &PCI_SBDF(iommu->seg, dev_id));
+        return;
+    }
+
+    pt_mfn = _mfn(dt[dev_id].pt_root);
+    level = dt[dev_id].paging_mode;
+    printk("%pp root @ %"PRI_mfn" (%u levels) dfn=%"PRI_dfn"\n",
+           &PCI_SBDF(iommu->seg, dev_id), mfn_x(pt_mfn), level, dfn_x(dfn));
+
+    while ( level )
+    {
+        const union amd_iommu_pte *pt = map_domain_page(pt_mfn);
+        unsigned int idx = pfn_to_pde_idx(dfn_x(dfn), level);
+        union amd_iommu_pte pte = pt[idx];
+
+        unmap_domain_page(pt);
+
+        printk("  L%u[%03x] = %"PRIx64" %c%c\n", level, idx, pte.raw,
+               pte.pr ? pte.ir ? 'r' : '-' : 'n',
+               pte.pr ? pte.iw ? 'w' : '-' : 'p');
+
+        if ( !pte.pr )
+            break;
+
+        if ( pte.next_level >= level )
+        {
+            printk("  L%u[%03x]: next: %u\n", level, idx, pte.next_level);
+            break;
+        }
+
+        pt_mfn = _mfn(pte.mfn);
+        level = pte.next_level;
+    }
+}
+
 static unsigned long flush_count(unsigned long dfn, unsigned long page_count,
                                  unsigned int order)
 {
diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c
index 8c5d69a46a..4bf87e8c03 100644
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c
@@ -724,10 +724,11 @@ static void amd_dump_page_table_level(struct page_info *pg, int level,
                 mfn_to_page(_mfn(pde->mfn)), pde->next_level,
                 address, indent + 1);
         else
-            printk("%*sdfn: %08lx  mfn: %08lx\n",
+            printk("%*sdfn: %08lx  mfn: %08lx  %c%c\n",
                    indent, "",
                    (unsigned long)PFN_DOWN(address),
-                   (unsigned long)PFN_DOWN(pfn_to_paddr(pde->mfn)));
+                   (unsigned long)PFN_DOWN(pfn_to_paddr(pde->mfn)),
+                   pde->ir ? 'r' : '-', pde->iw ? 'w' : '-');
     }
 
     unmap_domain_page(table_vaddr);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat May 21 23:56:44 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 21 May 2022 23:56:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.334930.559049 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nsYxg-000184-LP; Sat, 21 May 2022 23:56:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 334930.559049; Sat, 21 May 2022 23: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 1nsYxg-00017v-IT; Sat, 21 May 2022 23:56:44 +0000
Received: by outflank-mailman (input) for mailman id 334930;
 Sat, 21 May 2022 23: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 1nsYxf-00017k-3e
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23: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 1nsYxf-0002vz-0E
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23:56:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nsYxe-0000f9-Vk
 for xen-changelog@lists.xenproject.org; Sat, 21 May 2022 23:56: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=qDkTp3ctck7NGdfpEm55Men/rN6KmMDniy3Ixh7ZEUQ=; b=QXAvApFdpqlaA9zzUd7zoPSotm
	T5w+o9t65G6y8rsY3ZejrmgcTfBpP5ZzPH/F2/Vj4YcqsftD5Ft3oEdmT9AaCKrD7akDRnrzJLj5S
	pOZmriPQz3m/AX2SkON6OF6ELEMHZuI3AEyz6xEj46RQP+5TZPNbktFkSW4ZUNDufNew=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] AMD/IOMMU: return old PTE from {set,clear}_iommu_pte_present()
Message-Id: <E1nsYxe-0000f9-Vk@xenbits.xenproject.org>
Date: Sat, 21 May 2022 23:56:42 +0000

commit ec0cce125b8b9fccde3fa825b8ee963083b5de3b
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Fri May 20 12:24:43 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri May 20 12:24:43 2022 +0200

    AMD/IOMMU: return old PTE from {set,clear}_iommu_pte_present()
    
    In order to free intermediate page tables when replacing smaller
    mappings by a single larger one callers will need to know the full PTE.
    Flush indicators can be derived from this in the callers (and outside
    the locked regions). First split set_iommu_pte_present() from
    set_iommu_ptes_present(): Only the former needs to return the old PTE,
    while the latter (like also set_iommu_pde_present()) doesn't even need
    to return flush indicators. Then change return types/values and callers
    accordingly.
    
    Note that for subsequent changes returning merely a boolean (old.pr) is
    not going to be sufficient; the next_level field will also be required.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/drivers/passthrough/amd/iommu_map.c | 88 ++++++++++++++++++++-------------
 1 file changed, 53 insertions(+), 35 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_map.c b/xen/drivers/passthrough/amd/iommu_map.c
index 5ad33340e8..9dbd44812d 100644
--- a/xen/drivers/passthrough/amd/iommu_map.c
+++ b/xen/drivers/passthrough/amd/iommu_map.c
@@ -31,30 +31,28 @@ static unsigned int pfn_to_pde_idx(unsigned long pfn, unsigned int level)
     return idx;
 }
 
-static unsigned int clear_iommu_pte_present(unsigned long l1_mfn,
-                                            unsigned long dfn)
+static union amd_iommu_pte clear_iommu_pte_present(unsigned long l1_mfn,
+                                                   unsigned long dfn)
 {
-    union amd_iommu_pte *table, *pte;
-    unsigned int flush_flags;
+    union amd_iommu_pte *table, *pte, old;
 
     table = map_domain_page(_mfn(l1_mfn));
     pte = &table[pfn_to_pde_idx(dfn, 1)];
+    old = *pte;
 
-    flush_flags = pte->pr ? IOMMU_FLUSHF_modified : 0;
     write_atomic(&pte->raw, 0);
 
     unmap_domain_page(table);
 
-    return flush_flags;
+    return old;
 }
 
-static unsigned int set_iommu_pde_present(union amd_iommu_pte *pte,
-                                          unsigned long next_mfn,
-                                          unsigned int next_level, bool iw,
-                                          bool ir)
+static void set_iommu_pde_present(union amd_iommu_pte *pte,
+                                  unsigned long next_mfn,
+                                  unsigned int next_level,
+                                  bool iw, bool ir)
 {
-    union amd_iommu_pte new = {}, old;
-    unsigned int flush_flags = IOMMU_FLUSHF_added;
+    union amd_iommu_pte new = {};
 
     /*
      * FC bit should be enabled in PTE, this helps to solve potential
@@ -68,29 +66,42 @@ static unsigned int set_iommu_pde_present(union amd_iommu_pte *pte,
     new.next_level = next_level;
     new.pr = true;
 
-    old.raw = read_atomic(&pte->raw);
-    old.ign0 = 0;
-    old.ign1 = 0;
-    old.ign2 = 0;
+    write_atomic(&pte->raw, new.raw);
+}
 
-    if ( old.pr && old.raw != new.raw )
-        flush_flags |= IOMMU_FLUSHF_modified;
+static union amd_iommu_pte set_iommu_pte_present(unsigned long pt_mfn,
+                                                 unsigned long dfn,
+                                                 unsigned long next_mfn,
+                                                 unsigned int level,
+                                                 bool iw, bool ir)
+{
+    union amd_iommu_pte *table, *pde, old;
 
-    write_atomic(&pte->raw, new.raw);
+    table = map_domain_page(_mfn(pt_mfn));
+    pde = &table[pfn_to_pde_idx(dfn, level)];
+
+    old = *pde;
+    if ( !old.pr || old.next_level ||
+         old.mfn != next_mfn ||
+         old.iw != iw || old.ir != ir )
+        set_iommu_pde_present(pde, next_mfn, 0, iw, ir);
+    else
+        old.pr = false; /* signal "no change" to the caller */
 
-    return flush_flags;
+    unmap_domain_page(table);
+
+    return old;
 }
 
-static unsigned int set_iommu_ptes_present(unsigned long pt_mfn,
-                                           unsigned long dfn,
-                                           unsigned long next_mfn,
-                                           unsigned int nr_ptes,
-                                           unsigned int pde_level,
-                                           bool iw, bool ir)
+static void set_iommu_ptes_present(unsigned long pt_mfn,
+                                   unsigned long dfn,
+                                   unsigned long next_mfn,
+                                   unsigned int nr_ptes,
+                                   unsigned int pde_level,
+                                   bool iw, bool ir)
 {
     union amd_iommu_pte *table, *pde;
     unsigned long page_sz = 1UL << (PTE_PER_TABLE_SHIFT * (pde_level - 1));
-    unsigned int flush_flags = 0;
 
     table = map_domain_page(_mfn(pt_mfn));
     pde = &table[pfn_to_pde_idx(dfn, pde_level)];
@@ -98,20 +109,18 @@ static unsigned int set_iommu_ptes_present(unsigned long pt_mfn,
     if ( (void *)(pde + nr_ptes) > (void *)table + PAGE_SIZE )
     {
         ASSERT_UNREACHABLE();
-        return 0;
+        return;
     }
 
     while ( nr_ptes-- )
     {
-        flush_flags |= set_iommu_pde_present(pde, next_mfn, 0, iw, ir);
+        set_iommu_pde_present(pde, next_mfn, 0, iw, ir);
 
         ++pde;
         next_mfn += page_sz;
     }
 
     unmap_domain_page(table);
-
-    return flush_flags;
 }
 
 /*
@@ -349,6 +358,7 @@ int cf_check amd_iommu_map_page(
     struct domain_iommu *hd = dom_iommu(d);
     int rc;
     unsigned long pt_mfn = 0;
+    union amd_iommu_pte old;
 
     spin_lock(&hd->arch.mapping_lock);
 
@@ -385,12 +395,16 @@ int cf_check amd_iommu_map_page(
     }
 
     /* Install 4k mapping */
-    *flush_flags |= set_iommu_ptes_present(pt_mfn, dfn_x(dfn), mfn_x(mfn),
-                                           1, 1, (flags & IOMMUF_writable),
-                                           (flags & IOMMUF_readable));
+    old = set_iommu_pte_present(pt_mfn, dfn_x(dfn), mfn_x(mfn), 1,
+                                (flags & IOMMUF_writable),
+                                (flags & IOMMUF_readable));
 
     spin_unlock(&hd->arch.mapping_lock);
 
+    *flush_flags |= IOMMU_FLUSHF_added;
+    if ( old.pr )
+        *flush_flags |= IOMMU_FLUSHF_modified;
+
     return 0;
 }
 
@@ -399,6 +413,7 @@ int cf_check amd_iommu_unmap_page(
 {
     unsigned long pt_mfn = 0;
     struct domain_iommu *hd = dom_iommu(d);
+    union amd_iommu_pte old = {};
 
     spin_lock(&hd->arch.mapping_lock);
 
@@ -420,11 +435,14 @@ int cf_check amd_iommu_unmap_page(
     if ( pt_mfn )
     {
         /* Mark PTE as 'page not present'. */
-        *flush_flags |= clear_iommu_pte_present(pt_mfn, dfn_x(dfn));
+        old = clear_iommu_pte_present(pt_mfn, dfn_x(dfn));
     }
 
     spin_unlock(&hd->arch.mapping_lock);
 
+    if ( old.pr )
+        *flush_flags |= IOMMU_FLUSHF_modified;
+
     return 0;
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue May 24 23:22:12 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 24 May 2022 23:22:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.336762.561147 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ntdqn-0008Pf-N4; Tue, 24 May 2022 23:22:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 336762.561147; Tue, 24 May 2022 23: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 1ntdqn-0008PX-JS; Tue, 24 May 2022 23:22:05 +0000
Received: by outflank-mailman (input) for mailman id 336762;
 Tue, 24 May 2022 23: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 1ntdqm-0008PR-Qc
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23: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 1ntdqm-0002xf-Nb
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23:22:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ntdqm-0003Pt-MO
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23: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=N3019b0/53dBHwaU3LrMyiVGfXMpuwaOmPy8iBeoMq4=; b=fth6uKYmwTZUTtvNY3Vqw3W33B
	GzdxRD1s/JkDv7dzsiE26q3GT5jPZHTBuBworSm4V5la9QJWet/hRMWhVKpbp3WPmA/ngKCrMBJS2
	kgDBdJuVBvdtyE+Y2jRLmpJqGUTaLd0Zz7qBFrUyxKMBMVlesMhmwoACrxbyw5PgOTlc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/dt: of_property_read_string return -ENODATA when !length
Message-Id: <E1ntdqm-0003Pt-MO@xenbits.xenproject.org>
Date: Tue, 24 May 2022 23:22:04 +0000

commit d43d2b6056fc65126e8d991a11f5dec14e51754d
Author:     Stefano Stabellini <stefano.stabellini@xilinx.com>
AuthorDate: Fri May 13 14:07:24 2022 -0700
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Tue May 24 16:11:06 2022 -0700

    xen/dt: of_property_read_string return -ENODATA when !length
    
    When the length of the string is zero of_property_read_string should
    return -ENODATA according to the description of the function.
    
    However, of_property_read_string doesn't check prop->length. If
    prop->length is zero, return -ENODATA.
    
    Without this patch the following command in u-boot:
    
    fdt set /chosen/node property-name
    
    results in of_property_read_string returning -EILSEQ when attempting to
    read property-name. With this patch, it returns -ENODATA as expected.
    
    This commit is a backport of:
    https://lore.kernel.org/xen-devel/20220416003028.1315268-1-sstabellini@kernel.org/
    
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
    Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
---
 xen/common/device_tree.c      | 2 +-
 xen/include/xen/device_tree.h | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index 4aae281e89..0e8798bd24 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -198,7 +198,7 @@ int dt_property_read_string(const struct dt_device_node *np,
 
     if ( !pp )
         return -EINVAL;
-    if ( !pp->value )
+    if ( !pp->length )
         return -ENODATA;
     if ( strnlen(pp->value, pp->length) >= pp->length )
         return -EILSEQ;
diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index fd6cd00b43..430a1ef445 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -451,6 +451,9 @@ static inline bool_t dt_property_read_bool(const struct dt_device_node *np,
  * doest not have value, and -EILSEQ if the string is not
  * null-terminated with the length of the property data.
  *
+ * Note that the empty string "" has length of 1, thus -ENODATA cannot
+ * be interpreted as an empty string.
+ *
  * The out_string pointer is modified only if a valid string can be decoded.
  */
 int dt_property_read_string(const struct dt_device_node *np,
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue May 24 23:22:15 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 24 May 2022 23:22:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.336763.561151 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ntdqx-0008RE-OD; Tue, 24 May 2022 23:22:15 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 336763.561151; Tue, 24 May 2022 23: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 1ntdqx-0008R7-LN; Tue, 24 May 2022 23:22:15 +0000
Received: by outflank-mailman (input) for mailman id 336763;
 Tue, 24 May 2022 23: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 1ntdqw-0008R1-Rs
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23: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 1ntdqw-0002y6-R1
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23:22:14 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ntdqw-0003SI-Q0
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23: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=H4Fcy5XSmqwEHEFL8i6VQJkXc8lkJdZ2ZEvgtQVapro=; b=bANlLoZR8fFgEpD41pd0e1zbAU
	0pdPz+GhsdS1GRhFEsGFLhng37AUnZoTuf1iSnQjF+yg4m0C77i81Uj1x1bAp9JhLHEm1Av9+UH1A
	aSTHhmvk8qCKYkzYaKg3GqlUghSXaWTnu2JAsc8FPPLoWIIjhmDK0uz7sZi2c8Y2cKr4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/arm: implement domU extended regions
Message-Id: <E1ntdqw-0003SI-Q0@xenbits.xenproject.org>
Date: Tue, 24 May 2022 23:22:14 +0000

commit 2a2447757b3c276be426b1f5d4070c2e993114fe
Author:     Stefano Stabellini <stefano.stabellini@xilinx.com>
AuthorDate: Fri May 13 14:07:25 2022 -0700
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Tue May 24 16:12:09 2022 -0700

    xen/arm: implement domU extended regions
    
    Implement extended regions for dom0less domUs. The implementation is
    based on the libxl implementation.
    
    Also update docs for the ext_regions command line option.
    
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
    Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
    Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 docs/misc/xen-command-line.pandoc |  9 +++---
 xen/arch/arm/domain_build.c       | 60 +++++++++++++++++++++++++++++++++------
 2 files changed, 56 insertions(+), 13 deletions(-)

diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
index 1dc7e1ca07..881fe409ac 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -1110,11 +1110,12 @@ to use the default.
 
 > Default : `true`
 
-Flag to enable or disable support for extended regions for Dom0.
+Flag to enable or disable support for extended regions for Dom0 and
+Dom0less DomUs.
 
-Extended regions are ranges of unused address space exposed to Dom0 as
-"safe to use" for special memory mappings. Disable if your board device
-tree is incomplete.
+Extended regions are ranges of unused address space exposed to the guest
+as "safe to use" for special memory mappings. Disable if your board
+device tree is incomplete.
 
 ### flask
 > `= permissive | enforcing | late | disabled`
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index aa777741bd..c4dd211b91 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -35,7 +35,10 @@
 static unsigned int __initdata opt_dom0_max_vcpus;
 integer_param("dom0_max_vcpus", opt_dom0_max_vcpus);
 
-/* If true, the extended regions support is enabled for dom0 */
+/*
+ * If true, the extended regions support is enabled for dom0 and
+ * dom0less domUs.
+ */
 static bool __initdata opt_ext_regions = true;
 boolean_param("ext_regions", opt_ext_regions);
 
@@ -1327,6 +1330,36 @@ out:
     return res;
 }
 
+static int __init find_domU_holes(const struct kernel_info *kinfo,
+                                  struct meminfo *ext_regions)
+{
+    unsigned int i;
+    paddr_t bankend;
+    const paddr_t bankbase[] = GUEST_RAM_BANK_BASES;
+    const paddr_t banksize[] = GUEST_RAM_BANK_SIZES;
+    int res = -ENOENT;
+
+    for ( i = 0; i < GUEST_RAM_BANKS; i++ )
+    {
+        struct membank *ext_bank = &(ext_regions->bank[ext_regions->nr_banks]);
+
+        ext_bank->start = ROUNDUP(bankbase[i] + kinfo->mem.bank[i].size, SZ_2M);
+
+        bankend = ~0ULL >> (64 - p2m_ipa_bits);
+        bankend = min(bankend, bankbase[i] + banksize[i] - 1);
+        if ( bankend > ext_bank->start )
+            ext_bank->size = bankend - ext_bank->start + 1;
+
+        /* 64MB is the minimum size of an extended region */
+        if ( ext_bank->size < MB(64) )
+            continue;
+        ext_regions->nr_banks++;
+        res = 0;
+    }
+
+    return res;
+}
+
 static int __init make_hypervisor_node(struct domain *d,
                                        const struct kernel_info *kinfo,
                                        int addrcells, int sizecells)
@@ -1363,12 +1396,13 @@ static int __init make_hypervisor_node(struct domain *d,
 
     if ( !opt_ext_regions )
     {
-        printk(XENLOG_INFO "The extended regions support is disabled\n");
+        printk(XENLOG_INFO "%pd: extended regions support is disabled\n", d);
         nr_ext_regions = 0;
     }
     else if ( is_32bit_domain(d) )
     {
-        printk(XENLOG_WARNING "The extended regions are only supported for 64-bit guest currently\n");
+        printk(XENLOG_WARNING
+               "%pd: extended regions not supported for 32-bit guests\n", d);
         nr_ext_regions = 0;
     }
     else
@@ -1377,13 +1411,21 @@ static int __init make_hypervisor_node(struct domain *d,
         if ( !ext_regions )
             return -ENOMEM;
 
-        if ( !is_iommu_enabled(d) )
-            res = find_unallocated_memory(kinfo, ext_regions);
+        if ( is_domain_direct_mapped(d) )
+        {
+            if ( !is_iommu_enabled(d) )
+                res = find_unallocated_memory(kinfo, ext_regions);
+            else
+                res = find_memory_holes(kinfo, ext_regions);
+        }
         else
-            res = find_memory_holes(kinfo, ext_regions);
+        {
+            res = find_domU_holes(kinfo, ext_regions);
+        }
 
         if ( res )
-            printk(XENLOG_WARNING "Failed to allocate extended regions\n");
+            printk(XENLOG_WARNING "%pd: failed to allocate extended regions\n",
+                   d);
         nr_ext_regions = ext_regions->nr_banks;
     }
 
@@ -1404,8 +1446,8 @@ static int __init make_hypervisor_node(struct domain *d,
         u64 start = ext_regions->bank[i].start;
         u64 size = ext_regions->bank[i].size;
 
-        printk("Extended region %d: %#"PRIx64"->%#"PRIx64"\n",
-               i, start, start + size);
+        printk("%pd: extended region %d: %#"PRIx64"->%#"PRIx64"\n",
+               d, i, start, start + size);
 
         dt_child_set_range(&cells, addrcells, sizecells, start, size);
     }
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue May 24 23:22:25 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 24 May 2022 23:22:25 +0000
Received: from list by lists.xenproject.org with outflank-mailman.336764.561155 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ntdr7-0008Tv-Pm; Tue, 24 May 2022 23:22:25 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 336764.561155; Tue, 24 May 2022 23: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 1ntdr7-0008To-N1; Tue, 24 May 2022 23:22:25 +0000
Received: by outflank-mailman (input) for mailman id 336764;
 Tue, 24 May 2022 23:22: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 1ntdr6-0008Tg-V7
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23: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 1ntdr6-0002yN-UF
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23:22:24 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ntdr6-0003Sv-TI
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23: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=9mIoum7/ba8iiIDE1Lec2t5BkcddgBxsBZuI7rNwzIU=; b=WSAJjwFRZx4cr99RP3l/QgjIYa
	IBjF9CuXBwEPuI8W5DF1S2s6kDlCjT/NtSe7HLc11BhPOMiM3rD5PIY3s/ccLZdAE8fLggo0+i68D
	4KhuH9Dt+s8WKXOr03vg8oCctq1BG6p7OQUFFa+jo972QZkh6bCVUSxr2JoCTye7EBA8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen: introduce xen,enhanced dom0less property
Message-Id: <E1ntdr6-0003Sv-TI@xenbits.xenproject.org>
Date: Tue, 24 May 2022 23:22:24 +0000

commit 5eedfe77287981b40669272b6ac42f2d57cd9b32
Author:     Stefano Stabellini <stefano.stabellini@xilinx.com>
AuthorDate: Fri May 13 14:07:26 2022 -0700
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Tue May 24 16:16:42 2022 -0700

    xen: introduce xen,enhanced dom0less property
    
    Introduce a new "xen,enhanced" dom0less property to enable/disable PV
    driver interfaces for dom0less guests. Currently only "enabled" and
    "disabled" are supported property values (and empty). Leave the option
    open to implement further possible values in the future (e.g.
    "xenstore" to enable only xenstore.) Dom0 presence is required for now
    to use "xen,enhanced" on a domU.
    
    The configurable option is for domUs only. For dom0 we always set the
    corresponding property in the Xen code to true (PV interfaces enabled.)
    
    This patch only parses the property. Next patches will make use of it.
    
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    CC: Julien Grall <julien@xen.org>
    CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
    CC: Bertrand Marquis <bertrand.marquis@arm.com>
---
 docs/misc/arm/device-tree/booting.txt | 18 ++++++++++++++++++
 xen/arch/arm/domain_build.c           | 12 ++++++++++++
 xen/arch/arm/include/asm/kernel.h     |  3 +++
 3 files changed, 33 insertions(+)

diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-tree/booting.txt
index 7b4a29a2c2..98253414b8 100644
--- a/docs/misc/arm/device-tree/booting.txt
+++ b/docs/misc/arm/device-tree/booting.txt
@@ -193,6 +193,24 @@ with the following properties:
     Optional. Handle to a xen,cpupool device tree node that identifies the
     cpupool where the guest will be started at boot.
 
+- xen,enhanced
+
+    A string property. Possible property values are:
+
+    - "enabled" (or missing property value)
+    Xen PV interfaces, including grant-table and xenstore, will be
+    enabled for the VM.
+
+    - "disabled"
+    Xen PV interfaces are disabled.
+
+    If the xen,enhanced property is present with no value, it defaults
+    to "enabled". If the xen,enhanced property is not present, PV
+    interfaces are disabled.
+
+    In the future other possible property values might be added to
+    enable only selected interfaces.
+
 Under the "xen,domain" compatible node, one or more sub-nodes are present
 for the DomU kernel and ramdisk.
 
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index c4dd211b91..831f6f3af9 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -3157,6 +3157,7 @@ static int __init construct_domU(struct domain *d,
                                  const struct dt_device_node *node)
 {
     struct kernel_info kinfo = {};
+    const char *dom0less_enhanced;
     int rc;
     u64 mem;
 
@@ -3172,6 +3173,17 @@ static int __init construct_domU(struct domain *d,
 
     kinfo.vpl011 = dt_property_read_bool(node, "vpl011");
 
+    rc = dt_property_read_string(node, "xen,enhanced", &dom0less_enhanced);
+    if ( rc == -EILSEQ ||
+         rc == -ENODATA ||
+         (rc == 0 && !strcmp(dom0less_enhanced, "enabled")) )
+    {
+        if ( hardware_domain )
+            kinfo.dom0less_enhanced = true;
+        else
+            panic("Tried to use xen,enhanced without dom0\n");
+    }
+
     if ( vcpu_create(d, 0) == NULL )
         return -ENOMEM;
 
diff --git a/xen/arch/arm/include/asm/kernel.h b/xen/arch/arm/include/asm/kernel.h
index 874aa108a7..c4dc039b54 100644
--- a/xen/arch/arm/include/asm/kernel.h
+++ b/xen/arch/arm/include/asm/kernel.h
@@ -36,6 +36,9 @@ struct kernel_info {
     /* Enable pl011 emulation */
     bool vpl011;
 
+    /* Enable PV drivers */
+    bool dom0less_enhanced;
+
     /* GIC phandle */
     uint32_t phandle_gic;
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue May 24 23:22:35 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 24 May 2022 23:22:35 +0000
Received: from list by lists.xenproject.org with outflank-mailman.336765.561160 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ntdrH-00005q-Rs; Tue, 24 May 2022 23:22:35 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 336765.561160; Tue, 24 May 2022 23: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 1ntdrH-00005h-Oc; Tue, 24 May 2022 23:22:35 +0000
Received: by outflank-mailman (input) for mailman id 336765;
 Tue, 24 May 2022 23:22: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 1ntdrH-00005X-2L
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23:22: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 1ntdrH-0002yX-1a
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23:22:35 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ntdrH-0003Tp-0W
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23:22: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=5YzuRkyF4poGvmYTcZGGwMeivafZH+pX1GQaqgOwnNc=; b=jxd8CmjgpTFB986MZxLCHjugVm
	4MXX4FHSuGa6fcXbyQ1tIO+Bb5wHsJL9mfAFYAeCgnkIy1mprlVOPQdNLzZQyCZ4h5Qb4fs39/ah/
	xvRnmw15zA63ViK9Kg4dOqqnAt8rHaLm3asfmTYnT1PXX/TgZM5lidIMhQq1ckUS+YcE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/arm: configure dom0less domain for enabling xenstore after boot
Message-Id: <E1ntdrH-0003Tp-0W@xenbits.xenproject.org>
Date: Tue, 24 May 2022 23:22:35 +0000

commit 79eb2871f25ea4c44ba0e54362ad5a13d21b354f
Author:     Luca Miccio <lucmiccio@gmail.com>
AuthorDate: Fri May 13 14:07:27 2022 -0700
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Tue May 24 16:17:35 2022 -0700

    xen/arm: configure dom0less domain for enabling xenstore after boot
    
    Export evtchn_alloc_unbound and make it __must_check.
    
    If "xen,enhanced" is enabled, then add to dom0less domains:
    
    - the hypervisor node in device tree
    - the xenstore event channel
    
    The xenstore event channel is also used for the first notification to
    let the guest know that xenstore has become available.
    
    Signed-off-by: Luca Miccio <lucmiccio@gmail.com>
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    CC: Julien Grall <julien@xen.org>
    CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
    CC: Bertrand Marquis <bertrand.marquis@arm.com>
---
 xen/arch/arm/domain_build.c | 38 ++++++++++++++++++++++++++++++++++++++
 xen/common/event_channel.c  |  2 +-
 xen/include/xen/event.h     |  3 +++
 3 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 831f6f3af9..e7510dec90 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -27,6 +27,7 @@
 #include <asm/setup.h>
 #include <asm/cpufeature.h>
 #include <asm/domain_build.h>
+#include <xen/event.h>
 
 #include <xen/irq.h>
 #include <xen/grant_table.h>
@@ -2813,6 +2814,8 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo)
     int ret;
 
     kinfo->phandle_gic = GUEST_PHANDLE_GIC;
+    kinfo->gnttab_start = GUEST_GNTTAB_BASE;
+    kinfo->gnttab_size = GUEST_GNTTAB_SIZE;
 
     addrcells = GUEST_ROOT_ADDRESS_CELLS;
     sizecells = GUEST_ROOT_SIZE_CELLS;
@@ -2887,6 +2890,13 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo)
             goto err;
     }
 
+    if ( kinfo->dom0less_enhanced )
+    {
+        ret = make_hypervisor_node(d, kinfo, addrcells, sizecells);
+        if ( ret )
+            goto err;
+    }
+
     ret = fdt_end_node(kinfo->fdt);
     if ( ret < 0 )
         goto err;
@@ -3153,6 +3163,25 @@ static int __init construct_domain(struct domain *d, struct kernel_info *kinfo)
     return 0;
 }
 
+static int __init alloc_xenstore_evtchn(struct domain *d)
+{
+    evtchn_alloc_unbound_t alloc;
+    int rc;
+
+    alloc.dom = d->domain_id;
+    alloc.remote_dom = hardware_domain->domain_id;
+    rc = evtchn_alloc_unbound(&alloc);
+    if ( rc )
+    {
+        printk("Failed allocating event channel for domain\n");
+        return rc;
+    }
+
+    d->arch.hvm.params[HVM_PARAM_STORE_EVTCHN] = alloc.port;
+
+    return 0;
+}
+
 static int __init construct_domU(struct domain *d,
                                  const struct dt_device_node *node)
 {
@@ -3222,6 +3251,15 @@ static int __init construct_domU(struct domain *d,
     if ( rc < 0 )
         return rc;
 
+    if ( kinfo.dom0less_enhanced )
+    {
+        ASSERT(hardware_domain);
+        rc = alloc_xenstore_evtchn(d);
+        if ( rc < 0 )
+            return rc;
+        d->arch.hvm.params[HVM_PARAM_STORE_PFN] = ~0ULL;
+    }
+
     return rc;
 }
 
diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
index 0a82eb3ac2..e60cd98d75 100644
--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -290,7 +290,7 @@ void evtchn_free(struct domain *d, struct evtchn *chn)
     xsm_evtchn_close_post(chn);
 }
 
-static int evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc)
+int evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc)
 {
     struct evtchn *chn;
     struct domain *d;
diff --git a/xen/include/xen/event.h b/xen/include/xen/event.h
index 21c95e14fd..f3021fe304 100644
--- a/xen/include/xen/event.h
+++ b/xen/include/xen/event.h
@@ -71,6 +71,9 @@ void evtchn_free(struct domain *d, struct evtchn *chn);
 /* Allocate a specific event channel port. */
 int evtchn_allocate_port(struct domain *d, unsigned int port);
 
+/* Allocate a new event channel */
+int __must_check evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc);
+
 /* Unmask a local event-channel port. */
 int evtchn_unmask(unsigned int port);
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue May 24 23:22:46 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 24 May 2022 23:22:46 +0000
Received: from list by lists.xenproject.org with outflank-mailman.336766.561165 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ntdrS-00009P-Tb; Tue, 24 May 2022 23:22:46 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 336766.561165; Tue, 24 May 2022 23: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 1ntdrS-00009H-QD; Tue, 24 May 2022 23:22:46 +0000
Received: by outflank-mailman (input) for mailman id 336766;
 Tue, 24 May 2022 23: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 1ntdrR-00008x-5T
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23: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 1ntdrR-0002yj-4k
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23:22:45 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ntdrR-0003UO-3q
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23:22: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=kWxSqm2IGtg+2IYM8tDEnNW3rUQO/aUsAFmufJIMlyQ=; b=KopMH+K3eUJJOPju0udNUnm3c/
	nXXOr/yC9H2ynm0Pzw4oYtevGMbR5MGxNQ1rp+xyTIG4PU1+YuNI8S8sd4PYlVqs2vaQbqkzK5/zk
	/vg9G2xjizWDLoi18QDuDTXteu19LBqXiDPY3etRu8xKgvjOhsCvqPdFFKGt1V3T//UY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xenstored: send an evtchn notification on introduce_domain
Message-Id: <E1ntdrR-0003UO-3q@xenbits.xenproject.org>
Date: Tue, 24 May 2022 23:22:45 +0000

commit fc2b57c9af462d67df871b080c0897156a616b7d
Author:     Luca Miccio <lucmiccio@gmail.com>
AuthorDate: Fri May 13 14:07:28 2022 -0700
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Tue May 24 16:18:08 2022 -0700

    xenstored: send an evtchn notification on introduce_domain
    
    When xs_introduce_domain is called, send out a notification on the
    xenstore event channel so that any (dom0less) domain waiting for the
    xenstore interface to be ready can continue with the initialization.
    Before sending the notification, clear XENSTORE_RECONNECTING.
    
    The extra notification is harmless for domains that don't require it.
    
    In xs_wire.h update the commment on top of XENSTORE_RECONNECTING to
    generalize its meaning to suit the dom0less use-case better. Also
    improve docs/misc/xenstore-ring.txt.
    
    Signed-off-by: Luca Miccio <lucmiccio@gmail.com>
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
---
 docs/misc/xenstore-ring.txt       | 8 +++++++-
 tools/xenstore/xenstored_domain.c | 4 ++++
 xen/include/public/io/xs_wire.h   | 2 +-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/docs/misc/xenstore-ring.txt b/docs/misc/xenstore-ring.txt
index b338b21b19..f3d6ca4264 100644
--- a/docs/misc/xenstore-ring.txt
+++ b/docs/misc/xenstore-ring.txt
@@ -111,7 +111,13 @@ Assuming the server has advertised the feature, the guest can initiate
 a reconnection by setting the the Connection state to 1 ("Ring close
 and reconnect is in progress") and signalling the event channel.
 The guest must now ignore all fields except the Connection state and
-wait for it to be set to 0 ("Ring is connected")
+wait for it to be set to 0 ("Ring is connected").
+
+In certain circumstances (e.g. dom0less guests with PV drivers support)
+it is possible for the guest to find the Connection state already set to
+1 by someone else during xenstore initialization. In that case, like in
+the previous case, the guest must ignore all fields except the
+Connection state and wait for it to be set to 0 before proceeding.
 
 The server will guarantee to
 
diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
index 80ba1d627b..de88bf2a68 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -493,6 +493,10 @@ static struct domain *introduce_domain(const void *ctx,
 		/* Now domain belongs to its connection. */
 		talloc_steal(domain->conn, domain);
 
+		/* Notify the domain that xenstore is available */
+		interface->connection = XENSTORE_CONNECTED;
+		xenevtchn_notify(xce_handle, domain->port);
+
 		if (!is_master_domain && !restore)
 			fire_watches(NULL, ctx, "@introduceDomain", NULL,
 				     true, NULL);
diff --git a/xen/include/public/io/xs_wire.h b/xen/include/public/io/xs_wire.h
index 953a0050a3..c1ec7c73e3 100644
--- a/xen/include/public/io/xs_wire.h
+++ b/xen/include/public/io/xs_wire.h
@@ -141,7 +141,7 @@ struct xenstore_domain_interface {
 
 /* Valid values for the connection field */
 #define XENSTORE_CONNECTED 0 /* the steady-state */
-#define XENSTORE_RECONNECT 1 /* guest has initiated a reconnect */
+#define XENSTORE_RECONNECT 1 /* reconnect in progress */
 
 /* Valid values for the error field */
 #define XENSTORE_ERROR_NONE    0 /* No error */
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue May 24 23:22:56 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 24 May 2022 23:22:56 +0000
Received: from list by lists.xenproject.org with outflank-mailman.336767.561167 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ntdrc-0000Cn-V4; Tue, 24 May 2022 23:22:56 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 336767.561167; Tue, 24 May 2022 23: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 1ntdrc-0000Cf-Rr; Tue, 24 May 2022 23:22:56 +0000
Received: by outflank-mailman (input) for mailman id 336767;
 Tue, 24 May 2022 23:22: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 1ntdrb-0000C8-8g
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23:22: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 1ntdrb-0002yt-7q
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23:22:55 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ntdrb-0003Uv-6w
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23:22: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=PHsd4c+1oARQGIBh+/UwBcMIOGV5G1yNCFRb6GNSs1g=; b=XGv81TiFnxmTvMBYhBdzTQRUiB
	9TYQEfH+wYIAJeYsT5baaHfxLqQIc810emeKH1RgugsVL5sj5bmoAy3jjjWgEvaVn9tRg04RQ7v9N
	nSYNsPvZ2l04YYmgCk5O3ifqqRsrr0ATTO+wCvq0y75F6BXY/dV3Kzc1S3RAh358Uyx8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools: add example application to initialize dom0less PV drivers
Message-Id: <E1ntdrb-0003Uv-6w@xenbits.xenproject.org>
Date: Tue, 24 May 2022 23:22:55 +0000

commit ec53e0c4ea94c4442fe31e91170df4cca9f49fbe
Author:     Luca Miccio <lucmiccio@gmail.com>
AuthorDate: Fri May 13 14:07:29 2022 -0700
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Tue May 24 16:20:12 2022 -0700

    tools: add example application to initialize dom0less PV drivers
    
    Add an example application that can be run in dom0 to complete the
    dom0less domains initialization so that they can get access to xenstore
    and use PV drivers.
    
    The application sets "connection" to XENSTORE_RECONNECT on the xenstore
    page before calling xs_introduce_domain to signal that the connection is
    not ready yet to be used. XENSTORE_RECONNECT is reset soon after by
    xenstored.
    
    Signed-off-by: Luca Miccio <lucmiccio@gmail.com>
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    CC: Wei Liu <wl@xen.org>
    CC: Anthony PERARD <anthony.perard@citrix.com>
    CC: Juergen Gross <jgross@suse.com>
---
 tools/helpers/Makefile        |  13 ++
 tools/helpers/init-dom0less.c | 345 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 358 insertions(+)

diff --git a/tools/helpers/Makefile b/tools/helpers/Makefile
index 7f6c422440..8d78ab1e90 100644
--- a/tools/helpers/Makefile
+++ b/tools/helpers/Makefile
@@ -10,6 +10,9 @@ ifeq ($(CONFIG_Linux),y)
 ifeq ($(CONFIG_X86),y)
 PROGS += init-xenstore-domain
 endif
+ifeq ($(CONFIG_ARM),y)
+PROGS += init-dom0less
+endif
 endif
 
 XEN_INIT_DOM0_OBJS = xen-init-dom0.o init-dom-json.o
@@ -26,6 +29,13 @@ $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(CFLAGS_libxenstore)
 $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(CFLAGS_libxenlight)
 $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h
 
+INIT_DOM0LESS_OBJS = init-dom0less.o init-dom-json.o
+$(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxentoollog)
+$(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenstore)
+$(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenlight)
+$(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenctrl)
+$(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenevtchn)
+
 .PHONY: all
 all: $(PROGS)
 
@@ -35,6 +45,9 @@ xen-init-dom0: $(XEN_INIT_DOM0_OBJS)
 init-xenstore-domain: $(INIT_XENSTORE_DOMAIN_OBJS)
 	$(CC) $(LDFLAGS) -o $@ $(INIT_XENSTORE_DOMAIN_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenlight) $(APPEND_LDFLAGS)
 
+init-dom0less: $(INIT_DOM0LESS_OBJS)
+	$(CC) $(LDFLAGS) -o $@ $(INIT_DOM0LESS_OBJS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenevtchn) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(LDLIBS_libxenlight) $(LDLIBS_libxenguest) $(LDLIBS_libxenforeignmemory) $(APPEND_LDFLAGS)
+
 .PHONY: install
 install: all
 	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
diff --git a/tools/helpers/init-dom0less.c b/tools/helpers/init-dom0less.c
new file mode 100644
index 0000000000..42e74c4153
--- /dev/null
+++ b/tools/helpers/init-dom0less.c
@@ -0,0 +1,345 @@
+#include <stdbool.h>
+#include <syslog.h>
+#include <stdio.h>
+#include <err.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <xenstore.h>
+#include <xenctrl.h>
+#include <xenguest.h>
+#include <libxl.h>
+#include <xenevtchn.h>
+#include <xenforeignmemory.h>
+#include <xen/io/xs_wire.h>
+
+#include "init-dom-json.h"
+
+#define XENSTORE_PFN_OFFSET 1
+#define STR_MAX_LENGTH 128
+
+static int alloc_xs_page(struct xc_interface_core *xch,
+                         libxl_dominfo *info,
+                         uint64_t *xenstore_pfn)
+{
+    int rc;
+    const xen_pfn_t base = GUEST_MAGIC_BASE >> XC_PAGE_SHIFT;
+    xen_pfn_t p2m = (GUEST_MAGIC_BASE >> XC_PAGE_SHIFT) + XENSTORE_PFN_OFFSET;
+
+    rc = xc_domain_setmaxmem(xch, info->domid,
+                             info->max_memkb + (XC_PAGE_SIZE/1024));
+    if (rc < 0)
+        return rc;
+
+    rc = xc_domain_populate_physmap_exact(xch, info->domid, 1, 0, 0, &p2m);
+    if (rc < 0)
+        return rc;
+
+    *xenstore_pfn = base + XENSTORE_PFN_OFFSET;
+    rc = xc_clear_domain_page(xch, info->domid, *xenstore_pfn);
+    if (rc < 0)
+        return rc;
+
+    return 0;
+}
+
+static bool do_xs_write_dom(struct xs_handle *xsh, xs_transaction_t t,
+                            domid_t domid, char *path, char *val)
+{
+    char full_path[STR_MAX_LENGTH];
+    struct xs_permissions perms[2];
+
+    perms[0].id = domid;
+    perms[0].perms = XS_PERM_NONE;
+    perms[1].id = 0;
+    perms[1].perms = XS_PERM_READ;
+
+    if (snprintf(full_path, STR_MAX_LENGTH,
+                 "/local/domain/%u/%s", domid, path) < 0)
+        return false;
+    if (!xs_write(xsh, t, full_path, val, strlen(val)))
+        return false;
+    return xs_set_permissions(xsh, t, full_path, perms, 2);
+}
+
+static bool do_xs_write_libxl(struct xs_handle *xsh, xs_transaction_t t,
+                              domid_t domid, char *path, char *val)
+{
+    char full_path[STR_MAX_LENGTH];
+
+    if (snprintf(full_path, STR_MAX_LENGTH,
+                 "/libxl/%u/%s", domid, path) < 0)
+        return false;
+    return xs_write(xsh, t, full_path, val, strlen(val));
+}
+
+static bool do_xs_write_vm(struct xs_handle *xsh, xs_transaction_t t,
+                           libxl_uuid uuid, char *path, char *val)
+{
+    char full_path[STR_MAX_LENGTH];
+
+    if (snprintf(full_path, STR_MAX_LENGTH,
+                 "/vm/" LIBXL_UUID_FMT "/%s", LIBXL_UUID_BYTES(uuid), path) < 0)
+        return false;
+    return xs_write(xsh, t, full_path, val, strlen(val));
+}
+
+/*
+ * The xenstore nodes are the xenstore nodes libxl writes at domain
+ * creation.
+ *
+ * The list was retrieved by running xenstore-ls on a corresponding
+ * domain started by xl/libxl.
+ */
+static int create_xenstore(struct xs_handle *xsh,
+                           libxl_dominfo *info, libxl_uuid uuid,
+                           evtchn_port_t xenstore_port)
+{
+    domid_t domid;
+    unsigned int i;
+    char uuid_str[STR_MAX_LENGTH];
+    char dom_name_str[STR_MAX_LENGTH];
+    char vm_val_str[STR_MAX_LENGTH];
+    char id_str[STR_MAX_LENGTH];
+    char max_memkb_str[STR_MAX_LENGTH];
+    char target_memkb_str[STR_MAX_LENGTH];
+    char cpu_str[STR_MAX_LENGTH];
+    char xenstore_port_str[STR_MAX_LENGTH];
+    char ring_ref_str[STR_MAX_LENGTH];
+    xs_transaction_t t;
+    struct timeval start_time;
+    char start_time_str[STR_MAX_LENGTH];
+    int rc;
+
+    if (gettimeofday(&start_time, NULL) < 0)
+        return -errno;
+    rc = snprintf(start_time_str, STR_MAX_LENGTH, "%jd.%02d",
+            (intmax_t)start_time.tv_sec, (int)start_time.tv_usec / 10000);
+    if (rc < 0)
+        return rc;
+
+    domid = info->domid;
+    rc = snprintf(id_str, STR_MAX_LENGTH, "%u", domid);
+    if (rc < 0)
+        return rc;
+    rc = snprintf(dom_name_str, STR_MAX_LENGTH, "dom0less-%u", domid);
+    if (rc < 0)
+        return rc;
+    rc = snprintf(uuid_str, STR_MAX_LENGTH, LIBXL_UUID_FMT, LIBXL_UUID_BYTES(uuid));
+    if (rc < 0)
+        return rc;
+    rc = snprintf(vm_val_str, STR_MAX_LENGTH,
+                  "vm/" LIBXL_UUID_FMT, LIBXL_UUID_BYTES(uuid));
+    if (rc < 0)
+        return rc;
+    rc = snprintf(max_memkb_str, STR_MAX_LENGTH, "%lu", info->max_memkb);
+    if (rc < 0)
+        return rc;
+    rc = snprintf(target_memkb_str, STR_MAX_LENGTH, "%lu", info->current_memkb);
+    if (rc < 0)
+        return rc;
+    rc = snprintf(ring_ref_str, STR_MAX_LENGTH, "%lld",
+                  (GUEST_MAGIC_BASE >> XC_PAGE_SHIFT) + XENSTORE_PFN_OFFSET);
+    if (rc < 0)
+        return rc;
+    rc = snprintf(xenstore_port_str, STR_MAX_LENGTH, "%u", xenstore_port);
+    if (rc < 0)
+        return rc;
+
+retry_transaction:
+    t = xs_transaction_start(xsh);
+    if (t == XBT_NULL)
+        return -errno;
+
+    rc = -EIO;
+    /* /vm */
+    if (!do_xs_write_vm(xsh, t, uuid, "name", dom_name_str)) goto err;
+    if (!do_xs_write_vm(xsh, t, uuid, "uuid", uuid_str)) goto err;
+    if (!do_xs_write_vm(xsh, t, uuid, "start_time", start_time_str)) goto err;
+
+    /* /domain */
+    if (!do_xs_write_dom(xsh, t, domid, "vm", vm_val_str)) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "name", dom_name_str)) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "cpu", "")) goto err;
+    for (i = 0; i < info->vcpu_max_id; i++) {
+        rc = snprintf(cpu_str, STR_MAX_LENGTH, "cpu/%u/availability/", i);
+        if (rc < 0)
+            goto err;
+        rc = -EIO;
+        if (!do_xs_write_dom(xsh, t, domid, cpu_str,
+                             (info->cpupool & (1 << i)) ? "online" : "offline"))
+            goto err;
+    }
+
+    if (!do_xs_write_dom(xsh, t, domid, "memory", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "memory/static-max", max_memkb_str)) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "memory/target", target_memkb_str)) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "memory/videoram", "-1")) goto err;
+
+    if (!do_xs_write_dom(xsh, t, domid, "device", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "device/suspend", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "device/suspend/event-channel", "")) goto err;
+
+    if (!do_xs_write_dom(xsh, t, domid, "control", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "control/shutdown", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "control/feature-poweroff", "1")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "control/feature-reboot", "1")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "control/feature-suspend", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "control/sysrq", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "control/platform-feature-multiprocessor-suspend", "1")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "control/platform-feature-xs_reset_watches", "1")) goto err;
+
+    if (!do_xs_write_dom(xsh, t, domid, "domid", id_str)) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "data", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "drivers", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "feature", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "attr", "")) goto err;
+
+    if (!do_xs_write_dom(xsh, t, domid, "store/port", xenstore_port_str)) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "store/ring-ref", ring_ref_str)) goto err;
+
+    if (!do_xs_write_libxl(xsh, t, domid, "type", "pvh")) goto err;
+    if (!do_xs_write_libxl(xsh, t, domid, "dm-version", "qemu_xen")) goto err;
+
+    if (!xs_transaction_end(xsh, t, false)) {
+        if (errno == EAGAIN)
+            goto retry_transaction;
+        else
+            return -errno;
+    }
+
+    return 0;
+
+err:
+    xs_transaction_end(xsh, t, true);
+    return rc;
+}
+
+static int init_domain(struct xs_handle *xsh,
+                       struct xc_interface_core *xch,
+                       xenforeignmemory_handle *xfh,
+                       libxl_dominfo *info)
+{
+    libxl_uuid uuid;
+    uint64_t xenstore_evtchn, xenstore_pfn;
+    int rc;
+    struct xenstore_domain_interface *intf;
+
+    printf("Init dom0less domain: %u\n", info->domid);
+
+    rc = xc_hvm_param_get(xch, info->domid, HVM_PARAM_STORE_EVTCHN,
+                          &xenstore_evtchn);
+    if (rc != 0) {
+        printf("Failed to get HVM_PARAM_STORE_EVTCHN\n");
+        return 1;
+    }
+
+    /* no xen,enhanced; nothing to do */
+    if (!xenstore_evtchn)
+        return 0;
+
+    /* Alloc xenstore page */
+    if (alloc_xs_page(xch, info, &xenstore_pfn) != 0) {
+        printf("Error on alloc magic pages\n");
+        return 1;
+    }
+
+    intf = xenforeignmemory_map(xfh, info->domid, PROT_READ | PROT_WRITE, 1,
+                                &xenstore_pfn, NULL);
+    if (!intf) {
+        printf("Error mapping xenstore page\n");
+        return 1;
+    }
+    intf->connection = XENSTORE_RECONNECT;
+    xenforeignmemory_unmap(xfh, intf, 1);
+
+    rc = xc_dom_gnttab_seed(xch, info->domid, true,
+                            (xen_pfn_t)-1, xenstore_pfn, 0, 0);
+    if (rc)
+        err(1, "xc_dom_gnttab_seed");
+
+    libxl_uuid_generate(&uuid);
+    xc_domain_sethandle(xch, info->domid, libxl_uuid_bytearray(&uuid));
+
+    rc = gen_stub_json_config(info->domid, &uuid);
+    if (rc)
+        err(1, "gen_stub_json_config");
+
+    /* Now everything is ready: set HVM_PARAM_STORE_PFN */
+    rc = xc_hvm_param_set(xch, info->domid, HVM_PARAM_STORE_PFN,
+                          xenstore_pfn);
+    if (rc < 0)
+        return rc;
+
+    rc = create_xenstore(xsh, info, uuid, xenstore_evtchn);
+    if (rc)
+        err(1, "writing to xenstore");
+
+    rc = xs_introduce_domain(xsh, info->domid,
+            (GUEST_MAGIC_BASE >> XC_PAGE_SHIFT) + XENSTORE_PFN_OFFSET,
+            xenstore_evtchn);
+    if (!rc)
+        err(1, "xs_introduce_domain");
+    return 0;
+}
+
+/* Check if domain has been configured in XS */
+static bool domain_exists(struct xs_handle *xsh, int domid)
+{
+    return xs_is_domain_introduced(xsh, domid);
+}
+
+int main(int argc, char **argv)
+{
+    libxl_dominfo *info = NULL;
+    libxl_ctx *ctx;
+    int nb_vm = 0, rc = 0, i;
+    struct xs_handle *xsh = NULL;
+    struct xc_interface_core *xch = NULL;
+    xenforeignmemory_handle *xfh = NULL;
+
+    /* TODO reuse libxl xsh connection */
+    xsh = xs_open(0);
+    xch = xc_interface_open(0, 0, 0);
+    xfh = xenforeignmemory_open(0, 0);
+    if (xsh == NULL || xch == NULL || xfh == NULL) {
+        fprintf(stderr, "Cannot open xc/xs/xenforeignmemory interfaces");
+        rc = -errno;
+        goto out;
+    }
+
+    rc = libxl_ctx_alloc(&ctx, LIBXL_VERSION, 0, NULL);
+    if (rc) {
+        fprintf(stderr, "cannot init xl context\n");
+        goto out;
+    }
+
+    info = libxl_list_domain(ctx, &nb_vm);
+    if (!info) {
+        fprintf(stderr, "libxl_list_vm failed.\n");
+        rc = -1;
+        goto out;
+    }
+
+    for (i = 0; i < nb_vm; i++) {
+        domid_t domid = info[i].domid;
+
+        /* Don't need to check for Dom0 */
+        if (!domid)
+            continue;
+
+        printf("Checking domid: %u\n", domid);
+        if (!domain_exists(xsh, domid)) {
+            rc = init_domain(xsh, xch, xfh, &info[i]);
+            if (rc < 0) {
+                fprintf(stderr, "init_domain failed.\n");
+                goto out;
+            }
+        } else {
+            printf("Domain %u has already been initialized\n", domid);
+        }
+    }
+out:
+    libxl_dominfo_list_free(info, nb_vm);
+    return rc;
+}
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Tue May 24 23:44:08 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 24 May 2022 23:44:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.336792.561204 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nteC6-00041O-A9; Tue, 24 May 2022 23:44:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 336792.561204; Tue, 24 May 2022 23:44: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 1nteC6-00041G-7J; Tue, 24 May 2022 23:44:06 +0000
Received: by outflank-mailman (input) for mailman id 336792;
 Tue, 24 May 2022 23: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 1nteC5-000415-3w
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23: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 1nteC5-0003KI-0y
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23:44:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nteC4-0004oV-W4
 for xen-changelog@lists.xenproject.org; Tue, 24 May 2022 23: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=ZhKp5wdZ2egR9+dYfLMnFVS6ZAIXrNootP2e7QO9fsU=; b=SKS+vhCHYAw07kZ26PfqOOUyPz
	JdpC66e2u1qvqJ+RG4yo0RSFvVIUT/10SfsgT2b5r70qxloxyRFtn8xtGUGEn7mUOZokJyblmbaIJ
	ae8pvcEDPDVOTOBS8X6vkMgIsXZ+Bb6YvICNg/id5JPf6WI7hEmlMsEz+0+819ni12ak=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/arm: setup: nr_banks should be unsigned int
Message-Id: <E1nteC4-0004oV-W4@xenbits.xenproject.org>
Date: Tue, 24 May 2022 23:44:04 +0000

commit 49399b101e38fb2c11478c849ffdaaace8e318a8
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Tue May 24 16:38:15 2022 -0700
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Tue May 24 16:40:19 2022 -0700

    xen/arm: setup: nr_banks should be unsigned int
    
    It is not possible to have a negative number of banks. So switch to
    unsigned int.
    
    The type change is also propagated to any users of nr_banks that were
    using "int" (there are not that many).
    
    Note that fdt_num_mem_rsv() can actually returns a negative value in
    case of an error. So the return should be checked before assigning the
    result to an unsigned variable.
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Wei Chen <Wei.Chen@arm.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 xen/arch/arm/domain_build.c      |  9 +++++----
 xen/arch/arm/efi/efi-dom0.c      |  4 ++--
 xen/arch/arm/include/asm/setup.h |  6 +++---
 xen/arch/arm/setup.c             | 17 +++++++++++++----
 4 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index e7510dec90..7ddd16c26d 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -115,7 +115,8 @@ static bool __init insert_11_bank(struct domain *d,
                                   struct page_info *pg,
                                   unsigned int order)
 {
-    int res, i;
+    unsigned int i;
+    int res;
     mfn_t smfn;
     paddr_t start, size;
 
@@ -268,7 +269,7 @@ static void __init allocate_memory_11(struct domain *d,
     const unsigned int min_order = get_order_from_bytes(MB(4));
     struct page_info *pg;
     unsigned int order = get_allocation_size(kinfo->unassigned_mem);
-    int i;
+    unsigned int i;
 
     bool lowmem = true;
     unsigned int lowmem_bitsize = min(32U, arch_get_dma_bitsize());
@@ -1026,8 +1027,8 @@ static int __init make_memory_node(const struct domain *d,
                                    int addrcells, int sizecells,
                                    struct meminfo *mem)
 {
-    int res, i;
-    int reg_size = addrcells + sizecells;
+    unsigned int i;
+    int res, reg_size = addrcells + sizecells;
     int nr_cells = 0;
     /* Placeholder for memory@ + a 64-bit number + \0 */
     char buf[24];
diff --git a/xen/arch/arm/efi/efi-dom0.c b/xen/arch/arm/efi/efi-dom0.c
index 494420eaa2..aae0f97911 100644
--- a/xen/arch/arm/efi/efi-dom0.c
+++ b/xen/arch/arm/efi/efi-dom0.c
@@ -34,14 +34,14 @@
 /* Constant to indicate "Xen" in unicode u16 format */
 static const CHAR16 xen_efi_fw_vendor[] = {0x0058, 0x0065, 0x006E, 0x0000};
 
-size_t __init estimate_efi_size(int mem_nr_banks)
+size_t __init estimate_efi_size(unsigned int mem_nr_banks)
 {
     size_t size;
     size_t est_size = sizeof(EFI_SYSTEM_TABLE);
     size_t ect_size = sizeof(EFI_CONFIGURATION_TABLE);
     size_t emd_size = sizeof(EFI_MEMORY_DESCRIPTOR);
     size_t fw_vendor_size = sizeof(xen_efi_fw_vendor);
-    int acpi_mem_nr_banks = 0;
+    unsigned int acpi_mem_nr_banks = 0;
 
     if ( !acpi_disabled )
         acpi_mem_nr_banks = bootinfo.acpi.nr_banks;
diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/setup.h
index 7a1e1d6798..2bb01ecfa8 100644
--- a/xen/arch/arm/include/asm/setup.h
+++ b/xen/arch/arm/include/asm/setup.h
@@ -30,7 +30,7 @@ struct membank {
 };
 
 struct meminfo {
-    int nr_banks;
+    unsigned int nr_banks;
     struct membank bank[NR_MEM_BANKS];
 };
 
@@ -93,7 +93,7 @@ extern domid_t max_init_domid;
 
 void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len);
 
-size_t estimate_efi_size(int mem_nr_banks);
+size_t estimate_efi_size(unsigned int mem_nr_banks);
 
 void acpi_create_efi_system_table(struct domain *d,
                                   struct membank tbl_add[]);
@@ -109,7 +109,7 @@ void create_dom0(void);
 
 void discard_initial_modules(void);
 void fw_unreserved_regions(paddr_t s, paddr_t e,
-                           void (*cb)(paddr_t, paddr_t), int first);
+                           void (*cb)(paddr_t, paddr_t), unsigned int first);
 
 size_t boot_fdt_info(const void *fdt, paddr_t paddr);
 const char *boot_fdt_cmdline(const void *fdt);
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index d5d0792ed4..ea1f5ee3d3 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -201,9 +201,17 @@ static void __init processor_id(void)
 
 static void __init dt_unreserved_regions(paddr_t s, paddr_t e,
                                          void (*cb)(paddr_t, paddr_t),
-                                         int first)
+                                         unsigned int first)
 {
-    int i, nr = fdt_num_mem_rsv(device_tree_flattened);
+    unsigned int i, nr;
+    int rc;
+
+    rc = fdt_num_mem_rsv(device_tree_flattened);
+    if ( rc < 0 )
+        panic("Unable to retrieve the number of reserved regions (rc=%d)\n",
+              rc);
+
+    nr = rc;
 
     for ( i = first; i < nr ; i++ )
     {
@@ -249,7 +257,8 @@ static void __init dt_unreserved_regions(paddr_t s, paddr_t e,
 }
 
 void __init fw_unreserved_regions(paddr_t s, paddr_t e,
-                                  void (*cb)(paddr_t, paddr_t), int first)
+                                  void (*cb)(paddr_t, paddr_t),
+                                  unsigned int first)
 {
     if ( acpi_disabled )
         dt_unreserved_regions(s, e, cb, first);
@@ -643,7 +652,7 @@ static void __init setup_mm(void)
     paddr_t s, e;
     unsigned long ram_pages;
     unsigned long heap_pages, xenheap_pages, domheap_pages;
-    int i;
+    unsigned int i;
     const uint32_t ctr = READ_CP32(CTR);
 
     if ( !bootinfo.mem.nr_banks )
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed May 25 08:55:09 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 25 May 2022 08:55:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337051.561526 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ntmnJ-0006zl-Hk; Wed, 25 May 2022 08:55:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337051.561526; Wed, 25 May 2022 08: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 1ntmnJ-0006zd-Ex; Wed, 25 May 2022 08:55:05 +0000
Received: by outflank-mailman (input) for mailman id 337051;
 Wed, 25 May 2022 08: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 1ntmnI-0006zX-Je
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 08: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 1ntmnI-0004V6-It
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 08:55:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ntmnI-0007M8-Ho
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 08: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=p4AoBAe8SIxsquKKOslkQpOwDLjRTuW8gGwhLdsJhqA=; b=23kGtIC6qCruPKRrpMu6Ej5nDF
	ELiv08iVD+/iGNYq/0tv9wXu5D83jueGrKBhO88YGJK2AQPtOzFthLKb8TIL7ws85Frp3CTQxM0ra
	sPM29LdUJtBvlVnDXlrCsu2kbE2+baL23Y23TEv0fD0b5802BgI1c8ih35m2ZPcHVF1k=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] xen/iommu: dt: Check the return value of xsm_deassign_dtdevice()
Message-Id: <E1ntmnI-0007M8-Ho@xenbits.xenproject.org>
Date: Wed, 25 May 2022 08:55:04 +0000

commit b22db3fcba1a5b4f9e563b58d402f1d5c434209f
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Wed May 25 09:52:38 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Wed May 25 09:52:59 2022 +0100

    xen/iommu: dt: Check the return value of xsm_deassign_dtdevice()
    
    xsm_deassign_dtdevice() will indicate whether the caller is allowed
    to issue the operation. So the return value has to be checked.
    
    Spotted by clang static analyzer.
    
    Fixes: fe36cccc483c ("xen/passthrough: Extend XEN_DOMCTL_*assign_device to support DT device")
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Michal Orzel <michal.orzel@arm.com>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
---
 xen/drivers/passthrough/device_tree.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c
index 98f2aa0dad..1c32d7b50c 100644
--- a/xen/drivers/passthrough/device_tree.c
+++ b/xen/drivers/passthrough/device_tree.c
@@ -269,6 +269,8 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, struct domain *d,
             break;
 
         ret = xsm_deassign_dtdevice(XSM_HOOK, d, dt_node_full_name(dev));
+        if ( ret )
+            break;
 
         if ( d == dom_io )
             return -EINVAL;
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed May 25 09:11:08 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 25 May 2022 09:11:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337061.561541 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ntn2o-00010A-2Q; Wed, 25 May 2022 09:11:06 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337061.561541; Wed, 25 May 2022 09:11: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 1ntn2n-000103-Vo; Wed, 25 May 2022 09:11:05 +0000
Received: by outflank-mailman (input) for mailman id 337061;
 Wed, 25 May 2022 09:11: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 1ntn2n-0000zx-3c
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 09:11: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 1ntn2n-0004q0-0c
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 09:11:05 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ntn2m-000094-Vv
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 09: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=MUR4zF4TQGgiKK8PnYNW/wM8N7GwTLjZdYRGBoZ9tgI=; b=mc+Sh9L554gV+Y0CDcMgD+L01k
	06VI49jW70z2cSb2ZUakVAQeYj1bw3LWnJ4mGWyuJlHnxLCVMrTE0/FaPo+BCztbTNGeLWLvoKI7X
	qEbG1LI34mQHWD9BUkvDgFD/hZ4saWdHjjTdUVl/UNRoJ7lgnnzPWBG6QirHFAv6h1d4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xl: sort create command options
Message-Id: <E1ntn2m-000094-Vv@xenbits.xenproject.org>
Date: Wed, 25 May 2022 09:11:04 +0000

commit f64c55b2f1b67c4d5e53146a7940707cb7671cee
Author:     Elliott Mitchell <ehem+xen@m5p.com>
AuthorDate: Wed May 25 11:07:17 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 25 11:07:17 2022 +0200

    tools/xl: sort create command options
    
    Hopefully simplify future changes by sorting options lists for
    `xl create`.  While at it, declare the options list constant.
    
    Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/xl/xl_cmdtable.c  | 12 ++++++------
 tools/xl/xl_vmcontrol.c | 40 ++++++++++++++++++++--------------------
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index 661323d488..35182ca196 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -24,16 +24,16 @@ const struct cmd_spec cmd_table[] = {
       &main_create, 1, 1,
       "Create a domain from config file <filename>",
       "<ConfigFile> [options] [vars]",
-      "-h                      Print this help.\n"
-      "-p                      Leave the domain paused after it is created.\n"
       "-c                      Connect to the console after the domain is created.\n"
+      "-d                      Enable debug messages.\n"
+      "-e                      Do not wait in the background for the death of the domain.\n"
+      "-F                      Run in foreground until death of the domain.\n"
       "-f FILE, --defconfig=FILE\n                     Use the given configuration file.\n"
-      "-q, --quiet             Quiet.\n"
+      "-h                      Print this help.\n"
       "-n, --dryrun            Dry run - prints the resulting configuration\n"
       "                         (deprecated in favour of global -N option).\n"
-      "-d                      Enable debug messages.\n"
-      "-F                      Run in foreground until death of the domain.\n"
-      "-e                      Do not wait in the background for the death of the domain.\n"
+      "-p                      Leave the domain paused after it is created.\n"
+      "-q, --quiet             Quiet.\n"
       "-V, --vncviewer         Connect to the VNC display after the domain is created.\n"
       "-A, --vncviewer-autopass\n"
       "                        Pass VNC password to viewer via stdin.\n"
diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c
index 435155a033..d081c6c290 100644
--- a/tools/xl/xl_vmcontrol.c
+++ b/tools/xl/xl_vmcontrol.c
@@ -1169,13 +1169,13 @@ int main_create(int argc, char **argv)
     int paused = 0, debug = 0, daemonize = 1, console_autoconnect = 0,
         quiet = 0, monitor = 1, vnc = 0, vncautopass = 0, ignore_masks = 0;
     int opt, rc;
-    static struct option opts[] = {
+    static const struct option opts[] = {
+        {"defconfig", 1, 0, 'f'},
         {"dryrun", 0, 0, 'n'},
+        {"ignore-global-affinity-masks", 0, 0, 'i'},
         {"quiet", 0, 0, 'q'},
-        {"defconfig", 1, 0, 'f'},
         {"vncviewer", 0, 0, 'V'},
         {"vncviewer-autopass", 0, 0, 'A'},
-        {"ignore-global-affinity-masks", 0, 0, 'i'},
         COMMON_LONG_OPTS
     };
 
@@ -1186,12 +1186,15 @@ int main_create(int argc, char **argv)
         argc--; argv++;
     }
 
-    SWITCH_FOREACH_OPT(opt, "Fnqf:pcdeVAi", opts, "create", 0) {
-    case 'f':
-        filename = optarg;
+    SWITCH_FOREACH_OPT(opt, "AFVcdef:inpq", opts, "create", 0) {
+    case 'A':
+        vnc = vncautopass = 1;
         break;
-    case 'p':
-        paused = 1;
+    case 'F':
+        daemonize = 0;
+        break;
+    case 'V':
+        vnc = 1;
         break;
     case 'c':
         console_autoconnect = 1;
@@ -1199,28 +1202,25 @@ int main_create(int argc, char **argv)
     case 'd':
         debug = 1;
         break;
-    case 'F':
-        daemonize = 0;
-        break;
     case 'e':
         daemonize = 0;
         monitor = 0;
         break;
+    case 'f':
+        filename = optarg;
+        break;
+    case 'i':
+        ignore_masks = 1;
+        break;
     case 'n':
         dryrun_only = 1;
         break;
+    case 'p':
+        paused = 1;
+        break;
     case 'q':
         quiet = 1;
         break;
-    case 'V':
-        vnc = 1;
-        break;
-    case 'A':
-        vnc = vncautopass = 1;
-        break;
-    case 'i':
-        ignore_masks = 1;
-        break;
     }
 
     memset(&dom_info, 0, sizeof(dom_info));
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed May 25 09:11:16 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 25 May 2022 09:11:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337062.561546 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ntn2y-000125-4B; Wed, 25 May 2022 09:11:16 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337062.561546; Wed, 25 May 2022 09:11: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 1ntn2y-00011y-1G; Wed, 25 May 2022 09:11:16 +0000
Received: by outflank-mailman (input) for mailman id 337062;
 Wed, 25 May 2022 09:11: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 1ntn2x-00011m-4W
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 09:11: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 1ntn2x-0004qR-3p
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 09:11:15 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ntn2x-0000A2-2n
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 09:11: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=cE4YSnmTuYF7Y8/wZr9elavLaNdlCk22dlzweKyFlDA=; b=T6RHzsCyIjX3fAva1Bv8DWFGHn
	IkXZH5FKJpnW2MkNSF4ghPF7AkBWs6ymXUvmAXih9lZgcIniksREW1YH8Kh3kkIqvz6jmL/12Babp
	03GhhPvU2BdyNnoFoGmv5L80dYadVqlIXChkmXJUV2SFyVC1Zkj8IG5VHjwM4gM2dT+Y=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] build: fix make warning if there is no cppcheck
Message-Id: <E1ntn2x-0000A2-2n@xenbits.xenproject.org>
Date: Wed, 25 May 2022 09:11:15 +0000

commit 890b23a43345785aafd5e55ccd91a80d3ad76f36
Author:     Bertrand Marquis <bertrand.marquis@arm.com>
AuthorDate: Wed May 25 11:07:46 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 25 11:07:46 2022 +0200

    build: fix make warning if there is no cppcheck
    
    If cppcheck is not present, the following warning appears during build:
    which: no cppcheck in ([...])
    /bin/sh: cppcheck: command not found
    
    Fix the problem by using shell code inside the cppcheck-version rule to
    also prevent unneeded call of which when something else than cppcheck is
    built.
    
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/Makefile | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/xen/Makefile b/xen/Makefile
index 15388703bc..82f5310b12 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -694,12 +694,14 @@ $(objtree)/%.c.cppcheck: $(srctree)/%.c $(objtree)/include/generated/autoconf.h
 	$(call if_changed,cppcheck_xml)
 
 cppcheck-version:
-ifeq ($(shell which $(CPPCHECK)),)
-	$(error Cannot find cppcheck executable: $(CPPCHECK))
-endif
-ifeq ($(shell $(CPPCHECK) --version | awk '{print ($$2 < 2.7)}'),1)
-	$(error Please upgrade your cppcheck to version 2.7 or greater)
-endif
+	$(Q)if ! which $(CPPCHECK) > /dev/null 2>&1; then \
+		echo "Cannot find cppcheck executable: $(CPPCHECK)"; \
+		exit 1; \
+	fi
+	$(Q)if [ "$$($(CPPCHECK) --version | awk '{print ($$2 < 2.7)}')" -eq 1 ]; then \
+		echo "Please upgrade your cppcheck to version 2.7 or greater"; \
+		exit 1; \
+	fi
 
 # Put this in generated headers this way it is cleaned by include/Makefile
 $(objtree)/include/generated/compiler-def.h:
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed May 25 09:11:26 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 25 May 2022 09:11:26 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337063.561550 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ntn38-00015F-5n; Wed, 25 May 2022 09:11:26 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337063.561550; Wed, 25 May 2022 09: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 1ntn38-000156-2m; Wed, 25 May 2022 09:11:26 +0000
Received: by outflank-mailman (input) for mailman id 337063;
 Wed, 25 May 2022 09:11: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 1ntn37-00014v-7v
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 09:11: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 1ntn37-0004qb-7B
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 09:11:25 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ntn37-0000An-6J
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 09:11: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=iKRSLsw3HY0D4eUUHmQLr6UMwnLpr13AHRsf5TShJxU=; b=cTxU+4N0fNCvH4wwwBvK79w5DS
	ciooBSaBHGvGz6WQ1RybIQlL0pd0sEk1xxKILgPQu9Z9RTuYsrTUXHkZhOBrXobQw1gcG2vZOrPZn
	PJBUttZXZLJhFXNSbQCIPB/2ak//lPxupLxE2oRg3c6K6S7KR8wsrIhoOnu1NjhF6Bw4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/mm: rename FLUSH_FORCE_IPI to FLUSH_NO_ASSIST
Message-Id: <E1ntn37-0000An-6J@xenbits.xenproject.org>
Date: Wed, 25 May 2022 09:11:25 +0000

commit 54e3d5e0fb880ed990695573f4a4f59a60187bf0
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Wed May 25 11:08:28 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 25 11:08:28 2022 +0200

    x86/mm: rename FLUSH_FORCE_IPI to FLUSH_NO_ASSIST
    
    Rename the flag to better note that it's not actually forcing any IPIs
    to be issued if none is required, but merely avoiding the usage of TLB
    flush assistance (which itself can avoid the sending of IPIs to remote
    processors).
    
    No functional change expected.
    
    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/include/asm/flushtlb.h | 16 ++++++++--------
 xen/arch/x86/mm.c                   |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/include/asm/flushtlb.h b/xen/arch/x86/include/asm/flushtlb.h
index 18777f1d4c..a461ee36ff 100644
--- a/xen/arch/x86/include/asm/flushtlb.h
+++ b/xen/arch/x86/include/asm/flushtlb.h
@@ -128,13 +128,12 @@ void switch_cr3_cr4(unsigned long cr3, unsigned long cr4);
 #endif
 #if defined(CONFIG_PV) || defined(CONFIG_SHADOW_PAGING)
 /*
- * Force an IPI to be sent. Note that adding this to the flags passed to
- * flush_area_mask will prevent using the assisted flush without having any
- * other side effect.
+ * Adding this to the flags passed to flush_area_mask will prevent using the
+ * assisted flush without having any other side effect.
  */
-# define FLUSH_FORCE_IPI 0x8000
+# define FLUSH_NO_ASSIST 0x8000
 #else
-# define FLUSH_FORCE_IPI 0
+# define FLUSH_NO_ASSIST 0
 #endif
 
 /* Flush local TLBs/caches. */
@@ -162,11 +161,12 @@ void flush_area_mask(const cpumask_t *, const void *va, unsigned int flags);
     flush_area_mask(mask, (const void *)(v), FLUSH_TLB|FLUSH_ORDER(0))
 
 /*
- * Make the common code TLB flush helper force use of an IPI in order to be
- * on the safe side. Note that not all calls from common code strictly require
+ * Make the common code TLB flush helper disallow the usage of any flush
+ * assistance in order to be on the safe side and interrupt remote processors
+ * requiring a flush. Note that not all calls from common code strictly require
  * this.
  */
-#define arch_flush_tlb_mask(mask) flush_mask(mask, FLUSH_TLB | FLUSH_FORCE_IPI)
+#define arch_flush_tlb_mask(mask) flush_mask(mask, FLUSH_TLB | FLUSH_NO_ASSIST)
 
 /* Flush all CPUs' TLBs */
 #define flush_tlb_all()                         \
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 796faca641..4f759b0af2 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -2990,7 +2990,7 @@ static int _get_page_type(struct page_info *page, unsigned long type,
                     flush_mask(mask,
                                (x & PGT_type_mask) &&
                                (x & PGT_type_mask) <= PGT_root_page_table
-                               ? FLUSH_TLB | FLUSH_FORCE_IPI
+                               ? FLUSH_TLB | FLUSH_NO_ASSIST
                                : FLUSH_TLB);
                 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed May 25 09:11:37 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 25 May 2022 09:11:37 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337064.561556 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ntn3J-00018U-8k; Wed, 25 May 2022 09:11:37 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337064.561556; Wed, 25 May 2022 09:11: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 1ntn3J-00018M-4R; Wed, 25 May 2022 09:11:37 +0000
Received: by outflank-mailman (input) for mailman id 337064;
 Wed, 25 May 2022 09: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 1ntn3H-000184-BQ
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 09:11: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 1ntn3H-0004qm-Af
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 09:11:35 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ntn3H-0000BJ-9a
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 09:11: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=V3soI31IHhQ5B5l8cqa2sSmh2fRuJvZpSD6hmZwMB0o=; b=EXcYBTIuCNB2zHsuTIaGy+qmp6
	re19RdTLzNAfQ2EuRfNINjxe7Sa9TMqf8rHvk5PTKO8k2Lt9Ze/NNzS5P0SfnbYiX45M+SYzsY4kI
	LGpXMD06r/JScxRpKgSinSc/HUsnr/a0hefNkPAhMqd+adex/YPfrc6WFMDO9yfZpEPU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] x86/flushtlb: remove flush_area check on system state
Message-Id: <E1ntn3H-0000BJ-9a@xenbits.xenproject.org>
Date: Wed, 25 May 2022 09:11:35 +0000

commit 9f735ee4903f1b9f1966bb4ba5b5616b03ae08b5
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Wed May 25 11:09:46 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 25 11:09:46 2022 +0200

    x86/flushtlb: remove flush_area check on system state
    
    Booting with Shadow Stacks leads to the following assert on a debug
    hypervisor:
    
    Assertion 'local_irq_is_enabled()' failed at arch/x86/smp.c:265
    ----[ Xen-4.17.0-10.24-d  x86_64  debug=y  Not tainted ]----
    CPU:    0
    RIP:    e008:[<ffff82d040345300>] flush_area_mask+0x40/0x13e
    [...]
    Xen call trace:
       [<ffff82d040345300>] R flush_area_mask+0x40/0x13e
       [<ffff82d040338a40>] F modify_xen_mappings+0xc5/0x958
       [<ffff82d0404474f9>] F arch/x86/alternative.c#_alternative_instructions+0xb7/0xb9
       [<ffff82d0404476cc>] F alternative_branches+0xf/0x12
       [<ffff82d04044e37d>] F __start_xen+0x1ef4/0x2776
       [<ffff82d040203344>] F __high_start+0x94/0xa0
    
    This is due to SYS_STATE_smp_boot being set before calling
    alternative_branches(), and the flush in modify_xen_mappings() then
    using flush_area_all() with interrupts disabled.  Note that
    alternative_branches() is called before APs are started, so the flush
    must be a local one (and indeed the cpumask passed to
    flush_area_mask() just contains one CPU).
    
    Take the opportunity to simplify a bit the logic and make flush_area()
    an alias of flush_area_all() in mm.c, taking into account that
    cpu_online_map just contains the BSP before APs are started.  This
    requires widening the assert in flush_area_mask() to allow being
    called with interrupts disabled as long as it's strictly a local only
    flush.
    
    The overall result is that a conditional can be removed from
    flush_area().
    
    While there also introduce an ASSERT to check that a vCPU state flush
    is not issued for the local CPU only.
    
    Fixes: 78e072bc37 ('x86/mm: avoid inadvertently degrading a TLB flush to local only')
    Suggested-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/arch/x86/mm.c  | 9 ++-------
 xen/arch/x86/smp.c | 5 ++++-
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 4f759b0af2..04d5ec705d 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -5068,13 +5068,8 @@ l1_pgentry_t *virt_to_xen_l1e(unsigned long v)
 #define l1f_to_lNf(f) (((f) & _PAGE_PRESENT) ? ((f) |  _PAGE_PSE) : (f))
 #define lNf_to_l1f(f) (((f) & _PAGE_PRESENT) ? ((f) & ~_PAGE_PSE) : (f))
 
-/*
- * map_pages_to_xen() can be called early in boot before any other
- * CPUs are online. Use flush_area_local() in this case.
- */
-#define flush_area(v,f) (system_state < SYS_STATE_smp_boot ?    \
-                         flush_area_local((const void *)v, f) : \
-                         flush_area_all((const void *)v, f))
+/* flush_area_all() can be used prior to any other CPU being online.  */
+#define flush_area(v, f) flush_area_all((const void *)(v), f)
 
 #define L3T_INIT(page) (page) = ZERO_BLOCK_PTR
 
diff --git a/xen/arch/x86/smp.c b/xen/arch/x86/smp.c
index 0a02086966..b42603c351 100644
--- a/xen/arch/x86/smp.c
+++ b/xen/arch/x86/smp.c
@@ -262,7 +262,10 @@ void flush_area_mask(const cpumask_t *mask, const void *va, unsigned int flags)
 {
     unsigned int cpu = smp_processor_id();
 
-    ASSERT(local_irq_is_enabled());
+    /* Local flushes can be performed with interrupts disabled. */
+    ASSERT(local_irq_is_enabled() || cpumask_subset(mask, cpumask_of(cpu)));
+    /* Exclude use of FLUSH_VCPU_STATE for the local CPU. */
+    ASSERT(!cpumask_test_cpu(cpu, mask) || !(flags & FLUSH_VCPU_STATE));
 
     if ( (flags & ~(FLUSH_VCPU_STATE | FLUSH_ORDER_MASK)) &&
          cpumask_test_cpu(cpu, mask) )
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed May 25 11:11:10 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 25 May 2022 11:11:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337142.561658 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1ntouv-0000LL-Gh; Wed, 25 May 2022 11:11:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337142.561658; Wed, 25 May 2022 11: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 1ntouv-0000LD-Ci; Wed, 25 May 2022 11:11:05 +0000
Received: by outflank-mailman (input) for mailman id 337142;
 Wed, 25 May 2022 11: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 1ntouu-0000L7-9a
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 11: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 1ntouu-0006zt-6e
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 11:11:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1ntouu-0007Za-5Z
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 11: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=U1C/SXRYcLruJJ/+7jCmrcfEDEBH/ABGfgnUIcR3gWo=; b=Fc2LE5cCcIWERbYqd7bUpygPnc
	ckwfY21eiAqTug9tiFca9YU7IQ0m2ndPrnruYH3kSTy2t8kP4024odeTN1AkFN1/+wh0Ollu9uLoG
	FgQ7H58VK1aPGwP1/QnUo9LrJF8AicqRnT8kIJW+0YFHTjiERwlLZHhKyBBgM3RBann0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] tools/xenstore: fix event sending in introduce_domain()
Message-Id: <E1ntouu-0007Za-5Z@xenbits.xenproject.org>
Date: Wed, 25 May 2022 11:11:04 +0000

commit 49dd52fb1311dadab29f6634d0bc1f4c022c357a
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Wed May 25 12:55:49 2022 +0200
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Wed May 25 12:10:03 2022 +0100

    tools/xenstore: fix event sending in introduce_domain()
    
    Commit fc2b57c9af46 ("xenstored: send an evtchn notification on
    introduce_domain") introduced a potential NULL dereference in case of
    Xenstore live update.
    
    Fix that by adding an appropriate check.
    
    Coverity-Id: 1504572
    Fixes: fc2b57c9af46 ("xenstored: send an evtchn notification on introduce_domain")
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 tools/xenstore/xenstored_domain.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
index de88bf2a68..ead4c237d2 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -493,9 +493,11 @@ static struct domain *introduce_domain(const void *ctx,
 		/* Now domain belongs to its connection. */
 		talloc_steal(domain->conn, domain);
 
-		/* Notify the domain that xenstore is available */
-		interface->connection = XENSTORE_CONNECTED;
-		xenevtchn_notify(xce_handle, domain->port);
+		if (!restore) {
+			/* Notify the domain that xenstore is available */
+			interface->connection = XENSTORE_CONNECTED;
+			xenevtchn_notify(xce_handle, domain->port);
+		}
 
 		if (!is_master_domain && !restore)
 			fire_watches(NULL, ctx, "@introduceDomain", NULL,
--
generated by git-patchbot for /home/xen/git/xen.git#staging


From xen-changelog-bounces@lists.xenproject.org Wed May 25 23:11:07 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 25 May 2022 23:11:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337393.561956 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nu09e-0004K2-QY; Wed, 25 May 2022 23:11:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337393.561956; Wed, 25 May 2022 23: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 1nu09e-0004Ju-NI; Wed, 25 May 2022 23:11:02 +0000
Received: by outflank-mailman (input) for mailman id 337393;
 Wed, 25 May 2022 23: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 1nu09d-0004Jo-Qy
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23: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 1nu09d-0003Ff-QA
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23:11:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nu09d-0006O6-P8
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23: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=gvQLXFx60SFIfLx3SSJKiGOJlILtyMsGuLXxMZOYIJ8=; b=vd5HRuuzvEfeQs8/gNbRqxjbSo
	zq/vDO0+lFQVRht5QVdwdR3x35HIrhv9JuT0myZwEe5Ws1HeUmnY+lJLfirPSYL0xFR+yUz1sVFi1
	tpYEQSYJHGchoyqLompEpOaPxnqGyGMOWpUOsjLkvv+yRaCk+uyaigp2kogssVcVZPsw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/dt: of_property_read_string return -ENODATA when !length
Message-Id: <E1nu09d-0006O6-P8@xenbits.xenproject.org>
Date: Wed, 25 May 2022 23:11:01 +0000

commit d43d2b6056fc65126e8d991a11f5dec14e51754d
Author:     Stefano Stabellini <stefano.stabellini@xilinx.com>
AuthorDate: Fri May 13 14:07:24 2022 -0700
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Tue May 24 16:11:06 2022 -0700

    xen/dt: of_property_read_string return -ENODATA when !length
    
    When the length of the string is zero of_property_read_string should
    return -ENODATA according to the description of the function.
    
    However, of_property_read_string doesn't check prop->length. If
    prop->length is zero, return -ENODATA.
    
    Without this patch the following command in u-boot:
    
    fdt set /chosen/node property-name
    
    results in of_property_read_string returning -EILSEQ when attempting to
    read property-name. With this patch, it returns -ENODATA as expected.
    
    This commit is a backport of:
    https://lore.kernel.org/xen-devel/20220416003028.1315268-1-sstabellini@kernel.org/
    
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
    Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
---
 xen/common/device_tree.c      | 2 +-
 xen/include/xen/device_tree.h | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/xen/common/device_tree.c b/xen/common/device_tree.c
index 4aae281e89..0e8798bd24 100644
--- a/xen/common/device_tree.c
+++ b/xen/common/device_tree.c
@@ -198,7 +198,7 @@ int dt_property_read_string(const struct dt_device_node *np,
 
     if ( !pp )
         return -EINVAL;
-    if ( !pp->value )
+    if ( !pp->length )
         return -ENODATA;
     if ( strnlen(pp->value, pp->length) >= pp->length )
         return -EILSEQ;
diff --git a/xen/include/xen/device_tree.h b/xen/include/xen/device_tree.h
index fd6cd00b43..430a1ef445 100644
--- a/xen/include/xen/device_tree.h
+++ b/xen/include/xen/device_tree.h
@@ -451,6 +451,9 @@ static inline bool_t dt_property_read_bool(const struct dt_device_node *np,
  * doest not have value, and -EILSEQ if the string is not
  * null-terminated with the length of the property data.
  *
+ * Note that the empty string "" has length of 1, thus -ENODATA cannot
+ * be interpreted as an empty string.
+ *
  * The out_string pointer is modified only if a valid string can be decoded.
  */
 int dt_property_read_string(const struct dt_device_node *np,
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed May 25 23:11:12 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 25 May 2022 23:11:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337394.561962 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nu09o-0004M8-Sn; Wed, 25 May 2022 23:11:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337394.561962; Wed, 25 May 2022 23: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 1nu09o-0004M1-P9; Wed, 25 May 2022 23:11:12 +0000
Received: by outflank-mailman (input) for mailman id 337394;
 Wed, 25 May 2022 23: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 1nu09n-0004Lr-Us
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23: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 1nu09n-0003Fk-Ti
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23:11:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nu09n-0006Ow-Sm
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23: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=DuA97AeiaPKJZhidIxHO8hhQMSUkSqRcm5O2AJziVmk=; b=ItyS6ik9yOIYPc97eNiA/DV+WJ
	twc/iu1WpSAFJykhJD6W5Zdudm21IQDBiEIdlg0jLygtcSSFryIJWgusiLTeDRC8LGJYcw6cNEoJF
	VP471cvak9aS3dNOi1W/5NPB0tbSaH+WmWMWudVD+lf9xzCXYe0CkM1110IA+bDeVeEk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: implement domU extended regions
Message-Id: <E1nu09n-0006Ow-Sm@xenbits.xenproject.org>
Date: Wed, 25 May 2022 23:11:11 +0000

commit 2a2447757b3c276be426b1f5d4070c2e993114fe
Author:     Stefano Stabellini <stefano.stabellini@xilinx.com>
AuthorDate: Fri May 13 14:07:25 2022 -0700
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Tue May 24 16:12:09 2022 -0700

    xen/arm: implement domU extended regions
    
    Implement extended regions for dom0less domUs. The implementation is
    based on the libxl implementation.
    
    Also update docs for the ext_regions command line option.
    
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
    Reviewed-by: Luca Fancellu <luca.fancellu@arm.com>
    Reviewed-by: Oleksandr Tyshchenko <oleksandr_tyshchenko@epam.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 docs/misc/xen-command-line.pandoc |  9 +++---
 xen/arch/arm/domain_build.c       | 60 +++++++++++++++++++++++++++++++++------
 2 files changed, 56 insertions(+), 13 deletions(-)

diff --git a/docs/misc/xen-command-line.pandoc b/docs/misc/xen-command-line.pandoc
index 1dc7e1ca07..881fe409ac 100644
--- a/docs/misc/xen-command-line.pandoc
+++ b/docs/misc/xen-command-line.pandoc
@@ -1110,11 +1110,12 @@ to use the default.
 
 > Default : `true`
 
-Flag to enable or disable support for extended regions for Dom0.
+Flag to enable or disable support for extended regions for Dom0 and
+Dom0less DomUs.
 
-Extended regions are ranges of unused address space exposed to Dom0 as
-"safe to use" for special memory mappings. Disable if your board device
-tree is incomplete.
+Extended regions are ranges of unused address space exposed to the guest
+as "safe to use" for special memory mappings. Disable if your board
+device tree is incomplete.
 
 ### flask
 > `= permissive | enforcing | late | disabled`
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index aa777741bd..c4dd211b91 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -35,7 +35,10 @@
 static unsigned int __initdata opt_dom0_max_vcpus;
 integer_param("dom0_max_vcpus", opt_dom0_max_vcpus);
 
-/* If true, the extended regions support is enabled for dom0 */
+/*
+ * If true, the extended regions support is enabled for dom0 and
+ * dom0less domUs.
+ */
 static bool __initdata opt_ext_regions = true;
 boolean_param("ext_regions", opt_ext_regions);
 
@@ -1327,6 +1330,36 @@ out:
     return res;
 }
 
+static int __init find_domU_holes(const struct kernel_info *kinfo,
+                                  struct meminfo *ext_regions)
+{
+    unsigned int i;
+    paddr_t bankend;
+    const paddr_t bankbase[] = GUEST_RAM_BANK_BASES;
+    const paddr_t banksize[] = GUEST_RAM_BANK_SIZES;
+    int res = -ENOENT;
+
+    for ( i = 0; i < GUEST_RAM_BANKS; i++ )
+    {
+        struct membank *ext_bank = &(ext_regions->bank[ext_regions->nr_banks]);
+
+        ext_bank->start = ROUNDUP(bankbase[i] + kinfo->mem.bank[i].size, SZ_2M);
+
+        bankend = ~0ULL >> (64 - p2m_ipa_bits);
+        bankend = min(bankend, bankbase[i] + banksize[i] - 1);
+        if ( bankend > ext_bank->start )
+            ext_bank->size = bankend - ext_bank->start + 1;
+
+        /* 64MB is the minimum size of an extended region */
+        if ( ext_bank->size < MB(64) )
+            continue;
+        ext_regions->nr_banks++;
+        res = 0;
+    }
+
+    return res;
+}
+
 static int __init make_hypervisor_node(struct domain *d,
                                        const struct kernel_info *kinfo,
                                        int addrcells, int sizecells)
@@ -1363,12 +1396,13 @@ static int __init make_hypervisor_node(struct domain *d,
 
     if ( !opt_ext_regions )
     {
-        printk(XENLOG_INFO "The extended regions support is disabled\n");
+        printk(XENLOG_INFO "%pd: extended regions support is disabled\n", d);
         nr_ext_regions = 0;
     }
     else if ( is_32bit_domain(d) )
     {
-        printk(XENLOG_WARNING "The extended regions are only supported for 64-bit guest currently\n");
+        printk(XENLOG_WARNING
+               "%pd: extended regions not supported for 32-bit guests\n", d);
         nr_ext_regions = 0;
     }
     else
@@ -1377,13 +1411,21 @@ static int __init make_hypervisor_node(struct domain *d,
         if ( !ext_regions )
             return -ENOMEM;
 
-        if ( !is_iommu_enabled(d) )
-            res = find_unallocated_memory(kinfo, ext_regions);
+        if ( is_domain_direct_mapped(d) )
+        {
+            if ( !is_iommu_enabled(d) )
+                res = find_unallocated_memory(kinfo, ext_regions);
+            else
+                res = find_memory_holes(kinfo, ext_regions);
+        }
         else
-            res = find_memory_holes(kinfo, ext_regions);
+        {
+            res = find_domU_holes(kinfo, ext_regions);
+        }
 
         if ( res )
-            printk(XENLOG_WARNING "Failed to allocate extended regions\n");
+            printk(XENLOG_WARNING "%pd: failed to allocate extended regions\n",
+                   d);
         nr_ext_regions = ext_regions->nr_banks;
     }
 
@@ -1404,8 +1446,8 @@ static int __init make_hypervisor_node(struct domain *d,
         u64 start = ext_regions->bank[i].start;
         u64 size = ext_regions->bank[i].size;
 
-        printk("Extended region %d: %#"PRIx64"->%#"PRIx64"\n",
-               i, start, start + size);
+        printk("%pd: extended region %d: %#"PRIx64"->%#"PRIx64"\n",
+               d, i, start, start + size);
 
         dt_child_set_range(&cells, addrcells, sizecells, start, size);
     }
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed May 25 23:11:22 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 25 May 2022 23:11:22 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337395.561965 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nu09y-0004PG-Tw; Wed, 25 May 2022 23:11:22 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337395.561965; Wed, 25 May 2022 23:11: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 1nu09y-0004P8-R7; Wed, 25 May 2022 23:11:22 +0000
Received: by outflank-mailman (input) for mailman id 337395;
 Wed, 25 May 2022 23: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 1nu09y-0004Oy-1h
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23: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 1nu09y-0003G0-0z
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23:11:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nu09x-0006PT-WB
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23:11: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=oiD9fjZoWZahS2CIm3xeW550Tm/xX95VCm/rVn+I6h4=; b=Meeuo1cIXFMOqho1ySiU0+vYXR
	r33a6sLh12kaZ3X0lzpz5y3La6IFWg/KZVqUtkNTYjzrYRbVR9WAeXA4V+eoJigh2Xufjjn6Mf6WJ
	W4uPsZ4BZG1+WXLGtXqG2MY7jLRppP24P7SNEWx7cJb9VnyqdzT57+oogcERr4iSxDzg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen: introduce xen,enhanced dom0less property
Message-Id: <E1nu09x-0006PT-WB@xenbits.xenproject.org>
Date: Wed, 25 May 2022 23:11:21 +0000

commit 5eedfe77287981b40669272b6ac42f2d57cd9b32
Author:     Stefano Stabellini <stefano.stabellini@xilinx.com>
AuthorDate: Fri May 13 14:07:26 2022 -0700
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Tue May 24 16:16:42 2022 -0700

    xen: introduce xen,enhanced dom0less property
    
    Introduce a new "xen,enhanced" dom0less property to enable/disable PV
    driver interfaces for dom0less guests. Currently only "enabled" and
    "disabled" are supported property values (and empty). Leave the option
    open to implement further possible values in the future (e.g.
    "xenstore" to enable only xenstore.) Dom0 presence is required for now
    to use "xen,enhanced" on a domU.
    
    The configurable option is for domUs only. For dom0 we always set the
    corresponding property in the Xen code to true (PV interfaces enabled.)
    
    This patch only parses the property. Next patches will make use of it.
    
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    CC: Julien Grall <julien@xen.org>
    CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
    CC: Bertrand Marquis <bertrand.marquis@arm.com>
---
 docs/misc/arm/device-tree/booting.txt | 18 ++++++++++++++++++
 xen/arch/arm/domain_build.c           | 12 ++++++++++++
 xen/arch/arm/include/asm/kernel.h     |  3 +++
 3 files changed, 33 insertions(+)

diff --git a/docs/misc/arm/device-tree/booting.txt b/docs/misc/arm/device-tree/booting.txt
index 7b4a29a2c2..98253414b8 100644
--- a/docs/misc/arm/device-tree/booting.txt
+++ b/docs/misc/arm/device-tree/booting.txt
@@ -193,6 +193,24 @@ with the following properties:
     Optional. Handle to a xen,cpupool device tree node that identifies the
     cpupool where the guest will be started at boot.
 
+- xen,enhanced
+
+    A string property. Possible property values are:
+
+    - "enabled" (or missing property value)
+    Xen PV interfaces, including grant-table and xenstore, will be
+    enabled for the VM.
+
+    - "disabled"
+    Xen PV interfaces are disabled.
+
+    If the xen,enhanced property is present with no value, it defaults
+    to "enabled". If the xen,enhanced property is not present, PV
+    interfaces are disabled.
+
+    In the future other possible property values might be added to
+    enable only selected interfaces.
+
 Under the "xen,domain" compatible node, one or more sub-nodes are present
 for the DomU kernel and ramdisk.
 
diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index c4dd211b91..831f6f3af9 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -3157,6 +3157,7 @@ static int __init construct_domU(struct domain *d,
                                  const struct dt_device_node *node)
 {
     struct kernel_info kinfo = {};
+    const char *dom0less_enhanced;
     int rc;
     u64 mem;
 
@@ -3172,6 +3173,17 @@ static int __init construct_domU(struct domain *d,
 
     kinfo.vpl011 = dt_property_read_bool(node, "vpl011");
 
+    rc = dt_property_read_string(node, "xen,enhanced", &dom0less_enhanced);
+    if ( rc == -EILSEQ ||
+         rc == -ENODATA ||
+         (rc == 0 && !strcmp(dom0less_enhanced, "enabled")) )
+    {
+        if ( hardware_domain )
+            kinfo.dom0less_enhanced = true;
+        else
+            panic("Tried to use xen,enhanced without dom0\n");
+    }
+
     if ( vcpu_create(d, 0) == NULL )
         return -ENOMEM;
 
diff --git a/xen/arch/arm/include/asm/kernel.h b/xen/arch/arm/include/asm/kernel.h
index 874aa108a7..c4dc039b54 100644
--- a/xen/arch/arm/include/asm/kernel.h
+++ b/xen/arch/arm/include/asm/kernel.h
@@ -36,6 +36,9 @@ struct kernel_info {
     /* Enable pl011 emulation */
     bool vpl011;
 
+    /* Enable PV drivers */
+    bool dom0less_enhanced;
+
     /* GIC phandle */
     uint32_t phandle_gic;
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed May 25 23:11:33 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 25 May 2022 23:11:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337396.561970 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nu0A8-0004SM-Vy; Wed, 25 May 2022 23:11:32 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337396.561970; Wed, 25 May 2022 23:11: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 1nu0A8-0004SC-Sg; Wed, 25 May 2022 23:11:32 +0000
Received: by outflank-mailman (input) for mailman id 337396;
 Wed, 25 May 2022 23: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 1nu0A8-0004S2-4z
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23: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 1nu0A8-0003GS-4C
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23:11:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nu0A8-0006Q2-3R
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23: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=VRc4MUJBr3pkaFgGs99vwBwgGyPjPBHKW11UnB1HcJE=; b=EdWcL/78xgpwaFe4Gli3i+3Psr
	xJ+SB4Hw3nTYy7tnr5TaHszXG1xhxAuKHxOCAwOZQwM1u6khg19wJTiJQi2HQS81LR1qHB+reDn17
	UZlgRtJv2ulvchG8gfOws0MfblkgUIsoDpZLMjsTQJoQYWZj6ANXvIDWXLxYzEM13bUg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: configure dom0less domain for enabling xenstore after boot
Message-Id: <E1nu0A8-0006Q2-3R@xenbits.xenproject.org>
Date: Wed, 25 May 2022 23:11:32 +0000

commit 79eb2871f25ea4c44ba0e54362ad5a13d21b354f
Author:     Luca Miccio <lucmiccio@gmail.com>
AuthorDate: Fri May 13 14:07:27 2022 -0700
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Tue May 24 16:17:35 2022 -0700

    xen/arm: configure dom0less domain for enabling xenstore after boot
    
    Export evtchn_alloc_unbound and make it __must_check.
    
    If "xen,enhanced" is enabled, then add to dom0less domains:
    
    - the hypervisor node in device tree
    - the xenstore event channel
    
    The xenstore event channel is also used for the first notification to
    let the guest know that xenstore has become available.
    
    Signed-off-by: Luca Miccio <lucmiccio@gmail.com>
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    CC: Julien Grall <julien@xen.org>
    CC: Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
    CC: Bertrand Marquis <bertrand.marquis@arm.com>
---
 xen/arch/arm/domain_build.c | 38 ++++++++++++++++++++++++++++++++++++++
 xen/common/event_channel.c  |  2 +-
 xen/include/xen/event.h     |  3 +++
 3 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 831f6f3af9..e7510dec90 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -27,6 +27,7 @@
 #include <asm/setup.h>
 #include <asm/cpufeature.h>
 #include <asm/domain_build.h>
+#include <xen/event.h>
 
 #include <xen/irq.h>
 #include <xen/grant_table.h>
@@ -2813,6 +2814,8 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo)
     int ret;
 
     kinfo->phandle_gic = GUEST_PHANDLE_GIC;
+    kinfo->gnttab_start = GUEST_GNTTAB_BASE;
+    kinfo->gnttab_size = GUEST_GNTTAB_SIZE;
 
     addrcells = GUEST_ROOT_ADDRESS_CELLS;
     sizecells = GUEST_ROOT_SIZE_CELLS;
@@ -2887,6 +2890,13 @@ static int __init prepare_dtb_domU(struct domain *d, struct kernel_info *kinfo)
             goto err;
     }
 
+    if ( kinfo->dom0less_enhanced )
+    {
+        ret = make_hypervisor_node(d, kinfo, addrcells, sizecells);
+        if ( ret )
+            goto err;
+    }
+
     ret = fdt_end_node(kinfo->fdt);
     if ( ret < 0 )
         goto err;
@@ -3153,6 +3163,25 @@ static int __init construct_domain(struct domain *d, struct kernel_info *kinfo)
     return 0;
 }
 
+static int __init alloc_xenstore_evtchn(struct domain *d)
+{
+    evtchn_alloc_unbound_t alloc;
+    int rc;
+
+    alloc.dom = d->domain_id;
+    alloc.remote_dom = hardware_domain->domain_id;
+    rc = evtchn_alloc_unbound(&alloc);
+    if ( rc )
+    {
+        printk("Failed allocating event channel for domain\n");
+        return rc;
+    }
+
+    d->arch.hvm.params[HVM_PARAM_STORE_EVTCHN] = alloc.port;
+
+    return 0;
+}
+
 static int __init construct_domU(struct domain *d,
                                  const struct dt_device_node *node)
 {
@@ -3222,6 +3251,15 @@ static int __init construct_domU(struct domain *d,
     if ( rc < 0 )
         return rc;
 
+    if ( kinfo.dom0less_enhanced )
+    {
+        ASSERT(hardware_domain);
+        rc = alloc_xenstore_evtchn(d);
+        if ( rc < 0 )
+            return rc;
+        d->arch.hvm.params[HVM_PARAM_STORE_PFN] = ~0ULL;
+    }
+
     return rc;
 }
 
diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c
index 0a82eb3ac2..e60cd98d75 100644
--- a/xen/common/event_channel.c
+++ b/xen/common/event_channel.c
@@ -290,7 +290,7 @@ void evtchn_free(struct domain *d, struct evtchn *chn)
     xsm_evtchn_close_post(chn);
 }
 
-static int evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc)
+int evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc)
 {
     struct evtchn *chn;
     struct domain *d;
diff --git a/xen/include/xen/event.h b/xen/include/xen/event.h
index 21c95e14fd..f3021fe304 100644
--- a/xen/include/xen/event.h
+++ b/xen/include/xen/event.h
@@ -71,6 +71,9 @@ void evtchn_free(struct domain *d, struct evtchn *chn);
 /* Allocate a specific event channel port. */
 int evtchn_allocate_port(struct domain *d, unsigned int port);
 
+/* Allocate a new event channel */
+int __must_check evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc);
+
 /* Unmask a local event-channel port. */
 int evtchn_unmask(unsigned int port);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed May 25 23:11:43 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 25 May 2022 23:11:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337397.561973 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nu0AJ-0004W5-0l; Wed, 25 May 2022 23:11:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337397.561973; Wed, 25 May 2022 23:11: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 1nu0AI-0004Vx-UE; Wed, 25 May 2022 23:11:42 +0000
Received: by outflank-mailman (input) for mailman id 337397;
 Wed, 25 May 2022 23: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 1nu0AI-0004Vn-83
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23: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 1nu0AI-0003Gc-7M
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23:11:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nu0AI-0006Qa-6L
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23: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=/nrd/aUPydTF5R7WanUnkj8oj6i82WE2xTeDDWpHLgY=; b=ckEhhn/+E0ZMZwLgtDZ1qwDl04
	stkyKht2AVm7hYNSz9caEVoeKyDULLKuYO349+I6/1WCG5Nq1b5GA1+a2csflYnggnpAw5g0cNo2k
	SjyIatxfr3Rf00n13LHE5pd2l+q7Iw6cBZwIfT7X7efqElc1XWoS+DivfyV96sPgMyBc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xenstored: send an evtchn notification on introduce_domain
Message-Id: <E1nu0AI-0006Qa-6L@xenbits.xenproject.org>
Date: Wed, 25 May 2022 23:11:42 +0000

commit fc2b57c9af462d67df871b080c0897156a616b7d
Author:     Luca Miccio <lucmiccio@gmail.com>
AuthorDate: Fri May 13 14:07:28 2022 -0700
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Tue May 24 16:18:08 2022 -0700

    xenstored: send an evtchn notification on introduce_domain
    
    When xs_introduce_domain is called, send out a notification on the
    xenstore event channel so that any (dom0less) domain waiting for the
    xenstore interface to be ready can continue with the initialization.
    Before sending the notification, clear XENSTORE_RECONNECTING.
    
    The extra notification is harmless for domains that don't require it.
    
    In xs_wire.h update the commment on top of XENSTORE_RECONNECTING to
    generalize its meaning to suit the dom0less use-case better. Also
    improve docs/misc/xenstore-ring.txt.
    
    Signed-off-by: Luca Miccio <lucmiccio@gmail.com>
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
    Reviewed-by: Juergen Gross <jgross@suse.com>
---
 docs/misc/xenstore-ring.txt       | 8 +++++++-
 tools/xenstore/xenstored_domain.c | 4 ++++
 xen/include/public/io/xs_wire.h   | 2 +-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/docs/misc/xenstore-ring.txt b/docs/misc/xenstore-ring.txt
index b338b21b19..f3d6ca4264 100644
--- a/docs/misc/xenstore-ring.txt
+++ b/docs/misc/xenstore-ring.txt
@@ -111,7 +111,13 @@ Assuming the server has advertised the feature, the guest can initiate
 a reconnection by setting the the Connection state to 1 ("Ring close
 and reconnect is in progress") and signalling the event channel.
 The guest must now ignore all fields except the Connection state and
-wait for it to be set to 0 ("Ring is connected")
+wait for it to be set to 0 ("Ring is connected").
+
+In certain circumstances (e.g. dom0less guests with PV drivers support)
+it is possible for the guest to find the Connection state already set to
+1 by someone else during xenstore initialization. In that case, like in
+the previous case, the guest must ignore all fields except the
+Connection state and wait for it to be set to 0 before proceeding.
 
 The server will guarantee to
 
diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
index 80ba1d627b..de88bf2a68 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -493,6 +493,10 @@ static struct domain *introduce_domain(const void *ctx,
 		/* Now domain belongs to its connection. */
 		talloc_steal(domain->conn, domain);
 
+		/* Notify the domain that xenstore is available */
+		interface->connection = XENSTORE_CONNECTED;
+		xenevtchn_notify(xce_handle, domain->port);
+
 		if (!is_master_domain && !restore)
 			fire_watches(NULL, ctx, "@introduceDomain", NULL,
 				     true, NULL);
diff --git a/xen/include/public/io/xs_wire.h b/xen/include/public/io/xs_wire.h
index 953a0050a3..c1ec7c73e3 100644
--- a/xen/include/public/io/xs_wire.h
+++ b/xen/include/public/io/xs_wire.h
@@ -141,7 +141,7 @@ struct xenstore_domain_interface {
 
 /* Valid values for the connection field */
 #define XENSTORE_CONNECTED 0 /* the steady-state */
-#define XENSTORE_RECONNECT 1 /* guest has initiated a reconnect */
+#define XENSTORE_RECONNECT 1 /* reconnect in progress */
 
 /* Valid values for the error field */
 #define XENSTORE_ERROR_NONE    0 /* No error */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed May 25 23:11:53 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 25 May 2022 23:11:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337398.561979 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nu0AT-0004YX-3q; Wed, 25 May 2022 23:11:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337398.561979; Wed, 25 May 2022 23: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 1nu0AS-0004YN-Vm; Wed, 25 May 2022 23:11:52 +0000
Received: by outflank-mailman (input) for mailman id 337398;
 Wed, 25 May 2022 23: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 1nu0AS-0004YH-BH
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23: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 1nu0AS-0003Gm-AV
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23:11:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nu0AS-0006RD-9W
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23: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=bXaELyHtQ+C63o+utZ4GWHarC3lHh+lOjj2+jkTnnaA=; b=B5bRNebd0HWnMMN/95CBjOcJ+m
	jDgXdv0wskL1+tJLM28+k/0BIcsepk5F+lBWrDqYUqhVhYbCkXOnCRdIUnUUnXwphdnawQYaPpBOH
	0BtOY2OQOLpeqn9ZXbyzxJ1T5mJhT8wH7cX+inlTvaXh44l4fXz8tn+qhVzA6gLfRkNE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools: add example application to initialize dom0less PV drivers
Message-Id: <E1nu0AS-0006RD-9W@xenbits.xenproject.org>
Date: Wed, 25 May 2022 23:11:52 +0000

commit ec53e0c4ea94c4442fe31e91170df4cca9f49fbe
Author:     Luca Miccio <lucmiccio@gmail.com>
AuthorDate: Fri May 13 14:07:29 2022 -0700
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Tue May 24 16:20:12 2022 -0700

    tools: add example application to initialize dom0less PV drivers
    
    Add an example application that can be run in dom0 to complete the
    dom0less domains initialization so that they can get access to xenstore
    and use PV drivers.
    
    The application sets "connection" to XENSTORE_RECONNECT on the xenstore
    page before calling xs_introduce_domain to signal that the connection is
    not ready yet to be used. XENSTORE_RECONNECT is reset soon after by
    xenstored.
    
    Signed-off-by: Luca Miccio <lucmiccio@gmail.com>
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    CC: Wei Liu <wl@xen.org>
    CC: Anthony PERARD <anthony.perard@citrix.com>
    CC: Juergen Gross <jgross@suse.com>
---
 tools/helpers/Makefile        |  13 ++
 tools/helpers/init-dom0less.c | 345 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 358 insertions(+)

diff --git a/tools/helpers/Makefile b/tools/helpers/Makefile
index 7f6c422440..8d78ab1e90 100644
--- a/tools/helpers/Makefile
+++ b/tools/helpers/Makefile
@@ -10,6 +10,9 @@ ifeq ($(CONFIG_Linux),y)
 ifeq ($(CONFIG_X86),y)
 PROGS += init-xenstore-domain
 endif
+ifeq ($(CONFIG_ARM),y)
+PROGS += init-dom0less
+endif
 endif
 
 XEN_INIT_DOM0_OBJS = xen-init-dom0.o init-dom-json.o
@@ -26,6 +29,13 @@ $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(CFLAGS_libxenstore)
 $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += $(CFLAGS_libxenlight)
 $(INIT_XENSTORE_DOMAIN_OBJS): CFLAGS += -include $(XEN_ROOT)/tools/config.h
 
+INIT_DOM0LESS_OBJS = init-dom0less.o init-dom-json.o
+$(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxentoollog)
+$(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenstore)
+$(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenlight)
+$(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenctrl)
+$(INIT_DOM0LESS_OBJS): CFLAGS += $(CFLAGS_libxenevtchn)
+
 .PHONY: all
 all: $(PROGS)
 
@@ -35,6 +45,9 @@ xen-init-dom0: $(XEN_INIT_DOM0_OBJS)
 init-xenstore-domain: $(INIT_XENSTORE_DOMAIN_OBJS)
 	$(CC) $(LDFLAGS) -o $@ $(INIT_XENSTORE_DOMAIN_OBJS) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(LDLIBS_libxenctrl) $(LDLIBS_libxenguest) $(LDLIBS_libxenlight) $(APPEND_LDFLAGS)
 
+init-dom0less: $(INIT_DOM0LESS_OBJS)
+	$(CC) $(LDFLAGS) -o $@ $(INIT_DOM0LESS_OBJS) $(LDLIBS_libxenctrl) $(LDLIBS_libxenevtchn) $(LDLIBS_libxentoollog) $(LDLIBS_libxenstore) $(LDLIBS_libxenlight) $(LDLIBS_libxenguest) $(LDLIBS_libxenforeignmemory) $(APPEND_LDFLAGS)
+
 .PHONY: install
 install: all
 	$(INSTALL_DIR) $(DESTDIR)$(LIBEXEC_BIN)
diff --git a/tools/helpers/init-dom0less.c b/tools/helpers/init-dom0less.c
new file mode 100644
index 0000000000..42e74c4153
--- /dev/null
+++ b/tools/helpers/init-dom0less.c
@@ -0,0 +1,345 @@
+#include <stdbool.h>
+#include <syslog.h>
+#include <stdio.h>
+#include <err.h>
+#include <stdlib.h>
+#include <sys/mman.h>
+#include <sys/time.h>
+#include <xenstore.h>
+#include <xenctrl.h>
+#include <xenguest.h>
+#include <libxl.h>
+#include <xenevtchn.h>
+#include <xenforeignmemory.h>
+#include <xen/io/xs_wire.h>
+
+#include "init-dom-json.h"
+
+#define XENSTORE_PFN_OFFSET 1
+#define STR_MAX_LENGTH 128
+
+static int alloc_xs_page(struct xc_interface_core *xch,
+                         libxl_dominfo *info,
+                         uint64_t *xenstore_pfn)
+{
+    int rc;
+    const xen_pfn_t base = GUEST_MAGIC_BASE >> XC_PAGE_SHIFT;
+    xen_pfn_t p2m = (GUEST_MAGIC_BASE >> XC_PAGE_SHIFT) + XENSTORE_PFN_OFFSET;
+
+    rc = xc_domain_setmaxmem(xch, info->domid,
+                             info->max_memkb + (XC_PAGE_SIZE/1024));
+    if (rc < 0)
+        return rc;
+
+    rc = xc_domain_populate_physmap_exact(xch, info->domid, 1, 0, 0, &p2m);
+    if (rc < 0)
+        return rc;
+
+    *xenstore_pfn = base + XENSTORE_PFN_OFFSET;
+    rc = xc_clear_domain_page(xch, info->domid, *xenstore_pfn);
+    if (rc < 0)
+        return rc;
+
+    return 0;
+}
+
+static bool do_xs_write_dom(struct xs_handle *xsh, xs_transaction_t t,
+                            domid_t domid, char *path, char *val)
+{
+    char full_path[STR_MAX_LENGTH];
+    struct xs_permissions perms[2];
+
+    perms[0].id = domid;
+    perms[0].perms = XS_PERM_NONE;
+    perms[1].id = 0;
+    perms[1].perms = XS_PERM_READ;
+
+    if (snprintf(full_path, STR_MAX_LENGTH,
+                 "/local/domain/%u/%s", domid, path) < 0)
+        return false;
+    if (!xs_write(xsh, t, full_path, val, strlen(val)))
+        return false;
+    return xs_set_permissions(xsh, t, full_path, perms, 2);
+}
+
+static bool do_xs_write_libxl(struct xs_handle *xsh, xs_transaction_t t,
+                              domid_t domid, char *path, char *val)
+{
+    char full_path[STR_MAX_LENGTH];
+
+    if (snprintf(full_path, STR_MAX_LENGTH,
+                 "/libxl/%u/%s", domid, path) < 0)
+        return false;
+    return xs_write(xsh, t, full_path, val, strlen(val));
+}
+
+static bool do_xs_write_vm(struct xs_handle *xsh, xs_transaction_t t,
+                           libxl_uuid uuid, char *path, char *val)
+{
+    char full_path[STR_MAX_LENGTH];
+
+    if (snprintf(full_path, STR_MAX_LENGTH,
+                 "/vm/" LIBXL_UUID_FMT "/%s", LIBXL_UUID_BYTES(uuid), path) < 0)
+        return false;
+    return xs_write(xsh, t, full_path, val, strlen(val));
+}
+
+/*
+ * The xenstore nodes are the xenstore nodes libxl writes at domain
+ * creation.
+ *
+ * The list was retrieved by running xenstore-ls on a corresponding
+ * domain started by xl/libxl.
+ */
+static int create_xenstore(struct xs_handle *xsh,
+                           libxl_dominfo *info, libxl_uuid uuid,
+                           evtchn_port_t xenstore_port)
+{
+    domid_t domid;
+    unsigned int i;
+    char uuid_str[STR_MAX_LENGTH];
+    char dom_name_str[STR_MAX_LENGTH];
+    char vm_val_str[STR_MAX_LENGTH];
+    char id_str[STR_MAX_LENGTH];
+    char max_memkb_str[STR_MAX_LENGTH];
+    char target_memkb_str[STR_MAX_LENGTH];
+    char cpu_str[STR_MAX_LENGTH];
+    char xenstore_port_str[STR_MAX_LENGTH];
+    char ring_ref_str[STR_MAX_LENGTH];
+    xs_transaction_t t;
+    struct timeval start_time;
+    char start_time_str[STR_MAX_LENGTH];
+    int rc;
+
+    if (gettimeofday(&start_time, NULL) < 0)
+        return -errno;
+    rc = snprintf(start_time_str, STR_MAX_LENGTH, "%jd.%02d",
+            (intmax_t)start_time.tv_sec, (int)start_time.tv_usec / 10000);
+    if (rc < 0)
+        return rc;
+
+    domid = info->domid;
+    rc = snprintf(id_str, STR_MAX_LENGTH, "%u", domid);
+    if (rc < 0)
+        return rc;
+    rc = snprintf(dom_name_str, STR_MAX_LENGTH, "dom0less-%u", domid);
+    if (rc < 0)
+        return rc;
+    rc = snprintf(uuid_str, STR_MAX_LENGTH, LIBXL_UUID_FMT, LIBXL_UUID_BYTES(uuid));
+    if (rc < 0)
+        return rc;
+    rc = snprintf(vm_val_str, STR_MAX_LENGTH,
+                  "vm/" LIBXL_UUID_FMT, LIBXL_UUID_BYTES(uuid));
+    if (rc < 0)
+        return rc;
+    rc = snprintf(max_memkb_str, STR_MAX_LENGTH, "%lu", info->max_memkb);
+    if (rc < 0)
+        return rc;
+    rc = snprintf(target_memkb_str, STR_MAX_LENGTH, "%lu", info->current_memkb);
+    if (rc < 0)
+        return rc;
+    rc = snprintf(ring_ref_str, STR_MAX_LENGTH, "%lld",
+                  (GUEST_MAGIC_BASE >> XC_PAGE_SHIFT) + XENSTORE_PFN_OFFSET);
+    if (rc < 0)
+        return rc;
+    rc = snprintf(xenstore_port_str, STR_MAX_LENGTH, "%u", xenstore_port);
+    if (rc < 0)
+        return rc;
+
+retry_transaction:
+    t = xs_transaction_start(xsh);
+    if (t == XBT_NULL)
+        return -errno;
+
+    rc = -EIO;
+    /* /vm */
+    if (!do_xs_write_vm(xsh, t, uuid, "name", dom_name_str)) goto err;
+    if (!do_xs_write_vm(xsh, t, uuid, "uuid", uuid_str)) goto err;
+    if (!do_xs_write_vm(xsh, t, uuid, "start_time", start_time_str)) goto err;
+
+    /* /domain */
+    if (!do_xs_write_dom(xsh, t, domid, "vm", vm_val_str)) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "name", dom_name_str)) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "cpu", "")) goto err;
+    for (i = 0; i < info->vcpu_max_id; i++) {
+        rc = snprintf(cpu_str, STR_MAX_LENGTH, "cpu/%u/availability/", i);
+        if (rc < 0)
+            goto err;
+        rc = -EIO;
+        if (!do_xs_write_dom(xsh, t, domid, cpu_str,
+                             (info->cpupool & (1 << i)) ? "online" : "offline"))
+            goto err;
+    }
+
+    if (!do_xs_write_dom(xsh, t, domid, "memory", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "memory/static-max", max_memkb_str)) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "memory/target", target_memkb_str)) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "memory/videoram", "-1")) goto err;
+
+    if (!do_xs_write_dom(xsh, t, domid, "device", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "device/suspend", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "device/suspend/event-channel", "")) goto err;
+
+    if (!do_xs_write_dom(xsh, t, domid, "control", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "control/shutdown", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "control/feature-poweroff", "1")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "control/feature-reboot", "1")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "control/feature-suspend", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "control/sysrq", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "control/platform-feature-multiprocessor-suspend", "1")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "control/platform-feature-xs_reset_watches", "1")) goto err;
+
+    if (!do_xs_write_dom(xsh, t, domid, "domid", id_str)) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "data", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "drivers", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "feature", "")) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "attr", "")) goto err;
+
+    if (!do_xs_write_dom(xsh, t, domid, "store/port", xenstore_port_str)) goto err;
+    if (!do_xs_write_dom(xsh, t, domid, "store/ring-ref", ring_ref_str)) goto err;
+
+    if (!do_xs_write_libxl(xsh, t, domid, "type", "pvh")) goto err;
+    if (!do_xs_write_libxl(xsh, t, domid, "dm-version", "qemu_xen")) goto err;
+
+    if (!xs_transaction_end(xsh, t, false)) {
+        if (errno == EAGAIN)
+            goto retry_transaction;
+        else
+            return -errno;
+    }
+
+    return 0;
+
+err:
+    xs_transaction_end(xsh, t, true);
+    return rc;
+}
+
+static int init_domain(struct xs_handle *xsh,
+                       struct xc_interface_core *xch,
+                       xenforeignmemory_handle *xfh,
+                       libxl_dominfo *info)
+{
+    libxl_uuid uuid;
+    uint64_t xenstore_evtchn, xenstore_pfn;
+    int rc;
+    struct xenstore_domain_interface *intf;
+
+    printf("Init dom0less domain: %u\n", info->domid);
+
+    rc = xc_hvm_param_get(xch, info->domid, HVM_PARAM_STORE_EVTCHN,
+                          &xenstore_evtchn);
+    if (rc != 0) {
+        printf("Failed to get HVM_PARAM_STORE_EVTCHN\n");
+        return 1;
+    }
+
+    /* no xen,enhanced; nothing to do */
+    if (!xenstore_evtchn)
+        return 0;
+
+    /* Alloc xenstore page */
+    if (alloc_xs_page(xch, info, &xenstore_pfn) != 0) {
+        printf("Error on alloc magic pages\n");
+        return 1;
+    }
+
+    intf = xenforeignmemory_map(xfh, info->domid, PROT_READ | PROT_WRITE, 1,
+                                &xenstore_pfn, NULL);
+    if (!intf) {
+        printf("Error mapping xenstore page\n");
+        return 1;
+    }
+    intf->connection = XENSTORE_RECONNECT;
+    xenforeignmemory_unmap(xfh, intf, 1);
+
+    rc = xc_dom_gnttab_seed(xch, info->domid, true,
+                            (xen_pfn_t)-1, xenstore_pfn, 0, 0);
+    if (rc)
+        err(1, "xc_dom_gnttab_seed");
+
+    libxl_uuid_generate(&uuid);
+    xc_domain_sethandle(xch, info->domid, libxl_uuid_bytearray(&uuid));
+
+    rc = gen_stub_json_config(info->domid, &uuid);
+    if (rc)
+        err(1, "gen_stub_json_config");
+
+    /* Now everything is ready: set HVM_PARAM_STORE_PFN */
+    rc = xc_hvm_param_set(xch, info->domid, HVM_PARAM_STORE_PFN,
+                          xenstore_pfn);
+    if (rc < 0)
+        return rc;
+
+    rc = create_xenstore(xsh, info, uuid, xenstore_evtchn);
+    if (rc)
+        err(1, "writing to xenstore");
+
+    rc = xs_introduce_domain(xsh, info->domid,
+            (GUEST_MAGIC_BASE >> XC_PAGE_SHIFT) + XENSTORE_PFN_OFFSET,
+            xenstore_evtchn);
+    if (!rc)
+        err(1, "xs_introduce_domain");
+    return 0;
+}
+
+/* Check if domain has been configured in XS */
+static bool domain_exists(struct xs_handle *xsh, int domid)
+{
+    return xs_is_domain_introduced(xsh, domid);
+}
+
+int main(int argc, char **argv)
+{
+    libxl_dominfo *info = NULL;
+    libxl_ctx *ctx;
+    int nb_vm = 0, rc = 0, i;
+    struct xs_handle *xsh = NULL;
+    struct xc_interface_core *xch = NULL;
+    xenforeignmemory_handle *xfh = NULL;
+
+    /* TODO reuse libxl xsh connection */
+    xsh = xs_open(0);
+    xch = xc_interface_open(0, 0, 0);
+    xfh = xenforeignmemory_open(0, 0);
+    if (xsh == NULL || xch == NULL || xfh == NULL) {
+        fprintf(stderr, "Cannot open xc/xs/xenforeignmemory interfaces");
+        rc = -errno;
+        goto out;
+    }
+
+    rc = libxl_ctx_alloc(&ctx, LIBXL_VERSION, 0, NULL);
+    if (rc) {
+        fprintf(stderr, "cannot init xl context\n");
+        goto out;
+    }
+
+    info = libxl_list_domain(ctx, &nb_vm);
+    if (!info) {
+        fprintf(stderr, "libxl_list_vm failed.\n");
+        rc = -1;
+        goto out;
+    }
+
+    for (i = 0; i < nb_vm; i++) {
+        domid_t domid = info[i].domid;
+
+        /* Don't need to check for Dom0 */
+        if (!domid)
+            continue;
+
+        printf("Checking domid: %u\n", domid);
+        if (!domain_exists(xsh, domid)) {
+            rc = init_domain(xsh, xch, xfh, &info[i]);
+            if (rc < 0) {
+                fprintf(stderr, "init_domain failed.\n");
+                goto out;
+            }
+        } else {
+            printf("Domain %u has already been initialized\n", domid);
+        }
+    }
+out:
+    libxl_dominfo_list_free(info, nb_vm);
+    return rc;
+}
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed May 25 23:12:03 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 25 May 2022 23:12:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337399.561981 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nu0Ad-0004c5-64; Wed, 25 May 2022 23:12:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337399.561981; Wed, 25 May 2022 23: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 1nu0Ad-0004bx-2p; Wed, 25 May 2022 23:12:03 +0000
Received: by outflank-mailman (input) for mailman id 337399;
 Wed, 25 May 2022 23: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 1nu0Ac-0004br-GK
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23: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 1nu0Ac-0003HB-Do
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23:12:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nu0Ac-0006Rp-Cv
 for xen-changelog@lists.xenproject.org; Wed, 25 May 2022 23: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=DwL8Y9B3kEoJ4Sq3ITbz+PSVheFfKmEBh8qFgO3KR/M=; b=UjJQyrgodSZHdhNJTf10PjElJW
	euneBd+CkIJKE5LZQruFLBqmHR1XtDiflSlmctGFwyQTNEtMdxtQyzMrTmDCb49u0hEkZfFvnrkBB
	NafvrYXLYiXP89Q2uwINXVYPCi1I2lEpvskJfeyoChHTOoexhvaqcODFH+98tJWdOVAA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: setup: nr_banks should be unsigned int
Message-Id: <E1nu0Ac-0006Rp-Cv@xenbits.xenproject.org>
Date: Wed, 25 May 2022 23:12:02 +0000

commit 49399b101e38fb2c11478c849ffdaaace8e318a8
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Tue May 24 16:38:15 2022 -0700
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Tue May 24 16:40:19 2022 -0700

    xen/arm: setup: nr_banks should be unsigned int
    
    It is not possible to have a negative number of banks. So switch to
    unsigned int.
    
    The type change is also propagated to any users of nr_banks that were
    using "int" (there are not that many).
    
    Note that fdt_num_mem_rsv() can actually returns a negative value in
    case of an error. So the return should be checked before assigning the
    result to an unsigned variable.
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Wei Chen <Wei.Chen@arm.com>
    Acked-by: Stefano Stabellini <sstabellini@kernel.org>
---
 xen/arch/arm/domain_build.c      |  9 +++++----
 xen/arch/arm/efi/efi-dom0.c      |  4 ++--
 xen/arch/arm/include/asm/setup.h |  6 +++---
 xen/arch/arm/setup.c             | 17 +++++++++++++----
 4 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index e7510dec90..7ddd16c26d 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -115,7 +115,8 @@ static bool __init insert_11_bank(struct domain *d,
                                   struct page_info *pg,
                                   unsigned int order)
 {
-    int res, i;
+    unsigned int i;
+    int res;
     mfn_t smfn;
     paddr_t start, size;
 
@@ -268,7 +269,7 @@ static void __init allocate_memory_11(struct domain *d,
     const unsigned int min_order = get_order_from_bytes(MB(4));
     struct page_info *pg;
     unsigned int order = get_allocation_size(kinfo->unassigned_mem);
-    int i;
+    unsigned int i;
 
     bool lowmem = true;
     unsigned int lowmem_bitsize = min(32U, arch_get_dma_bitsize());
@@ -1026,8 +1027,8 @@ static int __init make_memory_node(const struct domain *d,
                                    int addrcells, int sizecells,
                                    struct meminfo *mem)
 {
-    int res, i;
-    int reg_size = addrcells + sizecells;
+    unsigned int i;
+    int res, reg_size = addrcells + sizecells;
     int nr_cells = 0;
     /* Placeholder for memory@ + a 64-bit number + \0 */
     char buf[24];
diff --git a/xen/arch/arm/efi/efi-dom0.c b/xen/arch/arm/efi/efi-dom0.c
index 494420eaa2..aae0f97911 100644
--- a/xen/arch/arm/efi/efi-dom0.c
+++ b/xen/arch/arm/efi/efi-dom0.c
@@ -34,14 +34,14 @@
 /* Constant to indicate "Xen" in unicode u16 format */
 static const CHAR16 xen_efi_fw_vendor[] = {0x0058, 0x0065, 0x006E, 0x0000};
 
-size_t __init estimate_efi_size(int mem_nr_banks)
+size_t __init estimate_efi_size(unsigned int mem_nr_banks)
 {
     size_t size;
     size_t est_size = sizeof(EFI_SYSTEM_TABLE);
     size_t ect_size = sizeof(EFI_CONFIGURATION_TABLE);
     size_t emd_size = sizeof(EFI_MEMORY_DESCRIPTOR);
     size_t fw_vendor_size = sizeof(xen_efi_fw_vendor);
-    int acpi_mem_nr_banks = 0;
+    unsigned int acpi_mem_nr_banks = 0;
 
     if ( !acpi_disabled )
         acpi_mem_nr_banks = bootinfo.acpi.nr_banks;
diff --git a/xen/arch/arm/include/asm/setup.h b/xen/arch/arm/include/asm/setup.h
index 7a1e1d6798..2bb01ecfa8 100644
--- a/xen/arch/arm/include/asm/setup.h
+++ b/xen/arch/arm/include/asm/setup.h
@@ -30,7 +30,7 @@ struct membank {
 };
 
 struct meminfo {
-    int nr_banks;
+    unsigned int nr_banks;
     struct membank bank[NR_MEM_BANKS];
 };
 
@@ -93,7 +93,7 @@ extern domid_t max_init_domid;
 
 void copy_from_paddr(void *dst, paddr_t paddr, unsigned long len);
 
-size_t estimate_efi_size(int mem_nr_banks);
+size_t estimate_efi_size(unsigned int mem_nr_banks);
 
 void acpi_create_efi_system_table(struct domain *d,
                                   struct membank tbl_add[]);
@@ -109,7 +109,7 @@ void create_dom0(void);
 
 void discard_initial_modules(void);
 void fw_unreserved_regions(paddr_t s, paddr_t e,
-                           void (*cb)(paddr_t, paddr_t), int first);
+                           void (*cb)(paddr_t, paddr_t), unsigned int first);
 
 size_t boot_fdt_info(const void *fdt, paddr_t paddr);
 const char *boot_fdt_cmdline(const void *fdt);
diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index d5d0792ed4..ea1f5ee3d3 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -201,9 +201,17 @@ static void __init processor_id(void)
 
 static void __init dt_unreserved_regions(paddr_t s, paddr_t e,
                                          void (*cb)(paddr_t, paddr_t),
-                                         int first)
+                                         unsigned int first)
 {
-    int i, nr = fdt_num_mem_rsv(device_tree_flattened);
+    unsigned int i, nr;
+    int rc;
+
+    rc = fdt_num_mem_rsv(device_tree_flattened);
+    if ( rc < 0 )
+        panic("Unable to retrieve the number of reserved regions (rc=%d)\n",
+              rc);
+
+    nr = rc;
 
     for ( i = first; i < nr ; i++ )
     {
@@ -249,7 +257,8 @@ static void __init dt_unreserved_regions(paddr_t s, paddr_t e,
 }
 
 void __init fw_unreserved_regions(paddr_t s, paddr_t e,
-                                  void (*cb)(paddr_t, paddr_t), int first)
+                                  void (*cb)(paddr_t, paddr_t),
+                                  unsigned int first)
 {
     if ( acpi_disabled )
         dt_unreserved_regions(s, e, cb, first);
@@ -643,7 +652,7 @@ static void __init setup_mm(void)
     paddr_t s, e;
     unsigned long ram_pages;
     unsigned long heap_pages, xenheap_pages, domheap_pages;
-    int i;
+    unsigned int i;
     const uint32_t ctr = READ_CP32(CTR);
 
     if ( !bootinfo.mem.nr_banks )
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 26 12:11:08 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 26 May 2022 12:11:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337600.562232 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nuCKV-0003AZ-9j; Thu, 26 May 2022 12:11:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337600.562232; Thu, 26 May 2022 12:11: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 1nuCKV-0003AR-5m; Thu, 26 May 2022 12:11:03 +0000
Received: by outflank-mailman (input) for mailman id 337600;
 Thu, 26 May 2022 12: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 1nuCKU-0003AL-EG
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12: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 1nuCKU-00009Q-Ap
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12:11:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nuCKU-00006j-9g
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12: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=FD/ddBRlsR+/fGUICVOmOhKSsx15DEYqinHlEjRUT4w=; b=hVqBKOOIfGupSraywjZJxTIOe8
	98UoPAATeLt/OOcNwmg100L8coUD/mXDQrU/kJSppIbsh0QeyM7NCTM49zRW/WtalYi+SMRekKh9D
	Pgn92e18SJDa1zre2o4B9gQnzYfqvCXLtLupKcv/h9h0GPqu/do734PEE223yIXb1acE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/iommu: dt: Check the return value of xsm_deassign_dtdevice()
Message-Id: <E1nuCKU-00006j-9g@xenbits.xenproject.org>
Date: Thu, 26 May 2022 12:11:02 +0000

commit b22db3fcba1a5b4f9e563b58d402f1d5c434209f
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Wed May 25 09:52:38 2022 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Wed May 25 09:52:59 2022 +0100

    xen/iommu: dt: Check the return value of xsm_deassign_dtdevice()
    
    xsm_deassign_dtdevice() will indicate whether the caller is allowed
    to issue the operation. So the return value has to be checked.
    
    Spotted by clang static analyzer.
    
    Fixes: fe36cccc483c ("xen/passthrough: Extend XEN_DOMCTL_*assign_device to support DT device")
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Michal Orzel <michal.orzel@arm.com>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
---
 xen/drivers/passthrough/device_tree.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/drivers/passthrough/device_tree.c b/xen/drivers/passthrough/device_tree.c
index 98f2aa0dad..1c32d7b50c 100644
--- a/xen/drivers/passthrough/device_tree.c
+++ b/xen/drivers/passthrough/device_tree.c
@@ -269,6 +269,8 @@ int iommu_do_dt_domctl(struct xen_domctl *domctl, struct domain *d,
             break;
 
         ret = xsm_deassign_dtdevice(XSM_HOOK, d, dt_node_full_name(dev));
+        if ( ret )
+            break;
 
         if ( d == dom_io )
             return -EINVAL;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 26 12:11:13 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 26 May 2022 12:11:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337601.562235 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nuCKf-0003CQ-AH; Thu, 26 May 2022 12:11:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337601.562235; Thu, 26 May 2022 12:11: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 1nuCKf-0003CJ-7g; Thu, 26 May 2022 12:11:13 +0000
Received: by outflank-mailman (input) for mailman id 337601;
 Thu, 26 May 2022 12: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 1nuCKe-0003CD-Et
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12: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 1nuCKe-00009U-E4
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12:11:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nuCKe-00007d-Cz
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12: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=S1+ZfPTdJ8jU8UTbeRPypCimNkZoluXQC3PgDl8TGfE=; b=eZjQ5myiTZWQBAA22vjY/FKOiZ
	yipX11XycsqzWKGnxHRUNvVMLMKyfHQD96jOrw1b5mS2Ddo6tNtXFZod0IRkCxa6MOsS5mpQIVgRV
	n1whaUBPKBlY6aEg9vjer2GCJqKOPo+IweYY8OsYIhlt9TjlfoiNb4lZrmSN0HDYcJ+o=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xl: sort create command options
Message-Id: <E1nuCKe-00007d-Cz@xenbits.xenproject.org>
Date: Thu, 26 May 2022 12:11:12 +0000

commit f64c55b2f1b67c4d5e53146a7940707cb7671cee
Author:     Elliott Mitchell <ehem+xen@m5p.com>
AuthorDate: Wed May 25 11:07:17 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 25 11:07:17 2022 +0200

    tools/xl: sort create command options
    
    Hopefully simplify future changes by sorting options lists for
    `xl create`.  While at it, declare the options list constant.
    
    Signed-off-by: Elliott Mitchell <ehem+xen@m5p.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/xl/xl_cmdtable.c  | 12 ++++++------
 tools/xl/xl_vmcontrol.c | 40 ++++++++++++++++++++--------------------
 2 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index 661323d488..35182ca196 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -24,16 +24,16 @@ const struct cmd_spec cmd_table[] = {
       &main_create, 1, 1,
       "Create a domain from config file <filename>",
       "<ConfigFile> [options] [vars]",
-      "-h                      Print this help.\n"
-      "-p                      Leave the domain paused after it is created.\n"
       "-c                      Connect to the console after the domain is created.\n"
+      "-d                      Enable debug messages.\n"
+      "-e                      Do not wait in the background for the death of the domain.\n"
+      "-F                      Run in foreground until death of the domain.\n"
       "-f FILE, --defconfig=FILE\n                     Use the given configuration file.\n"
-      "-q, --quiet             Quiet.\n"
+      "-h                      Print this help.\n"
       "-n, --dryrun            Dry run - prints the resulting configuration\n"
       "                         (deprecated in favour of global -N option).\n"
-      "-d                      Enable debug messages.\n"
-      "-F                      Run in foreground until death of the domain.\n"
-      "-e                      Do not wait in the background for the death of the domain.\n"
+      "-p                      Leave the domain paused after it is created.\n"
+      "-q, --quiet             Quiet.\n"
       "-V, --vncviewer         Connect to the VNC display after the domain is created.\n"
       "-A, --vncviewer-autopass\n"
       "                        Pass VNC password to viewer via stdin.\n"
diff --git a/tools/xl/xl_vmcontrol.c b/tools/xl/xl_vmcontrol.c
index 435155a033..d081c6c290 100644
--- a/tools/xl/xl_vmcontrol.c
+++ b/tools/xl/xl_vmcontrol.c
@@ -1169,13 +1169,13 @@ int main_create(int argc, char **argv)
     int paused = 0, debug = 0, daemonize = 1, console_autoconnect = 0,
         quiet = 0, monitor = 1, vnc = 0, vncautopass = 0, ignore_masks = 0;
     int opt, rc;
-    static struct option opts[] = {
+    static const struct option opts[] = {
+        {"defconfig", 1, 0, 'f'},
         {"dryrun", 0, 0, 'n'},
+        {"ignore-global-affinity-masks", 0, 0, 'i'},
         {"quiet", 0, 0, 'q'},
-        {"defconfig", 1, 0, 'f'},
         {"vncviewer", 0, 0, 'V'},
         {"vncviewer-autopass", 0, 0, 'A'},
-        {"ignore-global-affinity-masks", 0, 0, 'i'},
         COMMON_LONG_OPTS
     };
 
@@ -1186,12 +1186,15 @@ int main_create(int argc, char **argv)
         argc--; argv++;
     }
 
-    SWITCH_FOREACH_OPT(opt, "Fnqf:pcdeVAi", opts, "create", 0) {
-    case 'f':
-        filename = optarg;
+    SWITCH_FOREACH_OPT(opt, "AFVcdef:inpq", opts, "create", 0) {
+    case 'A':
+        vnc = vncautopass = 1;
         break;
-    case 'p':
-        paused = 1;
+    case 'F':
+        daemonize = 0;
+        break;
+    case 'V':
+        vnc = 1;
         break;
     case 'c':
         console_autoconnect = 1;
@@ -1199,28 +1202,25 @@ int main_create(int argc, char **argv)
     case 'd':
         debug = 1;
         break;
-    case 'F':
-        daemonize = 0;
-        break;
     case 'e':
         daemonize = 0;
         monitor = 0;
         break;
+    case 'f':
+        filename = optarg;
+        break;
+    case 'i':
+        ignore_masks = 1;
+        break;
     case 'n':
         dryrun_only = 1;
         break;
+    case 'p':
+        paused = 1;
+        break;
     case 'q':
         quiet = 1;
         break;
-    case 'V':
-        vnc = 1;
-        break;
-    case 'A':
-        vnc = vncautopass = 1;
-        break;
-    case 'i':
-        ignore_masks = 1;
-        break;
     }
 
     memset(&dom_info, 0, sizeof(dom_info));
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 26 12:11:23 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 26 May 2022 12:11:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337602.562239 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nuCKp-0003FJ-CY; Thu, 26 May 2022 12:11:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337602.562239; Thu, 26 May 2022 12: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 1nuCKp-0003FB-9R; Thu, 26 May 2022 12:11:23 +0000
Received: by outflank-mailman (input) for mailman id 337602;
 Thu, 26 May 2022 12: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 1nuCKo-0003F1-Hp
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12: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 1nuCKo-00009l-H9
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12:11:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nuCKo-00008I-GC
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12: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=dkj/Mi6aY23tv16PiTx6oigT63ByNrxPPaWqBUpPKOA=; b=E0YZqsQL2ngyomFzjJ0TSYB8Dc
	Ef+4NNpja0w12t5IuwJg2ejqqC+JNTb10eeij+7NLyxLvQOb++KbgyAWDsv60bFiA8okZQTcsGC+h
	AswPx+cwRlGKpY5Y9BNvA74V/QzyfhLsmjxc9LOZApEixuz7etl8RkiHu+RGNvdouhRc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] build: fix make warning if there is no cppcheck
Message-Id: <E1nuCKo-00008I-GC@xenbits.xenproject.org>
Date: Thu, 26 May 2022 12:11:22 +0000

commit 890b23a43345785aafd5e55ccd91a80d3ad76f36
Author:     Bertrand Marquis <bertrand.marquis@arm.com>
AuthorDate: Wed May 25 11:07:46 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 25 11:07:46 2022 +0200

    build: fix make warning if there is no cppcheck
    
    If cppcheck is not present, the following warning appears during build:
    which: no cppcheck in ([...])
    /bin/sh: cppcheck: command not found
    
    Fix the problem by using shell code inside the cppcheck-version rule to
    also prevent unneeded call of which when something else than cppcheck is
    built.
    
    Reported-by: Julien Grall <julien@xen.org>
    Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/Makefile | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/xen/Makefile b/xen/Makefile
index 15388703bc..82f5310b12 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -694,12 +694,14 @@ $(objtree)/%.c.cppcheck: $(srctree)/%.c $(objtree)/include/generated/autoconf.h
 	$(call if_changed,cppcheck_xml)
 
 cppcheck-version:
-ifeq ($(shell which $(CPPCHECK)),)
-	$(error Cannot find cppcheck executable: $(CPPCHECK))
-endif
-ifeq ($(shell $(CPPCHECK) --version | awk '{print ($$2 < 2.7)}'),1)
-	$(error Please upgrade your cppcheck to version 2.7 or greater)
-endif
+	$(Q)if ! which $(CPPCHECK) > /dev/null 2>&1; then \
+		echo "Cannot find cppcheck executable: $(CPPCHECK)"; \
+		exit 1; \
+	fi
+	$(Q)if [ "$$($(CPPCHECK) --version | awk '{print ($$2 < 2.7)}')" -eq 1 ]; then \
+		echo "Please upgrade your cppcheck to version 2.7 or greater"; \
+		exit 1; \
+	fi
 
 # Put this in generated headers this way it is cleaned by include/Makefile
 $(objtree)/include/generated/compiler-def.h:
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 26 12:11:33 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 26 May 2022 12:11:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337603.562243 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nuCKz-0003Il-Dl; Thu, 26 May 2022 12:11:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337603.562243; Thu, 26 May 2022 12: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 1nuCKz-0003Ie-Az; Thu, 26 May 2022 12:11:33 +0000
Received: by outflank-mailman (input) for mailman id 337603;
 Thu, 26 May 2022 12: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 1nuCKy-0003IR-LA
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12: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 1nuCKy-0000AP-KI
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12:11:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nuCKy-000097-JP
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12: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=m0nJzZvKuv2fWo8a1l8RllPXRI4SruncJ115H/CeIAo=; b=ww4mSrDdiDob5AlTGO5+tsTiLQ
	F1rMJu9Y16jJFiip7OtYKUZdvO/fDPp2PqdX99au3/tyb+/McqlX0NYvW8BOaov3IUkKRSBrm2A3X
	dZizjNdihHeymXvsa2BFB9/Fa9a7PNmW+xT5dKMx9eN17bENEazyn/OxkOnefVZD+nzg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/mm: rename FLUSH_FORCE_IPI to FLUSH_NO_ASSIST
Message-Id: <E1nuCKy-000097-JP@xenbits.xenproject.org>
Date: Thu, 26 May 2022 12:11:32 +0000

commit 54e3d5e0fb880ed990695573f4a4f59a60187bf0
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Wed May 25 11:08:28 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 25 11:08:28 2022 +0200

    x86/mm: rename FLUSH_FORCE_IPI to FLUSH_NO_ASSIST
    
    Rename the flag to better note that it's not actually forcing any IPIs
    to be issued if none is required, but merely avoiding the usage of TLB
    flush assistance (which itself can avoid the sending of IPIs to remote
    processors).
    
    No functional change expected.
    
    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/include/asm/flushtlb.h | 16 ++++++++--------
 xen/arch/x86/mm.c                   |  2 +-
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/xen/arch/x86/include/asm/flushtlb.h b/xen/arch/x86/include/asm/flushtlb.h
index 18777f1d4c..a461ee36ff 100644
--- a/xen/arch/x86/include/asm/flushtlb.h
+++ b/xen/arch/x86/include/asm/flushtlb.h
@@ -128,13 +128,12 @@ void switch_cr3_cr4(unsigned long cr3, unsigned long cr4);
 #endif
 #if defined(CONFIG_PV) || defined(CONFIG_SHADOW_PAGING)
 /*
- * Force an IPI to be sent. Note that adding this to the flags passed to
- * flush_area_mask will prevent using the assisted flush without having any
- * other side effect.
+ * Adding this to the flags passed to flush_area_mask will prevent using the
+ * assisted flush without having any other side effect.
  */
-# define FLUSH_FORCE_IPI 0x8000
+# define FLUSH_NO_ASSIST 0x8000
 #else
-# define FLUSH_FORCE_IPI 0
+# define FLUSH_NO_ASSIST 0
 #endif
 
 /* Flush local TLBs/caches. */
@@ -162,11 +161,12 @@ void flush_area_mask(const cpumask_t *, const void *va, unsigned int flags);
     flush_area_mask(mask, (const void *)(v), FLUSH_TLB|FLUSH_ORDER(0))
 
 /*
- * Make the common code TLB flush helper force use of an IPI in order to be
- * on the safe side. Note that not all calls from common code strictly require
+ * Make the common code TLB flush helper disallow the usage of any flush
+ * assistance in order to be on the safe side and interrupt remote processors
+ * requiring a flush. Note that not all calls from common code strictly require
  * this.
  */
-#define arch_flush_tlb_mask(mask) flush_mask(mask, FLUSH_TLB | FLUSH_FORCE_IPI)
+#define arch_flush_tlb_mask(mask) flush_mask(mask, FLUSH_TLB | FLUSH_NO_ASSIST)
 
 /* Flush all CPUs' TLBs */
 #define flush_tlb_all()                         \
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 796faca641..4f759b0af2 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -2990,7 +2990,7 @@ static int _get_page_type(struct page_info *page, unsigned long type,
                     flush_mask(mask,
                                (x & PGT_type_mask) &&
                                (x & PGT_type_mask) <= PGT_root_page_table
-                               ? FLUSH_TLB | FLUSH_FORCE_IPI
+                               ? FLUSH_TLB | FLUSH_NO_ASSIST
                                : FLUSH_TLB);
                 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 26 12:11:43 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 26 May 2022 12:11:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337607.562259 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nuCL9-0003ei-Pu; Thu, 26 May 2022 12:11:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337607.562259; Thu, 26 May 2022 12: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 1nuCL9-0003ea-MN; Thu, 26 May 2022 12:11:43 +0000
Received: by outflank-mailman (input) for mailman id 337607;
 Thu, 26 May 2022 12: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 1nuCL8-0003dt-OT
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12: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 1nuCL8-0000Aj-Nq
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12:11:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nuCL8-0000AF-MW
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12: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=eSZGSXZSrdac3cqSTW8PYpc+ayUaFlX2ZmDtF26ZpWM=; b=z3k7MXogXVI2zJJ52xERgUO68+
	ihsP207jYKa2f16RuY5YBtliQI/7Gns4I51faCeDG6O/Q7K8D9zrGJLciMYYSZCsbn0V440LKoXMj
	WyZL1J7Me6DpIPqoHg9UTnZZFZru8SJjfJZx50u3enzepXRIFzzFQQxrx/VvdgCMqxD4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/flushtlb: remove flush_area check on system state
Message-Id: <E1nuCL8-0000AF-MW@xenbits.xenproject.org>
Date: Thu, 26 May 2022 12:11:42 +0000

commit 9f735ee4903f1b9f1966bb4ba5b5616b03ae08b5
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Wed May 25 11:09:46 2022 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed May 25 11:09:46 2022 +0200

    x86/flushtlb: remove flush_area check on system state
    
    Booting with Shadow Stacks leads to the following assert on a debug
    hypervisor:
    
    Assertion 'local_irq_is_enabled()' failed at arch/x86/smp.c:265
    ----[ Xen-4.17.0-10.24-d  x86_64  debug=y  Not tainted ]----
    CPU:    0
    RIP:    e008:[<ffff82d040345300>] flush_area_mask+0x40/0x13e
    [...]
    Xen call trace:
       [<ffff82d040345300>] R flush_area_mask+0x40/0x13e
       [<ffff82d040338a40>] F modify_xen_mappings+0xc5/0x958
       [<ffff82d0404474f9>] F arch/x86/alternative.c#_alternative_instructions+0xb7/0xb9
       [<ffff82d0404476cc>] F alternative_branches+0xf/0x12
       [<ffff82d04044e37d>] F __start_xen+0x1ef4/0x2776
       [<ffff82d040203344>] F __high_start+0x94/0xa0
    
    This is due to SYS_STATE_smp_boot being set before calling
    alternative_branches(), and the flush in modify_xen_mappings() then
    using flush_area_all() with interrupts disabled.  Note that
    alternative_branches() is called before APs are started, so the flush
    must be a local one (and indeed the cpumask passed to
    flush_area_mask() just contains one CPU).
    
    Take the opportunity to simplify a bit the logic and make flush_area()
    an alias of flush_area_all() in mm.c, taking into account that
    cpu_online_map just contains the BSP before APs are started.  This
    requires widening the assert in flush_area_mask() to allow being
    called with interrupts disabled as long as it's strictly a local only
    flush.
    
    The overall result is that a conditional can be removed from
    flush_area().
    
    While there also introduce an ASSERT to check that a vCPU state flush
    is not issued for the local CPU only.
    
    Fixes: 78e072bc37 ('x86/mm: avoid inadvertently degrading a TLB flush to local only')
    Suggested-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/arch/x86/mm.c  | 9 ++-------
 xen/arch/x86/smp.c | 5 ++++-
 2 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 4f759b0af2..04d5ec705d 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -5068,13 +5068,8 @@ l1_pgentry_t *virt_to_xen_l1e(unsigned long v)
 #define l1f_to_lNf(f) (((f) & _PAGE_PRESENT) ? ((f) |  _PAGE_PSE) : (f))
 #define lNf_to_l1f(f) (((f) & _PAGE_PRESENT) ? ((f) & ~_PAGE_PSE) : (f))
 
-/*
- * map_pages_to_xen() can be called early in boot before any other
- * CPUs are online. Use flush_area_local() in this case.
- */
-#define flush_area(v,f) (system_state < SYS_STATE_smp_boot ?    \
-                         flush_area_local((const void *)v, f) : \
-                         flush_area_all((const void *)v, f))
+/* flush_area_all() can be used prior to any other CPU being online.  */
+#define flush_area(v, f) flush_area_all((const void *)(v), f)
 
 #define L3T_INIT(page) (page) = ZERO_BLOCK_PTR
 
diff --git a/xen/arch/x86/smp.c b/xen/arch/x86/smp.c
index 0a02086966..b42603c351 100644
--- a/xen/arch/x86/smp.c
+++ b/xen/arch/x86/smp.c
@@ -262,7 +262,10 @@ void flush_area_mask(const cpumask_t *mask, const void *va, unsigned int flags)
 {
     unsigned int cpu = smp_processor_id();
 
-    ASSERT(local_irq_is_enabled());
+    /* Local flushes can be performed with interrupts disabled. */
+    ASSERT(local_irq_is_enabled() || cpumask_subset(mask, cpumask_of(cpu)));
+    /* Exclude use of FLUSH_VCPU_STATE for the local CPU. */
+    ASSERT(!cpumask_test_cpu(cpu, mask) || !(flags & FLUSH_VCPU_STATE));
 
     if ( (flags & ~(FLUSH_VCPU_STATE | FLUSH_ORDER_MASK)) &&
          cpumask_test_cpu(cpu, mask) )
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu May 26 12:11:53 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 26 May 2022 12:11:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.337609.562264 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nuCLJ-0003lv-RN; Thu, 26 May 2022 12:11:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 337609.562264; Thu, 26 May 2022 12: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 1nuCLJ-0003ln-Nx; Thu, 26 May 2022 12:11:53 +0000
Received: by outflank-mailman (input) for mailman id 337609;
 Thu, 26 May 2022 12: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 1nuCLI-0003lQ-Re
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12: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 1nuCLI-0000At-Qv
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12:11:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nuCLI-0000BC-Pv
 for xen-changelog@lists.xenproject.org; Thu, 26 May 2022 12: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=eVyvve8FBlLS4gJamzxS+QM+pQARzSc+L62TcGj/mdM=; b=Oy9spruw/WEXX97vwHiTgtDf6y
	1gnnMzGrR7nYWX13wsvoFEpXOiqRmqIZARf5y/4NiWNfD1NvV+YbIvS65aCNlECgB1ltOjHs16M/M
	giMawC6yH6NmnfSjCnEkErvWTbWajOoamMuH1EEo0KjIZqjfGSz8UEm1wY6vKoVcXvtA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/xenstore: fix event sending in introduce_domain()
Message-Id: <E1nuCLI-0000BC-Pv@xenbits.xenproject.org>
Date: Thu, 26 May 2022 12:11:52 +0000

commit 49dd52fb1311dadab29f6634d0bc1f4c022c357a
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Wed May 25 12:55:49 2022 +0200
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Wed May 25 12:10:03 2022 +0100

    tools/xenstore: fix event sending in introduce_domain()
    
    Commit fc2b57c9af46 ("xenstored: send an evtchn notification on
    introduce_domain") introduced a potential NULL dereference in case of
    Xenstore live update.
    
    Fix that by adding an appropriate check.
    
    Coverity-Id: 1504572
    Fixes: fc2b57c9af46 ("xenstored: send an evtchn notification on introduce_domain")
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 tools/xenstore/xenstored_domain.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/tools/xenstore/xenstored_domain.c b/tools/xenstore/xenstored_domain.c
index de88bf2a68..ead4c237d2 100644
--- a/tools/xenstore/xenstored_domain.c
+++ b/tools/xenstore/xenstored_domain.c
@@ -493,9 +493,11 @@ static struct domain *introduce_domain(const void *ctx,
 		/* Now domain belongs to its connection. */
 		talloc_steal(domain->conn, domain);
 
-		/* Notify the domain that xenstore is available */
-		interface->connection = XENSTORE_CONNECTED;
-		xenevtchn_notify(xce_handle, domain->port);
+		if (!restore) {
+			/* Notify the domain that xenstore is available */
+			interface->connection = XENSTORE_CONNECTED;
+			xenevtchn_notify(xce_handle, domain->port);
+		}
 
 		if (!is_master_domain && !restore)
 			fire_watches(NULL, ctx, "@introduceDomain", NULL,
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue May 31 20:11:12 2022
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 31 May 2022 20:11:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.340044.564977 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1nw8Cn-00026z-RW; Tue, 31 May 2022 20:11:05 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 340044.564977; Tue, 31 May 2022 20: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 1nw8Cn-00026r-Nb; Tue, 31 May 2022 20:11:05 +0000
Received: by outflank-mailman (input) for mailman id 340044;
 Tue, 31 May 2022 20: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 1nw8Cm-00026l-9D
 for xen-changelog@lists.xenproject.org; Tue, 31 May 2022 20: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 1nw8Cm-0003gW-6l
 for xen-changelog@lists.xenproject.org; Tue, 31 May 2022 20:11:04 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1nw8Cm-0002f8-5P
 for xen-changelog@lists.xenproject.org; Tue, 31 May 2022 20: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=bDoXedCF1FnrMDK+6KUBFVhCaRgSFhJpxtldmo7su5I=; b=qS1Ll4s2bzOCrHHLv8TW0R5QcA
	XLgjRkuxq/sdBtSvxmhVpoX0hqq1nWBdSJKpZPpvuaITzuL0O5DVJGVTDpzF7d6WL+yfKWV+JQJAG
	6KQrgg4eRKKmRpPgt+hDt6oBGMl1FXH9AfKHbJ1sbx0VL9V0lTMwmzO5MAmW6+PdasBc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen staging] init-dom0less: better snprintf checks
Message-Id: <E1nw8Cm-0002f8-5P@xenbits.xenproject.org>
Date: Tue, 31 May 2022 20:11:04 +0000

commit 09a6a71097e3e7d28eaa0f55e8f2c4b879c299f5
Author:     Stefano Stabellini <stefano.stabellini@xilinx.com>
AuthorDate: Tue May 24 16:35:44 2022 -0700
Commit:     Stefano Stabellini <stefano.stabellini@xilinx.com>
CommitDate: Tue May 31 13:01:24 2022 -0700

    init-dom0less: better snprintf checks
    
    snprintf returns the number of characters that would have been written
    to the final string if enough space had been available. A return value
    of size or more means that the output was truncated.
    
    Add a check for that in init-dom0less.
    
    Signed-off-by: Stefano Stabellini <stefano.stabellini@xilinx.com>
    Reviewed-by: Michal Orzel <michal.orzel@arm.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 tools/helpers/init-dom0less.c | 38 ++++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 16 deletions(-)

diff --git a/tools/helpers/init-dom0less.c b/tools/helpers/init-dom0less.c
index 42e74c4153..4c90dd6a0c 100644
--- a/tools/helpers/init-dom0less.c
+++ b/tools/helpers/init-dom0less.c
@@ -48,14 +48,16 @@ static bool do_xs_write_dom(struct xs_handle *xsh, xs_transaction_t t,
 {
     char full_path[STR_MAX_LENGTH];
     struct xs_permissions perms[2];
+    int rc;
 
     perms[0].id = domid;
     perms[0].perms = XS_PERM_NONE;
     perms[1].id = 0;
     perms[1].perms = XS_PERM_READ;
 
-    if (snprintf(full_path, STR_MAX_LENGTH,
-                 "/local/domain/%u/%s", domid, path) < 0)
+    rc = snprintf(full_path, STR_MAX_LENGTH,
+                  "/local/domain/%u/%s", domid, path);
+    if (rc < 0 || rc >= STR_MAX_LENGTH)
         return false;
     if (!xs_write(xsh, t, full_path, val, strlen(val)))
         return false;
@@ -66,9 +68,11 @@ static bool do_xs_write_libxl(struct xs_handle *xsh, xs_transaction_t t,
                               domid_t domid, char *path, char *val)
 {
     char full_path[STR_MAX_LENGTH];
+    int rc;
 
-    if (snprintf(full_path, STR_MAX_LENGTH,
-                 "/libxl/%u/%s", domid, path) < 0)
+    rc = snprintf(full_path, STR_MAX_LENGTH,
+                  "/libxl/%u/%s", domid, path);
+    if (rc < 0 || rc >= STR_MAX_LENGTH)
         return false;
     return xs_write(xsh, t, full_path, val, strlen(val));
 }
@@ -77,9 +81,11 @@ static bool do_xs_write_vm(struct xs_handle *xsh, xs_transaction_t t,
                            libxl_uuid uuid, char *path, char *val)
 {
     char full_path[STR_MAX_LENGTH];
+    int rc;
 
-    if (snprintf(full_path, STR_MAX_LENGTH,
-                 "/vm/" LIBXL_UUID_FMT "/%s", LIBXL_UUID_BYTES(uuid), path) < 0)
+    rc = snprintf(full_path, STR_MAX_LENGTH,
+                  "/vm/" LIBXL_UUID_FMT "/%s", LIBXL_UUID_BYTES(uuid), path);
+    if (rc < 0 || rc >= STR_MAX_LENGTH)
         return false;
     return xs_write(xsh, t, full_path, val, strlen(val));
 }
@@ -115,35 +121,35 @@ static int create_xenstore(struct xs_handle *xsh,
         return -errno;
     rc = snprintf(start_time_str, STR_MAX_LENGTH, "%jd.%02d",
             (intmax_t)start_time.tv_sec, (int)start_time.tv_usec / 10000);
-    if (rc < 0)
+    if (rc < 0 || rc >= STR_MAX_LENGTH)
         return rc;
 
     domid = info->domid;
     rc = snprintf(id_str, STR_MAX_LENGTH, "%u", domid);
-    if (rc < 0)
+    if (rc < 0 || rc >= STR_MAX_LENGTH)
         return rc;
     rc = snprintf(dom_name_str, STR_MAX_LENGTH, "dom0less-%u", domid);
-    if (rc < 0)
+    if (rc < 0 || rc >= STR_MAX_LENGTH)
         return rc;
     rc = snprintf(uuid_str, STR_MAX_LENGTH, LIBXL_UUID_FMT, LIBXL_UUID_BYTES(uuid));
-    if (rc < 0)
+    if (rc < 0 || rc >= STR_MAX_LENGTH)
         return rc;
     rc = snprintf(vm_val_str, STR_MAX_LENGTH,
                   "vm/" LIBXL_UUID_FMT, LIBXL_UUID_BYTES(uuid));
-    if (rc < 0)
+    if (rc < 0 || rc >= STR_MAX_LENGTH)
         return rc;
     rc = snprintf(max_memkb_str, STR_MAX_LENGTH, "%lu", info->max_memkb);
-    if (rc < 0)
+    if (rc < 0 || rc >= STR_MAX_LENGTH)
         return rc;
     rc = snprintf(target_memkb_str, STR_MAX_LENGTH, "%lu", info->current_memkb);
-    if (rc < 0)
+    if (rc < 0 || rc >= STR_MAX_LENGTH)
         return rc;
     rc = snprintf(ring_ref_str, STR_MAX_LENGTH, "%lld",
                   (GUEST_MAGIC_BASE >> XC_PAGE_SHIFT) + XENSTORE_PFN_OFFSET);
-    if (rc < 0)
+    if (rc < 0 || rc >= STR_MAX_LENGTH)
         return rc;
     rc = snprintf(xenstore_port_str, STR_MAX_LENGTH, "%u", xenstore_port);
-    if (rc < 0)
+    if (rc < 0 || rc >= STR_MAX_LENGTH)
         return rc;
 
 retry_transaction:
@@ -163,7 +169,7 @@ retry_transaction:
     if (!do_xs_write_dom(xsh, t, domid, "cpu", "")) goto err;
     for (i = 0; i < info->vcpu_max_id; i++) {
         rc = snprintf(cpu_str, STR_MAX_LENGTH, "cpu/%u/availability/", i);
-        if (rc < 0)
+        if (rc < 0 || rc >= STR_MAX_LENGTH)
             goto err;
         rc = -EIO;
         if (!do_xs_write_dom(xsh, t, domid, cpu_str,
--
generated by git-patchbot for /home/xen/git/xen.git#staging


