From nobody Fri Nov 29 03:43:28 2024 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E1848193062 for ; Wed, 25 Sep 2024 15:02:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727276565; cv=none; b=qQgLTvPK9REQAftorEOqpj/jZN0SaTRGx7I1Mj1cyrqFfOSggUtISjjpD36dcqewHlP4x6dkboh0sPF+xdUnNCPdAy68aOGu+Cp9GiPlfEZG60+arzMyeDbO9ummryfa55zeSnfgCRw3VY12vhLPYfNljKnjz18T2ZZ7dRD/K9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727276565; c=relaxed/simple; bh=9UAQuGK2mWhKEqX7oxUH9zhtKGPJ6CK9xsJA2g/Xjq0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=MCpxlXoUW2yE6mFA2m5MYNqavdSIOhpg95rOS1pEmRmCulZ7w5/pqble8YNBXDl1RcCSXiCc1yvzIFVZwqwvPNzsAciXJmrTFF1L5sF4HmNK6Xc6Qm4hymEhuQuqTidzdJNToepjGhnmwo9mKQbjRYqa9+kPqVqomA5vq7kOh1I= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=r++YG/pQ; arc=none smtp.client-ip=209.85.128.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ardb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="r++YG/pQ" Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-6db7a8c6831so109995817b3.3 for ; Wed, 25 Sep 2024 08:02:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727276562; x=1727881362; darn=vger.kernel.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=FlbORA03gt7VD7U3AKlte04ifRsDRozPK1w/WollpSI=; b=r++YG/pQlTOwXp9f1MnH7vTGQLeQr5cQaejWllulTN1n4LXJIpELvkvQZR5I4t0Jgw yS8YxYNmG+tCO3iprEn2zRX4KABA1nrOu7OorZ0caCZN5h52Oq1KB6LVv4RWSv0XLOTy mLnFb0YYsQ3Nh//iLrpL+xDtidxbAipOUHNd13y9OOvXSwDd6dX2mHnmaxQEEaQ274wo fJ5t1gHpnord3C5N2cPrvS+p+rS7cYl/f5yp7+JgHMOOLiwXg1M4YSIoy+MOTrruHRW/ 825Mzn7ewNtj0f6kEFj4ZoMoI+ieqmi/aXoCPE8VsmmEmlnV97dz2qm3cxvTVctsmLV4 wOtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727276562; x=1727881362; 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=FlbORA03gt7VD7U3AKlte04ifRsDRozPK1w/WollpSI=; b=kOl0s7BvWye+Mr9r/RrHZp3s+cwet3WSqPJAAJAQrazliStkSDhsA0AdMGZ7IriW/7 6jmIOTgCA9kXSqSMnfpGHzei9BzpZAgHptsp2h62YD1DS85t2MowootKn1shSIsWnFUI yv8WzY+SEkcZmwSq/msT5Zo5m56XVCM3RkDnsG80GlLXsX6AYmFfk7g/86YDcK4l8bav DJvCIdQwgLk7HuQh4m6FJT4K1NeAC+VuIfwpqiwADAG2wEwbz6s7rr/Qt2RmUOGD1FCx d1fxM4Ig9LcdpJok6A0OKU5I+qU3mbAfFHOK3YVkXSpY957B4h7W3YQm0T7k7gKBlL4b E6mA== X-Gm-Message-State: AOJu0Yx0eIKfMbVaTrJWgMqm/6zt5s41feabyz8dgOMOEBq2rseo0v0B SLibe9sUDOyUbv8RogjCJHhctk1u6IC+PZmb1s7Ke3mz781aLlTJos2zVJ99/ZX8TubnRRzuQJS GnzhI6Bg8saL3qL2JAG2rpnV8/yTy4tKLP0thFlicY+sm+SrWPxF4bGeQtpkE6nZDTsBprXxzys SVMLCyBuclP7mEdbwsnHN39co61QV5JA== X-Google-Smtp-Source: AGHT+IH4yCJxpgJpRghyt05ffZ0KMtbzY3622CltTm7OPK0ZYLkhBwwkH9bUzMfV7VeGOafl80KA41By X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:7b:198d:ac11:8138]) (user=ardb job=sendgmr) by 2002:a05:690c:4289:b0:6e0:1ad:b197 with SMTP id 00721157ae682-6e21d9eb35cmr74667b3.3.1727276561223; Wed, 25 Sep 2024 08:02:41 -0700 (PDT) Date: Wed, 25 Sep 2024 17:01:20 +0200 In-Reply-To: <20240925150059.3955569-30-ardb+git@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20240925150059.3955569-30-ardb+git@google.com> X-Developer-Key: i=ardb@kernel.org; a=openpgp; fpr=F43D03328115A198C90016883D200E9CA6329909 X-Developer-Signature: v=1; a=openpgp-sha256; l=2120; i=ardb@kernel.org; h=from:subject; bh=udZt3Ybebg1JaBid31YzntWp5JIa5pAk0HVUlAzZyZ0=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIe2L6gljFsPIOfpfC+4mTz0SPOfTfNeM53artXe5vlz2r m2tZ4xiRykLgxgHg6yYIovA7L/vdp6eKFXrPEsWZg4rE8gQBi5OAZjI/0qG/z53N1inv844/EXP gLPr2aVVD8T/nDB5/WSxtlzL53WrfboZGX7d3NY04aKrkHqeft+Obu4DWbvCTcvYF6zT0yzuZn0 pwQAA X-Mailer: git-send-email 2.46.0.792.g87dc391469-goog Message-ID: <20240925150059.3955569-50-ardb+git@google.com> Subject: [RFC PATCH 20/28] x64/acpi: Use PIC-compatible references in wakeup_64.S From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Cc: Ard Biesheuvel , x86@kernel.org, "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Uros Bizjak , Dennis Zhou , Tejun Heo , Christoph Lameter , Mathieu Desnoyers , Paolo Bonzini , Vitaly Kuznetsov , Juergen Gross , Boris Ostrovsky , Greg Kroah-Hartman , Arnd Bergmann , Masahiro Yamada , Kees Cook , Nathan Chancellor , Keith Packard , Justin Stitt , Josh Poimboeuf , Arnaldo Carvalho de Melo , Namhyung Kim , Jiri Olsa , Ian Rogers , Adrian Hunter , Kan Liang , linux-doc@vger.kernel.org, linux-pm@vger.kernel.org, kvm@vger.kernel.org, xen-devel@lists.xenproject.org, linux-efi@vger.kernel.org, linux-arch@vger.kernel.org, linux-sparse@vger.kernel.org, linux-kbuild@vger.kernel.org, linux-perf-users@vger.kernel.org, rust-for-linux@vger.kernel.org, llvm@lists.linux.dev Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Ard Biesheuvel Use ordinary RIP-relative references to make the code compatible with running the linker in PIE mode. Note that wakeup_long64() runs in the kernel's ordinary virtual mapping so there is no need to record the address of .Lresume_point in a global variable. And fix the comment while at it. Signed-off-by: Ard Biesheuvel --- arch/x86/kernel/acpi/wakeup_64.S | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/acpi/wakeup_64.S b/arch/x86/kernel/acpi/wakeup= _64.S index 94ff83f3d3fe..af2f2ed57658 100644 --- a/arch/x86/kernel/acpi/wakeup_64.S +++ b/arch/x86/kernel/acpi/wakeup_64.S @@ -14,7 +14,7 @@ =20 .code64 /* - * Hooray, we are in Long 64-bit mode (but still running in low memory) + * Hooray, we are in Long 64-bit mode */ SYM_FUNC_START(wakeup_long64) movq saved_magic(%rip), %rax @@ -40,7 +40,7 @@ SYM_FUNC_START(wakeup_long64) movq saved_rsi(%rip), %rsi movq saved_rbp(%rip), %rbp =20 - movq saved_rip(%rip), %rax + leaq .Lresume_point(%rip), %rax ANNOTATE_RETPOLINE_SAFE jmp *%rax SYM_FUNC_END(wakeup_long64) @@ -51,7 +51,7 @@ SYM_FUNC_START(do_suspend_lowlevel) xorl %eax, %eax call save_processor_state =20 - movq $saved_context, %rax + leaq saved_context(%rip), %rax movq %rsp, pt_regs_sp(%rax) movq %rbp, pt_regs_bp(%rax) movq %rsi, pt_regs_si(%rax) @@ -70,8 +70,6 @@ SYM_FUNC_START(do_suspend_lowlevel) pushfq popq pt_regs_flags(%rax) =20 - movq $.Lresume_point, saved_rip(%rip) - movq %rsp, saved_rsp(%rip) movq %rbp, saved_rbp(%rip) movq %rbx, saved_rbx(%rip) @@ -88,7 +86,7 @@ SYM_FUNC_START(do_suspend_lowlevel) .align 4 .Lresume_point: /* We don't restore %rax, it must be 0 anyway */ - movq $saved_context, %rax + leaq saved_context(%rip), %rax movq saved_context_cr4(%rax), %rbx movq %rbx, %cr4 movq saved_context_cr3(%rax), %rbx @@ -137,7 +135,6 @@ saved_rsi: .quad 0 saved_rdi: .quad 0 saved_rbx: .quad 0 =20 -saved_rip: .quad 0 saved_rsp: .quad 0 =20 SYM_DATA(saved_magic, .quad 0) --=20 2.46.0.792.g87dc391469-goog