From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231406; cv=none; d=zohomail.com; s=zohoarc; b=nD+y3lANFyqFlU2Em4FNt/xJmilzNQFsGXW/dh0QOuFraIXDWauagX81b/X0DXA3CF8GtO/coM/l+F+XEcbs2NTLons8pKe38RWwxetdGG4qQU2w4aj/eKdALgZbY3QkHwjh7O1/LLzdBNwu8FrgaxbIVn+5Ek3xIwSld8vU6cc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231406; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WMu73wym0Gow5akvjboCGHRUYvigv/8DgHoM/En3UyE=; b=Y2Xfq2zMrdKzxnV0bP3uiGUROa5OF5ZwDfXQ+6437p84TGjwTBhqwI3asr+NH4mwNVym3ZdKNcjYZ9cceYcA5x0xPghxe2+K5cLlMBhQLajgbXwqB0BoFfHd62KwhCqkjk36VUCfBUVTnPDpPWCF3IPIVjU9xGY7yVDfaS6YPtM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231406535476.36986876772005; Fri, 4 Sep 2020 07:56:46 -0700 (PDT) Received: from localhost ([::1]:36506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kED8v-0001Yz-0Y for importer@patchew.org; Fri, 04 Sep 2020 10:56:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41116) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED7z-0000MX-6T for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:55:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:47385) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED7w-0007Cn-5u for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:55:46 -0400 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-278-N1oH3JCiN2uSWX-VzwL3cA-1; Fri, 04 Sep 2020 10:54:36 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D45706408E for ; Fri, 4 Sep 2020 14:54:35 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 792307A1F4; Fri, 4 Sep 2020 14:54:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599231343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WMu73wym0Gow5akvjboCGHRUYvigv/8DgHoM/En3UyE=; b=J+raaqGjU6jG6i6uur6S6MAfEuVeyN5emwQ6KJSDalmJg2fGUFOi+2bDl02fEyu9bupEIr ZhG2mDfr5pJuKW9axgrzwt97EhB8D2PjYA2BEp60k6m2I3OFjskwBCR9ajExx8YYLp87SL 9yfLzCrCiZhhXDG+gmw4xRtkgsnOhLo= X-MC-Unique: N1oH3JCiN2uSWX-VzwL3cA-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 01/22] WIP: update linux/headers Date: Fri, 4 Sep 2020 16:54:10 +0200 Message-Id: <20200904145431.196885-2-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 06:46:59 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" KVM_CAP_SYS_HYPERV_CPUID definition is needed for this series. Signed-off-by: Vitaly Kuznetsov --- include/standard-headers/drm/drm_fourcc.h | 140 ++++++++++++++++++ include/standard-headers/linux/ethtool.h | 87 +++++++++++ .../linux/input-event-codes.h | 3 +- linux-headers/asm-generic/unistd.h | 6 +- linux-headers/asm-mips/unistd_n32.h | 1 + linux-headers/asm-mips/unistd_n64.h | 1 + linux-headers/asm-mips/unistd_o32.h | 1 + linux-headers/asm-powerpc/kvm.h | 5 + linux-headers/asm-powerpc/mman.h | 2 +- linux-headers/asm-powerpc/unistd_32.h | 1 + linux-headers/asm-powerpc/unistd_64.h | 1 + linux-headers/asm-s390/kvm.h | 7 +- linux-headers/asm-s390/unistd_32.h | 1 + linux-headers/asm-s390/unistd_64.h | 1 + linux-headers/asm-x86/unistd_32.h | 1 + linux-headers/asm-x86/unistd_64.h | 1 + linux-headers/asm-x86/unistd_x32.h | 1 + linux-headers/linux/kvm.h | 7 +- linux-headers/linux/vfio.h | 2 +- 19 files changed, 261 insertions(+), 8 deletions(-) diff --git a/include/standard-headers/drm/drm_fourcc.h b/include/standard-h= eaders/drm/drm_fourcc.h index 909a66753c03..2757bdf6fa70 100644 --- a/include/standard-headers/drm/drm_fourcc.h +++ b/include/standard-headers/drm/drm_fourcc.h @@ -235,6 +235,12 @@ extern "C" { #define DRM_FORMAT_NV61 fourcc_code('N', 'V', '6', '1') /* 2x1 subsampled= Cb:Cr plane */ #define DRM_FORMAT_NV24 fourcc_code('N', 'V', '2', '4') /* non-subsampled= Cr:Cb plane */ #define DRM_FORMAT_NV42 fourcc_code('N', 'V', '4', '2') /* non-subsampled= Cb:Cr plane */ +/* + * 2 plane YCbCr + * index 0 =3D Y plane, [39:0] Y3:Y2:Y1:Y0 little endian + * index 1 =3D Cr:Cb plane, [39:0] Cr1:Cb1:Cr0:Cb0 little endian + */ +#define DRM_FORMAT_NV15 fourcc_code('N', 'V', '1', '5') /* 2x2 subsampled= Cr:Cb plane */ =20 /* * 2 plane YCbCr MSB aligned @@ -264,6 +270,22 @@ extern "C" { */ #define DRM_FORMAT_P016 fourcc_code('P', '0', '1', '6') /* 2x2 subsampled= Cr:Cb plane 16 bits per channel */ =20 +/* 3 plane non-subsampled (444) YCbCr + * 16 bits per component, but only 10 bits are used and 6 bits are padded + * index 0: Y plane, [15:0] Y:x [10:6] little endian + * index 1: Cb plane, [15:0] Cb:x [10:6] little endian + * index 2: Cr plane, [15:0] Cr:x [10:6] little endian + */ +#define DRM_FORMAT_Q410 fourcc_code('Q', '4', '1', '0') + +/* 3 plane non-subsampled (444) YCrCb + * 16 bits per component, but only 10 bits are used and 6 bits are padded + * index 0: Y plane, [15:0] Y:x [10:6] little endian + * index 1: Cr plane, [15:0] Cr:x [10:6] little endian + * index 2: Cb plane, [15:0] Cb:x [10:6] little endian + */ +#define DRM_FORMAT_Q401 fourcc_code('Q', '4', '0', '1') + /* * 3 plane YCbCr * index 0: Y plane, [7:0] Y @@ -308,6 +330,7 @@ extern "C" { #define DRM_FORMAT_MOD_VENDOR_BROADCOM 0x07 #define DRM_FORMAT_MOD_VENDOR_ARM 0x08 #define DRM_FORMAT_MOD_VENDOR_ALLWINNER 0x09 +#define DRM_FORMAT_MOD_VENDOR_AMLOGIC 0x0a =20 /* add more to the end as needed */ =20 @@ -322,8 +345,33 @@ extern "C" { * When adding a new token please document the layout with a code comment, * similar to the fourcc codes above. drm_fourcc.h is considered the * authoritative source for all of these. + * + * Generic modifier names: + * + * DRM_FORMAT_MOD_GENERIC_* definitions are used to provide vendor-neutral= names + * for layouts which are common across multiple vendors. To preserve + * compatibility, in cases where a vendor-specific definition already exis= ts and + * a generic name for it is desired, the common name is a purely symbolic = alias + * and must use the same numerical value as the original definition. + * + * Note that generic names should only be used for modifiers which describe + * generic layouts (such as pixel re-ordering), which may have + * independently-developed support across multiple vendors. + * + * In future cases where a generic layout is identified before merging wit= h a + * vendor-specific modifier, a new 'GENERIC' vendor or modifier using vend= or + * 'NONE' could be considered. This should only be for obvious, exceptional + * cases to avoid polluting the 'GENERIC' namespace with modifiers which o= nly + * apply to a single vendor. + * + * Generic names should not be used for cases where multiple hardware vend= ors + * have implementations of the same standardised compression scheme (such = as + * AFBC). In those cases, all implementations should use the same format + * modifier(s), reflecting the vendor of the standard. */ =20 +#define DRM_FORMAT_MOD_GENERIC_16_16_TILE DRM_FORMAT_MOD_SAMSUNG_16_16_TILE + /* * Invalid Modifier * @@ -891,6 +939,18 @@ drm_fourcc_canonicalize_nvidia_format_mod(uint64_t mod= ifier) */ #define AFBC_FORMAT_MOD_BCH (1ULL << 11) =20 +/* AFBC uncompressed storage mode + * + * Indicates that the buffer is using AFBC uncompressed storage mode. + * In this mode all superblock payloads in the buffer use the uncompressed + * storage mode, which is usually only used for data which cannot be compr= essed. + * The buffer layout is the same as for AFBC buffers without USM set, this= only + * affects the storage mode of the individual superblocks. Note that even a + * buffer without USM set may use uncompressed storage mode for some or all + * superblocks, USM just guarantees it for all. + */ +#define AFBC_FORMAT_MOD_USM (1ULL << 12) + /* * Arm 16x16 Block U-Interleaved modifier * @@ -915,6 +975,86 @@ drm_fourcc_canonicalize_nvidia_format_mod(uint64_t mod= ifier) */ #define DRM_FORMAT_MOD_ALLWINNER_TILED fourcc_mod_code(ALLWINNER, 1) =20 +/* + * Amlogic Video Framebuffer Compression modifiers + * + * Amlogic uses a proprietary lossless image compression protocol and form= at + * for their hardware video codec accelerators, either video decoders or + * video input encoders. + * + * It considerably reduces memory bandwidth while writing and reading + * frames in memory. + * + * The underlying storage is considered to be 3 components, 8bit or 10-bit + * per component YCbCr 420, single plane : + * - DRM_FORMAT_YUV420_8BIT + * - DRM_FORMAT_YUV420_10BIT + * + * The first 8 bits of the mode defines the layout, then the following 8 b= its + * defines the options changing the layout. + * + * Not all combinations are valid, and different SoCs may support different + * combinations of layout and options. + */ +#define __fourcc_mod_amlogic_layout_mask 0xf +#define __fourcc_mod_amlogic_options_shift 8 +#define __fourcc_mod_amlogic_options_mask 0xf + +#define DRM_FORMAT_MOD_AMLOGIC_FBC(__layout, __options) \ + fourcc_mod_code(AMLOGIC, \ + ((__layout) & __fourcc_mod_amlogic_layout_mask) | \ + ((__options) & __fourcc_mod_amlogic_options_mask \ + << __fourcc_mod_amlogic_options_shift)) + +/* Amlogic FBC Layouts */ + +/* + * Amlogic FBC Basic Layout + * + * The basic layout is composed of: + * - a body content organized in 64x32 superblocks with 4096 bytes per + * superblock in default mode. + * - a 32 bytes per 128x64 header block + * + * This layout is transferrable between Amlogic SoCs supporting this modif= ier. + */ +#define AMLOGIC_FBC_LAYOUT_BASIC (1ULL) + +/* + * Amlogic FBC Scatter Memory layout + * + * Indicates the header contains IOMMU references to the compressed + * frames content to optimize memory access and layout. + * + * In this mode, only the header memory address is needed, thus the + * content memory organization is tied to the current producer + * execution and cannot be saved/dumped neither transferrable between + * Amlogic SoCs supporting this modifier. + * + * Due to the nature of the layout, these buffers are not expected to + * be accessible by the user-space clients, but only accessible by the + * hardware producers and consumers. + * + * The user-space clients should expect a failure while trying to mmap + * the DMA-BUF handle returned by the producer. + */ +#define AMLOGIC_FBC_LAYOUT_SCATTER (2ULL) + +/* Amlogic FBC Layout Options Bit Mask */ + +/* + * Amlogic FBC Memory Saving mode + * + * Indicates the storage is packed when pixel size is multiple of word + * boudaries, i.e. 8bit should be stored in this mode to save allocation + * memory. + * + * This mode reduces body layout to 3072 bytes per 64x32 superblock with + * the basic layout and 3200 bytes per 64x32 superblock combined with + * the scatter layout. + */ +#define AMLOGIC_FBC_OPTION_MEM_SAVING (1ULL << 0) + #if defined(__cplusplus) } #endif diff --git a/include/standard-headers/linux/ethtool.h b/include/standard-he= aders/linux/ethtool.h index fd8d2cccfe89..e13eff44882d 100644 --- a/include/standard-headers/linux/ethtool.h +++ b/include/standard-headers/linux/ethtool.h @@ -579,6 +579,76 @@ struct ethtool_pauseparam { uint32_t tx_pause; }; =20 +/** + * enum ethtool_link_ext_state - link extended state + */ +enum ethtool_link_ext_state { + ETHTOOL_LINK_EXT_STATE_AUTONEG, + ETHTOOL_LINK_EXT_STATE_LINK_TRAINING_FAILURE, + ETHTOOL_LINK_EXT_STATE_LINK_LOGICAL_MISMATCH, + ETHTOOL_LINK_EXT_STATE_BAD_SIGNAL_INTEGRITY, + ETHTOOL_LINK_EXT_STATE_NO_CABLE, + ETHTOOL_LINK_EXT_STATE_CABLE_ISSUE, + ETHTOOL_LINK_EXT_STATE_EEPROM_ISSUE, + ETHTOOL_LINK_EXT_STATE_CALIBRATION_FAILURE, + ETHTOOL_LINK_EXT_STATE_POWER_BUDGET_EXCEEDED, + ETHTOOL_LINK_EXT_STATE_OVERHEAT, +}; + +/** + * enum ethtool_link_ext_substate_autoneg - more information in addition to + * ETHTOOL_LINK_EXT_STATE_AUTONEG. + */ +enum ethtool_link_ext_substate_autoneg { + ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_PARTNER_DETECTED =3D 1, + ETHTOOL_LINK_EXT_SUBSTATE_AN_ACK_NOT_RECEIVED, + ETHTOOL_LINK_EXT_SUBSTATE_AN_NEXT_PAGE_EXCHANGE_FAILED, + ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_PARTNER_DETECTED_FORCE_MODE, + ETHTOOL_LINK_EXT_SUBSTATE_AN_FEC_MISMATCH_DURING_OVERRIDE, + ETHTOOL_LINK_EXT_SUBSTATE_AN_NO_HCD, +}; + +/** + * enum ethtool_link_ext_substate_link_training - more information in addi= tion to + * ETHTOOL_LINK_EXT_STATE_LINK_TRAINING_FAILURE. + */ +enum ethtool_link_ext_substate_link_training { + ETHTOOL_LINK_EXT_SUBSTATE_LT_KR_FRAME_LOCK_NOT_ACQUIRED =3D 1, + ETHTOOL_LINK_EXT_SUBSTATE_LT_KR_LINK_INHIBIT_TIMEOUT, + ETHTOOL_LINK_EXT_SUBSTATE_LT_KR_LINK_PARTNER_DID_NOT_SET_RECEIVER_READY, + ETHTOOL_LINK_EXT_SUBSTATE_LT_REMOTE_FAULT, +}; + +/** + * enum ethtool_link_ext_substate_logical_mismatch - more information in a= ddition + * to ETHTOOL_LINK_EXT_STATE_LINK_LOGICAL_MISMATCH. + */ +enum ethtool_link_ext_substate_link_logical_mismatch { + ETHTOOL_LINK_EXT_SUBSTATE_LLM_PCS_DID_NOT_ACQUIRE_BLOCK_LOCK =3D 1, + ETHTOOL_LINK_EXT_SUBSTATE_LLM_PCS_DID_NOT_ACQUIRE_AM_LOCK, + ETHTOOL_LINK_EXT_SUBSTATE_LLM_PCS_DID_NOT_GET_ALIGN_STATUS, + ETHTOOL_LINK_EXT_SUBSTATE_LLM_FC_FEC_IS_NOT_LOCKED, + ETHTOOL_LINK_EXT_SUBSTATE_LLM_RS_FEC_IS_NOT_LOCKED, +}; + +/** + * enum ethtool_link_ext_substate_bad_signal_integrity - more information = in + * addition to ETHTOOL_LINK_EXT_STATE_BAD_SIGNAL_INTEGRITY. + */ +enum ethtool_link_ext_substate_bad_signal_integrity { + ETHTOOL_LINK_EXT_SUBSTATE_BSI_LARGE_NUMBER_OF_PHYSICAL_ERRORS =3D 1, + ETHTOOL_LINK_EXT_SUBSTATE_BSI_UNSUPPORTED_RATE, +}; + +/** + * enum ethtool_link_ext_substate_cable_issue - more information in + * addition to ETHTOOL_LINK_EXT_STATE_CABLE_ISSUE. + */ +enum ethtool_link_ext_substate_cable_issue { + ETHTOOL_LINK_EXT_SUBSTATE_CI_UNSUPPORTED_CABLE =3D 1, + ETHTOOL_LINK_EXT_SUBSTATE_CI_CABLE_TEST_FAILURE, +}; + #define ETH_GSTRING_LEN 32 =20 /** @@ -599,6 +669,7 @@ struct ethtool_pauseparam { * @ETH_SS_SOF_TIMESTAMPING: SOF_TIMESTAMPING_* flags * @ETH_SS_TS_TX_TYPES: timestamping Tx types * @ETH_SS_TS_RX_FILTERS: timestamping Rx filters + * @ETH_SS_UDP_TUNNEL_TYPES: UDP tunnel types */ enum ethtool_stringset { ETH_SS_TEST =3D 0, @@ -616,6 +687,7 @@ enum ethtool_stringset { ETH_SS_SOF_TIMESTAMPING, ETH_SS_TS_TX_TYPES, ETH_SS_TS_RX_FILTERS, + ETH_SS_UDP_TUNNEL_TYPES, =20 /* add new constants above here */ ETH_SS_COUNT @@ -1530,6 +1602,21 @@ enum ethtool_link_mode_bit_indices { ETHTOOL_LINK_MODE_400000baseDR8_Full_BIT =3D 72, ETHTOOL_LINK_MODE_400000baseCR8_Full_BIT =3D 73, ETHTOOL_LINK_MODE_FEC_LLRS_BIT =3D 74, + ETHTOOL_LINK_MODE_100000baseKR_Full_BIT =3D 75, + ETHTOOL_LINK_MODE_100000baseSR_Full_BIT =3D 76, + ETHTOOL_LINK_MODE_100000baseLR_ER_FR_Full_BIT =3D 77, + ETHTOOL_LINK_MODE_100000baseCR_Full_BIT =3D 78, + ETHTOOL_LINK_MODE_100000baseDR_Full_BIT =3D 79, + ETHTOOL_LINK_MODE_200000baseKR2_Full_BIT =3D 80, + ETHTOOL_LINK_MODE_200000baseSR2_Full_BIT =3D 81, + ETHTOOL_LINK_MODE_200000baseLR2_ER2_FR2_Full_BIT =3D 82, + ETHTOOL_LINK_MODE_200000baseDR2_Full_BIT =3D 83, + ETHTOOL_LINK_MODE_200000baseCR2_Full_BIT =3D 84, + ETHTOOL_LINK_MODE_400000baseKR4_Full_BIT =3D 85, + ETHTOOL_LINK_MODE_400000baseSR4_Full_BIT =3D 86, + ETHTOOL_LINK_MODE_400000baseLR4_ER4_FR4_Full_BIT =3D 87, + ETHTOOL_LINK_MODE_400000baseDR4_Full_BIT =3D 88, + ETHTOOL_LINK_MODE_400000baseCR4_Full_BIT =3D 89, /* must be last entry */ __ETHTOOL_LINK_MODE_MASK_NBITS }; diff --git a/include/standard-headers/linux/input-event-codes.h b/include/s= tandard-headers/linux/input-event-codes.h index ebf72c10317b..e740ad9f2e01 100644 --- a/include/standard-headers/linux/input-event-codes.h +++ b/include/standard-headers/linux/input-event-codes.h @@ -888,7 +888,8 @@ #define SW_LINEIN_INSERT 0x0d /* set =3D inserted */ #define SW_MUTE_DEVICE 0x0e /* set =3D device disabled */ #define SW_PEN_INSERTED 0x0f /* set =3D pen inserted */ -#define SW_MAX_ 0x0f +#define SW_MACHINE_COVER 0x10 /* set =3D cover closed */ +#define SW_MAX_ 0x10 #define SW_CNT (SW_MAX_+1) =20 /* diff --git a/linux-headers/asm-generic/unistd.h b/linux-headers/asm-generic= /unistd.h index f4a01305d9a6..995b36c2ea7d 100644 --- a/linux-headers/asm-generic/unistd.h +++ b/linux-headers/asm-generic/unistd.h @@ -606,9 +606,9 @@ __SYSCALL(__NR_sendto, sys_sendto) #define __NR_recvfrom 207 __SC_COMP(__NR_recvfrom, sys_recvfrom, compat_sys_recvfrom) #define __NR_setsockopt 208 -__SC_COMP(__NR_setsockopt, sys_setsockopt, compat_sys_setsockopt) +__SC_COMP(__NR_setsockopt, sys_setsockopt, sys_setsockopt) #define __NR_getsockopt 209 -__SC_COMP(__NR_getsockopt, sys_getsockopt, compat_sys_getsockopt) +__SC_COMP(__NR_getsockopt, sys_getsockopt, sys_getsockopt) #define __NR_shutdown 210 __SYSCALL(__NR_shutdown, sys_shutdown) #define __NR_sendmsg 211 @@ -850,6 +850,8 @@ __SYSCALL(__NR_pidfd_open, sys_pidfd_open) #define __NR_clone3 435 __SYSCALL(__NR_clone3, sys_clone3) #endif +#define __NR_close_range 436 +__SYSCALL(__NR_close_range, sys_close_range) =20 #define __NR_openat2 437 __SYSCALL(__NR_openat2, sys_openat2) diff --git a/linux-headers/asm-mips/unistd_n32.h b/linux-headers/asm-mips/u= nistd_n32.h index 3b9eda7e7d8f..246fbb6a7885 100644 --- a/linux-headers/asm-mips/unistd_n32.h +++ b/linux-headers/asm-mips/unistd_n32.h @@ -365,6 +365,7 @@ #define __NR_fspick (__NR_Linux + 433) #define __NR_pidfd_open (__NR_Linux + 434) #define __NR_clone3 (__NR_Linux + 435) +#define __NR_close_range (__NR_Linux + 436) #define __NR_openat2 (__NR_Linux + 437) #define __NR_pidfd_getfd (__NR_Linux + 438) #define __NR_faccessat2 (__NR_Linux + 439) diff --git a/linux-headers/asm-mips/unistd_n64.h b/linux-headers/asm-mips/u= nistd_n64.h index 9cdf9b6c60df..194d777dfd42 100644 --- a/linux-headers/asm-mips/unistd_n64.h +++ b/linux-headers/asm-mips/unistd_n64.h @@ -341,6 +341,7 @@ #define __NR_fspick (__NR_Linux + 433) #define __NR_pidfd_open (__NR_Linux + 434) #define __NR_clone3 (__NR_Linux + 435) +#define __NR_close_range (__NR_Linux + 436) #define __NR_openat2 (__NR_Linux + 437) #define __NR_pidfd_getfd (__NR_Linux + 438) #define __NR_faccessat2 (__NR_Linux + 439) diff --git a/linux-headers/asm-mips/unistd_o32.h b/linux-headers/asm-mips/u= nistd_o32.h index e3e5e238f026..3e093dd9134d 100644 --- a/linux-headers/asm-mips/unistd_o32.h +++ b/linux-headers/asm-mips/unistd_o32.h @@ -411,6 +411,7 @@ #define __NR_fspick (__NR_Linux + 433) #define __NR_pidfd_open (__NR_Linux + 434) #define __NR_clone3 (__NR_Linux + 435) +#define __NR_close_range (__NR_Linux + 436) #define __NR_openat2 (__NR_Linux + 437) #define __NR_pidfd_getfd (__NR_Linux + 438) #define __NR_faccessat2 (__NR_Linux + 439) diff --git a/linux-headers/asm-powerpc/kvm.h b/linux-headers/asm-powerpc/kv= m.h index 264e266a85bf..c3af3f324c5a 100644 --- a/linux-headers/asm-powerpc/kvm.h +++ b/linux-headers/asm-powerpc/kvm.h @@ -640,6 +640,11 @@ struct kvm_ppc_cpu_char { #define KVM_REG_PPC_ONLINE (KVM_REG_PPC | KVM_REG_SIZE_U32 | 0xbf) #define KVM_REG_PPC_PTCR (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc0) =20 +/* POWER10 registers */ +#define KVM_REG_PPC_MMCR3 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc1) +#define KVM_REG_PPC_SIER2 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc2) +#define KVM_REG_PPC_SIER3 (KVM_REG_PPC | KVM_REG_SIZE_U64 | 0xc3) + /* Transactional Memory checkpointed state: * This is all GPRs, all VSX regs and a subset of SPRs */ diff --git a/linux-headers/asm-powerpc/mman.h b/linux-headers/asm-powerpc/m= man.h index 8db7c2a3be30..c16840d33bfd 100644 --- a/linux-headers/asm-powerpc/mman.h +++ b/linux-headers/asm-powerpc/mman.h @@ -11,7 +11,7 @@ #include =20 =20 -#define PROT_SAO 0x10 /* Strong Access Ordering */ +#define PROT_SAO 0x10 /* Unsupported since v5.9 */ =20 #define MAP_RENAME MAP_ANONYMOUS /* In SunOS terminology */ #define MAP_NORESERVE 0x40 /* don't reserve swap pages */ diff --git a/linux-headers/asm-powerpc/unistd_32.h b/linux-headers/asm-powe= rpc/unistd_32.h index 862edb7448c5..0db9481d4962 100644 --- a/linux-headers/asm-powerpc/unistd_32.h +++ b/linux-headers/asm-powerpc/unistd_32.h @@ -418,6 +418,7 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 #define __NR_openat2 437 #define __NR_pidfd_getfd 438 #define __NR_faccessat2 439 diff --git a/linux-headers/asm-powerpc/unistd_64.h b/linux-headers/asm-powe= rpc/unistd_64.h index f553224ce408..9f74310988e1 100644 --- a/linux-headers/asm-powerpc/unistd_64.h +++ b/linux-headers/asm-powerpc/unistd_64.h @@ -390,6 +390,7 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 #define __NR_openat2 437 #define __NR_pidfd_getfd 438 #define __NR_faccessat2 439 diff --git a/linux-headers/asm-s390/kvm.h b/linux-headers/asm-s390/kvm.h index 0138ccb0d892..f053b8304a85 100644 --- a/linux-headers/asm-s390/kvm.h +++ b/linux-headers/asm-s390/kvm.h @@ -231,11 +231,13 @@ struct kvm_guest_debug_arch { #define KVM_SYNC_GSCB (1UL << 9) #define KVM_SYNC_BPBC (1UL << 10) #define KVM_SYNC_ETOKEN (1UL << 11) +#define KVM_SYNC_DIAG318 (1UL << 12) =20 #define KVM_SYNC_S390_VALID_FIELDS \ (KVM_SYNC_PREFIX | KVM_SYNC_GPRS | KVM_SYNC_ACRS | KVM_SYNC_CRS | \ KVM_SYNC_ARCH0 | KVM_SYNC_PFAULT | KVM_SYNC_VRS | KVM_SYNC_RICCB | \ - KVM_SYNC_FPRS | KVM_SYNC_GSCB | KVM_SYNC_BPBC | KVM_SYNC_ETOKEN) + KVM_SYNC_FPRS | KVM_SYNC_GSCB | KVM_SYNC_BPBC | KVM_SYNC_ETOKEN | \ + KVM_SYNC_DIAG318) =20 /* length and alignment of the sdnx as a power of two */ #define SDNXC 8 @@ -264,7 +266,8 @@ struct kvm_sync_regs { __u8 reserved2 : 7; __u8 padding1[51]; /* riccb needs to be 64byte aligned */ __u8 riccb[64]; /* runtime instrumentation controls block */ - __u8 padding2[192]; /* sdnx needs to be 256byte aligned */ + __u64 diag318; /* diagnose 0x318 info */ + __u8 padding2[184]; /* sdnx needs to be 256byte aligned */ union { __u8 sdnx[SDNXL]; /* state description annex */ struct { diff --git a/linux-headers/asm-s390/unistd_32.h b/linux-headers/asm-s390/un= istd_32.h index e08233c0c377..1803cd0c3ba6 100644 --- a/linux-headers/asm-s390/unistd_32.h +++ b/linux-headers/asm-s390/unistd_32.h @@ -408,6 +408,7 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 #define __NR_openat2 437 #define __NR_pidfd_getfd 438 #define __NR_faccessat2 439 diff --git a/linux-headers/asm-s390/unistd_64.h b/linux-headers/asm-s390/un= istd_64.h index 560e19ae2bb4..228d5004e5a8 100644 --- a/linux-headers/asm-s390/unistd_64.h +++ b/linux-headers/asm-s390/unistd_64.h @@ -356,6 +356,7 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 #define __NR_openat2 437 #define __NR_pidfd_getfd 438 #define __NR_faccessat2 439 diff --git a/linux-headers/asm-x86/unistd_32.h b/linux-headers/asm-x86/unis= td_32.h index c727981d4a3a..356c12c2dbce 100644 --- a/linux-headers/asm-x86/unistd_32.h +++ b/linux-headers/asm-x86/unistd_32.h @@ -426,6 +426,7 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 #define __NR_openat2 437 #define __NR_pidfd_getfd 438 #define __NR_faccessat2 439 diff --git a/linux-headers/asm-x86/unistd_64.h b/linux-headers/asm-x86/unis= td_64.h index 843fa6274584..ef70e1c7c93f 100644 --- a/linux-headers/asm-x86/unistd_64.h +++ b/linux-headers/asm-x86/unistd_64.h @@ -348,6 +348,7 @@ #define __NR_fspick 433 #define __NR_pidfd_open 434 #define __NR_clone3 435 +#define __NR_close_range 436 #define __NR_openat2 437 #define __NR_pidfd_getfd 438 #define __NR_faccessat2 439 diff --git a/linux-headers/asm-x86/unistd_x32.h b/linux-headers/asm-x86/uni= std_x32.h index 7d63d703cab4..84ae8e9f5fca 100644 --- a/linux-headers/asm-x86/unistd_x32.h +++ b/linux-headers/asm-x86/unistd_x32.h @@ -301,6 +301,7 @@ #define __NR_fspick (__X32_SYSCALL_BIT + 433) #define __NR_pidfd_open (__X32_SYSCALL_BIT + 434) #define __NR_clone3 (__X32_SYSCALL_BIT + 435) +#define __NR_close_range (__X32_SYSCALL_BIT + 436) #define __NR_openat2 (__X32_SYSCALL_BIT + 437) #define __NR_pidfd_getfd (__X32_SYSCALL_BIT + 438) #define __NR_faccessat2 (__X32_SYSCALL_BIT + 439) diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h index a28c3667370b..b4bd05d09135 100644 --- a/linux-headers/linux/kvm.h +++ b/linux-headers/linux/kvm.h @@ -289,6 +289,7 @@ struct kvm_run { /* KVM_EXIT_FAIL_ENTRY */ struct { __u64 hardware_entry_failure_reason; + __u32 cpu; } fail_entry; /* KVM_EXIT_EXCEPTION */ struct { @@ -1031,6 +1032,10 @@ struct kvm_ppc_resize_hpt { #define KVM_CAP_PPC_SECURE_GUEST 181 #define KVM_CAP_HALT_POLL 182 #define KVM_CAP_ASYNC_PF_INT 183 +#define KVM_CAP_LAST_CPU 184 +#define KVM_CAP_SMALLER_MAXPHYADDR 185 +#define KVM_CAP_S390_DIAG318 186 +#define KVM_CAP_SYS_HYPERV_CPUID 187 =20 #ifdef KVM_CAP_IRQ_ROUTING =20 @@ -1489,7 +1494,7 @@ struct kvm_enc_region { /* Available with KVM_CAP_MANUAL_DIRTY_LOG_PROTECT_2 */ #define KVM_CLEAR_DIRTY_LOG _IOWR(KVMIO, 0xc0, struct kvm_clear_d= irty_log) =20 -/* Available with KVM_CAP_HYPERV_CPUID */ +/* Available with KVM_CAP_HYPERV_CPUID (vcpu) / KVM_CAP_SYS_HYPERV_CPUID (= system) */ #define KVM_GET_SUPPORTED_HV_CPUID _IOWR(KVMIO, 0xc1, struct kvm_cpuid2) =20 /* Available with KVM_CAP_ARM_SVE */ diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h index f09df262c4b5..a90672494dc5 100644 --- a/linux-headers/linux/vfio.h +++ b/linux-headers/linux/vfio.h @@ -1030,7 +1030,7 @@ struct vfio_iommu_type1_info_cap_iova_range { * size in bytes that can be used by user applications when getting the di= rty * bitmap. */ -#define VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION 1 +#define VFIO_IOMMU_TYPE1_INFO_CAP_MIGRATION 2 =20 struct vfio_iommu_type1_info_cap_migration { struct vfio_info_cap_header header; --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231891; cv=none; d=zohomail.com; s=zohoarc; b=JOGpKwvfZB/3m+u+JZPYsies1zzOeNmwlhuvjne97FVeosOBnRVjMFeu5+CgGbT4iSJDOLDkbNqr8uVsg1LTaFeu3KvvfPdu2Jbt8FJ99doJKf3qNJPuKh/o+2Xh2s2a74MDV7hzNi5yz7dEGf43zOmg8zl1ivP9lgV5u6xs+3U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231891; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5QSqVYJpPoWVEQLzzzWfWliA4bGo975BBRnDM/wQNGo=; b=e4ePlp+/8RRsKYv5/be+HGoWnDQojZrYAWIagGwCfezlm32M8xbItDOAZP25XMjylDD0s5lna3cXkL7V+NQDCZPl+Modt5iR2LKiLvDJ5j4T/62WE75m949XtbnwPp29UuqDSeaFpEQVgysYr5vtRMja8jU8DYx/4iAPZ8UUeHU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231891266784.2551470185808; Fri, 4 Sep 2020 08:04:51 -0700 (PDT) Received: from localhost ([::1]:43708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDGj-0008D6-IW for importer@patchew.org; Fri, 04 Sep 2020 11:04:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41280) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED8H-0000tt-MV for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:05 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:52256 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED8E-0007E1-C9 for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:05 -0400 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-523-NyzZYUcwNhGm1SiEmqmX1Q-1; Fri, 04 Sep 2020 10:54:38 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5F9121017DC0 for ; Fri, 4 Sep 2020 14:54:37 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F34D7A1F4; Fri, 4 Sep 2020 14:54:36 +0000 (UTC) X-MC-Unique: NyzZYUcwNhGm1SiEmqmX1Q-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 02/22] i386: drop x86_cpu_get_supported_feature_word() forward declaration Date: Fri, 4 Sep 2020 16:54:11 +0200 Message-Id: <20200904145431.196885-3-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 03:57:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We only use x86_cpu_get_supported_feature_word() after its implementation, no forward declaration needed. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 49d89585288d..14489def2177 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -4283,9 +4283,6 @@ void x86_cpu_change_kvm_default(const char *prop, con= st char *value) assert(pv->prop); } =20 -static uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, - bool migratable_only); - static bool lmce_supported(void) { uint64_t mce_cap =3D 0; --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231500; cv=none; d=zohomail.com; s=zohoarc; b=QwqBsK/mmFwbwprPmaRdmLAQdqF4zDLlVbSAgQqYB4UQ9YfssdPoVVbEPwmH2W1JUdICbRBfKXr0hTXoixJ7fyBy+NtTMJCOCww70VF9dGm9et0iLHnHk4RRCC1PDXHE1uHZFvxcNYF+JJToP1HHFCRkGghh90exkd8fbxDavMI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231500; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=R1j58fbN+P75M6Py9JVnizkwxPGW9WRczMd8yOQC698=; b=KR/UWpozuSkDv/n2f8FFsH6DHIgxVHnWrvze/zGC8jSK7OYCZBYQgdvsKrr87UMNr8KFeSjV2YlG2CZ75eG1UlwGge8L27uDcumFK7R/mS6opD1KB6OHF1zKPtS3oe2nRP2wzkDvWeowcZRqBqJGYF38CvfJ0AvmKccF11OY4B8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231500055975.0774808521875; Fri, 4 Sep 2020 07:58:20 -0700 (PDT) Received: from localhost ([::1]:45324 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDAQ-000585-JZ for importer@patchew.org; Fri, 04 Sep 2020 10:58:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41126) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED80-0000Pc-SA for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:55:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39231) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED7z-0007D0-1a for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:55:48 -0400 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-139-zkH7E7V8PRaXWCRcAK3ePg-1; Fri, 04 Sep 2020 10:54:39 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0966C8D327D for ; Fri, 4 Sep 2020 14:54:39 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id AEEA27A1F4; Fri, 4 Sep 2020 14:54:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599231346; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R1j58fbN+P75M6Py9JVnizkwxPGW9WRczMd8yOQC698=; b=Fq+88HsWmU2hvC9aIsW7l5Dkl5QJSFTmg1WZlZ3kZQBvCY0dc5bSEscLVZxbXKH1+ojtSX 0ipRa4UAVhIk5cvhTXDp1UeikqLiEM9I0kJZN7JdWN6TpphMuNwKps/15RwrFOYocC05W1 u+N2pQ9HdNOYa/yweGRCN9wXL4Z+RII= X-MC-Unique: zkH7E7V8PRaXWCRcAK3ePg-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 03/22] i386: move hyperv_vendor_id initialization to x86_cpu_realizefn() Date: Fri, 4 Sep 2020 16:54:12 +0200 Message-Id: <20200904145431.196885-4-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vkuznets@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 06:46:59 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" As a preparation to expanding Hyper-V CPU features early, move hyperv_vendor_id initialization to x86_cpu_realizefn(). Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 15 ++++++++++++++- target/i386/cpu.h | 3 ++- target/i386/kvm.c | 25 ++++++++++--------------- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 14489def2177..07e9da9e567e 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6625,6 +6625,19 @@ static void x86_cpu_realizefn(DeviceState *dev, Erro= r **errp) } } =20 + if (!cpu->hyperv_vendor) { + memcpy(cpu->hyperv_vendor_id, "Microsoft Hv", 12); + } else { + size_t len =3D strlen(cpu->hyperv_vendor); + + if (len > 12) { + warn_report("hv-vendor-id truncated to 12 characters"); + len =3D 12; + } + memset(cpu->hyperv_vendor_id, 0, 12); + memcpy(cpu->hyperv_vendor_id, cpu->hyperv_vendor, len); + } + if (cpu->ucode_rev =3D=3D 0) { /* The default is the same as KVM's. */ if (IS_AMD_CPU(env)) { @@ -7313,7 +7326,7 @@ static Property x86_cpu_properties[] =3D { DEFINE_PROP_UINT32("min-xlevel2", X86CPU, env.cpuid_min_xlevel2, 0), DEFINE_PROP_UINT64("ucode-rev", X86CPU, ucode_rev, 0), DEFINE_PROP_BOOL("full-cpuid-auto-level", X86CPU, full_cpuid_auto_leve= l, true), - DEFINE_PROP_STRING("hv-vendor-id", X86CPU, hyperv_vendor_id), + DEFINE_PROP_STRING("hv-vendor-id", X86CPU, hyperv_vendor), DEFINE_PROP_BOOL("cpuid-0xb", X86CPU, enable_cpuid_0xb, true), DEFINE_PROP_BOOL("lmce", X86CPU, enable_lmce, false), DEFINE_PROP_BOOL("l3-cache", X86CPU, enable_l3_cache, true), diff --git a/target/i386/cpu.h b/target/i386/cpu.h index d3097be6a50a..903994818093 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1654,11 +1654,12 @@ struct X86CPU { uint64_t ucode_rev; =20 uint32_t hyperv_spinlock_attempts; - char *hyperv_vendor_id; + char *hyperv_vendor; bool hyperv_synic_kvm_only; uint64_t hyperv_features; bool hyperv_passthrough; OnOffAuto hyperv_no_nonarch_cs; + uint32_t hyperv_vendor_id[3]; =20 bool check_cpuid; bool enforce_cpuid; diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 205b68bc0ce8..47779c5e1efd 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1225,6 +1225,13 @@ static int hyperv_handle_properties(CPUState *cs, memcpy(cpuid_ent, &cpuid->entries[0], cpuid->nent * sizeof(cpuid->entries[0])); =20 + c =3D cpuid_find_entry(cpuid, HV_CPUID_VENDOR_AND_MAX_FUNCTIONS, 0= ); + if (c) { + cpu->hyperv_vendor_id[0] =3D c->ebx; + cpu->hyperv_vendor_id[1] =3D c->ecx; + cpu->hyperv_vendor_id[2] =3D c->edx; + } + c =3D cpuid_find_entry(cpuid, HV_CPUID_FEATURES, 0); if (c) { env->features[FEAT_HYPERV_EAX] =3D c->eax; @@ -1299,23 +1306,11 @@ static int hyperv_handle_properties(CPUState *cs, =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_VENDOR_AND_MAX_FUNCTIONS; - if (!cpu->hyperv_vendor_id) { - memcpy(signature, "Microsoft Hv", 12); - } else { - size_t len =3D strlen(cpu->hyperv_vendor_id); - - if (len > 12) { - error_report("hv-vendor-id truncated to 12 characters"); - len =3D 12; - } - memset(signature, 0, 12); - memcpy(signature, cpu->hyperv_vendor_id, len); - } c->eax =3D hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS) ? HV_CPUID_NESTED_FEATURES : HV_CPUID_IMPLEMENT_LIMITS; - c->ebx =3D signature[0]; - c->ecx =3D signature[1]; - c->edx =3D signature[2]; + c->ebx =3D cpu->hyperv_vendor_id[0]; + c->ecx =3D cpu->hyperv_vendor_id[1]; + c->edx =3D cpu->hyperv_vendor_id[2]; =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_INTERFACE; --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231584; cv=none; d=zohomail.com; s=zohoarc; b=DMD0WiSGBCWKCE8g2ZJFfng84zt1PuVC1pTb/p49uWx+KQBo0oFsQTxH3SFWns8cU8vawDspCFQnPRwy2DaghxBs+5UfQlflzboA+k1hcoQZHn/Pmja+v0X7ur5wEgPRe+17Ayvby3WZkQXN5SzX55A6UJcJ2sehFIH2+MDuHWA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231584; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VUoqjAqzCkzOwJPI6RPWCQKNVsV4ET0FkbNM68Cuoyo=; b=OJUhf+OjTqpI74LlbiNcbOA8zAwapgHnCgYmpb5/14GSaLMLOXEYwQmk4Wo5IjMeLOCe1fR28X9ZXglJ8/zmOXLVhb/ZLJBLQBr5YJCgHl+xmcxu/hjMqIcy/c0GmpIOHx17MJi2Kb8V9+Uy+B+bcYWR8r9MS/XikfXcX1AJ3gw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231584350254.74655358440418; Fri, 4 Sep 2020 07:59:44 -0700 (PDT) Received: from localhost ([::1]:52654 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDBm-00084b-Th for importer@patchew.org; Fri, 04 Sep 2020 10:59:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED83-0000U7-No for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:55:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:48795) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED82-0007DC-2J for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:55:51 -0400 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-79-DTdPiY_RM_qLf4M9ZS8ikA-1; Fri, 04 Sep 2020 10:54:41 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D74FF18BA285 for ; Fri, 4 Sep 2020 14:54:40 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 645977A1F4; Fri, 4 Sep 2020 14:54:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599231349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=VUoqjAqzCkzOwJPI6RPWCQKNVsV4ET0FkbNM68Cuoyo=; b=FmQk2RPSjHD+VKPwTptkZDxKq1WrSFTPEBGJAmRXVeDmOa2YM3aTTQfFPjwaz5KwFND55O iRNZ57YpmNwtjMHvsYpygy4fwygh6rBGrs7ujd2crljmGqbvJSCH1VrckuCpiap9Ik3Prm ZlqybYG+YqCrkBYw4hl5QW+xyx1nEw4= X-MC-Unique: DTdPiY_RM_qLf4M9ZS8ikA-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 04/22] i386: move hyperv_interface_id initialization to x86_cpu_realizefn() Date: Fri, 4 Sep 2020 16:54:13 +0200 Message-Id: <20200904145431.196885-5-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vkuznets@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 06:46:59 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" As a preparation to expanding Hyper-V CPU features early, move hyperv_interface_id initialization to x86_cpu_realizefn(). Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 6 ++++++ target/i386/cpu.h | 1 + target/i386/kvm.c | 18 ++++++++++++------ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 07e9da9e567e..16888125a30a 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6638,6 +6638,12 @@ static void x86_cpu_realizefn(DeviceState *dev, Erro= r **errp) memcpy(cpu->hyperv_vendor_id, cpu->hyperv_vendor, len); } =20 + /* 'Hv#1' interface identification*/ + cpu->hyperv_interface_id[0] =3D 0x31237648; + cpu->hyperv_interface_id[1] =3D 0; + cpu->hyperv_interface_id[2] =3D 0; + cpu->hyperv_interface_id[3] =3D 0; + if (cpu->ucode_rev =3D=3D 0) { /* The default is the same as KVM's. */ if (IS_AMD_CPU(env)) { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 903994818093..91edc54a268c 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1660,6 +1660,7 @@ struct X86CPU { bool hyperv_passthrough; OnOffAuto hyperv_no_nonarch_cs; uint32_t hyperv_vendor_id[3]; + uint32_t hyperv_interface_id[4]; =20 bool check_cpuid; bool enforce_cpuid; diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 47779c5e1efd..a36c65100cd0 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1188,7 +1188,6 @@ static int hyperv_handle_properties(CPUState *cs, CPUX86State *env =3D &cpu->env; struct kvm_cpuid2 *cpuid; struct kvm_cpuid_entry2 *c; - uint32_t signature[3]; uint32_t cpuid_i =3D 0; int r; =20 @@ -1232,6 +1231,14 @@ static int hyperv_handle_properties(CPUState *cs, cpu->hyperv_vendor_id[2] =3D c->edx; } =20 + c =3D cpuid_find_entry(cpuid, HV_CPUID_INTERFACE, 0); + if (c) { + cpu->hyperv_interface_id[0] =3D c->eax; + cpu->hyperv_interface_id[1] =3D c->ebx; + cpu->hyperv_interface_id[2] =3D c->ecx; + cpu->hyperv_interface_id[3] =3D c->edx; + } + c =3D cpuid_find_entry(cpuid, HV_CPUID_FEATURES, 0); if (c) { env->features[FEAT_HYPERV_EAX] =3D c->eax; @@ -1314,11 +1321,10 @@ static int hyperv_handle_properties(CPUState *cs, =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_INTERFACE; - memcpy(signature, "Hv#1\0\0\0\0\0\0\0\0", 12); - c->eax =3D signature[0]; - c->ebx =3D 0; - c->ecx =3D 0; - c->edx =3D 0; + c->eax =3D cpu->hyperv_interface_id[0]; + c->ebx =3D cpu->hyperv_interface_id[1]; + c->ecx =3D cpu->hyperv_interface_id[2]; + c->edx =3D cpu->hyperv_interface_id[3]; =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_VERSION; --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231798; cv=none; d=zohomail.com; s=zohoarc; b=L67YvOk9IDUr5ORxSa9z4JwcM74ZQYJwfbQVuxkmEiAPJwul50wj7jpplBT2hEDk1pR2fc/gcXM6fkzuRn/ilZaP8zCtoEapi5+Gr94XmqC/Ap+yAagq0R04FP+c2ui0SOF6+AyJeMEyTVPloznKUt1ruYDEfaHGs4+SsOuHTg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231798; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=H/FznvTWST6Zizl1NDdfsC8zFPZhgLS/+JbZ8BVcW1A=; b=LTEvFI2TqMOcuBjJHG5Qd/Zu4t2ZnUf5qI3PCVz8o9bmqktv683QS3irJxDnPFPsJhIinAiXRvPQE/7R3l5/5ZHmBFZ0QOfFwe5CChgQF9vAmHTHyjGUBwREiAWUAQH8SaJEP8QjPOHFLHhJ0SFvVlNgwlPAmV0ZCpdQOt3qq68= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231798974276.3755575980273; Fri, 4 Sep 2020 08:03:18 -0700 (PDT) Received: from localhost ([::1]:37502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDFF-0005JK-DJ for importer@patchew.org; Fri, 04 Sep 2020 11:03:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41276) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED8H-0000tV-HK for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:05 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:51253 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED8D-0007Dn-Ql for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:05 -0400 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-38-QYIsYuIaM0O86e4oCghf1Q-1; Fri, 04 Sep 2020 10:54:43 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B15808D3289 for ; Fri, 4 Sep 2020 14:54:42 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41BD07A1F4; Fri, 4 Sep 2020 14:54:41 +0000 (UTC) X-MC-Unique: QYIsYuIaM0O86e4oCghf1Q-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 05/22] i386: move hyperv_version_id initialization to x86_cpu_realizefn() Date: Fri, 4 Sep 2020 16:54:14 +0200 Message-Id: <20200904145431.196885-6-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vkuznets@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=vkuznets@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 03:58:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" As a preparation to expanding Hyper-V CPU features early, move hyperv_version_id initialization to x86_cpu_realizefn(). Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 4 ++++ target/i386/cpu.h | 1 + target/i386/kvm.c | 14 ++++++++++++-- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 16888125a30a..e605399eb8c0 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6644,6 +6644,10 @@ static void x86_cpu_realizefn(DeviceState *dev, Erro= r **errp) cpu->hyperv_interface_id[2] =3D 0; cpu->hyperv_interface_id[3] =3D 0; =20 + /* Hypervisor system identity */ + cpu->hyperv_version_id[0] =3D 0x00001bbc; + cpu->hyperv_version_id[1] =3D 0x00060001; + if (cpu->ucode_rev =3D=3D 0) { /* The default is the same as KVM's. */ if (IS_AMD_CPU(env)) { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 91edc54a268c..2630ffd2d4b2 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1661,6 +1661,7 @@ struct X86CPU { OnOffAuto hyperv_no_nonarch_cs; uint32_t hyperv_vendor_id[3]; uint32_t hyperv_interface_id[4]; + uint32_t hyperv_version_id[4]; =20 bool check_cpuid; bool enforce_cpuid; diff --git a/target/i386/kvm.c b/target/i386/kvm.c index a36c65100cd0..169bae2779a4 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1239,6 +1239,14 @@ static int hyperv_handle_properties(CPUState *cs, cpu->hyperv_interface_id[3] =3D c->edx; } =20 + c =3D cpuid_find_entry(cpuid, HV_CPUID_VERSION, 0); + if (c) { + cpu->hyperv_version_id[0] =3D c->eax; + cpu->hyperv_version_id[1] =3D c->ebx; + cpu->hyperv_version_id[2] =3D c->ecx; + cpu->hyperv_version_id[3] =3D c->edx; + } + c =3D cpuid_find_entry(cpuid, HV_CPUID_FEATURES, 0); if (c) { env->features[FEAT_HYPERV_EAX] =3D c->eax; @@ -1328,8 +1336,10 @@ static int hyperv_handle_properties(CPUState *cs, =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_VERSION; - c->eax =3D 0x00001bbc; - c->ebx =3D 0x00060001; + c->eax =3D cpu->hyperv_version_id[0]; + c->ebx =3D cpu->hyperv_version_id[1]; + c->ecx =3D cpu->hyperv_version_id[2]; + c->edx =3D cpu->hyperv_version_id[3]; =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_FEATURES; --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231417; cv=none; d=zohomail.com; s=zohoarc; b=ThborrdTIGhnDYZ5dsP1acXPrk7tZ+//5T6m7cqlKZx1V88JCU3ev0S4rk9+42doSH+FG4feoPyvsB4slx70ouk+j3Xl7VNR8jEMX1Bwd6zfAmO0gI2B7aNxSW8JDKzm4wqZ9miYikwKMqpNJMqV1UhRXuweATHGq4HIdkQk69o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231417; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=d9gcAG3gSaY3RVMD0x4eMnRQ/MdejmF6c4XVicOjz2M=; b=ciJapwnmtfjsC0pDSwO4v+9q6onH40MNo3fL5bADMSqsG8+l0jHbk5/wGblAU5hc495rQyysxMQKLHQvel4ipMEbF/1x2PAVH2sLf1CqDBnHZCbr0LNI4T+tewkJTvSd0sICkK/bRQm2HeNkpEuE/lDntrgz+higyZQL80VzLzs= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231417552516.3301947375294; Fri, 4 Sep 2020 07:56:57 -0700 (PDT) Received: from localhost ([::1]:37964 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kED96-0002B7-6y for importer@patchew.org; Fri, 04 Sep 2020 10:56:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41180) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED8C-0000jI-Me for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:00 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:23871 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED8A-0007Da-RL for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:00 -0400 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-533-EoRsuv_DMCGyaHXgzGJK7A-1; Fri, 04 Sep 2020 10:54:45 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A379E1017DC1 for ; Fri, 4 Sep 2020 14:54:44 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3497D7E416; Fri, 4 Sep 2020 14:54:42 +0000 (UTC) X-MC-Unique: EoRsuv_DMCGyaHXgzGJK7A-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 06/22] i386: move hyperv_limits initialization to x86_cpu_realizefn() Date: Fri, 4 Sep 2020 16:54:15 +0200 Message-Id: <20200904145431.196885-7-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 01:57:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" As a preparation to expanding Hyper-V CPU features early, move hyperv_limits initialization to x86_cpu_realizefn(). Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 5 +++++ target/i386/cpu.h | 1 + target/i386/kvm.c | 13 ++++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index e605399eb8c0..ef3c672cf415 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6648,6 +6648,11 @@ static void x86_cpu_realizefn(DeviceState *dev, Erro= r **errp) cpu->hyperv_version_id[0] =3D 0x00001bbc; cpu->hyperv_version_id[1] =3D 0x00060001; =20 + /* Hypervisor implementation limits */ + cpu->hyperv_limits[0] =3D 64; + cpu->hyperv_limits[1] =3D 0; + cpu->hyperv_limits[2] =3D 0; + if (cpu->ucode_rev =3D=3D 0) { /* The default is the same as KVM's. */ if (IS_AMD_CPU(env)) { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 2630ffd2d4b2..095d0bf75493 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1662,6 +1662,7 @@ struct X86CPU { uint32_t hyperv_vendor_id[3]; uint32_t hyperv_interface_id[4]; uint32_t hyperv_version_id[4]; + uint32_t hyperv_limits[3]; =20 bool check_cpuid; bool enforce_cpuid; diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 169bae2779a4..720c30e9df17 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1253,6 +1253,15 @@ static int hyperv_handle_properties(CPUState *cs, env->features[FEAT_HYPERV_EBX] =3D c->ebx; env->features[FEAT_HYPERV_EDX] =3D c->eax; } + + c =3D cpuid_find_entry(cpuid, HV_CPUID_IMPLEMENT_LIMITS, 0); + if (c) { + cpu->hv_max_vps =3D c->eax; + cpu->hyperv_limits[0] =3D c->ebx; + cpu->hyperv_limits[1] =3D c->ecx; + cpu->hyperv_limits[2] =3D c->edx; + } + c =3D cpuid_find_entry(cpuid, HV_CPUID_ENLIGHTMENT_INFO, 0); if (c) { env->features[FEAT_HV_RECOMM_EAX] =3D c->eax; @@ -1355,7 +1364,9 @@ static int hyperv_handle_properties(CPUState *cs, c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_IMPLEMENT_LIMITS; c->eax =3D cpu->hv_max_vps; - c->ebx =3D 0x40; + c->ebx =3D cpu->hyperv_limits[0]; + c->ecx =3D cpu->hyperv_limits[1]; + c->edx =3D cpu->hyperv_limits[2]; =20 if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS)) { __u32 function; --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231506; cv=none; d=zohomail.com; s=zohoarc; b=eUw4uVS25MDYVAaCq2ITJoCreL/YnoS8o04GFaVTs2LqUyKmySCMr99pK9U3OVd7ThJ30J1ntg3qepCq6daD43Co9zotwYiua+3twu73fql5UoOkplK7WH6Thu6+jfaVT6LrMfNS7F4fKL6XrIvzLE2wVqTx+MHqXcgdpUTQSPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231506; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SWjPXhcxIZUjC60C67S4Z9OKGeZn8o/9kGgirwPVcLo=; b=B6f4tKunTzNvv3c+KBCfeG0lzJU2Cp1xA/Ei82VimheMnWeEhuNdAD+JQ9EMH9LdZ6T3+wBEXVDoWOpuyHlE5dLFANF9/UZ0Jz9aTHLK5YIrChkl8Mqg3QH1JPr1gufdxqy6meOFf0r5YeePjo+XuYYcFmrYI9drdACpW3s7uj8= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15992315063268.257153059152984; Fri, 4 Sep 2020 07:58:26 -0700 (PDT) Received: from localhost ([::1]:46200 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDAX-0005UD-41 for importer@patchew.org; Fri, 04 Sep 2020 10:58:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41220) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED8F-0000oY-GB for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:03 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:37200 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED8D-0007Dl-JK for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:03 -0400 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-438-H0m7vYsDN1-9StuJrOLbfg-1; Fri, 04 Sep 2020 10:54:47 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9F05080B70F for ; Fri, 4 Sep 2020 14:54:46 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 272697A1F4; Fri, 4 Sep 2020 14:54:44 +0000 (UTC) X-MC-Unique: H0m7vYsDN1-9StuJrOLbfg-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 07/22] i386: fill in FEAT_HYPERV_EDX from edx instead of eax Date: Fri, 4 Sep 2020 16:54:16 +0200 Message-Id: <20200904145431.196885-8-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 03:57:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" There was a typo which went unnoticed. Fixes: e48ddcc6ce13 ("i386/kvm: implement 'hv-passthrough' mode") Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 720c30e9df17..1cb5592d4f7d 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1251,7 +1251,7 @@ static int hyperv_handle_properties(CPUState *cs, if (c) { env->features[FEAT_HYPERV_EAX] =3D c->eax; env->features[FEAT_HYPERV_EBX] =3D c->ebx; - env->features[FEAT_HYPERV_EDX] =3D c->eax; + env->features[FEAT_HYPERV_EDX] =3D c->edx; } =20 c =3D cpuid_find_entry(cpuid, HV_CPUID_IMPLEMENT_LIMITS, 0); --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231697; cv=none; d=zohomail.com; s=zohoarc; b=dXLYOflh85GGXAwXm+o48mul5J3rSvDH+G89Pwu/Fx1BNld2c8BB7lNK68NqtyY+qYmSSgT6DbZQSJ1JD7rNpFWR6Nkf0KFGYgQA7/4ZfW+aUCM7WXhZq6BgpRobn2bnxHCPPibTc+p0nZ1ZrAwOcoPpiZOjDFQk3OLe5jCPWFs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231697; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=u++KFsYvTGGQegCll+4FxyIlR9Pbv1ao6nnI6qS+z7A=; b=dBQR5zTK23ExcEZpY7rf5URW62sm7U1iv2UfR4MDped5Icv5KVQ06OK7hmIkRaWxWr8wvbO+41k7p0fBpdmgP+zuWpanKlJKwMZEzKOI7vTzfEZ+SODWAcydJvDJ/rmK+7yk5T0MJvknfSss0Xq1a1M1vjrOSVi2N0RT8Rnm5Jc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 159923169754152.64648554786322; Fri, 4 Sep 2020 08:01:37 -0700 (PDT) Received: from localhost ([::1]:59358 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDDb-0002ZE-Hu for importer@patchew.org; Fri, 04 Sep 2020 11:01:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41270) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED8H-0000t1-AA for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:05 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:26131 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED8E-0007Dt-6Q for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:05 -0400 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-428-75y9-7LAPZ2v8dDOmMd64w-1; Fri, 04 Sep 2020 10:54:49 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C189B8D3289 for ; Fri, 4 Sep 2020 14:54:48 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3326B7A1F4; Fri, 4 Sep 2020 14:54:47 +0000 (UTC) X-MC-Unique: 75y9-7LAPZ2v8dDOmMd64w-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 08/22] i386: invert hyperv_spinlock_attempts setting logic with hv_passthrough Date: Fri, 4 Sep 2020 16:54:17 +0200 Message-Id: <20200904145431.196885-9-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 03:57:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" There is no need to have this special case: like all other Hyper-V enlightenments we can just use kernel's supplied value in hv_passthrough mode. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 1cb5592d4f7d..96ac719adca1 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1265,11 +1265,7 @@ static int hyperv_handle_properties(CPUState *cs, c =3D cpuid_find_entry(cpuid, HV_CPUID_ENLIGHTMENT_INFO, 0); if (c) { env->features[FEAT_HV_RECOMM_EAX] =3D c->eax; - - /* hv-spinlocks may have been overriden */ - if (cpu->hyperv_spinlock_attempts !=3D HYPERV_SPINLOCK_NEVER_R= ETRY) { - c->ebx =3D cpu->hyperv_spinlock_attempts; - } + cpu->hyperv_spinlock_attempts =3D c->ebx; } c =3D cpuid_find_entry(cpuid, HV_CPUID_NESTED_FEATURES, 0); if (c) { --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231635; cv=none; d=zohomail.com; s=zohoarc; b=A5DNHpGxWrtqeVO1f1KdlL9gPRCMgOyQioeljug+na/V+KtaCyDYXMPDOgKBeNTVivw0OkKmbHHh0psrfgQRBnLAyrCciSu2qCO41PKk8mLFkrsFx6Rf1hf8FxtfhtJ8exCcmso0HZxlYxK44/091fUsQciPZg4AH6ZBIKLMXv8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231635; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=crBhg4rg8HFJNd0PLO478Ru1NLH9evheK9rAm9Qj1Mc=; b=I4bvGi8sH31/umn2e8HOUkLrlYUBUAFhy/2CInRdUdiil+SBomm8g18fiYh0o2x7LPQtVRyYl13BCm4ra2qfiaRYows8i7rp9amDf4BsPLTgqzlraFSdl4jdGxWx8jiulFaJL8sCIJtHZi51PMK47MTkc/9EWMYkkaFZ9O5TnVc= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231635775193.84461957467397; Fri, 4 Sep 2020 08:00:35 -0700 (PDT) Received: from localhost ([::1]:55950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDCW-0000xx-O4 for importer@patchew.org; Fri, 04 Sep 2020 11:00:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED8I-0000vk-Bj for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:06 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:39306 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED8E-0007Du-5v for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:06 -0400 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-389-JJKWu44JMwyMKWi8R7gmKA-1; Fri, 04 Sep 2020 10:54:51 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 822D31084D62 for ; Fri, 4 Sep 2020 14:54:50 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25D3A7E416; Fri, 4 Sep 2020 14:54:48 +0000 (UTC) X-MC-Unique: JJKWu44JMwyMKWi8R7gmKA-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 09/22] i386: add reserved FEAT_HYPERV_ECX CPUID leaf Date: Fri, 4 Sep 2020 16:54:18 +0200 Message-Id: <20200904145431.196885-10-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=vkuznets@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 03:58:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" As a preparation to expanding Hyper-V CPU features early, add reserved FEAT_HYPERV_ECX CPUID leaf. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 5 +++++ target/i386/cpu.h | 1 + target/i386/kvm.c | 2 ++ 3 files changed, 8 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index ef3c672cf415..70588571ccb1 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -974,6 +974,11 @@ static FeatureWordInfo feature_word_info[FEATURE_WORDS= ] =3D { }, .cpuid =3D { .eax =3D 0x40000003, .reg =3D R_EBX, }, }, + [FEAT_HYPERV_ECX] =3D { + .type =3D CPUID_FEATURE_WORD, + /* reserved */ + .cpuid =3D { .eax =3D 0x40000003, .reg =3D R_ECX, }, + }, [FEAT_HYPERV_EDX] =3D { .type =3D CPUID_FEATURE_WORD, .feat_names =3D { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 095d0bf75493..39e0e89aa41f 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -521,6 +521,7 @@ typedef enum FeatureWord { FEAT_KVM_HINTS, /* CPUID[4000_0001].EDX */ FEAT_HYPERV_EAX, /* CPUID[4000_0003].EAX */ FEAT_HYPERV_EBX, /* CPUID[4000_0003].EBX */ + FEAT_HYPERV_ECX, /* CPUID[4000_0003].ECX */ FEAT_HYPERV_EDX, /* CPUID[4000_0003].EDX */ FEAT_HV_RECOMM_EAX, /* CPUID[4000_0004].EAX */ FEAT_HV_NESTED_EAX, /* CPUID[4000_000A].EAX */ diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 96ac719adca1..259be2d514dd 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1251,6 +1251,7 @@ static int hyperv_handle_properties(CPUState *cs, if (c) { env->features[FEAT_HYPERV_EAX] =3D c->eax; env->features[FEAT_HYPERV_EBX] =3D c->ebx; + env->features[FEAT_HYPERV_ECX] =3D c->ecx; env->features[FEAT_HYPERV_EDX] =3D c->edx; } =20 @@ -1350,6 +1351,7 @@ static int hyperv_handle_properties(CPUState *cs, c->function =3D HV_CPUID_FEATURES; c->eax =3D env->features[FEAT_HYPERV_EAX]; c->ebx =3D env->features[FEAT_HYPERV_EBX]; + c->ecx =3D env->features[FEAT_HYPERV_ECX]; c->edx =3D env->features[FEAT_HYPERV_EDX]; =20 c =3D &cpuid_ent[cpuid_i++]; --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231721; cv=none; d=zohomail.com; s=zohoarc; b=HGnsoTwdL4vTa82UOPjTssMvIijAK8yI9iB23dq+9BLRa3YXzfRHOaj011OzKXnptCoJM+JGqPJ4L6jlWKTRUphqffI4V+7NMNHQ5kH1Yma+8yc+FvlJDNYpRNShAA5q8xPUzAor6mLqvstAWu8/4+cpbVMnjzISVTW6WYmEFIQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231721; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WJGDZQq5T/PCZn1QYsoPugSeSzEGszG7lsfpLe62ZFc=; b=lGNzx/UoPfWAdA0ZuSplhFXcG7mv1EuFYSD9zpVm2+CzzcMkA9vkhmlMiXBTqIHMlTfZ7PcvXHfn6D4nJfxrQajW23zhR+HKuhaOpH8aIngCFCZcU0wd9ZEVg74+5HrXQ7PIBX0GvkphZdpl08ms3a0TLGCKeDEo3lt0AmMMghk= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231721813478.9871351795939; Fri, 4 Sep 2020 08:02:01 -0700 (PDT) Received: from localhost ([::1]:60796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDDz-0003C1-TY for importer@patchew.org; Fri, 04 Sep 2020 11:01:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41260) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED8G-0000rl-Pu for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:04 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:33409 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED8E-0007E2-Ap for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:04 -0400 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-346-M6o4meO-Mn-bAiiyl1Y6mQ-1; Fri, 04 Sep 2020 10:54:53 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 55F548D3287 for ; Fri, 4 Sep 2020 14:54:52 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id DAA437E416; Fri, 4 Sep 2020 14:54:50 +0000 (UTC) X-MC-Unique: M6o4meO-Mn-bAiiyl1Y6mQ-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 10/22] i386: add reserved FEAT_HV_RECOMM_ECX/FEAT_HV_RECOMM_EDX CPUID leaves Date: Fri, 4 Sep 2020 16:54:19 +0200 Message-Id: <20200904145431.196885-11-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 03:57:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" As a preparation to expanding Hyper-V CPU features early, add reserved FEAT_HV_RECOMM_ECX/FEAT_HV_RECOMM_EDX CPUID leaves. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 10 ++++++++++ target/i386/cpu.h | 2 ++ target/i386/kvm.c | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 70588571ccb1..3665f22093e9 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1021,6 +1021,16 @@ static FeatureWordInfo feature_word_info[FEATURE_WOR= DS] =3D { }, .cpuid =3D { .eax =3D 0x40000004, .reg =3D R_EAX, }, }, + [FEAT_HV_RECOMM_ECX] =3D { + .type =3D CPUID_FEATURE_WORD, + /* reserved */ + .cpuid =3D { .eax =3D 0x40000004, .reg =3D R_ECX, }, + }, + [FEAT_HV_RECOMM_EDX] =3D { + .type =3D CPUID_FEATURE_WORD, + /* reserved */ + .cpuid =3D { .eax =3D 0x40000004, .reg =3D R_EDX, }, + }, [FEAT_HV_NESTED_EAX] =3D { .type =3D CPUID_FEATURE_WORD, .cpuid =3D { .eax =3D 0x4000000A, .reg =3D R_EAX, }, diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 39e0e89aa41f..0668fe74df4f 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -524,6 +524,8 @@ typedef enum FeatureWord { FEAT_HYPERV_ECX, /* CPUID[4000_0003].ECX */ FEAT_HYPERV_EDX, /* CPUID[4000_0003].EDX */ FEAT_HV_RECOMM_EAX, /* CPUID[4000_0004].EAX */ + FEAT_HV_RECOMM_ECX, /* CPUID[4000_0004].ECX */ + FEAT_HV_RECOMM_EDX, /* CPUID[4000_0004].EDX */ FEAT_HV_NESTED_EAX, /* CPUID[4000_000A].EAX */ FEAT_SVM, /* CPUID[8000_000A].EDX */ FEAT_XSAVE, /* CPUID[EAX=3D0xd,ECX=3D1].EAX */ diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 259be2d514dd..c18f221cd301 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1267,7 +1267,10 @@ static int hyperv_handle_properties(CPUState *cs, if (c) { env->features[FEAT_HV_RECOMM_EAX] =3D c->eax; cpu->hyperv_spinlock_attempts =3D c->ebx; + env->features[FEAT_HV_RECOMM_ECX] =3D c->ecx; + env->features[FEAT_HV_RECOMM_EDX] =3D c->edx; } + c =3D cpuid_find_entry(cpuid, HV_CPUID_NESTED_FEATURES, 0); if (c) { env->features[FEAT_HV_NESTED_EAX] =3D c->eax; @@ -1358,6 +1361,8 @@ static int hyperv_handle_properties(CPUState *cs, c->function =3D HV_CPUID_ENLIGHTMENT_INFO; c->eax =3D env->features[FEAT_HV_RECOMM_EAX]; c->ebx =3D cpu->hyperv_spinlock_attempts; + c->ecx =3D env->features[FEAT_HV_RECOMM_ECX]; + c->edx =3D env->features[FEAT_HV_RECOMM_EDX]; =20 c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_IMPLEMENT_LIMITS; --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231598; cv=none; d=zohomail.com; s=zohoarc; b=hQR4wVkSDzC+3rfEcoR7jPZdPegqlIwdQmYOdfIVSIaUKQb0KS6hQeXX7n2xQ3ML1A9NkBuetR8pTREAZ12sMXnLOKruCpoUNTTzKj8/Q4zZ32WHn+g9+ITphiqiXsh34Q+JnLfrAMMwKndvpESmDI4zJhY3GXlstkbuhY2Thwg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231598; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=EJaA8+NmorZsbhCkvkIm/fNDPNgoVlNN4owknRbS5ag=; b=fjZAsULuJgbDrsNbP6obNLBVt+d69N6tP3A7gj9/UEzGZMr2Pz3rXNqP9Yzh23OmA7Cg+CT2dqJXBUMs+Cd+zEkjDQ3UG2R44d5DrF17L11xFxPQE25uV3hsKRItf6SDayu0ZpdXbjvkky+gWDk+VUmq2eZR5/BUaK7g3z1O0W0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231598166528.7426923044054; Fri, 4 Sep 2020 07:59:58 -0700 (PDT) Received: from localhost ([::1]:54190 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDC0-0000Ft-R1 for importer@patchew.org; Fri, 04 Sep 2020 10:59:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41254) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED8G-0000r9-FW for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:52076) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED8E-0007Dz-CI for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:04 -0400 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-333-287JcF02NjCQqC9zHO-A0g-1; Fri, 04 Sep 2020 10:54:55 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4C4CD1017DC0 for ; Fri, 4 Sep 2020 14:54:54 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id B45157A1F4; Fri, 4 Sep 2020 14:54:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599231361; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=EJaA8+NmorZsbhCkvkIm/fNDPNgoVlNN4owknRbS5ag=; b=dpbD0LidMfA/UAU6VeIJzftvO5ov37qDg6NFhJl5AUi1ke7wesIaoVZW56WoBkOe70OJdX y5cE/fEQcKDXEdrzKltMI2EOqz1Y17yPwZOHrd0jeT0clyW4JtOWkfrpBVZSmByexfGRmL bTcVuELJnt1xAokr+ZIu6F5ks+G+1b0= X-MC-Unique: 287JcF02NjCQqC9zHO-A0g-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 11/22] i386: add reserved FEAT_HV_NESTED_EBX/ECX/EDX CPUID leaves Date: Fri, 4 Sep 2020 16:54:20 +0200 Message-Id: <20200904145431.196885-12-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 06:46:59 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" As a preparation to expanding Hyper-V CPU features early, add reserved FEAT_HV_NESTED_EBX/ECX/EDX CPUID leaves. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 15 +++++++++++++++ target/i386/cpu.h | 3 +++ target/i386/kvm.c | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 3665f22093e9..479c4bbbf459 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -1035,6 +1035,21 @@ static FeatureWordInfo feature_word_info[FEATURE_WOR= DS] =3D { .type =3D CPUID_FEATURE_WORD, .cpuid =3D { .eax =3D 0x4000000A, .reg =3D R_EAX, }, }, + [FEAT_HV_NESTED_EBX] =3D { + .type =3D CPUID_FEATURE_WORD, + /* reserved */ + .cpuid =3D { .eax =3D 0x4000000A, .reg =3D R_EBX, }, + }, + [FEAT_HV_NESTED_ECX] =3D { + .type =3D CPUID_FEATURE_WORD, + /* reserved */ + .cpuid =3D { .eax =3D 0x4000000A, .reg =3D R_ECX, }, + }, + [FEAT_HV_NESTED_EDX] =3D { + .type =3D CPUID_FEATURE_WORD, + /* reserved */ + .cpuid =3D { .eax =3D 0x4000000A, .reg =3D R_EDX, }, + }, [FEAT_SVM] =3D { .type =3D CPUID_FEATURE_WORD, .feat_names =3D { diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 0668fe74df4f..0aad60e0c707 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -527,6 +527,9 @@ typedef enum FeatureWord { FEAT_HV_RECOMM_ECX, /* CPUID[4000_0004].ECX */ FEAT_HV_RECOMM_EDX, /* CPUID[4000_0004].EDX */ FEAT_HV_NESTED_EAX, /* CPUID[4000_000A].EAX */ + FEAT_HV_NESTED_EBX, /* CPUID[4000_000A].EBX */ + FEAT_HV_NESTED_ECX, /* CPUID[4000_000A].ECX */ + FEAT_HV_NESTED_EDX, /* CPUID[4000_000A].EDX */ FEAT_SVM, /* CPUID[8000_000A].EDX */ FEAT_XSAVE, /* CPUID[EAX=3D0xd,ECX=3D1].EAX */ FEAT_6_EAX, /* CPUID[6].EAX */ diff --git a/target/i386/kvm.c b/target/i386/kvm.c index c18f221cd301..87b83a2aa2cb 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1274,6 +1274,9 @@ static int hyperv_handle_properties(CPUState *cs, c =3D cpuid_find_entry(cpuid, HV_CPUID_NESTED_FEATURES, 0); if (c) { env->features[FEAT_HV_NESTED_EAX] =3D c->eax; + env->features[FEAT_HV_NESTED_EBX] =3D c->ebx; + env->features[FEAT_HV_NESTED_ECX] =3D c->ecx; + env->features[FEAT_HV_NESTED_EDX] =3D c->edx; } } =20 @@ -1384,6 +1387,9 @@ static int hyperv_handle_properties(CPUState *cs, c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_NESTED_FEATURES; c->eax =3D env->features[FEAT_HV_NESTED_EAX]; + c->ebx =3D env->features[FEAT_HV_NESTED_EBX]; + c->ecx =3D env->features[FEAT_HV_NESTED_ECX]; + c->edx =3D env->features[FEAT_HV_NESTED_EDX]; } r =3D cpuid_i; =20 --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231814; cv=none; d=zohomail.com; s=zohoarc; b=NL8yPDO0dHYGrn2V36WGTBo9v+l0AcE7NhIIBWyAp2v4kCg9QqH30r/YzNyQ7MGchhs6b9L/z9zTSPOw5AgpQBsTZkhfUqt7RCCxYZLCPcd2bPbXDY/JoUuoLj8GoKHrPfY3kP3tIOIjdJ5r+rIIKIyM9qa3kuYXnXTyrnX6vwk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231814; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iUUbFEURxqT1aBT6XS3DxGWb8STdS+32NMsgCh8TfOo=; b=EMU0S6+BVa7AzDjWKjAe1McMMTklgbP7mSrBPgKkGiVv+wMHYlyRMYeHZXz4wN6IT5N9QENqrjKo3ekCzLZmfyBqeVyCzfUJABjjDHBcHUkF4wuazEq1dZLfgiDM4vxyk0l/BvUPFRSQqkGoHv/dzvtva619A03BVhmPpjwCwAo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231814361212.14279393588663; Fri, 4 Sep 2020 08:03:34 -0700 (PDT) Received: from localhost ([::1]:38866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDFU-0005ti-DJ for importer@patchew.org; Fri, 04 Sep 2020 11:03:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41314) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED8K-00010W-9x for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:08 -0400 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:29060 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED8G-0007Ec-JP for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:07 -0400 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-145-v0gl_LOIO02kxjU2HmFvSA-1; Fri, 04 Sep 2020 10:54:57 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2825B1084D62 for ; Fri, 4 Sep 2020 14:54:56 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC9097A1F4; Fri, 4 Sep 2020 14:54:54 +0000 (UTC) X-MC-Unique: v0gl_LOIO02kxjU2HmFvSA-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 12/22] i386: always fill Hyper-V CPUID feature leaves from X86CPU data Date: Fri, 4 Sep 2020 16:54:21 +0200 Message-Id: <20200904145431.196885-13-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 03:57:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" We have all the required data in X86CPU already and as we are about to split hyperv_handle_properties() into hyperv_expand_features()/ hyperv_fill_cpuids() we can remove the blind copy. The functional change is that QEMU won't pass CPUID leaves it doesn't currently know about to the guest but arguably this is a good change. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 87b83a2aa2cb..b7f0e200a75f 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1221,9 +1221,6 @@ static int hyperv_handle_properties(CPUState *cs, } =20 if (cpu->hyperv_passthrough) { - memcpy(cpuid_ent, &cpuid->entries[0], - cpuid->nent * sizeof(cpuid->entries[0])); - c =3D cpuid_find_entry(cpuid, HV_CPUID_VENDOR_AND_MAX_FUNCTIONS, 0= ); if (c) { cpu->hyperv_vendor_id[0] =3D c->ebx; @@ -1325,12 +1322,6 @@ static int hyperv_handle_properties(CPUState *cs, goto free; } =20 - if (cpu->hyperv_passthrough) { - /* We already copied all feature words from KVM as is */ - r =3D cpuid->nent; - goto free; - } - c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_VENDOR_AND_MAX_FUNCTIONS; c->eax =3D hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS) ? --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231741; cv=none; d=zohomail.com; s=zohoarc; b=IAQn2VtifuP1yEGJzhBOipLMkQw4WxhiP4K04A/g9E9siDB3e03xKawMmA6cB1pie6UkZbT0Wci2d0rnUkpSIPpYkSu2RWa+rZhX7wE3oDTcxoGPc6uVgTl/modruZNUxyVMMlq6sQBntRh5PcKvOLYgYM8JRM624DFZVGL9rMM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231741; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Az1du3JCrghqz5La7KS/d39N5VGhqTVFrD4qXzeZQ04=; b=U9UKIC1mqw3xuDlhwsvicDdn7RDBtmRreo2Ngkhxs2oqhb2vI65aEXEXqS4j1sNQYHyonc0Opn7lznzub7iGx761PckOrSFDS0iYnDhZqffdn1dw3nVMorPkxAdHPatuJy3IVV1zeAljFu/zbUyeiHxNmsbTpub1vwz87BJtNaw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231741699851.3367222929921; Fri, 4 Sep 2020 08:02:21 -0700 (PDT) Received: from localhost ([::1]:34164 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDEK-0003rb-0E for importer@patchew.org; Fri, 04 Sep 2020 11:02:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41328) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED8K-000128-U1 for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:08 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:24060 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED8I-0007EZ-RO for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:08 -0400 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-236-nhJe5k4SOZKr4CmO_P87GQ-1; Fri, 04 Sep 2020 10:54:59 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 46CA78D327D for ; Fri, 4 Sep 2020 14:54:58 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E8F07A1F4; Fri, 4 Sep 2020 14:54:56 +0000 (UTC) X-MC-Unique: nhJe5k4SOZKr4CmO_P87GQ-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 13/22] i386: split hyperv_handle_properties() into hyperv_expand_features()/hyperv_fill_cpuids() Date: Fri, 4 Sep 2020 16:54:22 +0200 Message-Id: <20200904145431.196885-14-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=vkuznets@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 01:57:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The intention is to call hyperv_expand_features() early, before vCPUs are created and use the acquired data later when we set guest visible CPUID data. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm.c | 45 +++++++++++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index b7f0e200a75f..c4bb147090a9 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1177,18 +1177,18 @@ static int hv_cpuid_check_and_set(CPUState *cs, str= uct kvm_cpuid2 *cpuid, } =20 /* - * Fill in Hyper-V CPUIDs. Returns the number of entries filled in cpuid_e= nt in - * case of success, errno < 0 in case of failure and 0 when no Hyper-V - * extentions are enabled. + * Expand Hyper-V CPU features. In partucular, check that all the requested + * features are supported by the host and the sanity of the configuration + * (that all the required dependencies are included). Also, this takes care + * of 'hv_passthrough' mode and fills the environment with all supported + * Hyper-V features. */ -static int hyperv_handle_properties(CPUState *cs, - struct kvm_cpuid_entry2 *cpuid_ent) +static int hyperv_expand_features(CPUState *cs) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; struct kvm_cpuid2 *cpuid; struct kvm_cpuid_entry2 *c; - uint32_t cpuid_i =3D 0; int r; =20 if (!hyperv_enabled(cpu)) @@ -1317,11 +1317,26 @@ static int hyperv_handle_properties(CPUState *cs, /* Not exposed by KVM but needed to make CPU hotplug in Windows work */ env->features[FEAT_HYPERV_EDX] |=3D HV_CPU_DYNAMIC_PARTITIONING_AVAILA= BLE; =20 + g_free(cpuid); + if (r) { - r =3D -ENOSYS; - goto free; + return -ENOSYS; } =20 + return 0; +} + +/* + * Fill in Hyper-V CPUIDs. Returns the number of entries filled in cpuid_e= nt. + */ +static int hyperv_fill_cpuids(CPUState *cs, + struct kvm_cpuid_entry2 *cpuid_ent) +{ + X86CPU *cpu =3D X86_CPU(cs); + CPUX86State *env =3D &cpu->env; + struct kvm_cpuid_entry2 *c; + uint32_t cpuid_i =3D 0; + c =3D &cpuid_ent[cpuid_i++]; c->function =3D HV_CPUID_VENDOR_AND_MAX_FUNCTIONS; c->eax =3D hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS) ? @@ -1382,12 +1397,8 @@ static int hyperv_handle_properties(CPUState *cs, c->ecx =3D env->features[FEAT_HV_NESTED_ECX]; c->edx =3D env->features[FEAT_HV_NESTED_EDX]; } - r =3D cpuid_i; =20 -free: - g_free(cpuid); - - return r; + return cpuid_i; } =20 static Error *hv_passthrough_mig_blocker; @@ -1529,11 +1540,13 @@ int kvm_arch_init_vcpu(CPUState *cs) env->apic_bus_freq =3D KVM_APIC_BUS_FREQUENCY; =20 /* Paravirtualization CPUIDs */ - r =3D hyperv_handle_properties(cs, cpuid_data.entries); + r =3D hyperv_expand_features(cs); if (r < 0) { return r; - } else if (r > 0) { - cpuid_i =3D r; + } + + if (hyperv_enabled(cpu)) { + cpuid_i =3D hyperv_fill_cpuids(cs, cpuid_data.entries); kvm_base =3D KVM_CPUID_SIGNATURE_NEXT; has_msr_hv_hypercall =3D true; } --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231402; cv=none; d=zohomail.com; s=zohoarc; b=EIw6An4bOdhgZS4u3K3mMp0DQAXA0Ecvsg+Fego3U2X9+JRfFRrpiltOSPcISNJiaFlYnhh7Zn8EoVixLsOursyjbJWLwYkN640dCKxvrhXGd+UrHX3H1hh/JkwfNTFMfmKToOGKAnstnZq6lN9k450UlcnhBYzjeDhgDYGaV5Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231402; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=u98WHXPms9o7itT+x5vaiVz7L91dBe8qi1maATjGJHw=; b=gcCu7PXAyR3o014sI9Tfai1bIZhnS/cw4vcsU7VUFiHx54U3kUZyEKMNPN8RK7gcSJb+mj2GweFm2wBMHqtG0FJD3zjj7OsApT90D0599dYPsH/VRSqsvJ2kRBS/nU5qLkjQxyROniTrcgC8NHKHr4WcFSmHNdIbMd4qs4JV3f0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231402151699.910027429669; Fri, 4 Sep 2020 07:56:42 -0700 (PDT) Received: from localhost ([::1]:36112 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kED8q-0001Ov-OA for importer@patchew.org; Fri, 04 Sep 2020 10:56:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41088) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED7w-0000LS-61 for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:55:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:20711) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED7r-0007CS-8D for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:55:42 -0400 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-28-PWCX_l4pMbWO1HxW7fqLtA-1; Fri, 04 Sep 2020 10:55:01 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 57D4A80EDA5 for ; Fri, 4 Sep 2020 14:55:00 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id B00567A1F4; Fri, 4 Sep 2020 14:54:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599231337; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u98WHXPms9o7itT+x5vaiVz7L91dBe8qi1maATjGJHw=; b=Dfk5y8r6wr13mQO6wKBhpJYvppqP7rVmpd+AUZvw3fyi12mxJuYcDHlS6j3TSE6fag0g+9 FFWk4V2pS38JuGnUq1fxYfLxVmG7r5H5iwYUATWSS38WOIiHiPoX2atFkPZyvvzhvKOq0h 5y5cQWdGFCd7GkBVWCfU4SATKIws/sA= X-MC-Unique: PWCX_l4pMbWO1HxW7fqLtA-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 14/22] i386: move eVMCS enablement to hyperv_init_vcpu() Date: Fri, 4 Sep 2020 16:54:23 +0200 Message-Id: <20200904145431.196885-15-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=vkuznets@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=63.128.21.124; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 06:46:59 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" hyperv_expand_features() will be called before we create vCPU so evmcs enablement should go away. hyperv_init_vcpu() looks like the right place. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm.c | 63 ++++++++++++++++++++++++++++------------------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index c4bb147090a9..2e9ceafa2421 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -974,6 +974,7 @@ static struct kvm_cpuid2 *get_supported_hv_cpuid(CPUSta= te *cs) { struct kvm_cpuid2 *cpuid; int max =3D 7; /* 0x40000000..0x40000005, 0x4000000A */ + int i; =20 /* * When the buffer is too small, KVM_GET_SUPPORTED_HV_CPUID fails with @@ -983,6 +984,22 @@ static struct kvm_cpuid2 *get_supported_hv_cpuid(CPUSt= ate *cs) while ((cpuid =3D try_get_hv_cpuid(cs, max)) =3D=3D NULL) { max++; } + + /* + * KVM_GET_SUPPORTED_HV_CPUID does not set EVMCS CPUID bit before + * KVM_CAP_HYPERV_ENLIGHTENED_VMCS is enabled but we want to get the + * information early, just check for the capability and set the bit + * manually. + */ + if (kvm_check_extension(cs->kvm_state, + KVM_CAP_HYPERV_ENLIGHTENED_VMCS) > 0) { + for (i =3D 0; i < cpuid->nent; i++) { + if (cpuid->entries[i].function =3D=3D HV_CPUID_ENLIGHTMENT_INF= O) { + cpuid->entries[i].eax |=3D HV_ENLIGHTENED_VMCS_RECOMMENDED; + } + } + } + return cpuid; } =20 @@ -1194,26 +1211,6 @@ static int hyperv_expand_features(CPUState *cs) if (!hyperv_enabled(cpu)) return 0; =20 - if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS) || - cpu->hyperv_passthrough) { - uint16_t evmcs_version; - - r =3D kvm_vcpu_enable_cap(cs, KVM_CAP_HYPERV_ENLIGHTENED_VMCS, 0, - (uintptr_t)&evmcs_version); - - if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS) && r) { - fprintf(stderr, "Hyper-V %s is not supported by kernel\n", - kvm_hyperv_properties[HYPERV_FEAT_EVMCS].desc); - return -ENOSYS; - } - - if (!r) { - env->features[FEAT_HV_RECOMM_EAX] |=3D - HV_ENLIGHTENED_VMCS_RECOMMENDED; - env->features[FEAT_HV_NESTED_EAX] =3D evmcs_version; - } - } - if (kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV_CPUID) > 0) { cpuid =3D get_supported_hv_cpuid(cs); } else { @@ -1407,6 +1404,7 @@ static Error *hv_no_nonarch_cs_mig_blocker; static int hyperv_init_vcpu(X86CPU *cpu) { CPUState *cs =3D CPU(cpu); + CPUX86State *env =3D &cpu->env; Error *local_err =3D NULL; int ret; =20 @@ -1482,6 +1480,21 @@ static int hyperv_init_vcpu(X86CPU *cpu) } } =20 + if (hyperv_feat_enabled(cpu, HYPERV_FEAT_EVMCS)) { + uint16_t evmcs_version; + + ret =3D kvm_vcpu_enable_cap(cs, KVM_CAP_HYPERV_ENLIGHTENED_VMCS, 0, + (uintptr_t)&evmcs_version); + + if (ret < 0) { + fprintf(stderr, "Hyper-V %s is not supported by kernel\n", + kvm_hyperv_properties[HYPERV_FEAT_EVMCS].desc); + return ret; + } + + env->features[FEAT_HV_NESTED_EAX] =3D evmcs_version; + } + return 0; } =20 @@ -1546,6 +1559,11 @@ int kvm_arch_init_vcpu(CPUState *cs) } =20 if (hyperv_enabled(cpu)) { + r =3D hyperv_init_vcpu(cpu); + if (r) { + return r; + } + cpuid_i =3D hyperv_fill_cpuids(cs, cpuid_data.entries); kvm_base =3D KVM_CPUID_SIGNATURE_NEXT; has_msr_hv_hypercall =3D true; @@ -1892,11 +1910,6 @@ int kvm_arch_init_vcpu(CPUState *cs) =20 kvm_init_msrs(cpu); =20 - r =3D hyperv_init_vcpu(cpu); - if (r) { - goto fail; - } - return 0; =20 fail: --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231849; cv=none; d=zohomail.com; s=zohoarc; b=bOOt5HQFKLBrydd4iddjHo08IFwEf4wRi6FHVjyyPhXt/v3PthmsyGreICP7BJohxJ3eifhDDI0vmmI4ec+tGmLyja3bHxRw9T0UwJ9WpwDlemaWbqp+CSA9QJ5g60Pj6npdLVsw/obGKETxxNQsGPJXdtmo/sWlXx8nknZrZgA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231849; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eE4PzcLFpd+UKefwOCI3MFb1JZpE/X0cuJeWciy1YLo=; b=VbYkZKPV6QzyqXvR+lCLCSUekbjYraEyF/c/lA+yjDTPwXqsNeHkPQr9S2KkLxKBcFJZsFJCUogAQHwdO8upsc8g6rlRUjI+rDUTWkXZAZvtXyqqSSWUVe2reNyLT30ARX1Dx3PCeSnwwfdY/g5hRj97Zwqx3KqgG8nHJUcm6rY= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231849646900.689964867393; Fri, 4 Sep 2020 08:04:09 -0700 (PDT) Received: from localhost ([::1]:40584 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDG3-0006cc-QI for importer@patchew.org; Fri, 04 Sep 2020 11:04:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41358) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED8O-0001BD-P3 for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:12 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:59165 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED8M-0007FL-Mq for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:12 -0400 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-546-vNIoLyMIPk6mQxmVfq-9UA-1; Fri, 04 Sep 2020 10:55:03 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id C72588D327D for ; Fri, 4 Sep 2020 14:55:02 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id CF8647E416; Fri, 4 Sep 2020 14:55:00 +0000 (UTC) X-MC-Unique: vNIoLyMIPk6mQxmVfq-9UA-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 15/22] i386: switch hyperv_expand_features() to using error_setg() Date: Fri, 4 Sep 2020 16:54:24 +0200 Message-Id: <20200904145431.196885-16-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=vkuznets@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 03:58:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Use standard error_setg() mechanism in hyperv_expand_features(). Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm.c | 96 +++++++++++++++++++++++++++++++---------------- 1 file changed, 64 insertions(+), 32 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 2e9ceafa2421..760b93091fea 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1139,7 +1139,7 @@ static int hv_cpuid_get_fw(struct kvm_cpuid2 *cpuid, = int fw, uint32_t *r) } =20 static int hv_cpuid_check_and_set(CPUState *cs, struct kvm_cpuid2 *cpuid, - int feature) + int feature, Error **errp) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; @@ -1155,11 +1155,10 @@ static int hv_cpuid_check_and_set(CPUState *cs, str= uct kvm_cpuid2 *cpuid, while (deps) { dep_feat =3D ctz64(deps); if (!(hyperv_feat_enabled(cpu, dep_feat))) { - fprintf(stderr, - "Hyper-V %s requires Hyper-V %s\n", - kvm_hyperv_properties[feature].desc, - kvm_hyperv_properties[dep_feat].desc); - return 1; + error_setg(errp, "Hyper-V %s requires Hyper-V %s", + kvm_hyperv_properties[feature].desc, + kvm_hyperv_properties[dep_feat].desc); + return 1; } deps &=3D ~(1ull << dep_feat); } @@ -1174,9 +1173,8 @@ static int hv_cpuid_check_and_set(CPUState *cs, struc= t kvm_cpuid2 *cpuid, =20 if (hv_cpuid_get_fw(cpuid, fw, &r) || (r & bits) !=3D bits) { if (hyperv_feat_enabled(cpu, feature)) { - fprintf(stderr, - "Hyper-V %s is not supported by kernel\n", - kvm_hyperv_properties[feature].desc); + error_setg(errp, "Hyper-V %s is not supported by kernel", + kvm_hyperv_properties[feature].desc); return 1; } else { return 0; @@ -1200,13 +1198,13 @@ static int hv_cpuid_check_and_set(CPUState *cs, str= uct kvm_cpuid2 *cpuid, * of 'hv_passthrough' mode and fills the environment with all supported * Hyper-V features. */ -static int hyperv_expand_features(CPUState *cs) +static int hyperv_expand_features(CPUState *cs, Error **errp) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; struct kvm_cpuid2 *cpuid; struct kvm_cpuid_entry2 *c; - int r; + int r =3D 1; =20 if (!hyperv_enabled(cpu)) return 0; @@ -1285,34 +1283,67 @@ static int hyperv_expand_features(CPUState *cs) } =20 /* Features */ - r =3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_RELAXED); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_VAPIC); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_TIME); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_CRASH); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_RESET); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_VPINDEX); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_RUNTIME); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_SYNIC); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_STIMER); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_FREQUENCIES); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_REENLIGHTENMENT); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_TLBFLUSH); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_EVMCS); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_IPI); - r |=3D hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_STIMER_DIRECT); + if (hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_RELAXED, errp)) { + goto out; + } + if (hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_VAPIC, errp)) { + goto out; + } + if (hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_TIME, errp)) { + goto out; + } + if (hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_CRASH, errp)) { + goto out; + } + if (hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_RESET, errp)) { + goto out; + } + if (hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_VPINDEX, errp)) { + goto out; + } + if (hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_RUNTIME, errp)) { + goto out; + } + if (hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_SYNIC, errp)) { + goto out; + } + if (hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_STIMER, errp)) { + goto out; + } + if (hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_FREQUENCIES, errp)) { + goto out; + } + if (hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_REENLIGHTENMENT, err= p)) { + goto out; + } + if (hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_TLBFLUSH, errp)) { + goto out; + } + if (hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_EVMCS, errp)) { + goto out; + } + if (hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_IPI, errp)) { + goto out; + } + if (hv_cpuid_check_and_set(cs, cpuid, HYPERV_FEAT_STIMER_DIRECT, errp)= ) { + goto out; + } =20 /* Additional dependencies not covered by kvm_hyperv_properties[] */ if (hyperv_feat_enabled(cpu, HYPERV_FEAT_SYNIC) && !cpu->hyperv_synic_kvm_only && !hyperv_feat_enabled(cpu, HYPERV_FEAT_VPINDEX)) { - fprintf(stderr, "Hyper-V %s requires Hyper-V %s\n", - kvm_hyperv_properties[HYPERV_FEAT_SYNIC].desc, - kvm_hyperv_properties[HYPERV_FEAT_VPINDEX].desc); - r |=3D 1; + error_setg(errp, "Hyper-V %s requires Hyper-V %s", + kvm_hyperv_properties[HYPERV_FEAT_SYNIC].desc, + kvm_hyperv_properties[HYPERV_FEAT_VPINDEX].desc); + goto out; } =20 /* Not exposed by KVM but needed to make CPU hotplug in Windows work */ env->features[FEAT_HYPERV_EDX] |=3D HV_CPU_DYNAMIC_PARTITIONING_AVAILA= BLE; + r =3D 0; + +out: =20 g_free(cpuid); =20 @@ -1553,8 +1584,9 @@ int kvm_arch_init_vcpu(CPUState *cs) env->apic_bus_freq =3D KVM_APIC_BUS_FREQUENCY; =20 /* Paravirtualization CPUIDs */ - r =3D hyperv_expand_features(cs); - if (r < 0) { + r =3D hyperv_expand_features(cs, &local_err); + if (local_err) { + error_report_err(local_err); return r; } =20 --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599232031; cv=none; d=zohomail.com; s=zohoarc; b=I9T3eKLziEYse8zY7MnoSF6c78reDkKPWCH63oUXzsPpaXhBJ4BHQrQc2o/Za8oj0MGYrvFsS5tllFZUU2MPCw3vuTiuD5nKITMYCBBcyMGQtlDwpuTq0ql72vVZI0+lC7ExbQzdR8yi3oyJ2yo8Md/PKaGZjX0iHV5SSc2GbAo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599232031; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p2GniblDvSGOkpovtp+zu6Bg/ifpp2V/+cGiGGH7mBo=; b=HQFvOAXfMbdtcRKOm9n6WuLU++LdVgFNlZbldCBd3AsGHTNU9fB9GNIdrfX07mXXIX1Yk6/csy98ORn8FoMJHtEDMlSwtmeacJSs6vJwQH0k/LJPhXIOmQs9aCygAUJpR+KksaC8URMErvbFWRKtCNPmvkMeLw+R/riilx3BLOw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599232031016476.05066098519603; Fri, 4 Sep 2020 08:07:11 -0700 (PDT) Received: from localhost ([::1]:53856 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDIz-0003zM-1o for importer@patchew.org; Fri, 04 Sep 2020 11:07:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41606) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED9D-00038w-VM for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:57:03 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:30505 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED9C-0007Iv-17 for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:57:03 -0400 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-463-7jkfCmtzOam0Su_QhUH-uw-1; Fri, 04 Sep 2020 10:55:06 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A36F118BA285 for ; Fri, 4 Sep 2020 14:55:04 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D0CE7E416; Fri, 4 Sep 2020 14:55:02 +0000 (UTC) X-MC-Unique: 7jkfCmtzOam0Su_QhUH-uw-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 16/22] i386: make hyperv_expand_features() return void Date: Fri, 4 Sep 2020 16:54:25 +0200 Message-Id: <20200904145431.196885-17-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=vkuznets@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 01:57:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" As hyperv_expand_features() now uses standard error_setg() mechanism we can make it return void. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 760b93091fea..cb35f759acaa 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1198,16 +1198,15 @@ static int hv_cpuid_check_and_set(CPUState *cs, str= uct kvm_cpuid2 *cpuid, * of 'hv_passthrough' mode and fills the environment with all supported * Hyper-V features. */ -static int hyperv_expand_features(CPUState *cs, Error **errp) +static void hyperv_expand_features(CPUState *cs, Error **errp) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; struct kvm_cpuid2 *cpuid; struct kvm_cpuid_entry2 *c; - int r =3D 1; =20 if (!hyperv_enabled(cpu)) - return 0; + return; =20 if (kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV_CPUID) > 0) { cpuid =3D get_supported_hv_cpuid(cs); @@ -1341,17 +1340,12 @@ static int hyperv_expand_features(CPUState *cs, Err= or **errp) =20 /* Not exposed by KVM but needed to make CPU hotplug in Windows work */ env->features[FEAT_HYPERV_EDX] |=3D HV_CPU_DYNAMIC_PARTITIONING_AVAILA= BLE; - r =3D 0; =20 out: =20 g_free(cpuid); =20 - if (r) { - return -ENOSYS; - } - - return 0; + return; } =20 /* @@ -1584,10 +1578,10 @@ int kvm_arch_init_vcpu(CPUState *cs) env->apic_bus_freq =3D KVM_APIC_BUS_FREQUENCY; =20 /* Paravirtualization CPUIDs */ - r =3D hyperv_expand_features(cs, &local_err); + hyperv_expand_features(cs, &local_err); if (local_err) { error_report_err(local_err); - return r; + return -ENOSYS; } =20 if (hyperv_enabled(cpu)) { --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231950; cv=none; d=zohomail.com; s=zohoarc; b=LKznaJDVeyyw3sB5SDD1nonViE0B9wTIQNUHiRnXXFiEvApFm1x3YqgDMfNzPE08CZgz4fEP6OLLUUB3bdwkWtkLfL3iiRN1d7kMRAqotzsYT6mloY5dA/BHmKVDOtkBFnn7cpwyDXZKMsf9NAa7Y6XmcCRk2dJVTReNwKRNt4w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231950; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=hQG5sf5jay5YZsBV0gjGnBxDX6jV7+xhROPTBvGN4t4=; b=TMH8f/8OSuAWMz1CQvFRjiWRd6V8fmmczTSI58qCdTTJyDmwXQtRxTvqcXqJi4xHalLfIIlWXlUkGYTP/Vsxy2K4KBZWeYBGB3CLb5PJO6KiVVA/6+v3+WtWAF+mgO8uEg5OOJxEFX6Gsd7GshGNUqAb1TJfqtKDuNtHw6Bxv1w= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231950552590.4715167099482; Fri, 4 Sep 2020 08:05:50 -0700 (PDT) Received: from localhost ([::1]:46984 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDHe-00017z-5D for importer@patchew.org; Fri, 04 Sep 2020 11:05:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED9D-00038f-To for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:57:03 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:24985 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED9C-0007Iw-0c for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:57:03 -0400 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-274-wigy_MJvOWmHK8lnoIaMfg-1; Fri, 04 Sep 2020 10:55:07 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id A7DDF80ED9A for ; Fri, 4 Sep 2020 14:55:06 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F9E27A1F4; Fri, 4 Sep 2020 14:55:04 +0000 (UTC) X-MC-Unique: wigy_MJvOWmHK8lnoIaMfg-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 17/22] i386: adjust the expected KVM_GET_SUPPORTED_HV_CPUID array size Date: Fri, 4 Sep 2020 16:54:26 +0200 Message-Id: <20200904145431.196885-18-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.61; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 01:57:11 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" SYNDBG leaves were recently (Linux-5.8) added to KVM but we haven't updated the expected size of KVM_GET_SUPPORTED_HV_CPUID output in KVM so we now make serveral tries before succeeding. Update the default. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index cb35f759acaa..70db2ca26313 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -973,7 +973,8 @@ static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs= , int max) static struct kvm_cpuid2 *get_supported_hv_cpuid(CPUState *cs) { struct kvm_cpuid2 *cpuid; - int max =3D 7; /* 0x40000000..0x40000005, 0x4000000A */ + /* 0x40000000..0x40000005, 0x4000000A, 0x40000080..0x40000080 leaves */ + int max =3D 10; int i; =20 /* --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231441; cv=none; d=zohomail.com; s=zohoarc; b=Jyh1pZiU9K1tDHrbW/E1xBSqh3wIFABRVxNT+ujNal0Kl3YoP8Hgfz9DVpJJhO000ehsOr2vkfahwmonQukusro+GC1YRy7Uis/c+CXd3lNdrk0Ml/szE4rloqXqvrXUdNaO26smvTfKExDbnJ9FgSYqVnvrlOW4o5DRVPhw5OQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231441; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/z9vb+EyV5Sv3SSatE4EZlOo7VZJ2a2YjWLkr5W6TfE=; b=S260R/5PGShVOd0zGaaaGe0miVK3siF8rM8ReX8cjCQtaxaWAhrVeU0dQx/i+nyEC+H3yRdtMZ7OIdA8POh1fUHKa0oPIfX59t1u7Fm4krzOfgmHXkYX/exe0vNAJN8IB67ivMIahJxRSwRfD2Lu5n2g84+AVF6niU13i2MQi6A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231441527772.3964811425784; Fri, 4 Sep 2020 07:57:21 -0700 (PDT) Received: from localhost ([::1]:40388 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kED9T-00038n-7m for importer@patchew.org; Fri, 04 Sep 2020 10:57:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41398) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED8U-0001PP-Qb for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:18 -0400 Received: from us-smtp-1.mimecast.com ([207.211.31.81]:50874 helo=us-smtp-delivery-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED8T-0007Fd-6U for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:18 -0400 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-424-ss_cc6wsOECNYzUG3MVDOg-1; Fri, 04 Sep 2020 10:55:09 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id B34301084D62 for ; Fri, 4 Sep 2020 14:55:08 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 167627E416; Fri, 4 Sep 2020 14:55:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599231376; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/z9vb+EyV5Sv3SSatE4EZlOo7VZJ2a2YjWLkr5W6TfE=; b=a3TmVG1ZWJ827wwF+w/vlSpzfhPIBtRT9YWQCcA54XdI5WKvjEXOi2OAqDdtgef+SOY1ho 6p3Khfg+OvE49Yb7IzpRVUc8RuOO/ApL7QdDOiFW/47JJI+nwQTy3bWRhArPfzHBwLvy9a F19ahrqlttmR/CcWW8E0H/IZDaqVz/U= X-MC-Unique: ss_cc6wsOECNYzUG3MVDOg-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 18/22] i386: prefer system KVM_GET_SUPPORTED_HV_CPUID ioctl over vCPU's one Date: Fri, 4 Sep 2020 16:54:27 +0200 Message-Id: <20200904145431.196885-19-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.81; envelope-from=vkuznets@redhat.com; helo=us-smtp-delivery-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 03:57:33 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" KVM_GET_SUPPORTED_HV_CPUID was made a system wide ioctl which can be called prior to creating vCPUs and we are going to use that to expand Hyper-V cpu features early. Use it when it is supported by KVM. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 70db2ca26313..b76d4a5a147b 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -940,7 +940,8 @@ static struct { }, }; =20 -static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs, int max) +static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *cs, int max, + bool do_sys_ioctl) { struct kvm_cpuid2 *cpuid; int r, size; @@ -949,7 +950,11 @@ static struct kvm_cpuid2 *try_get_hv_cpuid(CPUState *c= s, int max) cpuid =3D g_malloc0(size); cpuid->nent =3D max; =20 - r =3D kvm_vcpu_ioctl(cs, KVM_GET_SUPPORTED_HV_CPUID, cpuid); + if (do_sys_ioctl) { + r =3D kvm_ioctl(kvm_state, KVM_GET_SUPPORTED_HV_CPUID, cpuid); + } else { + r =3D kvm_vcpu_ioctl(cs, KVM_GET_SUPPORTED_HV_CPUID, cpuid); + } if (r =3D=3D 0 && cpuid->nent >=3D max) { r =3D -E2BIG; } @@ -976,13 +981,17 @@ static struct kvm_cpuid2 *get_supported_hv_cpuid(CPUS= tate *cs) /* 0x40000000..0x40000005, 0x4000000A, 0x40000080..0x40000080 leaves */ int max =3D 10; int i; + bool do_sys_ioctl; + + do_sys_ioctl =3D + kvm_check_extension(kvm_state, KVM_CAP_SYS_HYPERV_CPUID) > 0; =20 /* * When the buffer is too small, KVM_GET_SUPPORTED_HV_CPUID fails with * -E2BIG, however, it doesn't report back the right size. Keep increa= sing * it and re-trying until we succeed. */ - while ((cpuid =3D try_get_hv_cpuid(cs, max)) =3D=3D NULL) { + while ((cpuid =3D try_get_hv_cpuid(cs, max, do_sys_ioctl)) =3D=3D NULL= ) { max++; } =20 @@ -992,7 +1001,7 @@ static struct kvm_cpuid2 *get_supported_hv_cpuid(CPUSt= ate *cs) * information early, just check for the capability and set the bit * manually. */ - if (kvm_check_extension(cs->kvm_state, + if (!do_sys_ioctl && kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV_ENLIGHTENED_VMCS) > 0) { for (i =3D 0; i < cpuid->nent; i++) { if (cpuid->entries[i].function =3D=3D HV_CPUID_ENLIGHTMENT_INF= O) { --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231990; cv=none; d=zohomail.com; s=zohoarc; b=HQH6hEUlTt4pLG1aLzPHSG6kEai9eu//ikP5IhezZEwB6BAe4Jtc++ix9x2t4sRNq+c3DFUsVn2S/s81dNADUc7+tXSAPC6UhZ8LLF+gjAXx8Sb7S/ZhT+kUfZjTjiHL9fwnvDFMSxK9BJI0nZusuNPO21wSC9GjZVGLDvGB7do= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231990; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8Kibforen7lAPzg1zDsnLzbIsjniVCZ9xp23AJw5yeI=; b=XEa183UTbjYpIK/x0Iqm2OLAIXdDjUA2tMpmMwJ93A5eaAcAw0T3/jK9kr3W4bsAndNijYID+aWiY7diNsi55PksZDct6z7dqlOBsa+KtZBxvDZ65oUL6j16neNTzc3RsUP21eFVzrM9yBO5Yp+OZPGJk6CqdyKOgUDAP/XZVsg= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231990367112.21364702222058; Fri, 4 Sep 2020 08:06:30 -0700 (PDT) Received: from localhost ([::1]:50038 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDIJ-0002R8-QG for importer@patchew.org; Fri, 04 Sep 2020 11:06:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41462) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED8c-0001eC-DI for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:26 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:52329 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED8a-0007GE-C3 for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:26 -0400 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-294-IbQlGEotPDq9gBsXDU4QFw-1; Fri, 04 Sep 2020 10:55:11 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8D6D81084D6D for ; Fri, 4 Sep 2020 14:55:10 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DF827E416; Fri, 4 Sep 2020 14:55:08 +0000 (UTC) X-MC-Unique: IbQlGEotPDq9gBsXDU4QFw-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 19/22] i386: prepare hyperv_expand_features() to be called at CPU feature expansion time Date: Fri, 4 Sep 2020 16:54:28 +0200 Message-Id: <20200904145431.196885-20-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=vkuznets@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 01:57:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" If hyperv_expand_features() is called before vCPU is created, cs->kvm_state is NULL. We can only do the expantion if system wide KVM_GET_SUPPORTED_HV_C= PUID is supported. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index b76d4a5a147b..c17e7db5e627 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -986,6 +986,10 @@ static struct kvm_cpuid2 *get_supported_hv_cpuid(CPUSt= ate *cs) do_sys_ioctl =3D kvm_check_extension(kvm_state, KVM_CAP_SYS_HYPERV_CPUID) > 0; =20 + if (!do_sys_ioctl && !cs->kvm_state) { + return NULL; + } + /* * When the buffer is too small, KVM_GET_SUPPORTED_HV_CPUID fails with * -E2BIG, however, it doesn't report back the right size. Keep increa= sing @@ -1023,6 +1027,10 @@ static struct kvm_cpuid2 *get_supported_hv_cpuid_leg= acy(CPUState *cs) struct kvm_cpuid2 *cpuid; struct kvm_cpuid_entry2 *entry_feat, *entry_recomm; =20 + if (!cs->kvm_state) { + return NULL; + } + /* HV_CPUID_FEATURES, HV_CPUID_ENLIGHTMENT_INFO */ cpuid =3D g_malloc0(sizeof(*cpuid) + 2 * sizeof(*cpuid->entries)); cpuid->nent =3D 2; @@ -1218,12 +1226,15 @@ static void hyperv_expand_features(CPUState *cs, Er= ror **errp) if (!hyperv_enabled(cpu)) return; =20 - if (kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV_CPUID) > 0) { + if (kvm_check_extension(kvm_state, KVM_CAP_HYPERV_CPUID) > 0) { cpuid =3D get_supported_hv_cpuid(cs); } else { cpuid =3D get_supported_hv_cpuid_legacy(cs); } =20 + if (!cpuid) + return; + if (cpu->hyperv_passthrough) { c =3D cpuid_find_entry(cpuid, HV_CPUID_VENDOR_AND_MAX_FUNCTIONS, 0= ); if (c) { --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599232022; cv=none; d=zohomail.com; s=zohoarc; b=gDJ/3VcA4+D6Hi+DccGMmQ7DE7hAJYdZTFn9XDH9uF+1XeH2d++uIKBI54sEleBHAh7ANKna955busvSbCD9OXSu7U+8V9Ns458z1dNUhbzvRBkWsx6H5/zotVbbKNRQmDTQtusHLuMqwE3LajTUORtoAFJ9VKSXMsv3I0UnTE8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599232022; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=OMs1B3dJ07SvLw8B/CSaDDCLiMuzJf9HbE5Z00wg5ck=; b=HYBNf02BFXyBqKWduYz07+NX8stfMHS3yNogr/QObJYyFac+9Kxv6ylg6sD89mPC7FFRPpv3xwAXC1L9SteFPjmALuaqD0eENPTAJs4bKUiWXPZPxXiPSh9FLDFEw+MMFhxecFYCvGXeslqUvcSC4SdAQfIadx2gmcsgLFVk4oA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599232022985174.40319696200868; Fri, 4 Sep 2020 08:07:02 -0700 (PDT) Received: from localhost ([::1]:53346 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDIr-0003mZ-DN for importer@patchew.org; Fri, 04 Sep 2020 11:07:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41624) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED9F-0003C8-2Y for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:57:05 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:46598 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED9C-0007J0-3m for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:57:04 -0400 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-488-y9M9axFyMdKbA_yvj6zOvg-1; Fri, 04 Sep 2020 10:55: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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 66E7A80EDA4 for ; Fri, 4 Sep 2020 14:55:12 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id EBD317A1F4; Fri, 4 Sep 2020 14:55:10 +0000 (UTC) X-MC-Unique: y9M9axFyMdKbA_yvj6zOvg-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 20/22] i386: use global kvm_state in hyperv_enabled() check Date: Fri, 4 Sep 2020 16:54:29 +0200 Message-Id: <20200904145431.196885-21-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.002 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=vkuznets@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 03:58:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" There is no need to use vCPU-specific kvm state in hyperv_enabled() check and we need to do that when feature expansion happens early, before vCPU specific KVM state is created. Signed-off-by: Vitaly Kuznetsov --- target/i386/kvm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/target/i386/kvm.c b/target/i386/kvm.c index c17e7db5e627..0945983498b2 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -728,8 +728,7 @@ unsigned long kvm_arch_vcpu_id(CPUState *cs) =20 static bool hyperv_enabled(X86CPU *cpu) { - CPUState *cs =3D CPU(cpu); - return kvm_check_extension(cs->kvm_state, KVM_CAP_HYPERV) > 0 && + return kvm_check_extension(kvm_state, KVM_CAP_HYPERV) > 0 && ((cpu->hyperv_spinlock_attempts !=3D HYPERV_SPINLOCK_NEVER_RETRY) = || cpu->hyperv_features || cpu->hyperv_passthrough); } --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231548; cv=none; d=zohomail.com; s=zohoarc; b=QYo4WmA3EcMcbCRKr/YbeMYyBK75MBCVNN6paoUcCqnelYBsG7sTDw4wlK33Odf2KqPPG5oI0Q5xCBYC/TUz/xmbZkNmJvETyjtkp2Aoo7dvgCK76B+FsWv08uT2oeClPdmCJcxR0Bm1e3LI5L1tF09A7ln6HT8s++F3sH+CZX8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231548; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZQCpSNO7veoJhtMx8Ih+Np7ociwkxkz+29u6+xfj2qo=; b=Gn3tdWzXPleFmETWHkghLo0gR6dkNyBba+OEwjv/TjtA5E8bFWW8doECFcjLjJcgGjvKLXsQ0XceVQeiOjBLq2VdRObdp/7YXCoddWV+84kUiDlbXii6Ww/FALh96aViRGRqZ0xLFrGjiqhBkmkqVAy2HTSzfAkBDdwakCxcj3g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231548875416.6797262192272; Fri, 4 Sep 2020 07:59:08 -0700 (PDT) Received: from localhost ([::1]:49106 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDBD-0006eP-FA for importer@patchew.org; Fri, 04 Sep 2020 10:59:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41454) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED8c-0001dh-2g for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:26 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:38284 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED8a-0007G9-CN for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:25 -0400 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-520-e1eVaAbeP_KCXn6BQYr99g-1; Fri, 04 Sep 2020 10:55:15 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 401C518BA284 for ; Fri, 4 Sep 2020 14:55:14 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id C5B547A1F4; Fri, 4 Sep 2020 14:55:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599231382; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ZQCpSNO7veoJhtMx8Ih+Np7ociwkxkz+29u6+xfj2qo=; b=iOp6R/uepCeH3CuD8Gu1Eb0FZGMK0dHE0ZNXKh9YnIj9/ihTw3SwFJUt7g9ZA1HHl6gFX8 G7bRConmSGS+rPJu8D6D8zaHUs0r+v19D/xSF5wJS2GwhfuP0SCoflu32VdyreS0uAg+1i vAUZxLpCxmouwOR+Y4evVimaR5oOs+8= X-MC-Unique: e1eVaAbeP_KCXn6BQYr99g-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 21/22] i386: record if Hyper-V features were already expanded Date: Fri, 4 Sep 2020 16:54:30 +0200 Message-Id: <20200904145431.196885-22-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=205.139.110.120; envelope-from=vkuznets@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 01:57:12 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Introduce a per cpu hyperv_features_expaned flag indicating that Hyper-V related CPUIDs were already acquired from KVM. We are going to start doing the expansion prior to creating KVM vCPU but in case KVM doesn't support sustem wide KVM_GET_SUPPORTED_HV_CPUID ioctl this can't happen. Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.h | 1 + target/i386/kvm.c | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 0aad60e0c707..c72755139047 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1669,6 +1669,7 @@ struct X86CPU { uint32_t hyperv_interface_id[4]; uint32_t hyperv_version_id[4]; uint32_t hyperv_limits[3]; + bool hyperv_features_expaned; =20 bool check_cpuid; bool enforce_cpuid; diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 0945983498b2..961241528a5c 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1225,6 +1225,10 @@ static void hyperv_expand_features(CPUState *cs, Err= or **errp) if (!hyperv_enabled(cpu)) return; =20 + if (cpu->hyperv_features_expaned) { + return; + } + if (kvm_check_extension(kvm_state, KVM_CAP_HYPERV_CPUID) > 0) { cpuid =3D get_supported_hv_cpuid(cs); } else { @@ -1361,6 +1365,8 @@ static void hyperv_expand_features(CPUState *cs, Erro= r **errp) /* Not exposed by KVM but needed to make CPU hotplug in Windows work */ env->features[FEAT_HYPERV_EDX] |=3D HV_CPU_DYNAMIC_PARTITIONING_AVAILA= BLE; =20 + cpu->hyperv_features_expaned =3D true; + out: =20 g_free(cpuid); --=20 2.25.4 From nobody Mon Apr 29 04:19:14 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1599231958; cv=none; d=zohomail.com; s=zohoarc; b=jtnm2sT4YEG3Y088Mq0FTnaXpR3/rQXHT+AS+a0KcgkheEF4GRAWO83J7n+9KBQ5ips5jcEIU4xcaRWwChoVX/ZHoidYAmP/lVZD3/8/lpc0F46+nvEKvPvly7IFZFZ3dCjBdSf2EirlZTO2i6ltLtoiu79f6jTfQeAHTIcx1yY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599231958; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=CD5SBM3WcvjX6HTYGq/vgOkEqv/K0toOMbXSPBHFXcs=; b=f3zIWNzGLneWQULR9y/Wp/iS5MX9CBxuxZD/vlc7jRYpuPK/r8h787iOyHXUzl7IB+BWF/5Xg1W+Ra6lypvSso5FgddUXkUVSYhTAykIWPNX55+Vy9ty4h+HSCdsuRbhUzj66bh/2dJ9c8gYloW3n7xHk+vQi7683AcG4kza4VU= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1599231958641320.69012903458895; Fri, 4 Sep 2020 08:05:58 -0700 (PDT) Received: from localhost ([::1]:47740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kEDHo-0001Ud-LP for importer@patchew.org; Fri, 04 Sep 2020 11:05:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41428) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kED8Y-0001ZH-H8 for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:22 -0400 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:22484 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1kED8W-0007Fs-Q7 for qemu-devel@nongnu.org; Fri, 04 Sep 2020 10:56:22 -0400 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-527-4gqRsJDcOKis7-rI5CC2pQ-1; Fri, 04 Sep 2020 10:55:17 -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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 338F864087 for ; Fri, 4 Sep 2020 14:55:16 +0000 (UTC) Received: from vitty.brq.redhat.com (unknown [10.40.194.104]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8FAA87A1F4; Fri, 4 Sep 2020 14:55:14 +0000 (UTC) X-MC-Unique: 4gqRsJDcOKis7-rI5CC2pQ-1 From: Vitaly Kuznetsov To: qemu-devel@nongnu.org Subject: [PATCH RFC 22/22] i386: expand Hyper-V features early Date: Fri, 4 Sep 2020 16:54:31 +0200 Message-Id: <20200904145431.196885-23-vkuznets@redhat.com> In-Reply-To: <20200904145431.196885-1-vkuznets@redhat.com> References: <20200904145431.196885-1-vkuznets@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=207.211.31.120; envelope-from=vkuznets@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/09/04 03:58:24 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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: Paolo Bonzini , Marcelo Tosatti , Eduardo Habkost Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" To make Hyper-V features appear in e.g. QMP query-cpu-model-expansion we need to expand and set the corresponding CPUID leaves early. Modify x86_cpu_get_supported_feature_word() to call newly intoduced Hyper-V specific kvm_hv_get_supported_cpuid() instead of kvm_arch_get_supported_cpuid(). We can't use kvm_arch_get_supported_cpuid() as Hyper-V specific CPUID leaves intersect with KVM's. Note, early expansion will only happen when KVM supports system wide KVM_GET_SUPPORTED_HV_CPUID ioctl (KVM_CAP_SYS_HYPERV_CPUID). Signed-off-by: Vitaly Kuznetsov --- target/i386/cpu.c | 15 +++++++++------ target/i386/kvm.c | 15 +++++++++++++++ target/i386/kvm_i386.h | 7 +++++++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 479c4bbbf459..d3c4ecb3535c 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -5147,7 +5147,7 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Erro= r **errp) return cpu_list; } =20 -static uint64_t x86_cpu_get_supported_feature_word(FeatureWord w, +static uint64_t x86_cpu_get_supported_feature_word(X86CPU *cpu, FeatureWor= d w, bool migratable_only) { FeatureWordInfo *wi =3D &feature_word_info[w]; @@ -5156,9 +5156,12 @@ static uint64_t x86_cpu_get_supported_feature_word(F= eatureWord w, if (kvm_enabled()) { switch (wi->type) { case CPUID_FEATURE_WORD: - r =3D kvm_arch_get_supported_cpuid(kvm_state, wi->cpuid.eax, - wi->cpuid.ecx, - wi->cpuid.reg); + if (hyperv_feature_word(w)) + r =3D kvm_hv_get_supported_cpuid(cpu, w); + else + r =3D kvm_arch_get_supported_cpuid(kvm_state, wi->cpuid.ea= x, + wi->cpuid.ecx, + wi->cpuid.reg); break; case MSR_FEATURE_WORD: r =3D kvm_arch_get_supported_msr_feature(kvm_state, @@ -6485,7 +6488,7 @@ static void x86_cpu_expand_features(X86CPU *cpu, Erro= r **errp) * by the user. */ env->features[w] |=3D - x86_cpu_get_supported_feature_word(w, cpu->migratable) & + x86_cpu_get_supported_feature_word(cpu, w, cpu->migratable= ) & ~env->user_features[w] & ~feature_word_info[w].no_autoenable_flags; } @@ -6589,7 +6592,7 @@ static void x86_cpu_filter_features(X86CPU *cpu, bool= verbose) =20 for (w =3D 0; w < FEATURE_WORDS; w++) { uint64_t host_feat =3D - x86_cpu_get_supported_feature_word(w, false); + x86_cpu_get_supported_feature_word(cpu, w, false); uint64_t requested_features =3D env->features[w]; uint64_t unavailable_features =3D requested_features & ~host_feat; mark_unavailable_features(cpu, w, unavailable_features, prefix); diff --git a/target/i386/kvm.c b/target/i386/kvm.c index 961241528a5c..764b96fbbb7d 100644 --- a/target/i386/kvm.c +++ b/target/i386/kvm.c @@ -1449,6 +1449,21 @@ static int hyperv_fill_cpuids(CPUState *cs, return cpuid_i; } =20 +uint32_t kvm_hv_get_supported_cpuid(X86CPU *cpu, enum FeatureWord w) +{ + CPUState *cs =3D CPU(cpu); + CPUX86State *env =3D &cpu->env; + Error *local_err =3D NULL; + + hyperv_expand_features(cs, &local_err); + + if (local_err) { + error_report_err(local_err); + } + + return env->features[w]; +} + static Error *hv_passthrough_mig_blocker; static Error *hv_no_nonarch_cs_mig_blocker; =20 diff --git a/target/i386/kvm_i386.h b/target/i386/kvm_i386.h index 064b8798a26c..2e7da4f39668 100644 --- a/target/i386/kvm_i386.h +++ b/target/i386/kvm_i386.h @@ -48,4 +48,11 @@ bool kvm_has_waitpkg(void); =20 bool kvm_hv_vpindex_settable(void); =20 +static inline bool hyperv_feature_word(enum FeatureWord w) +{ + return w >=3D FEAT_HYPERV_EAX && w <=3D FEAT_HV_NESTED_EDX; +} + +uint32_t kvm_hv_get_supported_cpuid(X86CPU *cpu, enum FeatureWord w); + #endif --=20 2.25.4