Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp767318ybz; Fri, 17 Apr 2020 09:40:23 -0700 (PDT) X-Google-Smtp-Source: APiQypLVTaIsmVUzq91adbfGv90wECngPlLyBRLbzwXFAXbwyd63GCowcPhZlr2yjPjwCpHUAcWX X-Received: by 2002:aa7:c40c:: with SMTP id j12mr3700425edq.169.1587141623483; Fri, 17 Apr 2020 09:40:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587141623; cv=none; d=google.com; s=arc-20160816; b=WeNjBEu22vZtQcoxgG8juFa6b5cA/bFT0xGz0T4L4KgolwqilQi1wPlzhxrC5o4mEJ ESxBqoV6Z9+fltYCS+eXadSlWLwJwA1i35eyRZDskDARPLgkk6icEJaTPCbrX177Ek5B h7lrBGqllxZeSZei3/bwtg3Q96cdPs8SxBSPBTrOD+Ov9Bq94g/qX1RBxfINsIJn0ueN 4HhhXKSU5KL8Ugjh1ZOopiZumBUl268aYyMtfwLNbKubJFFp/eb/ZxKAmvO7almyfhaU cLnbuosP6J7c1a/gOWmZGBJ6tH1bEVFnd4WrPdgYJp200TWpRmTvmZzSAjInx5jWd+xX rhwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=Z/pKVMMwxLbjeJ0zqc1nvp6FeDnWdM331HyKwioYf8M=; b=MEny5v5ACSveQOETFg/fk0mNGUovJdEASvvGGlDR14+DSAqczjmVFoPaDIgdBlebX7 tNlvXPmJsTFKMmHMLPCAxwhvtGrUXVjs/xUTronyCFSoOj6e4qFnBxr673ug38WeWpC1 I8lY1RhoBpDGyFN2HhqS/PoRdw9TCKhVVi7fCAfEGiRvJqLNy8kfTV2U0EZUYLwuxc0N rgtxza8Tt0YBYmX2at1BTnB4OMcZ8sAv5eJdt+boOhTjRRnTHnQfm8b9NJp/ZTq0ivC+ 0Z7WGW7j7/n7B017guUATgngoQDMPGuY9C9gjGY/EpHxMnBOlhYUW1vbzw2pOunaKcuX FVqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FyZp3l7h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k11si22585edx.311.2020.04.17.09.39.59; Fri, 17 Apr 2020 09:40:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FyZp3l7h; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1726590AbgDQQiv (ORCPT + 99 others); Fri, 17 Apr 2020 12:38:51 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:23036 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725877AbgDQQiu (ORCPT ); Fri, 17 Apr 2020 12:38:50 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1587141529; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:in-reply-to:in-reply-to:references:references; bh=Z/pKVMMwxLbjeJ0zqc1nvp6FeDnWdM331HyKwioYf8M=; b=FyZp3l7hM6EYVN1Ry0vj4HP14HkXagzYaQXdthOFBbshrT+lQraOo8mbhByt8GLbZRtUCB xSapNOOBubYBR7X2wVGhAmU5KxTnZZ6mXSUZdEaKxAGouslT9/eLnuyaVBVybMjTT/yNDN pxQRuEBjoY9rtVBnXl24K6vLF4MYZEg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-207-Z7Q7GfjpPaOj1LKiOUnahg-1; Fri, 17 Apr 2020 12:38:46 -0400 X-MC-Unique: Z7Q7GfjpPaOj1LKiOUnahg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 056F91083E85; Fri, 17 Apr 2020 16:38:45 +0000 (UTC) Received: from virtlab511.virt.lab.eng.bos.redhat.com (virtlab511.virt.lab.eng.bos.redhat.com [10.19.152.198]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9DB685DA84; Fri, 17 Apr 2020 16:38:44 +0000 (UTC) From: Paolo Bonzini To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Sean Christopherson Subject: [PATCH 2/2] selftests: kvm/set_memory_region_test: do not check RIP if the guest shuts down Date: Fri, 17 Apr 2020 12:38:43 -0400 Message-Id: <20200417163843.71624-3-pbonzini@redhat.com> In-Reply-To: <20200417163843.71624-1-pbonzini@redhat.com> References: <20200417163843.71624-1-pbonzini@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On AMD, the state of the VMCB is undefined after a shutdown VMEXIT. KVM takes a very conservative approach to that and resets the guest altogether when that happens. This causes the set_memory_region_test to fail because the RIP is 0xfff0 (the reset vector). Restrict the RIP test to KVM_EXIT_INTERNAL_ERROR in order to fix this. Signed-off-by: Paolo Bonzini --- .../testing/selftests/kvm/set_memory_region_test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/kvm/set_memory_region_test.c b/tools/testing/selftests/kvm/set_memory_region_test.c index 260e638826dc..b3ece55a2da6 100644 --- a/tools/testing/selftests/kvm/set_memory_region_test.c +++ b/tools/testing/selftests/kvm/set_memory_region_test.c @@ -287,10 +287,15 @@ static void test_delete_memory_region(void) vcpu_regs_get(vm, VCPU_ID, ®s); - TEST_ASSERT(regs.rip >= final_rip_start && - regs.rip < final_rip_end, - "Bad rip, expected 0x%lx - 0x%lx, got 0x%llx\n", - final_rip_start, final_rip_end, regs.rip); + /* + * On AMD, after KVM_EXIT_SHUTDOWN the VMCB has been reinitialized already, + * so the instruction pointer would point to the reset vector. + */ + if (run->exit_reason == KVM_EXIT_INTERNAL_ERROR) + TEST_ASSERT(regs.rip >= final_rip_start && + regs.rip < final_rip_end, + "Bad rip, expected 0x%lx - 0x%lx, got 0x%llx\n", + final_rip_start, final_rip_end, regs.rip); kvm_vm_free(vm); } -- 2.18.2