From nobody Tue Feb 10 16:43:38 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1732663414; cv=none; d=zohomail.com; s=zohoarc; b=CpZpKOEd6ywX+51LfdMfHfwzSpX3LvLBGsrPZFVQ+qhn0j05VlbbHap8Gk8JkBPdX84ijUY0EPye0hdCxMBZ4qxnh8YZb95QAJhbtz8FGJ99HdOqzxd2zRuCgvAJwgSqoPbOnzv9NXXoHu9P+/dp1rlhAt7Qg/b9+l/oeMR8FLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732663414; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=vc/ybOj342O4JSb/ofGdnhvbnqMTuc2TqoXYnTa6tTc=; b=nwGCYCx/dW5dHUXQbAzJZWNCMNyQ70qMZNsIJRdMzFUXEuZFKyTaJiXaNU+A1WW2pyjAZ6oE11i+YcTm7bluexWpqUMonpqp5hgP+Ux+EvZ4CcGbAEZDByAseOwfHaidqMS58/106UPKLWQsjG2QQl78llX6bLrmZjthIs6T/GE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 173266341437356.336394313307665; Tue, 26 Nov 2024 15:23:34 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.844074.1259729 (Exim 4.92) (envelope-from ) id 1tG4tv-0003Rx-Uw; Tue, 26 Nov 2024 23:23:23 +0000 Received: by outflank-mailman (output) from mailman id 844074.1259729; Tue, 26 Nov 2024 23:23:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4tv-0003P1-3y; Tue, 26 Nov 2024 23:23:23 +0000 Received: by outflank-mailman (input) for mailman id 844074; Tue, 26 Nov 2024 23:22:09 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tG4sj-0000Ao-MS for xen-devel@lists.xenproject.org; Tue, 26 Nov 2024 23:22:09 +0000 Received: from dfw.source.kernel.org (dfw.source.kernel.org [2604:1380:4641:c500::1]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 3f7c2e3a-ac4d-11ef-a0cd-8be0dac302b0; Wed, 27 Nov 2024 00:22:05 +0100 (CET) Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id BF25A5C5DA0; Tue, 26 Nov 2024 23:21:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPS id EE3DBC4CED7; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id E276FD66B94; Tue, 26 Nov 2024 23:21:57 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 3f7c2e3a-ac4d-11ef-a0cd-8be0dac302b0 X-Custom-Connection: eyJyZW1vdGVpcCI6IjI2MDQ6MTM4MDo0NjQxOmM1MDA6OjEiLCJoZWxvIjoiZGZ3LnNvdXJjZS5rZXJuZWwub3JnIn0= X-Custom-Transaction: eyJpZCI6IjNmN2MyZTNhLWFjNGQtMTFlZi1hMGNkLThiZTBkYWMzMDJiMCIsInRzIjoxNzMyNjYzMzI2LjEzODY4OCwic2VuZGVyIjoiZGV2bnVsbCtkbXVraGluLmZvcmQuY29tQGtlcm5lbC5vcmciLCJyZWNpcGllbnQiOiJ4ZW4tZGV2ZWxAbGlzdHMueGVucHJvamVjdC5vcmcifQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1732663318; bh=YfYCHh0nVVhyUMXcW2poOpCSgAUn/qfDmEJPr0RM4oY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=YTyhPPJYnhy04bo8F7f8koIfZXZgjBfIB05ZmxEwq9aFZ7xlvRaphAT9vt3DANNzx ZQYH1TIFSRdNWl1Nb6i8Iie7rF7zqHQnWnCecWY/crT26czdMnE4zcWsl74guEwAcc ZxVqp0v3u8x38Jt3QCfYCEDjL8gp5rqYK39ujPilLoK42nz9zpvgeA1g1Q6vFJy0mD oUCQCL3czhCJNZBX+CQJs0U5du34E7pDX8CBkXo+/UR76HCQ603mi8YuYS/tZ+6pB0 j7lGnUyR49OEM1jSik6LQZpLPhi4vESjyNpZlPjeoWP4OCz1LsnjuHfe+WvfSX7Oeo lu9/mbfi+bjyA== From: Denis Mukhin via B4 Relay Date: Tue, 26 Nov 2024 15:22:24 -0800 Subject: [PATCH 34/36] x86/domain: implement domain_has_vuart() MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241126-vuart-ns8250-v1-v1-34-87b9a8375b7a@ford.com> References: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> In-Reply-To: <20241126-vuart-ns8250-v1-v1-0-87b9a8375b7a@ford.com> To: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , "Daniel P. Smith" , Stefano Stabellini , Julien Grall , Bertrand Marquis , Michal Orzel , Rahul Singh , Volodymyr Babchuk , Alistair Francis , Bob Eshleman , Connor Davis , Oleksii Kurochko , Shawn Anastasio , Anthony PERARD , Juergen Gross , Christian Lindig , David Scott , =?utf-8?q?Marek_Marczykowski-G=C3=B3recki?= Cc: xen-devel@lists.xenproject.org, Denis Mukhin X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1732663312; l=7401; i=dmukhin@ford.com; s=20241125; h=from:subject:message-id; bh=tfiJLSOur1vSXiemSyjr8enIFIEF26fIRGrdEEwbY18=; b=/N/5CYqKcD6seLR4F2jKfzySETrT8B+vZVURCXKxLPT1koQC+NDS1ls5JLia0xD7s5pm/MeaL subrLZMun+cCOrcoQyaLAF7u6vvZSXh4d8Ja0x+Pt9dNifh/cn4ke3C X-Developer-Key: i=dmukhin@ford.com; a=ed25519; pk=SsDZ9p39s0fqcpUKQuqKqrbn0rq6EtEAClvpOpzx6+U= X-Endpoint-Received: by B4 Relay for dmukhin@ford.com/20241125 with auth_id=287 X-Original-From: Denis Mukhin Reply-To: dmukhin@ford.com X-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1732663414919019100 From: Denis Mukhin Add new emulation flag for virtual UART on x86 and plumb it through the sta= ck. This change enables NS8250 emulator initialization. Signed-off-by: Denis Mukhin --- tools/libs/light/libxl_x86.c | 6 +++++- tools/ocaml/libs/xc/xenctrl.ml | 1 + tools/ocaml/libs/xc/xenctrl.mli | 1 + tools/python/xen/lowlevel/xc/xc.c | 4 +--- xen/arch/x86/domain.c | 8 +++++--- xen/arch/x86/include/asm/domain.h | 7 ++++--- xen/include/public/arch-x86/xen.h | 14 +++++++++++++- 7 files changed, 30 insertions(+), 11 deletions(-) diff --git a/tools/libs/light/libxl_x86.c b/tools/libs/light/libxl_x86.c index a3164a3077fec7e1b81a34074894dc646954a49a..de5f05e18cb0671bb031b101b9a= 7159eb0fe0178 100644 --- a/tools/libs/light/libxl_x86.c +++ b/tools/libs/light/libxl_x86.c @@ -8,7 +8,11 @@ int libxl__arch_domain_prepare_config(libxl__gc *gc, { switch(d_config->c_info.type) { case LIBXL_DOMAIN_TYPE_HVM: - config->arch.emulation_flags =3D (XEN_X86_EMU_ALL & ~XEN_X86_EMU_V= PCI); + config->arch.emulation_flags =3D XEN_X86_EMU_ALL; + config->arch.emulation_flags &=3D ~XEN_X86_EMU_VPCI; + /* Virtual UART is selected at Xen build time */ + config->arch.emulation_flags &=3D ~XEN_X86_EMU_VUART; + if (!libxl_defbool_val(d_config->b_info.u.hvm.pirq)) config->arch.emulation_flags &=3D ~XEN_X86_EMU_USE_PIRQ; break; diff --git a/tools/ocaml/libs/xc/xenctrl.ml b/tools/ocaml/libs/xc/xenctrl.ml index 2690f9a92316b812ad3d3ff0e1c36823070adb4a..647239b3e55e88b00eb8e9773a5= 267894cbbae54 100644 --- a/tools/ocaml/libs/xc/xenctrl.ml +++ b/tools/ocaml/libs/xc/xenctrl.ml @@ -47,6 +47,7 @@ type x86_arch_emulation_flags =3D | X86_EMU_PIT | X86_EMU_USE_PIRQ | X86_EMU_VPCI + | X86_EMU_VUART =20 type x86_arch_misc_flags =3D | X86_MSR_RELAXED diff --git a/tools/ocaml/libs/xc/xenctrl.mli b/tools/ocaml/libs/xc/xenctrl.= mli index febbe1f6ae3f10c5abe45eaa3c06a8a67d9ba268..4f5f64c786e83e8a0c3dd3cdb04= 60f7095de4a62 100644 --- a/tools/ocaml/libs/xc/xenctrl.mli +++ b/tools/ocaml/libs/xc/xenctrl.mli @@ -41,6 +41,7 @@ type x86_arch_emulation_flags =3D | X86_EMU_PIT | X86_EMU_USE_PIRQ | X86_EMU_VPCI + | X86_EMU_VUART =20 type x86_arch_misc_flags =3D | X86_MSR_RELAXED diff --git a/tools/python/xen/lowlevel/xc/xc.c b/tools/python/xen/lowlevel/= xc/xc.c index 9feb12ae2b16e48cb5d0c3c45044ae226f152f2d..e54308956efc7061d58d2166ec9= a95bc1dcd1781 100644 --- a/tools/python/xen/lowlevel/xc/xc.c +++ b/tools/python/xen/lowlevel/xc/xc.c @@ -159,9 +159,7 @@ static PyObject *pyxc_domain_create(XcObject *self, =20 #if defined (__i386) || defined(__x86_64__) if ( config.flags & XEN_DOMCTL_CDF_hvm ) - config.arch.emulation_flags =3D XEN_X86_EMU_ALL & - ~(XEN_X86_EMU_VPCI | - XEN_X86_EMU_USE_PIRQ); + config.arch.emulation_flags =3D XEN_X86_EMU_HVM_ALLOWABLE; #elif defined (__arm__) || defined(__aarch64__) config.arch.gic_version =3D XEN_DOMCTL_CONFIG_GIC_NATIVE; #else diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index c88d422a64544531c1e1058fa484364bb4277d1e..439da7adc92a3a8eb481075bf83= 4da5f9670dd54 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -752,10 +752,10 @@ static bool emulation_flags_ok(const struct domain *d= , uint32_t emflags) if ( is_hardware_domain(d) && emflags !=3D (X86_EMU_VPCI | X86_EMU_LAPIC | X86_EMU_IOAPIC) ) return false; + + emflags &=3D ~X86_EMU_VUART; if ( !is_hardware_domain(d) && - /* HVM PIRQ feature is user-selectable. */ - (emflags & ~X86_EMU_USE_PIRQ) !=3D - (X86_EMU_ALL & ~(X86_EMU_VPCI | X86_EMU_USE_PIRQ)) && + xen_emflags_allowable(emflags) !=3D XEN_X86_EMU_HVM_ALLOWABLE= && emflags !=3D X86_EMU_LAPIC ) return false; } @@ -806,6 +806,8 @@ int arch_domain_create(struct domain *d, =20 emflags =3D config->arch.emulation_flags; =20 + if ( IS_ENABLED(CONFIG_HAS_VUART_NS8250) && is_hvm_domain(d) ) + emflags |=3D XEN_X86_EMU_VUART; if ( is_hardware_domain(d) && is_pv_domain(d) ) emflags |=3D XEN_X86_EMU_PIT; =20 diff --git a/xen/arch/x86/include/asm/domain.h b/xen/arch/x86/include/asm/d= omain.h index c1d0d1f47324e8cc678a4c76c43f86820a89e7b3..dacea6e1aad46e9f8710b2202bb= 81203c5e92807 100644 --- a/xen/arch/x86/include/asm/domain.h +++ b/xen/arch/x86/include/asm/domain.h @@ -484,7 +484,8 @@ struct arch_domain #define X86_EMU_VPCI 0 #endif =20 -#define X86_EMU_PIT XEN_X86_EMU_PIT +#define X86_EMU_PIT XEN_X86_EMU_PIT +#define X86_EMU_VUART XEN_X86_EMU_VUART =20 /* This must match XEN_X86_EMU_ALL in xen.h */ #define X86_EMU_ALL (X86_EMU_LAPIC | X86_EMU_HPET | \ @@ -492,7 +493,7 @@ struct arch_domain X86_EMU_IOAPIC | X86_EMU_PIC | \ X86_EMU_VGA | X86_EMU_IOMMU | \ X86_EMU_PIT | X86_EMU_USE_PIRQ | \ - X86_EMU_VPCI) + X86_EMU_VPCI | X86_EMU_VUART) =20 #define has_vlapic(d) (!!((d)->arch.emulation_flags & X86_EMU_LAPIC)) #define has_vhpet(d) (!!((d)->arch.emulation_flags & X86_EMU_HPET)) @@ -507,7 +508,7 @@ struct arch_domain #define has_vpci(d) (!!((d)->arch.emulation_flags & X86_EMU_VPCI)) =20 /* NB: same symbol as in Arm port */ -#define domain_has_vuart(d) false +#define domain_has_vuart(d) (!!((d)->arch.emulation_flags & X86_EMU_VUART)) =20 #define gdt_ldt_pt_idx(v) \ ((v)->vcpu_id >> (PAGETABLE_ORDER - GDT_LDT_VCPU_SHIFT)) diff --git a/xen/include/public/arch-x86/xen.h b/xen/include/public/arch-x8= 6/xen.h index fc2487986642a7694578ab9d2f5f16d09761bff8..e7922e3f9ddc1742a464d228807= 279839df31e52 100644 --- a/xen/include/public/arch-x86/xen.h +++ b/xen/include/public/arch-x86/xen.h @@ -283,13 +283,25 @@ struct xen_arch_domainconfig { #define XEN_X86_EMU_USE_PIRQ (1U<<_XEN_X86_EMU_USE_PIRQ) #define _XEN_X86_EMU_VPCI 10 #define XEN_X86_EMU_VPCI (1U<<_XEN_X86_EMU_VPCI) +#define _XEN_X86_EMU_VUART 11 +#define XEN_X86_EMU_VUART (1U<<_XEN_X86_EMU_VUART) =20 #define XEN_X86_EMU_ALL (XEN_X86_EMU_LAPIC | XEN_X86_EMU_HPET = | \ XEN_X86_EMU_PM | XEN_X86_EMU_RTC | = \ XEN_X86_EMU_IOAPIC | XEN_X86_EMU_PIC = | \ XEN_X86_EMU_VGA | XEN_X86_EMU_IOMMU |= \ XEN_X86_EMU_PIT | XEN_X86_EMU_USE_PIR= Q |\ - XEN_X86_EMU_VPCI) + XEN_X86_EMU_VPCI | XEN_X86_EMU_VUART) + +/* HVM PIRQ feature is user-selectable (libxl). */ +#define XEN_X86_EMU_HVM_SELECTABLE (XEN_X86_EMU_VPCI | \ + XEN_X86_EMU_USE_PIRQ | \ + XEN_X86_EMU_VUART) + +#define xen_emflags_allowable(x) ((x) & ~XEN_X86_EMU_HVM_SELECTABLE) + +#define XEN_X86_EMU_HVM_ALLOWABLE xen_emflags_allowable(XEN_X86_EMU_ALL) + uint32_t emulation_flags; =20 /* --=20 2.34.1