From nobody Fri May 17 14:57:31 2024 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=reject dis=none) header.from=citrix.com ARC-Seal: i=1; a=rsa-sha256; t=1661203908; cv=none; d=zohomail.com; s=zohoarc; b=EocJFK2N+MglDQ5TO4RuHXJHG4azxUDtO1fYicOOFwbK/AkcgVQ6qL9bquFIqD1N8NOYw2+HKN7fewWh67C5fw/gD0jBex8vLPsWhK54+Xq5PrvJPacRM83gjd+KleDhkjhPj5UZOBH7IMbD8zyIuvCf+Lk/14P0ITz52cZ2jBI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661203908; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=+43/6XEmnMKmoY0c+XziJ7xl9S+MWa/wXFstbxnH7wc=; b=GQ4nU4J66u8ywj/uX1/NaBtPtS4JTdTAbI5VrE0nZCi3nTTTwSZkPsp7ezr2jvpXNX0T8v/h8j4WPPfnsCKQVcynNRhSpK86gg1ehjCW2FqA2gnalW//S341se0VhqCPBlC+nlrjcfFkSVq+QdYYJFK4c4lAb3kTB6HeZBx8Jm4= 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=reject dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1661203908723758.5268743297937; Mon, 22 Aug 2022 14:31:48 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.391594.629495 (Exim 4.92) (envelope-from ) id 1oQF0n-0006xC-Ja; Mon, 22 Aug 2022 21:31:09 +0000 Received: by outflank-mailman (output) from mailman id 391594.629495; Mon, 22 Aug 2022 21:31:09 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oQF0n-0006x5-Gj; Mon, 22 Aug 2022 21:31:09 +0000 Received: by outflank-mailman (input) for mailman id 391594; Mon, 22 Aug 2022 21:31:07 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1oQF0l-0006wz-JC for xen-devel@lists.xenproject.org; Mon, 22 Aug 2022 21:31:07 +0000 Received: from esa5.hc3370-68.iphmx.com (esa5.hc3370-68.iphmx.com [216.71.155.168]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id b7f21584-2261-11ed-9250-1f966e50362f; Mon, 22 Aug 2022 23:31:02 +0200 (CEST) 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: b7f21584-2261-11ed-9250-1f966e50362f DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=citrix.com; s=securemail; t=1661203862; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=NZAu9e4sXDTW33ZmtnfP+zdIlwABp1HNdu8TudbfLWY=; b=ReJ5n+xxyrSuhLJ+YGJGzhU/GxauHxYfktWkMG7IFJEZmwRxOckJ91qS GcJl9q15asf6+SHnMHsrcN3VSBrCCMpMM7gCShG8br00F/oy5Q+TLXor4 nE9ccdazMc71xmsNe7TkniXj9caePdjhyASNOTQERQ7Zls5+TDGvMTXC/ o=; Authentication-Results: esa5.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none X-SBRS: 2.7 X-MesageID: 77881871 X-Ironport-Server: esa5.hc3370-68.iphmx.com X-Remote-IP: 162.221.156.83 X-Policy: $RELAYED IronPort-Data: A9a23:UCDg76zAe59BSPMdCod6t+dbxirEfRIJ4+MujC+fZmUNrF6WrkUAn WYZUDjXM/reamL0ctolYIXn9kgPscKGmoQwQVQ5pSAxQypGp/SeCIXCJC8cHc8zwu4v7q5Dx 59DAjUVBJlsFhcwnj/0bv676yEUOZigHtLUEPTDNj16WThqQSIgjQMLs+Mii8tjjMPR7zml4 LsemOWCfg7+s9JIGjhMsfjb+Ek15K6aVA4w5TTSW9ga5DcyqFFNZH4vDfnZB2f1RIBSAtm7S 47rpF1u1jqEl/uFIorNfofTKiXmcJaLVeS9oiM+t5yZqgpDvkQPPpMTb5LwX6v1ZwKhxLidw P0V3XC5pJxA0qfkwIzxWDEAe81y0DEvFBYq7hFTvOTKp3AqfUcAzN0xHWo6EYwk6N1PXzBD5 /M1NDxTZRqc0rfeLLKTEoGAh+wmJcjveogepmth3XfSCvNOrZLrGvuQo4UChXFp254ITa22i 8kxMFKDaDzpZRFVN0hRI5U5hOqy3VH0ciFCqULTrq0yi4TW5FMugOi0YIWMEjCMbZtIpAWXq nqWxlbeGBhHbteZwxOhzn3504cjmgukAdlPRdVU7MVCn1m71mEVThoMWjOTg9O0l0q/UNJ3M FEP92wlqq1a3FymSJzxUgO1pFaAvwUAQJxAHusi8gaPx6HIpQGDCQA5oiVpMYJ88pVsHHpzi wHPz4iB6SFTXKO9FmO2+puVkSGJAXZEIH0NSDMIEwAP/Iy2yG0stS4jXuqPAYbs0IOtSW6sm mDUxMQtr+5N1JBWjs1X6XiC2mvx/caRE2bZ8y2NBgqYAhVFiJlJjmBCwXzS9r5+IYmQVTFtV 1BUypHFvIji4Xxg/RFhodnh/5nzvp5pyBWG3TZS82AJrlxBAUKLc4FK+y1ZL0x0KMsCcjKBS BaN51oItcQOYCPyPPMfj2eN5yMCnMDd+SnNDKiIPrKinLArHON4wM2eTRHJhD28+KTduao+J Y2aYa6RMJruMow+lWLeb7pMjtcWKtUWnzy7qWbTk0v6itJzpRe9Fd84Dbd5Rr9nsf/d/V6Km zudXuPToyhivCTFSnG/2eYuwZoidBDX2bieRxRrS9O+ IronPort-HdrOrdr: A9a23:MGo88asDKtYupDtNE3QlHxkA7skDetV00zEX/kB9WHVpmszxra 6TdZMgpHjJYVcqKRUdcL+7WJVoLUmxyXcX2/h1AV7BZniEhILAFugLhuGO/9SJIVyZygc378 ZdmsZFZ+EYdWIK7/rH3A== X-IronPort-AV: E=Sophos;i="5.93,255,1654574400"; d="scan'208";a="77881871" From: Andrew Cooper To: Xen-devel CC: Andrew Cooper , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Jane Malalane Subject: [PATCH] x86/domain: Fix struct domain memory corruption when building PV guests Date: Mon, 22 Aug 2022 22:30:36 +0100 Message-ID: <20220822213036.21630-1-andrew.cooper3@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @citrix.com) X-ZM-MESSAGEID: 1661203910992100001 arch_domain_create() can't blindly write into d->arch.hvm union. Move the logic into hvm_domain_initialise(), which involves passing config down. Fixes: 2ce11ce249a3 ("x86/HVM: allow per-domain usage of hardware virtualiz= ed APIC") Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- CC: Jan Beulich CC: Roger Pau Monn=C3=A9 CC: Wei Liu CC: Jane Malalane This does not fix XenServer's wall of red from testing, but I have at least figured out what's going on. There's a piece of plain RAM in place of a working LAPIC MMIO mapping (accelerated or otherwise), which causes HVMLoad= er to spin in a tight loop waiting for CPU 1 to come up after failing to send = an INIT-SIPI-SIPI. Sadly the fix is not as straightforward as I'd hoped, and needs more testin= g. --- xen/arch/x86/domain.c | 8 +------- xen/arch/x86/hvm/hvm.c | 9 ++++++++- xen/arch/x86/include/asm/hvm/hvm.h | 3 ++- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 15e7e772012e..41e1e3f27272 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -853,7 +853,7 @@ int arch_domain_create(struct domain *d, =20 if ( is_hvm_domain(d) ) { - if ( (rc =3D hvm_domain_initialise(d)) !=3D 0 ) + if ( (rc =3D hvm_domain_initialise(d, config)) !=3D 0 ) goto fail; } else if ( is_pv_domain(d) ) @@ -885,12 +885,6 @@ int arch_domain_create(struct domain *d, =20 d->arch.msr_relaxed =3D config->arch.misc_flags & XEN_X86_MSR_RELAXED; =20 - d->arch.hvm.assisted_xapic =3D - config->arch.misc_flags & XEN_X86_ASSISTED_XAPIC; - - d->arch.hvm.assisted_x2apic =3D - config->arch.misc_flags & XEN_X86_ASSISTED_X2APIC; - spec_ctrl_init_domain(d); =20 return 0; diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 6b5d585ed4cc..ae8267852013 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -576,7 +576,8 @@ static int cf_check hvm_print_line( return X86EMUL_OKAY; } =20 -int hvm_domain_initialise(struct domain *d) +int hvm_domain_initialise(struct domain *d, + struct xen_domctl_createdomain *config) { unsigned int nr_gsis; int rc; @@ -597,6 +598,12 @@ int hvm_domain_initialise(struct domain *d) INIT_LIST_HEAD(&d->arch.hvm.mmcfg_regions); INIT_LIST_HEAD(&d->arch.hvm.msix_tables); =20 + d->arch.hvm.assisted_xapic =3D + config->arch.misc_flags & XEN_X86_ASSISTED_XAPIC; + + d->arch.hvm.assisted_x2apic =3D + config->arch.misc_flags & XEN_X86_ASSISTED_X2APIC; + rc =3D create_perdomain_mapping(d, PERDOMAIN_VIRT_START, 0, NULL, NULL= ); if ( rc ) goto fail; diff --git a/xen/arch/x86/include/asm/hvm/hvm.h b/xen/arch/x86/include/asm/= hvm/hvm.h index 03096f31effa..55a53d9cac8f 100644 --- a/xen/arch/x86/include/asm/hvm/hvm.h +++ b/xen/arch/x86/include/asm/hvm/hvm.h @@ -259,7 +259,8 @@ extern s8 hvm_port80_allowed; extern const struct hvm_function_table *start_svm(void); extern const struct hvm_function_table *start_vmx(void); =20 -int hvm_domain_initialise(struct domain *d); +int hvm_domain_initialise(struct domain *d, + struct xen_domctl_createdomain *config); void hvm_domain_relinquish_resources(struct domain *d); void hvm_domain_destroy(struct domain *d); =20 --=20 2.11.0