From patchwork Tue Oct 16 21:29:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Mattson X-Patchwork-Id: 10644219 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B7D3F1057 for ; Tue, 16 Oct 2018 21:29:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A97962A9D3 for ; Tue, 16 Oct 2018 21:29:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9DB062A9DF; Tue, 16 Oct 2018 21:29:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, USER_IN_DEF_DKIM_WL autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD4FB2A9D3 for ; Tue, 16 Oct 2018 21:29:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726957AbeJQFWB (ORCPT ); Wed, 17 Oct 2018 01:22:01 -0400 Received: from mail-qt1-f201.google.com ([209.85.160.201]:35019 "EHLO mail-qt1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726067AbeJQFWB (ORCPT ); Wed, 17 Oct 2018 01:22:01 -0400 Received: by mail-qt1-f201.google.com with SMTP id s56-v6so26324275qtk.2 for ; Tue, 16 Oct 2018 14:29:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=cHl3tynkaR04a7D0zzKIExoPIkAlOHpBDrUKtcxKEos=; b=jKjVoR1pN6xGooAHiN9Cb+EAc4mj4ozuId5FHLIi/HUW/cqCJ55vsZScab28cBcqcg 4CJwWLvJSeWiWA03yLLlqowu0irhrtO6613HZazoMeBnpVg3SLqZMREy5vyk1a+t1VEC cC1ysao0W/mtRn6SEGBkfPOXwToIDw08ZKUhqNCrNq2A7OUbxLETSxpusG6qXlCSpzTF EZjcO05fQ2EPvDOIMzR8XUkQFeYfYR/iYpbCu6Ac5XiLPO2/V59/SejScqMlUlVyq/CJ +VmAhFkaExsZImQjJ05m38VhC1xc6nkZASmYQIigSk1SPwpZteJWzsrsLiFENXo5Aatp jjdw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=cHl3tynkaR04a7D0zzKIExoPIkAlOHpBDrUKtcxKEos=; b=A4sTkdMG3JqeTiIL1dQiwjaynv6BG7Ji5oFRhvSJAvswQp7nLLpwRQKaG0rEPIBtjo MkyMMvvWjWTnRtrGHcxDRJKZkffjbCiGwB2qIJCOqoJDfyQmRD16JKIiLPO/i+UgnLnB byaMT6dZwh0cATHFXaD6tGkSqn4JhNQOyxT9yYNBJnlK4oUT8dFQaquxSe7KLSui5qB0 PIzIXHy8F9tRVhJXGTOmmsa8G9kC2ty6N3liJJT7H7ylzkCPFPKqDC3F2TXNm/pSAUw0 r1F8WC34ZvuGHkKh2+NJk59k4TNoqLdUbgTCkjg9HbOLTP1y7VRhxuw8T6NqgolimwNx UD+w== X-Gm-Message-State: ABuFfoh/QUb0xZp0GVxqnzhxYFVa9DPM7Stfg4CRD8QIJQ1IlnEICkDg qlSfkoo8eGBoKMzbj6t7VG6DhiCfB0DhvXCGwy58KZbJ72PO3LkFlag1EyOaaobTSCoKdM/aSa5 S44douF02ShLRMdPy16Hdm7xWJ+ln2wRE3tiuCW0N1CGEROydnwUR88nf097RCTY= X-Google-Smtp-Source: ACcGV62DAC8XXTM1PZT0vw1K8GSN3wgOHS1EgBDkh9nXSWQVjlA5vQU8G+wOFq/rCx9GWYagFVPuxgESTpLGog== X-Received: by 2002:ac8:2d62:: with SMTP id o31-v6mr19730358qta.11.1539725382109; Tue, 16 Oct 2018 14:29:42 -0700 (PDT) Date: Tue, 16 Oct 2018 14:29:19 -0700 In-Reply-To: <20181016212924.130307-1-jmattson@google.com> Message-Id: <20181016212924.130307-2-jmattson@google.com> Mime-Version: 1.0 References: <20181016212924.130307-1-jmattson@google.com> X-Mailer: git-send-email 2.19.1.331.ge82ca0e54c-goog Subject: [PATCH v2 2/7] kvm: x86: Add has_payload and payload to kvm_queued_exception From: Jim Mattson To: kvm@vger.kernel.org Cc: Peter Shier , Liran Alon , Paolo Bonzini , Jim Mattson Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The payload associated with a #PF exception is the linear address of the fault to be loaded into CR2 when the fault is delivered. The payload associated with a #DB exception is a mask of the DR6 bits to be set (or in the case of DR6.RTM, cleared) when the fault is delivered. Add fields has_payload and payload to kvm_queued_exception to track payloads for pending exceptions. The new fields are introduced here, but for now, they are just cleared. Reported-by: Jim Mattson Suggested-by: Paolo Bonzini Signed-off-by: Jim Mattson --- arch/x86/include/asm/kvm_host.h | 2 ++ arch/x86/kvm/x86.c | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/arch/x86/include/asm/kvm_host.h b/arch/x86/include/asm/kvm_host.h index 09b2e3e2cf1b..69aea8886435 100644 --- a/arch/x86/include/asm/kvm_host.h +++ b/arch/x86/include/asm/kvm_host.h @@ -585,6 +585,8 @@ struct kvm_vcpu_arch { bool has_error_code; u8 nr; u32 error_code; + unsigned long payload; + bool has_payload; u8 nested_apf; } exception; diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index ca717737347e..eae639ce52be 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -431,6 +431,8 @@ static void kvm_multiple_exception(struct kvm_vcpu *vcpu, vcpu->arch.exception.has_error_code = has_error; vcpu->arch.exception.nr = nr; vcpu->arch.exception.error_code = error_code; + vcpu->arch.exception.has_payload = false; + vcpu->arch.exception.payload = 0; return; } @@ -455,6 +457,8 @@ static void kvm_multiple_exception(struct kvm_vcpu *vcpu, vcpu->arch.exception.has_error_code = true; vcpu->arch.exception.nr = DF_VECTOR; vcpu->arch.exception.error_code = 0; + vcpu->arch.exception.has_payload = false; + vcpu->arch.exception.payload = 0; } else /* replace previous exception with a new one in a hope that instruction re-execution will regenerate lost @@ -3429,6 +3433,8 @@ static int kvm_vcpu_ioctl_x86_set_vcpu_events(struct kvm_vcpu *vcpu, vcpu->arch.exception.nr = events->exception.nr; vcpu->arch.exception.has_error_code = events->exception.has_error_code; vcpu->arch.exception.error_code = events->exception.error_code; + vcpu->arch.exception.has_payload = false; + vcpu->arch.exception.payload = 0; vcpu->arch.interrupt.injected = events->interrupt.injected; vcpu->arch.interrupt.nr = events->interrupt.nr; @@ -9463,6 +9469,8 @@ void kvm_arch_async_page_present(struct kvm_vcpu *vcpu, vcpu->arch.exception.nr = 0; vcpu->arch.exception.has_error_code = false; vcpu->arch.exception.error_code = 0; + vcpu->arch.exception.has_payload = false; + vcpu->arch.exception.payload = 0; } else if (!apf_put_user(vcpu, KVM_PV_REASON_PAGE_READY)) { fault.vector = PF_VECTOR; fault.error_code_valid = true;