Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp428254ybe; Wed, 4 Sep 2019 01:53:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqw69osElukB8VEwOiTOBuNEH7S6c8PegiLSQwKXWNaZ33GAML9V87i7PULIg5fM3l5uFG0U X-Received: by 2002:a17:902:ff03:: with SMTP id f3mr34832409plj.134.1567587198845; Wed, 04 Sep 2019 01:53:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567587198; cv=none; d=google.com; s=arc-20160816; b=NaaU/v76ew3ASkggxidV0xnS5o9jQAVEWIfpo3hR7tOIdve9hgMXuGartJIccKXR96 IR8ikAmJarEixQiD9UlBGOGZHo8ao/MbS+3HsVTZJDxQO2Z0qvffUgVnlBNCfaXLo8wH 7WpIPZp71OuyaVXD9XzsNY97vu4JpZeMIO73gZRmWu5n87vQten882peTDPDoHG5OhUm AlRzvrCpAUZnRTsj0uL0bKG8f3r/A2GXKnjLu5EgBq8DYCi0BT6s8KhPLKjkfEJxItkp mLOm7jWF0Ur+rtqYxN3TnLGxwzxqrXSx/+RT+8gdvJFdxcZ8suITsdjdNatOEXjvThc0 hnlQ== 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; bh=pMOZL3bTYqy3zSxL7FbK/C4zCc6oCiRMiM8X06mzzPI=; b=HXNGamIyiodJusJeH2JfpHaCvaeFzZlswIF1bOj5ugt2OcXaVCygmoo0JpGH43WcQK t5vbAps1/KNdSRZdg6hURoc415zEo19tq3QqtvrCx2mGh+1CFoi0PNdLqH60zISIXzQI H51s6zG+xVSHOTUwOIYHyI04hXYVobBQ9tOFWjIDWoQDYdahTIis5LKYMJ+/sJkfWPUQ 5E0rjIb7P1H8ID+U50bd9r/cKK5CSzksI5Boq7xH058ya6OAPf9Lt4jV0NudP5buXd3n Zu4HLb4/X9br9H0Nr105fs8pk7cgLCECqZ1uVIhtFtaXPyfQ3//O3kfmA5ESSEijdfjU cKPA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k8si16761714pgt.548.2019.09.04.01.53.03; Wed, 04 Sep 2019 01:53:18 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729421AbfIDIwP (ORCPT + 99 others); Wed, 4 Sep 2019 04:52:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:43904 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725938AbfIDIwN (ORCPT ); Wed, 4 Sep 2019 04:52:13 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4C9A3875222; Wed, 4 Sep 2019 08:52:13 +0000 (UTC) Received: from thuth.com (ovpn-116-69.ams2.redhat.com [10.36.116.69]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A0B3600CD; Wed, 4 Sep 2019 08:52:11 +0000 (UTC) From: Thomas Huth To: kvm@vger.kernel.org, Christian Borntraeger , Janosch Frank Cc: David Hildenbrand , Cornelia Huck , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/2] KVM: selftests: Test invalid bits in kvm_valid_regs and kvm_dirty_regs on s390x Date: Wed, 4 Sep 2019 10:52:00 +0200 Message-Id: <20190904085200.29021-3-thuth@redhat.com> In-Reply-To: <20190904085200.29021-1-thuth@redhat.com> References: <20190904085200.29021-1-thuth@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.68]); Wed, 04 Sep 2019 08:52:13 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that we disallow invalid bits in kvm_valid_regs and kvm_dirty_regs on s390x, too, we should also check this condition in the selftests. The code has been taken from the x86-version of the sync_regs_test. Reviewed-by: Janosch Frank Reviewed-by: Christian Borntraeger Reviewed-by: Cornelia Huck Signed-off-by: Thomas Huth --- .../selftests/kvm/s390x/sync_regs_test.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tools/testing/selftests/kvm/s390x/sync_regs_test.c b/tools/testing/selftests/kvm/s390x/sync_regs_test.c index bbc93094519b..d5290b4ad636 100644 --- a/tools/testing/selftests/kvm/s390x/sync_regs_test.c +++ b/tools/testing/selftests/kvm/s390x/sync_regs_test.c @@ -85,6 +85,36 @@ int main(int argc, char *argv[]) run = vcpu_state(vm, VCPU_ID); + /* Request reading invalid register set from VCPU. */ + run->kvm_valid_regs = INVALID_SYNC_FIELD; + rv = _vcpu_run(vm, VCPU_ID); + TEST_ASSERT(rv < 0 && errno == EINVAL, + "Invalid kvm_valid_regs did not cause expected KVM_RUN error: %d\n", + rv); + vcpu_state(vm, VCPU_ID)->kvm_valid_regs = 0; + + run->kvm_valid_regs = INVALID_SYNC_FIELD | TEST_SYNC_FIELDS; + rv = _vcpu_run(vm, VCPU_ID); + TEST_ASSERT(rv < 0 && errno == EINVAL, + "Invalid kvm_valid_regs did not cause expected KVM_RUN error: %d\n", + rv); + vcpu_state(vm, VCPU_ID)->kvm_valid_regs = 0; + + /* Request setting invalid register set into VCPU. */ + run->kvm_dirty_regs = INVALID_SYNC_FIELD; + rv = _vcpu_run(vm, VCPU_ID); + TEST_ASSERT(rv < 0 && errno == EINVAL, + "Invalid kvm_dirty_regs did not cause expected KVM_RUN error: %d\n", + rv); + vcpu_state(vm, VCPU_ID)->kvm_dirty_regs = 0; + + run->kvm_dirty_regs = INVALID_SYNC_FIELD | TEST_SYNC_FIELDS; + rv = _vcpu_run(vm, VCPU_ID); + TEST_ASSERT(rv < 0 && errno == EINVAL, + "Invalid kvm_dirty_regs did not cause expected KVM_RUN error: %d\n", + rv); + vcpu_state(vm, VCPU_ID)->kvm_dirty_regs = 0; + /* Request and verify all valid register sets. */ run->kvm_valid_regs = TEST_SYNC_FIELDS; rv = _vcpu_run(vm, VCPU_ID); -- 2.18.1