From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f201.google.com (mail-pl1-f201.google.com [209.85.214.201]) (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 47DC53191DF for ; Tue, 20 Jan 2026 17:04:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768928669; cv=none; b=Vc4LCO2oipUp2lwNAZhF8hxSK1sm21GVG8mAJ9Cs7JvYWnUJ1YAeNMw2MH/MYNwf2rvgtec2hjyyL7gdRQNzDOIV17nyoG0OBhC3w2ifUtowUMoQP8oBCfP0Y1pPkpuqax5tYhKXGHwTLD8117YbxF4GyHXDbxAjoWy0YcFMeig= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768928669; c=relaxed/simple; bh=Ycy21iUncoH/EI2xFovIFcUv/mmTJGHGmyFSb6UEnT0=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=qSOPSId2QephKvJvjTFDcLcT3h3Am8ksxRDaBgA0Kph7V5AHEkIoSdj6wJLmejlIyn9bbpvpcC5T2HHc5l3YMs0Dpy14EWo9uDqGxU96q3SQ2+n2nXPwql8QX0EWIzwomqjzCQ/XuKrEpJNdpKjCdGwFCNp7YP/DRo9NkTCtHNg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=tDA6o+l1; arc=none smtp.client-ip=209.85.214.201 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--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="tDA6o+l1" Received: by mail-pl1-f201.google.com with SMTP id d9443c01a7336-2a377e15716so110587475ad.3 for ; Tue, 20 Jan 2026 09:04:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1768928667; x=1769533467; 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=3jBNcNLijS6CegFyscucRvLlda8lrhInLC4WxoMsJSU=; b=tDA6o+l1BsBl+fpfCTJN0Qj0VHDzGN0lpVwlBkUF82kQOyHLAeLtSNhV+R91PLXRgi cX0nBUxF80VpkQ6qZ8BuxeZzowOEb29oomsj7J0uLiJksJSitLAUwPKD7kKZX33AkCgq u62TlHkXPG9CE+dj/SwJRcgtdJJ8x3/9ILfuO+tV7IgSj+ItLnLKbcQBn7RDP765bcLY 8KxsErOwlj0ojwKOfAeMfBdlFf9Ju4RQodpEIynsbpnbHR53lJ6ZHMt2+aH5dNVodgWM Shmq1ugjl52ZjYbblvnsbmosTRBcRGjyE0IbVLcWbRfAQEKNmHJ7GjYU6bMRak7O5pIz Z2bA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768928667; x=1769533467; 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=3jBNcNLijS6CegFyscucRvLlda8lrhInLC4WxoMsJSU=; b=O+9CfGq9CwOy6KgbnT2X12lDfN/90NC49IwnTBh38KqmCPnBtJyLkQoaUGwZCc5snp SKl6bAMAUZKL9zTF/YsiMb2jflRr2yV5hnqa9qxyYmXMOIXD7lCGxvQxciAFB7uOC2gZ C+gI0j2Z2jQQkvR3hnuxq/eGAcxPW8PFcP0rU6V9xm7eCch9JgahMDfCP9w62MRI1yK4 4/opIgn6m209ukioww7QUblxVaDr6zJDyUIgtymZ3L1QRes/C5PFvDJ71hkFWZEhT+0K e/dDk/S1INL4geTk9NdeNvXH/3ciOvvbTLkSDxQeRfLGMqukhnc/jOTiKM+fOgM8rkWy xdaw== X-Gm-Message-State: AOJu0YxasIOhX8sNdoYuwqtUt+xcDm49461ijvpksKl0DZvPz1PU/f7f 5XMHzEy4QigPWX15e/01seAx7qJQZ6de6DkgPvDS0/e/i4Hh891M64L5UQb6ypOlqU79CX5hAgB r4vuPoQ== X-Received: from plbke15.prod.google.com ([2002:a17:903:340f:b0:2a7:6fd5:9ab9]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a17:902:c40e:b0:298:616a:ba93 with SMTP id d9443c01a7336-2a718857417mr116338325ad.9.1768928667435; Tue, 20 Jan 2026 09:04:27 -0800 (PST) Date: Tue, 20 Jan 2026 09:04:26 -0800 In-Reply-To: <20260108092526.28586-31-ardb@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260108092526.28586-21-ardb@kernel.org> <20260108092526.28586-31-ardb@kernel.org> Message-ID: Subject: Re: [RFC/RFT PATCH 10/19] x86/kvm: Use RIP-relative addressing From: Sean Christopherson To: Ard Biesheuvel Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Josh Poimboeuf , Peter Zijlstra , Kees Cook , Uros Bizjak , Brian Gerst , linux-hardening@vger.kernel.org Content-Type: text/plain; charset="us-ascii" On Thu, Jan 08, 2026, Ard Biesheuvel wrote: > Replace absolute references in inline asm with RIP-relative ones, to > avoid the need for relocation fixups at boot time. This is a > prerequisite for PIE linking, which only permits 64-bit wide > loader-visible absolute references. > > Signed-off-by: Ard Biesheuvel > --- > arch/x86/kernel/kvm.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/arch/x86/kernel/kvm.c b/arch/x86/kernel/kvm.c > index df78ddee0abb..1a0335f328e1 100644 > --- a/arch/x86/kernel/kvm.c > +++ b/arch/x86/kernel/kvm.c > @@ -807,8 +807,9 @@ extern bool __raw_callee_save___kvm_vcpu_is_preempted(long); > * restoring to/from the stack. > */ > #define PV_VCPU_PREEMPTED_ASM \ > - "movq __per_cpu_offset(,%rdi,8), %rax\n\t" \ > - "cmpb $0, " __stringify(KVM_STEAL_TIME_preempted) "+steal_time(%rax)\n\t" \ > + "0:leaq 0b(%rip), %rax\n\t" \ Please use something other than '0' for the label, it took me forever (and looking at disassembly) to realize "0b" was just a backwards label and not some fancy syntax I didn't know. It might also be worth calling out in the changelog that this function is called across CPUs, e.g. from kvm_smp_send_call_func_ipi(), and thus can't use gs: or any other "normal" method for accessing per-CPU data. > + "addq __per_cpu_offset - 0b(%rax,%rdi,8), %rax\n\t" \ > + "cmpb $0, " __stringify(KVM_STEAL_TIME_preempted) "+steal_time-0b(%rax)\n\t" \ > "setne %al\n\t" > > DEFINE_ASM_FUNC(__raw_callee_save___kvm_vcpu_is_preempted, > -- > 2.47.3 >