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 X-Spam-Level: X-Spam-Status: No, score=-7.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 39366C433DB for ; Sun, 28 Feb 2021 09:20:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9700164D99 for ; Sun, 28 Feb 2021 09:20:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9700164D99 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 0CAC98D001F; Sun, 28 Feb 2021 04:20:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 07DCA8D0019; Sun, 28 Feb 2021 04:20:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E5FC08D001F; Sun, 28 Feb 2021 04:20:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0131.hostedemail.com [216.40.44.131]) by kanga.kvack.org (Postfix) with ESMTP id D03828D0019 for ; Sun, 28 Feb 2021 04:20:52 -0500 (EST) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7BA4F8249980 for ; Sun, 28 Feb 2021 09:20:52 +0000 (UTC) X-FDA: 77867131944.03.F51D0C9 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf01.hostedemail.com (Postfix) with ESMTP id 51D9F2000383 for ; Sun, 28 Feb 2021 09:20:51 +0000 (UTC) Received: by mail-pf1-f169.google.com with SMTP id l7so4987964pfd.3 for ; Sun, 28 Feb 2021 01:20:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=5U8n3GiSpCk4oUUJob/tRw55WrYcqNjPdfcSiRR+jLk=; b=uPvwsFoFKDK8g2T84gIaPpi3E/fOAEueiY7gQ7Xe1D5qwdhiM4N7raHR3o1IddqgIm lZhHJpRfdquaZY0XWrnR6fOeZgBtrg73OWH4jioMwijAfXp2UIA5Htwzj5aAEpfg0Dql ASKAoc8Ms9py/QYHm2J3slvciLU+F+3GmtDMMD/+mTfjnfk0nrn8/4es8O0r01pScZWc USSnWDw+o0vXcOrVPtFnIS73DRhxvXRYWuCazNWgM4jIHxGR9XXriQRGluyuZifFIhZ8 vhXv58jURI2cdKcmEN0NeiB/TurIBq70NHeoAQgLszZvVW1VjjnbRKMb8xnFfeJpz+oe /ETw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=5U8n3GiSpCk4oUUJob/tRw55WrYcqNjPdfcSiRR+jLk=; b=G1ImX3P+N9y23zFEl4T4FnEhL9qtT4JOR5oMOg2GUkCjaXeyRLfaecZqK+g/AiK6nh N3dkan+My6pm13c/SO1UxZBb4FgBriOZFHF5RdllNIs+j1g8thUbXtsTqDPcDGSvhnyf ipZUpLLIWQo9eDpGL3SCLRjKrRiRPzZrFhTEeekyeTb6mjcK0XhuAMbOkq16JS3C6VWz exhJf2Evecik/+qe1+Uuhn13m42hOzW3H5soZqN8mBSnPgZYHYegmZP797WYN9U8n6f1 VI1BvtWSlaMsDr49RTEqpm7x/VrZRbsnBwKxNSi175i+cn7EDbQZIjcPwmeIcOHR7K0q Y3dg== X-Gm-Message-State: AOAM533W51gURYPH5UEQ7u/jadVF4i31CkZMUiVNVjAAnw4A3GIryVuI FT7HK3NaKPNVyVAfqkEgtlQ= X-Google-Smtp-Source: ABdhPJzghzaw8I4A27oiC5/wqt/NmTbTNPOLJ3zDtLBVlDQdI46KTq9yEk17hAhTWQZqfTZCdLWCXA== X-Received: by 2002:a62:1ad4:0:b029:1ed:b92c:6801 with SMTP id a203-20020a621ad40000b02901edb92c6801mr10305462pfa.7.1614504050812; Sun, 28 Feb 2021 01:20:50 -0800 (PST) Received: from [192.168.88.245] (c-24-6-216-183.hsd1.ca.comcast.net. [24.6.216.183]) by smtp.gmail.com with ESMTPSA id y23sm13984165pfo.50.2021.02.28.01.20.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Feb 2021 01:20:50 -0800 (PST) From: Nadav Amit Message-Id: <194EFB5E-46DE-4FEB-BCD5-3281B4C2A097@gmail.com> Content-Type: multipart/signed; boundary="Apple-Mail=_AD31CEAA-7F3A-40B6-BCEF-0FCEE3FAC892"; protocol="application/pgp-signature"; micalg=pgp-sha256 Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Subject: Re: [RFC 1/6] vdso/extable: fix calculation of base Date: Sun, 28 Feb 2021 01:20:48 -0800 In-Reply-To: Cc: Linux-MM , LKML , Hugh Dickins , Andy Lutomirski , Thomas Gleixner , Peter Zijlstra , Ingo Molnar , Borislav Petkov , Andrew Morton , x86@kernel.org To: Sean Christopherson References: <20210225072910.2811795-1-namit@vmware.com> <20210225072910.2811795-2-namit@vmware.com> <2CDFE432-90D3-43EE-BA9F-2CFEB8BB343C@gmail.com> X-Mailer: Apple Mail (2.3654.60.0.2.21) X-Stat-Signature: ttrc1gwgbktjsqpqypdhcs4qesr88sgj X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 51D9F2000383 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf01; identity=mailfrom; envelope-from=""; helo=mail-pf1-f169.google.com; client-ip=209.85.210.169 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1614504051-697453 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --Apple-Mail=_AD31CEAA-7F3A-40B6-BCEF-0FCEE3FAC892 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > On Feb 26, 2021, at 9:47 AM, Sean Christopherson = wrote: >=20 > On Fri, Feb 26, 2021, Nadav Amit wrote: >>=20 >>> On Feb 25, 2021, at 1:16 PM, Sean Christopherson = wrote: >>> It's been literally years since I wrote this code, but I distinctly = remember the >>> addresses being relative to the base. I also remember testing = multiple entries, >>> but again, that was a long time ago. >>>=20 >>> Assuming things have changed, or I was flat out wrong, the comment = above the >>> macro magic should also be updated. >>>=20 >>> /* >>> * Inject exception fixup for vDSO code. Unlike normal exception = fixup, >>> * vDSO uses a dedicated handler the addresses are relative to the = overall >>> * exception table, not each individual entry. >>> */ >>=20 >> I will update the comment. I am not very familiar with pushsection = stuff, >> but the offsets were wrong. >>=20 >> Since you say you checked it, I wonder whether it can somehow be = caused >> by having exception table entries defined from multiple object files. >=20 > Oooh, I think that would do it. Have you checked what happens if = there are > multiple object files and multiple fixups within an object file? Good thing that you insisted... I certainly do not know well enough the assembly section directives, but indeed it seems (after some experiments) that referring to the section provides different values from different objects. So both the current (yours) and this patch (mine) are broken. I think the easiest thing is to fall back to the kernel exception table scheme. I checked the following with both entries in the same and different objects and it seems to work correctly: -- >8 -- diff --git a/arch/x86/entry/vdso/extable.c = b/arch/x86/entry/vdso/extable.c index afcf5b65beef..3f395b782553 100644 --- a/arch/x86/entry/vdso/extable.c +++ b/arch/x86/entry/vdso/extable.c @@ -32,9 +32,11 @@ bool fixup_vdso_exception(struct pt_regs *regs, int = trapnr, nr_entries =3D image->extable_len / (sizeof(*extable)); extable =3D image->extable; - for (i =3D 0; i < nr_entries; i++) { - if (regs->ip =3D=3D base + extable[i].insn) { - regs->ip =3D base + extable[i].fixup; + for (i =3D 0; i < nr_entries; i++, base +=3D sizeof(*extable)) { + if (regs->ip =3D=3D base + extable[i].insn + + offsetof(struct vdso_exception_table_entry, = insn)) { + regs->ip =3D base + extable[i].fixup + + offsetof(struct = vdso_exception_table_entry, fixup); regs->di =3D trapnr; regs->si =3D error_code; regs->dx =3D fault_addr; diff --git a/arch/x86/entry/vdso/extable.h = b/arch/x86/entry/vdso/extable.h index b56f6b012941..4ffe3d533148 100644 --- a/arch/x86/entry/vdso/extable.h +++ b/arch/x86/entry/vdso/extable.h @@ -13,8 +13,8 @@ .macro ASM_VDSO_EXTABLE_HANDLE from:req to:req .pushsection __ex_table, "a" - .long (\from) - __ex_table - .long (\to) - __ex_table + .long (\from) - . + .long (\to) - . .popsection .endm #else -- 2.25.1 --Apple-Mail=_AD31CEAA-7F3A-40B6-BCEF-0FCEE3FAC892 Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEESJL3osl5Ymx/w9I1HaAqSabaD1oFAmA7YHAACgkQHaAqSaba D1q7mw//RVy8FkgUNYcgRRtELtMq8RlPe6Nv7vJPg/O3K+H1H9AHPMiIhUXF+I3I 7UX77t9TmQ4s6ezq4tsjcb9IAcv3Q30sPfvIjU71Uig7RWGUbyGOxQ7T+itVyv94 1zadspaFnfm70kPh6/uuIJOyTJd8pxWO3U1naiJwzhwSqcJUin1EvQwoG2X9eVXk +vHDra6ORUmMKxj0CPYpGhOjwn3oQjLWUwRCsL6VOqYKmnFHfDbdop+CWY7vFilg 4rdSDgAwtCze9luOUqcBKxapqvAaYGnfQaymTIIs/vc3YyVpdikzbh50/pk7NOVo +i2P+fPKAPgTZsF+dNFQDBqRvC6F68q2CmPK2XzWRugkDuTNwtKVwPsKijU/+bM3 HDIQ1dGcrMcds9Upl/fLygOCWa5n3nKey9B0yNhkYaVLkzjOl0P7l9bzdL4Bf+x1 S93IEsNbD4efJFg/jyV2+DyieyhyQoNNIvcvOdhBHZ4xE5Ky9KSSGEIm2F/YXA1z RFe1atpNk90rOGqJR1B2BekcXSUHY2gKjLYzyJZLG4QYTpgwSQEd1MIdRfTd0QPN CYNGGxxfB/rIg0nBzezlhmiFYpo4IUDku5DY8Y50thQFmnUkfOPa+pVugnlNoUh4 1h2tLoEOGpcu7dZgpvdVJb6q1zn/fOA9CF7EyyHac6GdInA7Fgw= =EXpb -----END PGP SIGNATURE----- --Apple-Mail=_AD31CEAA-7F3A-40B6-BCEF-0FCEE3FAC892--