Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp998724imi; Fri, 22 Jul 2022 14:37:48 -0700 (PDT) X-Google-Smtp-Source: AGRyM1s4CJ1etdBsW91hdmZpKn1/Jq80XdcxKhgYlgORIchDHj9Ck+F5ZjpzcGhv2gV4M2XMcX57 X-Received: by 2002:a17:902:db02:b0:16c:5568:d740 with SMTP id m2-20020a170902db0200b0016c5568d740mr1486004plx.100.1658525868142; Fri, 22 Jul 2022 14:37:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658525868; cv=none; d=google.com; s=arc-20160816; b=TfOeAatKiF3vvyEVwugSRWCV2irzL/55D/1d1aHhgQfiNAXWcAMOypw1StQm0Sqk8B CNSVgHdoE8Ggcp2Il5aKoLYkBmn8d2VIFjLkorYi+MhTaksO4uQACEaE67TsewLh2YQB eg9RktG+S+90JcTfjfwhaQcp/MIerWytie0MjoV0VhjIRcN+puPvzGrpr/JqV8QiUC+F j5PRhZOyOznp/j1D5hEVyxD50MxSXmhJ9oKtBev4ZECfKuGQ/kL/RWHegJOcmqeei5tu ux6LFgKfuX7UnDkEo8b+U40qDrAGGH8Ac6S7tzD+fABmVYR0YJINcqlF/w6eHfcvVl4g odnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:mime-version:dkim-signature; bh=9WScczfM7tLHRbQ7a/K4AEWRZApP20xQzhsemglgp/Y=; b=DGlTbiKYH+8ylAgSe9uwdfmPNIQMD7JjOKq+JSYHZQWacRuMkbLT+haIileW5T/M2K zVzmaG7+8Ok/jO6bO2MK6eiFahB411Xb+UPZf58C0nt9JWGnD6B90PO7Gbt46f9ES6+N +MtczpGTgtscS3gbJFDRS6OIUUjnejlq3dIia5R03Q3bNINnQKYRRhXgcy1hOZskWgnA 38A2kBQxLMHhWTI5b5rPSQmC2NTtRBt/BDN9kjKAjMleY1qXONj/RZS7CgMIMB5N8nFe q5PwHHtob6z5/DB1gxIT+EL8OYGixmNuiaF61lQhJaWEZRBDpyRVNebn4XGRNeqxpr27 J7FQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=aLHUbGrR; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ba11-20020a170902720b00b0016cf165f951si6337191plb.555.2022.07.22.14.37.32; Fri, 22 Jul 2022 14:37:48 -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=@google.com header.s=20210112 header.b=aLHUbGrR; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236133AbiGVVfu (ORCPT + 99 others); Fri, 22 Jul 2022 17:35:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39696 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229522AbiGVVfr (ORCPT ); Fri, 22 Jul 2022 17:35:47 -0400 Received: from mail-oi1-x233.google.com (mail-oi1-x233.google.com [IPv6:2607:f8b0:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A15CEAF843 for ; Fri, 22 Jul 2022 14:35:45 -0700 (PDT) Received: by mail-oi1-x233.google.com with SMTP id r82so6944165oig.2 for ; Fri, 22 Jul 2022 14:35:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :mime-version:from:to:cc; bh=9WScczfM7tLHRbQ7a/K4AEWRZApP20xQzhsemglgp/Y=; b=aLHUbGrR02PJ4ixgBCGa1InFsJsCBWmLb2s2PpIhGy6R5aKyboeaDnWdT3NQtekc6V guUdfehOHU3dYQN5slembq6V1+7iHhqE61aDtlHhYlcvIOxfMgEqx+9VlgODK5G6JwyL w772qBXwsgHaqQuVb7pycZ6D1xynJieCfB6vQRBrA+be1RSnYN3cD7+Jl8sCkMKaWcR1 Lae57Ow2LzlcDbwYmpMRe0H7IsW49D8XLHXhHddViCjpEGgMbfgydUPfu/jBSMLqkFDM rM/AY1XdzxTerV/nYq2OpfFgNxEM6r/+RDFEOT513F82amDb7HkJoh4MXMSi+ZQF54ZC 7TNg== 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 :mime-version:x-gm-message-state:from:to:cc; bh=9WScczfM7tLHRbQ7a/K4AEWRZApP20xQzhsemglgp/Y=; b=7p0lZf1Vc4aaRPcqpnDIblSH4/BwxaDa/Wv2itrS6siLeABH1VL7/M8T69dx5M90lR 6J5Au3P1Qwwz4ejvRY1Fn6qFOJuYelhnwnufYPZqXkaZBo7H5uxqaTPYn0AQRbe4IyIo 7V5Pj/Li0Q2kDvG6voiWwT/LBaipW/Auy6tKZOuw2isY3Aeg0v49/V75zFTKX3jV5D8p w/Z01LwE71ILo4VuDrqMeMxVLxjvaWoam15/Y4qXa7K+6gtg37PWgRvls1DTzIN5qWyq WNwedCYcDfr6epdD2Bo9Leo3erNrPfvTWPEiV8TVpFbdh/V0MZqRAsEt7YhR2oRoXkmk V2Gg== X-Gm-Message-State: AJIora9Pwbnj9ZA6g7ealPuTlzZuZE6eH5sy9Q/S/rgcynKK3ewYFU53 CoU3U0D+5958dKvKWcTAyDqpObeivDOWWZ1aRBu9Sw== X-Received: by 2002:a05:6808:1b28:b0:33a:b03e:5d1 with SMTP id bx40-20020a0568081b2800b0033ab03e05d1mr3893621oib.112.1658525744847; Fri, 22 Jul 2022 14:35:44 -0700 (PDT) MIME-Version: 1.0 From: Jim Mattson Date: Fri, 22 Jul 2022 14:35:34 -0700 Message-ID: Subject: RFC: The hypervisor's responsibility to stuff the RSB To: kvm list , Paolo Bonzini Cc: LKML , Paul Turner Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 Now that Retbleed has drawn everyone's attention back to Skylake's RSBA behavior, I've been hearing murmurings about the hypervisor's responsibility to stuff the RSB on VM-entry when running on RSBA parts. Referring back to Intel's paper, "Retpoline: A Branch Target Injection Mitigation," it does say: > There are also a number of events that happen asynchronously from normal = program execution that can result in an empty RSB. Software may use =E2=80= =9CRSB stuffing=E2=80=9D sequences whenever these asynchronous events occur= : > > 1. Interrupts/NMIs/traps/aborts/exceptions which increase call depth. > 2. System Management Interrupts (SMI) (see BIOS/Firmware Interactions). > 3. Host VMEXIT/VMRESUME/VMENTER. > 4. Microcode update load (WRMSR 0x79) on another logical processor of the= same core. > > Software may avoid RSB underflow by inserting an =E2=80=9CRSB stuffing=E2= =80=9D sequence following all of the above conditions. KVM *does* stuff the RSB on VM-exit, to protect the host kernel. However, it fails to stuff the RSB on VM-entry. Stuffing the RSB on VM-entry is necessary to protect the guest if KVM has made any unsafe changes to the RSB, such as reducing its depth. Though Intel doesn't spell it out, the responsibility of the hypervisor on VM-entry is much the same as the responsibility of the SMI handler on RSM. For reference, here's the "BIOS/Firmware Interactions" section of the aforementioned paper, referenced above: > System Management Interrupt (SMI) handlers can leave the RSB in a state t= hat OS code does not expect. In order to avoid RSB underflow on return from= SMI, an SMI handler may implement RSB stuffing (for parts identified in Ta= ble 5) before returning from System Management Mode (SMM). Updated SMI hand= lers are provided via system BIOS updates. I don't really want to do this, but I don't want to be negligent, either. Thoughts?