[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] xen/arm: XEN_DOMCTL_get_address_size hypercall support


  • To: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Milan Djokic <milan_djokic@xxxxxxxx>
  • Date: Thu, 2 Oct 2025 13:10:40 +0200
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=epam.com; dmarc=pass action=none header.from=epam.com; dkim=pass header.d=epam.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=3GyfR64pNTgcQqYoT1qYuyv4fzec20C0AYH22uKTQd8=; b=fjMkJmYrlwzDIiUk6PnE/K5axWJXzMtzU98RZP597P8eBG8QNPM3utfjR5IOwnzfCTXt3dqNzMIQF4EmNFAg5NJmvIrKQiKGmaX2m5Qv7ga/5anVnHurJclYKp/c77mXB3GDBsuxOj3Bf8/7NZyavkK2EsreswQIr0mETd5aTbIf1PDsna3npUUCdhvPGGXQh9R1UQ2bw9IL1hQ0TOHftW3p7f4FeB8e3TgHJcQf8Dt5eOEAwSPPpcGkbGkYogFLo1AqSS8Ln8x3MKDLSa21tUNJOlu2xs2zFyG/5uowZc2pZtuDRnNb+ilxuvWSx+xa3ggzWZ4/tWCwCDpY7das3Q==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=Mqt1O3BM8SJlRrvnBokdp0RFhedXMnbc7jn7ItHAVdhByyk7pLby/7gDYkjzYy8DHnbNHn//hJnuj/TWtFYs6mzjIEUwOxEHLdrU5LyHL7YTrZkinPDTYaCm57xj2KTkr/LmkkKaiP8f79x5ADTNH8yJpEwRhXTwddJ7PniEEjeENBwpXalAsmmY9Gy45O0sSsxiXE8awKT2FnFdI1zeh5lRurMwvEiCY/gKDQb0z8QjFtXKXPXQ/rE2JedPlCbvNcZ+pLNqfYqQHHcxGA/wMTvWts/fSiVudC00NR8Z2HY//p7ecLWQskmu48EECYg66bEb1b8ExyDkf0dY7akogQ==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=epam.com;
  • Cc: Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Thu, 02 Oct 2025 11:11:13 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Hello Andrew,

On 10/2/25 12:10, Andrew Cooper wrote:
On 01/10/2025 9:01 pm, Milan Djokic wrote:
Signed-off-by: Milan Djokic <milan_djokic@xxxxxxxx>

---
XEN_DOMCTL_get_address_size hypercall is not implemented for arm (only for x86)
It would be useful to have this hypercall supported for arm64, in order to get
current guest addressing mode and also to verify that 
XEN_DOMCTL_set_address_size
performs switch to target addressing mode (instead of relying on its returned 
error code only).

Please don't copy this misfeature of x86 PV guests into ARM.

Letting domains be of variable bitness after domain create leads to a
whole lot of bugs, many security relevant.

32bit vs 64bit should be an input to domain_create(), not something that
is edited after the domain has been constructed.


Yes, the idea behind this patch is not to introduce variable bitness, just to have the ability to get current addressing mode through hypercall. In our case, we have used it only in domain creation path (after domain_create(), to verify that target addressing mode is set). Of course, whether this hypercall support would be useful in mainline is open for discussion.

diff --git a/xen/arch/arm/arm64/domctl.c b/xen/arch/arm/arm64/domctl.c
index 8720d126c9..f227309e06 100644
--- a/xen/arch/arm/arm64/domctl.c
+++ b/xen/arch/arm/arm64/domctl.c
@@ -33,6 +34,37 @@ static long switch_mode(struct domain *d, enum domain_type 
type)
      return 0;
  }
+static long get_address_size(struct domain *d, uint32_t *address_size)
+{
+    long rc = 0;
+    struct vcpu *v;
+    /* Check invalid arguments */
+    if ( d == NULL || address_size == NULL) {
+        rc = -EINVAL;
+    }
+    /* Domain structure type field and actual vcpu mode must be aligned */
+    if(rc == 0) {
+        for_each_vcpu(d, v) {
+            if(vcpu_get_mode(v) != d->arch.type) {
+                rc = -EFAULT;
+            }
+        }

This is deeply suspicious.

Under what circumstances can the vCPU setting be different from the
domain setting?


It should never happen, this is more of a sanity check. Alternative would be to use only one of vCPU or domain settings, checking against both seemed more complete to me.

~Andrew

BR,
Milan




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.