Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp9206704rwd; Wed, 21 Jun 2023 04:38:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ44bZm1zpaTWhrANwF6klF6JEW1M6Xvb8nQFrUe8WVGTBMTTeTF+i0eRczla9hDfgwjEsZf X-Received: by 2002:a05:6a00:1886:b0:668:8545:cbeb with SMTP id x6-20020a056a00188600b006688545cbebmr8505088pfh.15.1687347505065; Wed, 21 Jun 2023 04:38:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687347505; cv=none; d=google.com; s=arc-20160816; b=i+0UCKZjSSzh2/UYMHvC+qNjOJetGZrlWxX50i0D+6dvvaVlGEyOXOkA3lkBomSYdX Fu/31dVLhzdFQxoPzriqZfxWnB3OTwHQBPNetby2bfLIP8W6YSPU2HdrAA3dhb0INYmH zXffi561Tw4eSYaLMxqVTYIK2d5i/U86MC1nbGWHZivG7BSYKbEwWP/6Dc9SgjD6LT/H EOMiY9G5Nd2sZtyAnDwbeacqbFZvNx1DafsOJ+bf457OKQlNpgRMR+xpqAqoiv/BSRhi SQIBr4a/E0awZUgbNCHNyHlvHhfLuwGxXIS5YVDyW6/32NtGjrN0BrfJ85zqNv9T0GCo qeyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=dW10WzO/1D1df+c5COuWituJ1H1J79DUe0LfeJ0bU1c=; b=FqAdCVx2gINdAv9n8zp1nCBw4awqUNBCPlWjW7iwKDAImCTAXNa1aYvjcCn3lBnWFs tf/K/WoKbHo0NvCWMiKGYxhWCpgoo8sHC7FlhlJHeasOBwozM7tslMENUIS2btOWwpJI pwnk1MRNo7rb6RoYPcXB9UGSwVyVHVhPKYHX2vuVajMCkgDZeiAZWIeNt6U8AgNrYa8Q FpRrWWBb35WW+kb857UmFw2ZUxOJoNjlNENfilziPK2XNdNBIystztKOwucqnKySG4hP VusXSlBbLsvDJXJ3bvB0XOAt/NEsmJTy6UvnVWkH3m/3djeJaKojOmBHXVAQr9KFTuHq zQ5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=dpEnioDv; dkim=pass header.i=@alien8.de header.s=alien8 header.b=G8Ic9iU9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h18-20020aa79f52000000b006645f87dbf2si598546pfr.223.2023.06.21.04.38.10; Wed, 21 Jun 2023 04:38:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=dpEnioDv; dkim=pass header.i=@alien8.de header.s=alien8 header.b=G8Ic9iU9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231823AbjFULJ2 (ORCPT + 99 others); Wed, 21 Jun 2023 07:09:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40416 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229783AbjFULJZ (ORCPT ); Wed, 21 Jun 2023 07:09:25 -0400 Received: from mail.skyhub.de (mail.skyhub.de [IPv6:2a01:4f8:190:11c2::b:1457]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 683009B; Wed, 21 Jun 2023 04:09:24 -0700 (PDT) Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 9BFBC1EC0645; Wed, 21 Jun 2023 13:09:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1687345762; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:in-reply-to:in-reply-to: references:references; bh=dW10WzO/1D1df+c5COuWituJ1H1J79DUe0LfeJ0bU1c=; b=dpEnioDv7ovBtKQfZ7wxK6DT7xfn47sqTKDsed0UFc+/GswtEoTwj5hL7S9Pnd/yB6jAGF uZvtpoAf0/ngE01Z3FWKk+/odbnqn5t6dWO0OduiC/3L5SZQBwQcb0K3mze5hA6r+1XxLI BULR4iuYScPkWdAJi/at72k17yqgP3c= X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=pass (4096-bit key) header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id FHFnIBtczH5v; Wed, 21 Jun 2023 11:09:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1687345758; bh=dW10WzO/1D1df+c5COuWituJ1H1J79DUe0LfeJ0bU1c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=G8Ic9iU9eL/U44nJG0zZRt/DzhRRg+4nw2s7UAUE9IIRyPJKGgN8unciTBIZ7riDN Kg6VYIsyEtj+xC3t1oPjPgE24bgeVdUciREBFgQgY0WLGkIigXnhOTqV7UAvfHAIF5 ImPivRpBsWt4UPqGqmFtFB49JPzbtCjd4mVOHIVsoURVf1o6oH+ksZvSCyuGu3svws Iw3aWZXvY5whdHmxKeVe0iQl4tyU7KIZKxFMHTNwfh7/kAQMgS6OpbvXNVdGeFfSIj BV8l2r4RzgSg571NfSCx5Qeo4AX0Unn2PbNRNTQw4J35iGe1345hffB8DMy2JphCDj MTDbFdvIPENbXeKAVS66aA2a5F+f1ertw6ONZyEf5mCtnj4GkM6ujA7gNS2eGUpJRy kW5390pUCZx/RxlbUSlxgxmtydUpyKRJ3f9m8O69UqtmXkjAh5QqPR/ZQdCbXMeSsb AiR7bJEQ2LFbpfjaEAgTDs539ArarVFM0KMybQdey6YO1eY3ZmK9YlnECL+aHBHuml Lt8f3mnhCNOf/9e+mQ8ak01HIOiyKoNWdD88hR3bMUgg6D7YYBzHNAkbpqtk7/2K9n vRhIqjtIKVEfQIcOAUvimNUemIbt5IQLhuFsKeShB/obgfMa1n7mdbnICphbztqa/B YWbGx3kVCF7ZaCnK1ounlSEo= Received: from zn.tnic (p200300ea971Dc592329c23FffEA6a903.dip0.t-ipconnect.de [IPv6:2003:ea:971d:c592:329c:23ff:fea6:a903]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 4DDA540E019B; Wed, 21 Jun 2023 11:08:59 +0000 (UTC) Date: Wed, 21 Jun 2023 13:08:52 +0200 From: Borislav Petkov To: Ard Biesheuvel Cc: linux-efi@vger.kernel.org, linux-kernel@vger.kernel.org, Evgeniy Baskov , Andy Lutomirski , Dave Hansen , Ingo Molnar , Peter Zijlstra , Thomas Gleixner , Alexey Khoroshilov , Peter Jones , Gerd Hoffmann , Dave Young , Mario Limonciello , Kees Cook , Tom Lendacky , "Kirill A . Shutemov" , Linus Torvalds , Joerg Roedel Subject: Re: [PATCH v5 05/20] x86/decompressor: Use proper sequence to take the address of the GOT Message-ID: <20230621110852.GAZJLaRAuGBCc5R4yb@fat_crate.local> References: <20230607072342.4054036-1-ardb@kernel.org> <20230607072342.4054036-6-ardb@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20230607072342.4054036-6-ardb@kernel.org> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 07, 2023 at 09:23:27AM +0200, Ard Biesheuvel wrote: > The 32-bit decompressor does not actually use a global offset table > (GOT), but as is common for 32-bit position independent code, it uses > the magic symbol _GLOBAL_OFFSET_TABLE_ as an anchor from which to derive > the actual runtime addresses of other symbols, using special @GOTOFF > symbol references that are resolved at link time, and populated with the > distance between the address of the magic _GLOBAL_OFFSET_TABLE_ anchor > and the address of the symbol in question. > > This means _GLOBAL_OFFSET_TABLE_ is the only symbol whose actual runtime > address needs to be determined explicitly, which is one of the first > things that happens in startup_32. However, it does so by taking the > absolute address via the immediate field of an ADD instruction (plus a > small offset), which seems to defeat the point. > > Fortunately, the assembler knows that _GLOBAL_OFFSET_TABLE_ is magic, > and emits a special relative relocation instead, and so the resulting Which special relocation do you mean? This guy: Relocation section '.rel.head.text' at offset 0x3a0 contains 12 entries: Offset Info Type Sym.Value Sym. Name 00000010 00000d0a R_386_GOTPC 00000000 _GLOBAL_OFFSET_TABLE_ ? In any case, this thing came from a2c4fc4d4e2c ("x86/boot: Remove run-time relocations from .head.text code") Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette