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=-10.0 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=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 54497C43331 for ; Tue, 31 Mar 2020 19:01:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 22983207FF for ; Tue, 31 Mar 2020 19:01:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="CwhxjFW8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731073AbgCaTBE (ORCPT ); Tue, 31 Mar 2020 15:01:04 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:48213 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726295AbgCaTBD (ORCPT ); Tue, 31 Mar 2020 15:01:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1585681262; 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=lvoidnZPqPUSWh6jETn/g9SWiiflMsbax7YPeLocRiM=; b=CwhxjFW8F9nYTjCKhhWEJl4fGbksJKWECExhYQRkf0NqwJ4BQFPuK6oVBeezIVxgXWaLCE VKb27xAAQ7IoBPsaNDK32i0WWxsi0APdGL4CTU2RutM3wqgKyd6FsWvdw6S6hDyEDrwE7G GVTV5sspwTGeMDdtgyPLSMJfoqDpXhs= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-167-2ldCZsmNMm-PpvExSVK6uQ-1; Tue, 31 Mar 2020 15:01:00 -0400 X-MC-Unique: 2ldCZsmNMm-PpvExSVK6uQ-1 Received: by mail-wr1-f71.google.com with SMTP id t25so11017752wrb.16 for ; Tue, 31 Mar 2020 12:01:00 -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=lvoidnZPqPUSWh6jETn/g9SWiiflMsbax7YPeLocRiM=; b=Y7RAmoSWhJWN0beKdu4aQ7wtnKfExKGn105hfCSq9U3QMyHzbcUdoxeT2dQ3cx1D/K Jf8F2w00HIijKGr8Vn5bXa6NYSCVqLhpuP+aI/ijNabu0KBemuY40Eu9rWXJUAU6/O61 8eUtFMzhI7BPJ/1nAhHBy8eEpdN+P7shdaDxQGJrxqJjnojLtbkNBXJ2peqc1PO6g/oq JYbEIjQNstqvXQlhOMVI16u5OJ3FhKPre+Wb5xHHeG/RhMjoVe5HduoyWm8ZB0lLBehA aha80bxKrPB6yXqDGAfdp2gDXEEyB8NyRx77ftkkAejo1EFlPpOAXAwEFbnbBheHhogs oNgg== X-Gm-Message-State: AGi0PubbIGaAaE9SiIWauhgNMqJE70CISqZrsv6fuQxOldYvQLPQEy0L yBZc8Lq99KwQQuXUop5jZNTaiqZ7G9sVtPQgz2OIacYLUUNqh2V8tANwmkbgaqzxf92Lith8jqt TExZj5/IupwsEjY9BrY0mNPvs X-Received: by 2002:a1c:2842:: with SMTP id o63mr291278wmo.73.1585681259088; Tue, 31 Mar 2020 12:00:59 -0700 (PDT) X-Google-Smtp-Source: APiQypIMEbB8FgDIHKfz2jBBidIdJtnxskEPlPzxV7OjJvwOKEURIRmixY0ZEEnS5wY0iKDzb75OcA== X-Received: by 2002:a1c:2842:: with SMTP id o63mr291244wmo.73.1585681258814; Tue, 31 Mar 2020 12:00:58 -0700 (PDT) Received: from xz-x1.redhat.com ([2607:9880:19c0:32::2]) by smtp.gmail.com with ESMTPSA id a8sm4819848wmb.39.2020.03.31.12.00.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Mar 2020 12:00:58 -0700 (PDT) From: Peter Xu To: linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: Kevin Tian , "Michael S . Tsirkin" , Jason Wang , Sean Christopherson , Christophe de Dinechin , Yan Zhao , Alex Williamson , Paolo Bonzini , Vitaly Kuznetsov , "Dr . David Alan Gilbert" , peterx@redhat.com Subject: [PATCH v8 09/14] KVM: selftests: Sync uapi/linux/kvm.h to tools/ Date: Tue, 31 Mar 2020 14:59:55 -0400 Message-Id: <20200331190000.659614-10-peterx@redhat.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200331190000.659614-1-peterx@redhat.com> References: <20200331190000.659614-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 | 100 ++++++++++++++++++++++++++++++++- 1 file changed, 98 insertions(+), 2 deletions(-) diff --git a/tools/include/uapi/linux/kvm.h b/tools/include/uapi/linux/kvm.h index 4b95f9a31a2f..74f150c69ee6 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. */ @@ -474,12 +475,17 @@ struct kvm_s390_mem_op { __u32 size; /* amount of bytes */ __u32 op; /* type of operation */ __u64 buf; /* buffer in userspace */ - __u8 ar; /* the access register number */ - __u8 reserved[31]; /* should be set to 0 */ + union { + __u8 ar; /* the access register number */ + __u32 sida_offset; /* offset into the sida */ + __u8 reserved[32]; /* should be set to 0 */ + }; }; /* types for kvm_s390_mem_op->op */ #define KVM_S390_MEMOP_LOGICAL_READ 0 #define KVM_S390_MEMOP_LOGICAL_WRITE 1 +#define KVM_S390_MEMOP_SIDA_READ 2 +#define KVM_S390_MEMOP_SIDA_WRITE 3 /* flags for kvm_s390_mem_op->flags */ #define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0) #define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1) @@ -1010,6 +1016,9 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_ARM_NISV_TO_USER 177 #define KVM_CAP_ARM_INJECT_EXT_DABT 178 #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 @@ -1478,6 +1487,42 @@ struct kvm_enc_region { #define KVM_S390_NORMAL_RESET _IO(KVMIO, 0xc3) #define KVM_S390_CLEAR_RESET _IO(KVMIO, 0xc4) +struct kvm_s390_pv_sec_parm { + __u64 origin; + __u64 length; +}; + +struct kvm_s390_pv_unp { + __u64 addr; + __u64 size; + __u64 tweak; +}; + +enum pv_cmd_id { + KVM_PV_ENABLE, + KVM_PV_DISABLE, + KVM_PV_SET_SEC_PARMS, + KVM_PV_UNPACK, + KVM_PV_VERIFY, + KVM_PV_PREP_RESET, + KVM_PV_UNSHARE_ALL, +}; + +struct kvm_pv_cmd { + __u32 cmd; /* Command to be executed */ + __u16 rc; /* Ultravisor return code */ + __u16 rrc; /* Ultravisor return reason code */ + __u64 data; /* Data or address */ + __u32 flags; /* flags for future extensions. Must be 0 for now */ + __u32 reserved[3]; +}; + +/* 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 */ @@ -1628,4 +1673,55 @@ struct kvm_hyperv_eventfd { #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0) +#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.24.1