Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1135838rdd; Wed, 10 Jan 2024 09:36:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IH3tPNEHjxasflJnLLkWA0QFNIxYYcxARAyDm5O2ZQ/ZPO8DL6vWqzuzp7UfH3VKV01YlP0 X-Received: by 2002:a19:8c57:0:b0:50e:cd10:1768 with SMTP id i23-20020a198c57000000b0050ecd101768mr579057lfj.109.1704908166908; Wed, 10 Jan 2024 09:36:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704908166; cv=none; d=google.com; s=arc-20160816; b=0zkX/bfm8Jt3mJYShjrgyq7b4VicSbCpDTcRRgsgCkITLfBppFvXWdm5OzkW1BrNWO wjjH0pbGlVgxzvCYakK4Xs5M5K339a8a+g/DzHcmuSWFrdQMlAnKuGpHOjHZH1UVy75J 2FmFWSVvJ++V8E+oGcITI6FAu+8xWIVdEwg91ilqDEz4+l9F5dAPHGCqic+ih3mZ5Ty8 uv16gh8FT3swM7D7WS4FTiiyQNvYSNZ0QgzHWShGHONWtzxRbAw4+3YO5cr0hAOzUUW6 ysvIRrhNiiDoa+5U80gn411TxHHBROPwFeJWeFThnkf9ELPwNO/REskIRF/kjr7omVgU /5aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=v1gDQWRsTBn8FfuPpZdgTLj6dmGKzp9kvOi2HJqDhRc=; fh=F7XTrW/Ykn9PoZonf1hhTubLK4/Ie1ix3n7FsqIFKho=; b=MAHVnTE0W5v1RdacvPCxKTZa882H7JeAZQKLTMuv9M9DHPNiQna+sU6B4MtdNd+VtZ 34tyzyUb7waw+0deSt+Yb27rSa4ksjs0ia/Kz83qAjw5HlStCuG4NOQ7W28tb1xAGQ+/ qP6rahUZnr1WXeP34xAm5l1EbdgIcrFQwJf3qlCiIiY2Dcv+ggpSe9Zd15Wr1JsRqgLM c5nhi8AMjtTzbiKDYU+UN+GtMBvob1ZDPqhGFVdbkFaM9fscvPao/asUTf/JO1BR6rHf Dn2oQQjvp2XaUUnkfW847CPf2ao9kHmICuGZ8bCsmDS2USSQXeflKDlu1w4r6wG4M4gj +uoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=h8F25P27; spf=pass (google.com: domain of linux-kernel+bounces-22535-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22535-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id r19-20020a50aad3000000b00554e9024673si1855439edc.626.2024.01.10.09.36.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jan 2024 09:36:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-22535-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=h8F25P27; spf=pass (google.com: domain of linux-kernel+bounces-22535-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-22535-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 85B981F28C0A for ; Wed, 10 Jan 2024 17:28:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A62FA4CE1B; Wed, 10 Jan 2024 17:28:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="h8F25P27" Received: from mail-ua1-f41.google.com (mail-ua1-f41.google.com [209.85.222.41]) (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 96F8347F56 for ; Wed, 10 Jan 2024 17:28:33 +0000 (UTC) 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=google.com Received: by mail-ua1-f41.google.com with SMTP id a1e0cc1a2514c-7cd42bc09adso1313375241.2 for ; Wed, 10 Jan 2024 09:28:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1704907712; x=1705512512; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=v1gDQWRsTBn8FfuPpZdgTLj6dmGKzp9kvOi2HJqDhRc=; b=h8F25P27vHUT8FawdZEMegwqD0cSRM1tQiSA3jzYaw0xWgZlyuWw+pRR8BJn07DzWA wOf2KTyOkKv/bAiiJ1fWIjopjHAGVKRnnyU74W9njxo6Em08hf/48FOa0a0lneFpKtln FkJstHydYZfAYoxtY2/8gT9UGC870aks/DRn/r2nFio7PX/Jk0yRTx1XPqn00PisP//a jzF9JaRFWKUgsQKxk5EA8TnRkvmgSaoxfMRs2OCzLEWZEjwXe4wzT+Di6VZWvQPJ0P41 loTwAkFBt3rp9D3nPB/TcectJZOeFc30NTzeic13kw6KNa2nbEBXtclFgvIT87XQxUC7 hWRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704907712; x=1705512512; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=v1gDQWRsTBn8FfuPpZdgTLj6dmGKzp9kvOi2HJqDhRc=; b=vtvzvefxGrHn0YvVpqschVOsybrLwDwE0hltd0VMmZd4FHveGbDSQ+y1MxbjBDWJtm vbeU5izNl2eE4PJdHbR+8pChVj0G/TlK3sEHYvJVpzxnjMwmtXEBPgVj41ywUgPH6ca1 GHlsya4DTqN9j6GoDEDzF7IUKTnFQDEwMBcOJEcVm58gUti2LWNaLgwAi8cPCTst/h0c XHTYJSqn/ww+e2rNrdXqQQ+Ibr+9A1g4uh+WqImdVjqF+qlZr8A8fP1hCu+cjaRCJEAK f9UZ7NsgkwH8d85JmM4FnbZyk7Rz+/Mbmd5foN2yW9cWhPWrWg0kgqpkIXKf2xqE0+ji hbaA== X-Gm-Message-State: AOJu0Yw//e2OYPHDyYyZiKFcHbCvWm2srx+g41Qdx4YK5E/P9Ymw6rso OjTElzzs/CN22CQPVI4vGp8VqUvmGEcaI0aaeXjSbZO7K5Na X-Received: by 2002:a05:6102:5091:b0:467:e34a:e8d0 with SMTP id bl17-20020a056102509100b00467e34ae8d0mr1169324vsb.2.1704907712294; Wed, 10 Jan 2024 09:28:32 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240110012640.1335694-1-kevinloughlin@google.com> <20240110133657.vbpzplchgaim3bya@box> In-Reply-To: <20240110133657.vbpzplchgaim3bya@box> From: Kevin Loughlin Date: Wed, 10 Jan 2024 09:28:21 -0800 Message-ID: Subject: Re: [RFC PATCH] x86/sev: x86/sev: enforce PC-relative addressing in clang To: "Kirill A. Shutemov" Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Rick Edgecombe , Kees Cook , "Masami Hiramatsu (Google)" , Ze Gao , Josh Poimboeuf , Pengfei Xu , Brijesh Singh , Michael Roth , Ashish Kalra , Tom Lendacky , Joerg Roedel , linux-kernel@vger.kernel.org, llvm@lists.linux.dev, linux-coco@lists.linux.dev, Adam Dunlap , Peter Gonda , Jacob Xu , Sidharth Telang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jan 10, 2024 at 5:37=E2=80=AFAM Kirill A. Shutemov wrote: > > Similar issues was fixed before with fixup_pointer() tricks. Have you > tried looking this direction. > > Relevant thread starting with: > > https://lore.kernel.org/all/20210920192341.maue7db4lcbdn46x@box.shutemov.= name Yes, I considered using `fixup_pointer()` as well, and I agree that it remains a valid option to solve this problem. I just now mentioned the primary downside to using `fixup_pointer()` in my response to Andi (https://lore.kernel.org/lkml/CAGdbjmJcQeLWroBkbRC-cFQ6OuMHONsGLzpUrrA5k3uc= 8Rzkmw@mail.gmail.com/). Namely, we would have to pass around `physaddr` from `__startup64()` to any functions wanting to use `fixup_pointer()`). However, we should be able to get around needing `physaddr` by using something like the `GET_RIP_RELATIVE_PTR()` macro that I proposed in the same reply (forthcoming in v2 of this RFC PATCH).