From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yw1-x112e.google.com (mail-yw1-x112e.google.com [IPv6:2607:f8b0:4864:20::112e]) by sourceware.org (Postfix) with ESMTPS id D70C63850082 for ; Fri, 9 Dec 2022 02:04:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D70C63850082 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-yw1-x112e.google.com with SMTP id 00721157ae682-3f15a6f72d0so35768837b3.1 for ; Thu, 08 Dec 2022 18:04:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=w6x9B4h0FI22nW0cO82pgzgG781Egm5CAETJKEev4cM=; b=MiaS9Zl//Br8FyAGPHv1iWKv3I6hhi05VypYHUQjZ7vGQn0PMgYmRxsfF/hvxvJNQN nN7ouBofRlvSZJ9id9jWOtNkmKpQ/FpPzoB9ZeTg5tgvoHAGP5XHAHKQo8m8+noS6rKE w2auOk/hsV3G7Im3PJCQpQft19ZQlp/Beppje/TM+CHPl2QGIOvJns9hdPVii9Mt5FcJ jNjt6VDxCGCe2Xpw/Ei2/XZkDM8mGwN2APFyb2IaWzPJ9XmNyeqt7tAB56/nqJLZh7tA 4CAXCsiXs3GeV+rEWIQnvqyrZ3IKToZOCmfR0jEvlYTOSHSSuzj5i33tXlNEQiph08j9 ebfw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=w6x9B4h0FI22nW0cO82pgzgG781Egm5CAETJKEev4cM=; b=gr9gvJHsf/hVf/q8lK0BHWl8VC+kIjDN3ZRqFfHYR48+N+vvA7JmJ/ylzuD8+NMP3Z sZ2Ys+vS68ewJiZXIYrWU+WQ/GO/6P4+2zDUEtec7lwWH9lDMqBdFEogYtUc0GpPRPe7 vdcWgoNqmjaiJF7oR+5Y5CWR2XU5dVjYH8BHtkeLkYUQBnaqdrJ5HOA8cM3quE4PNS2y MSuJzDAXjoP/V3mJt8DQlwrL5k6gKdERDOK7TqZ96H0cw3xI/6PgtNhgzKZhEF71xAe+ I3SEgIraAmFgQM2OeDIAEM4uAlOSjkWD14ebDbpGReG03UugitCaR5iXOqdAdLVQyecY MtIw== X-Gm-Message-State: ANoB5plS98+F2ubSGrerjIj+4vhzfC4THTVhWY9KPtHeONY0ZQbUOWZl KMwAFyQHpgBjP+Qxr0dwl9iBTXW7to/ySrK0gjE= X-Google-Smtp-Source: AA0mqf4WJ7/pCMSvmXZOJNtV8kRqEpBWtJgP1mto2ZRwzcyp5j7EmaIYi3reXViF0iBrigxTECOvHM6LOgCD6kXL7is= X-Received: by 2002:a81:998a:0:b0:3dd:49a2:837b with SMTP id q132-20020a81998a000000b003dd49a2837bmr29027975ywg.241.1670551453736; Thu, 08 Dec 2022 18:04:13 -0800 (PST) MIME-Version: 1.0 References: <20221111012631.76776-1-hongtao.liu@intel.com> In-Reply-To: From: Hongtao Liu Date: Fri, 9 Dec 2022 10:04:02 +0800 Message-ID: Subject: Re: [PATCH 0/2] Support HWASAN with Intel LAM To: =?UTF-8?Q?Martin_Li=C5=A1ka?= Cc: liuhongt , gcc-patches@gcc.gnu.org, hjl.tools@gmail.com, ubizjak@gmail.com, Florian Weimer Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,KAM_SHORT,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Wed, Nov 30, 2022 at 10:07 PM Martin Li=C5=A1ka wrote: > > On 11/29/22 03:37, Hongtao Liu wrote: > > On Mon, Nov 28, 2022 at 10:40 PM Martin Li=C5=A1ka wro= te: > >> > >> On 11/11/22 02:26, liuhongt via Gcc-patches wrote: > >>> 2 years ago, ARM folks support HWASAN[1] in GCC[2], and introduced= several > >>> target hooks(Many thanks to their work) so other backends can do simi= lar > >>> things if they have similar feature. > >>> Intel LAM(linear Address Masking)[3 Charpter 14] supports similar = feature with > >>> the upper bits of pointers can be used as metadata, LAM support two m= odes: > >>> LAM_U48:bits 48-62 can be used as metadata > >>> LAM_U57:bits 57-62 can be used as metedata. > >>> > >>> These 2 patches mainly support those target hooks, but HWASAN is not = really > >>> enabled until the final decision for the LAM kernel interface which m= ay take > >>> quite a long time. We have verified our patches with a "fake" interfa= ce locally[4], and > >>> decided to push the backend patches to the GCC13 to make other HWASAN= developper's work > >>> easy. I've committed 2 patches. > >> > >> Hello. > >> > >> A few random comments I noticed: > >> > >> 1) please document the new target -mlam in extend.texi > > I will. > > Thanks. > > >> 2) the description speaks about bits [48-62] or [57-62], can explain w= hy the patch contains: > >> > > Kernel will use bit 63 for special purposes, and here we want to > > extract the tag by shifting right the pointer 57 bits, and need to > > manually mask off bit63. > > And thanks for the explanation. > > Martin > > >> + /* Mask off bit63 when LAM_U57. */ > >> + if (ix86_lam_type =3D=3D lam_u57) > >> ? > >> > >> 3) Shouldn't the -lman option emit GNU_PROPERTY_X86_FEATURE_1_LAM_U57 = or GNU_PROPERTY_X86_FEATURE_1_LAM_U48 > >> .gnu.property note? > >> > >> 4) Can you please explain Florian's comment here: > >> https://gitlab.com/x86-psABIs/x86-64-ABI/-/merge_requests/13#note_1181= 396487 > >> > >> Thanks, > >> Martin > >> > >>> > >>> [1] https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesig= n.html > >>> [2] https://gcc.gnu.org/pipermail/gcc-patches/2020-November/557857.ht= ml > >>> [3] https://www.intel.com/content/dam/develop/external/us/en/document= s/architecture-instruction-set-extensions-programming-reference.pdf > >>> [4] https://gitlab.com/x86-gcc/gcc/-/tree/users/intel/lam/master > >>> > >>> > >>> Bootstrapped and regtested on x86_64-pc-linux-gnu{-m32,}. > >>> Ok for trunk? > >>> > >>> liuhongt (2): > >>> Implement hwasan target_hook. > >>> Enable hwasan for x86-64. > >>> > >>> gcc/config/i386/i386-expand.cc | 12 ++++ > >>> gcc/config/i386/i386-options.cc | 3 + > >>> gcc/config/i386/i386-opts.h | 6 ++ > >>> gcc/config/i386/i386-protos.h | 2 + > >>> gcc/config/i386/i386.cc | 123 +++++++++++++++++++++++++++++= +++ > >>> gcc/config/i386/i386.opt | 16 +++++ > >>> libsanitizer/configure.tgt | 1 + > >>> 7 files changed, 163 insertions(+) > >>> > >> > > > > > --=20 BR, Hongtao