From xen-changelog-bounces@lists.xenproject.org Sat Jan 06 22:11:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 06 Jan 2024 22:11:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.662564.1032637 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rMEsh-0002Cq-8X; Sat, 06 Jan 2024 22:11:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 662564.1032637; Sat, 06 Jan 2024 22: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 1rMEsh-0002Ci-5q; Sat, 06 Jan 2024 22:11:03 +0000
Received: by outflank-mailman (input) for mailman id 662564;
 Sat, 06 Jan 2024 22: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 1rMEsf-0002Cc-WA
 for xen-changelog@lists.xenproject.org; Sat, 06 Jan 2024 22: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 1rMEsf-0005bP-LV
 for xen-changelog@lists.xenproject.org; Sat, 06 Jan 2024 22:11:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rMEsf-0005tY-K3
 for xen-changelog@lists.xenproject.org; Sat, 06 Jan 2024 22: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=xnWdoxq2ACGvsMIftP6U6Q0StpWwbqjrW/H7s4hNpaI=; b=aYf3GsRct+Sb95RoaifB/y+jaL
	IPyMpwswPtXyN5v8hI29erYJgMUcoNUxghp4MWj9gbF5C+sD30kI5sMeAj5In0Skl+Z7T9xxYDnJM
	qaoDi3/pS+U6g1BW16pszU3dnE62AaNPhomkwJEmNn5g595Us7uegCnVumPfZ7cRPyeU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: smmu-v3: address violations of MISRA C:2012 Rule 16.3
Message-Id: <E1rMEsf-0005tY-K3@xenbits.xenproject.org>
Date: Sat, 06 Jan 2024 22:11:01 +0000

commit 5a3ace21f3d779b291a2d305824b2820d88de7f1
Author:     Federico Serafini <federico.serafini@bugseng.com>
AuthorDate: Wed Dec 20 12:03:07 2023 +0100
Commit:     Stefano Stabellini <stefano.stabellini@amd.com>
CommitDate: Fri Jan 5 14:38:23 2024 -0800

    xen/arm: smmu-v3: address violations of MISRA C:2012 Rule 16.3
    
    Add a break statement at the end of the switch-clauses to address
    violations of MISRA C:2012 Rule 16.3 ("An unconditional `break'
    statement shall terminate every switch-clause").
    No funtional change.
    
    Signed-off-by: Federico Serafini <federico.serafini@bugseng.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com
---
 xen/drivers/passthrough/arm/smmu-v3.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/xen/drivers/passthrough/arm/smmu-v3.c b/xen/drivers/passthrough/arm/smmu-v3.c
index cdbb505134..bca5866b35 100644
--- a/xen/drivers/passthrough/arm/smmu-v3.c
+++ b/xen/drivers/passthrough/arm/smmu-v3.c
@@ -2200,6 +2200,7 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu)
 		fallthrough;
 	case IDR0_STALL_MODEL_STALL:
 		smmu->features |= ARM_SMMU_FEAT_STALLS;
+		break;
 	}
 
 	if (reg & IDR0_S2P)
@@ -2301,6 +2302,7 @@ static int arm_smmu_device_hw_probe(struct arm_smmu_device *smmu)
 		fallthrough;
 	case IDR5_OAS_48_BIT:
 		smmu->oas = 48;
+		break;
 	}
 
 	smmu->oas = min_t(unsigned long, PADDR_BITS, smmu->oas);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Jan 10 16:44:07 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 10 Jan 2024 16:44:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.665686.1035925 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbgS-0001Oy-2t; Wed, 10 Jan 2024 16:44:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 665686.1035925; Wed, 10 Jan 2024 16:44:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbgS-0001Or-0B; Wed, 10 Jan 2024 16:44:04 +0000
Received: by outflank-mailman (input) for mailman id 665686;
 Wed, 10 Jan 2024 16: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 1rNbgQ-0001Oi-8P
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16: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 1rNbgQ-0007fw-7a
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16:44:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rNbgQ-000289-6a
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16: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=l/DiC8LEVCQCDBKXdgsMskrluE82o+QojsA7pGqQHjQ=; b=neVbam9eCcKjXyxZteVqkBJtWS
	8hufEQWO68/QB/nc6FiZVRaKTDaezMxX/oyawp4xeqkfkn6I7+Njn+zi2vD4Pz6zwPNstv/GZ1RjK
	fJ2KNhoB9kb0iUYqI+ENxhLhyd48/i5ahGQCSjhAyBlKBJ1HySHHopJFZ29EVTh96lE4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/asm-generic: introduce generic div64.h header
Message-Id: <E1rNbgQ-000289-6a@xenbits.xenproject.org>
Date: Wed, 10 Jan 2024 16:44:02 +0000

commit e2c7111d6505d49274f9c0d0148a956bd62c3595
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Wed Dec 20 16:08:25 2023 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 8 10:13:48 2024 +0100

    xen/asm-generic: introduce generic div64.h header
    
    All archs have the do_div implementation for BITS_PER_LONG == 64
    so do_div64.h is moved to asm-generic.
    
    x86 and PPC were switched to asm-generic version of div64.h.
    Arm was switched partly because Arm has different implementation
    for 32-bits.
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Shawn Anastasio <sanastasio@raptorengineering.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/include/asm/div64.h  |  8 +-------
 xen/arch/ppc/include/asm/Makefile |  1 +
 xen/arch/ppc/include/asm/div64.h  | 14 --------------
 xen/arch/x86/include/asm/Makefile |  1 +
 xen/arch/x86/include/asm/div64.h  | 14 --------------
 xen/include/asm-generic/div64.h   | 27 +++++++++++++++++++++++++++
 6 files changed, 30 insertions(+), 35 deletions(-)

diff --git a/xen/arch/arm/include/asm/div64.h b/xen/arch/arm/include/asm/div64.h
index fc667a80f9..0459d5cc01 100644
--- a/xen/arch/arm/include/asm/div64.h
+++ b/xen/arch/arm/include/asm/div64.h
@@ -24,13 +24,7 @@
 
 #if BITS_PER_LONG == 64
 
-# define do_div(n,base) ({                                      \
-        uint32_t __base = (base);                               \
-        uint32_t __rem;                                         \
-        __rem = ((uint64_t)(n)) % __base;                       \
-        (n) = ((uint64_t)(n)) / __base;                         \
-        __rem;                                                  \
- })
+#include <asm-generic/div64.h>
 
 #elif BITS_PER_LONG == 32
 
diff --git a/xen/arch/ppc/include/asm/Makefile b/xen/arch/ppc/include/asm/Makefile
index 2da995bb2f..a8e848d4d0 100644
--- a/xen/arch/ppc/include/asm/Makefile
+++ b/xen/arch/ppc/include/asm/Makefile
@@ -1,5 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0-only
 generic-y += altp2m.h
+generic-y += div64.h
 generic-y += hardirq.h
 generic-y += hypercall.h
 generic-y += iocap.h
diff --git a/xen/arch/ppc/include/asm/div64.h b/xen/arch/ppc/include/asm/div64.h
deleted file mode 100644
index d213e50585..0000000000
--- a/xen/arch/ppc/include/asm/div64.h
+++ /dev/null
@@ -1,14 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef __ASM_PPC_DIV64_H__
-#define __ASM_PPC_DIV64_H__
-
-#include <xen/types.h>
-
-#define do_div(n, base) ({                       \
-    uint32_t base_ = (base);                     \
-    uint32_t rem_ = (uint64_t)(n) % base_;       \
-    (n) = (uint64_t)(n) / base_;                 \
-    rem_;                                        \
-})
-
-#endif /* __ASM_PPC_DIV64_H__ */
diff --git a/xen/arch/x86/include/asm/Makefile b/xen/arch/x86/include/asm/Makefile
index 874429ed30..daab34ff0a 100644
--- a/xen/arch/x86/include/asm/Makefile
+++ b/xen/arch/x86/include/asm/Makefile
@@ -1,2 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0-only
+generic-y += div64.h
 generic-y += percpu.h
diff --git a/xen/arch/x86/include/asm/div64.h b/xen/arch/x86/include/asm/div64.h
deleted file mode 100644
index dd49f64a3b..0000000000
--- a/xen/arch/x86/include/asm/div64.h
+++ /dev/null
@@ -1,14 +0,0 @@
-#ifndef __X86_DIV64
-#define __X86_DIV64
-
-#include <xen/types.h>
-
-#define do_div(n,base) ({                       \
-    uint32_t __base = (base);                   \
-    uint32_t __rem;                             \
-    __rem = ((uint64_t)(n)) % __base;           \
-    (n) = ((uint64_t)(n)) / __base;             \
-    __rem;                                      \
-})
-
-#endif
diff --git a/xen/include/asm-generic/div64.h b/xen/include/asm-generic/div64.h
new file mode 100644
index 0000000000..068d8a11ad
--- /dev/null
+++ b/xen/include/asm-generic/div64.h
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_DIV64
+#define __ASM_GENERIC_DIV64
+
+#include <xen/types.h>
+
+#if BITS_PER_LONG == 64
+
+#define do_div(n, divisor) ({                   \
+    uint32_t divisor_ = (divisor);              \
+    uint32_t rem_ = (uint64_t)(n) % divisor_;   \
+    (n) = (uint64_t)(n) / divisor_;             \
+    rem_;                                       \
+})
+
+#endif /* BITS_PER_LONG */
+
+#endif
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Jan 10 16:44:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 10 Jan 2024 16:44:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.665688.1035930 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbgc-0001R2-55; Wed, 10 Jan 2024 16:44:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 665688.1035930; Wed, 10 Jan 2024 16:44:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbgc-0001Qu-1t; Wed, 10 Jan 2024 16:44:14 +0000
Received: by outflank-mailman (input) for mailman id 665688;
 Wed, 10 Jan 2024 16: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 1rNbga-0001Qi-FR
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16: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 1rNbga-0007g5-D2
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16:44:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rNbga-00028k-9w
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16: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=K7Lc6VoRMvsjeIwZyZ+Sy7ak8l9J5VWbCYHh5zJhVYM=; b=OBke5EgjjVQJcw/LSA5+Fh4DeI
	F9bhVlfSa2qhUrEugbw8KO7MNb4JPr7GivxbYukD4e9HT2DwS9UBuNq8Wb9iDCvvVdFO+5/ddQo3w
	wb6c67eLDiIn9uQWSpKI9MO8NuV21by24jr9wPcD9EwVQ/m7gGDDbDKZF+Hwf9q7IA+4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/asm-generic: introduce stub header softirq.h
Message-Id: <E1rNbga-00028k-9w@xenbits.xenproject.org>
Date: Wed, 10 Jan 2024 16:44:12 +0000

commit 42b814b7ff0af0022cb93c912120b59b08173158
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Wed Dec 20 16:08:28 2023 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 8 10:15:19 2024 +0100

    xen/asm-generic: introduce stub header softirq.h
    
    <asm/softirq.h> is common between Arm, PPC and RISC-V so it is
    moved to asm-generic.
    
    Drop Arm and PPC's softirq.h and use asm-generic version instead.
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Reviewed-by: Michal Orzel <michal.orzel@amd.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Shawn Anastasio <sanastasio@raptorengineering.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/include/asm/Makefile  |  1 +
 xen/arch/arm/include/asm/softirq.h | 16 ----------------
 xen/arch/ppc/include/asm/Makefile  |  1 +
 xen/arch/ppc/include/asm/softirq.h |  8 --------
 xen/include/asm-generic/softirq.h  | 17 +++++++++++++++++
 5 files changed, 19 insertions(+), 24 deletions(-)

diff --git a/xen/arch/arm/include/asm/Makefile b/xen/arch/arm/include/asm/Makefile
index 8221429c2c..505cb49090 100644
--- a/xen/arch/arm/include/asm/Makefile
+++ b/xen/arch/arm/include/asm/Makefile
@@ -5,4 +5,5 @@ generic-y += iocap.h
 generic-y += paging.h
 generic-y += percpu.h
 generic-y += random.h
+generic-y += softirq.h
 generic-y += vm_event.h
diff --git a/xen/arch/arm/include/asm/softirq.h b/xen/arch/arm/include/asm/softirq.h
deleted file mode 100644
index 976e0ebd70..0000000000
--- a/xen/arch/arm/include/asm/softirq.h
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef __ASM_SOFTIRQ_H__
-#define __ASM_SOFTIRQ_H__
-
-#define NR_ARCH_SOFTIRQS       0
-
-#define arch_skip_send_event_check(cpu) 0
-
-#endif /* __ASM_SOFTIRQ_H__ */
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/arch/ppc/include/asm/Makefile b/xen/arch/ppc/include/asm/Makefile
index a8e848d4d0..3fd893f3e0 100644
--- a/xen/arch/ppc/include/asm/Makefile
+++ b/xen/arch/ppc/include/asm/Makefile
@@ -7,4 +7,5 @@ generic-y += iocap.h
 generic-y += paging.h
 generic-y += percpu.h
 generic-y += random.h
+generic-y += softirq.h
 generic-y += vm_event.h
diff --git a/xen/arch/ppc/include/asm/softirq.h b/xen/arch/ppc/include/asm/softirq.h
deleted file mode 100644
index a0b28a5e51..0000000000
--- a/xen/arch/ppc/include/asm/softirq.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef __ASM_PPC_SOFTIRQ_H__
-#define __ASM_PPC_SOFTIRQ_H__
-
-#define NR_ARCH_SOFTIRQS 0
-
-#define arch_skip_send_event_check(cpu) 0
-
-#endif /* __ASM_PPC_SOFTIRQ_H__ */
diff --git a/xen/include/asm-generic/softirq.h b/xen/include/asm-generic/softirq.h
new file mode 100644
index 0000000000..83be855e50
--- /dev/null
+++ b/xen/include/asm-generic/softirq.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_SOFTIRQ_H__
+#define __ASM_GENERIC_SOFTIRQ_H__
+
+#define NR_ARCH_SOFTIRQS       0
+
+#define arch_skip_send_event_check(cpu) 0
+
+#endif /* __ASM_GENERIC_SOFTIRQ_H__ */
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Jan 10 16:44:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 10 Jan 2024 16:44:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.665689.1035932 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbgm-0001U2-67; Wed, 10 Jan 2024 16:44:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 665689.1035932; Wed, 10 Jan 2024 16:44:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbgm-0001Tu-3I; Wed, 10 Jan 2024 16:44:24 +0000
Received: by outflank-mailman (input) for mailman id 665689;
 Wed, 10 Jan 2024 16: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 1rNbgk-0001Te-Ic
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16: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 1rNbgk-0007gD-Hw
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16:44:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rNbgk-00029N-FD
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16: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=xfidAAf9ZU2SPHru2aE2+6/QGkFI5vbyoMl6w0uIv5s=; b=Rh50OUyeblC/KBILvfkFZTbqeN
	0Klj/PHfpbbHZRIAysY7fJqOlLZ2qD/fVDjmtNFT/3R5s9UiJF72+RSj1PePu7V4fHAiiSXmspTfH
	23zkeLUrm7jTilMBYJkfw6IwgcjjC23u2wGnI+H4EMgKM2t68cNruBlJKNg0CMgKkYf0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>
Message-Id: <E1rNbgk-00029N-FD@xenbits.xenproject.org>
Date: Wed, 10 Jan 2024 16:44:22 +0000

commit 589d8cf146290bdc7f4347bced10c20bd14791f6
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Wed Dec 20 16:08:29 2023 +0200
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 8 10:15:44 2024 +0100

    xen: ifdef inclusion of <asm/grant_table.h> in <xen/grant_table.h>
    
    Ifdef-ing inclusion of <asm/grant_table.h> allows to avoid
    generation of empty <asm/grant_table.h> for cases when
    CONFIG_GRANT_TABLE is not enabled.
    
    The following changes were done for Arm:
    <asm/grant_table.h> should be included directly because it contains
    gnttab_dom0_frames() macros which is unique for Arm and is used in
    arch/arm/domain_build.c.
    <asm/grant_table.h> is #ifdef-ed with CONFIG_GRANT_TABLE in
    <xen/grant_table.h> so in case of !CONFIG_GRANT_TABLE gnttab_dom0_frames
    won't be available for use in arch/arm/domain_build.c.
    
    Suggested-by: Jan Beulich <jbeulich@suse.com>
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
    Acked-by: Shawn Anastasio <sanastasio@raptorengineering.com>
---
 xen/arch/arm/domain_build.c            | 1 +
 xen/arch/ppc/include/asm/grant_table.h | 5 -----
 xen/include/xen/grant_table.h          | 3 +++
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 6945b9755d..46161848dc 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -36,6 +36,7 @@
 
 #include <xen/irq.h>
 #include <xen/grant_table.h>
+#include <asm/grant_table.h>
 #include <xen/serial.h>
 
 static unsigned int __initdata opt_dom0_max_vcpus;
diff --git a/xen/arch/ppc/include/asm/grant_table.h b/xen/arch/ppc/include/asm/grant_table.h
deleted file mode 100644
index d0ff58dd3d..0000000000
--- a/xen/arch/ppc/include/asm/grant_table.h
+++ /dev/null
@@ -1,5 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-#ifndef __ASM_PPC_GRANT_TABLE_H__
-#define __ASM_PPC_GRANT_TABLE_H__
-
-#endif /* __ASM_PPC_GRANT_TABLE_H__ */
diff --git a/xen/include/xen/grant_table.h b/xen/include/xen/grant_table.h
index 85fe6b7b5e..50edfecfb6 100644
--- a/xen/include/xen/grant_table.h
+++ b/xen/include/xen/grant_table.h
@@ -26,7 +26,10 @@
 #include <xen/mm-frame.h>
 #include <xen/rwlock.h>
 #include <public/grant_table.h>
+
+#ifdef CONFIG_GRANT_TABLE
 #include <asm/grant_table.h>
+#endif
 
 struct grant_table;
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Jan 10 16:44:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 10 Jan 2024 16:44:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.665690.1035937 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbgw-0001Wn-7I; Wed, 10 Jan 2024 16:44:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 665690.1035937; Wed, 10 Jan 2024 16:44:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbgw-0001Wg-4u; Wed, 10 Jan 2024 16:44:34 +0000
Received: by outflank-mailman (input) for mailman id 665690;
 Wed, 10 Jan 2024 16: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 1rNbgu-0001WU-Lv
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16: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 1rNbgu-0007gM-Kt
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16:44:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rNbgu-0002A2-Jz
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16: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=lEoFf6x3Hx8Qrpz/DONU2q9x8v00wWoTKigv0l0Tt+g=; b=CHVqiW7F/esa2fIc3C51F2RMsz
	g2zCwF8pKOC8j8wYu7mjgwV5lV7xfdtYv+kINSszTaEBa96hDtpAYBRAFP4CjilG0rIQptGW7y4kF
	xciYXzzC6bqZZh4c/SrMgTStzV4942VpM0Yu/1SktCJlGNlBrsVjahJqknhc4xFbHK1c=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/public: add some more 9pfs xenstore paths
Message-Id: <E1rNbgu-0002A2-Jz@xenbits.xenproject.org>
Date: Wed, 10 Jan 2024 16:44:32 +0000

commit cc5a436002c418dc970677a3e99099968fd47ec3
Author:     Juergen Gross <jgross@suse.com>
AuthorDate: Mon Jan 8 10:16:42 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 8 10:16:42 2024 +0100

    xen/public: add some more 9pfs xenstore paths
    
    Add some optional additional backend paths for 9pfs PV devices. Those
    paths will be supported by the new xen-9pfsd 9pfs backend.
    
    Signed-off-by: Juergen Gross <jgross@suse.com>
    Reviewed-by: Jason Andryuk <jandryuk@gmail.com>
---
 xen/include/public/io/9pfs.h | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/xen/include/public/io/9pfs.h b/xen/include/public/io/9pfs.h
index 9ad2773082..ac4bf0434b 100644
--- a/xen/include/public/io/9pfs.h
+++ b/xen/include/public/io/9pfs.h
@@ -71,6 +71,40 @@
  *                 created on the guest (no user ownership squash or remap)
  *         Only "none" is supported in this version of the protocol.
  *
+ *    max-files
+ *         Values:        <uint32_t>
+ *
+ *         The maximum number of files (including directories) allowed for
+ *         this device. Backend support of this node is optional. If the node
+ *         is not present or the value is zero the number of files is not
+ *         limited.
+ *
+ *    max-open-files
+ *         Values:        <uint32_t>
+ *
+ *         The maximum number of files the guest is allowed to have opened
+ *         concurrently. Multiple concurrent opens of the same file are counted
+ *         individually. Backend support of this node is optional. If the node
+ *         is not present or the value is zero a backend specific default is
+ *         applied.
+ *
+ *    max-space
+ *         Values:        <uint32_t>
+ *
+ *         The maximum file space in MiBs the guest is allowed to use for this
+ *         device. Backend support of this node is optional. If the node is
+ *         not present or the value is zero the space is not limited.
+ *
+ *    auto-delete
+ *         Values:        <bool>
+ *
+ *         When set to "1" the backend will delete the file with the oldest
+ *         modification date below <path> in case the allowed maximum file
+ *         space (see <max-space>) or file number (see <max-files>) is being
+ *         exceeded due to guest activity (creation or extension of files).
+ *         Files currently opened by the guest won't be deleted. Backend
+ *         support of this node is optional.
+ *
  ******************************************************************************
  *                            Frontend XenBus Nodes
  ******************************************************************************
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Jan 10 16:44:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 10 Jan 2024 16:44:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.665691.1035941 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbh6-0001Zc-8t; Wed, 10 Jan 2024 16:44:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 665691.1035941; Wed, 10 Jan 2024 16:44:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbh6-0001ZU-6H; Wed, 10 Jan 2024 16:44:44 +0000
Received: by outflank-mailman (input) for mailman id 665691;
 Wed, 10 Jan 2024 16: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 1rNbh4-0001ZC-PN
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16: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 1rNbh4-0007gm-Ol
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16:44:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rNbh4-0002Ag-Mt
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16: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=vYbup2WZxT5JYInq7vhliV4kOcY/PMcJj8lvZe7zYkI=; b=v9XUHDekr1Yk3phLg9Uet6W/NV
	y4HsUu0a6hOSD/ZMNmhoKpK9E398WcKK7UHqLbtehbavmFfDkVqaybaQcj3GLNCnCrXWcGHGEDwKO
	oafN4MzOPefLiQJ+KV5AIFmn7ySBO9dAwxcaIw1n5sb4/RFXKzzQk5J50G+f9KxNpirs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/mwait-idle: fix ubsan warning
Message-Id: <E1rNbh4-0002Ag-Mt@xenbits.xenproject.org>
Date: Wed, 10 Jan 2024 16:44:42 +0000

commit 2467ab2a74463107132f7d929d2ff0e30a8b6fa3
Author:     Tamas K Lengyel <tamas.lengyel@intel.com>
AuthorDate: Mon Jan 8 10:16:58 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 8 10:16:58 2024 +0100

    x86/mwait-idle: fix ubsan warning
    
    Fix warning:
    (XEN) UBSAN: Undefined behaviour in arch/x86/cpu/mwait-idle.c:1300:44
    (XEN) left shift of 15 by 28 places cannot be represented in type 'int'
    originating from sklh_idle_state_table_update() and hence observable on
    one kind of CPU only.
    
    Fixes: 5a211704e88 ("mwait-idle: prevent SKL-H boot failure when C8+C9+C10 enabled")
    Signed-off-by: Tamas K Lengyel <tamas.lengyel@intel.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/include/asm/mwait.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/x86/include/asm/mwait.h b/xen/arch/x86/include/asm/mwait.h
index f377d9fdca..9298f987c4 100644
--- a/xen/arch/x86/include/asm/mwait.h
+++ b/xen/arch/x86/include/asm/mwait.h
@@ -4,7 +4,7 @@
 #include <xen/types.h>
 
 #define MWAIT_SUBSTATE_MASK		0xf
-#define MWAIT_CSTATE_MASK		0xf
+#define MWAIT_CSTATE_MASK		0xfU
 #define MWAIT_SUBSTATE_SIZE		4
 
 #define CPUID_MWAIT_LEAF		5
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Jan 10 16:44:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 10 Jan 2024 16:44:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.665692.1035944 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbhG-0001cI-AX; Wed, 10 Jan 2024 16:44:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 665692.1035944; Wed, 10 Jan 2024 16:44:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbhG-0001cA-7g; Wed, 10 Jan 2024 16:44:54 +0000
Received: by outflank-mailman (input) for mailman id 665692;
 Wed, 10 Jan 2024 16: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 1rNbhE-0001c0-SV
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16: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 1rNbhE-0007gt-Rn
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16:44:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rNbhE-0002BD-Qs
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16: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=8EWOERqhm+D1VD2zKNWYkwfzUlwbOzD8VYjy0T8Ux64=; b=i16gNFP1GcXepMgjcTbJ56BfHh
	mZ3y/UZ7MgAP6tribU8WKUIFwDMgjgGSQhK9UaG455Q4WN8O25oxK4Fp/LuCmP4RolTPYb96PL3O+
	laK1WOnfQ/gRu1A90kOEUV97FqAlhNB0jyXx2l7JcO3iQzUYnKNmb3c9ofh/XGSRP2f8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] VMX: drop vmx_virt_exception and make vmx_vmfunc static
Message-Id: <E1rNbhE-0002BD-Qs@xenbits.xenproject.org>
Date: Wed, 10 Jan 2024 16:44:52 +0000

commit f628fc8d18d3f5ab7ce93b6a08a3327f49444a73
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Jan 9 14:05:33 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Jan 9 14:05:33 2024 +0100

    VMX: drop vmx_virt_exception and make vmx_vmfunc static
    
    The variable was introduced by 69b830e5ffb4 ("VMX: VMFUNC and #VE
    definitions and detection") without any use and - violating Misra C:2012
    rule 8.4 - without a declaration. Since no use has appeared, drop it.
    
    For vmx_vmfunc the situation is similar, but not identical: It at least
    has one use. Convert it to be static (and make style adjustments while
    there).
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/hvm/vmx/vmcs.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
index 6711697ff6..0a5348bdc8 100644
--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -167,8 +167,7 @@ u32 vmx_secondary_exec_control __read_mostly;
 u32 vmx_vmexit_control __read_mostly;
 u32 vmx_vmentry_control __read_mostly;
 u64 vmx_ept_vpid_cap __read_mostly;
-u64 vmx_vmfunc __read_mostly;
-bool vmx_virt_exception __read_mostly;
+static uint64_t __read_mostly vmx_vmfunc;
 
 static DEFINE_PER_CPU_READ_MOSTLY(paddr_t, vmxon_region);
 static DEFINE_PER_CPU(paddr_t, current_vmcs);
@@ -475,8 +474,7 @@ static int vmx_init_vmcs_config(bool bsp)
         vmx_basic_msr              = ((u64)vmx_basic_msr_high << 32) |
                                      vmx_basic_msr_low;
         vmx_vmfunc                 = _vmx_vmfunc;
-        vmx_virt_exception         = !!(_vmx_secondary_exec_control &
-                                       SECONDARY_EXEC_ENABLE_VIRT_EXCEPTIONS);
+
         vmx_display_features();
 
         /* IA-32 SDM Vol 3B: VMCS size is never greater than 4kB. */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Jan 10 16:45:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 10 Jan 2024 16:45:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.665693.1035950 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbhQ-0001fI-Cy; Wed, 10 Jan 2024 16:45:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 665693.1035950; Wed, 10 Jan 2024 16:45:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbhQ-0001f7-98; Wed, 10 Jan 2024 16:45:04 +0000
Received: by outflank-mailman (input) for mailman id 665693;
 Wed, 10 Jan 2024 16:45:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rNbhO-0001et-W8
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16: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 1rNbhO-0007hQ-VK
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16:45:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rNbhO-0002C6-U6
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16: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=6/9LFQ0ewxK1LRJAOsb66/OHiFTNS282p0vpcF88v9g=; b=HrR+TJS+0OAYqdpp+vMM6wNFWw
	cH6M8XWAj+ysdUZBAApB4qYRQwEzwwjFZV6eVGndpxJy7TrqlXSiOykeRUR2SRgZhhpqVaeCHh2ts
	qqVhc1kAWc4sMXmtTiiI6CBlOy9OZWPud/nF3RTZtYqCXQEdEohnNfEDnZte80Ys+OpU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/HVM: hide SVM/VMX when their enabling is prohibited by firmware
Message-Id: <E1rNbhO-0002C6-U6@xenbits.xenproject.org>
Date: Wed, 10 Jan 2024 16:45:02 +0000

commit 0b5f149338e35a795bf609ce584640b0977f9e6c
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Jan 9 14:06:34 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Jan 9 14:06:34 2024 +0100

    x86/HVM: hide SVM/VMX when their enabling is prohibited by firmware
    
    ... or we fail to enable the functionality on the BSP for other reasons.
    The only place where hardware announcing the feature is recorded is the
    raw CPU policy/featureset.
    
    Inspired by https://lore.kernel.org/all/20230921114940.957141-1-pbonzini@redhat.com/.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/hvm/svm/svm.c  |  1 +
 xen/arch/x86/hvm/vmx/vmcs.c | 17 +++++++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c
index 88bda6fb4c..65f437e958 100644
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -2543,6 +2543,7 @@ const struct hvm_function_table * __init start_svm(void)
 
     if ( _svm_cpu_up(true) )
     {
+        setup_clear_cpu_cap(X86_FEATURE_SVM);
         printk("SVM: failed to initialise.\n");
         return NULL;
     }
diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
index 0a5348bdc8..4fe1213855 100644
--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -2162,6 +2162,23 @@ int __init vmx_vmcs_init(void)
 
     if ( !ret )
         register_keyhandler('v', vmcs_dump, "dump VT-x VMCSs", 1);
+    else
+    {
+        setup_clear_cpu_cap(X86_FEATURE_VMX);
+
+        /*
+         * _vmx_vcpu_up() may have made it past feature identification.
+         * Make sure all dependent features are off as well.
+         */
+        vmx_basic_msr              = 0;
+        vmx_pin_based_exec_control = 0;
+        vmx_cpu_based_exec_control = 0;
+        vmx_secondary_exec_control = 0;
+        vmx_vmexit_control         = 0;
+        vmx_vmentry_control        = 0;
+        vmx_ept_vpid_cap           = 0;
+        vmx_vmfunc                 = 0;
+    }
 
     return ret;
 }
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Jan 10 16:45:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 10 Jan 2024 16:45:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.665694.1035953 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbha-0001ip-F7; Wed, 10 Jan 2024 16:45:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 665694.1035953; Wed, 10 Jan 2024 16:45:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbha-0001ii-CW; Wed, 10 Jan 2024 16:45:14 +0000
Received: by outflank-mailman (input) for mailman id 665694;
 Wed, 10 Jan 2024 16:45:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rNbhZ-0001iY-3L
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16:45:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rNbhZ-0007hX-2c
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16:45:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rNbhZ-0002Ct-1k
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16:45:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=WBnrspP/5bVzhxiF+zfVpHauPL5LoMWL8jYVm3JZ1k0=; b=K3FuJ4Yj2Z1czgDJYJeszNYccM
	E6nZ+J801XbcSf4M4aiXGbLquS6qzL35hBZe0d6TUBCRfGf2T9pw8bbvl7nKpBR0xsDQmYD3fJ9cb
	Ephf8LVUdXKJa8gMtQyRuXrJ2Xlefd2jfD4FxlFBTBPUoEEHTtB/o/RaujtjrsmmuZso=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/HVM: drop tsc_scaling.setup() hook
Message-Id: <E1rNbhZ-0002Ct-1k@xenbits.xenproject.org>
Date: Wed, 10 Jan 2024 16:45:13 +0000

commit 48193fe00a8b874f35d15f8d1f2b3bd7a351d4e7
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Jan 9 14:07:17 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Jan 9 14:07:17 2024 +0100

    x86/HVM: drop tsc_scaling.setup() hook
    
    This was used by VMX only, and the intended VMCS write can as well
    happen from vmx_set_tsc_offset(), invoked (directly or indirectly)
    almost immediately after the present call sites of the hook.
    vmx_set_tsc_offset() isn't invoked frequently elsewhere, so the extra
    VMCS write shouldn't raise performance concerns.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/hvm/hvm.c             |  6 ------
 xen/arch/x86/hvm/vmx/vmx.c         | 16 +++-------------
 xen/arch/x86/include/asm/hvm/hvm.h |  3 ---
 3 files changed, 3 insertions(+), 22 deletions(-)

diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 523e0df57c..6e952748d6 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -1086,9 +1086,6 @@ static int cf_check hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h)
     v->arch.hvm.guest_cr[2] = ctxt.cr2;
     hvm_update_guest_cr(v, 2);
 
-    if ( hvm_funcs.tsc_scaling.setup )
-        alternative_vcall(hvm_funcs.tsc_scaling.setup, v);
-
     v->arch.msrs->tsc_aux = ctxt.msr_tsc_aux;
 
     hvm_set_guest_tsc_fixed(v, ctxt.tsc, d->arch.hvm.sync_tsc);
@@ -4033,9 +4030,6 @@ void hvm_vcpu_reset_state(struct vcpu *v, uint16_t cs, uint16_t ip)
     hvm_set_segment_register(v, x86_seg_gdtr, &reg);
     hvm_set_segment_register(v, x86_seg_idtr, &reg);
 
-    if ( hvm_funcs.tsc_scaling.setup )
-        alternative_vcall(hvm_funcs.tsc_scaling.setup, v);
-
     /* Sync AP's TSC with BSP's. */
     v->arch.hvm.cache_tsc_offset =
         v->domain->vcpu[0]->arch.hvm.cache_tsc_offset;
diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 5663bc0178..8ff675883c 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -1454,20 +1454,13 @@ static void cf_check vmx_handle_cd(struct vcpu *v, unsigned long value)
     }
 }
 
-static void cf_check vmx_setup_tsc_scaling(struct vcpu *v)
-{
-    if ( v->domain->arch.vtsc )
-        return;
-
-    vmx_vmcs_enter(v);
-    __vmwrite(TSC_MULTIPLIER, hvm_tsc_scaling_ratio(v->domain));
-    vmx_vmcs_exit(v);
-}
-
 static void cf_check vmx_set_tsc_offset(struct vcpu *v, u64 offset, u64 at_tsc)
 {
     vmx_vmcs_enter(v);
 
+    if ( !v->domain->arch.vtsc && cpu_has_vmx_tsc_scaling )
+        __vmwrite(TSC_MULTIPLIER, hvm_tsc_scaling_ratio(v->domain));
+
     if ( nestedhvm_vcpu_in_guestmode(v) )
         offset += nvmx_get_tsc_offset(v);
 
@@ -3027,10 +3020,7 @@ const struct hvm_function_table * __init start_vmx(void)
     }
 
     if ( cpu_has_vmx_tsc_scaling )
-    {
         vmx_function_table.tsc_scaling.ratio_frac_bits = 48;
-        vmx_function_table.tsc_scaling.setup = vmx_setup_tsc_scaling;
-    }
 
     model_specific_lbr = get_model_specific_lbr();
     lbr_tsx_fixup_check();
diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/hvm/hvm.h
index a4c1af19ac..985c1c14c6 100644
--- a/xen/arch/x86/include/asm/hvm/hvm.h
+++ b/xen/arch/x86/include/asm/hvm/hvm.h
@@ -240,9 +240,6 @@ struct hvm_function_table {
         uint8_t  ratio_frac_bits;
         /* maximum-allowed TSC scaling ratio */
         uint64_t max_ratio;
-
-        /* Architecture function to setup TSC scaling ratio */
-        void (*setup)(struct vcpu *v);
     } tsc_scaling;
 };
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Jan 10 16:45:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 10 Jan 2024 16:45:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.665695.1035956 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbhk-0001lV-Gg; Wed, 10 Jan 2024 16:45:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 665695.1035956; Wed, 10 Jan 2024 16:45:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rNbhk-0001lM-E6; Wed, 10 Jan 2024 16:45:24 +0000
Received: by outflank-mailman (input) for mailman id 665695;
 Wed, 10 Jan 2024 16:45:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rNbhj-0001lF-6w
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16:45:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rNbhj-0007hj-6M
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16:45:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rNbhj-0002DJ-4q
 for xen-changelog@lists.xenproject.org; Wed, 10 Jan 2024 16:45:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=VXt9EC3ItuozworwDnVPXrI72ns9cW6kk68SNQj32+E=; b=YbX6Ls08nKyAZwa9uaRwrOPNCB
	aOhHeapoMBZiB6bhv/1sv+3pBU3npbbftKhxx5EW90Yz2HrFnKLZxrB7QpqxNdJFdPtadQkSwDXf7
	oqBzuCXqMIx/FzBMeFoLWli3nAK8jKFAG83AWrxER6oT6/y/tOVuTN9Y4xTP+4qYpBs8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/iommu: introduce a rangeset to perform hwdom IOMMU setup
Message-Id: <E1rNbhj-0002DJ-4q@xenbits.xenproject.org>
Date: Wed, 10 Jan 2024 16:45:23 +0000

commit c27c8922f2c6995d688437b0758cec6a27d18320
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Tue Jan 9 14:07:49 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Jan 9 14:07:49 2024 +0100

    x86/iommu: introduce a rangeset to perform hwdom IOMMU setup
    
    This change just introduces the boilerplate code in order to use a rangeset
    when setting up the hardware domain IOMMU mappings.  The rangeset is never
    populated in this patch, so it's a non-functional change as far as the mappings
    the domain gets established.
    
    Note there will be a change for HVM domains (ie: PVH dom0) when the code
    introduced here gets used: the p2m mappings will be established using
    map_mmio_regions() instead of p2m_add_identity_entry(), so that ranges can be
    mapped with a single function call if possible.  Note that the interface of
    map_mmio_regions() doesn't allow creating read-only mappings, but so far there
    are no such mappings created for PVH dom0 in arch_iommu_hwdom_init().
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/drivers/passthrough/x86/iommu.c | 103 ++++++++++++++++++++++++++++++++++--
 1 file changed, 100 insertions(+), 3 deletions(-)

diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c
index 857dccb6a4..59b0c7e980 100644
--- a/xen/drivers/passthrough/x86/iommu.c
+++ b/xen/drivers/passthrough/x86/iommu.c
@@ -370,10 +370,88 @@ static unsigned int __hwdom_init hwdom_iommu_map(const struct domain *d,
     return perms;
 }
 
+struct map_data {
+    struct domain *d;
+    unsigned int flush_flags;
+    bool mmio_ro;
+};
+
+static int __hwdom_init cf_check identity_map(unsigned long s, unsigned long e,
+                                              void *data)
+{
+    struct map_data *info = data;
+    struct domain *d = info->d;
+    long rc;
+
+    if ( iommu_verbose )
+        printk(XENLOG_INFO " [%010lx, %010lx] R%c\n",
+               s, e, info->mmio_ro ? 'O' : 'W');
+
+    if ( paging_mode_translate(d) )
+    {
+        if ( info->mmio_ro )
+        {
+            ASSERT_UNREACHABLE();
+            /* End the rangeset iteration, as other regions will also fail. */
+            return -EOPNOTSUPP;
+        }
+        while ( (rc = map_mmio_regions(d, _gfn(s), e - s + 1, _mfn(s))) > 0 )
+        {
+            s += rc;
+            process_pending_softirqs();
+        }
+    }
+    else
+    {
+        const unsigned int perms = IOMMUF_readable | IOMMUF_preempt |
+                                   (info->mmio_ro ? 0 : IOMMUF_writable);
+
+        /*
+         * Read-only ranges are strictly MMIO and need an additional iomem
+         * permissions check.
+         */
+        while ( info->mmio_ro && s <= e && !iomem_access_permitted(d, s, e) )
+        {
+            /*
+             * Consume a frame per iteration until the remainder is accessible
+             * or there's nothing left to map.
+             */
+            if ( iomem_access_permitted(d, s, s) )
+            {
+                rc = iommu_map(d, _dfn(s), _mfn(s), 1, perms,
+                               &info->flush_flags);
+                if ( rc < 0 )
+                    break;
+                /* Must map a frame at least, which is what we request for. */
+                ASSERT(rc == 1);
+                process_pending_softirqs();
+            }
+            s++;
+        }
+        while ( (rc = iommu_map(d, _dfn(s), _mfn(s), e - s + 1,
+                                perms, &info->flush_flags)) > 0 )
+        {
+            s += rc;
+            process_pending_softirqs();
+        }
+    }
+    ASSERT(rc <= 0);
+    if ( rc )
+        printk(XENLOG_WARNING
+               "IOMMU identity mapping of [%lx, %lx] failed: %ld\n",
+               s, e, rc);
+
+    /* Ignore errors and attempt to map the remaining regions. */
+    return 0;
+}
+
 void __hwdom_init arch_iommu_hwdom_init(struct domain *d)
 {
     unsigned long i, top, max_pfn, start, count;
-    unsigned int flush_flags = 0, start_perms = 0;
+    unsigned int start_perms = 0;
+    struct rangeset *map;
+    struct map_data map_data = { .d = d };
+    int rc;
 
     BUG_ON(!is_hardware_domain(d));
 
@@ -397,6 +475,10 @@ void __hwdom_init arch_iommu_hwdom_init(struct domain *d)
     if ( iommu_hwdom_passthrough )
         return;
 
+    map = rangeset_new(NULL, NULL, 0);
+    if ( !map )
+        panic("IOMMU init: unable to allocate rangeset\n");
+
     max_pfn = (GB(4) >> PAGE_SHIFT) - 1;
     top = max(max_pdx, pfn_to_pdx(max_pfn) + 1);
 
@@ -427,7 +509,7 @@ void __hwdom_init arch_iommu_hwdom_init(struct domain *d)
         commit:
             while ( (rc = iommu_map(d, _dfn(start), _mfn(start), count,
                                     start_perms | IOMMUF_preempt,
-                                    &flush_flags)) > 0 )
+                                    &map_data.flush_flags)) > 0 )
             {
                 start += rc;
                 count -= rc;
@@ -451,8 +533,23 @@ void __hwdom_init arch_iommu_hwdom_init(struct domain *d)
             goto commit;
     }
 
+    if ( iommu_verbose )
+        printk(XENLOG_INFO "%pd: identity mappings for IOMMU:\n", d);
+
+    rc = rangeset_report_ranges(map, 0, ~0UL, identity_map, &map_data);
+    rangeset_destroy(map);
+    if ( !rc && is_pv_domain(d) )
+    {
+        map_data.mmio_ro = true;
+        rc = rangeset_report_ranges(mmio_ro_ranges, 0, ~0UL, identity_map,
+                                    &map_data);
+    }
+    if ( rc )
+        printk(XENLOG_WARNING "IOMMU unable to create %smappings: %d\n",
+               map_data.mmio_ro ? "read-only " : "", rc);
+
     /* Use if to avoid compiler warning */
-    if ( iommu_iotlb_flush_all(d, flush_flags) )
+    if ( iommu_iotlb_flush_all(d, map_data.flush_flags) )
         return;
 }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Jan 13 11:00:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 13 Jan 2024 11:00:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667030.1038018 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rObkC-0006E9-2I; Sat, 13 Jan 2024 11:00:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667030.1038018; Sat, 13 Jan 2024 11:00:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rObkB-0006Dk-VZ; Sat, 13 Jan 2024 11:00:03 +0000
Received: by outflank-mailman (input) for mailman id 667030;
 Sat, 13 Jan 2024 11:00:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rObkA-0005v2-G2
 for xen-changelog@lists.xenproject.org; Sat, 13 Jan 2024 11:00:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rObkA-0005OO-At
 for xen-changelog@lists.xenproject.org; Sat, 13 Jan 2024 11:00:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rObkA-0007zM-9q
 for xen-changelog@lists.xenproject.org; Sat, 13 Jan 2024 11:00:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=0/ahbxC+wKBrcmKExxe9x/vKCxr8bDZS0BKeJbPtS44=; b=tBbe7RBkVRxdqv/0H8hrx+O0++
	6q2y+pyqUtXIWesYhdyBOueHILdYJNr1qllRw7gH9XnkRY1xshn2R6RUclbwUrDW9MhdX4jj/F1Wu
	6xQnUBYHSJBI/L5yiF3byJ/tTflYe81sYX5ldtYJmjZd1QN/bh3gx7sZmZqWcDf/Dy44=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm32: head: Rework how the fixmap and early UART mapping are prepared
Message-Id: <E1rObkA-0007zM-9q@xenbits.xenproject.org>
Date: Sat, 13 Jan 2024 11:00:02 +0000

commit 0f9a688f60e7033c580a22aa3c89fd887b80fdec
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Fri Jan 12 10:45:09 2024 +0000
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Fri Jan 12 11:02:36 2024 +0000

    xen/arm32: head: Rework how the fixmap and early UART mapping are prepared
    
    Since commit 5e213f0f4d2c ("xen/arm32: head: Widen the use of the
    temporary mapping"), boot_second (used to cover regions like Xen and
    the fixmap) will not be mapped if the identity mapping overlap.
    
    So it is ok to prepare the fixmap table and link it in boot_second
    earlier. With that, the fixmap can also be used earlier via the
    temporary mapping.
    
    Therefore split setup_fixmap() in two:
        * The table is now linked in create_page_tables() because
          the boot page tables needs to be recreated for every CPU.
        * The early UART mapping is only added for the boot CPU0 as the
          fixmap table is not cleared when secondary CPUs boot.
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Michal Orzel <michal.orzel@amd.com>
---
 xen/arch/arm/arm32/mmu/head.S | 62 +++++++++++--------------------------------
 1 file changed, 15 insertions(+), 47 deletions(-)

diff --git a/xen/arch/arm/arm32/mmu/head.S b/xen/arch/arm/arm32/mmu/head.S
index 4e6395e787..bb3980843a 100644
--- a/xen/arch/arm/arm32/mmu/head.S
+++ b/xen/arch/arm/arm32/mmu/head.S
@@ -165,11 +165,6 @@
  * Rebuild the boot pagetable's first-level entries. The structure
  * is described in mm.c.
  *
- * After the CPU enables paging it will add the fixmap mapping
- * to these page tables, however this may clash with the 1:1
- * mapping. So each CPU must rebuild the page tables here with
- * the 1:1 in place.
- *
  * Inputs:
  *   r9 : paddr(start)
  *   r10: phys offset
@@ -197,6 +192,10 @@ create_page_tables:
         add   r5, r5, #PAGE_SIZE            /* r5 := Next table */
 .endr
 
+        /* Map the fixmap into boot_second */
+        mov_w r0, FIXMAP_ADDR(0)
+        create_table_entry boot_second, xen_fixmap, r0, 2
+
         /*
          * Find the size of Xen in pages and multiply by the size of a
          * PTE. This will then be compared in the mapping loop below.
@@ -432,6 +431,7 @@ ENDPROC(enable_secondary_cpu_mm)
  * Inputs:
  *   r9 : paddr(start)
  *   r10: phys offset
+ *   r11: UART physical address
  *   lr : Virtual address to return to.
  *
  * Output:
@@ -442,19 +442,20 @@ ENDPROC(enable_secondary_cpu_mm)
 ENTRY(enable_boot_cpu_mm)
         mov   r6, lr
 
+#ifdef CONFIG_EARLY_PRINTK
+        /*
+         * Add the UART mapping to the fixmap so the UART can be used
+         * as the MMU is on. This only needs to be done on the boot CPU.
+         */
+        mov_w r0, EARLY_UART_VIRTUAL_ADDRESS
+        create_mapping_entry xen_fixmap, r0, r11, type=PT_DEV_L3
+#endif
+
         bl    create_page_tables
 
         /* Address in the runtime mapping to jump to after the MMU is enabled */
-        mov_w lr, 1f
-        b     enable_mmu
-1:
         mov   lr, r6
-
-        /*
-         * Prepare the fixmap. The function will return to the virtual address
-         * requested by the caller.
-         */
-        b     setup_fixmap
+        b     enable_mmu
 ENDPROC(enable_boot_cpu_mm)
 
 /*
@@ -503,39 +504,6 @@ remove_temporary_mapping:
         mov  pc, lr
 ENDPROC(remove_temporary_mapping)
 
-/*
- * Map the UART in the fixmap (when earlyprintk is used) and hook the
- * fixmap table in the page tables.
- *
- * The fixmap cannot be mapped in create_page_tables because it may
- * clash with the 1:1 mapping.
- *
- * Inputs:
- *   r10: Physical offset
- *   r11: Early UART base physical address
- *
- * Clobbers r0 - r4
- */
-setup_fixmap:
-#if defined(CONFIG_EARLY_PRINTK)
-        /* Add UART to the fixmap table */
-        mov_w r0, EARLY_UART_VIRTUAL_ADDRESS
-        create_mapping_entry xen_fixmap, r0, r11, type=PT_DEV_L3
-#endif
-        /* Map fixmap into boot_second */
-        mov_w r0, FIXMAP_ADDR(0)
-        create_table_entry boot_second, xen_fixmap, r0, 2
-        /* Ensure any page table updates made above have occurred. */
-        dsb   nshst
-        /*
-         * The fixmap area will be used soon after. So ensure no hardware
-         * translation happens before the dsb completes.
-         */
-        isb
-
-        mov   pc, lr
-ENDPROC(setup_fixmap)
-
 /* Fail-stop */
 fail:   PRINT("- Boot failed -\r\n")
 1:      wfe
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Jan 13 11:00:15 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 13 Jan 2024 11:00:15 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667031.1038022 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rObkM-0006fT-3T; Sat, 13 Jan 2024 11:00:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667031.1038022; Sat, 13 Jan 2024 11:00:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rObkM-0006fL-0r; Sat, 13 Jan 2024 11:00:14 +0000
Received: by outflank-mailman (input) for mailman id 667031;
 Sat, 13 Jan 2024 11:00:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rObkK-0006fE-FE
 for xen-changelog@lists.xenproject.org; Sat, 13 Jan 2024 11:00:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rObkK-0005OS-EE
 for xen-changelog@lists.xenproject.org; Sat, 13 Jan 2024 11:00:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rObkK-00080D-Cx
 for xen-changelog@lists.xenproject.org; Sat, 13 Jan 2024 11:00:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=QtBiaRgYH5k5+Rc1bFtq8wQegyG8gjqIsVIgN6d/BDA=; b=L7gKQt9GBK/WJYNr0BEmto/Lm8
	pGE4PtxCMykd/EjdtzCXrArRs2ajqWgpKOHs4ztfeFs60qhq3zIk4Gj374VnLDpjJ5mkfAYOAH1by
	Ok8YOnyUVDP+xI92pTOK9y0WQJIF+O5tTBOIND1wuH6fSJTh2mocdsnbHMAQ71ApiDj8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/common: Don't dereference overlay_node after checking that it is NULL
Message-Id: <E1rObkK-00080D-Cx@xenbits.xenproject.org>
Date: Sat, 13 Jan 2024 11:00:12 +0000

commit 89c384c525fff7ec8bec1e36653d480ffcb86069
Author:     Javi Merino <javi.merino@cloud.com>
AuthorDate: Thu Jan 11 12:09:27 2024 +0000
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Fri Jan 12 11:03:36 2024 +0000

    xen/common: Don't dereference overlay_node after checking that it is NULL
    
    In remove_nodes(), overlay_node is dereferenced when printing the
    error message even though it is known to be NULL.  Return without
    printing as an error message is already printed by the caller.
    
    The semantic patch that spots this code is available in
    
    https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/scripts/coccinelle/null/deref_null.cocci?id=1f874787ed9a2d78ed59cb21d0d90ac0178eceb0
    
    Fixes: 7e5c4a8b86f1 ("xen/arm: Implement device tree node removal functionalities")
    Signed-off-by: Javi Merino <javi.merino@cloud.com>
    Reviewed-by: Vikram Garhwal <vikram.garhwal@amd.com>
---
 xen/common/dt-overlay.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/xen/common/dt-overlay.c b/xen/common/dt-overlay.c
index 5663a049e9..1b197381f6 100644
--- a/xen/common/dt-overlay.c
+++ b/xen/common/dt-overlay.c
@@ -427,11 +427,7 @@ static int remove_nodes(const struct overlay_track *tracker)
     {
         overlay_node = (struct dt_device_node *)tracker->nodes_address[j];
         if ( overlay_node == NULL )
-        {
-            printk(XENLOG_ERR "Device %s is not present in the tree. Removing nodes failed\n",
-                   overlay_node->full_name);
             return -EINVAL;
-        }
 
         rc = remove_descendant_nodes_resources(overlay_node);
         if ( rc )
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Jan 13 11:00:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 13 Jan 2024 11:00:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667032.1038027 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rObkW-0006hZ-69; Sat, 13 Jan 2024 11:00:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667032.1038027; Sat, 13 Jan 2024 11:00:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rObkW-0006hR-2K; Sat, 13 Jan 2024 11:00:24 +0000
Received: by outflank-mailman (input) for mailman id 667032;
 Sat, 13 Jan 2024 11:00:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rObkU-0006hK-Ld
 for xen-changelog@lists.xenproject.org; Sat, 13 Jan 2024 11:00:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rObkU-0005Ov-Kt
 for xen-changelog@lists.xenproject.org; Sat, 13 Jan 2024 11:00:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rObkU-00080m-GL
 for xen-changelog@lists.xenproject.org; Sat, 13 Jan 2024 11:00:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=u/I5IXzveYWSX8TXsngnyhMuYg7XX/fzPhcj5U5sTvE=; b=kWAlzovoqSBhgGvN+HQtNVhlmy
	avCqPKjNkNySq/Z55vfuLexxoJlwokGpPW1rOsinrQhTTx7sDn7SfRIGcne/ajzJEnRxznlViUvGi
	XRCC/ZIbA1Rhnz0yiKg0UCMDWWgLsQNvTYbYH5a210sFWoYLoWwCLDUBChh0OHD6HjBE=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm: bootfdt: Harden handling of malformed mem reserve map
Message-Id: <E1rObkU-00080m-GL@xenbits.xenproject.org>
Date: Sat, 13 Jan 2024 11:00:22 +0000

commit 410837189edc7a5abfe018a71dee1084d8423849
Author:     Shawn Anastasio <sanastasio@raptorengineering.com>
AuthorDate: Thu Jan 11 17:24:22 2024 -0600
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Fri Jan 12 11:04:54 2024 +0000

    xen/arm: bootfdt: Harden handling of malformed mem reserve map
    
    The early_print_info routine in bootfdt.c incorrectly stores the result
    of a call to fdt_num_mem_rsv() in an unsigned int, which results in the
    negative error code being interpreted incorrectly in a subsequent loop
    in the case where the device tree is malformed. Fix this by properly
    checking the return code for an error and calling panic().
    
    Signed-off-by: Shawn Anastasio <sanastasio@raptorengineering.com>
    Reviewed-by: Michal Orzel <michal.orzel@amd.com>
---
 xen/arch/arm/bootfdt.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/bootfdt.c b/xen/arch/arm/bootfdt.c
index 1cbac3cb2a..35dbdf3384 100644
--- a/xen/arch/arm/bootfdt.c
+++ b/xen/arch/arm/bootfdt.c
@@ -463,7 +463,8 @@ static void __init early_print_info(void)
     struct meminfo *mem_resv = &bootinfo.reserved_mem;
     struct bootmodules *mods = &bootinfo.modules;
     struct bootcmdlines *cmds = &bootinfo.cmdlines;
-    unsigned int i, j, nr_rsvd;
+    unsigned int i, j;
+    int nr_rsvd;
 
     for ( i = 0; i < mi->nr_banks; i++ )
         printk("RAM: %"PRIpaddr" - %"PRIpaddr"\n",
@@ -478,6 +479,9 @@ static void __init early_print_info(void)
                 boot_module_kind_as_string(mods->module[i].kind));
 
     nr_rsvd = fdt_num_mem_rsv(device_tree_flattened);
+    if ( nr_rsvd < 0 )
+        panic("Parsing FDT memory reserve map failed (%d)\n", nr_rsvd);
+
     for ( i = 0; i < nr_rsvd; i++ )
     {
         paddr_t s, e;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Jan 13 11:00:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 13 Jan 2024 11:00:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667033.1038030 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rObkg-0006kE-6R; Sat, 13 Jan 2024 11:00:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667033.1038030; Sat, 13 Jan 2024 11:00:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rObkg-0006k7-3j; Sat, 13 Jan 2024 11:00:34 +0000
Received: by outflank-mailman (input) for mailman id 667033;
 Sat, 13 Jan 2024 11:00:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rObke-0006jg-QS
 for xen-changelog@lists.xenproject.org; Sat, 13 Jan 2024 11:00:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rObke-0005P4-OV
 for xen-changelog@lists.xenproject.org; Sat, 13 Jan 2024 11:00:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rObke-00081F-NM
 for xen-changelog@lists.xenproject.org; Sat, 13 Jan 2024 11:00:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=VSon4xVl2n9GmnXnfUSEcEhXWDihn4A+ry1YA2UTk10=; b=2Ciha0/jsJYRPBwiQQ5szN44P1
	f9j+O3SJaE8K/ISTa0hHRLPGYN//AJXO7OdTAWYaqke7JDHhZnQxE39PVd+yBjr591E3kcex5KvWy
	NhIuLrp6566BwkIl2o4eDDNeJ6H/t05RgxhN0tNyxEM9chZ8JPX774CR0UBOw5pptrlY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm32: head: Improve logging in head.S
Message-Id: <E1rObke-00081F-NM@xenbits.xenproject.org>
Date: Sat, 13 Jan 2024 11:00:32 +0000

commit 1ec3fe1f664fa837daf31e9fa8938f6109464f28
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Fri Jan 12 11:54:31 2024 +0000
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Fri Jan 12 11:54:49 2024 +0000

    xen/arm32: head: Improve logging in head.S
    
    The sequence to enable the MMU on arm32 is quite complex as we may need
    to jump to a temporary mapping to map Xen.
    
    Recently, we had one bug in the logic (see f5a49eb7f8b3 ("xen/arm32:
    head: Add mising isb in switch_to_runtime_mapping()") and it was
    a pain to debug because there are no logging.
    
    In order to improve the logging in the MMU switch we need to add
    support for early printk while running on the identity mapping
    and also on the temporary mapping.
    
    For the identity mapping, we have only the first page of Xen mapped.
    So all the strings should reside in the first page. For that purpose
    a new macro PRINT_ID is introduced.
    
    For the temporary mapping, the fixmap is already linked in the temporary
    area (and so does the UART). So we just need to update the register
    storing the UART address (i.e. r11) to point to the UART temporary
    mapping.
    
    Take the opportunity to introduce mov_w_on_cond in order to
    conditionally execute mov_w and avoid branches.
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Michal Orzel <michal.orzel@amd.com>
---
 xen/arch/arm/arm32/head.S               |  9 --------
 xen/arch/arm/arm32/mmu/head.S           | 39 +++++++++++++++++++++++++++++++++
 xen/arch/arm/include/asm/arm32/macros.h | 33 ++++++++++++++++++++--------
 xen/arch/arm/include/asm/asm_defns.h    |  6 +++--
 xen/arch/arm/include/asm/early_printk.h |  3 +++
 xen/arch/arm/include/asm/mmu/layout.h   |  4 ++++
 xen/arch/arm/mmu/setup.c                |  3 +++
 xen/arch/arm/xen.lds.S                  |  1 +
 8 files changed, 78 insertions(+), 20 deletions(-)

diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S
index 34ab14a9e2..99d7d4aa63 100644
--- a/xen/arch/arm/arm32/head.S
+++ b/xen/arch/arm/arm32/head.S
@@ -98,10 +98,6 @@ past_zImage:
         b     enable_boot_cpu_mm
 
 primary_switched:
-#ifdef CONFIG_EARLY_PRINTK
-        /* Use a virtual address to access the UART. */
-        mov_w r11, EARLY_UART_VIRTUAL_ADDRESS
-#endif
         bl    zero_bss
         PRINT("- Ready -\r\n")
         /* Setup the arguments for start_xen and jump to C world */
@@ -142,12 +138,7 @@ GLOBAL(init_secondary)
 
         mov_w lr, secondary_switched
         b     enable_secondary_cpu_mm
-
 secondary_switched:
-#ifdef CONFIG_EARLY_PRINTK
-        /* Use a virtual address to access the UART. */
-        mov_w r11, EARLY_UART_VIRTUAL_ADDRESS
-#endif
         PRINT("- Ready -\r\n")
         /* Jump to C world */
         mov_w r2, start_secondary
diff --git a/xen/arch/arm/arm32/mmu/head.S b/xen/arch/arm/arm32/mmu/head.S
index bb3980843a..1e2bbf0c82 100644
--- a/xen/arch/arm/arm32/mmu/head.S
+++ b/xen/arch/arm/arm32/mmu/head.S
@@ -298,6 +298,21 @@ enable_mmu:
         mcr   CP32(r0, HSCTLR)       /* now paging is enabled */
         isb                          /* Now, flush the icache */
 
+        /*
+         * At this stage, the UART address will depend on whether the
+         * temporary mapping was created or not.
+         *
+         * If it was, then the UART will be mapped in the temporary
+         * area. Otherwise, it will be mapped at runtime virtual
+         * mapping.
+         */
+#ifdef CONFIG_EARLY_PRINTK
+        teq   r12, #1               /* Was the temporary mapping created? */
+        mov_w_on_cond eq, r11, TEMPORARY_EARLY_UART_VIRTUAL_ADDRESS
+        mov_w_on_cond ne, r11, EARLY_UART_VIRTUAL_ADDRESS
+#endif
+        PRINT_ID("- Paging turned on -\r\n")
+
         /*
          * The MMU is turned on and we are in the 1:1 mapping. Switch
          * to the runtime mapping.
@@ -307,6 +322,17 @@ enable_mmu:
         b     switch_to_runtime_mapping
 1:
         mov   lr, r5                /* Restore LR */
+
+        /*
+         * Now we are running at the runtime address. The UART can
+         * be accessed using its runtime virtual address.
+         */
+#ifdef CONFIG_EARLY_PRINTK
+        mov_w r11, EARLY_UART_VIRTUAL_ADDRESS
+#endif
+
+        PRINT("- Switched to the runtime mapping -\r\n")
+
         /*
          * At this point, either the 1:1 map or the temporary mapping
          * will be present. The former may clash with other parts of the
@@ -348,12 +374,14 @@ switch_to_runtime_mapping:
         teq   r12, #0
         beq   ready_to_switch
 
+        PRINT_ID("- Switching to the temporary mapping -\r\n")
         /* We are still in the 1:1 mapping. Jump to the temporary Virtual address. */
         mov_w r0, 1f
         add   r0, r0, #XEN_TEMPORARY_OFFSET /* r0 := address in temporary mapping */
         mov   pc, r0
 
 1:
+        PRINT("- Running on the temporary mapping  -\r\n")
         /* Remove boot_second_id */
         mov   r2, #0
         mov   r3, #0
@@ -364,6 +392,8 @@ switch_to_runtime_mapping:
 
         flush_xen_tlb_local r0
 
+        PRINT("- 1:1 mapping removed -\r\n")
+
         /* Map boot_second into boot_pgtable */
         mov_w r0, XEN_VIRT_START
         create_table_entry boot_pgtable, boot_second, r0, 1
@@ -376,7 +406,10 @@ switch_to_runtime_mapping:
          */
         isb
 
+        PRINT("- Runtime mapping mapped -\r\n")
 ready_to_switch:
+        PRINT_ID("- Jumping to runtime address -\r\n")
+
         mov   pc, lr
 ENDPROC(switch_to_runtime_mapping)
 
@@ -404,6 +437,8 @@ ENTRY(enable_secondary_cpu_mm)
         mov_w lr, 1f
         b     enable_mmu
 1:
+        PRINT("- Switching to the runtime page-tables -\r\n")
+
         /*
          * Non-boot CPUs need to move on to the proper pagetables, which were
          * setup in prepare_secondary_mm.
@@ -469,6 +504,8 @@ ENDPROC(enable_boot_cpu_mm)
  * Clobbers r0 - r3
  */
 remove_identity_mapping:
+        PRINT("- Removing the identity mapping -\r\n")
+
         /* r2:r3 := invalid page-table entry */
         mov   r2, #0x0
         mov   r3, #0x0
@@ -489,6 +526,8 @@ ENDPROC(remove_identity_mapping)
  * Clobbers r0 - r3
  */
 remove_temporary_mapping:
+        PRINT("- Removing the temporary mapping -\r\n")
+
         /* r2:r3 := invalid page-table entry */
         mov   r2, #0
         mov   r3, #0
diff --git a/xen/arch/arm/include/asm/arm32/macros.h b/xen/arch/arm/include/asm/arm32/macros.h
index b84666c764..db681a7c7e 100644
--- a/xen/arch/arm/include/asm/arm32/macros.h
+++ b/xen/arch/arm/include/asm/arm32/macros.h
@@ -9,9 +9,13 @@
  * Move an immediate constant into a 32-bit register using movw/movt
  * instructions.
  */
+.macro mov_w_on_cond cond, reg, word
+        movw\cond  \reg, #:lower16:\word
+        movt\cond  \reg, #:upper16:\word
+.endm
+
 .macro mov_w reg, word
-        movw  \reg, #:lower16:\word
-        movt  \reg, #:upper16:\word
+        mov_w_on_cond al, \reg, \word
 .endm
 
 /*
@@ -29,16 +33,26 @@
 
 #ifdef CONFIG_EARLY_PRINTK
 /*
- * Macro to print a string to the UART, if there is one.
+ * Macros to print a string to the UART, if there is one.
+ *
+ * There are multiple flavors:
+ *  - PRINT_SECT(section, string): The @string will be located in @section
+ *  - PRINT(): The string will be located in .rodata.str.
+ *  - PRINT_ID(): When Xen is running on the Identity Mapping, it is
+ *    only possible to have a limited amount of Xen. This will create
+ *    the string in .rodata.idmap which will always be mapped.
  *
  * Clobbers r0 - r3
  */
-#define PRINT(_s)           \
-        mov   r3, lr       ;\
-        adr_l r0, 98f      ;\
-        bl    asm_puts     ;\
-        mov   lr, r3       ;\
-        RODATA_STR(98, _s)
+#define PRINT_SECT(section, string)         \
+        mov   r3, lr                       ;\
+        adr_l r0, 98f                      ;\
+        bl    asm_puts                     ;\
+        mov   lr, r3                       ;\
+        RODATA_SECT(section, 98, string)
+
+#define PRINT(string) PRINT_SECT(.rodata.str, string)
+#define PRINT_ID(string) PRINT_SECT(.rodata.idmap, string)
 
 /*
  * Macro to print the value of register \rb
@@ -54,6 +68,7 @@
 
 #else /* CONFIG_EARLY_PRINTK */
 #define PRINT(s)
+#define PRINT_ID(s)
 
 .macro print_reg rb
 .endm
diff --git a/xen/arch/arm/include/asm/asm_defns.h b/xen/arch/arm/include/asm/asm_defns.h
index 29a9dbb002..ec803c0a37 100644
--- a/xen/arch/arm/include/asm/asm_defns.h
+++ b/xen/arch/arm/include/asm/asm_defns.h
@@ -22,11 +22,13 @@
 # error "unknown ARM variant"
 #endif
 
-#define RODATA_STR(label, msg)                  \
-.pushsection .rodata.str, "aMS", %progbits, 1 ; \
+#define RODATA_SECT(section, label, msg)         \
+.pushsection section, "aMS", %progbits, 1 ;     \
 label:  .asciz msg;                             \
 .popsection
 
+#define RODATA_STR(label, msg) RODATA_SECT(.rodata.str, label, msg)
+
 #define ASM_INT(label, val)                 \
     .p2align 2;                             \
 label: .long (val);                         \
diff --git a/xen/arch/arm/include/asm/early_printk.h b/xen/arch/arm/include/asm/early_printk.h
index c5149b2976..c1e84f8b00 100644
--- a/xen/arch/arm/include/asm/early_printk.h
+++ b/xen/arch/arm/include/asm/early_printk.h
@@ -19,6 +19,9 @@
 #define EARLY_UART_VIRTUAL_ADDRESS \
     (FIXMAP_ADDR(FIXMAP_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
 
+#define TEMPORARY_EARLY_UART_VIRTUAL_ADDRESS \
+    (TEMPORARY_FIXMAP_ADDR(FIXMAP_CONSOLE) + (CONFIG_EARLY_UART_BASE_ADDRESS & ~PAGE_MASK))
+
 #endif /* !CONFIG_EARLY_PRINTK */
 
 #endif
diff --git a/xen/arch/arm/include/asm/mmu/layout.h b/xen/arch/arm/include/asm/mmu/layout.h
index eac7eef885..a3b546465b 100644
--- a/xen/arch/arm/include/asm/mmu/layout.h
+++ b/xen/arch/arm/include/asm/mmu/layout.h
@@ -116,6 +116,10 @@
       (TEMPORARY_AREA_FIRST_SLOT << XEN_PT_LEVEL_SHIFT(1)))
 
 #define TEMPORARY_XEN_VIRT_START    TEMPORARY_AREA_ADDR(XEN_VIRT_START)
+#define TEMPORARY_FIXMAP_VIRT_START TEMPORARY_AREA_ADDR(FIXMAP_VIRT_START)
+
+#define TEMPORARY_FIXMAP_ADDR(n)                    \
+     (TEMPORARY_FIXMAP_VIRT_START + (n) * PAGE_SIZE)
 
 #else /* ARM_64 */
 
diff --git a/xen/arch/arm/mmu/setup.c b/xen/arch/arm/mmu/setup.c
index d5264e51bc..72725840b6 100644
--- a/xen/arch/arm/mmu/setup.c
+++ b/xen/arch/arm/mmu/setup.c
@@ -120,7 +120,10 @@ static void __init __maybe_unused build_assertions(void)
 #ifdef CONFIG_ARM_32
     CHECK_SAME_SLOT(first, TEMPORARY_XEN_VIRT_START, DOMHEAP_VIRT_START);
     CHECK_DIFFERENT_SLOT(first, XEN_VIRT_START, TEMPORARY_XEN_VIRT_START);
+    CHECK_SAME_SLOT(first, TEMPORARY_XEN_VIRT_START,
+                    TEMPORARY_FIXMAP_VIRT_START);
     CHECK_SAME_SLOT(second, XEN_VIRT_START, TEMPORARY_XEN_VIRT_START);
+    CHECK_SAME_SLOT(second, FIXMAP_VIRT_START, TEMPORARY_FIXMAP_VIRT_START);
 #endif
 
 #undef CHECK_SAME_SLOT
diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index 59b80d122f..20598c6963 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -35,6 +35,7 @@ SECTIONS
        _idmap_start = .;
        *(.text.header)
        *(.text.idmap)
+       *(.rodata.idmap)
        _idmap_end = .;
 
        *(.text.cold)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 16 01:33:09 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 16 Jan 2024 01:33:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667606.1039030 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYK7-0003ik-9b; Tue, 16 Jan 2024 01:33:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667606.1039030; Tue, 16 Jan 2024 01: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 1rPYK7-0003ic-6G; Tue, 16 Jan 2024 01:33:03 +0000
Received: by outflank-mailman (input) for mailman id 667606;
 Tue, 16 Jan 2024 01:33:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYK6-0003iK-8s
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:33:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYK6-0003SG-7y
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:33:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYK6-00005k-6x
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:33:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=e+t0oYEZL/8GHPJ/dRzbEp9WpMmOm2JKezIoY0WBb94=; b=4+c239uN7h09j2HeNyro0rqNd3
	vf45CVT1+DkyVnSsa0itNvICeWYY6HkOLkp1D9zvDk6HwLuU0cdqtR37r8ej5AQyRjJwyWW9akBpK
	bW3xrHr7gNWDOEP++tuMyycx88E6taVF9hY2lksaTJYnTh31l+VC/r7TenONTrvAzLe8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86emul: support AVX-VNNI-INT16
Message-Id: <E1rPYK6-00005k-6x@xenbits.xenproject.org>
Date: Tue, 16 Jan 2024 01:33:02 +0000

commit c8bb7553f2973e2fdb758e14cea9aa02cd21ad5b
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 15 12:09:42 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 15 12:09:42 2024 +0100

    x86emul: support AVX-VNNI-INT16
    
    These are close relatives of the AVX-VNNI and AVX-VNNI-INT8 ISA
    extensions. Since the insns here and in particular their memory access
    patterns follow the usual scheme (and especially the word variants of
    AVX-VNNI), I didn't think it was necessary to add a contrived test
    specifically for them.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 tools/misc/xen-cpuid.c                      |  2 ++
 tools/tests/x86_emulator/predicates.c       |  6 ++++++
 tools/tests/x86_emulator/x86-emulate.h      |  1 +
 xen/arch/x86/include/asm/cpufeature.h       |  1 +
 xen/arch/x86/x86_emulate/decode.c           |  2 ++
 xen/arch/x86/x86_emulate/private.h          |  1 +
 xen/arch/x86/x86_emulate/x86_emulate.c      | 11 +++++++++++
 xen/include/public/arch-x86/cpufeatureset.h |  1 +
 xen/tools/gen-cpuid.py                      |  3 ++-
 9 files changed, 27 insertions(+), 1 deletion(-)

diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
index 2024b39dd3..3598d37f93 100644
--- a/tools/misc/xen-cpuid.c
+++ b/tools/misc/xen-cpuid.c
@@ -220,6 +220,8 @@ static const char *const str_7d1[32] =
 {
     [ 4] = "avx-vnni-int8",       [ 5] = "avx-ne-convert",
 
+    [10] = "avx-vnni-int16",
+
     [14] = "prefetchi",
 
     [18] = "cet-sss",
diff --git a/tools/tests/x86_emulator/predicates.c b/tools/tests/x86_emulator/predicates.c
index 4e90f5b625..b4d9b7836f 100644
--- a/tools/tests/x86_emulator/predicates.c
+++ b/tools/tests/x86_emulator/predicates.c
@@ -1397,6 +1397,12 @@ static const struct vex {
     { { 0xbe }, 2, T, R, pfx_66, Wn, Ln }, /* vnmsub231p{s,d} */
     { { 0xbf }, 2, T, R, pfx_66, Wn, LIG }, /* vnmsub231s{s,d} */
     { { 0xcf }, 2, T, R, pfx_66, W0, Ln }, /* vgf2p8mulb */
+    { { 0xd2 }, 2, T, R, pfx_no, W0, Ln }, /* vpdpwuud */
+    { { 0xd2 }, 2, T, R, pfx_66, W0, Ln }, /* vpdpwusd */
+    { { 0xd2 }, 2, T, R, pfx_f3, W0, Ln }, /* vpdpwsud */
+    { { 0xd3 }, 2, T, R, pfx_no, W0, Ln }, /* vpdpwuuds */
+    { { 0xd3 }, 2, T, R, pfx_66, W0, Ln }, /* vpdpwusds */
+    { { 0xd3 }, 2, T, R, pfx_f3, W0, Ln }, /* vpdpwsuds */
     { { 0xdb }, 2, T, R, pfx_66, WIG, L0 }, /* vaesimc */
     { { 0xdc }, 2, T, R, pfx_66, WIG, Ln }, /* vaesenc */
     { { 0xdd }, 2, T, R, pfx_66, WIG, Ln }, /* vaesenclast */
diff --git a/tools/tests/x86_emulator/x86-emulate.h b/tools/tests/x86_emulator/x86-emulate.h
index 34f0855114..4434d6c243 100644
--- a/tools/tests/x86_emulator/x86-emulate.h
+++ b/tools/tests/x86_emulator/x86-emulate.h
@@ -181,6 +181,7 @@ void wrpkru(unsigned int val);
 #define cpu_has_avx_ifma   (cp.feat.avx_ifma && xcr0_mask(6))
 #define cpu_has_avx_vnni_int8 (cp.feat.avx_vnni_int8 && xcr0_mask(6))
 #define cpu_has_avx_ne_convert (cp.feat.avx_ne_convert && xcr0_mask(6))
+#define cpu_has_avx_vnni_int16 (cp.feat.avx_vnni_int16 && xcr0_mask(6))
 
 #define cpu_has_xgetbv1   (cpu_has_xsave && cp.xstate.xgetbv1)
 
diff --git a/xen/arch/x86/include/asm/cpufeature.h b/xen/arch/x86/include/asm/cpufeature.h
index 1aa221eb52..3e89a6f007 100644
--- a/xen/arch/x86/include/asm/cpufeature.h
+++ b/xen/arch/x86/include/asm/cpufeature.h
@@ -191,6 +191,7 @@ static inline bool boot_cpu_has(unsigned int feat)
 /* CPUID level 0x00000007:1.edx */
 #define cpu_has_avx_vnni_int8   boot_cpu_has(X86_FEATURE_AVX_VNNI_INT8)
 #define cpu_has_avx_ne_convert  boot_cpu_has(X86_FEATURE_AVX_NE_CONVERT)
+#define cpu_has_avx_vnni_int16  boot_cpu_has(X86_FEATURE_AVX_VNNI_INT16)
 
 /* MSR_ARCH_CAPS */
 #define cpu_has_rdcl_no         boot_cpu_has(X86_FEATURE_RDCL_NO)
diff --git a/xen/arch/x86/x86_emulate/decode.c b/xen/arch/x86/x86_emulate/decode.c
index f58ca3984e..c85d98c04a 100644
--- a/xen/arch/x86/x86_emulate/decode.c
+++ b/xen/arch/x86/x86_emulate/decode.c
@@ -435,6 +435,8 @@ static const struct ext0f38_table {
     [0xcc] = { .simd_size = simd_packed_fp, .two_op = 1, .d8s = d8s_vl },
     [0xcd] = { .simd_size = simd_scalar_vexw, .d8s = d8s_dq },
     [0xcf] = { .simd_size = simd_packed_int, .d8s = d8s_vl },
+    [0xd2] = { .simd_size = simd_other },
+    [0xd3] = { .simd_size = simd_other },
     [0xd6] = { .simd_size = simd_other, .d8s = d8s_vl },
     [0xd7] = { .simd_size = simd_scalar_vexw, .d8s = d8s_dq },
     [0xdb] = { .simd_size = simd_packed_int, .two_op = 1 },
diff --git a/xen/arch/x86/x86_emulate/private.h b/xen/arch/x86/x86_emulate/private.h
index 719dad59cd..3552f3277f 100644
--- a/xen/arch/x86/x86_emulate/private.h
+++ b/xen/arch/x86/x86_emulate/private.h
@@ -593,6 +593,7 @@ amd_like(const struct x86_emulate_ctxt *ctxt)
 #define vcpu_has_avx_ifma()    (ctxt->cpuid->feat.avx_ifma)
 #define vcpu_has_avx_vnni_int8() (ctxt->cpuid->feat.avx_vnni_int8)
 #define vcpu_has_avx_ne_convert() (ctxt->cpuid->feat.avx_ne_convert)
+#define vcpu_has_avx_vnni_int16() (ctxt->cpuid->feat.avx_vnni_int16)
 
 #define vcpu_must_have(feat) \
     generate_exception_if(!vcpu_has_##feat(), X86_EXC_UD)
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index 00b7365ed3..92e7e622bc 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -6887,6 +6887,17 @@ x86_emulate(
         elem_bytes = 1;
         goto avx512f_no_sae;
 
+    case X86EMUL_OPC_VEX   (0x0f38, 0xd2): /* vpdpwuud [xy]mm/mem,[xy]mm,[xy]mm */
+    case X86EMUL_OPC_VEX_66(0x0f38, 0xd2): /* vpdpwusd [xy]mm/mem,[xy]mm,[xy]mm */
+    case X86EMUL_OPC_VEX_F3(0x0f38, 0xd2): /* vpdpwsud [xy]mm/mem,[xy]mm,[xy]mm */
+    case X86EMUL_OPC_VEX   (0x0f38, 0xd3): /* vpdpwuuds [xy]mm/mem,[xy]mm,[xy]mm */
+    case X86EMUL_OPC_VEX_66(0x0f38, 0xd3): /* vpdpwusds [xy]mm/mem,[xy]mm,[xy]mm */
+    case X86EMUL_OPC_VEX_F3(0x0f38, 0xd3): /* vpdpwsuds [xy]mm/mem,[xy]mm,[xy]mm */
+        host_and_vcpu_must_have(avx_vnni_int16);
+        generate_exception_if(vex.w, X86_EXC_UD);
+        op_bytes = 16 << vex.l;
+        goto simd_0f_ymm;
+
     case X86EMUL_OPC_VEX_66(0x0f38, 0xdc):  /* vaesenc {x,y}mm/mem,{x,y}mm,{x,y}mm */
     case X86EMUL_OPC_VEX_66(0x0f38, 0xdd):  /* vaesenclast {x,y}mm/mem,{x,y}mm,{x,y}mm */
     case X86EMUL_OPC_VEX_66(0x0f38, 0xde):  /* vaesdec {x,y}mm/mem,{x,y}mm,{x,y}mm */
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index a8945161f5..c2c977eb62 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -310,6 +310,7 @@ XEN_CPUFEATURE(MCDT_NO,            13*32+ 5) /*A  MCDT_NO */
 /* Intel-defined CPU features, CPUID level 0x00000007:1.edx, word 15 */
 XEN_CPUFEATURE(AVX_VNNI_INT8,      15*32+ 4) /*A  AVX-VNNI-INT8 Instructions */
 XEN_CPUFEATURE(AVX_NE_CONVERT,     15*32+ 5) /*A  AVX-NE-CONVERT Instructions */
+XEN_CPUFEATURE(AVX_VNNI_INT16,     15*32+10) /*A  AVX-VNNI-INT16 Instructions */
 XEN_CPUFEATURE(PREFETCHI,          15*32+14) /*A  PREFETCHIT{0,1} Instructions */
 XEN_CPUFEATURE(CET_SSS,            15*32+18) /*   CET Supervisor Shadow Stacks safe to use */
 
diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py
index 9aa59ffdb1..2617c8f8b9 100755
--- a/xen/tools/gen-cpuid.py
+++ b/xen/tools/gen-cpuid.py
@@ -284,7 +284,8 @@ def crunch_numbers(state):
         # feature flags.  If want to use AVX512, AVX2 must be supported and
         # enabled.  Certain later extensions, acting on 256-bit vectors of
         # integers, better depend on AVX2 than AVX.
-        AVX2: [AVX512F, VAES, VPCLMULQDQ, AVX_VNNI, AVX_IFMA, AVX_VNNI_INT8],
+        AVX2: [AVX512F, VAES, VPCLMULQDQ, AVX_VNNI, AVX_IFMA, AVX_VNNI_INT8,
+               AVX_VNNI_INT16],
 
         # AVX512F is taken to mean hardware support for 512bit registers
         # (which in practice depends on the EVEX prefix to encode) as well
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 16 01:33:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 16 Jan 2024 01:33:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667607.1039033 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYKH-0003pB-Ay; Tue, 16 Jan 2024 01:33:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667607.1039033; Tue, 16 Jan 2024 01: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 1rPYKH-0003p3-7u; Tue, 16 Jan 2024 01:33:13 +0000
Received: by outflank-mailman (input) for mailman id 667607;
 Tue, 16 Jan 2024 01:33:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYKG-0003ok-ET
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:33:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYKG-0003Sn-DH
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:33:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYKG-00006C-BC
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:33:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=yaIoXGA5ypqjLHg6FTErtUGHexRZFVrsCX/jIqUgtQ8=; b=pNuTedLg/fMUz60PUdCgbTZbCt
	M1hYvoW+WJaje5TeuTss0TJRXkIlMmPhj4MyoqXTqdv9dC4xYK2OmiyFIbTq7dEbAdtkxOgHI0dJO
	vyUWc12sxAV39F6q0rekY4Zqyyg68RIkEJNXXEF7VRRRRoiFbohglTaW7+sfxxK9+KoM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86emul: support SHA512
Message-Id: <E1rPYKG-00006C-BC@xenbits.xenproject.org>
Date: Tue, 16 Jan 2024 01:33:12 +0000

commit aa18530282cf65fd036a14224a1954afea7a567f
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 15 12:10:40 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 15 12:10:40 2024 +0100

    x86emul: support SHA512
    
    Since the insns here don't access memory, I didn't think it was
    necessary to extend our SHA test for them.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 tools/misc/xen-cpuid.c                      | 2 ++
 tools/tests/x86_emulator/predicates.c       | 3 +++
 tools/tests/x86_emulator/x86-emulate.h      | 1 +
 xen/arch/x86/include/asm/cpufeature.h       | 1 +
 xen/arch/x86/x86_emulate/decode.c           | 8 ++++++++
 xen/arch/x86/x86_emulate/private.h          | 1 +
 xen/arch/x86/x86_emulate/x86_emulate.c      | 8 ++++++++
 xen/include/public/arch-x86/cpufeatureset.h | 1 +
 xen/tools/gen-cpuid.py                      | 2 +-
 9 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
index 3598d37f93..3082cd52e6 100644
--- a/tools/misc/xen-cpuid.c
+++ b/tools/misc/xen-cpuid.c
@@ -185,6 +185,8 @@ static const char *const str_7d0[32] =
 
 static const char *const str_7a1[32] =
 {
+    [ 0] = "sha512",
+
     [ 4] = "avx-vnni",      [ 5] = "avx512-bf16",
 
     [10] = "fzrm",          [11] = "fsrs",
diff --git a/tools/tests/x86_emulator/predicates.c b/tools/tests/x86_emulator/predicates.c
index b4d9b7836f..0072889a8c 100644
--- a/tools/tests/x86_emulator/predicates.c
+++ b/tools/tests/x86_emulator/predicates.c
@@ -1396,6 +1396,9 @@ static const struct vex {
     { { 0xbd }, 2, T, R, pfx_66, Wn, LIG }, /* vnmadd231s{s,d} */
     { { 0xbe }, 2, T, R, pfx_66, Wn, Ln }, /* vnmsub231p{s,d} */
     { { 0xbf }, 2, T, R, pfx_66, Wn, LIG }, /* vnmsub231s{s,d} */
+    { { 0xcb, 0xc0 }, 2, F, N, pfx_f2, W0, L1 }, /* vsha512rnds2 */
+    { { 0xcc, 0xc0 }, 2, F, N, pfx_f2, W0, L1 }, /* vsha512msg1 */
+    { { 0xcd, 0xc0 }, 2, F, N, pfx_f2, W0, L1 }, /* vsha512msg2 */
     { { 0xcf }, 2, T, R, pfx_66, W0, Ln }, /* vgf2p8mulb */
     { { 0xd2 }, 2, T, R, pfx_no, W0, Ln }, /* vpdpwuud */
     { { 0xd2 }, 2, T, R, pfx_66, W0, Ln }, /* vpdpwusd */
diff --git a/tools/tests/x86_emulator/x86-emulate.h b/tools/tests/x86_emulator/x86-emulate.h
index 4434d6c243..7d5d1ce700 100644
--- a/tools/tests/x86_emulator/x86-emulate.h
+++ b/tools/tests/x86_emulator/x86-emulate.h
@@ -176,6 +176,7 @@ void wrpkru(unsigned int val);
 #define cpu_has_avx512_vp2intersect (cp.feat.avx512_vp2intersect && xcr0_mask(0xe6))
 #define cpu_has_serialize  cp.feat.serialize
 #define cpu_has_avx512_fp16 (cp.feat.avx512_fp16 && xcr0_mask(0xe6))
+#define cpu_has_sha512     (cp.feat.sha512 && xcr0_mask(6))
 #define cpu_has_avx_vnni   (cp.feat.avx_vnni && xcr0_mask(6))
 #define cpu_has_avx512_bf16 (cp.feat.avx512_bf16 && xcr0_mask(0xe6))
 #define cpu_has_avx_ifma   (cp.feat.avx_ifma && xcr0_mask(6))
diff --git a/xen/arch/x86/include/asm/cpufeature.h b/xen/arch/x86/include/asm/cpufeature.h
index 3e89a6f007..81cb14faba 100644
--- a/xen/arch/x86/include/asm/cpufeature.h
+++ b/xen/arch/x86/include/asm/cpufeature.h
@@ -184,6 +184,7 @@ static inline bool boot_cpu_has(unsigned int feat)
 #define cpu_has_arch_caps       boot_cpu_has(X86_FEATURE_ARCH_CAPS)
 
 /* CPUID level 0x00000007:1.eax */
+#define cpu_has_sha512          boot_cpu_has(X86_FEATURE_SHA512)
 #define cpu_has_avx_vnni        boot_cpu_has(X86_FEATURE_AVX_VNNI)
 #define cpu_has_avx512_bf16     boot_cpu_has(X86_FEATURE_AVX512_BF16)
 #define cpu_has_avx_ifma        boot_cpu_has(X86_FEATURE_AVX_IFMA)
diff --git a/xen/arch/x86/x86_emulate/decode.c b/xen/arch/x86/x86_emulate/decode.c
index c85d98c04a..29b35a6d14 100644
--- a/xen/arch/x86/x86_emulate/decode.c
+++ b/xen/arch/x86/x86_emulate/decode.c
@@ -916,6 +916,14 @@ decode_0f38(struct x86_emulate_state *s,
     case X86EMUL_OPC_EVEX_66(0, 0x7c): /* vpbroadcast{d,q} */
         break;
 
+    case X86EMUL_OPC_VEX_F2(0, 0xcc): /* vsha512msg1 */
+    case X86EMUL_OPC_VEX_F2(0, 0xcd): /* vsha512msg2 */
+        s->desc |= TwoOp;
+        /* fallthrough */
+    case X86EMUL_OPC_VEX_F2(0, 0xcb): /* vsha512rnds2 */
+        s->simd_size = simd_other;
+        break;
+
     case 0xf0: /* movbe / crc32 */
         s->desc |= s->vex.pfx == vex_f2 ? ByteOp : Mov;
         if ( s->vex.pfx >= vex_f3 )
diff --git a/xen/arch/x86/x86_emulate/private.h b/xen/arch/x86/x86_emulate/private.h
index 3552f3277f..126c0ac5a6 100644
--- a/xen/arch/x86/x86_emulate/private.h
+++ b/xen/arch/x86/x86_emulate/private.h
@@ -587,6 +587,7 @@ amd_like(const struct x86_emulate_ctxt *ctxt)
 #define vcpu_has_serialize()   (ctxt->cpuid->feat.serialize)
 #define vcpu_has_tsxldtrk()    (ctxt->cpuid->feat.tsxldtrk)
 #define vcpu_has_avx512_fp16() (ctxt->cpuid->feat.avx512_fp16)
+#define vcpu_has_sha512()      (ctxt->cpuid->feat.sha512)
 #define vcpu_has_avx_vnni()    (ctxt->cpuid->feat.avx_vnni)
 #define vcpu_has_avx512_bf16() (ctxt->cpuid->feat.avx512_bf16)
 #define vcpu_has_wrmsrns()     (ctxt->cpuid->feat.wrmsrns)
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index 92e7e622bc..af519f36bb 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -6872,6 +6872,14 @@ x86_emulate(
         host_and_vcpu_must_have(avx512er);
         goto simd_zmm_scalar_sae;
 
+    case X86EMUL_OPC_VEX_F2(0x0f38, 0xcb): /* vsha512rnds2 xmm,ymm,ymm */
+    case X86EMUL_OPC_VEX_F2(0x0f38, 0xcc): /* vsha512msg1 xmm,ymm */
+    case X86EMUL_OPC_VEX_F2(0x0f38, 0xcd): /* vsha512msg2 ymm,ymm */
+        host_and_vcpu_must_have(sha512);
+        generate_exception_if(ea.type != OP_REG || vex.w || !vex.l, X86_EXC_UD);
+        op_bytes = 32;
+        goto simd_0f_ymm;
+
     case X86EMUL_OPC_66(0x0f38, 0xcf):      /* gf2p8mulb xmm/m128,xmm */
         host_and_vcpu_must_have(gfni);
         goto simd_0f38_common;
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index c2c977eb62..ad12e24d95 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -277,6 +277,7 @@ XEN_CPUFEATURE(CORE_CAPS,     9*32+30) /*   IA32_CORE_CAPABILITIES MSR */
 XEN_CPUFEATURE(SSBD,          9*32+31) /*A  MSR_SPEC_CTRL.SSBD available */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:1.eax, word 10 */
+XEN_CPUFEATURE(SHA512,       10*32+ 0) /*A  SHA512 Instructions */
 XEN_CPUFEATURE(AVX_VNNI,     10*32+ 4) /*A  AVX-VNNI Instructions */
 XEN_CPUFEATURE(AVX512_BF16,  10*32+ 5) /*A  AVX512 BFloat16 Instructions */
 XEN_CPUFEATURE(FZRM,         10*32+10) /*A  Fast Zero-length REP MOVSB */
diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py
index 2617c8f8b9..edd4838825 100755
--- a/xen/tools/gen-cpuid.py
+++ b/xen/tools/gen-cpuid.py
@@ -285,7 +285,7 @@ def crunch_numbers(state):
         # enabled.  Certain later extensions, acting on 256-bit vectors of
         # integers, better depend on AVX2 than AVX.
         AVX2: [AVX512F, VAES, VPCLMULQDQ, AVX_VNNI, AVX_IFMA, AVX_VNNI_INT8,
-               AVX_VNNI_INT16],
+               AVX_VNNI_INT16, SHA512],
 
         # AVX512F is taken to mean hardware support for 512bit registers
         # (which in practice depends on the EVEX prefix to encode) as well
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 16 01:33:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 16 Jan 2024 01:33:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667608.1039038 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYKR-0003wz-Cb; Tue, 16 Jan 2024 01:33:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667608.1039038; Tue, 16 Jan 2024 01: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 1rPYKR-0003wr-9P; Tue, 16 Jan 2024 01:33:23 +0000
Received: by outflank-mailman (input) for mailman id 667608;
 Tue, 16 Jan 2024 01: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 1rPYKQ-0003vQ-IB
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01: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 1rPYKQ-0003TC-HL
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:33:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYKQ-00006b-GJ
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:33:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=hhws0wZYA+dGhM9TXVOEYWGxcIq/CZ42soA9UPp7r24=; b=MtIO7PI9Ir4kjQlDmeHBUwIl7J
	ut3EhLxQRcErNgBJWZDFjDTY5BZm3dqrdhFwCSvcO6wEq5VGvpqV+wBMGD94FYiBt5nNOcDLerfxZ
	V1gnkBgYZRBcbojdnQfnGvRQTgmyLkGjWPL9kiQzY+L48ST3fY9uPIy01Axb8wMiuSWM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86emul: support SM3
Message-Id: <E1rPYKQ-00006b-GJ@xenbits.xenproject.org>
Date: Tue, 16 Jan 2024 01:33:22 +0000

commit 390777414a7cfd7b6280d396497162058793f4e0
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 15 12:11:22 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 15 12:11:22 2024 +0100

    x86emul: support SM3
    
    Since the insns here and in particular their memory access patterns
    follow the usual scheme, I didn't think it was necessary to add a
    contrived test specifically for them.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 tools/misc/xen-cpuid.c                      |  2 +-
 tools/tests/x86_emulator/predicates.c       |  3 +++
 tools/tests/x86_emulator/x86-emulate.h      |  1 +
 xen/arch/x86/include/asm/cpufeature.h       |  1 +
 xen/arch/x86/x86_emulate/decode.c           |  2 ++
 xen/arch/x86/x86_emulate/private.h          |  1 +
 xen/arch/x86/x86_emulate/x86_emulate.c      | 12 ++++++++++++
 xen/include/public/arch-x86/cpufeatureset.h |  1 +
 xen/tools/gen-cpuid.py                      |  2 +-
 9 files changed, 23 insertions(+), 2 deletions(-)

diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
index 3082cd52e6..8b2a937d85 100644
--- a/tools/misc/xen-cpuid.c
+++ b/tools/misc/xen-cpuid.c
@@ -185,7 +185,7 @@ static const char *const str_7d0[32] =
 
 static const char *const str_7a1[32] =
 {
-    [ 0] = "sha512",
+    [ 0] = "sha512",        [ 1] = "sm3",
 
     [ 4] = "avx-vnni",      [ 5] = "avx512-bf16",
 
diff --git a/tools/tests/x86_emulator/predicates.c b/tools/tests/x86_emulator/predicates.c
index 0072889a8c..bfc9ee4f97 100644
--- a/tools/tests/x86_emulator/predicates.c
+++ b/tools/tests/x86_emulator/predicates.c
@@ -1406,6 +1406,8 @@ static const struct vex {
     { { 0xd3 }, 2, T, R, pfx_no, W0, Ln }, /* vpdpwuuds */
     { { 0xd3 }, 2, T, R, pfx_66, W0, Ln }, /* vpdpwusds */
     { { 0xd3 }, 2, T, R, pfx_f3, W0, Ln }, /* vpdpwsuds */
+    { { 0xda }, 2, T, R, pfx_no, W0, L0 }, /* vsm3msg1 */
+    { { 0xda }, 2, T, R, pfx_66, W0, L0 }, /* vsm3msg2 */
     { { 0xdb }, 2, T, R, pfx_66, WIG, L0 }, /* vaesimc */
     { { 0xdc }, 2, T, R, pfx_66, WIG, Ln }, /* vaesenc */
     { { 0xdd }, 2, T, R, pfx_66, WIG, Ln }, /* vaesenclast */
@@ -1490,6 +1492,7 @@ static const struct vex {
     { { 0x7f }, 3, T, R, pfx_66, Wn, LIG }, /* vfnmsubsd */
     { { 0xce }, 3, T, R, pfx_66, W1, Ln }, /* vgf2p8affineqb */
     { { 0xcf }, 3, T, R, pfx_66, W1, Ln }, /* vgf2p8affineinvqb */
+    { { 0xde }, 3, T, R, pfx_66, W0, L0 }, /* vsm3rnds2 */
     { { 0xdf }, 3, T, R, pfx_66, WIG, Ln }, /* vaeskeygenassist */
     { { 0xf0 }, 3, T, R, pfx_f2, Wn, L0 }, /* rorx */
 };
diff --git a/tools/tests/x86_emulator/x86-emulate.h b/tools/tests/x86_emulator/x86-emulate.h
index 7d5d1ce700..b127b4a93c 100644
--- a/tools/tests/x86_emulator/x86-emulate.h
+++ b/tools/tests/x86_emulator/x86-emulate.h
@@ -177,6 +177,7 @@ void wrpkru(unsigned int val);
 #define cpu_has_serialize  cp.feat.serialize
 #define cpu_has_avx512_fp16 (cp.feat.avx512_fp16 && xcr0_mask(0xe6))
 #define cpu_has_sha512     (cp.feat.sha512 && xcr0_mask(6))
+#define cpu_has_sm3        (cp.feat.sm3 && xcr0_mask(6))
 #define cpu_has_avx_vnni   (cp.feat.avx_vnni && xcr0_mask(6))
 #define cpu_has_avx512_bf16 (cp.feat.avx512_bf16 && xcr0_mask(0xe6))
 #define cpu_has_avx_ifma   (cp.feat.avx_ifma && xcr0_mask(6))
diff --git a/xen/arch/x86/include/asm/cpufeature.h b/xen/arch/x86/include/asm/cpufeature.h
index 81cb14faba..7d81b59e74 100644
--- a/xen/arch/x86/include/asm/cpufeature.h
+++ b/xen/arch/x86/include/asm/cpufeature.h
@@ -185,6 +185,7 @@ static inline bool boot_cpu_has(unsigned int feat)
 
 /* CPUID level 0x00000007:1.eax */
 #define cpu_has_sha512          boot_cpu_has(X86_FEATURE_SHA512)
+#define cpu_has_sm3             boot_cpu_has(X86_FEATURE_SM3)
 #define cpu_has_avx_vnni        boot_cpu_has(X86_FEATURE_AVX_VNNI)
 #define cpu_has_avx512_bf16     boot_cpu_has(X86_FEATURE_AVX512_BF16)
 #define cpu_has_avx_ifma        boot_cpu_has(X86_FEATURE_AVX_IFMA)
diff --git a/xen/arch/x86/x86_emulate/decode.c b/xen/arch/x86/x86_emulate/decode.c
index 29b35a6d14..de836068fd 100644
--- a/xen/arch/x86/x86_emulate/decode.c
+++ b/xen/arch/x86/x86_emulate/decode.c
@@ -439,6 +439,7 @@ static const struct ext0f38_table {
     [0xd3] = { .simd_size = simd_other },
     [0xd6] = { .simd_size = simd_other, .d8s = d8s_vl },
     [0xd7] = { .simd_size = simd_scalar_vexw, .d8s = d8s_dq },
+    [0xda] = { .simd_size = simd_other },
     [0xdb] = { .simd_size = simd_packed_int, .two_op = 1 },
     [0xdc ... 0xdf] = { .simd_size = simd_packed_int, .d8s = d8s_vl },
     [0xf0] = { .two_op = 1 },
@@ -519,6 +520,7 @@ static const struct ext0f3a_table {
     [0xc2] = { .simd_size = simd_any_fp, .d8s = d8s_vl },
     [0xcc] = { .simd_size = simd_other },
     [0xce ... 0xcf] = { .simd_size = simd_packed_int, .d8s = d8s_vl },
+    [0xde] = { .simd_size = simd_other },
     [0xdf] = { .simd_size = simd_packed_int, .two_op = 1 },
     [0xf0] = {},
 };
diff --git a/xen/arch/x86/x86_emulate/private.h b/xen/arch/x86/x86_emulate/private.h
index 126c0ac5a6..def8db000b 100644
--- a/xen/arch/x86/x86_emulate/private.h
+++ b/xen/arch/x86/x86_emulate/private.h
@@ -588,6 +588,7 @@ amd_like(const struct x86_emulate_ctxt *ctxt)
 #define vcpu_has_tsxldtrk()    (ctxt->cpuid->feat.tsxldtrk)
 #define vcpu_has_avx512_fp16() (ctxt->cpuid->feat.avx512_fp16)
 #define vcpu_has_sha512()      (ctxt->cpuid->feat.sha512)
+#define vcpu_has_sm3()         (ctxt->cpuid->feat.sm3)
 #define vcpu_has_avx_vnni()    (ctxt->cpuid->feat.avx_vnni)
 #define vcpu_has_avx512_bf16() (ctxt->cpuid->feat.avx512_bf16)
 #define vcpu_has_wrmsrns()     (ctxt->cpuid->feat.wrmsrns)
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index af519f36bb..429eb4953c 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -6906,6 +6906,12 @@ x86_emulate(
         op_bytes = 16 << vex.l;
         goto simd_0f_ymm;
 
+    case X86EMUL_OPC_VEX   (0x0f38, 0xda): /* vsm3msg1 xmm/mem,xmm,xmm */
+    case X86EMUL_OPC_VEX_66(0x0f38, 0xda): /* vsm3msg2 xmm/mem,xmm,xmm */
+        generate_exception_if(vex.w || vex.l, X86_EXC_UD);
+        host_and_vcpu_must_have(sm3);
+        goto simd_0f_ymm;
+
     case X86EMUL_OPC_VEX_66(0x0f38, 0xdc):  /* vaesenc {x,y}mm/mem,{x,y}mm,{x,y}mm */
     case X86EMUL_OPC_VEX_66(0x0f38, 0xdd):  /* vaesenclast {x,y}mm/mem,{x,y}mm,{x,y}mm */
     case X86EMUL_OPC_VEX_66(0x0f38, 0xde):  /* vaesdec {x,y}mm/mem,{x,y}mm,{x,y}mm */
@@ -7778,6 +7784,12 @@ x86_emulate(
         fault_suppression = false;
         goto avx512f_imm8_no_sae;
 
+    case X86EMUL_OPC_VEX_66(0x0f3a, 0xde): /* vsm3rnds2 $imm8,xmm/mem,xmm,xmm */
+        host_and_vcpu_must_have(sm3);
+        generate_exception_if(vex.w || vex.l, X86_EXC_UD);
+        op_bytes = 16;
+        goto simd_0f_imm8_ymm;
+
     case X86EMUL_OPC_66(0x0f3a, 0xdf):     /* aeskeygenassist $imm8,xmm/m128,xmm */
     case X86EMUL_OPC_VEX_66(0x0f3a, 0xdf): /* vaeskeygenassist $imm8,xmm/m128,xmm */
         host_and_vcpu_must_have(aesni);
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index ad12e24d95..ed26683397 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -278,6 +278,7 @@ XEN_CPUFEATURE(SSBD,          9*32+31) /*A  MSR_SPEC_CTRL.SSBD available */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:1.eax, word 10 */
 XEN_CPUFEATURE(SHA512,       10*32+ 0) /*A  SHA512 Instructions */
+XEN_CPUFEATURE(SM3,          10*32+ 1) /*A  SM3 Instructions */
 XEN_CPUFEATURE(AVX_VNNI,     10*32+ 4) /*A  AVX-VNNI Instructions */
 XEN_CPUFEATURE(AVX512_BF16,  10*32+ 5) /*A  AVX512 BFloat16 Instructions */
 XEN_CPUFEATURE(FZRM,         10*32+10) /*A  Fast Zero-length REP MOVSB */
diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py
index edd4838825..8203d2605d 100755
--- a/xen/tools/gen-cpuid.py
+++ b/xen/tools/gen-cpuid.py
@@ -262,7 +262,7 @@ def crunch_numbers(state):
         # for the XOP prefix).  VEX/XOP-encoded GPR instructions, such as
         # those from the BMI{1,2}, TBM and LWP sets function fine in the
         # absence of any enabled xstate.
-        AVX: [FMA, FMA4, F16C, AVX2, XOP, AVX_NE_CONVERT],
+        AVX: [FMA, FMA4, F16C, AVX2, XOP, AVX_NE_CONVERT, SM3],
 
         # This dependency exists solely for the shadow pagetable code.  If the
         # host doesn't have NX support, the shadow pagetable code can't handle
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 16 01:33:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 16 Jan 2024 01:33:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667610.1039041 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYKb-000443-Dj; Tue, 16 Jan 2024 01:33:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667610.1039041; Tue, 16 Jan 2024 01: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 1rPYKb-00043v-B2; Tue, 16 Jan 2024 01:33:33 +0000
Received: by outflank-mailman (input) for mailman id 667610;
 Tue, 16 Jan 2024 01: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 1rPYKa-00043l-OE
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01: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 1rPYKa-0003TK-La
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:33:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYKa-000072-KN
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01: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=BPuOBNbPdpn/icKARmOoQSALdqGNUQPfcs1hfbUwVhc=; b=LrQuj0mi+p3RroXv02BWLoVpbK
	LUrs3+Hg0Cc1bAgPVX85Nn2ob8ryir642zJmCtJev8AP9NxdQWiD2XoQybIibK30vAPnEYCc/kcXE
	6GCRd5zD3xCORiXPB6IE4FDOv1c75Az4uQB9oqsFzanZm6BcoHoFpx8Rz8YAA7/Uz8UI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86emul: support SM4
Message-Id: <E1rPYKa-000072-KN@xenbits.xenproject.org>
Date: Tue, 16 Jan 2024 01:33:32 +0000

commit cef805dce4e95881cd846507304706e2426fd381
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 15 12:12:00 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 15 12:12:00 2024 +0100

    x86emul: support SM4
    
    Since the insns here and in particular their memory access patterns
    follow the usual scheme, I didn't think it was necessary to add a
    contrived test specifically for them.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 tools/misc/xen-cpuid.c                      | 2 +-
 tools/tests/x86_emulator/predicates.c       | 2 ++
 tools/tests/x86_emulator/x86-emulate.h      | 1 +
 xen/arch/x86/include/asm/cpufeature.h       | 1 +
 xen/arch/x86/x86_emulate/private.h          | 1 +
 xen/arch/x86/x86_emulate/x86_emulate.c      | 7 +++++++
 xen/include/public/arch-x86/cpufeatureset.h | 1 +
 xen/tools/gen-cpuid.py                      | 2 +-
 8 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/tools/misc/xen-cpuid.c b/tools/misc/xen-cpuid.c
index 8b2a937d85..46abdb9140 100644
--- a/tools/misc/xen-cpuid.c
+++ b/tools/misc/xen-cpuid.c
@@ -186,7 +186,7 @@ static const char *const str_7d0[32] =
 static const char *const str_7a1[32] =
 {
     [ 0] = "sha512",        [ 1] = "sm3",
-
+    [ 2] = "sm4",
     [ 4] = "avx-vnni",      [ 5] = "avx512-bf16",
 
     [10] = "fzrm",          [11] = "fsrs",
diff --git a/tools/tests/x86_emulator/predicates.c b/tools/tests/x86_emulator/predicates.c
index bfc9ee4f97..613a1baea2 100644
--- a/tools/tests/x86_emulator/predicates.c
+++ b/tools/tests/x86_emulator/predicates.c
@@ -1408,6 +1408,8 @@ static const struct vex {
     { { 0xd3 }, 2, T, R, pfx_f3, W0, Ln }, /* vpdpwsuds */
     { { 0xda }, 2, T, R, pfx_no, W0, L0 }, /* vsm3msg1 */
     { { 0xda }, 2, T, R, pfx_66, W0, L0 }, /* vsm3msg2 */
+    { { 0xda }, 2, T, R, pfx_f3, W0, Ln }, /* vsm4key4 */
+    { { 0xda }, 2, T, R, pfx_f2, W0, Ln }, /* vsm4rnds4 */
     { { 0xdb }, 2, T, R, pfx_66, WIG, L0 }, /* vaesimc */
     { { 0xdc }, 2, T, R, pfx_66, WIG, Ln }, /* vaesenc */
     { { 0xdd }, 2, T, R, pfx_66, WIG, Ln }, /* vaesenclast */
diff --git a/tools/tests/x86_emulator/x86-emulate.h b/tools/tests/x86_emulator/x86-emulate.h
index b127b4a93c..8f8accfe3e 100644
--- a/tools/tests/x86_emulator/x86-emulate.h
+++ b/tools/tests/x86_emulator/x86-emulate.h
@@ -178,6 +178,7 @@ void wrpkru(unsigned int val);
 #define cpu_has_avx512_fp16 (cp.feat.avx512_fp16 && xcr0_mask(0xe6))
 #define cpu_has_sha512     (cp.feat.sha512 && xcr0_mask(6))
 #define cpu_has_sm3        (cp.feat.sm3 && xcr0_mask(6))
+#define cpu_has_sm4        (cp.feat.sm4 && xcr0_mask(6))
 #define cpu_has_avx_vnni   (cp.feat.avx_vnni && xcr0_mask(6))
 #define cpu_has_avx512_bf16 (cp.feat.avx512_bf16 && xcr0_mask(0xe6))
 #define cpu_has_avx_ifma   (cp.feat.avx_ifma && xcr0_mask(6))
diff --git a/xen/arch/x86/include/asm/cpufeature.h b/xen/arch/x86/include/asm/cpufeature.h
index 7d81b59e74..896483a900 100644
--- a/xen/arch/x86/include/asm/cpufeature.h
+++ b/xen/arch/x86/include/asm/cpufeature.h
@@ -186,6 +186,7 @@ static inline bool boot_cpu_has(unsigned int feat)
 /* CPUID level 0x00000007:1.eax */
 #define cpu_has_sha512          boot_cpu_has(X86_FEATURE_SHA512)
 #define cpu_has_sm3             boot_cpu_has(X86_FEATURE_SM3)
+#define cpu_has_sm4             boot_cpu_has(X86_FEATURE_SM4)
 #define cpu_has_avx_vnni        boot_cpu_has(X86_FEATURE_AVX_VNNI)
 #define cpu_has_avx512_bf16     boot_cpu_has(X86_FEATURE_AVX512_BF16)
 #define cpu_has_avx_ifma        boot_cpu_has(X86_FEATURE_AVX_IFMA)
diff --git a/xen/arch/x86/x86_emulate/private.h b/xen/arch/x86/x86_emulate/private.h
index def8db000b..33f2870508 100644
--- a/xen/arch/x86/x86_emulate/private.h
+++ b/xen/arch/x86/x86_emulate/private.h
@@ -589,6 +589,7 @@ amd_like(const struct x86_emulate_ctxt *ctxt)
 #define vcpu_has_avx512_fp16() (ctxt->cpuid->feat.avx512_fp16)
 #define vcpu_has_sha512()      (ctxt->cpuid->feat.sha512)
 #define vcpu_has_sm3()         (ctxt->cpuid->feat.sm3)
+#define vcpu_has_sm4()         (ctxt->cpuid->feat.sm4)
 #define vcpu_has_avx_vnni()    (ctxt->cpuid->feat.avx_vnni)
 #define vcpu_has_avx512_bf16() (ctxt->cpuid->feat.avx512_bf16)
 #define vcpu_has_wrmsrns()     (ctxt->cpuid->feat.wrmsrns)
diff --git a/xen/arch/x86/x86_emulate/x86_emulate.c b/xen/arch/x86/x86_emulate/x86_emulate.c
index 429eb4953c..ed710596dc 100644
--- a/xen/arch/x86/x86_emulate/x86_emulate.c
+++ b/xen/arch/x86/x86_emulate/x86_emulate.c
@@ -6912,6 +6912,13 @@ x86_emulate(
         host_and_vcpu_must_have(sm3);
         goto simd_0f_ymm;
 
+    case X86EMUL_OPC_VEX_F3(0x0f38, 0xda): /* vsm4key4 [xy]mm/mem,[xy]mm,[xy]mm */
+    case X86EMUL_OPC_VEX_F2(0x0f38, 0xda): /* vsm4rnds4 [xy]mm/mem,[xy]mm,[xy]mm */
+        host_and_vcpu_must_have(sm4);
+        generate_exception_if(vex.w, X86_EXC_UD);
+        op_bytes = 16 << vex.l;
+        goto simd_0f_ymm;
+
     case X86EMUL_OPC_VEX_66(0x0f38, 0xdc):  /* vaesenc {x,y}mm/mem,{x,y}mm,{x,y}mm */
     case X86EMUL_OPC_VEX_66(0x0f38, 0xdd):  /* vaesenclast {x,y}mm/mem,{x,y}mm,{x,y}mm */
     case X86EMUL_OPC_VEX_66(0x0f38, 0xde):  /* vaesdec {x,y}mm/mem,{x,y}mm,{x,y}mm */
diff --git a/xen/include/public/arch-x86/cpufeatureset.h b/xen/include/public/arch-x86/cpufeatureset.h
index ed26683397..c897c20401 100644
--- a/xen/include/public/arch-x86/cpufeatureset.h
+++ b/xen/include/public/arch-x86/cpufeatureset.h
@@ -279,6 +279,7 @@ XEN_CPUFEATURE(SSBD,          9*32+31) /*A  MSR_SPEC_CTRL.SSBD available */
 /* Intel-defined CPU features, CPUID level 0x00000007:1.eax, word 10 */
 XEN_CPUFEATURE(SHA512,       10*32+ 0) /*A  SHA512 Instructions */
 XEN_CPUFEATURE(SM3,          10*32+ 1) /*A  SM3 Instructions */
+XEN_CPUFEATURE(SM4,          10*32+ 2) /*A  SM4 Instructions */
 XEN_CPUFEATURE(AVX_VNNI,     10*32+ 4) /*A  AVX-VNNI Instructions */
 XEN_CPUFEATURE(AVX512_BF16,  10*32+ 5) /*A  AVX512 BFloat16 Instructions */
 XEN_CPUFEATURE(FZRM,         10*32+10) /*A  Fast Zero-length REP MOVSB */
diff --git a/xen/tools/gen-cpuid.py b/xen/tools/gen-cpuid.py
index 8203d2605d..df5222a3cd 100755
--- a/xen/tools/gen-cpuid.py
+++ b/xen/tools/gen-cpuid.py
@@ -285,7 +285,7 @@ def crunch_numbers(state):
         # enabled.  Certain later extensions, acting on 256-bit vectors of
         # integers, better depend on AVX2 than AVX.
         AVX2: [AVX512F, VAES, VPCLMULQDQ, AVX_VNNI, AVX_IFMA, AVX_VNNI_INT8,
-               AVX_VNNI_INT16, SHA512],
+               AVX_VNNI_INT16, SHA512, SM4],
 
         # AVX512F is taken to mean hardware support for 512bit registers
         # (which in practice depends on the EVEX prefix to encode) as well
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 16 01:33:43 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 16 Jan 2024 01:33:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667611.1039045 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYKl-00047W-Hn; Tue, 16 Jan 2024 01:33:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667611.1039045; Tue, 16 Jan 2024 01: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 1rPYKl-00047O-EB; Tue, 16 Jan 2024 01:33:43 +0000
Received: by outflank-mailman (input) for mailman id 667611;
 Tue, 16 Jan 2024 01: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 1rPYKk-000476-PX
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01: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 1rPYKk-0003TS-OY
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:33:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYKk-00007R-Nh
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01: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=l8ootOlwnXInEcQBRtt2SX2USufdj4+SSB6kfSTRGOw=; b=wHk47B2OsoEtr/IvgC1eH5uCOe
	enihsJ4jzzg21aMeDQjcBOMkg21G4TLw+qxfOJtNx2kE+Ib9CCXGLCVtgqLKAoYwTjKf5OzYZ5Gkj
	kMdEzhb1ctB6I2gI246x8oTeFBo3wPTxo3ORS5Vkdk708687gs3GUD90XcSDaFC/VQ60=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/riscv: introduce system.h
Message-Id: <E1rPYKk-00007R-Nh@xenbits.xenproject.org>
Date: Tue, 16 Jan 2024 01:33:42 +0000

commit 137c08aa07d544a925143432682fd7b7debc2676
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Mon Jan 15 12:12:52 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 15 12:12:52 2024 +0100

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

diff --git a/xen/arch/riscv/include/asm/system.h b/xen/arch/riscv/include/asm/system.h
new file mode 100644
index 0000000000..f76bafd168
--- /dev/null
+++ b/xen/arch/riscv/include/asm/system.h
@@ -0,0 +1,90 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _ASM_RISCV_SYSTEM_H
+#define _ASM_RISCV_SYSTEM_H
+
+#include <xen/stdbool.h>
+
+#include <asm/csr.h>
+
+#ifndef __ASSEMBLY__
+
+#define RISCV_FENCE(p, s) \
+    __asm__ __volatile__ ( "fence " #p "," #s : : : "memory" )
+
+/* These barriers need to enforce ordering on both devices or memory. */
+#define mb()                    RISCV_FENCE(iorw, iorw)
+#define rmb()                   RISCV_FENCE(ir, ir)
+#define wmb()                   RISCV_FENCE(ow, ow)
+
+/* These barriers do not need to enforce ordering on devices, just memory. */
+#define smp_mb()                RISCV_FENCE(rw, rw)
+#define smp_rmb()               RISCV_FENCE(r, r)
+#define smp_wmb()               RISCV_FENCE(w, w)
+#define smp_mb__before_atomic() smp_mb()
+#define smp_mb__after_atomic()  smp_mb()
+
+/*
+#define smp_store_release(p, v)         \
+do {                                    \
+    compiletime_assert_atomic_type(*p); \
+    RISCV_FENCE(rw, w);                 \
+    WRITE_ONCE(*p, v);                  \
+} while (0)
+
+#define smp_load_acquire(p)             \
+({                                      \
+    typeof(*p) p1 = READ_ONCE(*p);      \
+    compiletime_assert_atomic_type(*p); \
+    RISCV_FENCE(r,rw);                  \
+    p1;                                 \
+})
+*/
+
+static inline unsigned long local_save_flags(void)
+{
+    return csr_read(sstatus);
+}
+
+static inline void local_irq_enable(void)
+{
+    csr_set(sstatus, SSTATUS_SIE);
+}
+
+static inline void local_irq_disable(void)
+{
+    csr_clear(sstatus, SSTATUS_SIE);
+}
+
+#define local_irq_save(x)                           \
+({                                                  \
+    x = csr_read_clear(CSR_SSTATUS, SSTATUS_SIE);   \
+    local_irq_disable();                            \
+})
+
+static inline void local_irq_restore(unsigned long flags)
+{
+	csr_set(CSR_SSTATUS, flags & SSTATUS_SIE);
+}
+
+static inline bool local_irq_is_enabled(void)
+{
+    unsigned long flags = local_save_flags();
+
+    return (flags & SSTATUS_SIE) != 0;
+}
+
+#define arch_fetch_and_add(x, v) __sync_fetch_and_add(x, v)
+
+#endif /* __ASSEMBLY__ */
+
+#endif /* _ASM_RISCV_SYSTEM_H */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 16 01:33:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 16 Jan 2024 01:33:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667612.1039050 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYKw-0004B7-J7; Tue, 16 Jan 2024 01:33:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667612.1039050; Tue, 16 Jan 2024 01:33:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYKw-0004Ay-Fk; Tue, 16 Jan 2024 01:33:54 +0000
Received: by outflank-mailman (input) for mailman id 667612;
 Tue, 16 Jan 2024 01:33: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 1rPYKu-0004Ak-SX
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:33: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 1rPYKu-0003Tc-Ri
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:33:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYKu-00009r-Qn
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:33: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=tVfi8cdCuarBfkHICc1aqCqlIpijrKLtnfgCyJfm4lU=; b=yvsLCBjCQ093Yya/f07wt6ePyq
	GhiRbeCieQL+Q9i2Zs7++VKT8iyKkXBgw6Nedwf3cj0niad7zbbig31k+6ffs/zbrmymg+ToXdHsW
	1hO7Piy6BY4DkiNg4v6guVPmCUDroi4Y/M1TiFCQ6+oVDsmLXGrgRLkgi6nWECtGs60o=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] NUMA: limit first_valid_mfn exposure
Message-Id: <E1rPYKu-00009r-Qn@xenbits.xenproject.org>
Date: Tue, 16 Jan 2024 01:33:52 +0000

commit 5e600b4fb9a0ff6a692dbd22d80b18a94da561be
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 15 12:15:56 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 15 12:15:56 2024 +0100

    NUMA: limit first_valid_mfn exposure
    
    Address the TODO regarding first_valid_mfn by making the variable static
    when NUMA=y, thus also addressing a Misra C:2012 rule 8.4 concern (on
    x86). To carry this out, introduce two new IS_ENABLED()-like macros
    conditionally inserting "static". One less macro expansion layer is
    sufficient though (I might guess that some early form of IS_ENABLED()
    pasted CONFIG_ onto the incoming argument, at which point the extra
    layer would have been necessary), and part of the existing helper macros
    can be re-used.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/common/page_alloc.c   |  8 +++-----
 xen/include/xen/kconfig.h | 13 +++++++++++++
 2 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index d874525916..740b6f0ff7 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -255,12 +255,10 @@ static PAGE_LIST_HEAD(page_broken_list);
  */
 
 /*
- * first_valid_mfn is exported because it is used when !CONFIG_NUMA.
- *
- * TODO: Consider if we can conditionally export first_valid_mfn based
- * on whether NUMA is selected.
+ * When !CONFIG_NUMA first_valid_mfn is non-static, for use by respective
+ * stubs.
  */
-mfn_t first_valid_mfn = INVALID_MFN_INITIALIZER;
+STATIC_IF(CONFIG_NUMA) mfn_t first_valid_mfn = INVALID_MFN_INITIALIZER;
 
 struct bootmem_region {
     unsigned long s, e; /* MFNs @s through @e-1 inclusive are free */
diff --git a/xen/include/xen/kconfig.h b/xen/include/xen/kconfig.h
index a717b0819c..c25dc0f6c2 100644
--- a/xen/include/xen/kconfig.h
+++ b/xen/include/xen/kconfig.h
@@ -11,6 +11,8 @@
 /* cppcheck is failing to parse the macro so use a dummy one */
 #ifdef CPPCHECK
 #define IS_ENABLED(option) option
+#define STATIC_IF(option) option
+#define STATIC_IF_NOT(option) option
 #else
 /*
  * Getting something that works in C and CPP for an arg that may or may
@@ -31,6 +33,17 @@
  * otherwise.
  */
 #define IS_ENABLED(option) config_enabled(option)
+
+/* Use similar trickery for conditionally inserting "static". */
+#define static_if(value) _static_if(__ARG_PLACEHOLDER_##value)
+#define _static_if(arg1_or_junk) ___config_enabled(arg1_or_junk static,)
+
+#define STATIC_IF(option) static_if(option)
+
+#define static_if_not(value) _static_if_not(__ARG_PLACEHOLDER_##value)
+#define _static_if_not(arg1_or_junk) ___config_enabled(arg1_or_junk, static)
+
+#define STATIC_IF_NOT(option) static_if_not(option)
 #endif
 
 #endif /* __XEN_KCONFIG_H */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 16 01:34:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 16 Jan 2024 01:34:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667613.1039054 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYL6-0004EB-KN; Tue, 16 Jan 2024 01:34:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667613.1039054; Tue, 16 Jan 2024 01:34:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYL6-0004E0-HJ; Tue, 16 Jan 2024 01:34:04 +0000
Received: by outflank-mailman (input) for mailman id 667613;
 Tue, 16 Jan 2024 01:34:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYL4-0004Dm-Va
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34: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 1rPYL4-0003Tz-Uu
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYL4-0000BA-U3
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34: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=jZeMB6e/lLztHml2LPaoAOftQQTrSTbbiNesNwirnas=; b=yxW1laTAcC2aVYrH+rA5FC1oF8
	DpanPCIEXrvlFxF6FzEzH/lmrS95R/+tQXITwgM/EjvHvFb+ZxgJZfiq+5SRmhH2EE0PgvfgvFZMO
	NQ9qPFZy7wC27MyrzVd+WUKj+gUjcgaNoXoBJRKzqUa6kwejqWwcRXHt0NdqrdFz3Qj0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/HVM: split restore state checking from state loading
Message-Id: <E1rPYL4-0000BA-U3@xenbits.xenproject.org>
Date: Tue, 16 Jan 2024 01:34:02 +0000

commit 5b6cab423cfa8677da92623d03cdcef3c9017669
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 15 12:16:56 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 15 12:16:56 2024 +0100

    x86/HVM: split restore state checking from state loading
    
    ..., at least as reasonably feasible without making a check hook
    mandatory (in particular strict vs relaxed/zero-extend length checking
    can't be done early this way).
    
    Note that only one of the two uses of "real" hvm_load() is accompanied
    with a "checking" one. The other directly consumes hvm_save() output,
    which ought to be well-formed. This means that while input data related
    checks don't need repeating in the "load" function when already done by
    the "check" one (albeit assertions to this effect may be desirable),
    domain state related checks (e.g. has_xyz(d)) will be required in both
    places.
    
    With the split arch_hvm_{check,load}(), also invoke the latter only
    after downing all the vCPU-s.
    
    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/arch/x86/domctl.c               |  6 ++-
 xen/arch/x86/hvm/hvm.c              |  2 +-
 xen/arch/x86/hvm/save.c             | 95 ++++++++++++++++++++++++++++---------
 xen/arch/x86/include/asm/hvm/save.h |  4 +-
 4 files changed, 82 insertions(+), 25 deletions(-)

diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 3c0ea85541..9a72d57333 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -379,8 +379,12 @@ long arch_do_domctl(
         if ( copy_from_guest(c.data, domctl->u.hvmcontext.buffer, c.size) != 0 )
             goto sethvmcontext_out;
 
+        ret = hvm_load(d, false, &c);
+        if ( ret )
+            goto sethvmcontext_out;
+
         domain_pause(d);
-        ret = hvm_load(d, &c);
+        ret = hvm_load(d, true, &c);
         domain_unpause(d);
 
     sethvmcontext_out:
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 6e952748d6..4650cba72b 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -5391,7 +5391,7 @@ int hvm_copy_context_and_params(struct domain *dst, struct domain *src)
     }
 
     c.cur = 0;
-    rc = hvm_load(dst, &c);
+    rc = hvm_load(dst, true, &c);
 
  out:
     vfree(c.data);
diff --git a/xen/arch/x86/hvm/save.c b/xen/arch/x86/hvm/save.c
index 78b34e5cff..21d08c76a6 100644
--- a/xen/arch/x86/hvm/save.c
+++ b/xen/arch/x86/hvm/save.c
@@ -30,7 +30,8 @@ static void arch_hvm_save(struct domain *d, struct hvm_save_header *hdr)
     d->arch.hvm.sync_tsc = rdtsc();
 }
 
-static int arch_hvm_load(struct domain *d, const struct hvm_save_header *hdr)
+static int arch_hvm_check(const struct domain *d,
+                          const struct hvm_save_header *hdr)
 {
     uint32_t eax, ebx, ecx, edx;
 
@@ -55,6 +56,11 @@ static int arch_hvm_load(struct domain *d, const struct hvm_save_header *hdr)
                "(%#"PRIx32") and restored on another (%#"PRIx32").\n",
                d->domain_id, hdr->cpuid, eax);
 
+    return 0;
+}
+
+static void arch_hvm_load(struct domain *d, const struct hvm_save_header *hdr)
+{
     /* Restore guest's preferred TSC frequency. */
     if ( hdr->gtsc_khz )
         d->arch.tsc_khz = hdr->gtsc_khz;
@@ -66,13 +72,12 @@ static int arch_hvm_load(struct domain *d, const struct hvm_save_header *hdr)
 
     /* VGA state is not saved/restored, so we nobble the cache. */
     d->arch.hvm.stdvga.cache = STDVGA_CACHE_DISABLED;
-
-    return 0;
 }
 
 /* List of handlers for various HVM save and restore types */
 static struct {
     hvm_save_handler save;
+    hvm_check_handler check;
     hvm_load_handler load;
     const char *name;
     size_t size;
@@ -88,6 +93,7 @@ void __init hvm_register_savevm(uint16_t typecode,
 {
     ASSERT(typecode <= HVM_SAVE_CODE_MAX);
     ASSERT(hvm_sr_handlers[typecode].save == NULL);
+    ASSERT(hvm_sr_handlers[typecode].check == NULL);
     ASSERT(hvm_sr_handlers[typecode].load == NULL);
     hvm_sr_handlers[typecode].save = save_state;
     hvm_sr_handlers[typecode].load = load_state;
@@ -275,12 +281,15 @@ int hvm_save(struct domain *d, hvm_domain_context_t *h)
     return 0;
 }
 
-int hvm_load(struct domain *d, hvm_domain_context_t *h)
+/*
+ * @real = false requests checking of the incoming state, while @real = true
+ * requests actual loading, which will then assume that checking was already
+ * done or is unnecessary.
+ */
+int hvm_load(struct domain *d, bool real, hvm_domain_context_t *h)
 {
     const struct hvm_save_header *hdr;
     struct hvm_save_descriptor *desc;
-    hvm_load_handler handler;
-    struct vcpu *v;
     int rc;
 
     if ( d->is_dying )
@@ -291,50 +300,92 @@ int hvm_load(struct domain *d, hvm_domain_context_t *h)
     if ( !hdr )
         return -ENODATA;
 
-    rc = arch_hvm_load(d, hdr);
-    if ( rc )
-        return rc;
+    rc = arch_hvm_check(d, hdr);
+    if ( real )
+    {
+        struct vcpu *v;
+
+        ASSERT(!rc);
 
-    /* Down all the vcpus: we only re-enable the ones that had state saved. */
-    for_each_vcpu(d, v)
-        if ( !test_and_set_bit(_VPF_down, &v->pause_flags) )
-            vcpu_sleep_nosync(v);
+        /*
+         * Down all the vcpus: we only re-enable the ones that had state
+         * saved.
+         */
+        for_each_vcpu(d, v)
+            if ( !test_and_set_bit(_VPF_down, &v->pause_flags) )
+                vcpu_sleep_nosync(v);
+
+        arch_hvm_load(d, hdr);
+    }
+    else if ( rc )
+        return rc;
 
     for ( ; ; )
     {
+        const char *name;
+        hvm_load_handler load;
+
         if ( h->size - h->cur < sizeof(struct hvm_save_descriptor) )
         {
             /* Run out of data */
             printk(XENLOG_G_ERR
                    "HVM%d restore: save did not end with a null entry\n",
                    d->domain_id);
+            ASSERT(!real);
             return -ENODATA;
         }
 
         /* Read the typecode of the next entry  and check for the end-marker */
         desc = (struct hvm_save_descriptor *)(&h->data[h->cur]);
-        if ( desc->typecode == 0 )
+        if ( desc->typecode == HVM_SAVE_CODE(END) )
+        {
+            /* Reset cursor for hvm_load(, true, ). */
+            if ( !real )
+                h->cur = 0;
             return 0;
+        }
 
         /* Find the handler for this entry */
-        if ( (desc->typecode > HVM_SAVE_CODE_MAX) ||
-             ((handler = hvm_sr_handlers[desc->typecode].load) == NULL) )
+        if ( desc->typecode >= ARRAY_SIZE(hvm_sr_handlers) ||
+             !(name = hvm_sr_handlers[desc->typecode].name) ||
+             !(load = hvm_sr_handlers[desc->typecode].load) )
         {
             printk(XENLOG_G_ERR "HVM%d restore: unknown entry typecode %u\n",
                    d->domain_id, desc->typecode);
+            ASSERT(!real);
             return -EINVAL;
         }
 
-        /* Load the entry */
-        printk(XENLOG_G_INFO "HVM%d restore: %s %"PRIu16"\n", d->domain_id,
-               hvm_sr_handlers[desc->typecode].name, desc->instance);
-        rc = handler(d, h);
+        if ( real )
+        {
+            /* Load the entry */
+            printk(XENLOG_G_INFO "HVM restore %pd: %s %"PRIu16"\n", d,
+                   name, desc->instance);
+            rc = load(d, h);
+        }
+        else
+        {
+            /* Check the entry. */
+            hvm_check_handler check = hvm_sr_handlers[desc->typecode].check;
+
+            if ( !check )
+            {
+                if ( desc->length > h->size - h->cur - sizeof(*desc) )
+                    return -ENODATA;
+                h->cur += sizeof(*desc) + desc->length;
+                rc = 0;
+            }
+            else
+                rc = check(d, h);
+        }
+
         if ( rc )
         {
-            printk(XENLOG_G_ERR "HVM%d restore: failed to load entry %u/%u rc %d\n",
-                   d->domain_id, desc->typecode, desc->instance, rc);
+            printk(XENLOG_G_ERR "HVM restore %pd: failed to %s %s:%u rc %d\n",
+                   d, real ? "load" : "check", name, desc->instance, rc);
             return rc;
         }
+
         process_pending_softirqs();
     }
 
diff --git a/xen/arch/x86/include/asm/hvm/save.h b/xen/arch/x86/include/asm/hvm/save.h
index 992a91d646..43765e81cf 100644
--- a/xen/arch/x86/include/asm/hvm/save.h
+++ b/xen/arch/x86/include/asm/hvm/save.h
@@ -103,6 +103,8 @@ static inline unsigned int hvm_load_instance(const struct hvm_domain_context *h)
  * restoring.  Both return non-zero on error. */
 typedef int (*hvm_save_handler) (struct vcpu *v,
                                  hvm_domain_context_t *h);
+typedef int (*hvm_check_handler)(const struct domain *d,
+                                 hvm_domain_context_t *h);
 typedef int (*hvm_load_handler) (struct domain *d,
                                  hvm_domain_context_t *h);
 
@@ -140,6 +142,6 @@ size_t hvm_save_size(struct domain *d);
 int hvm_save(struct domain *d, hvm_domain_context_t *h);
 int hvm_save_one(struct domain *d, unsigned int typecode, unsigned int instance,
                  XEN_GUEST_HANDLE_64(uint8) handle, uint64_t *bufsz);
-int hvm_load(struct domain *d, hvm_domain_context_t *h);
+int hvm_load(struct domain *d, bool real, hvm_domain_context_t *h);
 
 #endif /* __XEN_HVM_SAVE_H__ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 16 01:34:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 16 Jan 2024 01:34:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667614.1039059 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYLG-0004HN-Pp; Tue, 16 Jan 2024 01:34:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667614.1039059; Tue, 16 Jan 2024 01:34:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYLG-0004HG-Ix; Tue, 16 Jan 2024 01:34:14 +0000
Received: by outflank-mailman (input) for mailman id 667614;
 Tue, 16 Jan 2024 01:34:13 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYLF-0004H7-3B
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34:13 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYLF-0003UW-2L
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34:13 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYLF-0000Bx-1N
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34:13 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=GpMlpb/CiDJFmFDUsydE7DlMGOFoo0FBrmZpdSlP5xI=; b=sowQgXxUBzptnjZbnP0ZQursUa
	+uE/uzZck9z9uY/OkTG4gtvSKJzDlZSlIG2DzdX6WzcTMwDnFGXrAO0huxlV1c3zbkucSWa6rqx7t
	zEops1iLzYo+R5oNBjZdXsIk3yrlXmPF8snagUsq4OUUf6RtwP2n2FUIKFGG+NNW6s2Y=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/HVM: adjust save/restore hook registration for optional check handler
Message-Id: <E1rPYLF-0000Bx-1N@xenbits.xenproject.org>
Date: Tue, 16 Jan 2024 01:34:13 +0000

commit c3c6e9b8e84becc2fc03107729f4cdc618914af4
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 15 12:17:37 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 15 12:17:37 2024 +0100

    x86/HVM: adjust save/restore hook registration for optional check handler
    
    Register NULL uniformly as a first step.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/cpu/mcheck/vmce.c       | 2 +-
 xen/arch/x86/emul-i8254.c            | 2 +-
 xen/arch/x86/hvm/hpet.c              | 2 +-
 xen/arch/x86/hvm/hvm.c               | 6 ++++--
 xen/arch/x86/hvm/irq.c               | 6 +++---
 xen/arch/x86/hvm/mtrr.c              | 2 +-
 xen/arch/x86/hvm/pmtimer.c           | 2 +-
 xen/arch/x86/hvm/rtc.c               | 2 +-
 xen/arch/x86/hvm/save.c              | 2 ++
 xen/arch/x86/hvm/vioapic.c           | 3 ++-
 xen/arch/x86/hvm/viridian/viridian.c | 4 ++--
 xen/arch/x86/hvm/vlapic.c            | 4 ++--
 xen/arch/x86/hvm/vpic.c              | 2 +-
 xen/arch/x86/include/asm/hvm/save.h  | 4 +++-
 14 files changed, 25 insertions(+), 18 deletions(-)

diff --git a/xen/arch/x86/cpu/mcheck/vmce.c b/xen/arch/x86/cpu/mcheck/vmce.c
index 904b0c0d3a..353d4f19b2 100644
--- a/xen/arch/x86/cpu/mcheck/vmce.c
+++ b/xen/arch/x86/cpu/mcheck/vmce.c
@@ -374,7 +374,7 @@ static int cf_check vmce_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t *
     return err ?: vmce_restore_vcpu(v, &ctxt);
 }
 
-HVM_REGISTER_SAVE_RESTORE(VMCE_VCPU, vmce_save_vcpu_ctxt,
+HVM_REGISTER_SAVE_RESTORE(VMCE_VCPU, vmce_save_vcpu_ctxt, NULL,
                           vmce_load_vcpu_ctxt, 1, HVMSR_PER_VCPU);
 #endif
 
diff --git a/xen/arch/x86/emul-i8254.c b/xen/arch/x86/emul-i8254.c
index ea17fb502a..3c888d1a6b 100644
--- a/xen/arch/x86/emul-i8254.c
+++ b/xen/arch/x86/emul-i8254.c
@@ -458,7 +458,7 @@ static int cf_check pit_load(struct domain *d, hvm_domain_context_t *h)
     return rc;
 }
 
-HVM_REGISTER_SAVE_RESTORE(PIT, pit_save, pit_load, 1, HVMSR_PER_DOM);
+HVM_REGISTER_SAVE_RESTORE(PIT, pit_save, NULL, pit_load, 1, HVMSR_PER_DOM);
 #endif
 
 /* The intercept action for PIT DM retval: 0--not handled; 1--handled. */
diff --git a/xen/arch/x86/hvm/hpet.c b/xen/arch/x86/hvm/hpet.c
index f6b554ecc7..1db9c0b60e 100644
--- a/xen/arch/x86/hvm/hpet.c
+++ b/xen/arch/x86/hvm/hpet.c
@@ -692,7 +692,7 @@ static int cf_check hpet_load(struct domain *d, hvm_domain_context_t *h)
     return 0;
 }
 
-HVM_REGISTER_SAVE_RESTORE(HPET, hpet_save, hpet_load, 1, HVMSR_PER_DOM);
+HVM_REGISTER_SAVE_RESTORE(HPET, hpet_save, NULL, hpet_load, 1, HVMSR_PER_DOM);
 
 static void hpet_set(HPETState *h)
 {
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 4650cba72b..e3bd9157d7 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -793,7 +793,7 @@ static int cf_check hvm_load_tsc_adjust(struct domain *d, hvm_domain_context_t *
     return 0;
 }
 
-HVM_REGISTER_SAVE_RESTORE(TSC_ADJUST, hvm_save_tsc_adjust,
+HVM_REGISTER_SAVE_RESTORE(TSC_ADJUST, hvm_save_tsc_adjust, NULL,
                           hvm_load_tsc_adjust, 1, HVMSR_PER_VCPU);
 
 static int cf_check hvm_save_cpu_ctxt(struct vcpu *v, hvm_domain_context_t *h)
@@ -1186,7 +1186,7 @@ static int cf_check hvm_load_cpu_ctxt(struct domain *d, hvm_domain_context_t *h)
     return 0;
 }
 
-HVM_REGISTER_SAVE_RESTORE(CPU, hvm_save_cpu_ctxt, hvm_load_cpu_ctxt, 1,
+HVM_REGISTER_SAVE_RESTORE(CPU, hvm_save_cpu_ctxt, NULL, hvm_load_cpu_ctxt, 1,
                           HVMSR_PER_VCPU);
 
 #define HVM_CPU_XSAVE_SIZE(xcr0) (offsetof(struct hvm_hw_cpu_xsave, \
@@ -1535,6 +1535,7 @@ static int __init cf_check hvm_register_CPU_save_and_restore(void)
     hvm_register_savevm(CPU_XSAVE_CODE,
                         "CPU_XSAVE",
                         hvm_save_cpu_xsave_states,
+                        NULL,
                         hvm_load_cpu_xsave_states,
                         HVM_CPU_XSAVE_SIZE(xfeature_mask) +
                             sizeof(struct hvm_save_descriptor),
@@ -1543,6 +1544,7 @@ static int __init cf_check hvm_register_CPU_save_and_restore(void)
     hvm_register_savevm(CPU_MSR_CODE,
                         "CPU_MSR",
                         hvm_save_cpu_msrs,
+                        NULL,
                         hvm_load_cpu_msrs,
                         HVM_CPU_MSR_SIZE(ARRAY_SIZE(msrs_to_send)) +
                             sizeof(struct hvm_save_descriptor),
diff --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c
index 98cb28f366..65c56ce47d 100644
--- a/xen/arch/x86/hvm/irq.c
+++ b/xen/arch/x86/hvm/irq.c
@@ -784,9 +784,9 @@ static int cf_check irq_load_link(struct domain *d, hvm_domain_context_t *h)
     return 0;
 }
 
-HVM_REGISTER_SAVE_RESTORE(PCI_IRQ, irq_save_pci, irq_load_pci,
+HVM_REGISTER_SAVE_RESTORE(PCI_IRQ, irq_save_pci, NULL, irq_load_pci,
                           1, HVMSR_PER_DOM);
-HVM_REGISTER_SAVE_RESTORE(ISA_IRQ, irq_save_isa, irq_load_isa,
+HVM_REGISTER_SAVE_RESTORE(ISA_IRQ, irq_save_isa, NULL, irq_load_isa,
                           1, HVMSR_PER_DOM);
-HVM_REGISTER_SAVE_RESTORE(PCI_LINK, irq_save_link, irq_load_link,
+HVM_REGISTER_SAVE_RESTORE(PCI_LINK, irq_save_link, NULL, irq_load_link,
                           1, HVMSR_PER_DOM);
diff --git a/xen/arch/x86/hvm/mtrr.c b/xen/arch/x86/hvm/mtrr.c
index 52df34a6de..32f74c1db0 100644
--- a/xen/arch/x86/hvm/mtrr.c
+++ b/xen/arch/x86/hvm/mtrr.c
@@ -773,7 +773,7 @@ static int cf_check hvm_load_mtrr_msr(struct domain *d, hvm_domain_context_t *h)
     return 0;
 }
 
-HVM_REGISTER_SAVE_RESTORE(MTRR, hvm_save_mtrr_msr, hvm_load_mtrr_msr, 1,
+HVM_REGISTER_SAVE_RESTORE(MTRR, hvm_save_mtrr_msr, NULL, hvm_load_mtrr_msr, 1,
                           HVMSR_PER_VCPU);
 
 void memory_type_changed(struct domain *d)
diff --git a/xen/arch/x86/hvm/pmtimer.c b/xen/arch/x86/hvm/pmtimer.c
index eb4a455763..97099ac305 100644
--- a/xen/arch/x86/hvm/pmtimer.c
+++ b/xen/arch/x86/hvm/pmtimer.c
@@ -300,7 +300,7 @@ static int cf_check acpi_load(struct domain *d, hvm_domain_context_t *h)
     return 0;
 }
 
-HVM_REGISTER_SAVE_RESTORE(PMTIMER, acpi_save, acpi_load,
+HVM_REGISTER_SAVE_RESTORE(PMTIMER, acpi_save, NULL, acpi_load,
                           1, HVMSR_PER_DOM);
 
 int pmtimer_change_ioport(struct domain *d, uint64_t version)
diff --git a/xen/arch/x86/hvm/rtc.c b/xen/arch/x86/hvm/rtc.c
index 853ead5e80..4b31382619 100644
--- a/xen/arch/x86/hvm/rtc.c
+++ b/xen/arch/x86/hvm/rtc.c
@@ -797,7 +797,7 @@ static int cf_check rtc_load(struct domain *d, hvm_domain_context_t *h)
     return 0;
 }
 
-HVM_REGISTER_SAVE_RESTORE(RTC, rtc_save, rtc_load, 1, HVMSR_PER_DOM);
+HVM_REGISTER_SAVE_RESTORE(RTC, rtc_save, NULL, rtc_load, 1, HVMSR_PER_DOM);
 
 void rtc_reset(struct domain *d)
 {
diff --git a/xen/arch/x86/hvm/save.c b/xen/arch/x86/hvm/save.c
index 21d08c76a6..99aaf3fc33 100644
--- a/xen/arch/x86/hvm/save.c
+++ b/xen/arch/x86/hvm/save.c
@@ -88,6 +88,7 @@ static struct {
 void __init hvm_register_savevm(uint16_t typecode,
                                 const char *name,
                                 hvm_save_handler save_state,
+                                hvm_check_handler check_state,
                                 hvm_load_handler load_state,
                                 size_t size, int kind)
 {
@@ -96,6 +97,7 @@ void __init hvm_register_savevm(uint16_t typecode,
     ASSERT(hvm_sr_handlers[typecode].check == NULL);
     ASSERT(hvm_sr_handlers[typecode].load == NULL);
     hvm_sr_handlers[typecode].save = save_state;
+    hvm_sr_handlers[typecode].check = check_state;
     hvm_sr_handlers[typecode].load = load_state;
     hvm_sr_handlers[typecode].name = name;
     hvm_sr_handlers[typecode].size = size;
diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c
index 4e40d3609a..f896b9ea12 100644
--- a/xen/arch/x86/hvm/vioapic.c
+++ b/xen/arch/x86/hvm/vioapic.c
@@ -631,7 +631,8 @@ static int cf_check ioapic_load(struct domain *d, hvm_domain_context_t *h)
     return 0;
 }
 
-HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, ioapic_load, 1, HVMSR_PER_DOM);
+HVM_REGISTER_SAVE_RESTORE(IOAPIC, ioapic_save, NULL, ioapic_load, 1,
+                          HVMSR_PER_DOM);
 
 void vioapic_reset(struct domain *d)
 {
diff --git a/xen/arch/x86/hvm/viridian/viridian.c b/xen/arch/x86/hvm/viridian/viridian.c
index 61171e3363..0496c52ed5 100644
--- a/xen/arch/x86/hvm/viridian/viridian.c
+++ b/xen/arch/x86/hvm/viridian/viridian.c
@@ -1145,7 +1145,7 @@ static int cf_check viridian_load_domain_ctxt(
     return 0;
 }
 
-HVM_REGISTER_SAVE_RESTORE(VIRIDIAN_DOMAIN, viridian_save_domain_ctxt,
+HVM_REGISTER_SAVE_RESTORE(VIRIDIAN_DOMAIN, viridian_save_domain_ctxt, NULL,
                           viridian_load_domain_ctxt, 1, HVMSR_PER_DOM);
 
 static int cf_check viridian_save_vcpu_ctxt(
@@ -1188,7 +1188,7 @@ static int cf_check viridian_load_vcpu_ctxt(
     return 0;
 }
 
-HVM_REGISTER_SAVE_RESTORE(VIRIDIAN_VCPU, viridian_save_vcpu_ctxt,
+HVM_REGISTER_SAVE_RESTORE(VIRIDIAN_VCPU, viridian_save_vcpu_ctxt, NULL,
                           viridian_load_vcpu_ctxt, 1, HVMSR_PER_VCPU);
 
 static int __init cf_check parse_viridian_version(const char *arg)
diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c
index cdb69d9742..405bcd9a1c 100644
--- a/xen/arch/x86/hvm/vlapic.c
+++ b/xen/arch/x86/hvm/vlapic.c
@@ -1617,9 +1617,9 @@ static int cf_check lapic_load_regs(struct domain *d, hvm_domain_context_t *h)
     return 0;
 }
 
-HVM_REGISTER_SAVE_RESTORE(LAPIC, lapic_save_hidden,
+HVM_REGISTER_SAVE_RESTORE(LAPIC, lapic_save_hidden, NULL,
                           lapic_load_hidden, 1, HVMSR_PER_VCPU);
-HVM_REGISTER_SAVE_RESTORE(LAPIC_REGS, lapic_save_regs,
+HVM_REGISTER_SAVE_RESTORE(LAPIC_REGS, lapic_save_regs, NULL,
                           lapic_load_regs, 1, HVMSR_PER_VCPU);
 
 int vlapic_init(struct vcpu *v)
diff --git a/xen/arch/x86/hvm/vpic.c b/xen/arch/x86/hvm/vpic.c
index 5f822844db..8a6244921d 100644
--- a/xen/arch/x86/hvm/vpic.c
+++ b/xen/arch/x86/hvm/vpic.c
@@ -449,7 +449,7 @@ static int cf_check vpic_load(struct domain *d, hvm_domain_context_t *h)
     return 0;
 }
 
-HVM_REGISTER_SAVE_RESTORE(PIC, vpic_save, vpic_load, 2, HVMSR_PER_DOM);
+HVM_REGISTER_SAVE_RESTORE(PIC, vpic_save, NULL, vpic_load, 2, HVMSR_PER_DOM);
 
 void vpic_reset(struct domain *d)
 {
diff --git a/xen/arch/x86/include/asm/hvm/save.h b/xen/arch/x86/include/asm/hvm/save.h
index 43765e81cf..04a47ffcc4 100644
--- a/xen/arch/x86/include/asm/hvm/save.h
+++ b/xen/arch/x86/include/asm/hvm/save.h
@@ -113,6 +113,7 @@ typedef int (*hvm_load_handler) (struct domain *d,
 void hvm_register_savevm(uint16_t typecode,
                          const char *name, 
                          hvm_save_handler save_state,
+                         hvm_check_handler check_state,
                          hvm_load_handler load_state,
                          size_t size, int kind);
 
@@ -122,12 +123,13 @@ void hvm_register_savevm(uint16_t typecode,
 
 /* Syntactic sugar around that function: specify the max number of
  * saves, and this calculates the size of buffer needed */
-#define HVM_REGISTER_SAVE_RESTORE(_x, _save, _load, _num, _k)             \
+#define HVM_REGISTER_SAVE_RESTORE(_x, _save, check, _load, _num, _k)      \
 static int __init cf_check __hvm_register_##_x##_save_and_restore(void)   \
 {                                                                         \
     hvm_register_savevm(HVM_SAVE_CODE(_x),                                \
                         #_x,                                              \
                         &_save,                                           \
+                        check,                                            \
                         &_load,                                           \
                         (_num) * (HVM_SAVE_LENGTH(_x)                     \
                                   + sizeof (struct hvm_save_descriptor)), \
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 16 01:34:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 16 Jan 2024 01:34:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667615.1039062 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYLQ-0004LH-Pb; Tue, 16 Jan 2024 01:34:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667615.1039062; Tue, 16 Jan 2024 01:34:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYLQ-0004L7-MO; Tue, 16 Jan 2024 01:34:24 +0000
Received: by outflank-mailman (input) for mailman id 667615;
 Tue, 16 Jan 2024 01:34:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYLP-0004Ku-6A
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYLP-0003Uo-5R
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYLP-0000D0-4T
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34:23 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=it2jQHIhbrZk9WZjQ/zIw3y0TgtsjGP//W2MZJ9NtoE=; b=13YL6eoeaf1BnuUBjEPiyGv5Cw
	r9isJzLKtKl9mySTOiZ/e1l7ZJV7jvZeIaZsw4Hldo2XDgc2vUSup+rqodizh7sFyBF4mOuTjTWLb
	Uee30S4zfxtivnMps3PDoBPa6km/dW/RE+COvCGx4G9Hshp3Gv5H82bB+ALyZq2+hw20=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/vPIT: check values loaded from state save record
Message-Id: <E1rPYLP-0000D0-4T@xenbits.xenproject.org>
Date: Tue, 16 Jan 2024 01:34:23 +0000

commit c53013da6f1e7d23b01ffaa56695563945391ffa
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 15 12:18:10 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 15 12:18:10 2024 +0100

    x86/vPIT: check values loaded from state save record
    
    In particular pit_latch_status() and speaker_ioport_read() perform
    calculations which assume in-bounds values. Several of the state save
    record fields can hold wider ranges, though. Refuse to load values which
    cannot result from normal operation, except mode, the init state of
    which (see also below) cannot otherwise be reached.
    
    Note that ->gate should only be possible to be zero for channel 2;
    enforce that as well.
    
    Adjust pit_reset()'s writing of ->mode as well, to not unduly affect
    the value pit_latch_status() may calculate. The chosen mode of 7 is
    still one which cannot be established by writing the control word. Note
    that with or without this adjustment effectively all switch() statements
    using mode as the control expression aren't quite right when the PIT is
    still in that init state; there is an apparent assumption that before
    these can sensibly be invoked, the guest would init the PIT (i.e. in
    particular set the mode).
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/emul-i8254.c | 54 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 52 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/emul-i8254.c b/xen/arch/x86/emul-i8254.c
index 3c888d1a6b..0191f80ba2 100644
--- a/xen/arch/x86/emul-i8254.c
+++ b/xen/arch/x86/emul-i8254.c
@@ -47,6 +47,7 @@
 #define RW_STATE_MSB 2
 #define RW_STATE_WORD0 3
 #define RW_STATE_WORD1 4
+#define RW_STATE_NUM 5
 
 #define get_guest_time(v) \
    (is_hvm_vcpu(v) ? hvm_get_guest_time(v) : (u64)get_s_time())
@@ -427,6 +428,47 @@ static int cf_check pit_save(struct vcpu *v, hvm_domain_context_t *h)
     return rc;
 }
 
+static int cf_check pit_check(const struct domain *d, hvm_domain_context_t *h)
+{
+    const struct hvm_hw_pit *hw;
+    unsigned int i;
+
+    if ( !has_vpit(d) )
+        return -ENODEV;
+
+    hw = hvm_get_entry(PIT, h);
+    if ( !hw )
+        return -ENODATA;
+
+    /*
+     * Check to-be-loaded values are within valid range, for them to represent
+     * actually reachable state.  Uses of some of the values elsewhere assume
+     * this is the case.  Note that the channels' mode fields aren't checked;
+     * Xen prior to 4.19 might save them as 0xff.
+     */
+    if ( hw->speaker_data_on > 1 || hw->pad0 )
+        return -EDOM;
+
+    for ( i = 0; i < ARRAY_SIZE(hw->channels); ++i )
+    {
+        const struct hvm_hw_pit_channel *ch = &hw->channels[i];
+
+        if ( ch->count > 0x10000 ||
+             ch->count_latched >= RW_STATE_NUM ||
+             ch->read_state >= RW_STATE_NUM ||
+             ch->write_state >= RW_STATE_NUM ||
+             ch->rw_mode > RW_STATE_WORD0 ||
+             ch->gate > 1 ||
+             ch->bcd > 1 )
+            return -EDOM;
+
+        if ( i != 2 && !ch->gate )
+            return -EINVAL;
+    }
+
+    return 0;
+}
+
 static int cf_check pit_load(struct domain *d, hvm_domain_context_t *h)
 {
     PITState *pit = domain_vpit(d);
@@ -443,6 +485,14 @@ static int cf_check pit_load(struct domain *d, hvm_domain_context_t *h)
         goto out;
     }
     
+    for ( i = 0; i < ARRAY_SIZE(pit->hw.channels); ++i )
+    {
+        struct hvm_hw_pit_channel *ch = &pit->hw.channels[i];
+
+        if ( (ch->mode &= 7) > 5 )
+            ch->mode -= 4;
+    }
+
     /*
      * Recreate platform timers from hardware state.  There will be some 
      * time jitter here, but the wall-clock will have jumped massively, so 
@@ -458,7 +508,7 @@ static int cf_check pit_load(struct domain *d, hvm_domain_context_t *h)
     return rc;
 }
 
-HVM_REGISTER_SAVE_RESTORE(PIT, pit_save, NULL, pit_load, 1, HVMSR_PER_DOM);
+HVM_REGISTER_SAVE_RESTORE(PIT, pit_save, pit_check, pit_load, 1, HVMSR_PER_DOM);
 #endif
 
 /* The intercept action for PIT DM retval: 0--not handled; 1--handled. */
@@ -575,7 +625,7 @@ void pit_reset(struct domain *d)
     for ( i = 0; i < 3; i++ )
     {
         s = &pit->hw.channels[i];
-        s->mode = 0xff; /* the init mode */
+        s->mode = 7; /* unreachable sentinel */
         s->gate = (i != 2);
         pit_load_count(pit, i, 0);
     }
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 16 01:34:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 16 Jan 2024 01:34:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667617.1039066 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYLa-0004OY-R9; Tue, 16 Jan 2024 01:34:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667617.1039066; Tue, 16 Jan 2024 01:34: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 1rPYLa-0004OR-Nw; Tue, 16 Jan 2024 01:34:34 +0000
Received: by outflank-mailman (input) for mailman id 667617;
 Tue, 16 Jan 2024 01:34:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYLZ-0004O9-94
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYLZ-0003V4-8K
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYLZ-0000Dp-7X
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=65kVDidPw7GrEiB1pyf6Rnm2ZW7vzhJ9lJBrIPMU8uY=; b=Y1AR2dLgbmL+IXRGSPG18lJTSV
	F+kAFVr/WLSlCN9RN12EX5zCdIQVJ34/mT5GX3dC/h6k7/tP3lwMYVX8AW+Bm64fgIIuS2yA112pw
	rTIGmWbPJviea+BF23fLLD7sNCccUl4ptmquYDCgsTw73ft0wq4WRTmjKQKiQunOXk+Q=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/vPIC: check values loaded from state save record
Message-Id: <E1rPYLZ-0000Dp-7X@xenbits.xenproject.org>
Date: Tue, 16 Jan 2024 01:34:33 +0000

commit 69c89dd78745c0284aff62ab5869737fb8477b1b
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 15 12:18:43 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 15 12:18:43 2024 +0100

    x86/vPIC: check values loaded from state save record
    
    Loading is_master from the state save record can lead to out-of-bounds
    accesses via at least the two container_of() uses by vpic_domain() and
    __vpic_lock(). Make sure the value is consistent with the instance being
    loaded.
    
    For ->int_output (which for whatever reason isn't a 1-bit bitfield),
    besides bounds checking also take ->init_state into account.
    
    For ELCR follow what vpic_intercept_elcr_io()'s write path and
    vpic_reset() do, i.e. don't insist on the internal view of the value to
    be saved.
    
    Move the instance range check as well, leaving just an assertion in the
    load handler.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/hvm/vpic.c | 41 ++++++++++++++++++++++++++++++++++++++---
 1 file changed, 38 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/hvm/vpic.c b/xen/arch/x86/hvm/vpic.c
index 8a6244921d..4e23247a46 100644
--- a/xen/arch/x86/hvm/vpic.c
+++ b/xen/arch/x86/hvm/vpic.c
@@ -429,6 +429,38 @@ static int cf_check vpic_save(struct vcpu *v, hvm_domain_context_t *h)
     return 0;
 }
 
+static int cf_check vpic_check(const struct domain *d, hvm_domain_context_t *h)
+{
+    unsigned int inst = hvm_load_instance(h);
+    const struct hvm_hw_vpic *s;
+
+    if ( !has_vpic(d) )
+        return -ENODEV;
+
+    /* Which PIC is this? */
+    if ( inst >= ARRAY_SIZE(d->arch.hvm.vpic) )
+        return -ENOENT;
+
+    s = hvm_get_entry(PIC, h);
+    if ( !s )
+        return -ENODATA;
+
+    /*
+     * Check to-be-loaded values are within valid range, for them to represent
+     * actually reachable state.  Uses of some of the values elsewhere assume
+     * this is the case.
+     */
+    if ( s->int_output > 1 )
+        return -EDOM;
+
+    if ( s->is_master != !inst ||
+         (s->int_output && s->init_state) ||
+         (s->elcr & ~vpic_elcr_mask(s, 1)) )
+        return -EINVAL;
+
+    return 0;
+}
+
 static int cf_check vpic_load(struct domain *d, hvm_domain_context_t *h)
 {
     struct hvm_hw_vpic *s;
@@ -438,18 +470,21 @@ static int cf_check vpic_load(struct domain *d, hvm_domain_context_t *h)
         return -ENODEV;
 
     /* Which PIC is this? */
-    if ( inst > 1 )
-        return -ENOENT;
+    ASSERT(inst < ARRAY_SIZE(d->arch.hvm.vpic));
     s = &d->arch.hvm.vpic[inst];
 
     /* Load the state */
     if ( hvm_load_entry(PIC, h, s) != 0 )
         return -EINVAL;
 
+    if ( s->is_master )
+        s->elcr |= 1 << 2;
+
     return 0;
 }
 
-HVM_REGISTER_SAVE_RESTORE(PIC, vpic_save, NULL, vpic_load, 2, HVMSR_PER_DOM);
+HVM_REGISTER_SAVE_RESTORE(PIC, vpic_save, vpic_check, vpic_load, 2,
+                          HVMSR_PER_DOM);
 
 void vpic_reset(struct domain *d)
 {
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 16 01:34:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 16 Jan 2024 01:34:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667618.1039070 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYLk-0004RL-TA; Tue, 16 Jan 2024 01:34:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667618.1039070; Tue, 16 Jan 2024 01:34: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 1rPYLk-0004RD-Pg; Tue, 16 Jan 2024 01:34:44 +0000
Received: by outflank-mailman (input) for mailman id 667618;
 Tue, 16 Jan 2024 01:34: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 1rPYLj-0004R1-C4
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34: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 1rPYLj-0003VE-BM
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYLj-0000F7-AU
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=TOGSh8T5guWGHmzHjEHqsouEPb4DaN1k/6nevvQpiuc=; b=Y1cOPp7y3keO4Sg0SCQfIFAeUw
	e7D67Kj6AcfDemcB/fwrSULcaY5lSbH2EB2X6OGYKK7g+7r78M69EDy6Gh8gx7XiwtMRmNtjqfOT8
	TW0C4Sz27x/jPK6+rT9NtQUI1qxDVy9EsIv8T7b3Wc1ZVQYOW9MNLPXUzsGxKpj4iius=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/vIRQ: split PCI link load state checking from actual loading
Message-Id: <E1rPYLj-0000F7-AU@xenbits.xenproject.org>
Date: Tue, 16 Jan 2024 01:34:43 +0000

commit 7a3bd1cbc4c7456fc2ec88e4060746376a1cde7d
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 15 12:19:17 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 15 12:19:17 2024 +0100

    x86/vIRQ: split PCI link load state checking from actual loading
    
    Move the checking into a check hook, and add checking of the padding
    fields as well.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/hvm/irq.c | 38 ++++++++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 12 deletions(-)

diff --git a/xen/arch/x86/hvm/irq.c b/xen/arch/x86/hvm/irq.c
index 65c56ce47d..4a9fe82cbd 100644
--- a/xen/arch/x86/hvm/irq.c
+++ b/xen/arch/x86/hvm/irq.c
@@ -749,6 +749,30 @@ static int cf_check irq_load_isa(struct domain *d, hvm_domain_context_t *h)
     return 0;
 }
 
+static int cf_check irq_check_link(const struct domain *d,
+                                   hvm_domain_context_t *h)
+{
+    const struct hvm_hw_pci_link *pci_link = hvm_get_entry(PCI_LINK, h);
+    unsigned int link;
+
+    if ( !pci_link )
+        return -ENODATA;
+
+    for ( link = 0; link < ARRAY_SIZE(pci_link->pad0); link++ )
+        if ( pci_link->pad0[link] )
+            return -EINVAL;
+
+    for ( link = 0; link < ARRAY_SIZE(pci_link->route); link++ )
+        if ( pci_link->route[link] > 15 )
+        {
+            printk(XENLOG_G_ERR
+                   "HVM restore: PCI-ISA link %u out of range (%u)\n",
+                   link, pci_link->route[link]);
+            return -EINVAL;
+        }
+
+    return 0;
+}
 
 static int cf_check irq_load_link(struct domain *d, hvm_domain_context_t *h)
 {
@@ -759,16 +783,6 @@ static int cf_check irq_load_link(struct domain *d, hvm_domain_context_t *h)
     if ( hvm_load_entry(PCI_LINK, h, &hvm_irq->pci_link) != 0 )
         return -EINVAL;
 
-    /* Sanity check */
-    for ( link = 0; link < 4; link++ )
-        if ( hvm_irq->pci_link.route[link] > 15 )
-        {
-            printk(XENLOG_G_ERR
-                   "HVM restore: PCI-ISA link %u out of range (%u)\n",
-                   link, hvm_irq->pci_link.route[link]);
-            return -EINVAL;
-        }
-
     /* Adjust the GSI assert counts for the link outputs.
      * This relies on the PCI and ISA IRQ state being loaded first */
     for ( link = 0; link < 4; link++ )
@@ -788,5 +802,5 @@ HVM_REGISTER_SAVE_RESTORE(PCI_IRQ, irq_save_pci, NULL, irq_load_pci,
                           1, HVMSR_PER_DOM);
 HVM_REGISTER_SAVE_RESTORE(ISA_IRQ, irq_save_isa, NULL, irq_load_isa,
                           1, HVMSR_PER_DOM);
-HVM_REGISTER_SAVE_RESTORE(PCI_LINK, irq_save_link, NULL, irq_load_link,
-                          1, HVMSR_PER_DOM);
+HVM_REGISTER_SAVE_RESTORE(PCI_LINK, irq_save_link, irq_check_link,
+                          irq_load_link, 1, HVMSR_PER_DOM);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 16 01:34:55 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 16 Jan 2024 01:34:55 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667619.1039075 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYLu-0004Tz-Uo; Tue, 16 Jan 2024 01:34:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667619.1039075; Tue, 16 Jan 2024 01:34:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYLu-0004Tr-RJ; Tue, 16 Jan 2024 01:34:54 +0000
Received: by outflank-mailman (input) for mailman id 667619;
 Tue, 16 Jan 2024 01:34:53 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYLt-0004Te-FH
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34:53 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYLt-0003VR-EZ
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34:53 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYLt-0000GL-Di
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:34:53 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=r6fMoDHI4KEIC1SOcEfWJJ36lSObfmW/8pyfY52Nr9g=; b=EVkC3KZNxfhJQSicMdoXgleT8h
	Yb6u4qiaZR57GeafNJcy7edwS98D3mooTTZ+mSMrNcylsPIIbinRKNdyZFuakNiYKg7ZKPkxFmnAI
	lKWNxqYQ4z8BWV9utnhrkdSaR7/mgcGp0ZDV5eKbtaI/5q/Ghn+u7to4yubjAwJmq83Y=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/vPMU: drop regs parameter from interrupt functions
Message-Id: <E1rPYLt-0000GL-Di@xenbits.xenproject.org>
Date: Tue, 16 Jan 2024 01:34:53 +0000

commit cd574f3ed86636fb2375deaf2767b9f3e287cdc6
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 15 12:19:41 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 15 12:19:41 2024 +0100

    x86/vPMU: drop regs parameter from interrupt functions
    
    The vendor functions don't use the respective parameters at all. In
    vpmu_do_interrupt() there's only a very limited area where the
    outer context's state would be needed, retrievable by get_irq_regs().
    
    This is in preparation of dropping the register parameters from direct
    APIC vector handler functions.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/apic.c             | 2 +-
 xen/arch/x86/cpu/vpmu.c         | 5 +++--
 xen/arch/x86/cpu/vpmu_amd.c     | 2 +-
 xen/arch/x86/cpu/vpmu_intel.c   | 2 +-
 xen/arch/x86/include/asm/vpmu.h | 4 ++--
 5 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c
index d00ff0943f..da41d2dfed 100644
--- a/xen/arch/x86/apic.c
+++ b/xen/arch/x86/apic.c
@@ -1412,7 +1412,7 @@ static void cf_check error_interrupt(struct cpu_user_regs *regs)
 static void cf_check pmu_interrupt(struct cpu_user_regs *regs)
 {
     ack_APIC_irq();
-    vpmu_do_interrupt(regs);
+    vpmu_do_interrupt();
 }
 
 void __init apic_intr_init(void)
diff --git a/xen/arch/x86/cpu/vpmu.c b/xen/arch/x86/cpu/vpmu.c
index ed84372b80..2e08d2363c 100644
--- a/xen/arch/x86/cpu/vpmu.c
+++ b/xen/arch/x86/cpu/vpmu.c
@@ -158,7 +158,7 @@ static inline struct vcpu *choose_hwdom_vcpu(void)
     return hardware_domain->vcpu[idx];
 }
 
-void vpmu_do_interrupt(struct cpu_user_regs *regs)
+void vpmu_do_interrupt(void)
 {
     struct vcpu *sampled = current, *sampling;
     struct vpmu_struct *vpmu;
@@ -239,6 +239,7 @@ void vpmu_do_interrupt(struct cpu_user_regs *regs)
         else
 #endif
         {
+            const struct cpu_user_regs *regs = get_irq_regs();
             struct xen_pmu_regs *r = &vpmu->xenpmu_data->pmu.r.regs;
 
             if ( (vpmu_mode & XENPMU_MODE_SELF) )
@@ -301,7 +302,7 @@ void vpmu_do_interrupt(struct cpu_user_regs *regs)
     /* We don't support (yet) HVM dom0 */
     ASSERT(sampling == sampled);
 
-    if ( !alternative_call(vpmu_ops.do_interrupt, regs) ||
+    if ( !alternative_call(vpmu_ops.do_interrupt) ||
          !is_vlapic_lvtpc_enabled(vlapic) )
         return;
 
diff --git a/xen/arch/x86/cpu/vpmu_amd.c b/xen/arch/x86/cpu/vpmu_amd.c
index c28a7e3c47..db2fa420e1 100644
--- a/xen/arch/x86/cpu/vpmu_amd.c
+++ b/xen/arch/x86/cpu/vpmu_amd.c
@@ -175,7 +175,7 @@ static void amd_vpmu_unset_msr_bitmap(struct vcpu *v)
     msr_bitmap_off(vpmu);
 }
 
-static int cf_check amd_vpmu_do_interrupt(struct cpu_user_regs *regs)
+static int cf_check amd_vpmu_do_interrupt(void)
 {
     return 1;
 }
diff --git a/xen/arch/x86/cpu/vpmu_intel.c b/xen/arch/x86/cpu/vpmu_intel.c
index 0a73ae27a4..cd414165df 100644
--- a/xen/arch/x86/cpu/vpmu_intel.c
+++ b/xen/arch/x86/cpu/vpmu_intel.c
@@ -772,7 +772,7 @@ static void cf_check core2_vpmu_dump(const struct vcpu *v)
     }
 }
 
-static int cf_check core2_vpmu_do_interrupt(struct cpu_user_regs *regs)
+static int cf_check core2_vpmu_do_interrupt(void)
 {
     struct vcpu *v = current;
     u64 msr_content;
diff --git a/xen/arch/x86/include/asm/vpmu.h b/xen/arch/x86/include/asm/vpmu.h
index 6629093197..f271f28e4a 100644
--- a/xen/arch/x86/include/asm/vpmu.h
+++ b/xen/arch/x86/include/asm/vpmu.h
@@ -31,7 +31,7 @@ struct arch_vpmu_ops {
     int (*initialise)(struct vcpu *v);
     int (*do_wrmsr)(unsigned int msr, uint64_t msr_content);
     int (*do_rdmsr)(unsigned int msr, uint64_t *msr_content);
-    int (*do_interrupt)(struct cpu_user_regs *regs);
+    int (*do_interrupt)(void);
     void (*arch_vpmu_destroy)(struct vcpu *v);
     int (*arch_vpmu_save)(struct vcpu *v, bool to_guest);
     int (*arch_vpmu_load)(struct vcpu *v, bool from_guest);
@@ -99,7 +99,7 @@ static inline bool vpmu_are_all_set(const struct vpmu_struct *vpmu,
 
 void vpmu_lvtpc_update(uint32_t val);
 int vpmu_do_msr(unsigned int msr, uint64_t *msr_content, bool is_write);
-void vpmu_do_interrupt(struct cpu_user_regs *regs);
+void vpmu_do_interrupt(void);
 void vpmu_initialise(struct vcpu *v);
 void vpmu_destroy(struct vcpu *v);
 void vpmu_save(struct vcpu *v);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 16 01:35:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 16 Jan 2024 01:35:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667620.1039077 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYM4-0004WW-Va; Tue, 16 Jan 2024 01:35:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667620.1039077; Tue, 16 Jan 2024 01:35:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPYM4-0004WN-Sq; Tue, 16 Jan 2024 01:35:04 +0000
Received: by outflank-mailman (input) for mailman id 667620;
 Tue, 16 Jan 2024 01:35:03 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYM3-0004WA-IU
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:35:03 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYM3-0003Vm-Hl
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:35:03 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPYM3-0000HO-Gm
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 01:35:03 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=Pj0cRcVchi9R7Djwlj2W7iHy3rB3AQvdqabGXfOf30Q=; b=af6OY4vQ0yYpcvlFjw4K+KgEZb
	lEOpNcHpMYv5pBy2Ce04hvaAckMaHwEzMPJRooKFtocp0I8YIJzMomc1oog7bC7JKV+kabIBeZdjf
	9w/MsP8tRalcjvEH0e/bUogFEE47aWi0JRzrgn5jcP2fAIDvTePEGpERzX0iQxLaDlKQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] CirrusCI: drop FreeBSD 12
Message-Id: <E1rPYM3-0000HO-Gm@xenbits.xenproject.org>
Date: Tue, 16 Jan 2024 01:35:03 +0000

commit c2ce3466472e9c9eda79f5dc98eb701bc6fdba20
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Mon Jan 15 12:20:11 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 15 12:20:11 2024 +0100

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

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


From xen-changelog-bounces@lists.xenproject.org Tue Jan 16 14:55:09 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 16 Jan 2024 14:55:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667825.1039478 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPkqF-0006AA-Ko; Tue, 16 Jan 2024 14:55:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667825.1039478; Tue, 16 Jan 2024 14: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 1rPkqF-0006A2-I0; Tue, 16 Jan 2024 14:55:03 +0000
Received: by outflank-mailman (input) for mailman id 667825;
 Tue, 16 Jan 2024 14: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 1rPkqE-00069w-QZ
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 14: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 1rPkqE-0003JX-E5
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 14:55:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPkqE-0001Dx-Cu
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 14: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=SqVyKGopvCpy+NcyMJO6Se8GqQ0+cEeCQJc3zyFsThg=; b=We85BPG08AwHGRSjTISb7ITUt+
	iz+ZY+KJuG+Ui45LtBlMcVaNhN+CdhlMEtIOeq113Tnw1TauThpTvjnPdba2Q11nNKm9fgge68g0O
	QZpE1K2w8/gh5VqGX0BD/LjULenGfLrTJ32RYfC9Rc4j0cwnMD8AaSHnPo7kjKVdEx8o=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm32: head: Move earlyprintk 'hex' to .rodata.idmap
Message-Id: <E1rPkqE-0001Dx-Cu@xenbits.xenproject.org>
Date: Tue, 16 Jan 2024 14:55:02 +0000

commit d5a2ff06b1f7868442f4a30ae44610fa19e6974c
Author:     Michal Orzel <michal.orzel@amd.com>
AuthorDate: Mon Jan 15 13:48:58 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon Jan 15 19:30:58 2024 +0000

    xen/arm32: head: Move earlyprintk 'hex' to .rodata.idmap
    
    Thanks to 1ec3fe1f664f ("xen/arm32: head: Improve logging in head.S"),
    we can now use PRINT_ID() macro to print messages when running on
    identity mapping. For that, all the strings need to be part of the first
    page that is mapped. This is not the case for a 'hex' string (used by
    asm_putn when printing register values), which currently resides in
    .rodata.str. Move it to .rodata.idmap to allow making use of print_reg
    macro from anywhere (mostly to aid debugging).
    
    Signed-off-by: Michal Orzel <michal.orzel@amd.com>
---
 xen/arch/arm/arm32/head.S | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/arm32/head.S b/xen/arch/arm/arm32/head.S
index 99d7d4aa63..b488a21a71 100644
--- a/xen/arch/arm/arm32/head.S
+++ b/xen/arch/arm/arm32/head.S
@@ -320,7 +320,7 @@ ENTRY(asm_putn)
         mov   pc, lr
 ENDPROC(asm_putn)
 
-RODATA_STR(hex, "0123456789abcdef")
+RODATA_SECT(.rodata.idmap, hex, "0123456789abcdef")
 
 #endif /* CONFIG_EARLY_PRINTK */
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 16 14:55:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 16 Jan 2024 14:55:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.667826.1039482 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rPkqP-0006Bx-MI; Tue, 16 Jan 2024 14:55:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 667826.1039482; Tue, 16 Jan 2024 14: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 1rPkqP-0006Bp-JY; Tue, 16 Jan 2024 14:55:13 +0000
Received: by outflank-mailman (input) for mailman id 667826;
 Tue, 16 Jan 2024 14:55:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPkqO-0006Bj-IC
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 14:55:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPkqO-0003Jf-HT
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 14:55:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rPkqO-0001F5-GJ
 for xen-changelog@lists.xenproject.org; Tue, 16 Jan 2024 14:55:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=JCUicX/mI4kJv9qx5surGu2zBd67770SE5RonFMxxRU=; b=SGq0HgkBwpO5saxxVs/c5I2pID
	061DTiLmGmgW7n7R9bRhzSRhhV+qNITniF2lD4t20mWH5zUWV5UE9+zAWRgbnMpPyap6jGQ6R9Xqi
	0aFYhw/eDVo2V0MfqFpW28/nsxbKpsG3VnlnPkTEK8KSnU4uSQ6oX8C5PmSxf0Z/5WFI=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm64: head: Allow to use early printk while on 1:1 mapping
Message-Id: <E1rPkqO-0001F5-GJ@xenbits.xenproject.org>
Date: Tue, 16 Jan 2024 14:55:12 +0000

commit f3f6c500e2dbd23af77c207e2cf4b496fffa1b0d
Author:     Michal Orzel <michal.orzel@amd.com>
AuthorDate: Mon Jan 15 13:48:59 2024 +0100
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Mon Jan 15 19:30:58 2024 +0000

    xen/arm64: head: Allow to use early printk while on 1:1 mapping
    
    Take an example from commit 1ec3fe1f664f ("xen/arm32: head: Improve
    logging in head.S") to add support for printing early boot messages
    while running on identity mapping:
     - define PRINT_SECT() macro to be able to specify a section for storing
       a string. PRINT() will use .rodata.str and PRINT_ID() - .rodata.idmap.
       This is necessary, because when running on identity mapping, the
       strings need to be part of the first page that is mapped,
     - move loading a runtime virtual UART address right after enabling MMU
       (the corresponding steps repeated in {primary,secondary}_switched are
       now consolidated in a single place),
     - move early printk 'hex' string into .rodata.idmap and replace 'adr'
       instruction in asm_putn with 'adr_l' to extend the addressable range,
     - remove RODATA_STR() macro given no use.
    
    Signed-off-by: Michal Orzel <michal.orzel@amd.com>
---
 xen/arch/arm/arm64/head.S               | 13 ++-----------
 xen/arch/arm/arm64/mmu/head.S           |  8 ++++++++
 xen/arch/arm/include/asm/arm64/macros.h | 25 ++++++++++++++++++-------
 xen/arch/arm/include/asm/asm_defns.h    |  2 --
 4 files changed, 28 insertions(+), 20 deletions(-)

diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index 9d7d83a5ed..cfc04c7554 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -256,10 +256,6 @@ real_start_efi:
         b     enable_boot_cpu_mm
 
 primary_switched:
-#ifdef CONFIG_EARLY_PRINTK
-        /* Use a virtual address to access the UART. */
-        ldr   x23, =EARLY_UART_VIRTUAL_ADDRESS
-#endif
         bl    zero_bss
         PRINT("- Ready -\r\n")
         /* Setup the arguments for start_xen and jump to C world */
@@ -304,10 +300,6 @@ GLOBAL(init_secondary)
         b     enable_secondary_cpu_mm
 
 secondary_switched:
-#ifdef CONFIG_EARLY_PRINTK
-        /* Use a virtual address to access the UART. */
-        ldr   x23, =EARLY_UART_VIRTUAL_ADDRESS
-#endif
         PRINT("- Ready -\r\n")
         /* Jump to C world */
         ldr   x2, =start_secondary
@@ -480,7 +472,7 @@ ENDPROC(asm_puts)
  * Clobbers x0-x3
  */
 ENTRY(asm_putn)
-        adr   x1, hex
+        adr_l x1, hex
         mov   x3, #16
 1:
         early_uart_ready x23, 2
@@ -494,8 +486,7 @@ ENTRY(asm_putn)
         ret
 ENDPROC(asm_putn)
 
-hex:    .ascii "0123456789abcdef"
-        .align 2
+RODATA_SECT(.rodata.idmap, hex, "0123456789abcdef")
 
 #endif /* CONFIG_EARLY_PRINTK */
 
diff --git a/xen/arch/arm/arm64/mmu/head.S b/xen/arch/arm/arm64/mmu/head.S
index 10774f30e4..92b62ae94c 100644
--- a/xen/arch/arm/arm64/mmu/head.S
+++ b/xen/arch/arm/arm64/mmu/head.S
@@ -295,6 +295,14 @@ enable_mmu:
         dsb   sy                     /* Flush PTE writes and finish reads */
         msr   SCTLR_EL2, x0          /* now paging is enabled */
         isb                          /* Now, flush the icache */
+
+#ifdef CONFIG_EARLY_PRINTK
+        /* Use a virtual address to access the UART. */
+        ldr   x23, =EARLY_UART_VIRTUAL_ADDRESS
+#endif
+
+        PRINT_ID("- Paging turned on -\r\n")
+
         ret
 ENDPROC(enable_mmu)
 
diff --git a/xen/arch/arm/include/asm/arm64/macros.h b/xen/arch/arm/include/asm/arm64/macros.h
index d108dc3a3a..10e652041f 100644
--- a/xen/arch/arm/include/asm/arm64/macros.h
+++ b/xen/arch/arm/include/asm/arm64/macros.h
@@ -34,16 +34,26 @@
 
 #ifdef CONFIG_EARLY_PRINTK
 /*
- * Macro to print a string to the UART, if there is one.
+ * Macros to print a string to the UART, if there is one.
+ *
+ * There are multiple flavors:
+ *  - PRINT_SECT(section, string): The @string will be located in @section
+ *  - PRINT(): The string will be located in .rodata.str.
+ *  - PRINT_ID(): When Xen is running on the Identity Mapping, it is
+ *    only possible to have a limited amount of Xen. This will create
+ *    the string in .rodata.idmap which will always be mapped.
  *
  * Clobbers x0 - x3
  */
-#define PRINT(_s)          \
-        mov   x3, lr ;     \
-        adr_l x0, 98f ;    \
-        bl    asm_puts ;   \
-        mov   lr, x3 ;     \
-        RODATA_STR(98, _s)
+#define PRINT_SECT(section, string)         \
+        mov   x3, lr                       ;\
+        adr_l x0, 98f                      ;\
+        bl    asm_puts                     ;\
+        mov   lr, x3                       ;\
+        RODATA_SECT(section, 98, string)
+
+#define PRINT(string) PRINT_SECT(.rodata.str, string)
+#define PRINT_ID(string) PRINT_SECT(.rodata.idmap, string)
 
 /*
  * Macro to print the value of register \xb
@@ -59,6 +69,7 @@
 
 #else /* CONFIG_EARLY_PRINTK */
 #define PRINT(s)
+#define PRINT_ID(s)
 
 .macro print_reg xb
 .endm
diff --git a/xen/arch/arm/include/asm/asm_defns.h b/xen/arch/arm/include/asm/asm_defns.h
index ec803c0a37..eecafd3b39 100644
--- a/xen/arch/arm/include/asm/asm_defns.h
+++ b/xen/arch/arm/include/asm/asm_defns.h
@@ -27,8 +27,6 @@
 label:  .asciz msg;                             \
 .popsection
 
-#define RODATA_STR(label, msg) RODATA_SECT(.rodata.str, label, msg)
-
 #define ASM_INT(label, val)                 \
     .p2align 2;                             \
 label: .long (val);                         \
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Jan 18 14:22:07 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 18 Jan 2024 14:22:07 +0000
Received: from list by lists.xenproject.org with outflank-mailman.668787.1041226 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rQTHP-0001V7-3a; Thu, 18 Jan 2024 14:22:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 668787.1041226; Thu, 18 Jan 2024 14: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 1rQTHP-0001Uz-15; Thu, 18 Jan 2024 14:22:03 +0000
Received: by outflank-mailman (input) for mailman id 668787;
 Thu, 18 Jan 2024 14:22:01 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQTHN-0001Ut-LR
 for xen-changelog@lists.xenproject.org; Thu, 18 Jan 2024 14:22:01 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQTHN-0006bj-Gp
 for xen-changelog@lists.xenproject.org; Thu, 18 Jan 2024 14:22:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQTHN-0002cu-E9
 for xen-changelog@lists.xenproject.org; Thu, 18 Jan 2024 14:22:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=cDXPiQpR+MJbp2FxLotEpeBfd2RN5BUWd+M8daXYprQ=; b=POEkzSg+ouauXs4QG1Bd7YG/BI
	pxip8PL4IiBBtQbvZgopKGKBqEFvolWDHLvp8CoCSfDgS5X1GOwuqgT6/62GsouvAIhVIz3zPzfP5
	bvBPttsLUCAdihgE/Sg+XeV1+sFHieMN5/mWgMlIlW5bADoPSeN/+33p1WBQkW9QKC14=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/intel: ensure Global Performance Counter Control is setup correctly
Message-Id: <E1rQTHN-0002cu-E9@xenbits.xenproject.org>
Date: Thu, 18 Jan 2024 14:22:01 +0000

commit 6bdb965178bbb3fc50cd4418d4770a7789956e2c
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Wed Jan 17 10:40:52 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Jan 17 10:40:52 2024 +0100

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

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


From xen-changelog-bounces@lists.xenproject.org Thu Jan 18 14:22:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 18 Jan 2024 14:22:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.668790.1041230 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rQTHZ-0001X4-5M; Thu, 18 Jan 2024 14:22:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 668790.1041230; Thu, 18 Jan 2024 14: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 1rQTHZ-0001Ww-2U; Thu, 18 Jan 2024 14:22:13 +0000
Received: by outflank-mailman (input) for mailman id 668790;
 Thu, 18 Jan 2024 14:22:11 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQTHX-0001Wn-MZ
 for xen-changelog@lists.xenproject.org; Thu, 18 Jan 2024 14:22:11 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQTHX-0006br-Lj
 for xen-changelog@lists.xenproject.org; Thu, 18 Jan 2024 14:22:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQTHX-0002df-J2
 for xen-changelog@lists.xenproject.org; Thu, 18 Jan 2024 14:22:11 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=mDGiTdzmEu8YyzemhJJ8LDE+/wCORwKzy4gyKTEJGaA=; b=VDLlbKXel9zBvsLp3Gzg2+5+UD
	PQjmyCkvHYsiT7Q2il4lI9lkYYR2SYb8U4UfFGFxxza86KQQrSTJKiZ4vOjh3yPjJsqmZy97goepa
	+OkeZ84oilZdn0lcDD6NT9L4cjHQg/e64xTrncu/wXAZtWZfv/r23dIyyFrXc8zHh+fM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/APIC: finish genapic conversion to altcall
Message-Id: <E1rQTHX-0002df-J2@xenbits.xenproject.org>
Date: Thu, 18 Jan 2024 14:22:11 +0000

commit b1cc53753cba4c3253f2e1093a3a6a9a828314bf
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Wed Jan 17 10:41:52 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Jan 17 10:41:52 2024 +0100

    x86/APIC: finish genapic conversion to altcall
    
    While .probe() doesn't need fiddling with for being run only very early,
    init_apic_ldr() wants converting too despite not being on a frequently
    executed path: This way all pre-filled struct genapic instances can
    become __initconst_cf_clobber, thus allowing to eliminate 15 more ENDBR
    during the 2nd phase of alternatives patching.
    
    While fiddling with section annotations here, also move "genapic" itself
    to .data.ro_after_init.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/genapic/bigsmp.c                     | 2 +-
 xen/arch/x86/genapic/default.c                    | 2 +-
 xen/arch/x86/genapic/probe.c                      | 2 +-
 xen/arch/x86/genapic/x2apic.c                     | 6 +++---
 xen/arch/x86/include/asm/mach-generic/mach_apic.h | 2 +-
 5 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/xen/arch/x86/genapic/bigsmp.c b/xen/arch/x86/genapic/bigsmp.c
index 9ed46cea91..e97e4453a0 100644
--- a/xen/arch/x86/genapic/bigsmp.c
+++ b/xen/arch/x86/genapic/bigsmp.c
@@ -44,7 +44,7 @@ static int __init cf_check probe_bigsmp(void)
 	return def_to_bigsmp;
 } 
 
-const struct genapic __initconstrel apic_bigsmp = {
+const struct genapic __initconst_cf_clobber apic_bigsmp = {
 	APIC_INIT("bigsmp", probe_bigsmp),
 	GENAPIC_PHYS
 };
diff --git a/xen/arch/x86/genapic/default.c b/xen/arch/x86/genapic/default.c
index 2c63c1f917..a968836a18 100644
--- a/xen/arch/x86/genapic/default.c
+++ b/xen/arch/x86/genapic/default.c
@@ -14,7 +14,7 @@
 #include <asm/io_apic.h>
 
 /* should be called last. */
-const struct genapic __initconstrel apic_default = {
+const struct genapic __initconst_cf_clobber apic_default = {
 	APIC_INIT("default", NULL),
 	GENAPIC_FLAT
 };
diff --git a/xen/arch/x86/genapic/probe.c b/xen/arch/x86/genapic/probe.c
index ad57912f50..10ceeae4d2 100644
--- a/xen/arch/x86/genapic/probe.c
+++ b/xen/arch/x86/genapic/probe.c
@@ -16,7 +16,7 @@
 #include <asm/mach-generic/mach_apic.h>
 #include <asm/setup.h>
 
-struct genapic __read_mostly genapic;
+struct genapic __ro_after_init genapic;
 
 static const struct genapic *const __initconstrel apic_probe[] = {
 	&apic_bigsmp, 
diff --git a/xen/arch/x86/genapic/x2apic.c b/xen/arch/x86/genapic/x2apic.c
index b88c7a96fe..371dd100c7 100644
--- a/xen/arch/x86/genapic/x2apic.c
+++ b/xen/arch/x86/genapic/x2apic.c
@@ -158,7 +158,7 @@ static void cf_check send_IPI_mask_x2apic_cluster(
     local_irq_restore(flags);
 }
 
-static const struct genapic __initconstrel apic_x2apic_phys = {
+static const struct genapic __initconst_cf_clobber apic_x2apic_phys = {
     APIC_INIT("x2apic_phys", NULL),
     .int_delivery_mode = dest_Fixed,
     .int_dest_mode = 0 /* physical delivery */,
@@ -169,7 +169,7 @@ static const struct genapic __initconstrel apic_x2apic_phys = {
     .send_IPI_self = send_IPI_self_x2apic
 };
 
-static const struct genapic __initconstrel apic_x2apic_cluster = {
+static const struct genapic __initconst_cf_clobber apic_x2apic_cluster = {
     APIC_INIT("x2apic_cluster", NULL),
     .int_delivery_mode = dest_LowestPrio,
     .int_dest_mode = 1 /* logical delivery */,
@@ -187,7 +187,7 @@ static const struct genapic __initconstrel apic_x2apic_cluster = {
  * IPIs to be more efficiently delivered by not having to perform an ICR write
  * for each target CPU.
  */
-static const struct genapic __initconstrel apic_x2apic_mixed = {
+static const struct genapic __initconst_cf_clobber apic_x2apic_mixed = {
     APIC_INIT("x2apic_mixed", NULL),
 
     /*
diff --git a/xen/arch/x86/include/asm/mach-generic/mach_apic.h b/xen/arch/x86/include/asm/mach-generic/mach_apic.h
index cf8b31b6e0..c0d8b232c9 100644
--- a/xen/arch/x86/include/asm/mach-generic/mach_apic.h
+++ b/xen/arch/x86/include/asm/mach-generic/mach_apic.h
@@ -10,7 +10,7 @@
 #define INT_DELIVERY_MODE (genapic.int_delivery_mode)
 #define INT_DEST_MODE (genapic.int_dest_mode)
 #define TARGET_CPUS ((const typeof(cpu_online_map) *)&cpu_online_map)
-#define init_apic_ldr (genapic.init_apic_ldr)
+#define init_apic_ldr() alternative_vcall(genapic.init_apic_ldr)
 #define cpu_mask_to_apicid(mask) ({ \
 	/* \
 	 * There are a number of places where the address of a local variable \
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Jan 18 14:22:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 18 Jan 2024 14:22:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.668791.1041235 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rQTHj-0001ZY-7D; Thu, 18 Jan 2024 14:22:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 668791.1041235; Thu, 18 Jan 2024 14:22:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rQTHj-0001ZQ-41; Thu, 18 Jan 2024 14:22:23 +0000
Received: by outflank-mailman (input) for mailman id 668791;
 Thu, 18 Jan 2024 14:22:21 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQTHh-0001ZE-Ql
 for xen-changelog@lists.xenproject.org; Thu, 18 Jan 2024 14:22:21 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQTHh-0006bz-Pr
 for xen-changelog@lists.xenproject.org; Thu, 18 Jan 2024 14:22:21 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQTHh-0002e7-Nt
 for xen-changelog@lists.xenproject.org; Thu, 18 Jan 2024 14:22:21 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=oHKtxjjcubik+8A5dy5hJDPXQgxiQ2MWg/9n5pf/1tc=; b=p7YMh2fUD7mWwoGP3YrMyPg+n+
	sc/Xl07Y3oYNUmB1wmSOo+RyTUVWOl429ZdWQo7xo48X1/USPBryE+bVLI2064vqf3/hCTxsH0Cdo
	hRqkhtX/YPwmq3x2mmUj9naLVAwMRrEF+kDU+SanUUO6SGrfpWjIZ/WQuu6aK5ubm84U=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] cpufreq: finish genapic conversion to altcall
Message-Id: <E1rQTHh-0002e7-Nt@xenbits.xenproject.org>
Date: Thu, 18 Jan 2024 14:22:21 +0000

commit 467ae515caee491e9b6ae1da8b9b98d094955822
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Wed Jan 17 10:42:27 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Jan 17 10:42:27 2024 +0100

    cpufreq: finish genapic conversion to altcall
    
    Even functions used on infrequently executed paths want converting: This
    way all pre-filled struct cpufreq_driver instances can become
    __initconst_cf_clobber, thus allowing to eliminate another 15 ENDBR
    during the 2nd phase of alternatives patching.
    
    For acpi-cpufreq's optionally populated .get hook make sure alternatives
    patching can actually see the pointer. See also the code comment.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/acpi/cpufreq/cpufreq.c  | 17 ++++++++++++++++-
 xen/arch/x86/acpi/cpufreq/hwp.c      |  4 ++--
 xen/arch/x86/acpi/cpufreq/powernow.c |  3 ++-
 xen/drivers/acpi/pmstat.c            |  3 ++-
 xen/drivers/cpufreq/cpufreq.c        |  6 +++---
 xen/drivers/cpufreq/utility.c        |  6 +++---
 6 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/xen/arch/x86/acpi/cpufreq/cpufreq.c b/xen/arch/x86/acpi/cpufreq/cpufreq.c
index 61b62c370a..2b6ef99678 100644
--- a/xen/arch/x86/acpi/cpufreq/cpufreq.c
+++ b/xen/arch/x86/acpi/cpufreq/cpufreq.c
@@ -625,12 +625,14 @@ static int cf_check acpi_cpufreq_cpu_exit(struct cpufreq_policy *policy)
     return 0;
 }
 
-static const struct cpufreq_driver __initconstrel acpi_cpufreq_driver = {
+static const struct cpufreq_driver __initconst_cf_clobber
+acpi_cpufreq_driver = {
     .name   = "acpi-cpufreq",
     .verify = acpi_cpufreq_verify,
     .target = acpi_cpufreq_target,
     .init   = acpi_cpufreq_cpu_init,
     .exit   = acpi_cpufreq_cpu_exit,
+    .get    = get_cur_freq_on_cpu,
 };
 
 static int __init cf_check cpufreq_driver_init(void)
@@ -675,6 +677,19 @@ static int __init cf_check cpufreq_driver_init(void)
 }
 presmp_initcall(cpufreq_driver_init);
 
+static int __init cf_check cpufreq_driver_late_init(void)
+{
+    /*
+     * While acpi_cpufreq_driver wants to unconditionally have all hooks
+     * populated for __initconst_cf_clobber to have as much of an effect as
+     * possible, zap the .get hook here (but not in cpufreq_driver_init()),
+     * until acpi_cpufreq_cpu_init() knows whether it's wanted / needed.
+     */
+    cpufreq_driver.get = NULL;
+    return 0;
+}
+__initcall(cpufreq_driver_late_init);
+
 int cpufreq_cpu_init(unsigned int cpuid)
 {
     int ret;
diff --git a/xen/arch/x86/acpi/cpufreq/hwp.c b/xen/arch/x86/acpi/cpufreq/hwp.c
index 620149243d..e61212803e 100644
--- a/xen/arch/x86/acpi/cpufreq/hwp.c
+++ b/xen/arch/x86/acpi/cpufreq/hwp.c
@@ -513,8 +513,8 @@ static int cf_check hwp_cpufreq_update(int cpuid, struct cpufreq_policy *policy)
     return per_cpu(hwp_drv_data, cpuid)->ret;
 }
 
-static const struct cpufreq_driver __initconstrel hwp_cpufreq_driver =
-{
+static const struct cpufreq_driver __initconst_cf_clobber
+hwp_cpufreq_driver = {
     .name   = XEN_HWP_DRIVER_NAME,
     .verify = hwp_cpufreq_verify,
     .target = hwp_cpufreq_target,
diff --git a/xen/arch/x86/acpi/cpufreq/powernow.c b/xen/arch/x86/acpi/cpufreq/powernow.c
index 8e0784b69c..8a27ee82a5 100644
--- a/xen/arch/x86/acpi/cpufreq/powernow.c
+++ b/xen/arch/x86/acpi/cpufreq/powernow.c
@@ -317,7 +317,8 @@ static int cf_check powernow_cpufreq_cpu_exit(struct cpufreq_policy *policy)
     return 0;
 }
 
-static const struct cpufreq_driver __initconstrel powernow_cpufreq_driver = {
+static const struct cpufreq_driver __initconst_cf_clobber
+powernow_cpufreq_driver = {
     .name   = "powernow",
     .verify = powernow_cpufreq_verify,
     .target = powernow_cpufreq_target,
diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/acpi/pmstat.c
index 85097d463c..803971bdb0 100644
--- a/xen/drivers/acpi/pmstat.c
+++ b/xen/drivers/acpi/pmstat.c
@@ -240,7 +240,8 @@ static int get_cpufreq_para(struct xen_sysctl_pm_op *op)
         return ret;
 
     op->u.get_para.cpuinfo_cur_freq =
-        cpufreq_driver.get ? cpufreq_driver.get(op->cpuid) : policy->cur;
+        cpufreq_driver.get ? alternative_call(cpufreq_driver.get, op->cpuid)
+                           : policy->cur;
     op->u.get_para.cpuinfo_max_freq = policy->cpuinfo.max_freq;
     op->u.get_para.cpuinfo_min_freq = policy->cpuinfo.min_freq;
     op->u.get_para.turbo_enabled = cpufreq_get_turbo_status(op->cpuid);
diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c
index 430351b775..36c800f4fa 100644
--- a/xen/drivers/cpufreq/cpufreq.c
+++ b/xen/drivers/cpufreq/cpufreq.c
@@ -278,7 +278,7 @@ int cpufreq_add_cpu(unsigned int cpu)
         policy->cpu = cpu;
         per_cpu(cpufreq_cpu_policy, cpu) = policy;
 
-        ret = cpufreq_driver.init(policy);
+        ret = alternative_call(cpufreq_driver.init, policy);
         if (ret) {
             free_cpumask_var(policy->cpus);
             xfree(policy);
@@ -337,7 +337,7 @@ err1:
     cpumask_clear_cpu(cpu, cpufreq_dom->map);
 
     if (cpumask_empty(policy->cpus)) {
-        cpufreq_driver.exit(policy);
+        alternative_call(cpufreq_driver.exit, policy);
         free_cpumask_var(policy->cpus);
         xfree(policy);
     }
@@ -401,7 +401,7 @@ int cpufreq_del_cpu(unsigned int cpu)
     cpumask_clear_cpu(cpu, cpufreq_dom->map);
 
     if (cpumask_empty(policy->cpus)) {
-        cpufreq_driver.exit(policy);
+        alternative_call(cpufreq_driver.exit, policy);
         free_cpumask_var(policy->cpus);
         xfree(policy);
     }
diff --git a/xen/drivers/cpufreq/utility.c b/xen/drivers/cpufreq/utility.c
index 6831f62851..dbf8985969 100644
--- a/xen/drivers/cpufreq/utility.c
+++ b/xen/drivers/cpufreq/utility.c
@@ -413,7 +413,7 @@ int cpufreq_update_turbo(int cpuid, int new_state)
     policy->turbo = new_state;
     if (cpufreq_driver.update)
     {
-        ret = cpufreq_driver.update(cpuid, policy);
+        ret = alternative_call(cpufreq_driver.update, cpuid, policy);
         if (ret)
             policy->turbo = curr_state;
     }
@@ -449,7 +449,7 @@ int __cpufreq_set_policy(struct cpufreq_policy *data,
         return -EINVAL;
 
     /* verify the cpu speed can be set within this limit */
-    ret = cpufreq_driver.verify(policy);
+    ret = alternative_call(cpufreq_driver.verify, policy);
     if (ret)
         return ret;
 
@@ -457,7 +457,7 @@ int __cpufreq_set_policy(struct cpufreq_policy *data,
     data->max = policy->max;
     data->limits = policy->limits;
     if (cpufreq_driver.setpolicy)
-        return cpufreq_driver.setpolicy(data);
+        return alternative_call(cpufreq_driver.setpolicy, data);
 
     if (policy->governor != data->governor) {
         /* save old, working values */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Jan 18 14:22:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 18 Jan 2024 14:22:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.668792.1041237 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rQTHt-0001bv-7p; Thu, 18 Jan 2024 14:22:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 668792.1041237; Thu, 18 Jan 2024 14:22:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rQTHt-0001bo-5Q; Thu, 18 Jan 2024 14:22:33 +0000
Received: by outflank-mailman (input) for mailman id 668792;
 Thu, 18 Jan 2024 14:22:31 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQTHr-0001be-Tj
 for xen-changelog@lists.xenproject.org; Thu, 18 Jan 2024 14:22:31 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQTHr-0006c8-T1
 for xen-changelog@lists.xenproject.org; Thu, 18 Jan 2024 14:22:31 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQTHr-0002eW-S1
 for xen-changelog@lists.xenproject.org; Thu, 18 Jan 2024 14:22:31 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=oHz+8QD/81wUEzAe8wDEPYlbB6ScUTSu2/fXDfP1ess=; b=IAumcJkLRF9XBxJenm8Ywh2EeB
	5k/pZuGm5xkOxoO/mhucdcs0UXunGHkglNKsMQMvmTnBwUsoJiQXS8qP5oDZkIWPrX2LBbzhnEWEZ
	QMUCAt6pUrRPR67U/5iDYUODC1DWpzHn1s+HPDBGGYMiCr8sn+ot61owsL2YrU1hyJ2Q=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/HPET: avoid an indirect call
Message-Id: <E1rQTHr-0002eW-S1@xenbits.xenproject.org>
Date: Thu, 18 Jan 2024 14:22:31 +0000

commit 730d2637a8e5b98dc8e4e366179b4cedc496b3ad
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Wed Jan 17 10:43:02 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Wed Jan 17 10:43:02 2024 +0100

    x86/HPET: avoid an indirect call
    
    When this code was written, indirect branches still weren't considered
    much of a problem (besides being a little slower). Instead of a function
    pointer, pass a boolean to _disable_pit_irq(), thus allowing to
    eliminate two ENDBR (one of them in .text).
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/hpet.c             |  4 ++--
 xen/arch/x86/include/asm/hpet.h |  4 ++--
 xen/arch/x86/time.c             | 12 ++++++------
 3 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/hpet.c b/xen/arch/x86/hpet.c
index 7be26c6a9b..d982b0f6b2 100644
--- a/xen/arch/x86/hpet.c
+++ b/xen/arch/x86/hpet.c
@@ -563,7 +563,7 @@ static void cf_check handle_rtc_once(uint8_t index, uint8_t value)
     }
 }
 
-void __init cf_check hpet_broadcast_init(void)
+void __init hpet_broadcast_init(void)
 {
     u64 hpet_rate = hpet_setup();
     u32 hpet_id, cfg;
@@ -634,7 +634,7 @@ void __init cf_check hpet_broadcast_init(void)
         hpet_events->flags = HPET_EVT_LEGACY;
 }
 
-void cf_check hpet_broadcast_resume(void)
+void hpet_broadcast_resume(void)
 {
     u32 cfg;
     unsigned int i, n;
diff --git a/xen/arch/x86/include/asm/hpet.h b/xen/arch/x86/include/asm/hpet.h
index c095b833d4..c402c63168 100644
--- a/xen/arch/x86/include/asm/hpet.h
+++ b/xen/arch/x86/include/asm/hpet.h
@@ -89,8 +89,8 @@ void hpet_disable_legacy_replacement_mode(void);
  * Temporarily use an HPET event counter for timer interrupt handling,
  * rather than using the LAPIC timer. Used for Cx state entry.
  */
-void cf_check hpet_broadcast_init(void);
-void cf_check hpet_broadcast_resume(void);
+void hpet_broadcast_init(void);
+void hpet_broadcast_resume(void);
 void cf_check hpet_broadcast_enter(void);
 void cf_check hpet_broadcast_exit(void);
 int hpet_broadcast_is_available(void);
diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index 6d33edd0ad..34ddb9633f 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -2427,7 +2427,7 @@ void __init early_time_init(void)
 }
 
 /* keep pit enabled for pit_broadcast working while cpuidle enabled */
-static int _disable_pit_irq(void(*hpet_broadcast_setup)(void))
+static int _disable_pit_irq(bool init)
 {
     int ret = 1;
 
@@ -2442,13 +2442,13 @@ static int _disable_pit_irq(void(*hpet_broadcast_setup)(void))
      */
     if ( cpuidle_using_deep_cstate() && !boot_cpu_has(X86_FEATURE_ARAT) )
     {
-        hpet_broadcast_setup();
+        init ? hpet_broadcast_init() : hpet_broadcast_resume();
         if ( !hpet_broadcast_is_available() )
         {
             if ( xen_cpuidle > 0 )
             {
-                printk("%ps() failed, turning to PIT broadcast\n",
-                       hpet_broadcast_setup);
+                printk("hpet_broadcast_%s() failed, turning to PIT broadcast\n",
+                       init ? "init" : "resume");
                 return -1;
             }
             ret = 0;
@@ -2465,7 +2465,7 @@ static int _disable_pit_irq(void(*hpet_broadcast_setup)(void))
 
 static int __init cf_check disable_pit_irq(void)
 {
-    if ( !_disable_pit_irq(hpet_broadcast_init) )
+    if ( !_disable_pit_irq(true) )
     {
         xen_cpuidle = 0;
         printk("CPUIDLE: disabled due to no HPET. "
@@ -2526,7 +2526,7 @@ int time_resume(void)
 
     resume_platform_timer();
 
-    if ( !_disable_pit_irq(hpet_broadcast_resume) )
+    if ( !_disable_pit_irq(false) )
         BUG();
 
     init_percpu_time();
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Jan 19 08:44:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 19 Jan 2024 08:44:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.668951.1041452 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rQkTr-0001P0-QV; Fri, 19 Jan 2024 08:44:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 668951.1041452; Fri, 19 Jan 2024 08: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 1rQkTr-0001Oq-NK; Fri, 19 Jan 2024 08:44:03 +0000
Received: by outflank-mailman (input) for mailman id 668951;
 Fri, 19 Jan 2024 08: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 1rQkTq-0001OV-GU
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 08: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 1rQkTq-00068g-7g
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 08:44:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQkTq-0000GQ-6Y
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 08: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=GChNyTNLs/kUe72NhNvmK10Xs5z+ZvJ9ihJYSrJT2cg=; b=j054mcgYnV99Ghr/jgu0yu+tuA
	WZPF3/IQFueMf4OSh1hDaxdTpH5eMr8XBt0vIJwFBmBe3GvFj060ZB0Y7EJPm5f8UkYgqOYFvYcBc
	c58jWs0dZUImZnR5craquuLyhEUfqw/eEfNwK9yPetBfZPVpj88Wtr0GL+ngCrNFIGc4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [mini-os master] x86/mm: add EXPORT_SYMBOL() for `pt_base`
Message-Id: <E1rQkTq-0000GQ-6Y@xenbits.xenproject.org>
Date: Fri, 19 Jan 2024 08:44:02 +0000

commit 51ecb456b133d82ac44b3774a47202cea0d1842e
Author:     Anthony PERARD <anthony.perard@citrix.com>
AuthorDate: Fri Jan 19 09:42:09 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Fri Jan 19 09:42:09 2024 +0100

    x86/mm: add EXPORT_SYMBOL() for `pt_base`
    
    Without this, building "ioemu-stubdom" fails on Debian Buster or
    Bookworm, with:
    
    /home/osstest/build.184372.build-amd64/xen/stubdom/mini-os-x86_64-ioemu/mini-os.o: in function `xenfb_pv_display_init':
    ungetc.c:(.text+0x43533): undefined reference to `pt_base'
    
    Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
    Reviewed-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
---
 arch/x86/mm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/x86/mm.c b/arch/x86/mm.c
index 767a5f0..be1cf0c 100644
--- a/arch/x86/mm.c
+++ b/arch/x86/mm.c
@@ -57,6 +57,7 @@
 unsigned long *phys_to_machine_mapping;
 unsigned long mfn_zero;
 pgentry_t *pt_base;
+EXPORT_SYMBOL(pt_base);
 static unsigned long first_free_pfn;
 static unsigned long last_free_pfn;
 static unsigned long virt_kernel_area_end = VIRT_KERNEL_AREA;
--
generated by git-patchbot for /home/xen/git/mini-os.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Jan 19 09:55:06 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 19 Jan 2024 09:55:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.668999.1041547 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rQlaZ-0000hl-48; Fri, 19 Jan 2024 09:55:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 668999.1041547; Fri, 19 Jan 2024 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 1rQlaZ-0000hb-07; Fri, 19 Jan 2024 09:55:03 +0000
Received: by outflank-mailman (input) for mailman id 668999;
 Fri, 19 Jan 2024 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 1rQlaX-0000gn-J2
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 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 1rQlaX-0007Lj-Fy
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 09:55:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQlaX-0003Da-Eo
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 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=uWIP+1UXYLGoLgKLmZIkJpuQ6FGwCl0WptR8aAg1yPI=; b=59Pxmo5CzhYHyE/jrdAi/IbcVM
	g+1OyYoZhZfmCGBhB7WSMd6quPpGLQRk5eDLQInN3atFQQ+fIor6tj4NnQRF0auzKIQ9cHXmTfXTS
	nn9djH7oBMlizN/M/+iAkKLODDMZQfIEP4TkQZT6omzbvLqFgtRYllgxACZFM+vkkoSw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/vmx: Collect all empty VMExit cases together
Message-Id: <E1rQlaX-0003Da-Eo@xenbits.xenproject.org>
Date: Fri, 19 Jan 2024 09:55:01 +0000

commit 6522ef73fd961c6c93e676c7e2a39d65e5ca7120
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Thu Jan 11 20:26:53 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Jan 18 20:59:06 2024 +0000

    x86/vmx: Collect all empty VMExit cases together
    
    ... rather than having them spread out.  Explain concisely why each is empty.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/hvm/vmx/vmx.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 8ff675883c..829c27f1fa 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -4374,9 +4374,7 @@ void asmlinkage vmx_vmexit_handler(struct cpu_user_regs *regs)
         }
         break;
     }
-    case EXIT_REASON_EXTERNAL_INTERRUPT:
-        /* Already handled above. */
-        break;
+
     case EXIT_REASON_TRIPLE_FAULT:
         hvm_triple_fault();
         break;
@@ -4539,9 +4537,6 @@ void asmlinkage vmx_vmexit_handler(struct cpu_user_regs *regs)
         hvm_inject_hw_exception(X86_EXC_UD, X86_EVENT_NO_EC);
         break;
 
-    case EXIT_REASON_TPR_BELOW_THRESHOLD:
-        break;
-
     case EXIT_REASON_APIC_ACCESS:
         if ( !vmx_handle_eoi_write() && !handle_mmio() )
             hvm_inject_hw_exception(X86_EXC_GP, 0);
@@ -4680,15 +4675,6 @@ void asmlinkage vmx_vmexit_handler(struct cpu_user_regs *regs)
         vmx_handle_descriptor_access(exit_reason);
         break;
 
-    case EXIT_REASON_BUS_LOCK:
-        /*
-         * Nothing to do: just taking a vmexit should be enough of a pause to
-         * prevent a VM from crippling the host with bus locks.  Note
-         * EXIT_REASON_BUS_LOCK will always have bit 26 set in exit_reason, and
-         * hence the perf counter is already increased.
-         */
-        break;
-
     case EXIT_REASON_NOTIFY:
         __vmread(EXIT_QUALIFICATION, &exit_qualification);
 
@@ -4705,6 +4691,11 @@ void asmlinkage vmx_vmexit_handler(struct cpu_user_regs *regs)
 
         break;
 
+    case EXIT_REASON_EXTERNAL_INTERRUPT:  /* Handled earlier */
+    case EXIT_REASON_TPR_BELOW_THRESHOLD: /* Handled later in vmx_intr_assist() */
+    case EXIT_REASON_BUS_LOCK:            /* Nothing to do (rate-limit only) */
+        break;
+
     case EXIT_REASON_VMX_PREEMPTION_TIMER_EXPIRED:
     case EXIT_REASON_INVPCID:
     /* fall through */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Jan 19 09:55:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 19 Jan 2024 09:55:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.669000.1041551 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rQlaj-0000o8-8z; Fri, 19 Jan 2024 09:55:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 669000.1041551; Fri, 19 Jan 2024 09: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 1rQlaj-0000o1-4S; Fri, 19 Jan 2024 09:55:13 +0000
Received: by outflank-mailman (input) for mailman id 669000;
 Fri, 19 Jan 2024 09: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 1rQlah-0000nO-Ke
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 09: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 1rQlah-0007ME-JX
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 09:55:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQlah-0003E5-IO
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 09: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=UO8gLTCLVJc1mxNadRhvamMvNVDcsxpAtr5eL0CrEbk=; b=rBpZt28jDn3nV/AN6Kcm4OlAMW
	6kJLO6x9qajBqH8Wb4kgpHO0zcDp+L9C6uMENOqnFubrEDep61bddURFCME+XsVHWGA9lSXzXhXL5
	JC3dUkR/s/4aU2+WEHbtwH8D2NSPF78205Lb6aVg+R8r8XNvO08KZslfpPh1dVnHhBRc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/vmx: Fix IRQ handling for EXIT_REASON_INIT
Message-Id: <E1rQlah-0003E5-IO@xenbits.xenproject.org>
Date: Fri, 19 Jan 2024 09:55:11 +0000

commit d1f8883aebe00f6a9632d77ab0cd5c6d02c9cbe4
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Wed Nov 1 13:32:55 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Jan 18 20:59:06 2024 +0000

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

diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
index 829c27f1fa..a85394232a 100644
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -4090,7 +4090,7 @@ void asmlinkage vmx_vmexit_handler(struct cpu_user_regs *regs)
 
     case EXIT_REASON_INIT:
         printk(XENLOG_ERR "Error: INIT received - ignoring\n");
-        return; /* Renter the guest without further processing */
+        break;
     }
 
     /* Now enable interrupts so it's safe to take locks. */
@@ -4692,6 +4692,7 @@ void asmlinkage vmx_vmexit_handler(struct cpu_user_regs *regs)
         break;
 
     case EXIT_REASON_EXTERNAL_INTERRUPT:  /* Handled earlier */
+    case EXIT_REASON_INIT:                /* Handled earlier */
     case EXIT_REASON_TPR_BELOW_THRESHOLD: /* Handled later in vmx_intr_assist() */
     case EXIT_REASON_BUS_LOCK:            /* Nothing to do (rate-limit only) */
         break;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Jan 19 09:55:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 19 Jan 2024 09:55:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.669003.1041553 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rQlat-0000zH-8g; Fri, 19 Jan 2024 09:55:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 669003.1041553; Fri, 19 Jan 2024 09: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 1rQlat-0000z9-65; Fri, 19 Jan 2024 09:55:23 +0000
Received: by outflank-mailman (input) for mailman id 669003;
 Fri, 19 Jan 2024 09:55: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 1rQlar-0000xg-Np
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 09: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 1rQlar-0007MQ-N4
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 09:55:21 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQlar-0003Ec-Lx
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 09: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=rKccN0qWZSgLzsvW3VRYsUsWVgPUnd47Xs2FFAWdTLA=; b=qv61A73gg+J9Z5QU3be6doKHxR
	JtIKmlKjJupY1l++N4Sfetinhgm+NHQ0ZJqqcI0zaYAEAvOfweO47sTT39bUwpHnILqB9s9IwhAn4
	xx+u/7Ez4m2Qk3XEu3rG5fRy4QBPmbKrC459wTJ+d8j9xDvB7zqWb9Ma+yp0o46lNF0A=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/vmx: Disallow the use of inactivity states
Message-Id: <E1rQlar-0003Ec-Lx@xenbits.xenproject.org>
Date: Fri, 19 Jan 2024 09:55:21 +0000

commit 3643bb53a05b7c8fbac072c63bef1538f2a6d0d2
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Oct 27 17:02:21 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Jan 18 20:59:06 2024 +0000

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

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


From xen-changelog-bounces@lists.xenproject.org Fri Jan 19 09:55:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 19 Jan 2024 09:55:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.669005.1041558 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rQlb3-000176-AY; Fri, 19 Jan 2024 09:55:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 669005.1041558; Fri, 19 Jan 2024 09: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 1rQlb3-00016y-7X; Fri, 19 Jan 2024 09:55:33 +0000
Received: by outflank-mailman (input) for mailman id 669005;
 Fri, 19 Jan 2024 09:55:31 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQlb1-00016m-Qt
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 09:55:31 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQlb1-0007Mb-QA
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 09:55:31 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQlb1-0003F4-P7
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 09:55: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=lzZbjblTtO3Z4S/dnwjcDGMtXvaC/OxbQnP5ypCAsxI=; b=Pw1R9uN90drK5tRfRbnTxDbEBi
	zh/0akp+PBHpYeKN6Ilpr87Dt8ido54Cs9pizVSa8NzAo8Xk/ibsFZO5ZQy36sZDo0AcSD0lIcLD4
	A6y3Em6FM28BlkYdR56JGcoXjEtxD/MB61Ggt4YL8dCDGC+VN9z16n+40CSEfbh/u/mk=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/cpuid: Change cpuid() from a macro to a static inline
Message-Id: <E1rQlb1-0003F4-P7@xenbits.xenproject.org>
Date: Fri, 19 Jan 2024 09:55:31 +0000

commit 86d0edda34e732f1b000d2adddf4f7884d18e04a
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Jan 16 11:50:38 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Jan 18 20:59:06 2024 +0000

    x86/cpuid: Change cpuid() from a macro to a static inline
    
    Addresses MISRA Rule 5.5.  Introduces others, but lets fix one thing at a
    time.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/include/asm/processor.h | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/include/asm/processor.h b/xen/arch/x86/include/asm/processor.h
index ff62b080af..b227cdee8e 100644
--- a/xen/arch/x86/include/asm/processor.h
+++ b/xen/arch/x86/include/asm/processor.h
@@ -126,14 +126,6 @@ static inline int cpu_nr_siblings(unsigned int cpu)
     return cpu_data[cpu].x86_num_siblings;
 }
 
-/*
- * Generic CPUID function
- * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
- * resulting in stale register contents being returned.
- */
-#define cpuid(leaf, eax, ebx, ecx, edx)          \
-        cpuid_count(leaf, 0, eax, ebx, ecx, edx)
-
 /* Some CPUID calls want 'count' to be placed in ecx */
 static inline void cpuid_count(
     unsigned int op,
@@ -148,6 +140,21 @@ static inline void cpuid_count(
           : "0" (op), "c" (count) );
 }
 
+/*
+ * Generic CPUID function
+ * clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx
+ * resulting in stale register contents being returned.
+ */
+static inline void cpuid(
+    unsigned int leaf,
+    unsigned int *eax,
+    unsigned int *ebx,
+    unsigned int *ecx,
+    unsigned int *edx)
+{
+    cpuid_count(leaf, 0, eax, ebx, ecx, edx);
+}
+
 /*
  * CPUID functions returning a single datum
  */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Jan 19 09:55:43 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 19 Jan 2024 09:55:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.669006.1041562 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rQlbD-0001Ar-Bn; Fri, 19 Jan 2024 09:55:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 669006.1041562; Fri, 19 Jan 2024 09: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 1rQlbD-0001Aj-8x; Fri, 19 Jan 2024 09:55:43 +0000
Received: by outflank-mailman (input) for mailman id 669006;
 Fri, 19 Jan 2024 09:55:41 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQlbB-0001AL-U0
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 09:55:41 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQlbB-0007Mu-TI
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 09:55:41 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rQlbB-0003Ga-SK
 for xen-changelog@lists.xenproject.org; Fri, 19 Jan 2024 09:55:41 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=mkv1v3ludE9Oh3kyVj7u4p+9FNwDgj1b/dQpT6VB8KY=; b=AQ6A5+MqKwyWtR6ETpQd/9OxYt
	ezEMz6ZTUjd7INk7pSY0hApk5+DAYae7EBSnCaSN4rm4ZMyMnaE/HWMiSWBJ8fuHsw9DD1eYAE1i0
	eIOQUm+o1OcK89x2lRpjbp8plnocjrtLyIpK77XAS3q2Sln+fzY1H32IIEEMmyiLZnHs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/livepatch: Make check_for_livepatch_work() faster in the common case
Message-Id: <E1rQlbB-0003Ga-SK@xenbits.xenproject.org>
Date: Fri, 19 Jan 2024 09:55:41 +0000

commit c30021be302aa2a644ef5544097fb8bb763ec140
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Dec 22 21:06:16 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Jan 18 21:18:21 2024 +0000

    xen/livepatch: Make check_for_livepatch_work() faster in the common case
    
    When livepatching is enabled, this function is used all the time.  Really do
    check the fastpath first, and annotate it likely() as this is the right answer
    100% of the time (to many significant figures).  This cuts out 3 pointer
    dereferences in the "nothing to do path".
    
    However, GCC still needs some help to persuade it not to set the full stack
    frame (6 spilled registers, 3 slots of locals) even on the fastpath.
    
    Create a new check_for_livepatch_work() with the fastpath only, and make the
    "new" do_livepatch_work() noinline.  This causes the fastpath to need no stack
    frame, making it faster still.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/common/livepatch.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/xen/common/livepatch.c b/xen/common/livepatch.c
index 1209fea256..2c4b843827 100644
--- a/xen/common/livepatch.c
+++ b/xen/common/livepatch.c
@@ -1693,7 +1693,7 @@ static int livepatch_spin(atomic_t *counter, s_time_t timeout,
  * The main function which manages the work of quiescing the system and
  * patching code.
  */
-void check_for_livepatch_work(void)
+static void noinline do_livepatch_work(void)
 {
 #define ACTION(x) [LIVEPATCH_ACTION_##x] = #x
     static const char *const names[] = {
@@ -1711,10 +1711,6 @@ void check_for_livepatch_work(void)
          !is_idle_domain(current->sched_unit->domain) )
         return;
 
-    /* Fast path: no work to do. */
-    if ( !per_cpu(work_to_do, cpu ) )
-        return;
-
     smp_rmb();
     /* In case we aborted, other CPUs can skip right away. */
     if ( !livepatch_work.do_work )
@@ -1864,6 +1860,17 @@ void check_for_livepatch_work(void)
     }
 }
 
+void check_for_livepatch_work(void)
+{
+    unsigned int cpu = smp_processor_id();
+
+    /* Fast path: no work to do. */
+    if ( likely(!per_cpu(work_to_do, cpu)) )
+        return;
+
+    do_livepatch_work();
+}
+
 /*
  * Only allow dependent payload is applied on top of the correct
  * build-id.
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Jan 20 02:00:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 20 Jan 2024 02:00:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.669170.1041795 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rR0eR-0001cp-EX; Sat, 20 Jan 2024 02:00:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 669170.1041795; Sat, 20 Jan 2024 02:00:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rR0eR-0001cJ-Bn; Sat, 20 Jan 2024 02:00:03 +0000
Received: by outflank-mailman (input) for mailman id 669170;
 Sat, 20 Jan 2024 02:00:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rR0eQ-0001Ab-CF
 for xen-changelog@lists.xenproject.org; Sat, 20 Jan 2024 02:00:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rR0eQ-0003IJ-78
 for xen-changelog@lists.xenproject.org; Sat, 20 Jan 2024 02:00:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rR0eQ-0004DT-5y
 for xen-changelog@lists.xenproject.org; Sat, 20 Jan 2024 02:00:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=FNxGwC/cfvvg8glNU+w2ibhwCQCgZCUS7vfyXZxX4mk=; b=oAY1IB/ziGbH0avs3V93DrxN7/
	l40w5EWAgvnC462CKcCW0pwtc+cqODqCgn9oF17m7IS9qdeAXeD2LNszI1UsEVCHPNAimgTvoLcu5
	dpAzm643AYCLuwv/Vp6JQFVxTabgCRnJUMUio8gjQ5CNv/6iY8xQXZhB9S4I92oOC9fs=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen: Fold exit paths in find_text_region()
Message-Id: <E1rR0eQ-0004DT-5y@xenbits.xenproject.org>
Date: Sat, 20 Jan 2024 02:00:02 +0000

commit b25607e528f6ce7851e907ed59ad5ff583aa1840
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Thu Apr 13 19:52:10 2023 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Jan 18 22:52:54 2024 +0000

    xen: Fold exit paths in find_text_region()
    
    Despite rcu_read_unlock() being fully inlineable, the optimiser doesn't appear
    willing to fold the exit paths.  Rework the logic to do so explicitly.
    
    This compiles to marginally better code in all cases.  No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/common/virtual_region.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/xen/common/virtual_region.c b/xen/common/virtual_region.c
index 5f89703f51..ddac5c9147 100644
--- a/xen/common/virtual_region.c
+++ b/xen/common/virtual_region.c
@@ -40,20 +40,20 @@ static DEFINE_RCU_READ_LOCK(rcu_virtual_region_lock);
 
 const struct virtual_region *find_text_region(unsigned long addr)
 {
-    const struct virtual_region *region;
+    const struct virtual_region *iter, *region = NULL;
 
     rcu_read_lock(&rcu_virtual_region_lock);
-    list_for_each_entry_rcu( region, &virtual_region_list, list )
+    list_for_each_entry_rcu ( iter, &virtual_region_list, list )
     {
-        if ( (void *)addr >= region->start && (void *)addr < region->end )
+        if ( (void *)addr >= iter->start && (void *)addr < iter->end )
         {
-            rcu_read_unlock(&rcu_virtual_region_lock);
-            return region;
+            region = iter;
+            break;
         }
     }
     rcu_read_unlock(&rcu_virtual_region_lock);
 
-    return NULL;
+    return region;
 }
 
 void register_virtual_region(struct virtual_region *r)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 23 01:55:09 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 23 Jan 2024 01:55:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.670233.1042829 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS60F-0003ju-3V; Tue, 23 Jan 2024 01:55:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 670233.1042829; Tue, 23 Jan 2024 01: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 1rS60F-0003jn-12; Tue, 23 Jan 2024 01:55:03 +0000
Received: by outflank-mailman (input) for mailman id 670233;
 Tue, 23 Jan 2024 01: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 1rS60E-0003jh-9t
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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 1rS60E-0000pb-68
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01:55:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rS60E-0001QC-57
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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=NCPM0v9TWUSpR9AYn5xKgUecdJKd4ywaq4cuYqf+AUA=; b=Nryu++VvX44B2q52QwKLGjnhLs
	rEtMfa+3qaBAluNrNXDYMW8ozJlxEj2+bT+nA7JoyTeaZ33nVUjBG4LmU/eoVGBZJiipelbsDVIul
	gIPziuxrAstAsCewp6o2xNs+xfboLhrdKt6NW5OV1zyyulx6KbfvxIhK44SeKsG+6d7k=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] core-parking: use alternative_call()
Message-Id: <E1rS60E-0001QC-57@xenbits.xenproject.org>
Date: Tue, 23 Jan 2024 01:55:02 +0000

commit 1bc07ebcac3b1bb2a378732bc0f9a19940e76faf
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 22 13:38:24 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 22 13:38:24 2024 +0100

    core-parking: use alternative_call()
    
    This way we can arrange for core_parking_{performance,power}()'s ENDBR
    to also be zapped.
    
    For the decision to be taken before the 2nd alternative patching pass,
    the initcall needs to become a pre-SMP one, though.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/common/core_parking.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/xen/common/core_parking.c b/xen/common/core_parking.c
index c4f01291c0..a970ffeab8 100644
--- a/xen/common/core_parking.c
+++ b/xen/common/core_parking.c
@@ -30,10 +30,11 @@ static DEFINE_SPINLOCK(accounting_lock);
 static uint32_t cur_idle_nums;
 static unsigned int core_parking_cpunum[NR_CPUS] = {[0 ... NR_CPUS-1] = -1};
 
-static const struct cp_policy {
+struct cp_policy {
     char name[30];
     unsigned int (*next)(unsigned int event);
-} *__read_mostly core_parking_policy;
+};
+static struct cp_policy __ro_after_init core_parking_policy;
 
 static enum core_parking_controller {
     POWER_FIRST,
@@ -175,12 +176,13 @@ long cf_check core_parking_helper(void *data)
     unsigned int cpu;
     int ret = 0;
 
-    if ( !core_parking_policy )
+    if ( !core_parking_policy.next )
         return -EINVAL;
 
     while ( cur_idle_nums < idle_nums )
     {
-        cpu = core_parking_policy->next(CORE_PARKING_INCREMENT);
+        cpu = alternative_call(core_parking_policy.next,
+                               CORE_PARKING_INCREMENT);
         ret = cpu_down(cpu);
         if ( ret )
             return ret;
@@ -193,7 +195,8 @@ long cf_check core_parking_helper(void *data)
 
     while ( cur_idle_nums > idle_nums )
     {
-        cpu = core_parking_policy->next(CORE_PARKING_DECREMENT);
+        cpu = alternative_call(core_parking_policy.next,
+                               CORE_PARKING_DECREMENT);
         ret = cpu_up(cpu);
         if ( ret )
             return ret;
@@ -239,12 +242,12 @@ uint32_t get_cur_idle_nums(void)
     return cur_idle_nums;
 }
 
-static const struct cp_policy power_first = {
+static const struct cp_policy __initconst_cf_clobber power_first = {
     .name = "power",
     .next = core_parking_power,
 };
 
-static const struct cp_policy performance_first = {
+static const struct cp_policy __initconst_cf_clobber performance_first = {
     .name = "performance",
     .next = core_parking_performance,
 };
@@ -254,7 +257,7 @@ static int __init register_core_parking_policy(const struct cp_policy *policy)
     if ( !policy || !policy->next )
         return -EINVAL;
 
-    core_parking_policy = policy;
+    core_parking_policy = *policy;
     return 0;
 }
 
@@ -269,4 +272,4 @@ static int __init cf_check core_parking_init(void)
 
     return ret;
 }
-__initcall(core_parking_init);
+presmp_initcall(core_parking_init);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 23 01:55:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 23 Jan 2024 01:55:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.670234.1042832 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS60P-0003ls-5D; Tue, 23 Jan 2024 01:55:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 670234.1042832; Tue, 23 Jan 2024 01: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 1rS60P-0003ll-2e; Tue, 23 Jan 2024 01:55:13 +0000
Received: by outflank-mailman (input) for mailman id 670234;
 Tue, 23 Jan 2024 01: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 1rS60O-0003ld-BB
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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 1rS60O-0000pv-AO
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01:55:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rS60O-0001R6-8Q
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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=pc8SCCDm+I2J7GL98lVXW0rYrC9n5wNcbFuGKQ/Culk=; b=vwNnH6St5EGOMwqGrPkF7E51Nb
	NQa5CxO5Yn7Ob+6niKPijrQ+GSHScNWUy0fEfGRFSJbegQ1QrjjUc7Y/ZmAXetOTQ3+yddN31Tq/m
	pv7V93x78VZ15CPIqzSU0Tkums8l+RX4fu6xXozPuza3MYBSGx1jugN3gFkVBLZcJ6MU=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/MTRR: avoid several indirect calls
Message-Id: <E1rS60O-0001R6-8Q@xenbits.xenproject.org>
Date: Tue, 23 Jan 2024 01:55:12 +0000

commit e9e0eb30d4d6565b411499ca826718b4b9acab68
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 22 13:39:23 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 22 13:39:23 2024 +0100

    x86/MTRR: avoid several indirect calls
    
    The use of (supposedly) vendor-specific hooks is a relic from the days
    when Xen was still possible to build as 32-bit binary. There's no
    expectation that a new need for such an abstraction would arise. Convert
    mttr_if to a mere boolean and all prior calls through it to direct ones,
    thus allowing to eliminate 6 ENDBR from .text.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/cpu/mtrr/generic.c   | 26 +++++----------
 xen/arch/x86/cpu/mtrr/main.c      | 66 ++++++++++++++-------------------------
 xen/arch/x86/cpu/mtrr/mtrr.h      | 37 ++++++----------------
 xen/arch/x86/platform_hypercall.c |  2 +-
 4 files changed, 40 insertions(+), 91 deletions(-)

diff --git a/xen/arch/x86/cpu/mtrr/generic.c b/xen/arch/x86/cpu/mtrr/generic.c
index 25ae5f5b7d..c587e9140e 100644
--- a/xen/arch/x86/cpu/mtrr/generic.c
+++ b/xen/arch/x86/cpu/mtrr/generic.c
@@ -287,7 +287,7 @@ static void set_fixed_range(int msr, bool *changed, unsigned int *msrwords)
 	}
 }
 
-int cf_check generic_get_free_region(
+int mtrr_get_free_region(
     unsigned long base, unsigned long size, int replace_reg)
 /*  [SUMMARY] Get a free MTRR.
     <base> The starting (base) address of the region.
@@ -303,14 +303,14 @@ int cf_check generic_get_free_region(
 	if (replace_reg >= 0 && replace_reg < max)
 		return replace_reg;
 	for (i = 0; i < max; ++i) {
-		mtrr_if->get(i, &lbase, &lsize, &ltype);
+		mtrr_get(i, &lbase, &lsize, &ltype);
 		if (lsize == 0)
 			return i;
 	}
 	return -ENOSPC;
 }
 
-static void cf_check generic_get_mtrr(
+void mtrr_get(
     unsigned int reg, unsigned long *base, unsigned long *size, mtrr_type *type)
 {
 	uint64_t _mask, _base;
@@ -500,7 +500,7 @@ static void post_set(bool pge)
 	spin_unlock(&set_atomicity_lock);
 }
 
-static void cf_check generic_set_all(void)
+void mtrr_set_all(void)
 {
 	unsigned long mask, count;
 	unsigned long flags;
@@ -523,7 +523,7 @@ static void cf_check generic_set_all(void)
 	}
 }
 
-static void cf_check generic_set_mtrr(
+void mtrr_set(
     unsigned int reg, unsigned long base, unsigned long size, mtrr_type type)
 /*  [SUMMARY] Set variable MTRR register on the local CPU.
     <reg> The register to set.
@@ -567,7 +567,7 @@ static void cf_check generic_set_mtrr(
 	local_irq_restore(flags);
 }
 
-int cf_check generic_validate_add_page(
+int mtrr_validate_add_page(
     unsigned long base, unsigned long size, unsigned int type)
 {
 	unsigned long lbase, last;
@@ -586,21 +586,9 @@ int cf_check generic_validate_add_page(
 }
 
 
-static int cf_check generic_have_wrcomb(void)
+bool mtrr_have_wrcomb(void)
 {
 	unsigned long config;
 	rdmsrl(MSR_MTRRcap, config);
 	return (config & (1ULL << 10));
 }
-
-/* generic structure...
- */
-const struct mtrr_ops generic_mtrr_ops = {
-	.use_intel_if      = true,
-	.set_all	   = generic_set_all,
-	.get               = generic_get_mtrr,
-	.get_free_region   = generic_get_free_region,
-	.set               = generic_set_mtrr,
-	.validate_add_page = generic_validate_add_page,
-	.have_wrcomb       = generic_have_wrcomb,
-};
diff --git a/xen/arch/x86/cpu/mtrr/main.c b/xen/arch/x86/cpu/mtrr/main.c
index 2946003b84..55a4da54a7 100644
--- a/xen/arch/x86/cpu/mtrr/main.c
+++ b/xen/arch/x86/cpu/mtrr/main.c
@@ -57,7 +57,7 @@ static DEFINE_MUTEX(mtrr_mutex);
 u64 __read_mostly size_or_mask;
 u64 __read_mostly size_and_mask;
 
-const struct mtrr_ops *__read_mostly mtrr_if = NULL;
+static bool __ro_after_init mtrr_if;
 
 static void set_mtrr(unsigned int reg, unsigned long base,
 		     unsigned long size, mtrr_type type);
@@ -78,23 +78,12 @@ static const char *mtrr_attrib_to_str(int x)
 	return (x <= 6) ? mtrr_strings[x] : "?";
 }
 
-/*  Returns non-zero if we have the write-combining memory type  */
-static int have_wrcomb(void)
-{
-	return (mtrr_if->have_wrcomb ? mtrr_if->have_wrcomb() : 0);
-}
-
 /*  This function returns the number of variable MTRRs  */
 static void __init set_num_var_ranges(void)
 {
-	unsigned long config = 0;
-
-	if (use_intel()) {
-		rdmsrl(MSR_MTRRcap, config);
-	} else if (is_cpu(AMD))
-		config = 2;
-	else if (is_cpu(CENTAUR))
-		config = 8;
+	unsigned long config;
+
+	rdmsrl(MSR_MTRRcap, config);
 	num_var_ranges = MASK_EXTR(config, MTRRcap_VCNT);
 }
 
@@ -149,10 +138,10 @@ static void cf_check ipi_handler(void *info)
 	if (data->smp_reg == ~0U) /* update all mtrr registers */
 		/* At the cpu hot-add time this will reinitialize mtrr 
  		 * registres on the existing cpus. It is ok.  */
-		mtrr_if->set_all();
+		mtrr_set_all();
 	else /* single mtrr register update */
-		mtrr_if->set(data->smp_reg, data->smp_base, 
-			     data->smp_size, data->smp_type);
+		mtrr_set(data->smp_reg, data->smp_base,
+			 data->smp_size, data->smp_type);
 
 	atomic_dec(&data->count);
 	while(atomic_read(&data->gate))
@@ -198,10 +187,9 @@ static inline int types_compatible(mtrr_type type1, mtrr_type type2) {
  * of CPUs. As each CPU disables interrupts, it'll decrement it once. We wait
  * until it hits 0 and proceed. We set the data.gate flag and reset data.count.
  * Meanwhile, they are waiting for that flag to be set. Once it's set, each 
- * CPU goes through the transition of updating MTRRs. The CPU vendors may each do it 
- * differently, so we call mtrr_if->set() callback and let them take care of it.
- * When they're done, they again decrement data->count and wait for data.gate to 
- * be reset. 
+ * CPU goes through the transition of updating MTRRs.
+ * When mtrr_set() is done, they again decrement data->count and wait for
+ * data.gate to be reset.
  * When we finish, we wait for data.count to hit 0 and toggle the data.gate flag.
  * Everyone then enables interrupts and we all continue on.
  *
@@ -251,9 +239,9 @@ static void set_mtrr(unsigned int reg, unsigned long base,
 	if (reg == ~0U)  /* update all mtrr registers */
 		/* at boot or resume time, this will reinitialize the mtrrs on 
 		 * the bp. It is ok. */
-		mtrr_if->set_all();
+		mtrr_set_all();
 	else /* update the single mtrr register */
-		mtrr_if->set(reg,base,size,type);
+		mtrr_set(reg, base, size, type);
 
 	/* wait for the others */
 	while (atomic_read(&data.count))
@@ -319,7 +307,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
 	if (!mtrr_if)
 		return -ENXIO;
 		
-	if ((error = mtrr_if->validate_add_page(base,size,type)))
+	if ((error = mtrr_validate_add_page(base, size, type)))
 		return error;
 
 	if (type >= MTRR_NUM_TYPES) {
@@ -328,7 +316,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
 	}
 
 	/*  If the type is WC, check that this processor supports it  */
-	if ((type == X86_MT_WC) && !have_wrcomb()) {
+	if ((type == X86_MT_WC) && mtrr_have_wrcomb()) {
 		printk(KERN_WARNING
 		       "mtrr: your processor doesn't support write-combining\n");
 		return -EOPNOTSUPP;
@@ -350,7 +338,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
 	/*  Search for existing MTRR  */
 	mutex_lock(&mtrr_mutex);
 	for (i = 0; i < num_var_ranges; ++i) {
-		mtrr_if->get(i, &lbase, &lsize, &ltype);
+		mtrr_get(i, &lbase, &lsize, &ltype);
 		if (!lsize || base > lbase + lsize - 1 || base + size - 1 < lbase)
 			continue;
 		/*  At this point we know there is some kind of overlap/enclosure  */
@@ -385,7 +373,7 @@ int mtrr_add_page(unsigned long base, unsigned long size,
 		goto out;
 	}
 	/*  Search for an empty MTRR  */
-	i = mtrr_if->get_free_region(base, size, replace);
+	i = mtrr_get_free_region(base, size, replace);
 	if (i >= 0) {
 		set_mtrr(i, base, size, type);
 		if (likely(replace < 0))
@@ -494,7 +482,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
 	if (reg < 0) {
 		/*  Search for existing MTRR  */
 		for (i = 0; i < max; ++i) {
-			mtrr_if->get(i, &lbase, &lsize, &ltype);
+			mtrr_get(i, &lbase, &lsize, &ltype);
 			if (lbase == base && lsize == size) {
 				reg = i;
 				break;
@@ -510,7 +498,7 @@ int mtrr_del_page(int reg, unsigned long base, unsigned long size)
 		printk(KERN_WARNING "mtrr: register: %d too big\n", reg);
 		goto out;
 	}
-	mtrr_if->get(reg, &lbase, &lsize, &ltype);
+	mtrr_get(reg, &lbase, &lsize, &ltype);
 	if (lsize < 1) {
 		printk(KERN_WARNING "mtrr: MTRR %d not used\n", reg);
 		goto out;
@@ -568,7 +556,7 @@ struct mtrr_value {
 void __init mtrr_bp_init(void)
 {
 	if (cpu_has_mtrr) {
-		mtrr_if = &generic_mtrr_ops;
+		mtrr_if = true;
 		size_or_mask = ~((1ULL << (paddr_bits - PAGE_SHIFT)) - 1);
 		size_and_mask = ~size_or_mask & 0xfffff00000ULL;
 	}
@@ -576,14 +564,13 @@ void __init mtrr_bp_init(void)
 	if (mtrr_if) {
 		set_num_var_ranges();
 		init_table();
-		if (use_intel())
-			get_mtrr_state();
+		get_mtrr_state();
 	}
 }
 
 void mtrr_ap_init(void)
 {
-	if (!mtrr_if || !use_intel() || hold_mtrr_updates_on_aps)
+	if (!mtrr_if || hold_mtrr_updates_on_aps)
 		return;
 	/*
 	 * Ideally we should hold mtrr_mutex here to avoid mtrr entries changed,
@@ -612,32 +599,25 @@ void mtrr_save_state(void)
 
 void mtrr_aps_sync_begin(void)
 {
-	if (!use_intel())
-		return;
 	hold_mtrr_updates_on_aps = 1;
 }
 
 void mtrr_aps_sync_end(void)
 {
-	if (!use_intel())
-		return;
 	set_mtrr(~0U, 0, 0, 0);
 	hold_mtrr_updates_on_aps = 0;
 }
 
 void mtrr_bp_restore(void)
 {
-	if (!use_intel())
-		return;
-	mtrr_if->set_all();
+	mtrr_set_all();
 }
 
 static int __init cf_check mtrr_init_finialize(void)
 {
 	if (!mtrr_if)
 		return 0;
-	if (use_intel())
-		mtrr_state_warn();
+	mtrr_state_warn();
 	return 0;
 }
 __initcall(mtrr_init_finialize);
diff --git a/xen/arch/x86/cpu/mtrr/mtrr.h b/xen/arch/x86/cpu/mtrr/mtrr.h
index c7fd44daab..a9741e0cb0 100644
--- a/xen/arch/x86/cpu/mtrr/mtrr.h
+++ b/xen/arch/x86/cpu/mtrr/mtrr.h
@@ -6,40 +6,21 @@
 #define MTRR_CHANGE_MASK_VARIABLE  0x02
 #define MTRR_CHANGE_MASK_DEFTYPE   0x04
 
-
-struct mtrr_ops {
-	u32	vendor;
-	bool	use_intel_if;
-//	void	(*init)(void);
-	void	(*set)(unsigned int reg, unsigned long base,
-		       unsigned long size, mtrr_type type);
-	void	(*set_all)(void);
-
-	void	(*get)(unsigned int reg, unsigned long *base,
-		       unsigned long *size, mtrr_type * type);
-	int	(*get_free_region)(unsigned long base, unsigned long size,
-				   int replace_reg);
-	int	(*validate_add_page)(unsigned long base, unsigned long size,
-				     unsigned int type);
-	int	(*have_wrcomb)(void);
-};
-
-int cf_check generic_get_free_region(
+void mtrr_get(
+    unsigned int reg, unsigned long *base, unsigned long *size,
+    mtrr_type *type);
+void mtrr_set(
+    unsigned int reg, unsigned long base, unsigned long size, mtrr_type type);
+void mtrr_set_all(void);
+int mtrr_get_free_region(
     unsigned long base, unsigned long size, int replace_reg);
-int cf_check generic_validate_add_page(
+int mtrr_validate_add_page(
     unsigned long base, unsigned long size, unsigned int type);
-
-extern const struct mtrr_ops generic_mtrr_ops;
+bool mtrr_have_wrcomb(void);
 
 void get_mtrr_state(void);
 
-extern void set_mtrr_ops(const struct mtrr_ops *);
-
 extern u64 size_or_mask, size_and_mask;
-extern const struct mtrr_ops *mtrr_if;
-
-#define is_cpu(vnd)	(mtrr_if && mtrr_if->vendor == X86_VENDOR_##vnd)
-#define use_intel()	(mtrr_if && mtrr_if->use_intel_if)
 
 extern unsigned int num_var_ranges;
 
diff --git a/xen/arch/x86/platform_hypercall.c b/xen/arch/x86/platform_hypercall.c
index 641b045341..95467b88ab 100644
--- a/xen/arch/x86/platform_hypercall.c
+++ b/xen/arch/x86/platform_hypercall.c
@@ -295,7 +295,7 @@ ret_t do_platform_op(
         ret = -EINVAL;
         if ( op->u.read_memtype.reg < num_var_ranges )
         {
-            mtrr_if->get(op->u.read_memtype.reg, &mfn, &nr_mfns, &type);
+            mtrr_get(op->u.read_memtype.reg, &mfn, &nr_mfns, &type);
             op->u.read_memtype.mfn     = mfn;
             op->u.read_memtype.nr_mfns = nr_mfns;
             op->u.read_memtype.type    = type;
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 23 01:55:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 23 Jan 2024 01:55:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.670235.1042837 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS60Z-0003oH-6o; Tue, 23 Jan 2024 01:55:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 670235.1042837; Tue, 23 Jan 2024 01: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 1rS60Z-0003o9-47; Tue, 23 Jan 2024 01:55:23 +0000
Received: by outflank-mailman (input) for mailman id 670235;
 Tue, 23 Jan 2024 01: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 1rS60Y-0003o1-Fn
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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 1rS60Y-0000q7-E0
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01:55:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rS60Y-0001SC-Ce
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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=vtJYlxxLXfrqzXNeO9QwJWQzKFiQ2F97m/svnhroh8c=; b=Q3G0Mta21b8nMoS/Lakxox8PSv
	Vd4z8104OpFt9F2LdfSbVE9REkogziPaPbEqnfnmvw+R/a73JFKtct6Oijl55pL7YarwdBo02O0oA
	WD4VKS063/gj5vRSIqGtAH1QALEE1pivlyJDxS9WfV20MRAJET84DxSfS599Of1N9Ch8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/PV: avoid indirect call for I/O emulation quirk hook
Message-Id: <E1rS60Y-0001SC-Ce@xenbits.xenproject.org>
Date: Tue, 23 Jan 2024 01:55:22 +0000

commit 1212af3e8c4d3a1350046d4fe0ca3b97b51e67de
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 22 13:40:00 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 22 13:40:00 2024 +0100

    x86/PV: avoid indirect call for I/O emulation quirk hook
    
    This way ioemul_handle_proliant_quirk() won't need ENDBR anymore.
    
    While touching this code, also
    - arrange for it to not be built at all when !PV,
    - add "const" to the last function parameter and bring the definition
      in sync with the declaration (for Misra).
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/Makefile          |  2 +-
 xen/arch/x86/include/asm/io.h  | 10 +++++++---
 xen/arch/x86/ioport_emulate.c  |  9 ++++-----
 xen/arch/x86/pv/emul-priv-op.c |  2 +-
 4 files changed, 13 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index f3abdf9cd1..9f326b9e32 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -45,7 +45,7 @@ obj-$(CONFIG_LIVEPATCH) += alternative.o livepatch.o
 obj-y += msi.o
 obj-y += msr.o
 obj-$(CONFIG_INDIRECT_THUNK) += indirect-thunk.o
-obj-y += ioport_emulate.o
+obj-$(CONFIG_PV) += ioport_emulate.o
 obj-y += irq.o
 obj-$(CONFIG_KEXEC) += machine_kexec.o
 obj-y += mm.o x86_64/mm.o
diff --git a/xen/arch/x86/include/asm/io.h b/xen/arch/x86/include/asm/io.h
index 8c8a15bd06..9b19d2d389 100644
--- a/xen/arch/x86/include/asm/io.h
+++ b/xen/arch/x86/include/asm/io.h
@@ -47,10 +47,14 @@ __OUT(b,"b",char)
 __OUT(w,"w",short)
 __OUT(l,,int)
 
-/* Function pointer used to handle platform specific I/O port emulation. */
+/*
+ * Boolean indicator and function used to handle platform specific I/O port
+ * emulation.
+ */
 #define IOEMUL_QUIRK_STUB_BYTES 9
+extern bool ioemul_handle_quirk;
 struct cpu_user_regs;
-extern unsigned int (*ioemul_handle_quirk)(
-    uint8_t opcode, char *io_emul_stub, struct cpu_user_regs *regs);
+unsigned int ioemul_handle_proliant_quirk(
+    uint8_t opcode, char *io_emul_stub, const struct cpu_user_regs *regs);
 
 #endif
diff --git a/xen/arch/x86/ioport_emulate.c b/xen/arch/x86/ioport_emulate.c
index 57fbe9d09a..23cba842b2 100644
--- a/xen/arch/x86/ioport_emulate.c
+++ b/xen/arch/x86/ioport_emulate.c
@@ -8,11 +8,10 @@
 #include <xen/sched.h>
 #include <xen/dmi.h>
 
-unsigned int (*__read_mostly ioemul_handle_quirk)(
-    uint8_t opcode, char *io_emul_stub, struct cpu_user_regs *regs);
+bool __ro_after_init ioemul_handle_quirk;
 
-static unsigned int cf_check ioemul_handle_proliant_quirk(
-    u8 opcode, char *io_emul_stub, struct cpu_user_regs *regs)
+unsigned int ioemul_handle_proliant_quirk(
+    uint8_t opcode, char *io_emul_stub, const struct cpu_user_regs *regs)
 {
     static const char stub[] = {
         0x9c,       /*    pushf           */
@@ -95,7 +94,7 @@ static const struct dmi_system_id __initconstrel ioport_quirks_tbl[] = {
 static int __init cf_check ioport_quirks_init(void)
 {
     if ( dmi_check_system(ioport_quirks_tbl) )
-        ioemul_handle_quirk = ioemul_handle_proliant_quirk;
+        ioemul_handle_quirk = true;
 
     return 0;
 }
diff --git a/xen/arch/x86/pv/emul-priv-op.c b/xen/arch/x86/pv/emul-priv-op.c
index 0d9f84f458..f101510a1b 100644
--- a/xen/arch/x86/pv/emul-priv-op.c
+++ b/xen/arch/x86/pv/emul-priv-op.c
@@ -112,7 +112,7 @@ static io_emul_stub_t *io_emul_stub_setup(struct priv_op_ctxt *ctxt, u8 opcode,
     /* Some platforms might need to quirk the stub for specific inputs. */
     if ( unlikely(ioemul_handle_quirk) )
     {
-        quirk_bytes = ioemul_handle_quirk(opcode, p, ctxt->ctxt.regs);
+        quirk_bytes = ioemul_handle_proliant_quirk(opcode, p, ctxt->ctxt.regs);
         p += quirk_bytes;
     }
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 23 01:55:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 23 Jan 2024 01:55:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.670236.1042840 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS60j-0003r5-83; Tue, 23 Jan 2024 01:55:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 670236.1042840; Tue, 23 Jan 2024 01: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 1rS60j-0003qy-5a; Tue, 23 Jan 2024 01:55:33 +0000
Received: by outflank-mailman (input) for mailman id 670236;
 Tue, 23 Jan 2024 01: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 1rS60i-0003ql-J4
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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 1rS60i-0000qE-HI
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01:55:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rS60i-0001Sy-GJ
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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=KRAjYiHqFNKAiU6J2Cs+JtpNReRihdAU8fHPrMF+94k=; b=d5kx4MILRPv6UJBr9Eya0uL7OP
	1YLnMSqEyhpIoA5ut+GGqulXHy7RQ5BbGt/q5tFHiWQ5XEPXfb+bVOFFYSACD1wynkPyr7XOGH1SL
	Dk1PPh2AmdporNo8P6+b8lbhTsdAdMt0lHkLjEH1iaoYnEGkdAW4wrrUhTRWQ9/CQyok=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/MCE: separate BSP-only initialization
Message-Id: <E1rS60i-0001Sy-GJ@xenbits.xenproject.org>
Date: Tue, 23 Jan 2024 01:55:32 +0000

commit 9f58616ddb1cc1870399de2202fafc7bf0d61694
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 22 13:40:32 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 22 13:40:32 2024 +0100

    x86/MCE: separate BSP-only initialization
    
    Several function pointers are registered over and over again, when
    setting them once on the BSP suffices. Arrange for this in the vendor
    init functions and mark involved registration functions __init.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/cpu/mcheck/mcaction.c  |  2 +-
 xen/arch/x86/cpu/mcheck/mce.c       | 15 ++++++---------
 xen/arch/x86/cpu/mcheck/mce.h       |  2 +-
 xen/arch/x86/cpu/mcheck/mce_amd.c   | 20 +++++++++++++-------
 xen/arch/x86/cpu/mcheck/mce_intel.c | 10 +++++++---
 5 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/xen/arch/x86/cpu/mcheck/mcaction.c b/xen/arch/x86/cpu/mcheck/mcaction.c
index f4f265c1bc..695fb61d7d 100644
--- a/xen/arch/x86/cpu/mcheck/mcaction.c
+++ b/xen/arch/x86/cpu/mcheck/mcaction.c
@@ -29,7 +29,7 @@ mci_action_add_pageoffline(int bank, struct mc_info *mi,
 
 mce_check_addr_t mc_check_addr = NULL;
 
-void mce_register_addrcheck(mce_check_addr_t cbfunc)
+void __init mce_register_addrcheck(mce_check_addr_t cbfunc)
 {
     mc_check_addr = cbfunc;
 }
diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c
index 779a458cd8..7960ef35ba 100644
--- a/xen/arch/x86/cpu/mcheck/mce.c
+++ b/xen/arch/x86/cpu/mcheck/mce.c
@@ -84,7 +84,7 @@ static void cf_check unexpected_machine_check(const struct cpu_user_regs *regs)
 
 static x86_mce_vector_t _machine_check_vector = unexpected_machine_check;
 
-void x86_mce_vector_register(x86_mce_vector_t hdlr)
+void __init x86_mce_vector_register(x86_mce_vector_t hdlr)
 {
     _machine_check_vector = hdlr;
 }
@@ -107,7 +107,7 @@ void do_machine_check(const struct cpu_user_regs *regs)
  */
 static x86_mce_callback_t mc_callback_bank_extended = NULL;
 
-void x86_mce_callback_register(x86_mce_callback_t cbfunc)
+void __init x86_mce_callback_register(x86_mce_callback_t cbfunc)
 {
     mc_callback_bank_extended = cbfunc;
 }
@@ -118,7 +118,7 @@ void x86_mce_callback_register(x86_mce_callback_t cbfunc)
  */
 static mce_recoverable_t mc_recoverable_scan = NULL;
 
-void mce_recoverable_register(mce_recoverable_t cbfunc)
+void __init mce_recoverable_register(mce_recoverable_t cbfunc)
 {
     mc_recoverable_scan = cbfunc;
 }
@@ -181,7 +181,7 @@ static void mcabank_clear(int banknum)
  */
 static mce_need_clearbank_t mc_need_clearbank_scan = NULL;
 
-void mce_need_clearbank_register(mce_need_clearbank_t cbfunc)
+void __init mce_need_clearbank_register(mce_need_clearbank_t cbfunc)
 {
     mc_need_clearbank_scan = cbfunc;
 }
@@ -798,7 +798,7 @@ void mcheck_init(struct cpuinfo_x86 *c, bool bsp)
     {
     case X86_VENDOR_AMD:
     case X86_VENDOR_HYGON:
-        inited = amd_mcheck_init(c);
+        inited = amd_mcheck_init(c, bsp);
         break;
 
     case X86_VENDOR_INTEL:
@@ -1913,11 +1913,8 @@ static void cf_check mce_softirq(void)
  * will help to collect and log those MCE errors.
  * Round2: Do all MCE processing logic as normal.
  */
-void mce_handler_init(void)
+void __init mce_handler_init(void)
 {
-    if ( smp_processor_id() != 0 )
-        return;
-
     /* callback register, do we really need so many callback? */
     /* mce handler data initialization */
     spin_lock_init(&mce_logout_lock);
diff --git a/xen/arch/x86/cpu/mcheck/mce.h b/xen/arch/x86/cpu/mcheck/mce.h
index 34285296b4..9f87211832 100644
--- a/xen/arch/x86/cpu/mcheck/mce.h
+++ b/xen/arch/x86/cpu/mcheck/mce.h
@@ -43,7 +43,7 @@ extern uint8_t cmci_apic_vector;
 extern bool lmce_support;
 
 /* Init functions */
-enum mcheck_type amd_mcheck_init(const struct cpuinfo_x86 *c);
+enum mcheck_type amd_mcheck_init(const struct cpuinfo_x86 *c, bool bsp);
 enum mcheck_type intel_mcheck_init(struct cpuinfo_x86 *c, bool bsp);
 
 void amd_nonfatal_mcheck_init(struct cpuinfo_x86 *c);
diff --git a/xen/arch/x86/cpu/mcheck/mce_amd.c b/xen/arch/x86/cpu/mcheck/mce_amd.c
index 72f3feeaee..c8891de84d 100644
--- a/xen/arch/x86/cpu/mcheck/mce_amd.c
+++ b/xen/arch/x86/cpu/mcheck/mce_amd.c
@@ -272,7 +272,7 @@ int vmce_amd_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)
 }
 
 enum mcheck_type
-amd_mcheck_init(const struct cpuinfo_x86 *c)
+amd_mcheck_init(const struct cpuinfo_x86 *c, bool bsp)
 {
     uint32_t i;
     enum mcequirk_amd_flags quirkflag = 0;
@@ -282,9 +282,12 @@ amd_mcheck_init(const struct cpuinfo_x86 *c)
 
     /* Assume that machine check support is available.
      * The minimum provided support is at least the K8. */
-    mce_handler_init();
-    x86_mce_vector_register(mcheck_cmn_handler);
-    mce_need_clearbank_register(amd_need_clearbank_scan);
+    if ( bsp )
+    {
+        mce_handler_init();
+        x86_mce_vector_register(mcheck_cmn_handler);
+        mce_need_clearbank_register(amd_need_clearbank_scan);
+    }
 
     for ( i = 0; i < this_cpu(nr_mce_banks); i++ )
     {
@@ -324,9 +327,12 @@ amd_mcheck_init(const struct cpuinfo_x86 *c)
             ppin_msr = MSR_AMD_PPIN;
     }
 
-    x86_mce_callback_register(amd_f10_handler);
-    mce_recoverable_register(mc_amd_recoverable_scan);
-    mce_register_addrcheck(mc_amd_addrcheck);
+    if ( bsp )
+    {
+        x86_mce_callback_register(amd_f10_handler);
+        mce_recoverable_register(mc_amd_recoverable_scan);
+        mce_register_addrcheck(mc_amd_addrcheck);
+    }
 
     return c->x86_vendor == X86_VENDOR_HYGON ?
             mcheck_hygon : mcheck_amd_famXX;
diff --git a/xen/arch/x86/cpu/mcheck/mce_intel.c b/xen/arch/x86/cpu/mcheck/mce_intel.c
index 4045c6591d..84619aadd3 100644
--- a/xen/arch/x86/cpu/mcheck/mce_intel.c
+++ b/xen/arch/x86/cpu/mcheck/mce_intel.c
@@ -820,7 +820,7 @@ static void intel_mce_post_reset(void)
     return;
 }
 
-static void intel_init_mce(void)
+static void intel_init_mce(bool bsp)
 {
     uint64_t msr_content;
     int i;
@@ -846,6 +846,9 @@ static void intel_init_mce(void)
     if ( firstbank ) /* if cmci enabled, firstbank = 0 */
         wrmsrl(MSR_IA32_MC0_STATUS, 0x0ULL);
 
+    if ( !bsp )
+        return;
+
     x86_mce_vector_register(mcheck_cmn_handler);
     mce_recoverable_register(intel_recoverable_scan);
     mce_need_clearbank_register(intel_need_clearbank_scan);
@@ -985,9 +988,10 @@ enum mcheck_type intel_mcheck_init(struct cpuinfo_x86 *c, bool bsp)
 
     intel_init_mca(c);
 
-    mce_handler_init();
+    if ( bsp )
+        mce_handler_init();
 
-    intel_init_mce();
+    intel_init_mce(bsp);
 
     intel_init_cmci(c);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 23 01:55:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 23 Jan 2024 01:55:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.670237.1042845 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS60u-0003uq-Bb; Tue, 23 Jan 2024 01:55:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 670237.1042845; Tue, 23 Jan 2024 01:55:44 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS60u-0003ui-8v; Tue, 23 Jan 2024 01:55:44 +0000
Received: by outflank-mailman (input) for mailman id 670237;
 Tue, 23 Jan 2024 01: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 1rS60s-0003uS-LF
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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 1rS60s-0000qL-KW
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01:55:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rS60s-0001Tm-JZ
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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=AIu2zdBZMGGGB60W7bfK4zlOEuDmzkK0rOuHDcDm77k=; b=B7n+EOOaW4qaR0awNdz6FL/5hg
	QG0Vr1eExrlX2wBAfNBEuDh4BFvXUGTzb9affI9So8Ou+F/qgPPYtLexRgvM3142hSRQuXGqrABI3
	q8iURVjL++hRwTT/11rVygvu8abe1RWTBJkrar/lSdtJihlbFwVkltuwwKbI4IAhbG3k=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/MCE: switch some callback invocations to altcall
Message-Id: <E1rS60s-0001Tm-JZ@xenbits.xenproject.org>
Date: Tue, 23 Jan 2024 01:55:42 +0000

commit 85ba4d050f9f3c4286164f21660ae88435b7e83c
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 22 13:41:07 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 22 13:41:07 2024 +0100

    x86/MCE: switch some callback invocations to altcall
    
    While not performance critical, these hook invocations still would
    better be converted: This way all pre-filled (and newly introduced)
    struct mce_callback instances can become __initconst_cf_clobber, thus
    allowing to eliminate another 9 ENDBR during the 2nd phase of
    alternatives patching.
    
    While this means registering callbacks a little earlier, doing so is
    perhaps even advantageous, for having pointers be non-NULL earlier on.
    Only one set of callbacks would only ever be registered anyway, and
    neither of the respective initialization function can (subsequently)
    fail.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/cpu/mcheck/mcaction.c  | 10 ++----
 xen/arch/x86/cpu/mcheck/mcaction.h  |  5 ---
 xen/arch/x86/cpu/mcheck/mce.c       | 71 ++++++++++--------------------------
 xen/arch/x86/cpu/mcheck/mce.h       | 72 +++++++++++++++++++------------------
 xen/arch/x86/cpu/mcheck/mce_amd.c   | 26 +++++++-------
 xen/arch/x86/cpu/mcheck/mce_intel.c | 14 ++++----
 6 files changed, 80 insertions(+), 118 deletions(-)

diff --git a/xen/arch/x86/cpu/mcheck/mcaction.c b/xen/arch/x86/cpu/mcheck/mcaction.c
index 695fb61d7d..bf7a0de965 100644
--- a/xen/arch/x86/cpu/mcheck/mcaction.c
+++ b/xen/arch/x86/cpu/mcheck/mcaction.c
@@ -27,13 +27,6 @@ mci_action_add_pageoffline(int bank, struct mc_info *mi,
     return rec;
 }
 
-mce_check_addr_t mc_check_addr = NULL;
-
-void __init mce_register_addrcheck(mce_check_addr_t cbfunc)
-{
-    mc_check_addr = cbfunc;
-}
-
 void
 mc_memerr_dhandler(struct mca_binfo *binfo,
                    enum mce_result *result,
@@ -48,7 +41,8 @@ mc_memerr_dhandler(struct mca_binfo *binfo,
     int vmce_vcpuid;
     unsigned int mc_vcpuid;
 
-    if ( !mc_check_addr(bank->mc_status, bank->mc_misc, MC_ADDR_PHYSICAL) )
+    if ( !alternative_call(mce_callbacks.check_addr, bank->mc_status,
+                           bank->mc_misc, MC_ADDR_PHYSICAL) )
     {
         dprintk(XENLOG_WARNING,
                 "No physical address provided for memory error\n");
diff --git a/xen/arch/x86/cpu/mcheck/mcaction.h b/xen/arch/x86/cpu/mcheck/mcaction.h
index 9cb2ad6c9f..6c79498cd2 100644
--- a/xen/arch/x86/cpu/mcheck/mcaction.h
+++ b/xen/arch/x86/cpu/mcheck/mcaction.h
@@ -12,9 +12,4 @@ mc_memerr_dhandler(struct mca_binfo *binfo,
 #define MC_ADDR_PHYSICAL  0
 #define MC_ADDR_VIRTUAL   1
 
-typedef bool (*mce_check_addr_t)(uint64_t status, uint64_t misc, int addr_type);
-extern void mce_register_addrcheck(mce_check_addr_t cbfunc);
-
-extern mce_check_addr_t mc_check_addr;
-
 #endif
diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c
index 7960ef35ba..2844685983 100644
--- a/xen/arch/x86/cpu/mcheck/mce.c
+++ b/xen/arch/x86/cpu/mcheck/mce.c
@@ -82,47 +82,21 @@ static void cf_check unexpected_machine_check(const struct cpu_user_regs *regs)
     fatal_trap(regs, 1);
 }
 
-static x86_mce_vector_t _machine_check_vector = unexpected_machine_check;
-
-void __init x86_mce_vector_register(x86_mce_vector_t hdlr)
-{
-    _machine_check_vector = hdlr;
-}
+struct mce_callbacks __ro_after_init mce_callbacks = {
+    .handler = unexpected_machine_check,
+};
+static const typeof(mce_callbacks.handler) __initconst_cf_clobber __used
+    default_handler = unexpected_machine_check;
 
 /* Call the installed machine check handler for this CPU setup. */
 
 void do_machine_check(const struct cpu_user_regs *regs)
 {
     mce_enter();
-    _machine_check_vector(regs);
+    alternative_vcall(mce_callbacks.handler, regs);
     mce_exit();
 }
 
-/*
- * Init machine check callback handler
- * It is used to collect additional information provided by newer
- * CPU families/models without the need to duplicate the whole handler.
- * This avoids having many handlers doing almost nearly the same and each
- * with its own tweaks ands bugs.
- */
-static x86_mce_callback_t mc_callback_bank_extended = NULL;
-
-void __init x86_mce_callback_register(x86_mce_callback_t cbfunc)
-{
-    mc_callback_bank_extended = cbfunc;
-}
-
-/*
- * Machine check recoverable judgement callback handler
- * It is used to judge whether an UC error is recoverable by software
- */
-static mce_recoverable_t mc_recoverable_scan = NULL;
-
-void __init mce_recoverable_register(mce_recoverable_t cbfunc)
-{
-    mc_recoverable_scan = cbfunc;
-}
-
 struct mca_banks *mcabanks_alloc(unsigned int nr)
 {
     struct mca_banks *mb;
@@ -173,19 +147,6 @@ static void mcabank_clear(int banknum)
     mca_wrmsr(MSR_IA32_MCx_STATUS(banknum), 0x0ULL);
 }
 
-/*
- * Judging whether to Clear Machine Check error bank callback handler
- * According to Intel latest MCA OS Recovery Writer's Guide,
- * whether the error MCA bank needs to be cleared is decided by the mca_source
- * and MCi_status bit value.
- */
-static mce_need_clearbank_t mc_need_clearbank_scan = NULL;
-
-void __init mce_need_clearbank_register(mce_need_clearbank_t cbfunc)
-{
-    mc_need_clearbank_scan = cbfunc;
-}
-
 /*
  * mce_logout_lock should only be used in the trap handler,
  * while MCIP has not been cleared yet in the global status
@@ -226,7 +187,8 @@ static void mca_init_bank(enum mca_source who, struct mc_info *mi, int bank)
 
     if ( (mib->mc_status & MCi_STATUS_MISCV) &&
          (mib->mc_status & MCi_STATUS_ADDRV) &&
-         (mc_check_addr(mib->mc_status, mib->mc_misc, MC_ADDR_PHYSICAL)) &&
+         alternative_call(mce_callbacks.check_addr, mib->mc_status,
+                          mib->mc_misc, MC_ADDR_PHYSICAL) &&
          (who == MCA_POLLER || who == MCA_CMCI_HANDLER) &&
          (mfn_valid(_mfn(paddr_to_pfn(mib->mc_addr)))) )
     {
@@ -326,7 +288,7 @@ mcheck_mca_logout(enum mca_source who, struct mca_banks *bankmask,
      * If no mc_recovery_scan callback handler registered,
      * this error is not recoverable
      */
-    recover = mc_recoverable_scan ? 1 : 0;
+    recover = mce_callbacks.recoverable_scan;
 
     for ( i = 0; i < this_cpu(nr_mce_banks); i++ )
     {
@@ -343,8 +305,9 @@ mcheck_mca_logout(enum mca_source who, struct mca_banks *bankmask,
          * decide whether to clear bank by MCi_STATUS bit value such as
          * OVER/UC/EN/PCC/S/AR
          */
-        if ( mc_need_clearbank_scan )
-            need_clear = mc_need_clearbank_scan(who, status);
+        if ( mce_callbacks.need_clearbank_scan )
+            need_clear = alternative_call(mce_callbacks.need_clearbank_scan,
+                                          who, status);
 
         /*
          * If this is the first bank with valid MCA DATA, then
@@ -380,12 +343,12 @@ mcheck_mca_logout(enum mca_source who, struct mca_banks *bankmask,
 
         if ( recover && uc )
             /* uc = true, recover = true, we need not panic. */
-            recover = mc_recoverable_scan(status);
+            recover = alternative_call(mce_callbacks.recoverable_scan, status);
 
         mca_init_bank(who, mci, i);
 
-        if ( mc_callback_bank_extended )
-            mc_callback_bank_extended(mci, i, status);
+        if ( mce_callbacks.info_collect )
+            alternative_vcall(mce_callbacks.info_collect, mci, i, status);
 
         /* By default, need_clear = true */
         if ( who != MCA_MCE_SCAN && need_clear )
@@ -1913,9 +1876,11 @@ static void cf_check mce_softirq(void)
  * will help to collect and log those MCE errors.
  * Round2: Do all MCE processing logic as normal.
  */
-void __init mce_handler_init(void)
+void __init mce_handler_init(const struct mce_callbacks *cb)
 {
     /* callback register, do we really need so many callback? */
+    mce_callbacks = *cb;
+
     /* mce handler data initialization */
     spin_lock_init(&mce_logout_lock);
     open_softirq(MACHINE_CHECK_SOFTIRQ, mce_softirq);
diff --git a/xen/arch/x86/cpu/mcheck/mce.h b/xen/arch/x86/cpu/mcheck/mce.h
index 9f87211832..7f26afae23 100644
--- a/xen/arch/x86/cpu/mcheck/mce.h
+++ b/xen/arch/x86/cpu/mcheck/mce.h
@@ -63,20 +63,12 @@ void x86_mc_get_cpu_info(unsigned cpu, uint32_t *chipid, uint16_t *coreid,
                          unsigned *ncores, unsigned *ncores_active,
                          unsigned *nthreads);
 
-/* Register a handler for machine check exceptions. */
-typedef void (*x86_mce_vector_t)(const struct cpu_user_regs *regs);
-extern void x86_mce_vector_register(x86_mce_vector_t hdlr);
-
 /*
  * Common generic MCE handler that implementations may nominate
  * via x86_mce_vector_register.
  */
 void cf_check mcheck_cmn_handler(const struct cpu_user_regs *regs);
 
-/* Register a handler for judging whether mce is recoverable. */
-typedef bool (*mce_recoverable_t)(uint64_t status);
-extern void mce_recoverable_register(mce_recoverable_t cbfunc);
-
 /* Read an MSR, checking for an interposed value first */
 extern struct intpose_ent *intpose_lookup(unsigned int cpu_nr, uint64_t msr,
     uint64_t *valp);
@@ -137,30 +129,6 @@ extern mctelem_cookie_t mcheck_mca_logout(enum mca_source who,
                                           struct mca_summary *sp,
                                           struct mca_banks *clear_bank);
 
-/*
- * Register callbacks to be made during bank telemetry logout.
- * Those callbacks are only available to those machine check handlers
- * that call to the common mcheck_cmn_handler or who use the common
- * telemetry logout function mcheck_mca_logout in error polling.
- */
-
-/* Register a handler for judging whether the bank need to be cleared */
-typedef bool (*mce_need_clearbank_t)(enum mca_source who, u64 status);
-extern void mce_need_clearbank_register(mce_need_clearbank_t cbfunc);
-
-/*
- * Register a callback to collect additional information (typically non-
- * architectural) provided by newer CPU families/models without the need
- * to duplicate the whole handler resulting in various handlers each with
- * its own tweaks and bugs. The callback receives an struct mc_info pointer
- * which it can use with x86_mcinfo_reserve to add additional telemetry,
- * the current MCA bank number we are reading telemetry from, and the
- * MCi_STATUS value for that bank.
- */
-typedef struct mcinfo_extended *(*x86_mce_callback_t)
-    (struct mc_info *mi, uint16_t bank, uint64_t status);
-extern void x86_mce_callback_register(x86_mce_callback_t cbfunc);
-
 void *x86_mcinfo_reserve(struct mc_info *mi,
                          unsigned int size, unsigned int type);
 void x86_mcinfo_dump(struct mc_info *mi);
@@ -201,8 +169,44 @@ static inline int mce_bank_msr(const struct vcpu *v, uint32_t msr)
     return 0;
 }
 
-/* MC softirq */
-void mce_handler_init(void);
+struct mce_callbacks {
+    void (*handler)(const struct cpu_user_regs *regs);
+    bool (*check_addr)(uint64_t status, uint64_t misc, int addr_type);
+
+    /* Handler for judging whether mce is recoverable. */
+    bool (*recoverable_scan)(uint64_t status);
+
+    /*
+     * Callbacks to be made during bank telemetry logout.
+     * They are only available to those machine check handlers
+     * that call to the common mcheck_cmn_handler or who use the common
+     * telemetry logout function mcheck_mca_logout in error polling.
+     */
+
+    /*
+     * Judging whether to Clear Machine Check error bank callback handler.
+     * According to Intel latest MCA OS Recovery Writer's Guide, whether
+     * the error MCA bank needs to be cleared is decided by the mca_source
+     * and MCi_status bit value.
+     */
+    bool (*need_clearbank_scan)(enum mca_source who, u64 status);
+
+    /*
+     * Callback to collect additional information (typically non-
+     * architectural) provided by newer CPU families/models without the need
+     * to duplicate the whole handler resulting in various handlers each with
+     * its own tweaks and bugs. The callback receives an struct mc_info pointer
+     * which it can use with x86_mcinfo_reserve to add additional telemetry,
+     * the current MCA bank number we are reading telemetry from, and the
+     * MCi_STATUS value for that bank.
+     */
+    struct mcinfo_extended *(*info_collect)
+        (struct mc_info *mi, uint16_t bank, uint64_t status);
+};
+
+extern struct mce_callbacks mce_callbacks;
+
+void mce_handler_init(const struct mce_callbacks *cb);
 
 extern const struct mca_error_handler *mce_dhandlers;
 extern const struct mca_error_handler *mce_uhandlers;
diff --git a/xen/arch/x86/cpu/mcheck/mce_amd.c b/xen/arch/x86/cpu/mcheck/mce_amd.c
index c8891de84d..3318b8204f 100644
--- a/xen/arch/x86/cpu/mcheck/mce_amd.c
+++ b/xen/arch/x86/cpu/mcheck/mce_amd.c
@@ -271,6 +271,19 @@ int vmce_amd_rdmsr(const struct vcpu *v, uint32_t msr, uint64_t *val)
     return 1;
 }
 
+static const struct mce_callbacks __initconst_cf_clobber k8_callbacks = {
+    .handler = mcheck_cmn_handler,
+    .need_clearbank_scan = amd_need_clearbank_scan,
+};
+
+static const struct mce_callbacks __initconst_cf_clobber k10_callbacks = {
+    .handler = mcheck_cmn_handler,
+    .check_addr = mc_amd_addrcheck,
+    .recoverable_scan = mc_amd_recoverable_scan,
+    .need_clearbank_scan = amd_need_clearbank_scan,
+    .info_collect = amd_f10_handler,
+};
+
 enum mcheck_type
 amd_mcheck_init(const struct cpuinfo_x86 *c, bool bsp)
 {
@@ -283,11 +296,7 @@ amd_mcheck_init(const struct cpuinfo_x86 *c, bool bsp)
     /* Assume that machine check support is available.
      * The minimum provided support is at least the K8. */
     if ( bsp )
-    {
-        mce_handler_init();
-        x86_mce_vector_register(mcheck_cmn_handler);
-        mce_need_clearbank_register(amd_need_clearbank_scan);
-    }
+        mce_handler_init(c->x86 == 0xf ? &k8_callbacks : &k10_callbacks);
 
     for ( i = 0; i < this_cpu(nr_mce_banks); i++ )
     {
@@ -327,13 +336,6 @@ amd_mcheck_init(const struct cpuinfo_x86 *c, bool bsp)
             ppin_msr = MSR_AMD_PPIN;
     }
 
-    if ( bsp )
-    {
-        x86_mce_callback_register(amd_f10_handler);
-        mce_recoverable_register(mc_amd_recoverable_scan);
-        mce_register_addrcheck(mc_amd_addrcheck);
-    }
-
     return c->x86_vendor == X86_VENDOR_HYGON ?
             mcheck_hygon : mcheck_amd_famXX;
 }
diff --git a/xen/arch/x86/cpu/mcheck/mce_intel.c b/xen/arch/x86/cpu/mcheck/mce_intel.c
index 84619aadd3..a99f9cce9d 100644
--- a/xen/arch/x86/cpu/mcheck/mce_intel.c
+++ b/xen/arch/x86/cpu/mcheck/mce_intel.c
@@ -849,11 +849,6 @@ static void intel_init_mce(bool bsp)
     if ( !bsp )
         return;
 
-    x86_mce_vector_register(mcheck_cmn_handler);
-    mce_recoverable_register(intel_recoverable_scan);
-    mce_need_clearbank_register(intel_need_clearbank_scan);
-    mce_register_addrcheck(intel_checkaddr);
-
     mce_dhandlers = intel_mce_dhandlers;
     mce_dhandler_num = ARRAY_SIZE(intel_mce_dhandlers);
     mce_uhandlers = intel_mce_uhandlers;
@@ -963,6 +958,13 @@ static int cf_check cpu_callback(
     return notifier_from_errno(rc);
 }
 
+static const struct mce_callbacks __initconst_cf_clobber intel_callbacks = {
+    .handler = mcheck_cmn_handler,
+    .check_addr = intel_checkaddr,
+    .recoverable_scan = intel_recoverable_scan,
+    .need_clearbank_scan = intel_need_clearbank_scan,
+};
+
 static struct notifier_block cpu_nfb = {
     .notifier_call = cpu_callback
 };
@@ -989,7 +991,7 @@ enum mcheck_type intel_mcheck_init(struct cpuinfo_x86 *c, bool bsp)
     intel_init_mca(c);
 
     if ( bsp )
-        mce_handler_init();
+        mce_handler_init(&intel_callbacks);
 
     intel_init_mce(bsp);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 23 01:55:54 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 23 Jan 2024 01:55:54 +0000
Received: from list by lists.xenproject.org with outflank-mailman.670238.1042848 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS614-0003xp-D8; Tue, 23 Jan 2024 01:55:54 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 670238.1042848; Tue, 23 Jan 2024 01:55:54 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS614-0003xh-AO; Tue, 23 Jan 2024 01:55:54 +0000
Received: by outflank-mailman (input) for mailman id 670238;
 Tue, 23 Jan 2024 01: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 1rS612-0003xV-OK
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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 1rS612-0000qS-Nb
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01:55:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rS612-0001UT-Me
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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=4r9DlqasSyuZlY5U2IkEPpJ00TEHyEpr9vmvs7TqQtc=; b=NotEaEPeowhfsGVZjCwXYN7Jh8
	GWsT5mRlTahO2x0+vmrHFNPzBRvWZMjl6wJ7r+/+1LUNKl7gShU+9HD7J0UBtsl9TLFGaw8tm4DjU
	AVZMgUQ8AEOYPUOzh6QQMc2qcq5KtlGGUTkCyGSgRkggBpa8a0WYMe9iZZTmXZnCB99E=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] common: assembly entry point type/size annotations
Message-Id: <E1rS612-0001UT-Me@xenbits.xenproject.org>
Date: Tue, 23 Jan 2024 01:55:52 +0000

commit df2209f9b7924c312100ccda394eaa3622fd5070
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 22 13:50:40 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 22 13:50:40 2024 +0100

    common: assembly entry point type/size annotations
    
    Recent gas versions generate minimalistic Dwarf debug info for items
    annotated as functions and having their sizes specified [1]. Furthermore
    generating live patches wants items properly annotated. "Borrow" Arm's
    END() and (remotely) derive other annotation infrastructure from
    Linux'es, for all architectures to use.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    
    [1] https://sourceware.org/git?p=binutils-gdb.git;a=commitdiff;h=591cc9fbbfd6d51131c0f1d4a92e7893edcc7a28
---
 xen/include/xen/linkage.h | 54 +++++++++++++++++++++++++++++++++++++++++++++++
 xen/include/xen/macros.h  |  9 ++++++++
 2 files changed, 63 insertions(+)

diff --git a/xen/include/xen/linkage.h b/xen/include/xen/linkage.h
new file mode 100644
index 0000000000..52fe4dfa65
--- /dev/null
+++ b/xen/include/xen/linkage.h
@@ -0,0 +1,54 @@
+#ifndef __LINKAGE_H__
+#define __LINKAGE_H__
+
+#ifdef __ASSEMBLY__
+
+#include <xen/macros.h>
+
+/* CODE_ALIGN needs to be specified by every architecture. */
+#ifndef CODE_FILL
+# define CODE_FILL ~0
+#endif
+
+#ifndef DATA_ALIGN
+# define DATA_ALIGN 0
+#endif
+#ifndef DATA_FILL
+# define DATA_FILL ~0
+#endif
+
+#define SYM_ALIGN(align...) .balign align
+
+#define SYM_L_GLOBAL(name) .globl name
+#define SYM_L_WEAK(name)   .weak name
+#define SYM_L_LOCAL(name)  /* nothing */
+
+#define SYM_T_FUNC         STT_FUNC
+#define SYM_T_DATA         STT_OBJECT
+#define SYM_T_NONE         STT_NOTYPE
+
+#define SYM(name, typ, linkage, align...)         \
+        .type name, SYM_T_ ## typ;                \
+        SYM_L_ ## linkage(name);                  \
+        SYM_ALIGN(align);                         \
+        name:
+
+#define END(name) .size name, . - name
+
+#define FUNC(name, align...) \
+        SYM(name, FUNC, GLOBAL, LASTARG(CODE_ALIGN, ## align), CODE_FILL)
+#define LABEL(name, align...) \
+        SYM(name, NONE, GLOBAL, LASTARG(CODE_ALIGN, ## align), CODE_FILL)
+#define DATA(name, align...) \
+        SYM(name, DATA, GLOBAL, LASTARG(DATA_ALIGN, ## align), DATA_FILL)
+
+#define FUNC_LOCAL(name, align...) \
+        SYM(name, FUNC, LOCAL, LASTARG(CODE_ALIGN, ## align), CODE_FILL)
+#define LABEL_LOCAL(name, align...) \
+        SYM(name, NONE, LOCAL, LASTARG(CODE_ALIGN, ## align), CODE_FILL)
+#define DATA_LOCAL(name, align...) \
+        SYM(name, DATA, LOCAL, LASTARG(DATA_ALIGN, ## align), DATA_FILL)
+
+#endif /*  __ASSEMBLY__ */
+
+#endif /* __LINKAGE_H__ */
diff --git a/xen/include/xen/macros.h b/xen/include/xen/macros.h
index 18842cd8a5..e64373f018 100644
--- a/xen/include/xen/macros.h
+++ b/xen/include/xen/macros.h
@@ -21,6 +21,15 @@
 #define count_args(args...) \
     count_args_(., ## args, 8, 7, 6, 5, 4, 3, 2, 1, 0)
 
+#define ARG1_(x, y...) (x)
+#define ARG2_(x, y...) ARG1_(y)
+#define ARG3_(x, y...) ARG2_(y)
+#define ARG4_(x, y...) ARG3_(y)
+
+#define ARG__(nr) ARG ## nr ## _
+#define ARG_(nr)  ARG__(nr)
+#define LASTARG(x, y...) ARG_(count_args(x, ## y))(x, ## y)
+
 /* Indirect macros required for expanded argument pasting. */
 #define PASTE_(a, b) a ## b
 #define PASTE(a, b) PASTE_(a, b)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 23 01:56:04 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 23 Jan 2024 01:56:04 +0000
Received: from list by lists.xenproject.org with outflank-mailman.670239.1042853 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS61E-000407-FL; Tue, 23 Jan 2024 01:56:04 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 670239.1042853; Tue, 23 Jan 2024 01:56:04 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS61E-0003zz-C4; Tue, 23 Jan 2024 01:56:04 +0000
Received: by outflank-mailman (input) for mailman id 670239;
 Tue, 23 Jan 2024 01: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 1rS61C-0003zr-RQ
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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 1rS61C-0000qm-Qc
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01:56:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rS61C-0001Vs-Pl
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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=HWDOVp9wm5pw3lEjw7nWG8hlLfA+mYHKqhE6X/DwFcA=; b=sMzqNGcmSzvY6p3lK2ij0/fQ2J
	yxZWI6u9xGRKDGtd2nZzbD968PdRcfCHjHdVe5ti+rfJcwH7RnbTqQ9AZu1ShzYNSW8CKH+qCJb/A
	C4aBrDw2PYN6VU4E2dzwOo5TCPe+U4qmlsLxWdZWBRgs/qMaPg72oNjQF6ZWH6LshVno=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86: annotate entry points with type and size
Message-Id: <E1rS61C-0001Vs-Pl@xenbits.xenproject.org>
Date: Tue, 23 Jan 2024 01:56:02 +0000

commit b3a9037550dfeeffeb1d831249dadb6f1c3f091b
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 22 13:51:31 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 22 13:51:31 2024 +0100

    x86: annotate entry points with type and size
    
    Use the generic framework in xen/linkage.h.
    
    For switch_to_kernel() and restore_all_guest() so far implicit alignment
    (from being first in their respective sections) is being made explicit
    (as in: using FUNC() without 2nd argument). Whereas for
    {,compat}create_bounce_frame() and autogen_entrypoints[] alignment is
    newly arranged for.
    
    Except for the added/adjusted alignment padding (including their
    knock-on effects) no change in generated code/data. Note that the basis
    for support of weak definitions is added despite them not having any use
    right now.
    
    Note that ASM_INT() is switched to DATA(), not DATA_LOCAL(), as the only
    use site wants the symbol global anyway.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/include/asm/asm_defns.h |   6 +-
 xen/arch/x86/include/asm/config.h    |   4 +-
 xen/arch/x86/x86_64/compat/entry.S   |  36 +++++-----
 xen/arch/x86/x86_64/entry.S          | 124 +++++++++++++++++++++--------------
 4 files changed, 101 insertions(+), 69 deletions(-)

diff --git a/xen/arch/x86/include/asm/asm_defns.h b/xen/arch/x86/include/asm/asm_defns.h
index baaaccb26e..51bf1cf1e6 100644
--- a/xen/arch/x86/include/asm/asm_defns.h
+++ b/xen/arch/x86/include/asm/asm_defns.h
@@ -13,6 +13,7 @@
 #include <asm/alternative.h>
 
 #ifdef __ASSEMBLY__
+#include <xen/linkage.h>
 #include <asm/asm-defns.h>
 #ifndef CONFIG_INDIRECT_THUNK
 .equ CONFIG_INDIRECT_THUNK, 0
@@ -343,10 +344,7 @@ static always_inline void stac(void)
     .popsection
 
 #define ASM_INT(label, val)                 \
-    .p2align 2;                             \
-label: .long (val);                         \
-    .size label, . - label;                 \
-    .type label, @object
+    DATA(label, 4) .long (val); END(label)
 
 #define ASM_CONSTANT(name, value)                \
     asm ( ".equ " #name ", %P0; .global " #name  \
diff --git a/xen/arch/x86/include/asm/config.h b/xen/arch/x86/include/asm/config.h
index bbced338be..9eab23b6b9 100644
--- a/xen/arch/x86/include/asm/config.h
+++ b/xen/arch/x86/include/asm/config.h
@@ -43,7 +43,9 @@
 
 /* Linkage for x86 */
 #ifdef __ASSEMBLY__
-#define ALIGN .align 16,0x90
+#define CODE_ALIGN 16
+#define CODE_FILL 0x90
+#define ALIGN .align CODE_ALIGN, CODE_FILL
 #define ENTRY(name)                             \
   .globl name;                                  \
   ALIGN;                                        \
diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compat/entry.S
index fcc3a721f1..49811a56e9 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -11,7 +11,7 @@
 #include <public/xen.h>
 #include <irq_vectors.h>
 
-ENTRY(entry_int82)
+FUNC(entry_int82)
         ENDBR64
         ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
         pushq $0
@@ -29,9 +29,10 @@ ENTRY(entry_int82)
 
         mov   %rsp, %rdi
         call  do_entry_int82
+END(entry_int82)
 
 /* %rbx: struct vcpu */
-ENTRY(compat_test_all_events)
+FUNC(compat_test_all_events)
         ASSERT_NOT_IN_ATOMIC
         cli                             # tests must not race interrupts
 /*compat_test_softirqs:*/
@@ -68,24 +69,21 @@ compat_test_guest_events:
         call  compat_create_bounce_frame
         jmp   compat_test_all_events
 
-        ALIGN
 /* %rbx: struct vcpu */
-compat_process_softirqs:
+LABEL_LOCAL(compat_process_softirqs)
         sti
         call  do_softirq
         jmp   compat_test_all_events
 
-        ALIGN
 /* %rbx: struct vcpu, %rdx: struct trap_bounce */
-.Lcompat_process_trapbounce:
+LABEL_LOCAL(.Lcompat_process_trapbounce)
         sti
 .Lcompat_bounce_exception:
         call  compat_create_bounce_frame
         jmp   compat_test_all_events
 
-	ALIGN
 /* %rbx: struct vcpu */
-compat_process_mce:
+LABEL_LOCAL(compat_process_mce)
         testb $1 << VCPU_TRAP_MCE,VCPU_async_exception_mask(%rbx)
         jnz   .Lcompat_test_guest_nmi
         sti
@@ -99,9 +97,8 @@ compat_process_mce:
         movb %dl,VCPU_async_exception_mask(%rbx)
         jmp   compat_process_trap
 
-	ALIGN
 /* %rbx: struct vcpu */
-compat_process_nmi:
+LABEL_LOCAL(compat_process_nmi)
         testb $1 << VCPU_TRAP_NMI,VCPU_async_exception_mask(%rbx)
         jnz   compat_test_guest_events
         sti
@@ -118,9 +115,10 @@ compat_process_trap:
         leaq  VCPU_trap_bounce(%rbx),%rdx
         call  compat_create_bounce_frame
         jmp   compat_test_all_events
+END(compat_test_all_events)
 
 /* %rbx: struct vcpu, interrupts disabled */
-ENTRY(compat_restore_all_guest)
+FUNC(compat_restore_all_guest)
         ASSERT_INTERRUPTS_DISABLED
         mov   $~(X86_EFLAGS_IOPL | X86_EFLAGS_VM), %r11d
         and   UREGS_eflags(%rsp),%r11d
@@ -163,9 +161,10 @@ ENTRY(compat_restore_all_guest)
         RESTORE_ALL adj=8 compat=1
 .Lft0:  iretq
         _ASM_PRE_EXTABLE(.Lft0, handle_exception)
+END(compat_restore_all_guest)
 
 /* This mustn't modify registers other than %rax. */
-ENTRY(cr4_pv32_restore)
+FUNC(cr4_pv32_restore)
         push  %rdx
         GET_CPUINFO_FIELD(cr4, dx)
         mov   (%rdx), %rax
@@ -195,8 +194,9 @@ ENTRY(cr4_pv32_restore)
         pop   %rdx
         xor   %eax, %eax
         ret
+END(cr4_pv32_restore)
 
-ENTRY(compat_syscall)
+FUNC(compat_syscall)
         /* Fix up reported %cs/%ss for compat domains. */
         movl  $FLAT_COMPAT_USER_SS, UREGS_ss(%rsp)
         movl  $FLAT_COMPAT_USER_CS, UREGS_cs(%rsp)
@@ -224,8 +224,9 @@ UNLIKELY_END(compat_syscall_gpf)
         movw  %si,TRAPBOUNCE_cs(%rdx)
         movb  %cl,TRAPBOUNCE_flags(%rdx)
         jmp   .Lcompat_bounce_exception
+END(compat_syscall)
 
-ENTRY(compat_sysenter)
+FUNC(compat_sysenter)
         CR4_PV32_RESTORE
         movq  VCPU_trap_ctxt(%rbx),%rcx
         cmpb  $X86_EXC_GP, UREGS_entry_vector(%rsp)
@@ -238,17 +239,19 @@ ENTRY(compat_sysenter)
         movw  %ax,TRAPBOUNCE_cs(%rdx)
         call  compat_create_bounce_frame
         jmp   compat_test_all_events
+END(compat_sysenter)
 
-ENTRY(compat_int80_direct_trap)
+FUNC(compat_int80_direct_trap)
         CR4_PV32_RESTORE
         call  compat_create_bounce_frame
         jmp   compat_test_all_events
+END(compat_int80_direct_trap)
 
 /* CREATE A BASIC EXCEPTION FRAME ON GUEST OS (RING-1) STACK:            */
 /*   {[ERRCODE,] EIP, CS, EFLAGS, [ESP, SS]}                             */
 /* %rdx: trap_bounce, %rbx: struct vcpu                                  */
 /* On return only %rbx and %rdx are guaranteed non-clobbered.            */
-compat_create_bounce_frame:
+FUNC_LOCAL(compat_create_bounce_frame)
         ASSERT_INTERRUPTS_ENABLED
         mov   %fs,%edi
         ALTERNATIVE "", stac, X86_FEATURE_XEN_SMAP
@@ -354,3 +357,4 @@ compat_crash_page_fault:
         jmp   .Lft14
 .previous
         _ASM_EXTABLE(.Lft14, .Lfx14)
+END(compat_create_bounce_frame)
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index c25b14dde6..482c91d4f5 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -24,7 +24,7 @@
 
 #ifdef CONFIG_PV
 /* %rbx: struct vcpu */
-switch_to_kernel:
+FUNC_LOCAL(switch_to_kernel)
         leaq  VCPU_trap_bounce(%rbx),%rdx
 
         /* TB_eip = 32-bit syscall ? syscall32_addr : syscall_addr */
@@ -89,24 +89,21 @@ test_guest_events:
         call  create_bounce_frame
         jmp   test_all_events
 
-        ALIGN
 /* %rbx: struct vcpu */
-process_softirqs:
+LABEL_LOCAL(process_softirqs)
         sti
         call do_softirq
         jmp  test_all_events
 
-        ALIGN
 /* %rbx: struct vcpu, %rdx struct trap_bounce */
-.Lprocess_trapbounce:
+LABEL_LOCAL(.Lprocess_trapbounce)
         sti
 .Lbounce_exception:
         call  create_bounce_frame
         jmp   test_all_events
 
-        ALIGN
 /* %rbx: struct vcpu */
-process_mce:
+LABEL_LOCAL(process_mce)
         testb $1 << VCPU_TRAP_MCE, VCPU_async_exception_mask(%rbx)
         jnz  .Ltest_guest_nmi
         sti
@@ -120,9 +117,8 @@ process_mce:
         movb %dl, VCPU_async_exception_mask(%rbx)
         jmp  process_trap
 
-        ALIGN
 /* %rbx: struct vcpu */
-process_nmi:
+LABEL_LOCAL(process_nmi)
         testb $1 << VCPU_TRAP_NMI, VCPU_async_exception_mask(%rbx)
         jnz  test_guest_events
         sti
@@ -139,11 +135,12 @@ process_trap:
         leaq VCPU_trap_bounce(%rbx), %rdx
         call create_bounce_frame
         jmp  test_all_events
+END(switch_to_kernel)
 
         .section .text.entry, "ax", @progbits
 
 /* %rbx: struct vcpu, interrupts disabled */
-restore_all_guest:
+FUNC_LOCAL(restore_all_guest)
         ASSERT_INTERRUPTS_DISABLED
 
         /* Stash guest SPEC_CTRL value while we can read struct vcpu. */
@@ -220,8 +217,7 @@ restore_all_guest:
         sysretq
 1:      sysretl
 
-        ALIGN
-.Lrestore_rcx_iret_exit_to_guest:
+LABEL_LOCAL(.Lrestore_rcx_iret_exit_to_guest)
         movq  8(%rsp), %rcx           # RIP
 /* No special register assumptions. */
 iret_exit_to_guest:
@@ -230,6 +226,7 @@ iret_exit_to_guest:
         addq  $8,%rsp
 .Lft0:  iretq
         _ASM_PRE_EXTABLE(.Lft0, handle_exception)
+END(restore_all_guest)
 
 /*
  * When entering SYSCALL from kernel mode:
@@ -246,7 +243,7 @@ iret_exit_to_guest:
  *  - Guest %rsp stored in %rax
  *  - Xen stack loaded, pointing at the %ss slot
  */
-ENTRY(lstar_enter)
+FUNC(lstar_enter)
 #ifdef CONFIG_XEN_SHSTK
         ALTERNATIVE "", "setssbsy", X86_FEATURE_XEN_SHSTK
 #endif
@@ -281,9 +278,10 @@ ENTRY(lstar_enter)
         mov   %rsp, %rdi
         call  pv_hypercall
         jmp   test_all_events
+END(lstar_enter)
 
 /* See lstar_enter for entry register state. */
-ENTRY(cstar_enter)
+FUNC(cstar_enter)
 #ifdef CONFIG_XEN_SHSTK
         ALTERNATIVE "", "setssbsy", X86_FEATURE_XEN_SHSTK
 #endif
@@ -321,8 +319,9 @@ ENTRY(cstar_enter)
         jne   compat_syscall
 #endif
         jmp   switch_to_kernel
+END(cstar_enter)
 
-ENTRY(sysenter_entry)
+FUNC(sysenter_entry)
         ENDBR64
 #ifdef CONFIG_XEN_SHSTK
         ALTERNATIVE "", "setssbsy", X86_FEATURE_XEN_SHSTK
@@ -330,7 +329,7 @@ ENTRY(sysenter_entry)
         pushq $FLAT_USER_SS
         pushq $0
         pushfq
-GLOBAL(sysenter_eflags_saved)
+LABEL(sysenter_eflags_saved, 0)
         ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
         pushq $3 /* ring 3 null cs */
         pushq $0 /* null rip */
@@ -384,8 +383,9 @@ UNLIKELY_END(sysenter_gpf)
         jne   compat_sysenter
 #endif
         jmp   .Lbounce_exception
+END(sysenter_entry)
 
-ENTRY(entry_int80)
+FUNC(entry_int80)
         ENDBR64
         ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
         pushq $0
@@ -473,6 +473,7 @@ int80_slow_path:
          */
         GET_STACK_END(14)
         jmp   handle_exception_saved
+END(entry_int80)
 
         /* create_bounce_frame & helpers don't need to be in .text.entry */
         .text
@@ -481,7 +482,7 @@ int80_slow_path:
 /*   { RCX, R11, [ERRCODE,] RIP, CS, RFLAGS, RSP, SS }                   */
 /* %rdx: trap_bounce, %rbx: struct vcpu                                  */
 /* On return only %rbx and %rdx are guaranteed non-clobbered.            */
-create_bounce_frame:
+FUNC_LOCAL(create_bounce_frame)
         ASSERT_INTERRUPTS_ENABLED
         testb $TF_kernel_mode,VCPU_thread_flags(%rbx)
         jnz   1f
@@ -617,6 +618,7 @@ ENTRY(dom_crash_sync_extable)
         xorl  %edi,%edi
         jmp   asm_domain_crash_synchronous /* Does not return */
         .popsection
+END(create_bounce_frame)
 #endif /* CONFIG_PV */
 
 /* --- CODE BELOW THIS LINE (MOSTLY) NOT GUEST RELATED --- */
@@ -625,7 +627,7 @@ ENTRY(dom_crash_sync_extable)
 
 /* No special register assumptions. */
 #ifdef CONFIG_PV
-ENTRY(continue_pv_domain)
+FUNC(continue_pv_domain)
         ENDBR64
         call  check_wakeup_from_wait
 ret_from_intr:
@@ -640,26 +642,28 @@ ret_from_intr:
 #else
         jmp   test_all_events
 #endif
+END(continue_pv_domain)
 #else
-ret_from_intr:
+FUNC_LOCAL(ret_from_intr, 0)
         ASSERT_CONTEXT_IS_XEN
         jmp   restore_all_xen
+END(ret_from_intr)
 #endif
 
         .section .init.text, "ax", @progbits
-ENTRY(early_page_fault)
+FUNC(early_page_fault)
         ENDBR64
         movl  $X86_EXC_PF, 4(%rsp)
         SAVE_ALL
         movq  %rsp, %rdi
         call  do_early_page_fault
         jmp   restore_all_xen
+END(early_page_fault)
 
         .section .text.entry, "ax", @progbits
 
-        ALIGN
 /* %r12=ist_exit */
-restore_all_xen:
+FUNC_LOCAL(restore_all_xen)
 
 #ifdef CONFIG_DEBUG
         mov   %rsp, %rdi
@@ -683,8 +687,9 @@ UNLIKELY_END(exit_cr3)
 
         RESTORE_ALL adj=8
         iretq
+END(restore_all_xen)
 
-ENTRY(common_interrupt)
+FUNC(common_interrupt)
         ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
         SAVE_ALL
 
@@ -713,12 +718,14 @@ ENTRY(common_interrupt)
         mov   %r15, STACK_CPUINFO_FIELD(xen_cr3)(%r14)
         mov   %bl, STACK_CPUINFO_FIELD(use_pv_cr3)(%r14)
         jmp ret_from_intr
+END(common_interrupt)
 
-ENTRY(entry_PF)
+FUNC(entry_PF)
         ENDBR64
         movl  $X86_EXC_PF, 4(%rsp)
+END(entry_PF)
 /* No special register assumptions. */
-GLOBAL(handle_exception)
+FUNC(handle_exception, 0)
         ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
         SAVE_ALL
 
@@ -886,92 +893,108 @@ FATAL_exception_with_ints_disabled:
         xorl  %esi,%esi
         movq  %rsp,%rdi
         tailcall fatal_trap
+END(handle_exception)
 
-ENTRY(entry_DE)
+FUNC(entry_DE)
         ENDBR64
         pushq $0
         movl  $X86_EXC_DE, 4(%rsp)
         jmp   handle_exception
+END(entry_DE)
 
-ENTRY(entry_MF)
+FUNC(entry_MF)
         ENDBR64
         pushq $0
         movl  $X86_EXC_MF, 4(%rsp)
         jmp   handle_exception
+END(entry_MF)
 
-ENTRY(entry_XM)
+FUNC(entry_XM)
         ENDBR64
         pushq $0
         movl  $X86_EXC_XM, 4(%rsp)
         jmp   handle_exception
+END(entry_XM)
 
-ENTRY(entry_NM)
+FUNC(entry_NM)
         ENDBR64
         pushq $0
         movl  $X86_EXC_NM, 4(%rsp)
         jmp   handle_exception
+END(entry_NM)
 
-ENTRY(entry_DB)
+FUNC(entry_DB)
         ENDBR64
         pushq $0
         movl  $X86_EXC_DB, 4(%rsp)
         jmp   handle_ist_exception
+END(entry_DB)
 
-ENTRY(entry_BP)
+FUNC(entry_BP)
         ENDBR64
         pushq $0
         movl  $X86_EXC_BP, 4(%rsp)
         jmp   handle_exception
+END(entry_BP)
 
-ENTRY(entry_OF)
+FUNC(entry_OF)
         ENDBR64
         pushq $0
         movl  $X86_EXC_OF, 4(%rsp)
         jmp   handle_exception
+END(entry_OF)
 
-ENTRY(entry_BR)
+FUNC(entry_BR)
         ENDBR64
         pushq $0
         movl  $X86_EXC_BR, 4(%rsp)
         jmp   handle_exception
+END(entry_BR)
 
-ENTRY(entry_UD)
+FUNC(entry_UD)
         ENDBR64
         pushq $0
         movl  $X86_EXC_UD, 4(%rsp)
         jmp   handle_exception
+END(entry_UD)
 
-ENTRY(entry_TS)
+FUNC(entry_TS)
         ENDBR64
         movl  $X86_EXC_TS, 4(%rsp)
         jmp   handle_exception
+END(entry_TS)
 
-ENTRY(entry_NP)
+FUNC(entry_NP)
         ENDBR64
         movl  $X86_EXC_NP, 4(%rsp)
         jmp   handle_exception
+END(entry_NP)
 
-ENTRY(entry_SS)
+FUNC(entry_SS)
         ENDBR64
         movl  $X86_EXC_SS, 4(%rsp)
         jmp   handle_exception
+END(entry_SS)
 
-ENTRY(entry_GP)
+FUNC(entry_GP)
         ENDBR64
         movl  $X86_EXC_GP, 4(%rsp)
         jmp   handle_exception
+END(entry_GP)
 
-ENTRY(entry_AC)
+FUNC(entry_AC)
         ENDBR64
         movl  $X86_EXC_AC, 4(%rsp)
         jmp   handle_exception
+END(entry_AC)
 
-ENTRY(entry_CP)
+FUNC(entry_CP)
         ENDBR64
         movl  $X86_EXC_CP, 4(%rsp)
         jmp   handle_exception
+END(entry_CP)
 
-ENTRY(entry_DF)
+FUNC(entry_DF)
         ENDBR64
         movl  $X86_EXC_DF, 4(%rsp)
         /* Set AC to reduce chance of further SMAP faults */
@@ -994,8 +1017,9 @@ ENTRY(entry_DF)
 
         movq  %rsp,%rdi
         tailcall do_double_fault
+END(entry_DF)
 
-ENTRY(entry_NMI)
+FUNC(entry_NMI)
         ENDBR64
         pushq $0
         movl  $X86_EXC_NMI, 4(%rsp)
@@ -1126,21 +1150,24 @@ handle_ist_exception:
         ASSERT_CONTEXT_IS_XEN
         jmp   restore_all_xen
 #endif
+END(entry_NMI)
 
-ENTRY(entry_MC)
+FUNC(entry_MC)
         ENDBR64
         pushq $0
         movl  $X86_EXC_MC, 4(%rsp)
         jmp   handle_ist_exception
+END(entry_MC)
 
 /* No op trap handler.  Required for kexec crash path. */
-GLOBAL(trap_nop)
+FUNC(trap_nop, 0)
         ENDBR64
         iretq
+END(trap_nop)
 
 /* Table of automatically generated entry points.  One per vector. */
         .pushsection .init.rodata, "a", @progbits
-GLOBAL(autogen_entrypoints)
+DATA(autogen_entrypoints, 8)
         /* pop into the .init.rodata section and record an entry point. */
         .macro entrypoint ent
         .pushsection .init.rodata, "a", @progbits
@@ -1149,7 +1176,7 @@ GLOBAL(autogen_entrypoints)
         .endm
 
         .popsection
-autogen_stubs: /* Automatically generated stubs. */
+FUNC_LOCAL(autogen_stubs, 0) /* Automatically generated stubs. */
 
         vec = 0
         .rept X86_NR_VECTORS
@@ -1193,6 +1220,7 @@ autogen_stubs: /* Automatically generated stubs. */
 
         vec = vec + 1
         .endr
+END(autogen_stubs)
 
         .section .init.rodata, "a", @progbits
-        .size autogen_entrypoints, . - autogen_entrypoints
+END(autogen_entrypoints)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 23 01:56:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 23 Jan 2024 01:56:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.670240.1042857 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS61O-00043n-I6; Tue, 23 Jan 2024 01:56:14 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 670240.1042857; Tue, 23 Jan 2024 01:56:14 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS61O-00043f-F8; Tue, 23 Jan 2024 01:56:14 +0000
Received: by outflank-mailman (input) for mailman id 670240;
 Tue, 23 Jan 2024 01: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 1rS61M-00043V-UA
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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 1rS61M-0000rF-TQ
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01:56:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rS61M-0001WJ-Sj
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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=uYuitIdUH0wPXFi+KkBbE0FcPd89FBzOYQ4i1Fc5Kms=; b=Vbus6sbCwwZA/kIEBdFexZqRGL
	xtnYhdBVdHXo1m2TcJ4ZYaOpknNpKciHCSV3qNvEHD4j8nYoKhIMAEOR6QLzS04dfSvkKY9O/gTvH
	466p+7jZp1kl7mPYB7ObucBZ8uq1BbAY6OICyeD4e4os/bpvLHhLqI6imjmtLiFM7KYM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86: also mark assembler globals hidden
Message-Id: <E1rS61M-0001WJ-Sj@xenbits.xenproject.org>
Date: Tue, 23 Jan 2024 01:56:12 +0000

commit 9de79317e844de8eaa28408f88c6b5a4ee177d20
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 22 13:52:13 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 22 13:52:13 2024 +0100

    x86: also mark assembler globals hidden
    
    Let's have assembler symbols be consistent with C ones. In principle
    there are (a few) cases where gas can produce smaller code this way,
    just that for now there's a gas bug causing smaller code to be emitted
    even when that shouldn't be the case.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/include/asm/config.h | 4 ++--
 xen/include/xen/linkage.h         | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/include/asm/config.h b/xen/arch/x86/include/asm/config.h
index 9eab23b6b9..660246d1da 100644
--- a/xen/arch/x86/include/asm/config.h
+++ b/xen/arch/x86/include/asm/config.h
@@ -47,11 +47,11 @@
 #define CODE_FILL 0x90
 #define ALIGN .align CODE_ALIGN, CODE_FILL
 #define ENTRY(name)                             \
-  .globl name;                                  \
   ALIGN;                                        \
-  name:
+  GLOBAL(name)
 #define GLOBAL(name)                            \
   .globl name;                                  \
+  .hidden name;                                 \
   name:
 #endif
 
diff --git a/xen/include/xen/linkage.h b/xen/include/xen/linkage.h
index 52fe4dfa65..b0f1fa2e09 100644
--- a/xen/include/xen/linkage.h
+++ b/xen/include/xen/linkage.h
@@ -19,7 +19,7 @@
 
 #define SYM_ALIGN(align...) .balign align
 
-#define SYM_L_GLOBAL(name) .globl name
+#define SYM_L_GLOBAL(name) .globl name; .hidden name
 #define SYM_L_WEAK(name)   .weak name
 #define SYM_L_LOCAL(name)  /* nothing */
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 23 01:56:24 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 23 Jan 2024 01:56:24 +0000
Received: from list by lists.xenproject.org with outflank-mailman.670241.1042861 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS61Y-00046a-Jd; Tue, 23 Jan 2024 01:56:24 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 670241.1042861; Tue, 23 Jan 2024 01:56:24 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS61Y-00046P-Gi; Tue, 23 Jan 2024 01:56:24 +0000
Received: by outflank-mailman (input) for mailman id 670241;
 Tue, 23 Jan 2024 01:56:23 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rS61X-00046J-0o
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01:56:23 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rS61X-0000rP-02
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01:56:23 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rS61W-0001Wp-VS
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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=bDQON8D6f0n/2chEUHNxTBw9jKJha/BMPeZTWf8H9GU=; b=KA5vc/ebYaK4iRlwccKdGwBjl7
	XMKCZ1zisNyJpIyCESUcQvocFy2LV8/0MW1OmBx1vntASl3bOdNQWHqSdvy0CcELaFuoMRaWCsLW5
	zYEIcCmsIvePanksWdGDEHAE9VAsBv0vfL7EU5eg1VZB+boDjiGSmO1ZDAoQntn3mLFQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] Arm: annotate entry points with type and size
Message-Id: <E1rS61W-0001Wp-VS@xenbits.xenproject.org>
Date: Tue, 23 Jan 2024 01:56:22 +0000

commit ae08d0c30498b2b3fa521ab7db102297a3630823
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 22 13:54:34 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 22 13:54:34 2024 +0100

    Arm: annotate entry points with type and size
    
    Use the generic framework in xen/linkage.h. No change in generated code
    except for the changed padding value (noticable when config.gz isn't a
    multiple of 4 in size). Plus of course the converted symbols change to
    be hidden ones.
    
    Note that ASM_INT() is switched to DATA(), not DATA_LOCAL(), as the only
    use site wants the symbol global anyway.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/arm32/lib/div64.S       | 4 ++--
 xen/arch/arm/arm64/lib/clear_page.S  | 4 ++--
 xen/arch/arm/include/asm/asm_defns.h | 6 ++----
 xen/arch/arm/include/asm/config.h    | 5 ++---
 4 files changed, 8 insertions(+), 11 deletions(-)

diff --git a/xen/arch/arm/arm32/lib/div64.S b/xen/arch/arm/arm32/lib/div64.S
index 58a52a7740..368e884af4 100644
--- a/xen/arch/arm/arm32/lib/div64.S
+++ b/xen/arch/arm/arm32/lib/div64.S
@@ -42,7 +42,7 @@
  * Clobbered regs: xl, ip
  */
 
-ENTRY(__do_div64)
+FUNC(__do_div64)
 UNWIND(.fnstart)
 
 	@ Test for easy paths first.
@@ -206,4 +206,4 @@ Ldiv0_64:
 	ldr	pc, [sp], #8
 
 UNWIND(.fnend)
-ENDPROC(__do_div64)
+END(__do_div64)
diff --git a/xen/arch/arm/arm64/lib/clear_page.S b/xen/arch/arm/arm64/lib/clear_page.S
index a767e63686..57e39f1cbb 100644
--- a/xen/arch/arm/arm64/lib/clear_page.S
+++ b/xen/arch/arm/arm64/lib/clear_page.S
@@ -22,7 +22,7 @@
  * Parameters:
  *	x0 - dest
  */
-ENTRY(clear_page)
+FUNC(clear_page)
 	mrs	x1, dczid_el0
 	and	w1, w1, #0xf
 	mov	x2, #4
@@ -33,4 +33,4 @@ ENTRY(clear_page)
 	tst	x0, #(PAGE_SIZE - 1)
 	b.ne	1b
 	ret
-ENDPROC(clear_page)
+END(clear_page)
diff --git a/xen/arch/arm/include/asm/asm_defns.h b/xen/arch/arm/include/asm/asm_defns.h
index eecafd3b39..c489547d29 100644
--- a/xen/arch/arm/include/asm/asm_defns.h
+++ b/xen/arch/arm/include/asm/asm_defns.h
@@ -5,6 +5,7 @@
 /* NB. Auto-generated from arch/.../asm-offsets.c */
 #include <asm/asm-offsets.h>
 #endif
+#include <xen/linkage.h>
 #include <asm/processor.h>
 
 /* Macros for generic assembly code */
@@ -28,10 +29,7 @@ label:  .asciz msg;                             \
 .popsection
 
 #define ASM_INT(label, val)                 \
-    .p2align 2;                             \
-label: .long (val);                         \
-    .size label, . - label;                 \
-    .type label, %object
+    DATA(label, 4) .long (val); END(label)
 
 #endif /* __ARM_ASM_DEFNS_H__ */
 /*
diff --git a/xen/arch/arm/include/asm/config.h b/xen/arch/arm/include/asm/config.h
index e1dcec4dd7..3b6d829197 100644
--- a/xen/arch/arm/include/asm/config.h
+++ b/xen/arch/arm/include/asm/config.h
@@ -53,7 +53,8 @@
 
 /* Linkage for ARM */
 #ifdef __ASSEMBLY__
-#define ALIGN .align 2
+#define CODE_ALIGN 4
+#define ALIGN .balign CODE_ALIGN
 #define ENTRY(name)                             \
   .globl name;                                  \
   ALIGN;                                        \
@@ -61,8 +62,6 @@
 #define GLOBAL(name)                            \
   .globl name;                                  \
   name:
-#define END(name) \
-  .size name, .-name
 #define ENDPROC(name) \
   .type name, %function; \
   END(name)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 23 01:56:34 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 23 Jan 2024 01:56:34 +0000
Received: from list by lists.xenproject.org with outflank-mailman.670242.1042864 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS61i-000490-Kh; Tue, 23 Jan 2024 01:56:34 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 670242.1042864; Tue, 23 Jan 2024 01:56:34 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS61i-00048t-IF; Tue, 23 Jan 2024 01:56:34 +0000
Received: by outflank-mailman (input) for mailman id 670242;
 Tue, 23 Jan 2024 01:56:33 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rS61h-00048i-56
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01:56:33 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rS61h-0000rW-3A
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01:56:33 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rS61h-0001XE-2I
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01:56:33 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=7zaIgmPf4X6Uy72gJZ4NSjpms6OXvgwp6LQDUQbPhS8=; b=ib/nCiqXM+zTKtMgjJSFaoUpXQ
	oNSGmhnpuGvBienH5BL1DPPXClIiGLLk9a30wVsLCuEQXmTHlLmWAh8ofOsOwf3VsQzSr8dP4boSn
	6hYoTma+nwZyCB02cnQbpPWjh9a3uo1JYFvxPEJ1/UqdLCmz+thoie7ELhv7HHwK2Ut0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] RISC-V: annotate entry points with type and size
Message-Id: <E1rS61h-0001XE-2I@xenbits.xenproject.org>
Date: Tue, 23 Jan 2024 01:56:33 +0000

commit 7015f337a217af151cb38d9da0d888c1aee18d15
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 22 13:55:11 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 22 13:55:11 2024 +0100

    RISC-V: annotate entry points with type and size
    
    Use the generic framework in xen/linkage.h. No change in generated code
    except of course the converted symbols change to be hidden ones and gain
    a valid size.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
---
 xen/arch/riscv/entry.S              |  3 ++-
 xen/arch/riscv/include/asm/asm.h    |  1 +
 xen/arch/riscv/include/asm/config.h |  8 ++------
 xen/arch/riscv/riscv64/head.S       |  9 ++++++---
 xen/arch/riscv/xen.lds.S            |  3 ---
 xen/include/xen/linkage.h           | 19 +++++++++++++++----
 6 files changed, 26 insertions(+), 17 deletions(-)

diff --git a/xen/arch/riscv/entry.S b/xen/arch/riscv/entry.S
index 0be543f8e0..bf974655f8 100644
--- a/xen/arch/riscv/entry.S
+++ b/xen/arch/riscv/entry.S
@@ -5,7 +5,7 @@
 #include <asm/traps.h>
 
 /* WIP: only works while interrupting Xen context */
-ENTRY(handle_trap)
+FUNC(handle_trap)
 
     /* Exceptions from xen */
 save_to_stack:
@@ -92,3 +92,4 @@ restore_registers:
         REG_L   sp, CPU_USER_REGS_SP(sp)
 
         sret
+END(handle_trap)
diff --git a/xen/arch/riscv/include/asm/asm.h b/xen/arch/riscv/include/asm/asm.h
index 6d426ecea7..87a3fd250b 100644
--- a/xen/arch/riscv/include/asm/asm.h
+++ b/xen/arch/riscv/include/asm/asm.h
@@ -7,6 +7,7 @@
 #define _ASM_RISCV_ASM_H
 
 #ifdef __ASSEMBLY__
+#include <xen/linkage.h>
 #define __ASM_STR(x)	x
 #else
 #define __ASM_STR(x)	#x
diff --git a/xen/arch/riscv/include/asm/config.h b/xen/arch/riscv/include/asm/config.h
index f0544c6a20..a80cdd4f85 100644
--- a/xen/arch/riscv/include/asm/config.h
+++ b/xen/arch/riscv/include/asm/config.h
@@ -69,12 +69,8 @@
 
 /* Linkage for RISCV */
 #ifdef __ASSEMBLY__
-#define ALIGN .align 4
-
-#define ENTRY(name)                                \
-  .globl name;                                     \
-  ALIGN;                                           \
-  name:
+#define CODE_ALIGN 16
+#define CODE_FILL /* empty */
 #endif
 
 #ifdef CONFIG_RISCV_64
diff --git a/xen/arch/riscv/riscv64/head.S b/xen/arch/riscv/riscv64/head.S
index b6ce2894ab..3261e9fce8 100644
--- a/xen/arch/riscv/riscv64/head.S
+++ b/xen/arch/riscv/riscv64/head.S
@@ -8,7 +8,7 @@
          *   a0 -> hart_id ( bootcpu_id )
          *   a1 -> dtb_base 
          */
-ENTRY(start)
+FUNC(start)
         /* Mask all interrupts */
         csrw    CSR_SIE, zero
 
@@ -60,19 +60,21 @@ ENTRY(start)
         mv      a1, s1
 
         tail    start_xen
+END(start)
 
         .section .text, "ax", %progbits
 
-ENTRY(reset_stack)
+FUNC(reset_stack)
         la      sp, cpu0_boot_stack
         li      t0, STACK_SIZE
         add     sp, sp, t0
 
         ret
+END(reset_stack)
 
         .section .text.ident, "ax", %progbits
 
-ENTRY(turn_on_mmu)
+FUNC(turn_on_mmu)
         sfence.vma
 
         li      t0, RV_STAGE1_MODE
@@ -84,3 +86,4 @@ ENTRY(turn_on_mmu)
         csrw    CSR_SATP, t1
 
         jr      a0
+END(turn_on_mmu)
diff --git a/xen/arch/riscv/xen.lds.S b/xen/arch/riscv/xen.lds.S
index a10e0ad87c..8510a87c4d 100644
--- a/xen/arch/riscv/xen.lds.S
+++ b/xen/arch/riscv/xen.lds.S
@@ -1,9 +1,6 @@
 #include <xen/lib.h>
 #include <xen/xen.lds.h>
 
-#undef ENTRY
-#undef ALIGN
-
 OUTPUT_ARCH(riscv)
 ENTRY(start)
 
diff --git a/xen/include/xen/linkage.h b/xen/include/xen/linkage.h
index b0f1fa2e09..0997e16810 100644
--- a/xen/include/xen/linkage.h
+++ b/xen/include/xen/linkage.h
@@ -35,17 +35,28 @@
 
 #define END(name) .size name, . - name
 
+/*
+ * CODE_FILL in particular may need to expand to nothing (e.g. for RISC-V), in
+ * which case we also need to get rid of the comma in the .balign directive.
+ */
+#define count_args_exp(args...) count_args(args)
+#if count_args_exp(CODE_FILL)
+# define DO_CODE_ALIGN(align...) LASTARG(CODE_ALIGN, ## align), CODE_FILL
+#else
+# define DO_CODE_ALIGN(align...) LASTARG(CODE_ALIGN, ## align)
+#endif
+
 #define FUNC(name, align...) \
-        SYM(name, FUNC, GLOBAL, LASTARG(CODE_ALIGN, ## align), CODE_FILL)
+        SYM(name, FUNC, GLOBAL, DO_CODE_ALIGN(align))
 #define LABEL(name, align...) \
-        SYM(name, NONE, GLOBAL, LASTARG(CODE_ALIGN, ## align), CODE_FILL)
+        SYM(name, NONE, GLOBAL, DO_CODE_ALIGN(align))
 #define DATA(name, align...) \
         SYM(name, DATA, GLOBAL, LASTARG(DATA_ALIGN, ## align), DATA_FILL)
 
 #define FUNC_LOCAL(name, align...) \
-        SYM(name, FUNC, LOCAL, LASTARG(CODE_ALIGN, ## align), CODE_FILL)
+        SYM(name, FUNC, LOCAL, DO_CODE_ALIGN(align))
 #define LABEL_LOCAL(name, align...) \
-        SYM(name, NONE, LOCAL, LASTARG(CODE_ALIGN, ## align), CODE_FILL)
+        SYM(name, NONE, LOCAL, DO_CODE_ALIGN(align))
 #define DATA_LOCAL(name, align...) \
         SYM(name, DATA, LOCAL, LASTARG(DATA_ALIGN, ## align), DATA_FILL)
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 23 01:56:44 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 23 Jan 2024 01:56:44 +0000
Received: from list by lists.xenproject.org with outflank-mailman.670243.1042868 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rS61s-0004Br-M7; Tue, 23 Jan 2024 01:56:44 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 670243.1042868; Tue, 23 Jan 2024 01: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 1rS61s-0004Bk-Jg; Tue, 23 Jan 2024 01:56:44 +0000
Received: by outflank-mailman (input) for mailman id 670243;
 Tue, 23 Jan 2024 01: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 1rS61r-0004BX-6t
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01: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 1rS61r-0000rg-66
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01:56:43 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rS61r-0001Xf-5F
 for xen-changelog@lists.xenproject.org; Tue, 23 Jan 2024 01:56:43 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=/qNro9qfGsuHA20bNTa/Wic87oK42AvKxvBPSc7lpkU=; b=29XR5cS2u8KnWUWHIdIGyn3UXD
	MMpeW4VR/AijoiQqJknsXXPQ9ErmNX1KjHWI4J4hLfHnG9xguIhOFkhntHLOzg64PHiEPozK3x71h
	vPcxHZDf/wh3VgoUo9YC+nVtTFCyysCXYDiGJ9fvkQLGj7T21ElphNlYCOZaLzAmRIjc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools/binfile: switch to common annotations model
Message-Id: <E1rS61r-0001Xf-5F@xenbits.xenproject.org>
Date: Tue, 23 Jan 2024 01:56:43 +0000

commit 4900c939cb9b876c51cfc7a4c854f54c722a30b5
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 22 13:55:38 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 22 13:55:38 2024 +0100

    tools/binfile: switch to common annotations model
    
    Use DATA() / END() and drop the now redundant .global. No change in
    generated data; of course the two symbols now properly gain "hidden"
    binding.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/tools/binfile | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/xen/tools/binfile b/xen/tools/binfile
index 23099c49bf..099d7eda9a 100755
--- a/xen/tools/binfile
+++ b/xen/tools/binfile
@@ -29,15 +29,10 @@ cat <<EOF >$target
 
         .section $section.rodata, "a", %progbits
 
-        .p2align $align
-        .global $varname
-$varname:
+DATA($varname, 1 << $align)
         .incbin "$binsource"
 .Lend:
+END($varname)
 
-        .type $varname, %object
-        .size $varname, .Lend - $varname
-
-        .global ${varname}_size
         ASM_INT(${varname}_size, .Lend - $varname)
 EOF
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Jan 24 08:55:09 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 24 Jan 2024 08:55:09 +0000
Received: from list by lists.xenproject.org with outflank-mailman.670812.1043831 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rSZ2F-0006aY-LE; Wed, 24 Jan 2024 08:55:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 670812.1043831; Wed, 24 Jan 2024 08: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 1rSZ2F-0006aR-IW; Wed, 24 Jan 2024 08:55:03 +0000
Received: by outflank-mailman (input) for mailman id 670812;
 Wed, 24 Jan 2024 08: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 1rSZ2E-0006aL-Ej
 for xen-changelog@lists.xenproject.org; Wed, 24 Jan 2024 08: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 1rSZ2E-00084U-4E
 for xen-changelog@lists.xenproject.org; Wed, 24 Jan 2024 08:55:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rSZ2E-0007gu-38
 for xen-changelog@lists.xenproject.org; Wed, 24 Jan 2024 08: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=jqAyKVpe+2/44qCoEtvs3VJnW32lDNJDqyP4VqWbB44=; b=QKo/Ni0P/Pd2lG9gumynbzvxMf
	XY1UUzHJUvPn4veBIncZdwIOGfsh7/k9NrHIRU7EliWBkP8WoodJoHQm0kmCNL9E4t7SQ9EZ75r2o
	dzNEyBplw9Cz/IMocpZEPhAhj4PzRC3cE5Vx9BZb8IYGU48f/oloRCVCp8ChzZIlCzRY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] PPC: switch entry point annotations to common model
Message-Id: <E1rSZ2E-0007gu-38@xenbits.xenproject.org>
Date: Wed, 24 Jan 2024 08:55:02 +0000

commit 2cfdbd58638255b08b4f9b319402bdf09fc832e2
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Jan 23 12:02:05 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Jan 23 12:02:05 2024 +0100

    PPC: switch entry point annotations to common model
    
    Use the generic framework in xen/linkage.h. No change in generated code
    except of course the converted symbols change to be hidden ones.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Shawn Anastasio <sanastasio@raptorengineering.com>
---
 xen/arch/ppc/include/asm/asm-defns.h |  1 +
 xen/arch/ppc/include/asm/config.h    |  7 +------
 xen/arch/ppc/ppc64/exceptions-asm.S  | 15 ++++++---------
 xen/arch/ppc/ppc64/head.S            | 12 ++++--------
 xen/arch/ppc/xen.lds.S               |  3 ---
 5 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/xen/arch/ppc/include/asm/asm-defns.h b/xen/arch/ppc/include/asm/asm-defns.h
index f1c49808bd..e46f0785ad 100644
--- a/xen/arch/ppc/include/asm/asm-defns.h
+++ b/xen/arch/ppc/include/asm/asm-defns.h
@@ -3,6 +3,7 @@
 #define _ASM_PPC_ASM_DEFNS_H
 
 #include <asm/asm-offsets.h>
+#include <xen/linkage.h>
 
 /*
  * Load a 64-bit immediate value into the specified GPR.
diff --git a/xen/arch/ppc/include/asm/config.h b/xen/arch/ppc/include/asm/config.h
index e012b75beb..e5d201e16c 100644
--- a/xen/arch/ppc/include/asm/config.h
+++ b/xen/arch/ppc/include/asm/config.h
@@ -32,12 +32,7 @@
 
 /* Linkage for PPC */
 #ifdef __ASSEMBLY__
-#define ALIGN .p2align 2
-
-#define ENTRY(name)                                                            \
-    .globl name;                                                               \
-    ALIGN;                                                                     \
-    name:
+#define CODE_ALIGN 4
 #endif
 
 #define XEN_VIRT_START _AC(0xc000000000000000, UL)
diff --git a/xen/arch/ppc/ppc64/exceptions-asm.S b/xen/arch/ppc/ppc64/exceptions-asm.S
index fa5f45add8..5c3d39b439 100644
--- a/xen/arch/ppc/ppc64/exceptions-asm.S
+++ b/xen/arch/ppc/ppc64/exceptions-asm.S
@@ -6,7 +6,7 @@
     .section .text.exceptions, "ax", %progbits
 
     /* Helper to dump CPU state to struct cpu_user_regs pointed to by r1. */
-ENTRY(exception_common)
+FUNC(exception_common)
     /*
      * Save GPRs 1-31. TODO: The value of %r1 has already been modified by the
      * ISR, so the value we save isn't the exact value we had on entry.
@@ -45,11 +45,10 @@ ENTRY(exception_common)
     stdu    %r0, -STACK_FRAME_OVERHEAD(%r1)
     bl      exception_handler
 
-    .size exception_common, . - exception_common
-    .type exception_common, %function
+    END(exception_common)
 
     /* Same as exception_common, but for exceptions that set HSRR{0,1} */
-ENTRY(h_exception_common)
+FUNC(h_exception_common)
     /*
      * Save GPRs 1-31. TODO: The value of %r1 has already been modified by the
      * ISR, so the value we save isn't the exact value we had on entry.
@@ -89,15 +88,14 @@ ENTRY(h_exception_common)
     stdu    %r0, -STACK_FRAME_OVERHEAD(%r1)
     bl      exception_handler
 
-    .size h_exception_common, . - h_exception_common
-    .type h_exception_common, %function
+    END(h_exception_common)
 
 /*
  * Declare an ISR for the provided exception that jumps to the specified handler
  */
 .macro ISR name, exc, handler
     . = (AIL_VECTOR_BASE - EXCEPTION_VECTORS_START) + \exc
-    ENTRY(\name)
+    FUNC(\name)
     /* TODO: switch stack */
 
     /* Reserve space for struct cpu_user_regs */
@@ -113,8 +111,7 @@ ENTRY(h_exception_common)
     /* Branch to common code */
     b       \handler
 
-    .size \name, . - \name
-    .type \name, %function
+    END(\name)
 .endm
 
 /*
diff --git a/xen/arch/ppc/ppc64/head.S b/xen/arch/ppc/ppc64/head.S
index 6ce313aff8..89553154a5 100644
--- a/xen/arch/ppc/ppc64/head.S
+++ b/xen/arch/ppc/ppc64/head.S
@@ -6,7 +6,7 @@
 
     .section .text.header, "ax", %progbits
 
-ENTRY(start)
+FUNC(start)
     /*
      * NOTE: argument registers (r3-r9) must be preserved until the C entrypoint
      */
@@ -64,11 +64,9 @@ ENTRY(start)
 
     /* should never return */
     trap
+END(start)
 
-    .size start, . - start
-    .type start, %function
-
-ENTRY(enable_mmu)
+FUNC(enable_mmu)
     mflr %r3
     mfmsr %r4
 
@@ -78,6 +76,4 @@ ENTRY(enable_mmu)
     mtsrr0 %r3 /* return to caller after MMU enable */
     mtsrr1 %r4
     rfid
-
-    .size enable_mmu, . - enable_mmu
-    .type enable_mmu, %function
+END(enable_mmu)
diff --git a/xen/arch/ppc/xen.lds.S b/xen/arch/ppc/xen.lds.S
index 3697d656f4..030e1ee37b 100644
--- a/xen/arch/ppc/xen.lds.S
+++ b/xen/arch/ppc/xen.lds.S
@@ -1,9 +1,6 @@
 #include <xen/lib.h>
 #include <xen/xen.lds.h>
 
-#undef ENTRY
-#undef ALIGN
-
 OUTPUT_ARCH(powerpc:common64)
 ENTRY(start)
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Jan 24 08:55:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 24 Jan 2024 08:55:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.670813.1043836 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rSZ2P-0006cJ-Md; Wed, 24 Jan 2024 08:55:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 670813.1043836; Wed, 24 Jan 2024 08: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 1rSZ2P-0006cB-K2; Wed, 24 Jan 2024 08:55:13 +0000
Received: by outflank-mailman (input) for mailman id 670813;
 Wed, 24 Jan 2024 08: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 1rSZ2O-0006c3-8S
 for xen-changelog@lists.xenproject.org; Wed, 24 Jan 2024 08: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 1rSZ2O-00084Y-7e
 for xen-changelog@lists.xenproject.org; Wed, 24 Jan 2024 08:55:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rSZ2O-0007if-6O
 for xen-changelog@lists.xenproject.org; Wed, 24 Jan 2024 08: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=xSA2krewQiPlb7bQx0s6oPD99yN1KNHECmjgoePJknE=; b=X2Gsb/7kWQdYSvYLv6rGydUZzy
	yDiQ5fLVSpRlW2tf3N9+Wai2/5//poKotwMas2dL/KNxgHToQH1rT4w5Fxs8W8bB1NCSnANwuRHbA
	OMewEVXHmbgd0wFFXfLl576hwT8lkBROLGhUPgLC1Xi2aTysqkeF1t5ukFgFZXBzdH1I=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] lib{fdt,elf}: move lib{fdt,elf}-temp.o and their deps to $(targets)
Message-Id: <E1rSZ2O-0007if-6O@xenbits.xenproject.org>
Date: Wed, 24 Jan 2024 08:55:12 +0000

commit 79519fcfa0605bbf19d8c02b979af3a2c8afed68
Author:     Michal Orzel <michal.orzel@amd.com>
AuthorDate: Tue Jan 23 12:02:44 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Jan 23 12:02:44 2024 +0100

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

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


From xen-changelog-bounces@lists.xenproject.org Wed Jan 24 08:55:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 24 Jan 2024 08:55:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.670814.1043840 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rSZ2Z-0006f1-O3; Wed, 24 Jan 2024 08:55:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 670814.1043840; Wed, 24 Jan 2024 08: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 1rSZ2Z-0006et-LV; Wed, 24 Jan 2024 08:55:23 +0000
Received: by outflank-mailman (input) for mailman id 670814;
 Wed, 24 Jan 2024 08: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 1rSZ2Y-0006eb-Bz
 for xen-changelog@lists.xenproject.org; Wed, 24 Jan 2024 08: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 1rSZ2Y-00084k-BB
 for xen-changelog@lists.xenproject.org; Wed, 24 Jan 2024 08:55:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rSZ2Y-0007jk-A4
 for xen-changelog@lists.xenproject.org; Wed, 24 Jan 2024 08: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=eVJnjaBCWYUK+S5lDnLmhbg0oPIfLhg/8HroRT+QoF8=; b=Zz614UGQ+vjKnehKY8CqGiggSB
	KwOiwyWd1cZtYocbDHFqcbL1+B3RxV/TFn7GTqTNQ7gFH89PdBldjGlGxoMh0FC1cG6fQbLrZ6jEm
	vAxk2a9jB1rhyJia5t5iiEP9nFCspGLeH0KvDKb9sHaq61SasXpZQmoybFUoem9D2LvA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] IRQ: generalize [gs]et_irq_regs()
Message-Id: <E1rSZ2Y-0007jk-A4@xenbits.xenproject.org>
Date: Wed, 24 Jan 2024 08:55:22 +0000

commit f67bddf3bccd99a5fee968c3b3f288db6a57d3be
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Jan 23 12:03:23 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Jan 23 12:03:23 2024 +0100

    IRQ: generalize [gs]et_irq_regs()
    
    Move functions (and their data) to common code, and invoke the functions
    on Arm as well. This is in preparation of dropping the register
    parameters from handler functions.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/irq.c             |  2 ++
 xen/arch/x86/include/asm/irq.h | 21 ---------------------
 xen/arch/x86/irq.c             |  2 --
 xen/common/irq.c               |  2 ++
 xen/include/xen/irq.h          | 21 +++++++++++++++++++++
 5 files changed, 25 insertions(+), 23 deletions(-)

diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index 1f05ecdee5..ae69fb4aeb 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -221,6 +221,7 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, int is_fiq)
 {
     struct irq_desc *desc = irq_to_desc(irq);
     struct irqaction *action;
+    struct cpu_user_regs *old_regs = set_irq_regs(regs);
 
     perfc_incr(irqs);
 
@@ -288,6 +289,7 @@ out:
 out_no_end:
     spin_unlock(&desc->lock);
     irq_exit();
+    set_irq_regs(old_regs);
 }
 
 void release_irq(unsigned int irq, const void *dev_id)
diff --git a/xen/arch/x86/include/asm/irq.h b/xen/arch/x86/include/asm/irq.h
index a87af47ece..6a93dc41d2 100644
--- a/xen/arch/x86/include/asm/irq.h
+++ b/xen/arch/x86/include/asm/irq.h
@@ -70,27 +70,6 @@ extern bool opt_noirqbalance;
 
 extern int opt_irq_vector_map;
 
-/*
- * Per-cpu current frame pointer - the location of the last exception frame on
- * the stack
- */
-DECLARE_PER_CPU(struct cpu_user_regs *, __irq_regs);
-
-static inline struct cpu_user_regs *get_irq_regs(void)
-{
-	return this_cpu(__irq_regs);
-}
-
-static inline struct cpu_user_regs *set_irq_regs(struct cpu_user_regs *new_regs)
-{
-	struct cpu_user_regs *old_regs, **pp_regs = &this_cpu(__irq_regs);
-
-	old_regs = *pp_regs;
-	*pp_regs = new_regs;
-	return old_regs;
-}
-
-
 #define platform_legacy_irq(irq)	((irq) < 16)
 
 void cf_check event_check_interrupt(struct cpu_user_regs *regs);
diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c
index 50e49e1a4b..bbae7751e4 100644
--- a/xen/arch/x86/irq.c
+++ b/xen/arch/x86/irq.c
@@ -53,8 +53,6 @@ static DEFINE_SPINLOCK(vector_lock);
 
 DEFINE_PER_CPU(vector_irq_t, vector_irq);
 
-DEFINE_PER_CPU(struct cpu_user_regs *, __irq_regs);
-
 static LIST_HEAD(irq_ratelimit_list);
 static DEFINE_SPINLOCK(irq_ratelimit_lock);
 static struct timer irq_ratelimit_timer;
diff --git a/xen/common/irq.c b/xen/common/irq.c
index 727cf8bd22..236cf171e2 100644
--- a/xen/common/irq.c
+++ b/xen/common/irq.c
@@ -1,6 +1,8 @@
 #include <xen/irq.h>
 #include <xen/errno.h>
 
+DEFINE_PER_CPU(struct cpu_user_regs *, irq_regs);
+
 int init_one_irq_desc(struct irq_desc *desc)
 {
     int err;
diff --git a/xen/include/xen/irq.h b/xen/include/xen/irq.h
index 0bdfe29576..76da442942 100644
--- a/xen/include/xen/irq.h
+++ b/xen/include/xen/irq.h
@@ -131,6 +131,27 @@ void cf_check irq_actor_none(struct irq_desc *desc);
 #define irq_disable_none irq_actor_none
 #define irq_enable_none irq_actor_none
 
+/*
+ * Per-cpu interrupted context register state - the inner-most interrupt frame
+ * on the stack.
+ */
+DECLARE_PER_CPU(struct cpu_user_regs *, irq_regs);
+
+static inline struct cpu_user_regs *get_irq_regs(void)
+{
+	return this_cpu(irq_regs);
+}
+
+static inline struct cpu_user_regs *set_irq_regs(struct cpu_user_regs *new_regs)
+{
+	struct cpu_user_regs *old_regs, **pp_regs = &this_cpu(irq_regs);
+
+	old_regs = *pp_regs;
+	*pp_regs = new_regs;
+
+	return old_regs;
+}
+
 struct domain;
 struct vcpu;
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Jan 25 06:44:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 25 Jan 2024 06:44:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.671325.1044594 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rStT1-0008GW-2N; Thu, 25 Jan 2024 06:44:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 671325.1044594; Thu, 25 Jan 2024 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 1rStT0-0008GO-Vy; Thu, 25 Jan 2024 06:44:02 +0000
Received: by outflank-mailman (input) for mailman id 671325;
 Thu, 25 Jan 2024 06:44:01 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rStSz-0008GE-RU
 for xen-changelog@lists.xenproject.org; Thu, 25 Jan 2024 06:44:01 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rStSz-0004Ti-Qb
 for xen-changelog@lists.xenproject.org; Thu, 25 Jan 2024 06:44:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rStSz-00004w-OM
 for xen-changelog@lists.xenproject.org; Thu, 25 Jan 2024 06:44:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ynXVaGrL63UEza3e5OLGMmpxlzf0sVAxYCaz0RB98Tc=; b=dTHUUvj9pZziVE91Qnr2aWj2bG
	H7HLJa3xyXzcdtgaAzsmdB7vV850rXnH0mogwRzPKrE0/7dtJSDznF0B5KqEnYNRyzaAtCkLq8Vci
	IVq7oSQLgGyEmpM+V2ZZ95ttuUR5ilNiYU3YWw75inN+eVORWX3+TN2N3uNFpxu4OGjc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/riscv: introduce domain.h
Message-Id: <E1rStSz-00004w-OM@xenbits.xenproject.org>
Date: Thu, 25 Jan 2024 06:44:01 +0000

commit f132bb5b6bfe6e200e0b32cbff9bcef56b6eda32
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Tue Jan 23 14:49:27 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Jan 23 14:49:27 2024 +0100

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

diff --git a/xen/arch/riscv/include/asm/domain.h b/xen/arch/riscv/include/asm/domain.h
new file mode 100644
index 0000000000..0f5dc2be40
--- /dev/null
+++ b/xen/arch/riscv/include/asm/domain.h
@@ -0,0 +1,53 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_RISCV_DOMAIN_H__
+#define __ASM_RISCV_DOMAIN_H__
+
+#include <xen/xmalloc.h>
+#include <public/hvm/params.h>
+
+struct hvm_domain
+{
+    uint64_t              params[HVM_NR_PARAMS];
+};
+
+#define is_domain_direct_mapped(d) ((void)(d), 0)
+
+struct arch_vcpu_io {
+};
+
+struct arch_vcpu {
+};
+
+struct arch_domain {
+    struct hvm_domain hvm;
+};
+
+#include <xen/sched.h>
+
+static inline struct vcpu_guest_context *alloc_vcpu_guest_context(void)
+{
+    return xmalloc(struct vcpu_guest_context);
+}
+
+static inline void free_vcpu_guest_context(struct vcpu_guest_context *vgc)
+{
+    xfree(vgc);
+}
+
+struct guest_memory_policy {};
+static inline void update_guest_memory_policy(struct vcpu *v,
+                                              struct guest_memory_policy *gmp)
+{}
+
+static inline void arch_vcpu_block(struct vcpu *v) {}
+
+#endif /* __ASM_RISCV_DOMAIN_H__ */
+
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Jan 25 06:44:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 25 Jan 2024 06:44:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.671326.1044599 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rStTB-0008IU-4C; Thu, 25 Jan 2024 06:44:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 671326.1044599; Thu, 25 Jan 2024 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 1rStTB-0008IM-19; Thu, 25 Jan 2024 06:44:13 +0000
Received: by outflank-mailman (input) for mailman id 671326;
 Thu, 25 Jan 2024 06:44:11 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rStT9-0008IC-Ub
 for xen-changelog@lists.xenproject.org; Thu, 25 Jan 2024 06:44:11 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rStT9-0004Tq-Tk
 for xen-changelog@lists.xenproject.org; Thu, 25 Jan 2024 06:44:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rStT9-00005a-Si
 for xen-changelog@lists.xenproject.org; Thu, 25 Jan 2024 06:44:11 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=44V928q3ckqT4Z1c7uoB++69ZJEUYKyw/VUucEhrSMU=; b=myTy/pI2J1vpQ/r4v19IB7cfYg
	2unPo37DDFgvz3Q2wyAnrSmh/7wR9XkL8cUmc5hj9pAYFpsZdQ2r6q1EbEVPG7axT0a6b5y7PZKfn
	k9OcA1avkeBmu/G5gT20rcaSMrsV9E6Cue++Qsfn7rjiCy4oQmBPHNJjPDR6ISuKrxZ0=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/riscv: introduce guest_access.h
Message-Id: <E1rStT9-00005a-Si@xenbits.xenproject.org>
Date: Thu, 25 Jan 2024 06:44:11 +0000

commit bbf7d6acd395312749d6c496b2dbfa9d444a0d46
Author:     Oleksii Kurochko <oleksii.kurochko@gmail.com>
AuthorDate: Tue Jan 23 14:49:54 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Jan 23 14:49:54 2024 +0100

    xen/riscv: introduce guest_access.h
    
    All necessary dummiy implementation of functions in this header
    will be introduced in stubs.c
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/riscv/include/asm/guest_access.h | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/xen/arch/riscv/include/asm/guest_access.h b/xen/arch/riscv/include/asm/guest_access.h
new file mode 100644
index 0000000000..c55951f538
--- /dev/null
+++ b/xen/arch/riscv/include/asm/guest_access.h
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_RISCV_GUEST_ACCESS_H__
+#define __ASM_RISCV_GUEST_ACCESS_H__
+
+unsigned long raw_copy_to_guest(void *to, const void *from, unsigned len);
+unsigned long raw_copy_from_guest(void *to, const void *from, unsigned len);
+unsigned long raw_clear_guest(void *to, unsigned int len);
+
+#define __raw_copy_to_guest raw_copy_to_guest
+#define __raw_copy_from_guest raw_copy_from_guest
+#define __raw_clear_guest raw_clear_guest
+
+/*
+ * Pre-validate a guest handle.
+ * Allows use of faster __copy_* functions.
+ */
+/* All RISCV guests are paging mode external and hence safe */
+#define guest_handle_okay(hnd, nr) (1)
+#define guest_handle_subrange_okay(hnd, first, last) (1)
+
+#endif /* __ASM_RISCV_GUEST_ACCESS_H__ */
+/*
+ * Local variables:
+ * mode: C
+ * c-file-style: "BSD"
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Jan 25 06:44:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 25 Jan 2024 06:44:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.671327.1044604 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rStTL-0008L9-6c; Thu, 25 Jan 2024 06:44:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 671327.1044604; Thu, 25 Jan 2024 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 1rStTL-0008L2-2f; Thu, 25 Jan 2024 06:44:23 +0000
Received: by outflank-mailman (input) for mailman id 671327;
 Thu, 25 Jan 2024 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 1rStTK-0008Ks-1L
 for xen-changelog@lists.xenproject.org; Thu, 25 Jan 2024 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 1rStTK-0004Ty-0S
 for xen-changelog@lists.xenproject.org; Thu, 25 Jan 2024 06:44:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rStTJ-00006L-Vp
 for xen-changelog@lists.xenproject.org; Thu, 25 Jan 2024 06:44:21 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=UfdRCF1HSuQYVgNDjyv8m2fYNnLtNn3cc7ZGpGABH7Q=; b=VufPR8hicI9suUik0Gku2geXQK
	CHY4ztgXOtgXwO8KE2sIakfnyB+qCpVQ/4i1cLYdCBKBCdy6Vh0lBCSiRMBB5O9y9SCcOD/boxH32
	+CorL8AY3HOg/rEx2mkJ31G3hs6Z/tTsrz7Yd+H5HYI+1NrNI4WCdmZtYln1ZOVOdics=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/kexec: Drop compatibility_mode_far
Message-Id: <E1rStTJ-00006L-Vp@xenbits.xenproject.org>
Date: Thu, 25 Jan 2024 06:44:21 +0000

commit 55fbecb64e512b191d8e4ca1c4516f92357b866e
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Thu Oct 28 20:03:21 2021 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Tue Jan 23 19:09:18 2024 +0000

    x86/kexec: Drop compatibility_mode_far
    
    LJMP is (famously?) incompatible between Intel and AMD CPUs, and while we're
    using one of the compatible forms, we've got a good stack and LRET is the far
    more common way of doing this.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/x86_64/kexec_reloc.S | 16 ++++------------
 1 file changed, 4 insertions(+), 12 deletions(-)

diff --git a/xen/arch/x86/x86_64/kexec_reloc.S b/xen/arch/x86/x86_64/kexec_reloc.S
index f4842025eb..035164e96f 100644
--- a/xen/arch/x86/x86_64/kexec_reloc.S
+++ b/xen/arch/x86/x86_64/kexec_reloc.S
@@ -86,12 +86,11 @@ ENTRY(kexec_reloc)
         movq    %rax, (compat_mode_gdt_desc + 2)(%rip)
         lgdt    compat_mode_gdt_desc(%rip)
 
-        /* Relocate compatibility mode entry point address. */
-        leal    compatibility_mode(%rip), %eax
-        movl    %eax, compatibility_mode_far(%rip)
-
         /* Enter compatibility mode. */
-        ljmp    *compatibility_mode_far(%rip)
+        lea     compatibility_mode(%rip), %rax
+        push    $0x10
+        push    %rax
+        lretq
 
 relocate_pages:
         /* %rdi - indirection page maddr */
@@ -171,13 +170,6 @@ compatibility_mode:
         ud2
 
         .align 4
-compatibility_mode_far:
-        .long 0x00000000             /* set in call_32_bit above */
-        .word 0x0010
-
-        .type compatibility_mode_far, @object
-        .size compatibility_mode_far, . - compatibility_mode_far
-
 compat_mode_gdt_desc:
         .word .Lcompat_mode_gdt_end - compat_mode_gdt -1
         .quad 0x0000000000000000     /* set in call_32_bit above */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Thu Jan 25 06:44:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Thu, 25 Jan 2024 06:44:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.671328.1044607 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rStTV-0008O3-6o; Thu, 25 Jan 2024 06:44:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 671328.1044607; Thu, 25 Jan 2024 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 1rStTV-0008Nv-47; Thu, 25 Jan 2024 06:44:33 +0000
Received: by outflank-mailman (input) for mailman id 671328;
 Thu, 25 Jan 2024 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 1rStTU-0008Nj-5i
 for xen-changelog@lists.xenproject.org; Thu, 25 Jan 2024 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 1rStTU-0004U7-4u
 for xen-changelog@lists.xenproject.org; Thu, 25 Jan 2024 06:44:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rStTU-00006n-2e
 for xen-changelog@lists.xenproject.org; Thu, 25 Jan 2024 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=uYKmi4DpDX4S6g5tQcfQbFKYifDEA72YURJQ8fimQrM=; b=bkySwQWxi8VQ7a4fRqQsKndGA4
	l/xvafNTg739oEt0zDZYuTookCd67BeA2NxXBu4H1PniffU+QlbJa5npcqGW1W/S43P/y7RUWD+gy
	SbJo7gej9hpSO7J6QVmGTYyfxBmpdOKvWAbYQjZVFNGnIuS1QUaRL3+iCXcUfQnqaeOA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/entry: Fix ELF metadata for NMI and handle_ist_exception
Message-Id: <E1rStTU-00006n-2e@xenbits.xenproject.org>
Date: Thu, 25 Jan 2024 06:44:32 +0000

commit 98ae35cab0e40e59963f9f58345bf378b9522d74
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Mon Jan 22 14:50:10 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Tue Jan 23 19:09:18 2024 +0000

    x86/entry: Fix ELF metadata for NMI and handle_ist_exception
    
    handle_ist_exception isn't part of the NMI handler, just like handle_exception
    isn't part of #PF.
    
    Fixes: b3a9037550df ("x86: annotate entry points with type and size")
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/x86_64/entry.S | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index 482c91d4f5..c3f6b667a7 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -1023,7 +1023,9 @@ FUNC(entry_NMI)
         ENDBR64
         pushq $0
         movl  $X86_EXC_NMI, 4(%rsp)
-handle_ist_exception:
+END(entry_NMI)
+
+FUNC(handle_ist_exception)
         ALTERNATIVE "", clac, X86_FEATURE_XEN_SMAP
         SAVE_ALL
 
@@ -1150,7 +1152,7 @@ handle_ist_exception:
         ASSERT_CONTEXT_IS_XEN
         jmp   restore_all_xen
 #endif
-END(entry_NMI)
+END(handle_ist_exception)
 
 FUNC(entry_MC)
         ENDBR64
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Jan 26 21:33:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 26 Jan 2024 21:33:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.672519.1046621 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rTTos-0004SW-9s; Fri, 26 Jan 2024 21:33:02 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 672519.1046621; Fri, 26 Jan 2024 21: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 1rTTos-0004SO-7G; Fri, 26 Jan 2024 21:33:02 +0000
Received: by outflank-mailman (input) for mailman id 672519;
 Fri, 26 Jan 2024 21: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 1rTTor-0004SI-Sp
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21: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 1rTTor-0005Tb-Rz
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:33:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rTTor-0006VU-Qw
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21: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=NYc4yCrucj6TRzsEs7GUWHHN42+SnZCw5O+3tmh0sbw=; b=A8MFNzpT/tHijDJjB+eRkafy1E
	EmXNFF1uRtP0418BkNBf+QfVvJ3X//Uh46BqhW+1A7I6VWc0yJsbeKEpeXtSl8iB1TuJDAwa41DpR
	MBjGbC4v7q5reDZhoV8c0bDQZ+upiWrpuTB75EKtxkQO66stSMWHbeXH6UirL2mU2PM8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/p2m-pt: fix off by one in entry check assert
Message-Id: <E1rTTor-0006VU-Qw@xenbits.xenproject.org>
Date: Fri, 26 Jan 2024 21:33:01 +0000

commit 610775d0dd61c1bd2f4720c755986098e6a5bafd
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Thu Jan 25 16:09:04 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Jan 25 16:09:04 2024 +0100

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

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


From xen-changelog-bounces@lists.xenproject.org Fri Jan 26 21:33:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 26 Jan 2024 21:33:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.672520.1046625 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rTTp2-0004Zg-BF; Fri, 26 Jan 2024 21:33:12 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 672520.1046625; Fri, 26 Jan 2024 21: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 1rTTp2-0004ZZ-8h; Fri, 26 Jan 2024 21:33:12 +0000
Received: by outflank-mailman (input) for mailman id 672520;
 Fri, 26 Jan 2024 21:33:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rTTp2-0004ZR-0C
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:33:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rTTp1-0005UK-Vh
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:33:11 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rTTp1-0006Vu-UG
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21: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=QqGYZcvEg/Rb7lCl8O1LxItyTGSiqBB/Srejdu7gvOo=; b=oLPH+bCiqrZ0dKvgBoTveN1HMA
	pUfQ+b2i8D8Q9/B9jY/t7GjwDmtAqsv8vICyB3jK7lvNwAoj932ryWZk3cjnh2aIGjPU+bs8yTvs1
	7mz3X+/KvzRhOxCF/nMe68sr+gf6GE0espE9kwg40hBYpAdqBIkEPDvPX110v7ujxuew=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/NMI: refine "watchdog stuck" log message
Message-Id: <E1rTTp1-0006Vu-UG@xenbits.xenproject.org>
Date: Fri, 26 Jan 2024 21:33:11 +0000

commit f575f055243eda56e6f1f26eee5bf3646281f122
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Jan 25 16:10:06 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Jan 25 16:10:06 2024 +0100

    x86/NMI: refine "watchdog stuck" log message
    
    Observing
    
    "Testing NMI watchdog on all CPUs: 0 stuck"
    
    it felt like it's not quite right, but I still read it as "no CPU stuck;
    all good", when really the system suffered from what 6bdb965178bb
    ("x86/intel: ensure Global Performance Counter Control is setup
    correctly") works around. Convert this to
    
    "Testing NMI watchdog on all CPUs: {0} stuck"
    
    or, with multiple CPUs having an issue, e.g.
    
    "Testing NMI watchdog on all CPUs: {0,40} stuck"
    
    to make more obvious that a lone number is not a count of CPUs.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/nmi.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c
index dc79c25e3f..633dc59bf8 100644
--- a/xen/arch/x86/nmi.c
+++ b/xen/arch/x86/nmi.c
@@ -167,13 +167,14 @@ static void __init cf_check wait_for_nmis(void *p)
 void __init check_nmi_watchdog(void)
 {
     static unsigned int __initdata prev_nmi_count[NR_CPUS];
-    int cpu;
+    unsigned int cpu;
+    char sep = '{';
     bool ok = true;
 
     if ( nmi_watchdog == NMI_NONE )
         return;
 
-    printk("Testing NMI watchdog on all CPUs:");
+    printk("Testing NMI watchdog on all CPUs: ");
 
     for_each_online_cpu ( cpu )
         prev_nmi_count[cpu] = per_cpu(nmi_count, cpu);
@@ -189,12 +190,13 @@ void __init check_nmi_watchdog(void)
     {
         if ( per_cpu(nmi_count, cpu) - prev_nmi_count[cpu] < 2 )
         {
-            printk(" %d", cpu);
+            printk("%c%u", sep, cpu);
+            sep = ',';
             ok = false;
         }
     }
 
-    printk(" %s\n", ok ? "ok" : "stuck");
+    printk("%s\n", ok ? "ok" : "} stuck");
 
     /*
      * Now that we know it works we can reduce NMI frequency to
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Jan 26 21:33:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 26 Jan 2024 21:33:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.672521.1046629 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rTTpD-0004h3-D8; Fri, 26 Jan 2024 21:33:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 672521.1046629; Fri, 26 Jan 2024 21: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 1rTTpD-0004gv-AP; Fri, 26 Jan 2024 21:33:23 +0000
Received: by outflank-mailman (input) for mailman id 672521;
 Fri, 26 Jan 2024 21: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 1rTTpC-0004gh-4g
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21: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 1rTTpC-0005Ub-2m
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:33:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rTTpC-0006WK-1j
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:33:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=B1Bwka8BZqlJjlUimDprUh+Kz9W8CCRwrAo2v3sTNxQ=; b=2OZjwW9rRMLjy5LBNJXLDox3IC
	mCVJRbe7L8lbSQaD+zEPcWf9LEkyBkg5wTx2YSuPT3MlamQbq9ZvnCI7PtaFM9cLDqi/ZE1feMzdd
	n7nAxHc6RIFembIxMSJUoUKFyr3WlQn2mpzz+BRk03CAiOy7LqblU+5uBSnVzJWMqoDY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/entry: replace two GET_CURRENT() uses
Message-Id: <E1rTTpC-0006WK-1j@xenbits.xenproject.org>
Date: Fri, 26 Jan 2024 21:33:22 +0000

commit e047b8d0fa05c6c051ad6e4f5ff6e0fe426965b3
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Thu Jan 25 16:10:58 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Jan 25 16:10:58 2024 +0100

    x86/entry: replace two GET_CURRENT() uses
    
    Now that we have %r14 set up using GET_STACK_END() in a number of
    places, in two places we can eliminate the redundancy of GET_CURRENT()
    also invoking that macro. In handle_ist_exception() actually go a step
    farther and avoid using %rbx altogether when retrieving the processor
    ID: Obtain the current vCPU pointer only in the PV32-specific code
    actually needing it.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/x86_64/asm-offsets.c | 1 +
 xen/arch/x86/x86_64/entry.S       | 6 +++---
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/x86_64/asm-offsets.c b/xen/arch/x86/x86_64/asm-offsets.c
index 57b73a4e62..f9546ec60b 100644
--- a/xen/arch/x86/x86_64/asm-offsets.c
+++ b/xen/arch/x86/x86_64/asm-offsets.c
@@ -118,6 +118,7 @@ void __dummy__(void)
 #endif
 
     OFFSET(CPUINFO_guest_cpu_user_regs, struct cpu_info, guest_cpu_user_regs);
+    OFFSET(CPUINFO_processor_id, struct cpu_info, processor_id);
     OFFSET(CPUINFO_verw_sel, struct cpu_info, verw_sel);
     OFFSET(CPUINFO_current_vcpu, struct cpu_info, current_vcpu);
     OFFSET(CPUINFO_per_cpu_offset, struct cpu_info, per_cpu_offset);
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index c3f6b667a7..5dab3e4832 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -749,7 +749,7 @@ FUNC(handle_exception, 0)
 .Lxcpt_cr3_okay:
 
 handle_exception_saved:
-        GET_CURRENT(bx)
+        mov   STACK_CPUINFO_FIELD(current_vcpu)(%r14), %rbx
         testb $X86_EFLAGS_IF>>8,UREGS_eflags+1(%rsp)
         jz    exception_with_ints_disabled
 
@@ -1130,9 +1130,8 @@ FUNC(handle_ist_exception)
 #ifdef CONFIG_PV
         testb $3,UREGS_cs(%rsp)
         jz    restore_all_xen
-        GET_CURRENT(bx)
         /* Send an IPI to ourselves to cover for the lack of event checking. */
-        movl  VCPU_processor(%rbx),%eax
+        mov   STACK_CPUINFO_FIELD(processor_id)(%r14), %eax
         shll  $IRQSTAT_shift,%eax
         leaq  irq_stat+IRQSTAT_softirq_pending(%rip),%rcx
         cmpl  $0,(%rcx,%rax,1)
@@ -1141,6 +1140,7 @@ FUNC(handle_ist_exception)
         call  send_IPI_self
 1:
 #ifdef CONFIG_PV32
+        mov   STACK_CPUINFO_FIELD(current_vcpu)(%r14), %rbx
         movq  VCPU_domain(%rbx),%rax
         cmpb  $0,DOMAIN_is_32bit_pv(%rax)
         je    restore_all_guest
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Jan 26 21:33:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 26 Jan 2024 21:33:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.672522.1046633 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rTTpN-0004rk-F7; Fri, 26 Jan 2024 21:33:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 672522.1046633; Fri, 26 Jan 2024 21: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 1rTTpN-0004rc-CF; Fri, 26 Jan 2024 21:33:33 +0000
Received: by outflank-mailman (input) for mailman id 672522;
 Fri, 26 Jan 2024 21: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 1rTTpM-0004rS-6p
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21: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 1rTTpM-0005Uk-63
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:33:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rTTpM-0006Wj-4q
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21: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=EqOjaMbqhzgbEf/bdgcwP/bOe67jBa6MyuaNXvc3yXk=; b=pcf33RvCV8mJCR0lUtayDd3O3s
	j4fdeSJ+3gcW2mRDjNCl60Py84y5wQR/B99IFjHQ0dltqHhu45qYWTqsCMhlTOG/p9zHFwMX5Ro72
	5ac4To6Mgz02XPYxFwucpqvmJv5N+JsGGXnyw6sShhR5j+Cou7Y8nmDGeJNu/PuqGHvY=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] pmstat: Limit hypercalls under HWP
Message-Id: <E1rTTpM-0006Wj-4q@xenbits.xenproject.org>
Date: Fri, 26 Jan 2024 21:33:32 +0000

commit 052d78fbec6a3163281df1b4204d6d606507c4c8
Author:     Jason Andryuk <jandryuk@gmail.com>
AuthorDate: Thu Jan 25 16:11:49 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Thu Jan 25 16:11:49 2024 +0100

    pmstat: Limit hypercalls under HWP
    
    When HWP is active, the cpufreq P-state information is not updated.  In
    that case, return -EOPNOTSUPP instead of bogus, incomplete info.
    
    Similarly, set_cpufreq_para() is not applicable when HWP is active.
    Many of the options already checked the governor and were inaccessible,
    but SCALING_MIN/MAX_FREQ was still accessible (though it would do
    nothing).  Add an ealier HWP check to handle all cases.
    
    Signed-off-by: Jason Andryuk <jandryuk@gmail.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/drivers/acpi/pmstat.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/xen/drivers/acpi/pmstat.c b/xen/drivers/acpi/pmstat.c
index 803971bdb0..998d2e3c65 100644
--- a/xen/drivers/acpi/pmstat.c
+++ b/xen/drivers/acpi/pmstat.c
@@ -66,6 +66,8 @@ int do_get_pm_info(struct xen_sysctl_get_pmstat *op)
             return -ENODEV;
         if ( !cpufreq_driver.init )
             return -ENODEV;
+        if ( hwp_active() )
+            return -EOPNOTSUPP;
         if ( !pmpt || !(pmpt->perf.init & XEN_PX_INIT) )
             return -EINVAL;
         break;
@@ -330,6 +332,9 @@ static int set_cpufreq_para(struct xen_sysctl_pm_op *op)
     if ( !policy || !policy->governor )
         return -EINVAL;
 
+    if ( hwp_active() )
+        return -EOPNOTSUPP;
+
     switch(op->u.set_para.ctrl_type)
     {
     case SCALING_MAX_FREQ:
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Jan 26 21:33:43 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 26 Jan 2024 21:33:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.672523.1046637 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rTTpX-00054i-GR; Fri, 26 Jan 2024 21:33:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 672523.1046637; Fri, 26 Jan 2024 21: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 1rTTpX-00054b-Dg; Fri, 26 Jan 2024 21:33:43 +0000
Received: by outflank-mailman (input) for mailman id 672523;
 Fri, 26 Jan 2024 21: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 1rTTpW-00053F-9i
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21: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 1rTTpW-0005Ur-8x
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:33:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rTTpW-0006X8-86
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21: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=BxjZpp9KIrHv0gEFY/J+Xvn7GPfKsjjD+otMUr0mKfA=; b=svlk/tTQ51Bu8ETwUIpemIat5F
	F16cZ9+YV+7OEO5YiW/Y9+0z6ogN/ZxCK0Gx+EHtZIq4uTH7oEK+haeJi/E/bWiQmOQHP2wKNdzeE
	YVfInQCCSCk6wwJ2tIu+yXyz/9N3kFsvsOwS1/9JLU+IH84SBGFHPLKt71j5YXSS0TQQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/ucode: Fix stability of the raw CPU Policy rescan
Message-Id: <E1rTTpW-0006X8-86@xenbits.xenproject.org>
Date: Fri, 26 Jan 2024 21:33:42 +0000

commit cf7fe8b72deaa94157ddf97d4bb391480205e9c2
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Tue Jan 23 20:24:22 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Jan 25 17:46:57 2024 +0000

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

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


From xen-changelog-bounces@lists.xenproject.org Fri Jan 26 21:33:53 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 26 Jan 2024 21:33:53 +0000
Received: from list by lists.xenproject.org with outflank-mailman.672524.1046641 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rTTph-0005CF-Hz; Fri, 26 Jan 2024 21:33:53 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 672524.1046641; Fri, 26 Jan 2024 21:33: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 1rTTph-0005C7-FG; Fri, 26 Jan 2024 21:33:53 +0000
Received: by outflank-mailman (input) for mailman id 672524;
 Fri, 26 Jan 2024 21:33: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 1rTTpg-0005By-Cy
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:33: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 1rTTpg-0005Uy-C3
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:33:52 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rTTpg-0006Yv-BD
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:33: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=j4ZMbNOUEGknL0iNpjBLuMA8RmdPvbck8ESQO3chln4=; b=u+QHc0/hAwhgIzsQVjdLGhNzGw
	kktL8/ccHL3BXKU2WKbS9UHMXcvlM/UgiRXSgBTVP7JAaAVLnNY99tJUN7zIt8ue6XGB+IpEjhWDx
	O6jP3vNSaT3K8xcivQSP7LnAPQy7JaUkUQBEOKbylAIga9o7oHB1IHk82T9jOCqmPoLA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/hvm: make X86_EMU_USE_PIRQ optional
Message-Id: <E1rTTpg-0006Yv-BD@xenbits.xenproject.org>
Date: Fri, 26 Jan 2024 21:33:52 +0000

commit 72cad62abbaab656acee0835099b0260ac6f13ab
Author:     Roger Pau Monne <roger.pau@citrix.com>
AuthorDate: Thu Jan 25 10:30:40 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Jan 25 17:46:57 2024 +0000

    x86/hvm: make X86_EMU_USE_PIRQ optional
    
    Allow selecting X86_EMU_USE_PIRQ for HVM guests, so it's no longer mandated to
    be always on.
    
    There's no restriction in Xen that forces such feature to be always on for HVM
    guests, as for example PVH guests don't support it, as such allow toolstack to
    select whether to enabled it on a per-domain basis.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/domain.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c
index 8a31d18f69..bda853e3c9 100644
--- a/xen/arch/x86/domain.c
+++ b/xen/arch/x86/domain.c
@@ -725,7 +725,9 @@ static bool emulation_flags_ok(const struct domain *d, uint32_t emflags)
              emflags != (X86_EMU_VPCI | X86_EMU_LAPIC | X86_EMU_IOAPIC) )
             return false;
         if ( !is_hardware_domain(d) &&
-             emflags != (X86_EMU_ALL & ~X86_EMU_VPCI) &&
+             /* HVM PIRQ feature is user-selectable. */
+             (emflags & ~X86_EMU_USE_PIRQ) !=
+             (X86_EMU_ALL & ~(X86_EMU_VPCI | X86_EMU_USE_PIRQ)) &&
              emflags != X86_EMU_LAPIC )
             return false;
     }
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Jan 26 21:34:03 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 26 Jan 2024 21:34:03 +0000
Received: from list by lists.xenproject.org with outflank-mailman.672525.1046645 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rTTpr-0005NS-Js; Fri, 26 Jan 2024 21:34:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 672525.1046645; Fri, 26 Jan 2024 21:34: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 1rTTpr-0005NF-Gl; Fri, 26 Jan 2024 21:34:03 +0000
Received: by outflank-mailman (input) for mailman id 672525;
 Fri, 26 Jan 2024 21:34: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 1rTTpq-0005Jf-HE
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:34: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 1rTTpq-0005VI-GM
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:34:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rTTpq-0006a8-Ew
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:34: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=LPBAkCfK/920N0VH001u+8G/I4uTb/7rvFO5lq2Ccpw=; b=xRxP5pU8vLWdAOtLzLufhNUAt/
	NShvC1Hnj0MUCODOU79xUkkSY494h0Tv4Znj6XlvxkPXNt+jxxqgpw0Wo2sx9HC+Fs43mniwmZII0
	N1iFUa65WbvSee1eHvbDYseNFDD/V8R2jYsMLW6rUzd5sF6sGOPThKijfn9IEEpnFHX8=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] tools: don't expose XENFEAT_hvm_pirqs by default
Message-Id: <E1rTTpq-0006a8-Ew@xenbits.xenproject.org>
Date: Fri, 26 Jan 2024 21:34:02 +0000

commit 024e7131be5ca0cb0a3f68522e490e5882099b00
Author:     Roger Pau Monne <roger.pau@citrix.com>
AuthorDate: Thu Jan 25 10:30:41 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Jan 25 17:46:57 2024 +0000

    tools: don't expose XENFEAT_hvm_pirqs by default
    
    The HVM pirq feature allows routing interrupts from both physical and emulated
    devices over event channels, this was done a performance improvement.  However
    its usage is fully undocumented, and the only reference implementation is in
    Linux.  It defeats the purpose of local APIC hardware virtualization, because
    when using it interrupts avoid the usage of the local APIC altogether.
    
    It has also been reported to not work properly with certain devices, at least
    when using some AMD GPUs Linux attempts to route interrupts over event
    channels, but Xen doesn't correctly detect such routing, which leads to the
    hypervisor complaining with:
    
    (XEN) d15v0: Unsupported MSI delivery mode 7 for Dom15
    
    When MSIs are attempted to be routed over event channels the entry delivery
    mode is set to ExtINT, but Xen doesn't detect such routing and attempts to
    inject the interrupt following the native MSI path, and the ExtINT delivery
    mode is not supported.
    
    Disable HVM PIRQs by default and provide a per-domain option in xl.cfg to
    enable such feature.  Also for backwards compatibility keep the feature enabled
    for any resumed domains that don't have an explicit selection.
    
    Note that the only user of the feature (Linux) is also able to handle native
    interrupts fine, as the feature was already not used if Xen reported local APIC
    hardware virtualization active.
    
    Link: https://github.com/QubesOS/qubes-issues/issues/7971
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
    Acked-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 CHANGELOG.md                      |  2 ++
 docs/man/xl.cfg.5.pod.in          |  7 +++++++
 tools/include/libxl.h             |  7 +++++++
 tools/libs/light/libxl_create.c   |  7 +++++--
 tools/libs/light/libxl_types.idl  |  1 +
 tools/libs/light/libxl_x86.c      | 12 +++++++++---
 tools/python/xen/lowlevel/xc/xc.c |  4 +++-
 tools/xl/xl_parse.c               |  1 +
 8 files changed, 35 insertions(+), 6 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index 723d064254..ddb3ab8db4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -9,6 +9,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
 ### Changed
  - Changed flexible array definitions in public I/O interface headers to not
    use "1" as the number of array elements.
+ - On x86:
+   - HVM PIRQs are disabled by default.
 
 ### Added
  - On x86:
diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
index 2e234b450e..ea8d41727d 100644
--- a/docs/man/xl.cfg.5.pod.in
+++ b/docs/man/xl.cfg.5.pod.in
@@ -2460,6 +2460,13 @@ The viridian option can be specified as a boolean. A value of true (1)
 is equivalent to the list [ "defaults" ], and a value of false (0) is
 equivalent to an empty list.
 
+=item B<hvm_pirq=BOOLEAN>
+
+Select whether the guest is allowed to route interrupts from devices (either
+emulated or passed through) over event channels.
+
+This option is disabled by default.
+
 =back
 
 =head3 Emulated VGA Graphics Device
diff --git a/tools/include/libxl.h b/tools/include/libxl.h
index 907aa0a330..f1652b1664 100644
--- a/tools/include/libxl.h
+++ b/tools/include/libxl.h
@@ -608,6 +608,13 @@
  * executable in order to not run it as the same user as libxl.
  */
 
+/*
+ * LIBXL_HAVE_HVM_PIRQ indicates the presence of the u.hvm.pirq filed in
+ * libxl_domain_build_info that signals whether an HVM guest has accesses to
+ * the XENFEAT_hvm_pirqs feature.
+ */
+#define LIBXL_HAVE_HVM_PIRQ 1
+
 /*
  * libxl memory management
  *
diff --git a/tools/libs/light/libxl_create.c b/tools/libs/light/libxl_create.c
index ce1d431103..0008fac607 100644
--- a/tools/libs/light/libxl_create.c
+++ b/tools/libs/light/libxl_create.c
@@ -376,6 +376,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
         libxl_defbool_setdefault(&b_info->u.hvm.usb,                false);
         libxl_defbool_setdefault(&b_info->u.hvm.vkb_device,         true);
         libxl_defbool_setdefault(&b_info->u.hvm.xen_platform_pci,   true);
+        libxl_defbool_setdefault(&b_info->u.hvm.pirq,               false);
 
         libxl_defbool_setdefault(&b_info->u.hvm.spice.enable, false);
         if (!libxl_defbool_val(b_info->u.hvm.spice.enable) &&
@@ -2375,10 +2376,12 @@ int libxl_domain_create_restore(libxl_ctx *ctx, libxl_domain_config *d_config,
 
     /*
      * When restoring (either from a save file or for a migration domain) set
-     * the MSR relaxed mode for compatibility with older Xen versions if the
-     * option is not set as part of the original configuration.
+     * the MSR relaxed mode and HVM PIRQs for compatibility with older Xen
+     * versions if the options are not set as part of the original
+     * configuration.
      */
     libxl_defbool_setdefault(&d_config->b_info.arch_x86.msr_relaxed, true);
+    libxl_defbool_setdefault(&d_config->b_info.u.hvm.pirq, true);
 
     return do_domain_create(ctx, d_config, domid, restore_fd, send_back_fd,
                             params, ao_how, aop_console_how);
diff --git a/tools/libs/light/libxl_types.idl b/tools/libs/light/libxl_types.idl
index 7d8bd5d216..899ad30969 100644
--- a/tools/libs/light/libxl_types.idl
+++ b/tools/libs/light/libxl_types.idl
@@ -692,6 +692,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
                                        ("rdm", libxl_rdm_reserve),
                                        ("rdm_mem_boundary_memkb", MemKB),
                                        ("mca_caps",         uint64),
+                                       ("pirq",             libxl_defbool),
                                        ])),
                  ("pv", Struct(None, [("kernel", string, {'deprecated_by': 'kernel'}),
                                       ("slack_memkb", MemKB),
diff --git a/tools/libs/light/libxl_x86.c b/tools/libs/light/libxl_x86.c
index d16573e72c..a50ec37eb3 100644
--- a/tools/libs/light/libxl_x86.c
+++ b/tools/libs/light/libxl_x86.c
@@ -9,6 +9,8 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc,
     switch(d_config->c_info.type) {
     case LIBXL_DOMAIN_TYPE_HVM:
         config->arch.emulation_flags = (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI);
+        if (!libxl_defbool_val(d_config->b_info.u.hvm.pirq))
+            config->arch.emulation_flags &= ~XEN_X86_EMU_USE_PIRQ;
         break;
     case LIBXL_DOMAIN_TYPE_PVH:
         config->arch.emulation_flags = XEN_X86_EMU_LAPIC;
@@ -864,15 +866,19 @@ void libxl__arch_update_domain_config(libxl__gc *gc,
                                       const libxl_domain_config *src)
 {
     /*
-     * Force MSR relaxed to be set (either to true or false) so it's part of
-     * the domain configuration when saving or performing a live-migration.
+     * Force MSR relaxed and HVM pirq to be set (either to true or false) so
+     * it's part of the domain configuration when saving or performing a
+     * live-migration.
      *
-     * Doing so allows the recovery side to figure out whether the flag should
+     * Doing so allows the recovery side to figure out whether the flags should
      * be set to true in order to keep backwards compatibility with already
      * started domains.
      */
     libxl_defbool_setdefault(&dst->b_info.arch_x86.msr_relaxed,
                     libxl_defbool_val(src->b_info.arch_x86.msr_relaxed));
+    if (src->c_info.type == LIBXL_DOMAIN_TYPE_HVM )
+        libxl_defbool_setdefault(&dst->b_info.u.hvm.pirq,
+                                 libxl_defbool_val(src->b_info.u.hvm.pirq));
 }
 
 /*
diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/xc/xc.c
index d3ea350e07..9feb12ae2b 100644
--- a/tools/python/xen/lowlevel/xc/xc.c
+++ b/tools/python/xen/lowlevel/xc/xc.c
@@ -159,7 +159,9 @@ static PyObject *pyxc_domain_create(XcObject *self,
 
 #if defined (__i386) || defined(__x86_64__)
     if ( config.flags & XEN_DOMCTL_CDF_hvm )
-        config.arch.emulation_flags = (XEN_X86_EMU_ALL & ~XEN_X86_EMU_VPCI);
+        config.arch.emulation_flags = XEN_X86_EMU_ALL &
+                                      ~(XEN_X86_EMU_VPCI |
+                                        XEN_X86_EMU_USE_PIRQ);
 #elif defined (__arm__) || defined(__aarch64__)
     config.arch.gic_version = XEN_DOMCTL_CONFIG_GIC_NATIVE;
 #else
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index ed983200c3..9b358f11b8 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -1801,6 +1801,7 @@ void parse_config_data(const char *config_source,
         xlu_cfg_get_defbool(config, "hpet", &b_info->u.hvm.hpet, 0);
         xlu_cfg_get_defbool(config, "vpt_align", &b_info->u.hvm.vpt_align, 0);
         xlu_cfg_get_defbool(config, "apic", &b_info->apic, 0);
+        xlu_cfg_get_defbool(config, "hvm_pirq", &b_info->u.hvm.pirq, 0);
 
         switch (xlu_cfg_get_list(config, "viridian",
                                  &viridian, &num_viridian, 1))
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Jan 26 21:34:14 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 26 Jan 2024 21:34:14 +0000
Received: from list by lists.xenproject.org with outflank-mailman.672526.1046649 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rTTq1-0005TE-Md; Fri, 26 Jan 2024 21:34:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 672526.1046649; Fri, 26 Jan 2024 21:34: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 1rTTq1-0005T4-Jl; Fri, 26 Jan 2024 21:34:13 +0000
Received: by outflank-mailman (input) for mailman id 672526;
 Fri, 26 Jan 2024 21:34: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 1rTTq0-0005Su-Lc
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:34: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 1rTTq0-0005Vg-Kq
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:34:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rTTq0-0006au-Ic
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:34: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=y1h3tKNHN5ArsMmAWs51+zRBgujtmhEeTpwBfNhnQV4=; b=UJid8Akx7gf/DDkb4BtMSXIngT
	vJHytdaIMzAzFG50jBfEoHHlGApc1Z9sBst5/ruNGZCbxNQ+iR4qf02TtGrcX9jNOziuwCiPqFN7j
	lN2HUYP9EZ+cAs6GdNxsE1Xc/mfneX39Y+f8NuKdT+/X3nwAaGmqoqteeHWEOndpLzVo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/entry: Avoid register spilling in cr4_pv32_restore()
Message-Id: <E1rTTq0-0006au-Ic@xenbits.xenproject.org>
Date: Fri, 26 Jan 2024 21:34:12 +0000

commit b24b540de613dad0f432bb606ea1eb935a8a89cf
Author:     Andrew Cooper <andrew.cooper3@citrix.com>
AuthorDate: Fri Feb 10 21:20:42 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Thu Jan 25 17:46:57 2024 +0000

    x86/entry: Avoid register spilling in cr4_pv32_restore()
    
    cr4_pv32_restore() needs two registers.  Right now, it spills %rdx and
    clobbers %rax.
    
    However, %rcx is free to use at all callsites.  Annotate CR4_PV32_RESTORE with
    our usual clobber comments, and swap %rdx for %rcx in the non-fatal paths
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 xen/arch/x86/x86_64/compat/entry.S | 17 +++++++----------
 xen/arch/x86/x86_64/entry.S        |  8 ++++----
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/xen/arch/x86/x86_64/compat/entry.S b/xen/arch/x86/x86_64/compat/entry.S
index 49811a56e9..d4f0e48040 100644
--- a/xen/arch/x86/x86_64/compat/entry.S
+++ b/xen/arch/x86/x86_64/compat/entry.S
@@ -23,7 +23,7 @@ FUNC(entry_int82)
 
         sti
 
-        CR4_PV32_RESTORE
+        CR4_PV32_RESTORE /* Clob: ac */
 
         GET_CURRENT(bx)
 
@@ -163,17 +163,15 @@ FUNC(compat_restore_all_guest)
         _ASM_PRE_EXTABLE(.Lft0, handle_exception)
 END(compat_restore_all_guest)
 
-/* This mustn't modify registers other than %rax. */
+/* Callers can cope with both %rax and %rcx being clobbered. */
 FUNC(cr4_pv32_restore)
-        push  %rdx
-        GET_CPUINFO_FIELD(cr4, dx)
-        mov   (%rdx), %rax
+        GET_CPUINFO_FIELD(cr4, cx)
+        mov   (%rcx), %rax
         test  $XEN_CR4_PV32_BITS, %eax
         jnz   0f
         or    cr4_pv32_mask(%rip), %rax
         mov   %rax, %cr4
-        mov   %rax, (%rdx)
-        pop   %rdx
+        mov   %rax, (%rcx)
         ret
 0:
 #ifndef NDEBUG
@@ -191,7 +189,6 @@ FUNC(cr4_pv32_restore)
         BUG
 1:
 #endif
-        pop   %rdx
         xor   %eax, %eax
         ret
 END(cr4_pv32_restore)
@@ -227,7 +224,7 @@ UNLIKELY_END(compat_syscall_gpf)
 END(compat_syscall)
 
 FUNC(compat_sysenter)
-        CR4_PV32_RESTORE
+        CR4_PV32_RESTORE /* Clob: ac */
         movq  VCPU_trap_ctxt(%rbx),%rcx
         cmpb  $X86_EXC_GP, UREGS_entry_vector(%rsp)
         movzwl VCPU_sysenter_sel(%rbx),%eax
@@ -242,7 +239,7 @@ FUNC(compat_sysenter)
 END(compat_sysenter)
 
 FUNC(compat_int80_direct_trap)
-        CR4_PV32_RESTORE
+        CR4_PV32_RESTORE /* Clob: ac */
         call  compat_create_bounce_frame
         jmp   compat_test_all_events
 END(compat_int80_direct_trap)
diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index 5dab3e4832..44f25def86 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -309,7 +309,7 @@ FUNC(cstar_enter)
 .Lcstar_cr3_okay:
         sti
 
-        CR4_PV32_RESTORE
+        CR4_PV32_RESTORE /* Clob: ac */
 
         movq  STACK_CPUINFO_FIELD(current_vcpu)(%rbx), %rbx
 
@@ -712,7 +712,7 @@ FUNC(common_interrupt)
         cmovnz %r12d, %ebx
 .Lintr_cr3_okay:
 
-        CR4_PV32_RESTORE
+        CR4_PV32_RESTORE /* Clob: ac */
         movq %rsp,%rdi
         callq do_IRQ
         mov   %r15, STACK_CPUINFO_FIELD(xen_cr3)(%r14)
@@ -762,7 +762,7 @@ handle_exception_saved:
         jz    .Lcr4_pv32_done
         cmpb  $0,DOMAIN_is_32bit_pv(%rax)
         je    .Lcr4_pv32_done
-        call  cr4_pv32_restore
+        call  cr4_pv32_restore /* Clob: ac */
         /*
          * An NMI or #MC may occur between clearing CR4.SMEP / CR4.SMAP in
          * compat_restore_all_guest and it actually returning to guest
@@ -1046,7 +1046,7 @@ FUNC(handle_ist_exception)
 .List_cr3_okay:
 
 #ifdef CONFIG_PV
-        CR4_PV32_RESTORE
+        CR4_PV32_RESTORE /* Clob: ac */
         testb $3,UREGS_cs(%rsp)
         jz    1f
         /*
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Jan 26 21:34:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 26 Jan 2024 21:34:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.672527.1046653 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rTTqB-0005bk-O4; Fri, 26 Jan 2024 21:34:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 672527.1046653; Fri, 26 Jan 2024 21:34: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 1rTTqB-0005bc-LD; Fri, 26 Jan 2024 21:34:23 +0000
Received: by outflank-mailman (input) for mailman id 672527;
 Fri, 26 Jan 2024 21:34: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 1rTTqA-0005aC-Ob
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:34: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 1rTTqA-0005Vn-Nl
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:34:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rTTqA-0006bf-My
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:34: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=Du8rDcyXsPddlqqOwVqgvxJSCUE4PVN8e1QXznthFzM=; b=ABxvR22MD9cURDnhGCvStrMLDb
	DJvsWFYYt4LA9vn3SDbPqP4TfVntDqB2+XaqQOINntoLgciBkigfFGVtl5+z33uBBchlsvFCZtewZ
	vxft9Q7sCQOnl01XVobpjwd1MEXQCOKvVjm/epZ9tFDXHiHSG1SoZjPbaFJvFs6zHuD4=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] arm/mmu: Move init_ttbr to a new section .data.idmap
Message-Id: <E1rTTqA-0006bf-My@xenbits.xenproject.org>
Date: Fri, 26 Jan 2024 21:34:22 +0000

commit 5ed59e62c6f28cbf855605e4e558aa556d2ea8f5
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Thu Jan 25 18:32:38 2024 +0000
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu Jan 25 18:36:51 2024 +0000

    arm/mmu: Move init_ttbr to a new section .data.idmap
    
    With the upcoming work to color Xen, the binary will not be anymore
    physically contiguous. This will be a problem during boot as the
    assembly code will need to work out where each piece of Xen reside.
    
    An easy way to solve the issue is to have all code/data accessed
    by the secondary CPUs while the MMU is off within a single page.
    
    Right now, init_ttbr is used by secondary CPUs to find there page-tables
    before the MMU is on. Yet it is currently in .data which is unlikely
    to be within the same page as the rest of the idmap.
    
    Create a new section .data.idmap that will be used for variables
    accessed by the early boot code. The first one is init_ttbr.
    
    The idmap is currently part of the text section and therefore will
    be mapped read-only executable. This means that we need to temporarily
    remap init_ttbr in order to update it.
    
    Introduce a new function set_init_ttbr() for this purpose so the code
    is not duplicated between arm64 and arm32.
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Michal Orzel <michal.orzel@amd.com>
---
 xen/arch/arm/mmu/smpboot.c | 34 +++++++++++++++++++++++++++++-----
 xen/arch/arm/xen.lds.S     |  1 +
 2 files changed, 30 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/mmu/smpboot.c b/xen/arch/arm/mmu/smpboot.c
index b6fc0aae07..bc91fdfe33 100644
--- a/xen/arch/arm/mmu/smpboot.c
+++ b/xen/arch/arm/mmu/smpboot.c
@@ -9,6 +9,10 @@
 
 #include <asm/setup.h>
 
+/* Override macros from asm/page.h to make them work with mfn_t */
+#undef virt_to_mfn
+#define virt_to_mfn(va) _mfn(__virt_to_mfn(va))
+
 /*
  * Static start-of-day pagetables that we use before the allocators
  * are up. These are used by all CPUs during bringup before switching
@@ -44,7 +48,7 @@ DEFINE_BOOT_PAGE_TABLE(boot_second);
 DEFINE_BOOT_PAGE_TABLES(boot_third, XEN_NR_ENTRIES(2));
 
 /* Non-boot CPUs use this to find the correct pagetables. */
-uint64_t init_ttbr;
+uint64_t __section(".data.idmap") init_ttbr;
 
 /* Clear a translation table and clean & invalidate the cache */
 static void clear_table(void *table)
@@ -68,6 +72,27 @@ static void clear_boot_pagetables(void)
     clear_table(boot_third);
 }
 
+static void set_init_ttbr(lpae_t *root)
+{
+    /*
+     * init_ttbr is part of the identity mapping which is read-only. So
+     * we need to re-map the region so it can be updated.
+     */
+    void *ptr = map_domain_page(virt_to_mfn(&init_ttbr));
+
+    ptr += PAGE_OFFSET(&init_ttbr);
+
+    *(uint64_t *)ptr = virt_to_maddr(root);
+
+    /*
+     * init_ttbr will be accessed with the MMU off, so ensure the update
+     * is visible by cleaning the cache.
+     */
+    clean_dcache(ptr);
+
+    unmap_domain_page(ptr);
+}
+
 #ifdef CONFIG_ARM_64
 int prepare_secondary_mm(int cpu)
 {
@@ -77,8 +102,8 @@ int prepare_secondary_mm(int cpu)
      * Set init_ttbr for this CPU coming up. All CPUs share a single setof
      * pagetables, but rewrite it each time for consistency with 32 bit.
      */
-    init_ttbr = virt_to_maddr(xen_pgtable);
-    clean_dcache(init_ttbr);
+    set_init_ttbr(xen_pgtable);
+
     return 0;
 }
 #else
@@ -109,8 +134,7 @@ int prepare_secondary_mm(int cpu)
     clear_boot_pagetables();
 
     /* Set init_ttbr for this CPU coming up */
-    init_ttbr = __pa(first);
-    clean_dcache(init_ttbr);
+    set_init_ttbr(first);
 
     return 0;
 }
diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index 20598c6963..470c8f2208 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -36,6 +36,7 @@ SECTIONS
        *(.text.header)
        *(.text.idmap)
        *(.rodata.idmap)
+       *(.data.idmap)
        _idmap_end = .;
 
        *(.text.cold)
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Jan 26 21:34:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 26 Jan 2024 21:34:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.672528.1046656 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rTTqL-0005lR-PL; Fri, 26 Jan 2024 21:34:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 672528.1046656; Fri, 26 Jan 2024 21:34: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 1rTTqL-0005lJ-Me; Fri, 26 Jan 2024 21:34:33 +0000
Received: by outflank-mailman (input) for mailman id 672528;
 Fri, 26 Jan 2024 21:34: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 1rTTqK-0005jn-Ra
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:34: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 1rTTqK-0005Vw-Qn
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:34:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rTTqK-0006cS-Px
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:34: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=U9dtTBLcFIMdB7aYw3gfv5qpEP3KqlEVXRgl/7Dwouw=; b=nG5Krsk4Nl4JThNL1xxCc6EWha
	tx6p3/jHwelSQvXJDSt808CG1RqbBnBWcPJ2P9QyRS8X/9lTSYLQDzMFR3WmFFDRPCpa4Ukhf86SE
	WvuTttuJ/RGhtMo9fN72sxgQ0tJ6fLP8A9ZYRZc/PEVCxe2gpxubwB6cu9Jnxh7BwN5c=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] arm/smpboot: Move smp_up_cpu to a new section .data.idmap
Message-Id: <E1rTTqK-0006cS-Px@xenbits.xenproject.org>
Date: Fri, 26 Jan 2024 21:34:32 +0000

commit 9a5114074b046c65da222d025466000053fb4e8d
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Thu Jan 25 18:33:50 2024 +0000
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu Jan 25 18:36:51 2024 +0000

    arm/smpboot: Move smp_up_cpu to a new section .data.idmap
    
    With the upcoming work to color Xen, the binary will not be anymore
    physically contiguous. This will be a problem during boot as the
    assembly code will need to work out where each piece of Xen reside.
    
    An easy way to solve the issue is to have all code/data accessed
    by the secondary CPUs while the MMU is off within a single page.
    
    Right now, smp_up_cpu is used by secondary CPUs to wait their turn for
    booting before the MMU is on. Yet it is currently in .data which is
    unlikely to be within the same page as the rest of the idmap.
    
    Move smp_up_cpu to the recently created section .data.idmap. The idmap is
    currently part of the text section and therefore will be mapped read-only
    executable. This means that we need to temporarily remap
    smp_up_cpu in order to update it.
    
    Introduce a new function set_smp_up_cpu() for this purpose so the code
    is not duplicated between when opening and closing the gate.
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Michal Orzel <michal.orzel@amd.com>
---
 xen/arch/arm/smpboot.c | 36 +++++++++++++++++++++++++++++++-----
 1 file changed, 31 insertions(+), 5 deletions(-)

diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index 7110bc11fc..a7de105418 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -29,6 +29,10 @@
 #include <asm/psci.h>
 #include <asm/acpi.h>
 
+/* Override macros from asm/page.h to make them work with mfn_t */
+#undef virt_to_mfn
+#define virt_to_mfn(va) _mfn(__virt_to_mfn(va))
+
 cpumask_t cpu_online_map;
 cpumask_t cpu_present_map;
 cpumask_t cpu_possible_map;
@@ -56,7 +60,7 @@ struct init_info init_data =
 };
 
 /* Shared state for coordinating CPU bringup */
-unsigned long smp_up_cpu = MPIDR_INVALID;
+unsigned long __section(".data.idmap") smp_up_cpu = MPIDR_INVALID;
 /* Shared state for coordinating CPU teardown */
 static bool cpu_is_dead;
 
@@ -429,6 +433,28 @@ void stop_cpu(void)
         wfi();
 }
 
+static void set_smp_up_cpu(unsigned long mpidr)
+{
+    /*
+     * smp_up_cpu is part of the identity mapping which is read-only. So
+     * We need to re-map the region so it can be updated.
+     */
+    void *ptr = map_domain_page(virt_to_mfn(&smp_up_cpu));
+
+    ptr += PAGE_OFFSET(&smp_up_cpu);
+
+    *(unsigned long *)ptr = mpidr;
+
+    /*
+     * smp_up_cpu will be accessed with the MMU off, so ensure the update
+     * is visible by cleaning the cache.
+     */
+    clean_dcache(ptr);
+
+    unmap_domain_page(ptr);
+
+}
+
 int __init cpu_up_send_sgi(int cpu)
 {
     /* We don't know the GIC ID of the CPU until it has woken up, so just
@@ -460,8 +486,7 @@ int __cpu_up(unsigned int cpu)
     init_data.cpuid = cpu;
 
     /* Open the gate for this CPU */
-    smp_up_cpu = cpu_logical_map(cpu);
-    clean_dcache(smp_up_cpu);
+    set_smp_up_cpu(cpu_logical_map(cpu));
 
     rc = arch_cpu_up(cpu);
 
@@ -497,8 +522,9 @@ int __cpu_up(unsigned int cpu)
      */
     init_data.stack = NULL;
     init_data.cpuid = ~0;
-    smp_up_cpu = MPIDR_INVALID;
-    clean_dcache(smp_up_cpu);
+
+    set_smp_up_cpu(MPIDR_INVALID);
+
     arch_cpu_up_finish();
 
     if ( !cpu_online(cpu) )
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Fri Jan 26 21:34:43 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Fri, 26 Jan 2024 21:34:43 +0000
Received: from list by lists.xenproject.org with outflank-mailman.672529.1046661 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rTTqV-0005zE-Qz; Fri, 26 Jan 2024 21:34:43 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 672529.1046661; Fri, 26 Jan 2024 21:34: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 1rTTqV-0005z5-OF; Fri, 26 Jan 2024 21:34:43 +0000
Received: by outflank-mailman (input) for mailman id 672529;
 Fri, 26 Jan 2024 21:34: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 1rTTqU-0005yv-UY
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:34: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 1rTTqU-0005W3-Ts
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:34:42 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rTTqU-0006d7-T1
 for xen-changelog@lists.xenproject.org; Fri, 26 Jan 2024 21:34: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=4iTR3vfc9AaAqqlZS/hoyvv3q8XPgvseUICoLrJMvqA=; b=txHIv0sx3Dyz8Q0KVQyWpaRmmN
	iZO7TxEhg1culXvO8yvTEGAWZNuzvuJbZYZxhoz8o6Ep4Y8WG08TqkGJlPstwbax8lHAs/7lIrCRO
	oMBxbK7iKpxTZibA9l5Y/j0DV/t5Ir4kXsTHTG95oJ9FBkwoC0CLIfm/lsK1k07BMx88=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/arm64: head: Use PRINT_ID() for secondary CPU MMU-off boot code
Message-Id: <E1rTTqU-0006d7-T1@xenbits.xenproject.org>
Date: Fri, 26 Jan 2024 21:34:42 +0000

commit dbdd7e8df75030d0b1097eb5a1b3c3cb378a657b
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Thu Jan 25 18:36:27 2024 +0000
Commit:     Julien Grall <jgrall@amazon.com>
CommitDate: Thu Jan 25 18:36:51 2024 +0000

    xen/arm64: head: Use PRINT_ID() for secondary CPU MMU-off boot code
    
    With the upcoming work to color Xen, the binary will not be anymore
    physically contiguous. This will be a problem during boot as the
    assembly code will need to work out where each piece of Xen reside.
    
    An easy way to solve the issue is to have all code/data accessed
    by the secondary CPUs while the MMU is off within a single page.
    
    Right now, most of the early printk messages are using PRINT() which
    will add the message in .rodata. This is unlikely to be within the
    same page as the rest of the idmap.
    
    So replace all the PRINT() that can be reachable by the secondary
    CPU with MMU-off with PRINT_ID().
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Reviewed-by: Michal Orzel <michal.orzel@amd.com>
---
 xen/arch/arm/arm64/head.S               | 16 ++++++++--------
 xen/arch/arm/arm64/mmu/head.S           |  2 +-
 xen/arch/arm/include/asm/arm64/macros.h |  9 ++++++---
 3 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/xen/arch/arm/arm64/head.S b/xen/arch/arm/arm64/head.S
index cfc04c7554..fb297e9eb5 100644
--- a/xen/arch/arm/arm64/head.S
+++ b/xen/arch/arm/arm64/head.S
@@ -289,9 +289,9 @@ GLOBAL(init_secondary)
 
 #ifdef CONFIG_EARLY_PRINTK
         ldr   x23, =CONFIG_EARLY_UART_BASE_ADDRESS /* x23 := UART base address */
-        PRINT("- CPU ")
+        PRINT_ID("- CPU ")
         print_reg x24
-        PRINT(" booting -\r\n")
+        PRINT_ID(" booting -\r\n")
 #endif
         bl    check_cpu_mode
         bl    cpu_init
@@ -314,10 +314,10 @@ ENDPROC(init_secondary)
  * Clobbers x0 - x5
  */
 check_cpu_mode:
-        PRINT("- Current EL ")
+        PRINT_ID("- Current EL ")
         mrs   x5, CurrentEL
         print_reg x5
-        PRINT(" -\r\n")
+        PRINT_ID(" -\r\n")
 
         /* Are we in EL2 */
         cmp   x5, #PSR_MODE_EL2t
@@ -326,8 +326,8 @@ check_cpu_mode:
         ret
 1:
         /* OK, we're boned. */
-        PRINT("- Xen must be entered in NS EL2 mode -\r\n")
-        PRINT("- Please update the bootloader -\r\n")
+        PRINT_ID("- Xen must be entered in NS EL2 mode -\r\n")
+        PRINT_ID("- Please update the bootloader -\r\n")
         b fail
 ENDPROC(check_cpu_mode)
 
@@ -361,7 +361,7 @@ ENDPROC(zero_bss)
  * Clobbers x0 - x3
  */
 cpu_init:
-        PRINT("- Initialize CPU -\r\n")
+        PRINT_ID("- Initialize CPU -\r\n")
 
         /* Set up memory attribute type tables */
         ldr   x0, =MAIRVAL
@@ -424,7 +424,7 @@ launch:
 ENDPROC(launch)
 
 /* Fail-stop */
-fail:   PRINT("- Boot failed -\r\n")
+fail:   PRINT_ID("- Boot failed -\r\n")
 1:      wfe
         b     1b
 ENDPROC(fail)
diff --git a/xen/arch/arm/arm64/mmu/head.S b/xen/arch/arm/arm64/mmu/head.S
index 92b62ae94c..fa40b696dd 100644
--- a/xen/arch/arm/arm64/mmu/head.S
+++ b/xen/arch/arm/arm64/mmu/head.S
@@ -276,7 +276,7 @@ ENDPROC(create_page_tables)
 enable_mmu:
         mov   x4, x0
         mov   x5, x1
-        PRINT("- Turning on paging -\r\n")
+        PRINT_ID("- Turning on paging -\r\n")
 
         /*
          * The state of the TLBs is unknown before turning on the MMU.
diff --git a/xen/arch/arm/include/asm/arm64/macros.h b/xen/arch/arm/include/asm/arm64/macros.h
index 10e652041f..46f50655ad 100644
--- a/xen/arch/arm/include/asm/arm64/macros.h
+++ b/xen/arch/arm/include/asm/arm64/macros.h
@@ -39,9 +39,12 @@
  * There are multiple flavors:
  *  - PRINT_SECT(section, string): The @string will be located in @section
  *  - PRINT(): The string will be located in .rodata.str.
- *  - PRINT_ID(): When Xen is running on the Identity Mapping, it is
- *    only possible to have a limited amount of Xen. This will create
- *    the string in .rodata.idmap which will always be mapped.
+ *  - PRINT_ID(): This will create the string in .rodata.idmap which
+ *    will always be accessible. This is used when:
+ *      - Xen is running on the identity mapping because not all of Xen is mapped
+ *      - Running with the MMU-off on secondary CPUs as Xen may not be
+ *        physically contiguous in memory (e.g. in the case of cache
+ *        coloring).
  *
  * Clobbers x0 - x3
  */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Sat Jan 27 09:55:06 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Sat, 27 Jan 2024 09:55:06 +0000
Received: from list by lists.xenproject.org with outflank-mailman.672621.1046779 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rTfOv-0004CM-Pt; Sat, 27 Jan 2024 09:55:01 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 672621.1046779; Sat, 27 Jan 2024 09:55:01 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rTfOv-0004CE-N4; Sat, 27 Jan 2024 09:55:01 +0000
Received: by outflank-mailman (input) for mailman id 672621;
 Sat, 27 Jan 2024 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 1rTfOv-0004C8-CY
 for xen-changelog@lists.xenproject.org; Sat, 27 Jan 2024 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 1rTfOv-00026a-BX
 for xen-changelog@lists.xenproject.org; Sat, 27 Jan 2024 09:55:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rTfOv-0006kf-9N
 for xen-changelog@lists.xenproject.org; Sat, 27 Jan 2024 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=yokw0+UCkUHzG7/g7NrahW29PA0C3mgCPbnINKQ0Wp8=; b=nO6IUdTV8kmrFKZOiGds2lPOrr
	4dJDrhbYT7ZcL98CopCLhuCt+bCP1n4JT8Bg5iVchRQIdgPLwK9fMUvSY8w+AIjFohpjbE8yhOL4a
	X6DmOKJKF0kQwep2NLR1X2NJ63v8o+cZfXzFMEg0WAkHiSj2yurvAHHCqOy6T518m+dA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/entry: fix jump into restore_all_guest without %rbx correctly set
Message-Id: <E1rTfOv-0006kf-9N@xenbits.xenproject.org>
Date: Sat, 27 Jan 2024 09:55:01 +0000

commit c378ff8983cd69786c35117e49640f027e581bca
Author:     Roger Pau Monné <roger.pau@citrix.com>
AuthorDate: Fri Jan 26 15:54:18 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Fri Jan 26 19:07:30 2024 +0000

    x86/entry: fix jump into restore_all_guest without %rbx correctly set
    
    e047b8d0fa05 went too far when limiting obtaining the vCPU pointer.  While the
    code in ist_dispatch_done does indeed only need the vCPU pointer when PV32 is
    enabled, the !PV32 path will end up jumping into restore_all_guest which does
    require rbx == vCPU pointer.
    
    Fix by moving the fetching of the vCPU pointer to be done outside of the PV32
    code block.
    
    Fixes: e047b8d0fa05 ('x86/entry: replace two GET_CURRENT() uses')
    Reported-by: Edwin Torok <edwin.torok@cloud.com>
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/x86_64/entry.S | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/x86_64/entry.S b/xen/arch/x86/x86_64/entry.S
index 44f25def86..ecdd6e5b47 100644
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -1139,8 +1139,9 @@ FUNC(handle_ist_exception)
         movl  $EVENT_CHECK_VECTOR,%edi
         call  send_IPI_self
 1:
-#ifdef CONFIG_PV32
+        /* For restore_all_guest. */
         mov   STACK_CPUINFO_FIELD(current_vcpu)(%r14), %rbx
+#ifdef CONFIG_PV32
         movq  VCPU_domain(%rbx),%rax
         cmpb  $0,DOMAIN_is_32bit_pv(%rax)
         je    restore_all_guest
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 30 05:55:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 30 Jan 2024 05:55:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.673217.1047466 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rUh5L-0006PP-IP; Tue, 30 Jan 2024 05:55:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 673217.1047466; Tue, 30 Jan 2024 05: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 1rUh5L-0006PH-Fb; Tue, 30 Jan 2024 05:55:03 +0000
Received: by outflank-mailman (input) for mailman id 673217;
 Tue, 30 Jan 2024 05:55:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUh5K-0006PB-Dv
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 05:55:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUh5K-0007RA-5V
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 05:55:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUh5K-0000Dt-4T
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 05:55:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=4ZhskCQDKh5mqrK9Fixs1J2Wf+HBoZH1L+BpZjkz6o4=; b=ggkFx77TynqGxXpUwKo2+3ViUe
	vAn83Tz2V663W6vL1Np6nkjVHpsxodq/dWHiFl7TLA3rMuC7H0jbaM2inPPN+hx27CqZPLG4831Kx
	5wnjTLKLzjBe/iXZps+9zMH4QHet+bnNGPnZKLf4YtlkcqNZT+DxNPDjIrye5AhEnJ90=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] xen/vmap: Check the page has been mapped in vm_init_type()
Message-Id: <E1rUh5K-0000Dt-4T@xenbits.xenproject.org>
Date: Tue, 30 Jan 2024 05:55:02 +0000

commit a75c5aa2b22bea552ef5e0826e047dfcf61a9645
Author:     Julien Grall <jgrall@amazon.com>
AuthorDate: Mon Jan 29 09:20:02 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 29 09:20:02 2024 +0100

    xen/vmap: Check the page has been mapped in vm_init_type()
    
    The function map_pages_to_xen() could fail if it can't allocate the
    underlying page tables or (at least on Arm) if the area was already
    mapped.
    
    The first error is caught by clear_page() because it would fault.
    However, the second error while very unlikely is not caught at all.
    
    As this is boot code, use BUG_ON() to check if map_pages_to_xen() has
    succeeded.
    
    Signed-off-by: Julien Grall <jgrall@amazon.com>
    Signed-off-by: Elias El Yandouzi <eliasely@amazon.com>
    Acked-by: Jan Beulich <jbeulich@suse.com>
---
 xen/common/vmap.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/xen/common/vmap.c b/xen/common/vmap.c
index 330e2ba897..830f64c5ef 100644
--- a/xen/common/vmap.c
+++ b/xen/common/vmap.c
@@ -35,8 +35,11 @@ void __init vm_init_type(enum vmap_region type, void *start, void *end)
     for ( i = 0, va = (unsigned long)vm_bitmap(type); i < nr; ++i, va += PAGE_SIZE )
     {
         struct page_info *pg = alloc_domheap_page(NULL, 0);
+        int rc;
+
+        rc = map_pages_to_xen(va, page_to_mfn(pg), 1, PAGE_HYPERVISOR);
+        BUG_ON(rc);
 
-        map_pages_to_xen(va, page_to_mfn(pg), 1, PAGE_HYPERVISOR);
         clear_page((void *)va);
     }
     bitmap_fill(vm_bitmap(type), vm_low[type]);
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 30 05:55:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 30 Jan 2024 05:55:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.673218.1047469 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rUh5V-0006R5-Ja; Tue, 30 Jan 2024 05:55:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 673218.1047469; Tue, 30 Jan 2024 05: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 1rUh5V-0006Qy-HA; Tue, 30 Jan 2024 05:55:13 +0000
Received: by outflank-mailman (input) for mailman id 673218;
 Tue, 30 Jan 2024 05:55:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUh5U-0006Qq-9k
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 05:55:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUh5U-0007RU-8s
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 05:55:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUh5U-0000F9-7u
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 05:55:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=7a+yNr3arhifWXUtURDdsb1X3CT82Td1LW/NvMYzo4E=; b=LM2YI283D3lbG7z09HgyLygmtO
	lJhMKF94WWFnYdcEbG34m+lh8IZSoD3+l2VPeJhF2mhGVAIiIZ73qVwbqvTvbYx+kpt3cqX7aMgj2
	aKm6xZSutOfZ7EAlTNSO+rt9Fav1qrXkuXZ7y5QfPWVKDx2f0HWmrArMoohQ8qg/9Y6U=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] NUMA: no need for asm/numa.h when !NUMA
Message-Id: <E1rUh5U-0000F9-7u@xenbits.xenproject.org>
Date: Tue, 30 Jan 2024 05:55:12 +0000

commit 10978783389ee8b4d9841654adddc296741f56f3
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 29 09:21:16 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 29 09:21:16 2024 +0100

    NUMA: no need for asm/numa.h when !NUMA
    
    There's no point in every architecture carrying the same stubs for the
    case when NUMA isn't enabled (or even supported). Move all of that to
    xen/numa.h; replace explicit uses of asm/numa.h in common code. Make
    inclusion of asm/numa.h dependent upon NUMA=y.
    
    Drop the no longer applicable "implement NUMA support" comments - in a
    !NUMA section this simply makes no sense.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Shawn Anastasio <sanastasio@raptorengineering.com>
    Acked-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
    Acked-by: Julien Grall <jgrall@amazon.com>
---
 xen/arch/arm/include/asm/numa.h | 31 -------------------------------
 xen/arch/arm/smpboot.c          |  2 +-
 xen/arch/ppc/include/asm/numa.h | 20 --------------------
 xen/common/page_alloc.c         |  1 -
 xen/common/sysctl.c             |  2 +-
 xen/include/xen/domain.h        |  2 +-
 xen/include/xen/numa.h          | 16 ++++++++++++++++
 xen/include/xen/pci.h           |  2 +-
 8 files changed, 20 insertions(+), 56 deletions(-)

diff --git a/xen/arch/arm/include/asm/numa.h b/xen/arch/arm/include/asm/numa.h
deleted file mode 100644
index a2c1da4a82..0000000000
--- a/xen/arch/arm/include/asm/numa.h
+++ /dev/null
@@ -1,31 +0,0 @@
-#ifndef __ARCH_ARM_NUMA_H
-#define __ARCH_ARM_NUMA_H
-
-#include <xen/mm.h>
-
-typedef u8 nodeid_t;
-
-#ifndef CONFIG_NUMA
-
-/* Fake one node for now. See also node_online_map. */
-#define cpu_to_node(cpu) 0
-#define node_to_cpumask(node)   (cpu_online_map)
-
-/* XXX: implement NUMA support */
-#define node_spanned_pages(nid) (max_page - mfn_x(first_valid_mfn))
-#define node_start_pfn(nid) (mfn_x(first_valid_mfn))
-#define __node_distance(a, b) (20)
-
-#endif
-
-#define arch_want_default_dmazone() (false)
-
-#endif /* __ARCH_ARM_NUMA_H */
-/*
- * Local variables:
- * mode: C
- * c-file-style: "BSD"
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- */
diff --git a/xen/arch/arm/smpboot.c b/xen/arch/arm/smpboot.c
index a7de105418..119bfa3160 100644
--- a/xen/arch/arm/smpboot.c
+++ b/xen/arch/arm/smpboot.c
@@ -46,7 +46,7 @@ integer_param("maxcpus", max_cpus);
 /* CPU logical map: map xen cpuid to an MPIDR */
 register_t __cpu_logical_map[NR_CPUS] = { [0 ... NR_CPUS-1] = MPIDR_INVALID };
 
-/* Fake one node for now. See also asm/numa.h */
+/* Fake one node for now. See also xen/numa.h */
 nodemask_t __read_mostly node_online_map = { { [0] = 1UL } };
 
 /* Xen stack for bringing up the first CPU. */
diff --git a/xen/arch/ppc/include/asm/numa.h b/xen/arch/ppc/include/asm/numa.h
deleted file mode 100644
index 204180ad5b..0000000000
--- a/xen/arch/ppc/include/asm/numa.h
+++ /dev/null
@@ -1,20 +0,0 @@
-#ifndef __ASM_PPC_NUMA_H__
-#define __ASM_PPC_NUMA_H__
-
-#include <xen/types.h>
-#include <xen/mm.h>
-
-typedef uint8_t nodeid_t;
-
-/* Fake one node for now. See also node_online_map. */
-#define cpu_to_node(cpu) 0
-#define node_to_cpumask(node)   (cpu_online_map)
-
-/* XXX: implement NUMA support */
-#define node_spanned_pages(nid) (max_page - mfn_x(first_valid_mfn))
-#define node_start_pfn(nid) (mfn_x(first_valid_mfn))
-#define __node_distance(a, b) (20)
-
-#define arch_want_default_dmazone() (false)
-
-#endif /* __ASM_PPC_NUMA_H__ */
diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c
index 740b6f0ff7..2f4f2859c4 100644
--- a/xen/common/page_alloc.c
+++ b/xen/common/page_alloc.c
@@ -138,7 +138,6 @@
 #include <xen/spinlock.h>
 
 #include <asm/flushtlb.h>
-#include <asm/numa.h>
 #include <asm/page.h>
 
 #include <public/sysctl.h>
diff --git a/xen/common/sysctl.c b/xen/common/sysctl.c
index 3e2cc4906c..2906f3f294 100644
--- a/xen/common/sysctl.c
+++ b/xen/common/sysctl.c
@@ -22,8 +22,8 @@
 #include <asm/current.h>
 #include <xen/hypercall.h>
 #include <public/sysctl.h>
-#include <asm/numa.h>
 #include <xen/nodemask.h>
+#include <xen/numa.h>
 #include <xsm/xsm.h>
 #include <xen/pmstat.h>
 #include <xen/livepatch.h>
diff --git a/xen/include/xen/domain.h b/xen/include/xen/domain.h
index d345278b71..b1a4aa6f38 100644
--- a/xen/include/xen/domain.h
+++ b/xen/include/xen/domain.h
@@ -2,6 +2,7 @@
 #ifndef __XEN_DOMAIN_H__
 #define __XEN_DOMAIN_H__
 
+#include <xen/numa.h>
 #include <xen/types.h>
 
 #include <public/xen.h>
@@ -12,7 +13,6 @@ struct guest_area {
 };
 
 #include <asm/domain.h>
-#include <asm/numa.h>
 
 typedef union {
     struct vcpu_guest_context *nat;
diff --git a/xen/include/xen/numa.h b/xen/include/xen/numa.h
index a10d4b1778..fd1511a6fb 100644
--- a/xen/include/xen/numa.h
+++ b/xen/include/xen/numa.h
@@ -2,7 +2,13 @@
 #define _XEN_NUMA_H
 
 #include <xen/mm-frame.h>
+
+#ifdef CONFIG_NUMA
+#include <xen/pdx.h>
 #include <asm/numa.h>
+#else
+typedef uint8_t nodeid_t;
+#endif
 
 #define NUMA_NO_NODE     0xFF
 #define NUMA_NO_DISTANCE 0xFF
@@ -108,8 +114,18 @@ extern void numa_set_processor_nodes_parsed(nodeid_t node);
 
 #else
 
+/* Fake one node for now. See also node_online_map. */
+#define cpu_to_node(cpu) 0
+#define node_to_cpumask(node)   cpu_online_map
+
+#define arch_want_default_dmazone() false
+
 extern mfn_t first_valid_mfn;
 
+#define node_spanned_pages(nid) (max_page - mfn_x(first_valid_mfn))
+#define node_start_pfn(nid) mfn_x(first_valid_mfn)
+#define __node_distance(a, b) 20
+
 static inline nodeid_t mfn_to_nid(mfn_t mfn)
 {
     return 0;
diff --git a/xen/include/xen/pci.h b/xen/include/xen/pci.h
index 54a974abc6..aabc5465a7 100644
--- a/xen/include/xen/pci.h
+++ b/xen/include/xen/pci.h
@@ -11,10 +11,10 @@
 #include <xen/list.h>
 #include <xen/spinlock.h>
 #include <xen/irq.h>
+#include <xen/numa.h>
 #include <xen/pci_regs.h>
 #include <xen/pfn.h>
 #include <asm/device.h>
-#include <asm/numa.h>
 
 /*
  * The PCI interface treats multi-function devices as independent
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 30 05:55:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 30 Jan 2024 05:55:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.673219.1047473 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rUh5f-0006Tc-LD; Tue, 30 Jan 2024 05:55:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 673219.1047473; Tue, 30 Jan 2024 05:55:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rUh5f-0006TU-Id; Tue, 30 Jan 2024 05:55:23 +0000
Received: by outflank-mailman (input) for mailman id 673219;
 Tue, 30 Jan 2024 05:55:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUh5e-0006TK-D4
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 05:55:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUh5e-0007Rf-CG
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 05:55:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUh5e-0000Gj-BG
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 05:55:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=SrjWSg3yYN0ftMQoX/dKfhKjIB/tOWSPlVdaa4QU/tc=; b=nf0jGUh0vvEbEgdzNMqtNyAMOl
	bk74Vs5KblIUweBdWtfjEwh6ADlznCcxNZ8MIXJ+1P/U2//Lt/E3FlU8HsaP1SKvGWE2UrfORtOUP
	RmNo0sFU6C5EZD3EPvm8LxbcLn78qu9iYKL70uUMVpcX0f5lpXzRZufQ1PaY3ELjvYRM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/APIC: purge {GET,SET}_APIC_DELIVERY_MODE()
Message-Id: <E1rUh5e-0000Gj-BG@xenbits.xenproject.org>
Date: Tue, 30 Jan 2024 05:55:22 +0000

commit 439676165432ca687c3194701d0b014f1d67b9bb
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 29 09:22:35 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 29 09:22:35 2024 +0100

    x86/APIC: purge {GET,SET}_APIC_DELIVERY_MODE()
    
    The few uses we have can easily be replaced, eliminating the need for
    redundant APIC_DM_* and APIC_MODE_* constants. Therefore also purge all
    respective APIC_MODE_* constants, introducing APIC_DM_MASK anew instead.
    This is further relevant since we have a different set of APIC_MODE_*,
    which could otherwise end up confusing.
    
    No functional change intended.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/apic.c                 | 10 ++++------
 xen/arch/x86/cpu/mcheck/mce_intel.c |  4 ++--
 xen/arch/x86/cpu/vpmu.c             |  6 +++---
 xen/arch/x86/hvm/vlapic.c           | 18 +++++++++---------
 xen/arch/x86/include/asm/apicdef.h  |  7 +------
 xen/arch/x86/oprofile/nmi_int.c     |  2 +-
 6 files changed, 20 insertions(+), 27 deletions(-)

diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c
index da41d2dfed..a69ac90405 100644
--- a/xen/arch/x86/apic.c
+++ b/xen/arch/x86/apic.c
@@ -263,22 +263,20 @@ void disconnect_bsp_APIC(int virt_wire_setup)
         if (!virt_wire_setup) {
             /* For LVT0 make it edge triggered, active high, external and enabled */
             value = apic_read(APIC_LVT0);
-            value &= ~(APIC_MODE_MASK | APIC_SEND_PENDING |
+            value &= ~(APIC_DM_MASK | APIC_SEND_PENDING |
                        APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
                        APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED );
-            value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
-            value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_EXTINT);
+            value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING | APIC_DM_EXTINT;
             apic_write(APIC_LVT0, value);
         }
 
         /* For LVT1 make it edge triggered, active high, nmi and enabled */
         value = apic_read(APIC_LVT1);
         value &= ~(
-            APIC_MODE_MASK | APIC_SEND_PENDING |
+            APIC_DM_MASK | APIC_SEND_PENDING |
             APIC_INPUT_POLARITY | APIC_LVT_REMOTE_IRR |
             APIC_LVT_LEVEL_TRIGGER | APIC_LVT_MASKED);
-        value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING;
-        value = SET_APIC_DELIVERY_MODE(value, APIC_MODE_NMI);
+        value |= APIC_LVT_REMOTE_IRR | APIC_SEND_PENDING | APIC_DM_NMI;
         apic_write(APIC_LVT1, value);
     }
 }
diff --git a/xen/arch/x86/cpu/mcheck/mce_intel.c b/xen/arch/x86/cpu/mcheck/mce_intel.c
index a99f9cce9d..7f9b87f973 100644
--- a/xen/arch/x86/cpu/mcheck/mce_intel.c
+++ b/xen/arch/x86/cpu/mcheck/mce_intel.c
@@ -139,12 +139,12 @@ static void intel_init_thermal(struct cpuinfo_x86 *c)
      * BIOS has programmed on AP based on BSP's info we saved (since BIOS
      * is required to set the same value for all threads/cores).
      */
-    if ( (val & APIC_MODE_MASK) != APIC_DM_FIXED
+    if ( (val & APIC_DM_MASK) != APIC_DM_FIXED
          || (val & APIC_VECTOR_MASK) > 0xf )
         apic_write(APIC_LVTTHMR, val);
 
     if ( (msr_content & (1ULL<<3))
-         && (val & APIC_MODE_MASK) == APIC_DM_SMI )
+         && (val & APIC_DM_MASK) == APIC_DM_SMI )
     {
         if ( c == &boot_cpu_data )
             printk(KERN_DEBUG "Thermal monitoring handled by SMI\n");
diff --git a/xen/arch/x86/cpu/vpmu.c b/xen/arch/x86/cpu/vpmu.c
index 2e08d2363c..b2e9881e06 100644
--- a/xen/arch/x86/cpu/vpmu.c
+++ b/xen/arch/x86/cpu/vpmu.c
@@ -308,12 +308,12 @@ void vpmu_do_interrupt(void)
 
     vlapic_lvtpc = vlapic_get_reg(vlapic, APIC_LVTPC);
 
-    switch ( GET_APIC_DELIVERY_MODE(vlapic_lvtpc) )
+    switch ( vlapic_lvtpc & APIC_DM_MASK )
     {
-    case APIC_MODE_FIXED:
+    case APIC_DM_FIXED:
         vlapic_set_irq(vlapic, vlapic_lvtpc & APIC_VECTOR_MASK, 0);
         break;
-    case APIC_MODE_NMI:
+    case APIC_DM_NMI:
         sampling->arch.nmi_pending = true;
         break;
     }
diff --git a/xen/arch/x86/hvm/vlapic.c b/xen/arch/x86/hvm/vlapic.c
index 405bcd9a1c..71a4b954b0 100644
--- a/xen/arch/x86/hvm/vlapic.c
+++ b/xen/arch/x86/hvm/vlapic.c
@@ -39,7 +39,7 @@
     (APIC_LVT_MASKED | APIC_SEND_PENDING | APIC_VECTOR_MASK)
 
 #define LINT_MASK   \
-    (LVT_MASK | APIC_MODE_MASK | APIC_INPUT_POLARITY |\
+    (LVT_MASK | APIC_DM_MASK | APIC_INPUT_POLARITY |\
     APIC_LVT_REMOTE_IRR | APIC_LVT_LEVEL_TRIGGER)
 
 static const unsigned int vlapic_lvt_mask[VLAPIC_LVT_NUM] =
@@ -47,9 +47,9 @@ static const unsigned int vlapic_lvt_mask[VLAPIC_LVT_NUM] =
      /* LVTT */
      LVT_MASK | APIC_TIMER_MODE_MASK,
      /* LVTTHMR */
-     LVT_MASK | APIC_MODE_MASK,
+     LVT_MASK | APIC_DM_MASK,
      /* LVTPC */
-     LVT_MASK | APIC_MODE_MASK,
+     LVT_MASK | APIC_DM_MASK,
      /* LVT0-1 */
      LINT_MASK, LINT_MASK,
      /* LVTERR */
@@ -260,7 +260,7 @@ static void vlapic_init_sipi_one(struct vcpu *target, uint32_t icr)
 {
     vcpu_pause(target);
 
-    switch ( icr & APIC_MODE_MASK )
+    switch ( icr & APIC_DM_MASK )
     {
     case APIC_DM_INIT: {
         bool fpu_initialised;
@@ -329,7 +329,7 @@ static void vlapic_accept_irq(struct vcpu *v, uint32_t icr_low)
     struct vlapic *vlapic = vcpu_vlapic(v);
     uint8_t vector = (uint8_t)icr_low;
 
-    switch ( icr_low & APIC_MODE_MASK )
+    switch ( icr_low & APIC_DM_MASK )
     {
     case APIC_DM_FIXED:
     case APIC_DM_LOWEST:
@@ -488,7 +488,7 @@ void vlapic_ipi(
 
     dest = _VLAPIC_ID(vlapic, icr_high);
 
-    switch ( icr_low & APIC_MODE_MASK )
+    switch ( icr_low & APIC_DM_MASK )
     {
     case APIC_DM_INIT:
     case APIC_DM_STARTUP:
@@ -993,7 +993,7 @@ int guest_wrmsr_x2apic(struct vcpu *v, uint32_t msr, uint64_t val)
     case APIC_LVTTHMR:
     case APIC_LVTPC:
     case APIC_CMCI:
-        if ( val & ~(LVT_MASK | APIC_MODE_MASK) )
+        if ( val & ~(LVT_MASK | APIC_DM_MASK) )
             return X86EMUL_EXCEPTION;
         break;
 
@@ -1017,7 +1017,7 @@ int guest_wrmsr_x2apic(struct vcpu *v, uint32_t msr, uint64_t val)
         break;
 
     case APIC_ICR:
-        if ( (uint32_t)val & ~(APIC_VECTOR_MASK | APIC_MODE_MASK |
+        if ( (uint32_t)val & ~(APIC_VECTOR_MASK | APIC_DM_MASK |
                                APIC_DEST_MASK | APIC_INT_ASSERT |
                                APIC_INT_LEVELTRIG | APIC_SHORT_MASK) )
             return X86EMUL_EXCEPTION;
@@ -1266,7 +1266,7 @@ static int __vlapic_accept_pic_intr(struct vcpu *v)
               redir0.fields.dest_id == VLAPIC_ID(vlapic) &&
               !vlapic_disabled(vlapic)) ||
              /* LAPIC has LVT0 unmasked for ExtInts? */
-             ((lvt0 & (APIC_MODE_MASK|APIC_LVT_MASKED)) == APIC_DM_EXTINT) ||
+             ((lvt0 & (APIC_DM_MASK | APIC_LVT_MASKED)) == APIC_DM_EXTINT) ||
              /* LAPIC is fully disabled? */
              vlapic_hw_disabled(vlapic)));
 }
diff --git a/xen/arch/x86/include/asm/apicdef.h b/xen/arch/x86/include/asm/apicdef.h
index c4068ccc10..b0790fad1c 100644
--- a/xen/arch/x86/include/asm/apicdef.h
+++ b/xen/arch/x86/include/asm/apicdef.h
@@ -68,6 +68,7 @@
 #define			APIC_DEST_MASK		0x00800
 #define			APIC_DEST_LOGICAL	0x00800
 #define			APIC_DEST_PHYSICAL	0x00000
+#define			APIC_DM_MASK		0x00700
 #define			APIC_DM_FIXED		0x00000
 #define			APIC_DM_LOWEST		0x00100
 #define			APIC_DM_SMI		0x00200
@@ -95,12 +96,6 @@
 #define			APIC_LVT_REMOTE_IRR		(1<<14)
 #define			APIC_INPUT_POLARITY		(1<<13)
 #define			APIC_SEND_PENDING		(1<<12)
-#define			APIC_MODE_MASK			0x700
-#define			GET_APIC_DELIVERY_MODE(x)	(((x)>>8)&0x7)
-#define			SET_APIC_DELIVERY_MODE(x,y)	(((x)&~0x700)|((y)<<8))
-#define				APIC_MODE_FIXED		0x0
-#define				APIC_MODE_NMI		0x4
-#define				APIC_MODE_EXTINT	0x7
 #define 	APIC_LVT1	0x360
 #define		APIC_LVTERR	0x370
 #define		APIC_TMICT	0x380
diff --git a/xen/arch/x86/oprofile/nmi_int.c b/xen/arch/x86/oprofile/nmi_int.c
index 1313818af8..fa3071d977 100644
--- a/xen/arch/x86/oprofile/nmi_int.c
+++ b/xen/arch/x86/oprofile/nmi_int.c
@@ -290,7 +290,7 @@ static void cf_check nmi_cpu_stop(void *dummy)
 	 * power on apic lvt contain a zero vector nr which are legal only for
 	 * NMI delivery mode. So inhibit apic err before restoring lvtpc
 	 */
-	if ( (apic_read(APIC_LVTPC) & APIC_MODE_MASK) != APIC_DM_NMI
+	if ( (apic_read(APIC_LVTPC) & APIC_DM_MASK) != APIC_DM_NMI
 	     || (apic_read(APIC_LVTPC) & APIC_LVT_MASKED) )
 	{
 		printk("nmi_stop: APIC not good %ul\n", apic_read(APIC_LVTPC));
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 30 05:55:33 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 30 Jan 2024 05:55:33 +0000
Received: from list by lists.xenproject.org with outflank-mailman.673220.1047478 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rUh5p-0006WE-MU; Tue, 30 Jan 2024 05:55:33 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 673220.1047478; Tue, 30 Jan 2024 05:55:33 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rUh5p-0006W7-K5; Tue, 30 Jan 2024 05:55:33 +0000
Received: by outflank-mailman (input) for mailman id 673220;
 Tue, 30 Jan 2024 05:55:32 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUh5o-0006Vz-GF
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 05:55:32 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUh5o-0007Ro-FX
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 05:55:32 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUh5o-0000HA-EO
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 05:55:32 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=CGqWfb908XhBg9715Vu1tcC/uYF2YIIl9MUQVPjHiGU=; b=dpE6ZPG4MIwcRhsHRY+1RNoaQI
	ZlXrZxCkt2cKvsfl1Y7teYnleqryDPqrzsmOG/5jwjwQ3PhXKSeCloL/4hmFSleQVsN05UhuVsA1X
	hAouJahOXJ1kjLWrZYPudnYYpCEqYUHRFUpRzi8dawHn8RqNiHQ/BYHf87u1XjlFJ86E=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86: purge NMI_IO_APIC
Message-Id: <E1rUh5o-0000HA-EO@xenbits.xenproject.org>
Date: Tue, 30 Jan 2024 05:55:32 +0000

commit 40a74677023a5eb20d7bbc09def37884f80919bd
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Mon Jan 29 09:23:43 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Mon Jan 29 09:23:43 2024 +0100

    x86: purge NMI_IO_APIC
    
    Even going back to 3.2 source code, I can't spot how this watchdog mode
    could ever have been enabled in Xen. The only effect its presence had
    for all the years was the retaining of a dead string literal.
    
    Signed-off-by: Jan Beulich <jbeulich@suse.com>
    Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
 xen/arch/x86/include/asm/apic.h | 3 +--
 xen/arch/x86/io_apic.c          | 5 -----
 2 files changed, 1 insertion(+), 7 deletions(-)

diff --git a/xen/arch/x86/include/asm/apic.h b/xen/arch/x86/include/asm/apic.h
index b20fae7ebc..d1cb001fb4 100644
--- a/xen/arch/x86/include/asm/apic.h
+++ b/xen/arch/x86/include/asm/apic.h
@@ -186,7 +186,6 @@ extern void check_nmi_watchdog(void);
 
 extern unsigned int nmi_watchdog;
 #define NMI_NONE	0
-#define NMI_IO_APIC	1
-#define NMI_LOCAL_APIC	2
+#define NMI_LOCAL_APIC	1
 
 #endif /* __ASM_APIC_H */
diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c
index dd25ba3943..b48a642465 100644
--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -2004,11 +2004,6 @@ static void __init check_timer(void)
     }
     printk(" failed.\n");
 
-    if (nmi_watchdog == NMI_IO_APIC) {
-        printk(KERN_WARNING "timer doesn't work through the IO-APIC - disabling NMI Watchdog!\n");
-        nmi_watchdog = 0;
-    }
-
     printk(KERN_INFO "...trying to set up timer as Virtual Wire IRQ...");
 
     disable_8259A_irq(irq_to_desc(0));
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 30 23:44:08 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 30 Jan 2024 23:44:08 +0000
Received: from list by lists.xenproject.org with outflank-mailman.673722.1048184 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rUxlr-00049U-HN; Tue, 30 Jan 2024 23:44:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 673722.1048184; Tue, 30 Jan 2024 23:44:03 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rUxlr-00049N-Ei; Tue, 30 Jan 2024 23:44:03 +0000
Received: by outflank-mailman (input) for mailman id 673722;
 Tue, 30 Jan 2024 23:44:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUxlq-00049H-9f
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 23:44:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUxlq-00037Y-8o
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 23:44:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUxlq-0001YK-7f
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 23:44:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=GcNJLyFOE4u72TsVtLPE2760lHk5US0Vi7Iwpq/bfUE=; b=LmRWidTeQRUgk+oWAHe7zjHCYs
	wshKUrJGyUAeSF2X+xCzsvv9600yUj71wE7UfvbAhgenH/o73Woud5fmy2Hgv2hr1G4U2rDs7Pw7V
	5MeCgApFJuyAwmww5v9jxkTqcCOXs9ISW9sRl96YoJ3b7Sla30YmSwzuGe19YiLFKR9s=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/iommu: remove regions not to be mapped
Message-Id: <E1rUxlq-0001YK-7f@xenbits.xenproject.org>
Date: Tue, 30 Jan 2024 23:44:02 +0000

commit 79fcc0e9d7df3a53cf69880729a43c1a8d3d8631
Author:     Roger Pau Monne <roger.pau@citrix.com>
AuthorDate: Thu Jan 25 14:26:26 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Jan 29 17:23:35 2024 +0000

    x86/iommu: remove regions not to be mapped
    
    Introduce the code to remove regions not to be mapped from the rangeset
    that will be used to setup the IOMMU page tables for the hardware domain.
    
    This change also introduces two new functions: remove_xen_ranges() and
    vpci_subtract_mmcfg() that copy the logic in xen_in_range() and
    vpci_is_mmcfg_address() respectively and remove the ranges that would otherwise
    be intercepted by the original functions.
    
    Note that the rangeset is still not populated.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Paul Durrant <paul@xen.org>
---
 xen/arch/x86/hvm/io.c               | 16 ++++++++++
 xen/arch/x86/include/asm/hvm/io.h   |  3 ++
 xen/arch/x86/include/asm/setup.h    |  1 +
 xen/arch/x86/setup.c                | 48 +++++++++++++++++++++++++++++
 xen/drivers/passthrough/x86/iommu.c | 61 +++++++++++++++++++++++++++++++++++++
 5 files changed, 129 insertions(+)

diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c
index d75af83ad0..a42854c52b 100644
--- a/xen/arch/x86/hvm/io.c
+++ b/xen/arch/x86/hvm/io.c
@@ -369,6 +369,22 @@ bool vpci_is_mmcfg_address(const struct domain *d, paddr_t addr)
     return vpci_mmcfg_find(d, addr);
 }
 
+int __hwdom_init vpci_subtract_mmcfg(const struct domain *d, struct rangeset *r)
+{
+    const struct hvm_mmcfg *mmcfg;
+
+    list_for_each_entry ( mmcfg, &d->arch.hvm.mmcfg_regions, next )
+    {
+        int rc = rangeset_remove_range(r, PFN_DOWN(mmcfg->addr),
+                                       PFN_DOWN(mmcfg->addr + mmcfg->size - 1));
+
+        if ( rc )
+            return rc;
+    }
+
+    return 0;
+}
+
 static unsigned int vpci_mmcfg_decode_addr(const struct hvm_mmcfg *mmcfg,
                                            paddr_t addr, pci_sbdf_t *sbdf)
 {
diff --git a/xen/arch/x86/include/asm/hvm/io.h b/xen/arch/x86/include/asm/hvm/io.h
index a977316578..e1e5e6fe74 100644
--- a/xen/arch/x86/include/asm/hvm/io.h
+++ b/xen/arch/x86/include/asm/hvm/io.h
@@ -156,6 +156,9 @@ void destroy_vpci_mmcfg(struct domain *d);
 /* Check if an address is between a MMCFG region for a domain. */
 bool vpci_is_mmcfg_address(const struct domain *d, paddr_t addr);
 
+/* Remove MMCFG regions from a given rangeset. */
+int vpci_subtract_mmcfg(const struct domain *d, struct rangeset *r);
+
 #endif /* __ASM_X86_HVM_IO_H__ */
 
 
diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h
index 9a460e4db8..cd07d98101 100644
--- a/xen/arch/x86/include/asm/setup.h
+++ b/xen/arch/x86/include/asm/setup.h
@@ -37,6 +37,7 @@ void discard_initial_images(void);
 void *bootstrap_map(const module_t *mod);
 
 int xen_in_range(unsigned long mfn);
+int remove_xen_ranges(struct rangeset *r);
 
 extern uint8_t kbd_shift_flags;
 
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 897b7e9208..ee233c69f1 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -2138,6 +2138,54 @@ int __hwdom_init xen_in_range(unsigned long mfn)
     return 0;
 }
 
+int __hwdom_init remove_xen_ranges(struct rangeset *r)
+{
+    paddr_t start, end;
+    int rc;
+
+    /* S3 resume code (and other real mode trampoline code) */
+    rc = rangeset_remove_range(r, PFN_DOWN(bootsym_phys(trampoline_start)),
+                               PFN_DOWN(bootsym_phys(trampoline_end) - 1));
+    if ( rc )
+        return rc;
+
+    /*
+     * This needs to remain in sync with the uses of the same symbols in
+     * - __start_xen()
+     * - is_xen_fixed_mfn()
+     * - tboot_shutdown()
+     */
+    /* hypervisor .text + .rodata */
+    rc = rangeset_remove_range(r, PFN_DOWN(__pa(&_stext)),
+                               PFN_DOWN(__pa(&__2M_rodata_end) - 1));
+    if ( rc )
+        return rc;
+
+    /* hypervisor .data + .bss */
+    if ( efi_boot_mem_unused(&start, &end) )
+    {
+        ASSERT(__pa(start) >= __pa(&__2M_rwdata_start));
+        rc = rangeset_remove_range(r, PFN_DOWN(__pa(&__2M_rwdata_start)),
+                                   PFN_DOWN(__pa(start) - 1));
+        if ( rc )
+            return rc;
+        ASSERT(__pa(end) <= __pa(&__2M_rwdata_end));
+        rc = rangeset_remove_range(r, PFN_DOWN(__pa(end)),
+                                   PFN_DOWN(__pa(&__2M_rwdata_end) - 1));
+        if ( rc )
+            return rc;
+    }
+    else
+    {
+        rc = rangeset_remove_range(r, PFN_DOWN(__pa(&__2M_rwdata_start)),
+                                   PFN_DOWN(__pa(&__2M_rwdata_end) - 1));
+        if ( rc )
+            return rc;
+    }
+
+    return 0;
+}
+
 static int __hwdom_init cf_check io_bitmap_cb(
     unsigned long s, unsigned long e, void *ctx)
 {
diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c
index 59b0c7e980..fc5215a9dc 100644
--- a/xen/drivers/passthrough/x86/iommu.c
+++ b/xen/drivers/passthrough/x86/iommu.c
@@ -370,6 +370,14 @@ static unsigned int __hwdom_init hwdom_iommu_map(const struct domain *d,
     return perms;
 }
 
+static int __hwdom_init cf_check map_subtract(unsigned long s, unsigned long e,
+                                              void *data)
+{
+    struct rangeset *map = data;
+
+    return rangeset_remove_range(map, s, e);
+}
+
 struct map_data {
     struct domain *d;
     unsigned int flush_flags;
@@ -533,6 +541,59 @@ void __hwdom_init arch_iommu_hwdom_init(struct domain *d)
             goto commit;
     }
 
+    /* Remove any areas in-use by Xen. */
+    rc = remove_xen_ranges(map);
+    if ( rc )
+        panic("IOMMU failed to remove Xen ranges: %d\n", rc);
+
+    /* Remove any overlap with the Interrupt Address Range. */
+    rc = rangeset_remove_range(map, 0xfee00, 0xfeeff);
+    if ( rc )
+        panic("IOMMU failed to remove Interrupt Address Range: %d\n", rc);
+
+    /* If emulating IO-APIC(s) make sure the base address is unmapped. */
+    if ( has_vioapic(d) )
+    {
+        for ( i = 0; i < d->arch.hvm.nr_vioapics; i++ )
+        {
+            rc = rangeset_remove_singleton(map,
+                PFN_DOWN(domain_vioapic(d, i)->base_address));
+            if ( rc )
+                panic("IOMMU failed to remove IO-APIC: %d\n", rc);
+        }
+    }
+
+    if ( is_pv_domain(d) )
+    {
+        /*
+         * Be consistent with CPU mappings: Dom0 is permitted to establish r/o
+         * ones there (also for e.g. HPET in certain cases), so it should also
+         * have such established for IOMMUs.  Remove any read-only ranges here,
+         * since ranges in mmio_ro_ranges are already explicitly mapped below
+         * in read-only mode.
+         */
+        rc = rangeset_report_ranges(mmio_ro_ranges, 0, ~0UL, map_subtract, map);
+        if ( rc )
+            panic("IOMMU failed to remove read-only regions: %d\n", rc);
+    }
+
+    if ( has_vpci(d) )
+    {
+        /*
+         * TODO: runtime added MMCFG regions are not checked to make sure they
+         * don't overlap with already mapped regions, thus preventing trapping.
+         */
+        rc = vpci_subtract_mmcfg(d, map);
+        if ( rc )
+            panic("IOMMU unable to remove MMCFG areas: %d\n", rc);
+    }
+
+    /* Remove any regions past the last address addressable by the domain. */
+    rc = rangeset_remove_range(map, PFN_DOWN(1UL << domain_max_paddr_bits(d)),
+                               ~0UL);
+    if ( rc )
+        panic("IOMMU unable to remove unaddressable ranges: %d\n", rc);
+
     if ( iommu_verbose )
         printk(XENLOG_INFO "%pd: identity mappings for IOMMU:\n", d);
 
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 30 23:44:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 30 Jan 2024 23:44:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.673723.1048188 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rUxm1-0004Bs-J6; Tue, 30 Jan 2024 23:44:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 673723.1048188; Tue, 30 Jan 2024 23:44:13 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rUxm1-0004Bj-GI; Tue, 30 Jan 2024 23:44:13 +0000
Received: by outflank-mailman (input) for mailman id 673723;
 Tue, 30 Jan 2024 23:44:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUxm0-0004BX-HE
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 23:44:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUxm0-00037g-FR
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 23:44:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUxm0-0001ZF-B0
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 23:44:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=rYgmGD5bBJQtdzt4M39LtGNeMMguH7FJP8DA+/kEL9k=; b=kNSiE8PILncyhbiydbUb5zjJEu
	iv7rZmxk+0s50KzwNM8CHFU9Fvwo8EkDVt8+Wxz4TYbUDGCsXlLsHLJvE2IK7Lxg++Feb9sChE2Pk
	nv/DrC073bloSnlY2BPaKcloJ7TeOHBJzRBRl/BTs/iGREIH6tM/fRTGZdvw3O0Gaoes=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/iommu: switch hwdom IOMMU to use a rangeset
Message-Id: <E1rUxm0-0001ZF-B0@xenbits.xenproject.org>
Date: Tue, 30 Jan 2024 23:44:12 +0000

commit 0e1bd15a1d5d3576c77061ad84db5ff186ca45fc
Author:     Roger Pau Monne <roger.pau@citrix.com>
AuthorDate: Wed Jan 24 18:29:52 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Jan 29 17:25:15 2024 +0000

    x86/iommu: switch hwdom IOMMU to use a rangeset
    
    The current loop that iterates from 0 to the maximum RAM address in order to
    setup the IOMMU mappings is highly inefficient, and it will get worse as the
    amount of RAM increases.  It's also not accounting for any reserved regions
    past the last RAM address.
    
    Instead of iterating over memory addresses, iterate over the memory map regions
    and use a rangeset in order to keep track of which ranges need to be identity
    mapped in the hardware domain physical address space.
    
    On an AMD EPYC 7452 with 512GiB of RAM, the time to execute
    arch_iommu_hwdom_init() in nanoseconds is:
    
    x old
    + new
        N           Min           Max        Median           Avg        Stddev
    x   5 2.2364154e+10  2.338244e+10 2.2474685e+10 2.2622409e+10 4.2949869e+08
    +   5       1025012       1033036       1026188     1028276.2     3623.1194
    Difference at 95.0% confidence
            -2.26214e+10 +/- 4.42931e+08
            -99.9955% +/- 9.05152e-05%
            (Student's t, pooled s = 3.03701e+08)
    
    Execution time of arch_iommu_hwdom_init() goes down from ~22s to ~0.001s.
    
    Note there's a change for HVM domains (ie: PVH dom0) that get switched to
    create the p2m mappings using map_mmio_regions() instead of
    p2m_add_identity_entry(), so that ranges can be mapped with a single function
    call if possible.  Note that the interface of map_mmio_regions() doesn't
    allow creating read-only mappings, but so far there are no such mappings
    created for PVH dom0 in arch_iommu_hwdom_init().
    
    No change intended in the resulting mappings that a hardware domain gets.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Paul Durrant <paul@xen.org>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
---
 CHANGELOG.md                        |   1 +
 xen/drivers/passthrough/x86/iommu.c | 149 ++++++++----------------------------
 2 files changed, 34 insertions(+), 116 deletions(-)

diff --git a/CHANGELOG.md b/CHANGELOG.md
index ddb3ab8db4..1f55c9c72d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
    use "1" as the number of array elements.
  - On x86:
    - HVM PIRQs are disabled by default.
+   - Reduce IOMMU setup time for hardware domain.
 
 ### Added
  - On x86:
diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c
index fc5215a9dc..c90755ff58 100644
--- a/xen/drivers/passthrough/x86/iommu.c
+++ b/xen/drivers/passthrough/x86/iommu.c
@@ -300,76 +300,6 @@ void iommu_identity_map_teardown(struct domain *d)
     }
 }
 
-static unsigned int __hwdom_init hwdom_iommu_map(const struct domain *d,
-                                                 unsigned long pfn,
-                                                 unsigned long max_pfn)
-{
-    mfn_t mfn = _mfn(pfn);
-    unsigned int i, type, perms = IOMMUF_readable | IOMMUF_writable;
-
-    /*
-     * Set up 1:1 mapping for dom0. Default to include only conventional RAM
-     * areas and let RMRRs include needed reserved regions. When set, the
-     * inclusive mapping additionally maps in every pfn up to 4GB except those
-     * that fall in unusable ranges for PV Dom0.
-     */
-    if ( (pfn > max_pfn && !mfn_valid(mfn)) || xen_in_range(pfn) )
-        return 0;
-
-    switch ( type = page_get_ram_type(mfn) )
-    {
-    case RAM_TYPE_UNUSABLE:
-        return 0;
-
-    case RAM_TYPE_CONVENTIONAL:
-        if ( iommu_hwdom_strict )
-            return 0;
-        break;
-
-    default:
-        if ( type & RAM_TYPE_RESERVED )
-        {
-            if ( !iommu_hwdom_inclusive && !iommu_hwdom_reserved )
-                perms = 0;
-        }
-        else if ( is_hvm_domain(d) )
-            return 0;
-        else if ( !iommu_hwdom_inclusive || pfn > max_pfn )
-            perms = 0;
-    }
-
-    /* Check that it doesn't overlap with the Interrupt Address Range. */
-    if ( pfn >= 0xfee00 && pfn <= 0xfeeff )
-        return 0;
-    /* ... or the IO-APIC */
-    if ( has_vioapic(d) )
-    {
-        for ( i = 0; i < d->arch.hvm.nr_vioapics; i++ )
-            if ( pfn == PFN_DOWN(domain_vioapic(d, i)->base_address) )
-                return 0;
-    }
-    else if ( is_pv_domain(d) )
-    {
-        /*
-         * Be consistent with CPU mappings: Dom0 is permitted to establish r/o
-         * ones there (also for e.g. HPET in certain cases), so it should also
-         * have such established for IOMMUs.
-         */
-        if ( iomem_access_permitted(d, pfn, pfn) &&
-             rangeset_contains_singleton(mmio_ro_ranges, pfn) )
-            perms = IOMMUF_readable;
-    }
-    /*
-     * ... or the PCIe MCFG regions.
-     * TODO: runtime added MMCFG regions are not checked to make sure they
-     * don't overlap with already mapped regions, thus preventing trapping.
-     */
-    if ( has_vpci(d) && vpci_is_mmcfg_address(d, pfn_to_paddr(pfn)) )
-        return 0;
-
-    return perms;
-}
-
 static int __hwdom_init cf_check map_subtract(unsigned long s, unsigned long e,
                                               void *data)
 {
@@ -455,8 +385,7 @@ static int __hwdom_init cf_check identity_map(unsigned long s, unsigned long e,
 
 void __hwdom_init arch_iommu_hwdom_init(struct domain *d)
 {
-    unsigned long i, top, max_pfn, start, count;
-    unsigned int start_perms = 0;
+    unsigned int i;
     struct rangeset *map;
     struct map_data map_data = { .d = d };
     int rc;
@@ -487,58 +416,46 @@ void __hwdom_init arch_iommu_hwdom_init(struct domain *d)
     if ( !map )
         panic("IOMMU init: unable to allocate rangeset\n");
 
-    max_pfn = (GB(4) >> PAGE_SHIFT) - 1;
-    top = max(max_pdx, pfn_to_pdx(max_pfn) + 1);
+    if ( iommu_hwdom_inclusive )
+    {
+        /* Add the whole range below 4GB, UNUSABLE regions will be removed. */
+        rc = rangeset_add_range(map, 0, PFN_DOWN(GB(4)) - 1);
+        if ( rc )
+            panic("IOMMU inclusive mappings can't be added: %d\n", rc);
+    }
 
-    for ( i = 0, start = 0, count = 0; i < top; )
+    for ( i = 0; i < e820.nr_map; i++ )
     {
-        unsigned long pfn = pdx_to_pfn(i);
-        unsigned int perms = hwdom_iommu_map(d, pfn, max_pfn);
+        const struct e820entry entry = e820.map[i];
 
-        if ( !perms )
-            /* nothing */;
-        else if ( paging_mode_translate(d) )
+        switch ( entry.type )
         {
-            int rc;
-
-            rc = p2m_add_identity_entry(d, pfn,
-                                        perms & IOMMUF_writable ? p2m_access_rw
-                                                                : p2m_access_r,
-                                        0);
+        case E820_UNUSABLE:
+            /* Only relevant for inclusive mode, otherwise this is a no-op. */
+            rc = rangeset_remove_range(map, PFN_DOWN(entry.addr),
+                                       PFN_DOWN(entry.addr + entry.size - 1));
             if ( rc )
-                printk(XENLOG_WARNING
-                       "%pd: identity mapping of %lx failed: %d\n",
-                       d, pfn, rc);
-        }
-        else if ( pfn != start + count || perms != start_perms )
-        {
-            long rc;
+                panic("IOMMU failed to remove unusable memory: %d\n", rc);
+            continue;
 
-        commit:
-            while ( (rc = iommu_map(d, _dfn(start), _mfn(start), count,
-                                    start_perms | IOMMUF_preempt,
-                                    &map_data.flush_flags)) > 0 )
-            {
-                start += rc;
-                count -= rc;
-                process_pending_softirqs();
-            }
-            if ( rc )
-                printk(XENLOG_WARNING
-                       "%pd: IOMMU identity mapping of [%lx,%lx) failed: %ld\n",
-                       d, start, start + count, rc);
-            start = pfn;
-            count = 1;
-            start_perms = perms;
-        }
-        else
-            ++count;
+        case E820_RESERVED:
+            if ( !iommu_hwdom_inclusive && !iommu_hwdom_reserved )
+                continue;
+            break;
 
-        if ( !(++i & 0xfffff) )
-            process_pending_softirqs();
+        case E820_RAM:
+            if ( iommu_hwdom_strict )
+                continue;
+            break;
 
-        if ( i == top && count )
-            goto commit;
+        default:
+            continue;
+        }
+
+        rc = rangeset_add_range(map, PFN_DOWN(entry.addr),
+                                PFN_DOWN(entry.addr + entry.size - 1));
+        if ( rc )
+            panic("IOMMU failed to add identity range: %d\n", rc);
     }
 
     /* Remove any areas in-use by Xen. */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Tue Jan 30 23:44:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Tue, 30 Jan 2024 23:44:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.673724.1048192 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rUxmB-0004Ed-KI; Tue, 30 Jan 2024 23:44:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 673724.1048192; Tue, 30 Jan 2024 23:44:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rUxmB-0004EW-Ho; Tue, 30 Jan 2024 23:44:23 +0000
Received: by outflank-mailman (input) for mailman id 673724;
 Tue, 30 Jan 2024 23:44:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUxmA-0004EJ-OO
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 23:44:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUxmA-000387-Km
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 23:44:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rUxmA-0001a0-Hk
 for xen-changelog@lists.xenproject.org; Tue, 30 Jan 2024 23:44:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=pfkPdyhdA9M01x9s6QsvEho6fCJIe5J5qB5lLvgkFDQ=; b=j9MXPSf6q6jeAtiWGaw8BZHKHS
	F+BLbsXu3p5nUYQEWhz5JlQfIZs4ah6rqCkHc3qwXlI3As4g8w/XNkc+6i617IkbTGEZ/ZMK140uX
	c4lzW9XrqxfmE3t6l6WrPcWMxu5Tvvl328z2R/kw8x1Ps4DCGLb0eqq7mm3Cc6ICxo1U=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen master] x86/iommu: cleanup unused functions
Message-Id: <E1rUxmA-0001a0-Hk@xenbits.xenproject.org>
Date: Tue, 30 Jan 2024 23:44:22 +0000

commit 4a7e71aa085170f1a13976507c8e248f8715f116
Author:     Roger Pau Monne <roger.pau@citrix.com>
AuthorDate: Wed Jan 24 18:29:53 2024 +0100
Commit:     Andrew Cooper <andrew.cooper3@citrix.com>
CommitDate: Mon Jan 29 17:25:15 2024 +0000

    x86/iommu: cleanup unused functions
    
    Remove xen_in_range() and vpci_is_mmcfg_address() now that hey are unused.
    
    Adjust comments to point to the new functions that replace the existing ones.
    
    No functional change.
    
    Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
    Reviewed-by: Jan Beulich <jbeulich@suse.com>
    Reviewed-by: Paul Durrant <paul@xen.org>
---
 xen/arch/x86/hvm/io.c             |  5 ----
 xen/arch/x86/include/asm/hvm/io.h |  3 ---
 xen/arch/x86/include/asm/setup.h  |  1 -
 xen/arch/x86/setup.c              | 53 ++-------------------------------------
 xen/arch/x86/tboot.c              |  2 +-
 5 files changed, 3 insertions(+), 61 deletions(-)

diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c
index a42854c52b..06283b41c4 100644
--- a/xen/arch/x86/hvm/io.c
+++ b/xen/arch/x86/hvm/io.c
@@ -364,11 +364,6 @@ static const struct hvm_mmcfg *vpci_mmcfg_find(const struct domain *d,
     return NULL;
 }
 
-bool vpci_is_mmcfg_address(const struct domain *d, paddr_t addr)
-{
-    return vpci_mmcfg_find(d, addr);
-}
-
 int __hwdom_init vpci_subtract_mmcfg(const struct domain *d, struct rangeset *r)
 {
     const struct hvm_mmcfg *mmcfg;
diff --git a/xen/arch/x86/include/asm/hvm/io.h b/xen/arch/x86/include/asm/hvm/io.h
index e1e5e6fe74..24d1b6134f 100644
--- a/xen/arch/x86/include/asm/hvm/io.h
+++ b/xen/arch/x86/include/asm/hvm/io.h
@@ -153,9 +153,6 @@ int register_vpci_mmcfg_handler(struct domain *d, paddr_t addr,
 /* Destroy tracked MMCFG areas. */
 void destroy_vpci_mmcfg(struct domain *d);
 
-/* Check if an address is between a MMCFG region for a domain. */
-bool vpci_is_mmcfg_address(const struct domain *d, paddr_t addr);
-
 /* Remove MMCFG regions from a given rangeset. */
 int vpci_subtract_mmcfg(const struct domain *d, struct rangeset *r);
 
diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h
index cd07d98101..1ced1299c7 100644
--- a/xen/arch/x86/include/asm/setup.h
+++ b/xen/arch/x86/include/asm/setup.h
@@ -36,7 +36,6 @@ unsigned long initial_images_nrpages(nodeid_t node);
 void discard_initial_images(void);
 void *bootstrap_map(const module_t *mod);
 
-int xen_in_range(unsigned long mfn);
 int remove_xen_ranges(struct rangeset *r);
 
 extern uint8_t kbd_shift_flags;
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index ee233c69f1..ee682dd136 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -1343,7 +1343,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p)
         relocated = true;
 
         /*
-         * This needs to remain in sync with xen_in_range() and the
+         * This needs to remain in sync with remove_xen_ranges() and the
          * respective reserve_e820_ram() invocation below. No need to
          * query efi_boot_mem_unused() here, though.
          */
@@ -1495,7 +1495,7 @@ void asmlinkage __init noreturn __start_xen(unsigned long mbi_p)
     if ( using_2M_mapping() )
         efi_boot_mem_unused(NULL, NULL);
 
-    /* This needs to remain in sync with xen_in_range(). */
+    /* This needs to remain in sync with remove_xen_ranges(). */
     if ( efi_boot_mem_unused(&eb_start, &eb_end) )
     {
         reserve_e820_ram(&boot_e820, __pa(_stext), __pa(eb_start));
@@ -2089,55 +2089,6 @@ void arch_get_xen_caps(xen_capabilities_info_t *info)
     }
 }
 
-int __hwdom_init xen_in_range(unsigned long mfn)
-{
-    paddr_t start, end;
-    int i;
-
-    enum { region_s3, region_ro, region_rw, region_bss, nr_regions };
-    static struct {
-        paddr_t s, e;
-    } xen_regions[nr_regions] __hwdom_initdata;
-
-    /* initialize first time */
-    if ( !xen_regions[0].s )
-    {
-        /* S3 resume code (and other real mode trampoline code) */
-        xen_regions[region_s3].s = bootsym_phys(trampoline_start);
-        xen_regions[region_s3].e = bootsym_phys(trampoline_end);
-
-        /*
-         * This needs to remain in sync with the uses of the same symbols in
-         * - __start_xen() (above)
-         * - is_xen_fixed_mfn()
-         * - tboot_shutdown()
-         */
-
-        /* hypervisor .text + .rodata */
-        xen_regions[region_ro].s = __pa(&_stext);
-        xen_regions[region_ro].e = __pa(&__2M_rodata_end);
-        /* hypervisor .data + .bss */
-        xen_regions[region_rw].s = __pa(&__2M_rwdata_start);
-        xen_regions[region_rw].e = __pa(&__2M_rwdata_end);
-        if ( efi_boot_mem_unused(&start, &end) )
-        {
-            ASSERT(__pa(start) >= xen_regions[region_rw].s);
-            ASSERT(__pa(end) <= xen_regions[region_rw].e);
-            xen_regions[region_rw].e = __pa(start);
-            xen_regions[region_bss].s = __pa(end);
-            xen_regions[region_bss].e = __pa(&__2M_rwdata_end);
-        }
-    }
-
-    start = (paddr_t)mfn << PAGE_SHIFT;
-    end = start + PAGE_SIZE;
-    for ( i = 0; i < nr_regions; i++ )
-        if ( (start < xen_regions[i].e) && (end > xen_regions[i].s) )
-            return 1;
-
-    return 0;
-}
-
 int __hwdom_init remove_xen_ranges(struct rangeset *r)
 {
     paddr_t start, end;
diff --git a/xen/arch/x86/tboot.c b/xen/arch/x86/tboot.c
index 86c4c22cac..4c254b4e34 100644
--- a/xen/arch/x86/tboot.c
+++ b/xen/arch/x86/tboot.c
@@ -321,7 +321,7 @@ void tboot_shutdown(uint32_t shutdown_type)
 
         /*
          * Xen regions for tboot to MAC. This needs to remain in sync with
-         * xen_in_range().
+         * remove_xen_ranges().
          */
         g_tboot_shared->num_mac_regions = 3;
         /* S3 resume code (and other real mode trampoline code) */
--
generated by git-patchbot for /home/xen/git/xen.git#master


From xen-changelog-bounces@lists.xenproject.org Wed Jan 31 04:22:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 31 Jan 2024 04:22:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.673731.1048207 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rV26t-0004SH-My; Wed, 31 Jan 2024 04:22:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 673731.1048207; Wed, 31 Jan 2024 04: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 1rV26t-0004S9-Jr; Wed, 31 Jan 2024 04:22:03 +0000
Received: by outflank-mailman (input) for mailman id 673731;
 Wed, 31 Jan 2024 04:22:01 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rV26r-0004Rz-MG
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 04:22:01 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rV26r-0002mB-L2
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 04:22:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rV26r-0001Ez-Ju
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 04:22:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=g8LJp7iYIMs1hCSvhp1DcR8hriSydlqKndJv5xMnmko=; b=yjp95CnnyW90kKdwmhniY/Undc
	wiXFsQh4NKVNuyoam//7ks4MyBF1PXAOGjYvEi8McH3MPFVhBHU5JQ+nQlkJbuOl+Js/tfFsyHfYb
	D4y6gR+D9AWJwHFRCUvSDk4rAIWZxfLcc1pwuCPNkO+l5XH7qcOb32cx/1MdsfvAoKGc=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.16] pci: fail device assignment if phantom functions cannot be assigned
Message-Id: <E1rV26r-0001Ez-Ju@xenbits.xenproject.org>
Date: Wed, 31 Jan 2024 04:22:01 +0000

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

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

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


From xen-changelog-bounces@lists.xenproject.org Wed Jan 31 06:00:16 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 31 Jan 2024 06:00:16 +0000
Received: from list by lists.xenproject.org with outflank-mailman.673742.1048221 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rV3do-0000TV-MI; Wed, 31 Jan 2024 06:00:08 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 673742.1048221; Wed, 31 Jan 2024 06:00:08 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rV3do-0000TN-Jc; Wed, 31 Jan 2024 06:00:08 +0000
Received: by outflank-mailman (input) for mailman id 673742;
 Wed, 31 Jan 2024 06:00:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rV3di-00086w-03
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 06:00:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rV3dh-0005KL-Tg
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 06:00:01 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rV3dh-0003vL-SV
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 06:00:01 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=ic49verdVauNxfzEVS0vdF64dSmgPJEIk9pbUbnVZ4k=; b=RiJMq4klvf3OkZ64T1OK5xnE8D
	piVkNHoQUfEZOaoiTMEwqwz+PNZeGObR3YgxNS+mgddOdRvr/CALVM5XYfo+ewWkDcb2kyj4eObmb
	ZqUAxFH/Io3OgJFjxsE60Fnrb9kzk9ZJaSuTBHnzjR2+uFZemcDv4Ej07U0WfJ/kxnDA=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.15] pci: fail device assignment if phantom functions cannot be assigned
Message-Id: <E1rV3dh-0003vL-SV@xenbits.xenproject.org>
Date: Wed, 31 Jan 2024 06:00:01 +0000

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

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

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


From xen-changelog-bounces@lists.xenproject.org Wed Jan 31 10:22:12 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 31 Jan 2024 10:22:12 +0000
Received: from list by lists.xenproject.org with outflank-mailman.673870.1048376 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rV7jH-0005TX-Ru; Wed, 31 Jan 2024 10:22:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 673870.1048376; Wed, 31 Jan 2024 10: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 1rV7jH-0005TQ-PP; Wed, 31 Jan 2024 10:22:03 +0000
Received: by outflank-mailman (input) for mailman id 673870;
 Wed, 31 Jan 2024 10: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 1rV7jG-0005TK-4d
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 10: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 1rV7jG-0002H4-2X
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 10:22:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rV7jG-0005Ho-18
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 10: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=U7H7IstZpyBZg/N8WU/NZlKgwrhHbBSVTPYtoUpXgVc=; b=c3TiMmFgRriUoR/6IHs/77F/2c
	213HKxdg/gZiUxtIWybEV4VmomzLvwTSmOycj8oVDQuUYIS+LgJfvsLPQuiBxQ3+t/bYXTPePq7ov
	+tGoAxObhZ44fy4aYplSVNlDg9uepHOP/vf3vsPrreoQ4io9KxvDt5f+ckcDvwx7VRQg=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] update Xen version to 4.17.4-pre
Message-Id: <E1rV7jG-0005Ho-18@xenbits.xenproject.org>
Date: Wed, 31 Jan 2024 10:22:02 +0000

commit 4f6e9d4327eb5252f1e8cac97a095d8b8485dadb
Author:     Jan Beulich <jbeulich@suse.com>
AuthorDate: Tue Jan 30 14:36:44 2024 +0100
Commit:     Jan Beulich <jbeulich@suse.com>
CommitDate: Tue Jan 30 14:36:44 2024 +0100

    update Xen version to 4.17.4-pre
---
 xen/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/Makefile b/xen/Makefile
index a46e6330db..dd0b004e1c 100644
--- a/xen/Makefile
+++ b/xen/Makefile
@@ -6,7 +6,7 @@ this-makefile := $(call lastword,$(MAKEFILE_LIST))
 # All other places this is stored (eg. compile.h) should be autogenerated.
 export XEN_VERSION       = 4
 export XEN_SUBVERSION    = 17
-export XEN_EXTRAVERSION ?= .3$(XEN_VENDORVERSION)
+export XEN_EXTRAVERSION ?= .4-pre$(XEN_VENDORVERSION)
 export XEN_FULLVERSION   = $(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION)
 -include xen-version
 
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Jan 31 10:22:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 31 Jan 2024 10:22:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.673871.1048381 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rV7jR-0005V8-U1; Wed, 31 Jan 2024 10:22:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 673871.1048381; Wed, 31 Jan 2024 10: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 1rV7jR-0005V0-R1; Wed, 31 Jan 2024 10:22:13 +0000
Received: by outflank-mailman (input) for mailman id 673871;
 Wed, 31 Jan 2024 10: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 1rV7jQ-0005Uq-6r
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 10: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 1rV7jQ-0002H8-5k
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 10:22:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rV7jQ-0005IY-4h
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 10: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=Q8aPLX+oMsv7ftCsSNree2wjMRvPtmFeMjDt4lFIm9c=; b=VI00MaqTbAOegkzSNOgayTmqZf
	bCmX6vhGjESfdWHyYKCF6RpkrmvdTGsEPNOoWoBkoawU7zhzEdeuN4h+AI0YkQYHPjeRfZu0f2nNf
	eZvg3aNz6aP3yE5lnyvPi+XVf9xIqoN4fFASw6zGq+k/B0CGZsFfQbJguXgkCtbBrOvw=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] pci: fail device assignment if phantom functions cannot be assigned
Message-Id: <E1rV7jQ-0005IY-4h@xenbits.xenproject.org>
Date: Wed, 31 Jan 2024 10:22:12 +0000

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

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

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


From xen-changelog-bounces@lists.xenproject.org Wed Jan 31 10:22:23 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 31 Jan 2024 10:22:23 +0000
Received: from list by lists.xenproject.org with outflank-mailman.673872.1048384 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rV7jb-0005Xa-Uy; Wed, 31 Jan 2024 10:22:23 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 673872.1048384; Wed, 31 Jan 2024 10:22:23 +0000
Received: from localhost ([127.0.0.1] helo=lists.xenproject.org)
	by lists.xenproject.org with esmtp (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rV7jb-0005XS-SX; Wed, 31 Jan 2024 10:22:23 +0000
Received: by outflank-mailman (input) for mailman id 673872;
 Wed, 31 Jan 2024 10:22:22 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rV7ja-0005XI-9S
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 10:22:22 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rV7ja-0002HK-8l
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 10:22:22 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rV7ja-0005J0-7y
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 10:22:22 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=hgVOXO9Y9lj+DcpkyA38VO2SV4FVIWCdxOxdhMUsOjo=; b=YujUShImB3HkcrYwn10/gRKbpJ
	da6xU2UzcN3iS/XFWJ9fYaWP2wMT6zbZFj5M5XJ5UtEHxLRG/qQyPZmNbTiaEWxznQE4oldMeAmFo
	KjOIHatyWd2H+4k9xysrXtWpIDVspV+ivaHEBqQzLKZASZQHXEO9+lsKFQ0O9of4lKLQ=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.17] VT-d: Fix "else" vs "#endif" misplacement
Message-Id: <E1rV7ja-0005J0-7y@xenbits.xenproject.org>
Date: Wed, 31 Jan 2024 10:22:22 +0000

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

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

diff --git a/xen/arch/x86/include/asm/p2m.h b/xen/arch/x86/include/asm/p2m.h
index cd43d8621a..4f691533d5 100644
--- a/xen/arch/x86/include/asm/p2m.h
+++ b/xen/arch/x86/include/asm/p2m.h
@@ -447,7 +447,14 @@ static inline bool_t p2m_is_altp2m(const struct p2m_domain *p2m)
     return p2m->p2m_class == p2m_alternate;
 }
 
-#define p2m_get_pagetable(p2m)  ((p2m)->phys_table)
+#ifdef CONFIG_HVM
+static inline pagetable_t p2m_get_pagetable(const struct p2m_domain *p2m)
+{
+    return p2m->phys_table;
+}
+#else
+pagetable_t p2m_get_pagetable(const struct p2m_domain *p2m);
+#endif
 
 /*
  * Ensure any deferred p2m TLB flush has been completed on all VCPUs.
diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index b4c11a6b48..908b3ba6ee 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -441,15 +441,13 @@ static paddr_t domain_pgd_maddr(struct domain *d, paddr_t pgd_maddr,
 
     if ( pgd_maddr )
         /* nothing */;
-#ifdef CONFIG_HVM
-    else if ( iommu_use_hap_pt(d) )
+    else if ( IS_ENABLED(CONFIG_HVM) && iommu_use_hap_pt(d) )
     {
         pagetable_t pgt = p2m_get_pagetable(p2m_get_hostp2m(d));
 
         pgd_maddr = pagetable_get_paddr(pgt);
     }
     else
-#endif
     {
         if ( !hd->arch.vtd.pgd_maddr )
         {
--
generated by git-patchbot for /home/xen/git/xen.git#stable-4.17


From xen-changelog-bounces@lists.xenproject.org Wed Jan 31 17:44:10 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 31 Jan 2024 17:44:10 +0000
Received: from list by lists.xenproject.org with outflank-mailman.674135.1048878 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVEd1-0004kR-CT; Wed, 31 Jan 2024 17:44:03 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 674135.1048878; Wed, 31 Jan 2024 17: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 1rVEd1-0004kK-A2; Wed, 31 Jan 2024 17:44:03 +0000
Received: by outflank-mailman (input) for mailman id 674135;
 Wed, 31 Jan 2024 17:44:02 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVEd0-0004kE-B3
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 17:44:02 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVEd0-0003SO-9u
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 17:44:02 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVEd0-0000bz-8o
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 17:44:02 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=99NvdlYauKpieQZWK2+g3rEIWmpJ4Gsl/avWPLIb09I=; b=kG55cc0gg9/nCOvoQgfV8Pr+k/
	oD2N2xRPelnyoc7149X7qm4h8/7+7bfAgVeT/K1QFc/CVFpvoBr2JkE7MhZyHSyaOenNNSQ5fwO6W
	ipJ1qZ1R4iica0f3f25IXvNH3mcgBCz2A4Fz4aa12yz1gHNwGJUG8H64ak9jaIWe2KyM=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] pci: fail device assignment if phantom functions cannot be assigned
Message-Id: <E1rVEd0-0000bz-8o@xenbits.xenproject.org>
Date: Wed, 31 Jan 2024 17:44:02 +0000

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

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

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


From xen-changelog-bounces@lists.xenproject.org Wed Jan 31 17:44:13 2024
Return-path: <xen-changelog-bounces@lists.xenproject.org>
Envelope-to: archives@lists.xen.org
Delivery-date: Wed, 31 Jan 2024 17:44:13 +0000
Received: from list by lists.xenproject.org with outflank-mailman.674136.1048882 (Exim 4.92)
	(envelope-from <xen-changelog-bounces@lists.xenproject.org>)
	id 1rVEdB-0004mG-EC; Wed, 31 Jan 2024 17:44:13 +0000
X-Outflank-Mailman: Message body and most headers restored to incoming version
Received: by outflank-mailman (output) from mailman id 674136.1048882; Wed, 31 Jan 2024 17: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 1rVEdB-0004m8-BV; Wed, 31 Jan 2024 17:44:13 +0000
Received: by outflank-mailman (input) for mailman id 674136;
 Wed, 31 Jan 2024 17:44:12 +0000
Received: from mail.xenproject.org ([104.130.215.37])
 by lists.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVEdA-0004m0-EO
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 17:44:12 +0000
Received: from xenbits.xenproject.org ([104.239.192.120])
 by mail.xenproject.org with esmtp (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVEdA-0003SW-DD
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 17:44:12 +0000
Received: from xen by xenbits.xenproject.org with local (Exim 4.92)
 (envelope-from <ian.jackson@eu.citrix.com>) id 1rVEdA-0000cY-CG
 for xen-changelog@lists.xenproject.org; Wed, 31 Jan 2024 17:44:12 +0000
X-BeenThere: xen-changelog@lists.xenproject.org
List-Id: "Change log for Mercurial \(receive only\)"
 <xen-changelog.lists.xenproject.org>
List-Unsubscribe: <https://lists.xenproject.org/mailman/options/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=unsubscribe>
List-Post: <mailto:xen-changelog@lists.xenproject.org>
List-Help: <mailto:xen-changelog-request@lists.xenproject.org?subject=help>
List-Subscribe: <https://lists.xenproject.org/mailman/listinfo/xen-changelog>, 
 <mailto:xen-changelog-request@lists.xenproject.org?subject=subscribe>
Errors-To: xen-changelog-bounces@lists.xenproject.org
Precedence: list
Sender: "Xen-changelog" <xen-changelog-bounces@lists.xenproject.org>
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org;
	s=20200302mail; h=Date:Message-Id:Subject:Reply-To:To:From;
	bh=zShxltCifKw+9Dg51kcIL3CRyux8apYEfMIgLuHvb8Y=; b=K8idhSSSLVgij5bc+7W7b/IqJm
	adD673rIbQ560AHKZ2sZ/f5xSfuw3SLmI2oui4rsZmm+oaOSLz2rYv4tf+AyFLlSjzCeWpVyvQjXL
	kM1PXzhtRG0AZCAn5DgfKWu4vgnW8FrYFUJhEDGcG5NtlBTDEzuAIBWEBTRztY47bveo=;
From: patchbot@xen.org
To: xen-changelog@lists.xenproject.org
Reply-To: xen-devel@lists.xenproject.org
Subject: [xen stable-4.18] VT-d: Fix "else" vs "#endif" misplacement
Message-Id: <E1rVEdA-0000cY-CG@xenbits.xenproject.org>
Date: Wed, 31 Jan 2024 17:44:12 +0000

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

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

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


