From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 542CFC433FE for ; Tue, 28 Dec 2021 23:24:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237759AbhL1XYm (ORCPT ); Tue, 28 Dec 2021 18:24:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237737AbhL1XYl (ORCPT ); Tue, 28 Dec 2021 18:24:41 -0500 Received: from mail-pg1-x54a.google.com (mail-pg1-x54a.google.com [IPv6:2607:f8b0:4864:20::54a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACB49C061574 for ; Tue, 28 Dec 2021 15:24:41 -0800 (PST) Received: by mail-pg1-x54a.google.com with SMTP id t1-20020a6564c1000000b002e7f31cf59fso10068728pgv.14 for ; Tue, 28 Dec 2021 15:24:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=reply-to:date:message-id:mime-version:subject:from:to:cc; bh=VCUbiUfxRQgO1C3fIu9TBCkG8k6G/qD2BOcSRTbuD1c=; b=lB59nZUv8KWJ5mLd88XkrXrrAgAQ6si3Sg1nBEAgELcKOmTCvXm44WSrvCJLWidktY 4ldpdJUkkLqwAtYCIm7aixOmQ/mHsI5qEDn1XlOJ1Mun5XP0Qml/697U181sepfza350 wjtDbCnHecuHUTFurFEw3CPXDr5PLs16oTKZM3Rgqn6ESeMAE5XBsi05rHElabyPJNKI KLsJ+uYTZlaHW0iYvhM/ZkXagRhmN2fbLwzb2oVIMbAxwERg7UcUEQaLp4MOG1BU/uOS FpHfHw4VxJZRmvpyHhxOlC8rNr/Hs9xmocB4pC0vIo49B+ounp4WZdXt6RstW3W6hiQU a5Mg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:reply-to:date:message-id:mime-version:subject :from:to:cc; bh=VCUbiUfxRQgO1C3fIu9TBCkG8k6G/qD2BOcSRTbuD1c=; b=UluZc/AzF/ti4rmpPsVLQy8eLgSULUG2tB2/jTKcX7x2g3C5TLJdKM2Rv0UAyR3zPN 0eo/RP98SKosbiR2AhnWZZ8ytYkiXh+bMUILFg0UcdAoIpOqxcAZKS6mLL2mqLTPcH7f RBhqvy5uVnG1n1goxsxytJ30EDq5fOiFOuZwWJplGRlmGDTxPTJayq9CR15c9VoojLk6 aXcORtWrwRkwQJ9tIozzqzloIANPG59JAGuVQPW6MY4OfLslPTXJL+DPz09FMxfJKnsl +S81gnmTlcGwCQvXVOU4o3hz64QYfolUkCOfgdvTm6Od/Qy2RHRgQI7EMSsuH/FupZ5b I+aw== X-Gm-Message-State: AOAM533vceBPVsar5Jnh3JPSui/oC3t61lKt2yaYs6YCrsnyhmmg8k96 oLFybfOswH770Z04fEybLSTYJZpHbo0= X-Google-Smtp-Source: ABdhPJzPjPTQbztBMp2uTNDFtTsH69aLQHjp2cS0Tw9ZlDzLurVhqCX/7moCfZkIjtfq+1Hqy+N1RtO0QOU= X-Received: from seanjc.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3e5]) (user=seanjc job=sendgmr) by 2002:aa7:9298:0:b0:4ba:7d3a:1742 with SMTP id j24-20020aa79298000000b004ba7d3a1742mr24182188pfa.62.1640733881004; Tue, 28 Dec 2021 15:24:41 -0800 (PST) Reply-To: Sean Christopherson Date: Tue, 28 Dec 2021 23:24:35 +0000 Message-Id: <20211228232437.1875318-1-seanjc@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.34.1.448.ga2b2bfdf31-goog Subject: [PATCH 0/2] KVM: VMX: Fix and test for emulation + exception From: Sean Christopherson To: Paolo Bonzini Cc: Sean Christopherson , Vitaly Kuznetsov , Wanpeng Li , Jim Mattson , Joerg Roedel , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+82112403ace4cbd780d8@syzkaller.appspotmail.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix an issue that allows userspace to trigger a WARN by rejecting KVM_RUN if userspace attempts to run a vCPU that require emulation in KVM and has a pending exception, which is not supported in KVM. No small part of me thinks this is a waste of code and that we'd be better off just deleting the WARN. But it's also not hard to fix and there are still folks out there that run on Core2... Intentionally didn't tag for stable. I highly doubt this actually fixes anything for anyone, the goal is purely to prevent userspace from triggering the WARN. Sean Christopherson (2): KVM: VMX: Reject KVM_RUN if emulation is required with pending exception KVM: selftests: Add a test to force emulation with a pending exception arch/x86/include/asm/kvm-x86-ops.h | 1 + arch/x86/include/asm/kvm_host.h | 1 + arch/x86/kvm/svm/svm.c | 6 + arch/x86/kvm/vmx/vmx.c | 22 ++- arch/x86/kvm/x86.c | 12 +- tools/testing/selftests/kvm/.gitignore | 1 + tools/testing/selftests/kvm/Makefile | 1 + .../vmx_exception_with_invalid_guest_state.c | 139 ++++++++++++++++++ 8 files changed, 178 insertions(+), 5 deletions(-) create mode 100644 tools/testing/selftests/kvm/x86_64/vmx_exception_with_invalid_guest_state.c -- 2.34.1.448.ga2b2bfdf31-goog