Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp3905923iog; Tue, 21 Jun 2022 08:12:57 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uF6tujDFju1hzmJQU7SohFv4zBmT0HZmuvlxorZWYIsHWV5B6gJiRKXs2qxNQglG+s5mCW X-Received: by 2002:a05:6402:294c:b0:435:2155:fbe8 with SMTP id ed12-20020a056402294c00b004352155fbe8mr35736171edb.256.1655824377285; Tue, 21 Jun 2022 08:12:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655824377; cv=none; d=google.com; s=arc-20160816; b=YR/gmMr9gDKgUQYEc8FhbaZpxYbOsafe64Ag3FkHoWkYJmnAWsNT1M4bYDjOlCrLc6 IBeyOCmd6qiI/9hpT6XBNjMSnUvYxZTVCp7pBdQiezYsyv/1KxfirzAqCC9V1eakqc5u P3qfyEwtCHhEtce67BKzams7wphJo0LmMxYs3cxQBAQtNPuZtk4Em2oJ3H1T0Ux6ZMAb ecCbCjI3yDeDQAfXieQ/u0kmKH9Qfo8PIX4eusj9Bo8YYptN+DX5kR6oUOSTUGIR79+M nNymeXj9fgaC+5RZl/KHUUdIDu16RXBjh5UwKM9+4UDW6xjtylZ6j2F6rp7utw+7nvHC eYmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=v6i2sWSli48GTHsEDuVBdZ0meIchicF21PFUgvtM/2Q=; b=iOPCn+XT7ITtr38FzFbzJYc1iw5QR/SdSWSf9R0tm+oavtQHz+pKpj3PKG87elX8EI y4aMvQiLA80Ks6BMYk/iqEf8ncGhCbPPUtZv9JxJIXyVWtvbV6MURHldbWTGniescqWk s+QCtgM44kKcVuKI2zfoGSf0gDFvLRVdg/N1sU9KQFia3Unp64TcGJMysqxo7WHeL2aS q5+T166Kd1TjlL0zKIAi6DEoMgweFtW5RfQL8YU1zqG3GtsAXRTTeV7hYlTF9/lkrsUB Whfb4qgVRVLooG+GPjA9UNWevGaWxLsb/uxfv0NN2bdOh+6Tn9OPvRDQPJqPHeH+RbMT 3Uzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="BDx8/RQF"; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bx28-20020a0564020b5c00b0042de30cf6e5si12969344edb.365.2022.06.21.08.12.27; Tue, 21 Jun 2022 08:12:57 -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=@redhat.com header.s=mimecast20190719 header.b="BDx8/RQF"; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352259AbiFUPJ1 (ORCPT + 99 others); Tue, 21 Jun 2022 11:09:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352230AbiFUPJV (ORCPT ); Tue, 21 Jun 2022 11:09:21 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 4CC3520194 for ; Tue, 21 Jun 2022 08:09:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1655824159; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=v6i2sWSli48GTHsEDuVBdZ0meIchicF21PFUgvtM/2Q=; b=BDx8/RQFWl+l9pgQUBrMNCooRlfrZv87vZjh2mrZQ/BTNPwunIW3WBN6Rhq/RjW9PE83og toUPo/YrnN55/Wknqp1joygWg5LiYVc9GZxfvk1Noityp5oIJZLsvDTXRuyMkhIU/Bvzwx cLxglG/R6T386Jtopl/AIDLl4/zuPsU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-38-D6fPNifgP9eHTJqlob27rQ-1; Tue, 21 Jun 2022 11:09:08 -0400 X-MC-Unique: D6fPNifgP9eHTJqlob27rQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D4C30803520; Tue, 21 Jun 2022 15:09:07 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.194.180]) by smtp.corp.redhat.com (Postfix) with ESMTP id 679EB9D7F; Tue, 21 Jun 2022 15:09:03 +0000 (UTC) From: Maxim Levitsky To: kvm@vger.kernel.org Cc: Sean Christopherson , x86@kernel.org, Kees Cook , Dave Hansen , linux-kernel@vger.kernel.org, "H. Peter Anvin" , Borislav Petkov , Joerg Roedel , Ingo Molnar , Paolo Bonzini , Thomas Gleixner , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Maxim Levitsky Subject: [PATCH v2 00/11] SMM emulation and interrupt shadow fixes Date: Tue, 21 Jun 2022 18:08:51 +0300 Message-Id: <20220621150902.46126-1-mlevitsk@redhat.com> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 This patch series is a result of long debug work to find out why=0D sometimes guests with win11 secure boot=0D were failing during boot.=0D =0D During writing a unit test I found another bug, turns out=0D that on rsm emulation, if the rsm instruction was done in real=0D or 32 bit mode, KVM would truncate the restored RIP to 32 bit.=0D =0D I also refactored the way we write SMRAM so it is easier=0D now to understand what is going on.=0D =0D The main bug in this series which I fixed is that we=0D allowed #SMI to happen during the STI interrupt shadow,=0D and we did nothing to both reset it on #SMI handler=0D entry and restore it on RSM.=0D =0D Best regards,=0D Maxim Levitsky=0D =0D Maxim Levitsky (11):=0D KVM: x86: emulator: em_sysexit should update ctxt->mode=0D KVM: x86: emulator: introduce update_emulation_mode=0D KVM: x86: emulator: remove assign_eip_near/far=0D KVM: x86: emulator: update the emulation mode after rsm=0D KVM: x86: emulator: update the emulation mode after CR0 write=0D KVM: x86: emulator/smm: number of GPRs in the SMRAM image depends on=0D the image format=0D KVM: x86: emulator/smm: add structs for KVM's smram layout=0D KVM: x86: emulator/smm: use smram struct for 32 bit smram load/restore=0D KVM: x86: emulator/smm: use smram struct for 64 bit smram load/restore=0D KVM: x86: SVM: use smram structs=0D KVM: x86: emulator/smm: preserve interrupt shadow in SMRAM=0D =0D arch/x86/include/asm/kvm_host.h | 6 -=0D arch/x86/kvm/emulate.c | 305 ++++++++++++++++----------------=0D arch/x86/kvm/kvm_emulate.h | 146 +++++++++++++++=0D arch/x86/kvm/svm/svm.c | 28 +--=0D arch/x86/kvm/x86.c | 162 ++++++++---------=0D 5 files changed, 394 insertions(+), 253 deletions(-)=0D =0D -- =0D 2.26.3=0D =0D