From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by sourceware.org (Postfix) with ESMTPS id 403A23858CDB for ; Tue, 29 Nov 2022 02:37:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 403A23858CDB 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-yb1-xb29.google.com with SMTP id 7so15759253ybp.13 for ; Mon, 28 Nov 2022 18:37:56 -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=89ykGvRbHzUueknElFiTuu2ENawCAAmnBniBPXh8M8I=; b=IwzeF7fmQXwQ6vl2+gRSVVcMP14R/SvttT5dFr0W8+G6q9xYm9zY7+o/4GqzxvhLtz nvgklIwd9mdceeYiBZ4eejD01ip0e3ZAwO+/t4fXxr0uzOT625TCRsMrZ4skbp3AljYa GyLrt8NWABki9f0hM3zyOyXNJ65Qv1//ogw5iIA1j9O1VH3bcRKjGLRyt6PKTnU5UfvK futLq9ZBuoDtOGlvztX4cRoaquzh1Fv5bGw08QW12xU4hYA6HRUpqqIRZpKdpo4kwPZf Yk+Y/rueBrRqrl0mP8a8+0zelrrt5u/RnUW6gTNuHdEYUIAkPnAZmMlP6YTL0mgHFyC7 aolA== 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=89ykGvRbHzUueknElFiTuu2ENawCAAmnBniBPXh8M8I=; b=Tcr5FkmWfxMA3wgnEnVFW7X3FIUvs6AvW/JjPHFpRYZ8zoKc9T7gUYxPSWIckq9r1c ayAk9Ir7m9i4dGwLJawZY0xJ79IqngKBaBxxEb7WctW3I26+s9LFFSSCTPpI06D4B2xV CJ1PnDhsgH8S46eKG84TXMS3v3GQWTeiD840vvCBF82F0BfyN31lYtXSFFLf6YxB7ynC LQY/VEdkBxjWNrgpee4E3tKIFFn0Pz4Jii/po/UM/ERoKN17pdqxwIzPaeQppXoPDzJl hmDWfPAkkzb1Z/tdJ96xlNcN6RRLzIuWczyRNxeSniySo+I5w0Ela6JeKnvNryb/dMsh zV/w== X-Gm-Message-State: ANoB5pkumL4T4SBpT6c7GSwH56qveTT+z3ad69NJ3/NOEw5qa0HZFQ+s odE2h08WegAR7BUdMOQaKYdZH3rZMk5esUWyLd0= X-Google-Smtp-Source: AA0mqf4TR7XohdaoSp6+wzvjCr+DdklfWPphvBjfHse8lYZlZYf1H0KDdGv4fFnvIXO2KypF3zrbwgDe9HNZEsYU4+M= X-Received: by 2002:a25:9c44:0:b0:6f8:1e09:f26e with SMTP id x4-20020a259c44000000b006f81e09f26emr3962096ybo.624.1669689475617; Mon, 28 Nov 2022 18:37:55 -0800 (PST) MIME-Version: 1.0 References: <20221111012631.76776-1-hongtao.liu@intel.com> In-Reply-To: From: Hongtao Liu Date: Tue, 29 Nov 2022 10:37:44 +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 Mon, Nov 28, 2022 at 10:40 PM Martin Li=C5=A1ka wrote: > > On 11/11/22 02:26, liuhongt via Gcc-patches wrote: > > 2 years ago, ARM folks support HWASAN[1] in GCC[2], and introduced s= everal > > target hooks(Many thanks to their work) so other backends can do simila= r > > things if they have similar feature. > > Intel LAM(linear Address Masking)[3 Charpter 14] supports similar fe= ature with > > the upper bits of pointers can be used as metadata, LAM support two mod= es: > > 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 re= ally > > enabled until the final decision for the LAM kernel interface which may= take > > quite a long time. We have verified our patches with a "fake" interface= locally[4], and > > decided to push the backend patches to the GCC13 to make other HWASAN d= evelopper's work > > easy. > > Hello. > > A few random comments I noticed: > > 1) please document the new target -mlam in extend.texi I will. > 2) the description speaks about bits [48-62] or [57-62], can explain why = 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. > + /* 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_1181396= 487 > > Thanks, > Martin > > > > > [1] https://clang.llvm.org/docs/HardwareAssistedAddressSanitizerDesign.= html > > [2] https://gcc.gnu.org/pipermail/gcc-patches/2020-November/557857.html > > [3] https://www.intel.com/content/dam/develop/external/us/en/documents/= 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