From nobody Sun Nov 24 18:59:03 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=google.com ARC-Seal: i=1; a=rsa-sha256; t=1727680546; cv=none; d=zohomail.com; s=zohoarc; b=Ai9vRalu0/cOR8Yp8eA+scxELotujSQUoLggsi+gUrSnZqlUyWFACxTJaqwlJh1e8c2oTY2HaT0/xBvUz5Z3USRS8o+aIfM0YSEdTxkPTwAinURXDVI/IN/kv3xmsIxmMFAX/zTo/ZEkyOtoXcqrBd4IkU0ZEjpg5xdVCo7eXdw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1727680546; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HsZTXhwK3mXXOhRjtLwXUoeG4XCPMITRRWukmjYsd98=; b=ngtJORcaQOob6Zamg0S15s5GKSTlTqZ0l/HVtUKIKP1Vx5thO656d5dUaM3WpXL6dJ9F2BouF6O9UFPz2TRJAS6D1XVxXDacKr9to6HVH8/aLaBAHC2x75uv/0dT/jxW5CpNVcZrbMlLf8bGwd4k0zNv7hA2zfJKMifpJuGb+eQ= 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 1727680546420181.8774844665869; Mon, 30 Sep 2024 00:15:46 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.807022.1218183 (Exim 4.92) (envelope-from ) id 1svAd2-0007se-0F; Mon, 30 Sep 2024 07:15:32 +0000 Received: by outflank-mailman (output) from mailman id 807022.1218183; Mon, 30 Sep 2024 07:15:31 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1svAd1-0007sT-TX; Mon, 30 Sep 2024 07:15:31 +0000 Received: by outflank-mailman (input) for mailman id 807022; Mon, 30 Sep 2024 07:15:30 +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 1svAd0-0007gP-9c for xen-devel@lists.xenproject.org; Mon, 30 Sep 2024 07:15:30 +0000 Received: from mail-yw1-x114a.google.com (mail-yw1-x114a.google.com [2607:f8b0:4864:20::114a]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id c563d1c4-7efb-11ef-a0ba-8be0dac302b0; Mon, 30 Sep 2024 09:15:29 +0200 (CEST) Received: by mail-yw1-x114a.google.com with SMTP id 00721157ae682-6ddbcc96984so59785677b3.2 for ; Mon, 30 Sep 2024 00:15:29 -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: c563d1c4-7efb-11ef-a0ba-8be0dac302b0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727680528; x=1728285328; darn=lists.xenproject.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=HsZTXhwK3mXXOhRjtLwXUoeG4XCPMITRRWukmjYsd98=; b=r5BvIWjhzgBZLXiFsnaR7700yj/lo3uMYDxrusVnxnFM22T4O6+rf5zcui6B0oxxRx uZSrkSDZwv7zMoVRDvC7XBnJ94PDbUVFXAG64mxvlBfOTNfj0Z20oQZjNQk2B5tCTpuy QcMqM09q2kVl+TQKXOCsUawMhyIH5flhKmkoqLndxTj6HvTSQHbjhwtKu3GKjATxXmq4 QLCjbllOu6p5ChA3Jp6Sar751mHvhfqLQM6oGu5tYRFUdGf2bIAknHMNC9MGuFbJPlBj ka3MOrOQViBp7IGzzzWBlBPTk3DeWJZup7rvoTRXaHUg/llgxLjWGbzbyAz9pD2vxo7W dbCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727680528; x=1728285328; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=HsZTXhwK3mXXOhRjtLwXUoeG4XCPMITRRWukmjYsd98=; b=Ux3Qs+Xi5ioYMOhuGlHPSXQsa7ku0PLytDLhdsLzPb2/9XfHozBPGn/YwcT46uaok5 eVZDl7H9XFf3w1n8b3bJNQ5SHmdy8fgPJTyx7tDUdPwm7DK3UhZDOWHjQBM9AA3KyVVk nEYUPyqnJbaSfCftE7TssimV6phRDLiZhBZboJvDL3Ebqn3JookzUBiv9DOTvRTLBeXx YIj93y+NPWrtWQA/MT35CBYTymKJ1DA6Tzdb/frVq5a1kMNQ7AnlH9BdofwXNQP1jtEN PBDKeJb1GKoiZAGEwPdoBcJmAUSMEtp/KkWBSWs++rKxbbU3W9RIlFnNnkDwAvxPKPiu a8Kg== X-Forwarded-Encrypted: i=1; AJvYcCWkG5XWsrct5kHYDnYsB4okyaCh1NTYaoqdy1pCluKz3Ks3tSfb9MTBh8ibrYH/r9X2ei66WsSaGpc=@lists.xenproject.org X-Gm-Message-State: AOJu0Yz1gSbPzNY6K9YJ8pq9n4ycPVlUGvUHFTz9h6DLey/YClMKtlVb Dysyfn3wNHnW1zrcxNQB+C2fhaoHoulbyADFBmSec3jPSkChDpllEZOK6n1T9cGcHcma0Q== X-Google-Smtp-Source: AGHT+IEEITnmcH5UeTV2zllc3PmFUNjrBWClElCZQ6t5GapgJ1dmZhJuA8uiVOK2ULv5OhBDd14Xgcyd X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:7b:198d:ac11:8138]) (user=ardb job=sendgmr) by 2002:a05:690c:c83:b0:68d:52a1:bed with SMTP id 00721157ae682-6e2474d2257mr1919327b3.1.1727680527795; Mon, 30 Sep 2024 00:15:27 -0700 (PDT) Date: Mon, 30 Sep 2024 09:15:15 +0200 In-Reply-To: <20240930071513.909462-7-ardb+git@google.com> Mime-Version: 1.0 References: <20240930071513.909462-7-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=1580; i=ardb@kernel.org; h=from:subject; bh=DOghVKCQRkP+2PZSSBUfsRwzGz2qTq1yeEJiIzZkHRA=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIe1XAPP+CW6ZqxccPKowL43/Tf6HExp8dsf8IuIdo91Dp 38VbpvbUcrCIMbBICumyCIw+++7nacnStU6z5KFmcPKBDKEgYtTACZyP5ThD39HQciqZ45X7a+I V/w7Vrn2CUPYFo2E0GfiEzqK3SeJaDH8FaicbvpzA/e5xw8uM6jYfnfbb220fSNTS1jDbtfUmGu XuAE= X-Mailer: git-send-email 2.46.1.824.gd892dcdcdd-goog Message-ID: <20240930071513.909462-8-ardb+git@google.com> Subject: [PATCH v2 1/5] x86/pvh: Call C code via the kernel virtual mapping From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: Ard Biesheuvel , Jason Andryuk , Juergen Gross , Boris Ostrovsky , x86@kernel.org, xen-devel@lists.xenproject.org X-ZohoMail-DKIM: pass (identity @google.com) X-ZM-MESSAGEID: 1727680548534116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ard Biesheuvel Calling C code via a different mapping than it was linked at is problematic, because the compiler assumes that RIP-relative and absolute symbol references are interchangeable. GCC in particular may use RIP-relative per-CPU variable references even when not using -fpic. So call xen_prepare_pvh() via its kernel virtual mapping on x86_64, so that those RIP-relative references produce the correct values. This matches the pre-existing behavior for i386, which also invokes xen_prepare_pvh() via the kernel virtual mapping before invoking startup_32 with paging disabled again. Fixes: 7243b93345f7 ("xen/pvh: Bootstrap PVH guest") Tested-by: Jason Andryuk Reviewed-by: Jason Andryuk Signed-off-by: Ard Biesheuvel --- arch/x86/platform/pvh/head.S | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/arch/x86/platform/pvh/head.S b/arch/x86/platform/pvh/head.S index 64fca49cd88f..ce4fd8d33da4 100644 --- a/arch/x86/platform/pvh/head.S +++ b/arch/x86/platform/pvh/head.S @@ -172,7 +172,14 @@ SYM_CODE_START_LOCAL(pvh_start_xen) movq %rbp, %rbx subq $_pa(pvh_start_xen), %rbx movq %rbx, phys_base(%rip) - call xen_prepare_pvh + + /* Call xen_prepare_pvh() via the kernel virtual mapping */ + leaq xen_prepare_pvh(%rip), %rax + subq phys_base(%rip), %rax + addq $__START_KERNEL_map, %rax + ANNOTATE_RETPOLINE_SAFE + call *%rax + /* * Clear phys_base. __startup_64 will *add* to its value, * so reset to 0. --=20 2.46.1.824.gd892dcdcdd-goog