From nobody Sat Dec 21 18:09:03 2024 Received: from mail-ej1-f73.google.com (mail-ej1-f73.google.com [209.85.218.73]) (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 C50CC18E021 for ; Wed, 25 Sep 2024 15:02:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.73 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727276544; cv=none; b=poEZ7nDywbun6C7eJjui/8k79CImn+kiNPiZ5hDTViF2a4vF8N4jXR6edVnDkk2Sl1v+vHCMadTiMq9HQ8XtYuzi7c6NSutyZJj/51fk0fSwEMRCiRhmvwQ2SjZas4RNdSNIMq1M9UndUKp9ETDKarTawHwNYc7D0s/AIACoQNc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727276544; c=relaxed/simple; bh=5QDZ8e6v38oe4vdIzJiUkWBfZtQ8UHIt+vUykdg9FgY=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=kG4PR6lqqUz1+bhdrYB/Fgw9Qv8WWrH9DOwIlOccPGXp04hE9BPHdkRRUKMBxK8ay9Of7UYsluwEu0UIGlT87FDdGRS1Pgvgg1aPooGFA2GGBzyefZgU9rhrVmFqgaa6D8U8DT2frBf6lw6rruFaIA5IKLYaT5RPpvwhaPxMb/M= 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=LeXPBBTs; arc=none smtp.client-ip=209.85.218.73 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="LeXPBBTs" Received: by mail-ej1-f73.google.com with SMTP id a640c23a62f3a-a8a7463c3d0so447911966b.2 for ; Wed, 25 Sep 2024 08:02:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1727276541; x=1727881341; 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=sMLI1adUSxUIp8UXfDcqdD38QxXI+e+F/+Ag4yCxL7E=; b=LeXPBBTsdUX0tgcobuyp0O/6x6z2M5lVDEdbOYH34+fi2/CYM93dEc402cMrFtvM+F CkJx94uMVdCwK7Xc97aEqwdfpJNBKO2xEg7vZldZWC55yQpmfJdjM/wsBayNID9D3qlx P1TsBUMydJjkA5gRJJs8M7gY02k1UvKjmTGyfyzSrE7txWaMXnE94lcDM+iaFZuH4duK /3T2QoUxHNE9G/Aef3gP8mIJ6FEaHR2IEDPCLGLt8Ef/RMihVG1nayEs1fW9xkZ6pdmI M/1LnAjWDiYtcu+/2Qxjjxg/Okoi/YybMwm16A4DUKBrZSlODzKYpyXRIT3F6S6iDa07 xNAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727276541; x=1727881341; 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=sMLI1adUSxUIp8UXfDcqdD38QxXI+e+F/+Ag4yCxL7E=; b=X58s44iTSd0bPcM2HXbdn+R3cmU/tMbJOsFCyFpThmaHvG9zIgGQ04CBW2o96C+snu 4OjlbTIFf4/INL2tRZ6FPFqZl8E6YJStI5lq/8O6D+hANxW/39DKnS3Z6X+xPbt0ABUG GULf8d8SRmLm6nCUC2oqQb2DFM6XQF9Fbey9pb+s3z3/j83unKVSMe0/VSy0BBaqme9N lSKVEAVBCJfhhKDqxKSiA0Wm3wMXhcsxUl/zcQ2h6Rn7jZcKiNNgM3U/KvRYAJEhGgO5 sKNLTY+JVFZo+Kp2wp3mM4UJTu16k1cLg7ON0mzAGx3pKv6azXrKCnicW5wfFgtXdKND Y0PA== X-Gm-Message-State: AOJu0Yy9wB0A3Q8LeiuFoPPHnmYTzEtMbxTYin4f+OnzQG57T6pmp5YU VQijqjfJftSlXyqPzXe+NdDsO3R6habeHLCc/kNcxClytgzsKH7kCE66iAgHVbSnEWZrdQnV/uS SR0YYnaK4C5EvkBk77U9KpNXdcdwvVc/Ncq1cHl2uBlDarsjcfUAFp+5OpTppRVAf9kzE0ARIco DRGHettgFRgXRBu15Z/HNfE+eyKiQTgA== X-Google-Smtp-Source: AGHT+IHqdrbnTURYSpf/5afh17e1i3rk5opqYbKAlLurQBauppiTWqSh5+YV6ICpl369+Ha35/G5jy3r X-Received: from palermo.c.googlers.com ([fda3:e722:ac3:cc00:7b:198d:ac11:8138]) (user=ardb job=sendgmr) by 2002:a17:906:6d8:b0:a8a:76fd:ae67 with SMTP id a640c23a62f3a-a93a061ba72mr129666b.10.1727276539991; Wed, 25 Sep 2024 08:02:19 -0700 (PDT) Date: Wed, 25 Sep 2024 17:01:12 +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=2056; i=ardb@kernel.org; h=from:subject; bh=VKZKKQxE7f774DDxhaNjhf6gM8y+4CHtkhz4ITFKHVU=; b=owGbwMvMwCFmkMcZplerG8N4Wi2JIe2L6l6HjphM91K+tMbfPlum+q87xXbcaBq/plqB6J0rH Clz7dQ6SlkYxDgYZMUUWQRm/3238/REqVrnWbIwc1iZQIYwcHEKwESez2L4w3XU9mNkQveSSXqf bkfpTfktlPbu753X3m4//t4RvX456gUjw9ItwQrWWxY9aPiwtX3xVeeW5YpKNdGO1l4qU7KmnF4 VzwoA X-Mailer: git-send-email 2.46.0.792.g87dc391469-goog Message-ID: <20240925150059.3955569-42-ardb+git@google.com> Subject: [RFC PATCH 12/28] x86/pm-trace: Use RIP-relative accesses for .tracedata 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 RIP-relative accesses and 32-bit offsets for .tracedata, to avoid the need for relocation fixups at boot time. Signed-off-by: Ard Biesheuvel --- arch/x86/include/asm/pm-trace.h | 4 ++-- drivers/base/power/trace.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/pm-trace.h b/arch/x86/include/asm/pm-trac= e.h index bfa32aa428e5..123faf978473 100644 --- a/arch/x86/include/asm/pm-trace.h +++ b/arch/x86/include/asm/pm-trace.h @@ -8,10 +8,10 @@ do { \ if (pm_trace_enabled) { \ const void *tracedata; \ - asm volatile(_ASM_MOV " $1f,%0\n" \ + asm volatile("lea " _ASM_RIP(1f) ", %0\n" \ ".section .tracedata,\"a\"\n" \ "1:\t.word %c1\n\t" \ - _ASM_PTR " %c2\n" \ + ".long %c2 - .\n" \ ".previous" \ :"=3Dr" (tracedata) \ : "i" (__LINE__), "i" (__FILE__)); \ diff --git a/drivers/base/power/trace.c b/drivers/base/power/trace.c index cd6e559648b2..686a0276ccfc 100644 --- a/drivers/base/power/trace.c +++ b/drivers/base/power/trace.c @@ -167,7 +167,7 @@ EXPORT_SYMBOL(set_trace_device); void generate_pm_trace(const void *tracedata, unsigned int user) { unsigned short lineno =3D *(unsigned short *)tracedata; - const char *file =3D *(const char **)(tracedata + 2); + const char *file =3D offset_to_ptr((int *)(tracedata + 2)); unsigned int user_hash_value, file_hash_value; =20 if (!x86_platform.legacy.rtc) @@ -187,9 +187,9 @@ static int show_file_hash(unsigned int value) =20 match =3D 0; for (tracedata =3D __tracedata_start ; tracedata < __tracedata_end ; - tracedata +=3D 2 + sizeof(unsigned long)) { + tracedata +=3D 2 + sizeof(int)) { unsigned short lineno =3D *(unsigned short *)tracedata; - const char *file =3D *(const char **)(tracedata + 2); + const char *file =3D offset_to_ptr((int *)(tracedata + 2)); unsigned int hash =3D hash_string(lineno, file, FILEHASH); if (hash !=3D value) continue; --=20 2.46.0.792.g87dc391469-goog