From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CDA46CCFA07 for ; Thu, 26 Sep 2024 06:42:20 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.804930.1215908 (Exim 4.92) (envelope-from ) id 1stiCY-0002ql-Lr; Thu, 26 Sep 2024 06:42:10 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 804930.1215908; Thu, 26 Sep 2024 06:42:10 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1stiCY-0002qe-HT; Thu, 26 Sep 2024 06:42:10 +0000 Received: by outflank-mailman (input) for mailman id 804930; Thu, 26 Sep 2024 06:42:09 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1stiCX-0002qW-Rk for xen-devel@lists.xenproject.org; Thu, 26 Sep 2024 06:42:09 +0000 Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [2a00:1450:4864:20::631]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 72c1b11b-7bd2-11ef-99a2-01e77a169b0f; Thu, 26 Sep 2024 08:42:07 +0200 (CEST) Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-a86e9db75b9so88919366b.1 for ; Wed, 25 Sep 2024 23:42:07 -0700 (PDT) Received: from [10.156.60.236] (ip-037-024-206-209.um08.pools.vodafone-ip.de. [37.24.206.209]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a9392f51e73sm307676766b.72.2024.09.25.23.42.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 25 Sep 2024 23:42:06 -0700 (PDT) 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: 72c1b11b-7bd2-11ef-99a2-01e77a169b0f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1727332926; x=1727937726; darn=lists.xenproject.org; h=content-transfer-encoding:in-reply-to:autocrypt:from:cc :content-language:references:to:subject:user-agent:mime-version:date :message-id:from:to:cc:subject:date:message-id:reply-to; bh=HjnpiT0q+VoSKkoAPhc/0tJfAYPPXzdpToP7lI/BkKA=; b=Br0ob+VPTUKL1LR4gSF+WvTGU4FZ8C7cpWDNmpxIAlJqlsi9B5H/VWlk/5ZRptSZCF F++t3rcoDM39vKsdtn6RDHO3tgJR0Fpg58kG8H8DxXfUepeMogkEXMMJ1R0yGZ6L39BX hbtvfZ+OdiNyT9iB+HWtBCKPF0kFH2GwMDUS15OPjHXD9EDws+AI5pmYaxqIyUuTV6T+ ZtLJX9Vk7sroffiMAhlSErscZ+MxWtDzs+/L/wX4TJBiPIPkj0vZMHPwMzl04NbAs6A8 50+ogmAa007Fov8ORtKwniSosYbx2aV1Vi0kzYfbFOq4g0RaGDP8EIoaLMwW/cUbO2LK UgWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727332926; x=1727937726; h=content-transfer-encoding:in-reply-to:autocrypt:from:cc :content-language:references:to:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=HjnpiT0q+VoSKkoAPhc/0tJfAYPPXzdpToP7lI/BkKA=; b=J/wZZpAPRT8gUQqdjRSOsytcu9fnbK01IhileA5WH4kwrPsYmvGBWVDHXhXTp5Bsge 97j/3nquucultDnkJi4LBNZLQ6+GNmr1lSjtzLIsbdjn5ViCR1U3veERZcLeFPijDlTp 1D0IjQd+LOlDxDn4a33Y8OENCt1WF+vyYhfxygqUIdN/xd6HlySzhDbZgt+MAm61+W4q Uh0eApmvVuQU+i1iUzWD9yC6Dk1ymNX4X06OOwvBZvUgfaLEzzfGN2q0VN1dI3S1P3yD dEkEEFnNB4jSbASjiPIUWTZSv4R//WplG3nRTGLtaDdMiGEU8ZibF9flVAhVzdCihTx0 CocA== X-Gm-Message-State: AOJu0Yxw3wH+dwHLnfP7uFksPADXBxUceATLldnZYMyX2dkC5dS4NM6z lOSjOfEJ3HtXiowvhnztvys5zy1RCQt5UKqjg621oUL99ohmRB/Sp02R1CAbIw== X-Google-Smtp-Source: AGHT+IEazeijGcaxokxDuJueeECKXeMjE9dvDwRj4GjYCQAEt/iAfUbagVZ92mVKYg4t2Ec6unrjOQ== X-Received: by 2002:a17:907:7f8d:b0:a8d:11c2:2b4 with SMTP id a640c23a62f3a-a93a06768aamr492299566b.56.1727332926541; Wed, 25 Sep 2024 23:42:06 -0700 (PDT) Message-ID: Date: Thu, 26 Sep 2024 08:42:05 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH 14/28] x86/rethook: Use RIP-relative reference for return address To: Andrew Cooper References: <20240925150059.3955569-30-ardb+git@google.com> <20240925150059.3955569-44-ardb+git@google.com> Content-Language: en-US Cc: xen-devel@lists.xenproject.org From: Jan Beulich Autocrypt: addr=jbeulich@suse.com; keydata= xsDiBFk3nEQRBADAEaSw6zC/EJkiwGPXbWtPxl2xCdSoeepS07jW8UgcHNurfHvUzogEq5xk hu507c3BarVjyWCJOylMNR98Yd8VqD9UfmX0Hb8/BrA+Hl6/DB/eqGptrf4BSRwcZQM32aZK 7Pj2XbGWIUrZrd70x1eAP9QE3P79Y2oLrsCgbZJfEwCgvz9JjGmQqQkRiTVzlZVCJYcyGGsD /0tbFCzD2h20ahe8rC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aqTaRbg3M/+MTbMpicpZuqF4rnB0AQD12/3BNWDR6bmh+EkYSMcEIpQmBM51qM EKYTQGybRCjpnKHGOxG0rfFY1085mBDZCH5Kx0cl0HVJuQKC+dV2ZY5AqjcKwAxpE75MLFkr wkkEGBECAAkFAlk3nEQCGwwACgkQoDSui/t3IH7nnwCfcJWUDUFKdCsBH/E5d+0ZnMQi+G0A nAuWpQkjM1ASeQwSHEeAWPgskBQL In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 25.09.2024 18:51, Andrew Cooper wrote: > On 25/09/2024 5:45 pm, Ard Biesheuvel wrote: >> On Wed, 25 Sept 2024 at 18:39, Linus Torvalds >> wrote: >>> And we do have special calling conventions that aren't the regular >>> ones, so %rdi might actually be used elsewhere. For example, >>> __get_user_X and __put_user_X all have magical calling conventions: >>> they don't actually use %rdi, but part of the calling convention is >>> that the unused registers aren't modified. >>> >>> Of course, I'm not actually sure you can probe those and trigger this >>> issue, but it all makes me think it's broken. >>> >>> And it's entirely possible that I'm wrong for some reason, but this >>> just _looks_ very very wrong to me. >>> >>> I think you can do this with a "pushq mem" instead, and put the >>> relocation into the memory location. >>> >> I'll change this into >> >> pushq arch_rethook_trampoline@GOTPCREL(%rip) >> >> which I had originally. I was trying to avoid the load from memory, >> but that obviously only works if the register is not live. > > But does that work?  Won't that will push the 8 bytes from the start of > arch_rethook_trampoline, when what's wanted is simply the address of > arch_rethook_trampoline itself. What you describe is pushq arch_rethook_trampoline(%rip) The @GOTPCREL makes the PUSH access an item from the GOT, and that item is arch_rethook_trampoline's address. Jan