From nobody Wed Dec 18 03:35:41 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=cloud.com ARC-Seal: i=1; a=rsa-sha256; t=1724335301; cv=none; d=zohomail.com; s=zohoarc; b=U0DBdczsNPyuwotG7ZRSZB4AGOtvEjVMsSG3kPsyTlQeeWmCSw7fvhMO/dpDru3QM7xsWq7V8wnzrkdaZGq0425BsHza9blSFlTQBW4FaGVAFGpzmuJe5vt3+NO1m79TtmLrEGc76hIevCFCPqvrNEieZmvU6xXqHwIO9xjjW/k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1724335301; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=X5khW8YaAwwfMgjgw8nuSi309AnsACpyZ2iwYQQbG3M=; b=DjYIPXlGpImBbJqvOSnL4oWKV2fMcbEd1XlbO/QTi+wO6qdVvXJ14zxoydreOrlGgDomevwLmy7LWIpGGiukMQL9X89DgZqD9agH6eJDATcPfDbNAjHGeIMJMj6xGRPw2DwkUeqXBqwvUNjHt1eK4fiqIxoZTMtLmbfC/wbVdVA= 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 1724335301125807.49210978472; Thu, 22 Aug 2024 07:01:41 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.781884.1191386 (Exim 4.92) (envelope-from ) id 1sh8NE-0000p4-4G; Thu, 22 Aug 2024 14:01:12 +0000 Received: by outflank-mailman (output) from mailman id 781884.1191386; Thu, 22 Aug 2024 14:01:12 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sh8NE-0000ox-1O; Thu, 22 Aug 2024 14:01:12 +0000 Received: by outflank-mailman (input) for mailman id 781884; Thu, 22 Aug 2024 14:01:10 +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 1sh8NC-0000or-R9 for xen-devel@lists.xenproject.org; Thu, 22 Aug 2024 14:01:10 +0000 Received: from mail-qv1-xf32.google.com (mail-qv1-xf32.google.com [2607:f8b0:4864:20::f32]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id f9ae65a5-608e-11ef-8776-851b0ebba9a2; Thu, 22 Aug 2024 16:01:06 +0200 (CEST) Received: by mail-qv1-xf32.google.com with SMTP id 6a1803df08f44-6bf6755323cso4338276d6.1 for ; Thu, 22 Aug 2024 07:01:06 -0700 (PDT) Received: from fziglio-xenia-fedora.eng.citrite.net ([185.25.67.249]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6c162d4c109sm7872586d6.49.2024.08.22.07.01.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Aug 2024 07:01:03 -0700 (PDT) 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: f9ae65a5-608e-11ef-8776-851b0ebba9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cloud.com; s=cloud; t=1724335265; x=1724940065; darn=lists.xenproject.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=X5khW8YaAwwfMgjgw8nuSi309AnsACpyZ2iwYQQbG3M=; b=DnWje7/BYvjbQJSLbIRFp0xqMC57AyRcMlfg9Sl9eiGu6J5B5U8tBIg2xEYqJbDxBM x7mSpA4t1Bbfh+X0aTykbFYXl2IPYpqLAefwFt8Geu2ftYrKt6noM1GK55mG3TR3vzwi z4LP+pMqkaswlvNKdE2hRIspS6aWdSydJgMxY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724335265; x=1724940065; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=X5khW8YaAwwfMgjgw8nuSi309AnsACpyZ2iwYQQbG3M=; b=tsbi78xfF6DbtmUW6Byd/zecIQeWjI8a3MUFTekvBa9wt3ht9801ztUgvg3/aAU/RS Y8noSzBYeGfHtI8/6sH0Km/ZZZ27oreJpMoA+Flsu6A+Rm0ysQR2+tW8ITglyaj/dfHh Hu7Bl1P8NGzwCuR9HKc7bIRYe9uXuY/qpdf7djUlNtJ0ufaB1nPPgcDkAcCu0CcHRVc4 EbIlI5SProPYJ2+YJoTWoguezO9M9/0XuSYxp6aiC6oFgr6GkLO0zDskJ31GXWBpRI85 hKqlffWU3kBV+a7wxuWXbZztB0WaQzf8otTrbc5E5nj+Leb1HzMHJSb6mo/6u0mkugOs 6FLw== X-Gm-Message-State: AOJu0YyBLear8Gq8BLHY+pyWlz6mb1i/bkb9oeUjmSJZRihDN/NN4KVr M21ai6UABQZLI3/gPGcqBDDud11L1xkW5LtwxDNb3hAdugFM3HclEPsLRCKH18C/xO+ieMyLEvo g X-Google-Smtp-Source: AGHT+IFTwIfHUxyJqPhqRnhQRnWSCdyuMoNRg5aSCiDzJIKW0BzQcLD+qPzatTyU1NObIezm7fa3KQ== X-Received: by 2002:a05:6214:4612:b0:6b4:4585:8e43 with SMTP id 6a1803df08f44-6c155d9d07amr74983806d6.31.1724335263878; Thu, 22 Aug 2024 07:01:03 -0700 (PDT) From: Frediano Ziglio To: xen-devel@lists.xenproject.org Cc: Frediano Ziglio , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [PATCH v2] Restore memory used for IP computation Date: Thu, 22 Aug 2024 15:00:43 +0100 Message-ID: <20240822140044.441126-1-frediano.ziglio@cloud.com> X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @cloud.com) X-ZM-MESSAGEID: 1724335303469116600 Content-Type: text/plain; charset="utf-8" We need to write in some location but no reasons to not trying to restore what we potentially overwrote. Signed-off-by: Frediano Ziglio --- xen/arch/x86/boot/head.S | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) --- Changes since v1: - Rewrite magic number field instead of some possible BIOS area. diff --git a/xen/arch/x86/boot/head.S b/xen/arch/x86/boot/head.S index d8ac0f0494..9b7e7b4e51 100644 --- a/xen/arch/x86/boot/head.S +++ b/xen/arch/x86/boot/head.S @@ -415,16 +415,19 @@ __pvh_start: =20 /* * We need one push/pop to determine load address. Use the same - * absolute stack address as the native path, for lack of a better - * alternative. + * stack address as the native path. */ - mov $0x1000, %esp + mov %ebx, %esp + pop %edx =20 /* Calculate the load base address. */ call 1f 1: pop %esi sub $sym_offs(1b), %esi =20 + /* Restore clobbered magic field */ + push %edx + /* Set up stack. */ lea STACK_SIZE - CPUINFO_sizeof + sym_esi(cpu0_stack), %esp =20 @@ -463,18 +466,21 @@ __start: * relocatable images, where one push/pop is required to calculate * images load address. * - * On a BIOS-based system, the IVT and BDA occupy the first 5/16th= s of - * the first page of RAM, with the rest free for use. Use the top= of - * this page for a temporary stack, being one of the safest locati= ons - * to clobber. + * Save and restore the magic field of start_info in ebx, and use + * that as the stack. See also + * https://lore.kernel.org/xen-devel/20240814195053.5564-3-jason.a= ndryuk@amd.com/ */ - mov $0x1000, %esp + mov %ebx, %esp + pop %edx =20 /* Calculate the load base address. */ call 1f 1: pop %esi sub $sym_offs(1b), %esi =20 + /* Restore clobbered magic field */ + push %edx + /* Set up stack. */ lea STACK_SIZE - CPUINFO_sizeof + sym_esi(cpu0_stack), %esp =20 --=20 2.46.0