From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id 220A3384B009 for ; Thu, 12 Nov 2020 04:40:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 220A3384B009 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=sifive.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=jimw@sifive.com Received: by mail-ed1-x52b.google.com with SMTP id o20so4705742eds.3 for ; Wed, 11 Nov 2020 20:40:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=fAtNuc+4bD4NTjWWNXhRp88FPsb15SLF8bSpaoOCBz8=; b=l82gcm7mIhLe70IKCaoSO7JZVnbYGsay1tsLuTqOwGK5yW3eilzsSmpEoQ4i7dYI7K v17R3n13JK9GUX42sIlu7pBDx16voWCfs+aq8/UGeO6CB52KU5CRFvNZinnyeLwHav34 yDtyaUafQsLB3rHBJL8SqdQn7iAfvhEpyp2SRWWRGKtJBa9Ytw0yyfkBPnGJmzes71H6 wl7fFEIoYYbKTZCO1m3VmhxQsrhBkxPr04Y+fMIWQ37baQ58pCqeOjPn5k5GYqvgYRwJ LCUcQtkG+utbcV4jW15XhxCJl9+mZsWR/v3NfwSFeWwvT8df58SZtIIZR4YEd9ZbIbnj 4KnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=fAtNuc+4bD4NTjWWNXhRp88FPsb15SLF8bSpaoOCBz8=; b=Jh6GdMB5Be3PhPebsE3r7w5DOSNPwTeQLpZ68SdQdGN2ZhcwXj1Wqnnn9ErI5WxRFS oGG4RzwuStFmchjcJeQKcAi32n8IjgdZ7GZFeLEiIs9GG9L/IIvH/HOk1wBHAoVoTNNQ lbG1cYbTDjDb6ekZ7xfztbxQLGtgs2a3omzE5vjpnjwHsNUMgZRXqhdX0tbdyqNHYuS4 Rqr755XCTBfW32ZsuY53wV1bGbh7Ww/3Dl+iIWhHj0ti7IKnLCiIVp919PipZIKXTqF9 fsRbZ2CfhT8sIUGbd06tWMapKA9KyqCX9ZDtBikL3mCwPRUoyLFnxF0BKAh2OTdI82o7 neKw== X-Gm-Message-State: AOAM531YtoQVQUmvD8lvq/qB/3kiGpYy/Otv96FzP79Qc1WG2dFd7tqm rxp7I6+Xp0y9EwLExQtZDuwSkDckHIoA/4NK/WRRpQ== X-Google-Smtp-Source: ABdhPJxI536kAbg9NUyLrrX29DmJtmxOZo/ZxgOEihf2y1A4YO2YEf2aZyc2nqzzo1hMEK6NCZnE/4T8JTIJO2q211c= X-Received: by 2002:a50:af21:: with SMTP id g30mr3119687edd.46.1605156001181; Wed, 11 Nov 2020 20:40:01 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Jim Wilson Date: Wed, 11 Nov 2020 20:39:50 -0800 Message-ID: Subject: Re: Spectre mitigations in gcc compiler To: Amir Naseredini Cc: "gcc-help@gcc.gnu.org" X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, HTML_MESSAGE, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-help@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-help mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 12 Nov 2020 04:40:03 -0000 On Tue, Nov 10, 2020 at 9:00 AM Amir Naseredini via Gcc-help < gcc-help@gcc.gnu.org> wrote: > I was looking over the internet and am a bit confused about the > mitigations that are provided by the gcc compiler for different variants of > Spectre attack. So, I was wondering if there are any mitigations > implemented for Specter v1 (Spectre-PHT), v2 (Spectre-BTB), v4 > (Spectre-STL) and v5 (Spectre-RSB) at the compiler level for gcc? > Looking forward to hearing from you. > We have a builtin function __builtin_speculation_safe_value that you can use to protect from some of these attacks. Support varies depending on the target, but most of the popular targets will emit a special instruction sequence when this is used. The docs are in this page https://gcc.gnu.org/onlinedocs/gcc-10.2.0/gcc/Other-Builtins.html#Other-Builtins about 1/5 of the way down. Jim