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 X-Spam-Level: X-Spam-Status: No, score=-16.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 71230C2B9F4 for ; Thu, 17 Jun 2021 09:56:57 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3589160FF1 for ; Thu, 17 Jun 2021 09:56:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3589160FF1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:59658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ltolc-0007bM-7l for qemu-devel@archiver.kernel.org; Thu, 17 Jun 2021 05:56:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ltoNY-000339-MP for qemu-devel@nongnu.org; Thu, 17 Jun 2021 05:32:04 -0400 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]:44932) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ltoNW-0006LY-V2 for qemu-devel@nongnu.org; Thu, 17 Jun 2021 05:32:04 -0400 Received: by mail-ej1-x62c.google.com with SMTP id gt18so8689641ejc.11 for ; Thu, 17 Jun 2021 02:32:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=zu0RUwB1p19Fagtd8xyL4/0jgFufKWq1IEEH4S5GC2c=; b=ZVTrQj9EgxNG/+/9+oq9y8opSvQAdCTmJleSeiSDMvWXhSa98q+8t8/wSRgEVWrKAC nBW0nvjwC6UH8jgqLZJm3WPQlnp0vnYvj/0MvTjpdKBS3EQsctn7GIxYtxymtoEsh25P 7QDwoF4wHBaT1nepVgw0VrnsUtfYznK2QVqIgsQmLJ1yz0cR/PKAWMxcCZtA4/s3B+i+ 4IrmhGA5j0bH8mMMkOcDkmeb8xFywyfx4+wvITUYyez0P49tZV4hNN/yxPJrX1iKPVBC Hb7fKW2PkrCZYXU6d5n6nhz7DeHBv1mcZI7B5fqoS5KjnWtjCbMlXu91FZ6M5fq91tCU xLIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=zu0RUwB1p19Fagtd8xyL4/0jgFufKWq1IEEH4S5GC2c=; b=EdXLr3ku8dGc2hARRFwUBz9fiIACZAegWicFJDRP9XfBYj0WWgC3jFYWFttLu4fdbv QMpaMFnKYp2vnBvX1h7SMjRIW4rCh+O25/6ZJvyMeplcjU8iwfOVGP4lQ+OiN5uMVeT+ gVspgxD9By9Y5FIqG2Iz9xnOpgV+tCTxAZlkmHdDd6g0njImyhNaR2Dx2/mVUctH89rH PzNFadZ/3nCYbhNrouPuKdM0jTgCh90OJUuX0TIa8M4YgGVBqllzuXq/YOGj8DhTrwFr dhuDaZkVInr5u8n+PrLJB2xrpjqF/88PKqQDLXPqtznav/djHTIKVmAawwJJI0oowLMr cxyA== X-Gm-Message-State: AOAM533b72YAZ+erGP1G8W9PYsSj0gxNzqwQQa/wKyw83sIaQvTdLVEn 2dJMfLgbkg4lO6P+5mvTOiT3NLTTMh4= X-Google-Smtp-Source: ABdhPJwHeQ9QE8QWeugkKfGIR07QYL3HZKi6YqdNL2eHQYpfr+KkJ+RxrvaOwFMTjwlEOfI5AddcpQ== X-Received: by 2002:a17:906:528b:: with SMTP id c11mr2984079ejm.156.1623922321540; Thu, 17 Jun 2021 02:32:01 -0700 (PDT) Received: from avogadro.lan ([2001:b07:6468:f312:c8dd:75d4:99ab:290a]) by smtp.gmail.com with ESMTPSA id m18sm3328140ejx.56.2021.06.17.02.32.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Jun 2021 02:32:01 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Subject: [PULL 35/45] target/i386: Added consistency checks for VMRUN intercept and ASID Date: Thu, 17 Jun 2021 11:31:24 +0200 Message-Id: <20210617093134.900014-36-pbonzini@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210617093134.900014-1-pbonzini@redhat.com> References: <20210617093134.900014-1-pbonzini@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::62c; envelope-from=paolo.bonzini@gmail.com; helo=mail-ej1-x62c.google.com X-Spam_score_int: -14 X-Spam_score: -1.5 X-Spam_bar: - X-Spam_report: (-1.5 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.249, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lara Lazier Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" From: Lara Lazier Zero VMRUN intercept and ASID should cause an immediate VMEXIT during the consistency checks performed by VMRUN. (AMD64 Architecture Programmer's Manual, V2, 15.5) Signed-off-by: Lara Lazier Message-Id: <20210616123907.17765-3-laramglazier@gmail.com> Signed-off-by: Paolo Bonzini --- target/i386/tcg/sysemu/svm_helper.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/target/i386/tcg/sysemu/svm_helper.c b/target/i386/tcg/sysemu/svm_helper.c index 2f7606bebf..902bf03fc3 100644 --- a/target/i386/tcg/sysemu/svm_helper.c +++ b/target/i386/tcg/sysemu/svm_helper.c @@ -72,6 +72,7 @@ void helper_vmrun(CPUX86State *env, int aflag, int next_eip_addend) uint64_t nested_ctl; uint32_t event_inj; uint32_t int_ctl; + uint32_t asid; cpu_svm_check_intercept_param(env, SVM_EXIT_VMRUN, 0, GETPC()); @@ -154,9 +155,18 @@ void helper_vmrun(CPUX86State *env, int aflag, int next_eip_addend) nested_ctl = x86_ldq_phys(cs, env->vm_vmcb + offsetof(struct vmcb, control.nested_ctl)); + asid = x86_ldq_phys(cs, env->vm_vmcb + offsetof(struct vmcb, + control.asid)); env->nested_pg_mode = 0; + if (!cpu_svm_has_intercept(env, SVM_EXIT_VMRUN)) { + cpu_vmexit(env, SVM_EXIT_ERR, 0, GETPC()); + } + if (asid == 0) { + cpu_vmexit(env, SVM_EXIT_ERR, 0, GETPC()); + } + if (nested_ctl & SVM_NPT_ENABLED) { env->nested_cr3 = x86_ldq_phys(cs, env->vm_vmcb + offsetof(struct vmcb, -- 2.31.1