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=-9.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable 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 A1C64C433E1 for ; Wed, 8 Jul 2020 19:35:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 85CD1206E9 for ; Wed, 8 Jul 2020 19:35:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="VPdrjD6L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726948AbgGHTfE (ORCPT ); Wed, 8 Jul 2020 15:35:04 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:21771 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726813AbgGHTea (ORCPT ); Wed, 8 Jul 2020 15:34:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594236868; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZK74dzjSy8T3R+12pLZXg3ORuRszBwsy+Uum3012XO0=; b=VPdrjD6LuRwN1RKF3oP9rNyT+CfLkSn0zvSV9HAeUKjPY+3/rj6Js+HJ7Lk6PsmIU+SqSv QiQB1gcRf1gMahbyOfBEKHe79JiRzCJHHZQc9qXGgBQR4mOur3zjTB5f3qE04k5umHis9P a+W/ljr3QoqjEllSIPw97VhPqhNWgaY= Received: from mail-qv1-f70.google.com (mail-qv1-f70.google.com [209.85.219.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-320-5A6PMyJeM92oI5ByF9WthA-1; Wed, 08 Jul 2020 15:34:26 -0400 X-MC-Unique: 5A6PMyJeM92oI5ByF9WthA-1 Received: by mail-qv1-f70.google.com with SMTP id u1so16447965qvu.18 for ; Wed, 08 Jul 2020 12:34:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZK74dzjSy8T3R+12pLZXg3ORuRszBwsy+Uum3012XO0=; b=Xoo9aggTuH9sj+cvmnZvxRiWm0j0T2b+Oh8zmAIO/HleGnrPnB7UzsZ34hziLZS5Ws lamRvKUK/iF08WyC9MGhz17nRtffxWjxZA7CwEaO2xg/dUoKI4F8wmqnSt7OxABFjq/p Kh8IznBmzoHlepvhkCsf/nNhBwTLdSCfwW2B/2VBE+K0JzO10LFcFDmzxXPO0n5LiGmZ jyBKw6V5hV1X+LKp4TBYKM06uG3rpFJ5tDhwX2oS9nfk9hxTYtQ7/3ckGMOkveVGEGja GdLOXqGD11MIU0xFJA8I2atOHHYn/Ma/AxEKXVBnuJI6ZD20TM7rUJrazpjp68gn9QLd Zleg== X-Gm-Message-State: AOAM5337yfxhwLgBT5/dLup7pOwEBKPzrnkhfA2yVYTXxY8eIZ3kAEOe Oc98gQms5RUzZprE2/si7utJxsMdy/nSc+gMVgule62E6WSe2zbjZ3H8wumH531OaXtG/CiigXs OkPHg57i4GHyoQ8hJ6bc/NvvT X-Received: by 2002:a05:6214:612:: with SMTP id z18mr58313893qvw.46.1594236866090; Wed, 08 Jul 2020 12:34:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyFSchYlOtevPJYCwsyJKUPX8tFeehIlcbcjp5bl/v9L5LM3SLhfdQLFAeBsoE8fPhhEkT3TQ== X-Received: by 2002:a05:6214:612:: with SMTP id z18mr58313867qvw.46.1594236865839; Wed, 08 Jul 2020 12:34:25 -0700 (PDT) Received: from xz-x1.redhat.com ([2607:9880:19c8:6f::1f4f]) by smtp.gmail.com with ESMTPSA id f18sm664884qtc.28.2020.07.08.12.34.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jul 2020 12:34:25 -0700 (PDT) From: Peter Xu To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: peterx@redhat.com, Sean Christopherson , "Dr . David Alan Gilbert" , Andrew Jones , Paolo Bonzini Subject: [PATCH v11 08/13] KVM: selftests: Sync uapi/linux/kvm.h to tools/ Date: Wed, 8 Jul 2020 15:34:03 -0400 Message-Id: <20200708193408.242909-9-peterx@redhat.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200708193408.242909-1-peterx@redhat.com> References: <20200708193408.242909-1-peterx@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This will be needed to extend the kvm selftest program. Signed-off-by: Peter Xu --- tools/include/uapi/linux/kvm.h | 53 ++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h index fdd632c833b4..4f7a0a7ce85a 100644 --- a/tools/include/uapi/linux/kvm.h +++ b/tools/include/uapi/linux/kvm.h @@ -236,6 +236,7 @@ struct kvm_hyperv_exit { #define KVM_EXIT_IOAPIC_EOI 26 #define KVM_EXIT_HYPERV 27 #define KVM_EXIT_ARM_NISV 28 +#define KVM_EXIT_DIRTY_RING_FULL 29 /* For KVM_EXIT_INTERNAL_ERROR */ /* Emulate instruction failed. */ @@ -1017,6 +1018,7 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_S390_VCPU_RESETS 179 #define KVM_CAP_S390_PROTECTED 180 #define KVM_CAP_PPC_SECURE_GUEST 181 +#define KVM_CAP_DIRTY_LOG_RING 182 #ifdef KVM_CAP_IRQ_ROUTING @@ -1518,6 +1520,9 @@ struct kvm_pv_cmd { /* Available with KVM_CAP_S390_PROTECTED */ #define KVM_S390_PV_COMMAND _IOWR(KVMIO, 0xc5, struct kvm_pv_cmd) +/* Available with KVM_CAP_DIRTY_LOG_RING */ +#define KVM_RESET_DIRTY_RINGS _IO(KVMIO, 0xc6) + /* Secure Encrypted Virtualization command */ enum sev_cmd_id { /* Guest initialization commands */ @@ -1671,4 +1676,52 @@ struct kvm_hyperv_eventfd { #define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0) #define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1) +/* + * Arch needs to define the macro after implementing the dirty ring + * feature. KVM_DIRTY_LOG_PAGE_OFFSET should be defined as the + * starting page offset of the dirty ring structures. + */ +#ifndef KVM_DIRTY_LOG_PAGE_OFFSET +#define KVM_DIRTY_LOG_PAGE_OFFSET 0 +#endif + +/* + * KVM dirty GFN flags, defined as: + * + * |---------------+---------------+--------------| + * | bit 1 (reset) | bit 0 (dirty) | Status | + * |---------------+---------------+--------------| + * | 0 | 0 | Invalid GFN | + * | 0 | 1 | Dirty GFN | + * | 1 | X | GFN to reset | + * |---------------+---------------+--------------| + * + * Lifecycle of a dirty GFN goes like: + * + * dirtied collected reset + * 00 -----------> 01 -------------> 1X -------+ + * ^ | + * | | + * +------------------------------------------+ + * + * The userspace program is only responsible for the 01->1X state + * conversion (to collect dirty bits). Also, it must not skip any + * dirty bits so that dirty bits are always collected in sequence. + */ +#define KVM_DIRTY_GFN_F_DIRTY BIT(0) +#define KVM_DIRTY_GFN_F_RESET BIT(1) +#define KVM_DIRTY_GFN_F_MASK 0x3 + +/* + * KVM dirty rings should be mapped at KVM_DIRTY_LOG_PAGE_OFFSET of + * per-vcpu mmaped regions as an array of struct kvm_dirty_gfn. The + * size of the gfn buffer is decided by the first argument when + * enabling KVM_CAP_DIRTY_LOG_RING. + */ +struct kvm_dirty_gfn { + __u32 flags; + __u32 slot; + __u64 offset; +}; + #endif /* __LINUX_KVM_H */ -- 2.26.2