From: Katy Feng Date: Thu, 6 Apr 2023 18:27:41 +0000 (-0700) Subject: Changes to common header files not applicable to open-vm-tools. X-Git-Tag: stable-12.3.0~79 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=377f82a668c6c02a3fa15ad3f2da3a5b7849f39a;p=thirdparty%2Fopen-vm-tools.git Changes to common header files not applicable to open-vm-tools. --- diff --git a/open-vm-tools/lib/include/guest_os.h b/open-vm-tools/lib/include/guest_os.h index 5825cfa85..979f81624 100644 --- a/open-vm-tools/lib/include/guest_os.h +++ b/open-vm-tools/lib/include/guest_os.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 1998-2021 VMware, Inc. All rights reserved. + * Copyright (C) 1998-2021, 2023 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -551,6 +551,9 @@ Bool Gos_InSetArray(uint32 gos, const uint32 *set); * Window on Arm support starts with Windows 10. */ +#define STR_OS_ARM_WIN "arm-windows" + + /* * Windows 10 * diff --git a/open-vm-tools/lib/include/vm_basic_asm.h b/open-vm-tools/lib/include/vm_basic_asm.h index 639e08a40..cf2e677af 100644 --- a/open-vm-tools/lib/include/vm_basic_asm.h +++ b/open-vm-tools/lib/include/vm_basic_asm.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (c) 2003-2022 VMware, Inc. All rights reserved. + * Copyright (c) 2003-2023 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -75,6 +75,12 @@ #include "mul64.h" #endif +#if defined _M_ARM64EC +#include "vm_assert.h" +#define MUL64_NO_ASM 1 +#include "mul64.h" +#endif + #if defined __cplusplus extern "C" { #endif diff --git a/open-vm-tools/lib/include/vm_basic_asm_arm64.h b/open-vm-tools/lib/include/vm_basic_asm_arm64.h index f9711f8f4..2cd7c5dce 100644 --- a/open-vm-tools/lib/include/vm_basic_asm_arm64.h +++ b/open-vm-tools/lib/include/vm_basic_asm_arm64.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2013-2022 VMware, Inc. All rights reserved. + * Copyright (C) 2013-2023 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -659,131 +659,6 @@ SetSPELx(VA va) } -#ifndef MUL64_NO_ASM -/* - *----------------------------------------------------------------------------- - * - * Mul64x6464 -- - * - * Unsigned integer by fixed point multiplication, with rounding: - * result = floor(multiplicand * multiplier * 2**(-shift) + 0.5) - * - * Unsigned 64-bit integer multiplicand. - * Unsigned 64-bit fixed point multiplier, represented as - * (multiplier, shift), where shift < 64. - * - * Result: - * Unsigned 64-bit integer product. - * - *----------------------------------------------------------------------------- - */ - -static INLINE uint64 -Mul64x6464(uint64 multiplicand, - uint64 multiplier, - uint32 shift) -{ - if (shift == 0) { - return multiplicand * multiplier; - } else { - uint64 lo, hi; - - asm("mul %0, %2, %3" "\n\t" - "umulh %1, %2, %3" - : "=&r" (lo), "=r" (hi) - : "r" (multiplicand), "r" (multiplier)); - return (hi << (64 - shift) | lo >> shift) + (lo >> (shift - 1) & 1); - } -} - - -/* - *----------------------------------------------------------------------------- - * - * Muls64x64s64 -- - * - * Signed integer by fixed point multiplication, with rounding: - * result = floor(multiplicand * multiplier * 2**(-shift) + 0.5) - * - * Signed 64-bit integer multiplicand. - * Unsigned 64-bit fixed point multiplier, represented as - * (multiplier, shift), where shift < 64. - * - * Result: - * Signed 64-bit integer product. - * - *----------------------------------------------------------------------------- - */ - -static INLINE int64 -Muls64x64s64(int64 multiplicand, - int64 multiplier, - uint32 shift) -{ - if (shift == 0) { - return multiplicand * multiplier; - } else { - uint64 lo, hi; - - asm("mul %0, %2, %3" "\n\t" - "smulh %1, %2, %3" - : "=&r" (lo), "=r" (hi) - : "r" (multiplicand), "r" (multiplier)); - return (hi << (64 - shift) | lo >> shift) + (lo >> (shift - 1) & 1); - } -} - - -/* - *----------------------------------------------------------------------------- - * - * Mul64x3264 -- - * - * Unsigned integer by fixed point multiplication, with rounding: - * result = floor(multiplicand * multiplier * 2**(-shift) + 0.5) - * - * Unsigned 64-bit integer multiplicand. - * Unsigned 32-bit fixed point multiplier, represented as - * (multiplier, shift), where shift < 64. - * - * Result: - * Unsigned 64-bit integer product. - * - *----------------------------------------------------------------------------- - */ - -static INLINE uint64 -Mul64x3264(uint64 multiplicand, uint32 multiplier, uint32 shift) -{ - return Mul64x6464(multiplicand, multiplier, shift); -} - - -/* - *----------------------------------------------------------------------------- - * - * Muls64x32s64 -- - * - * Signed integer by fixed point multiplication, with rounding: - * result = floor(multiplicand * multiplier * 2**(-shift) + 0.5) - * - * Signed 64-bit integer multiplicand. - * Unsigned 32-bit fixed point multiplier, represented as - * (multiplier, shift), where shift < 64. - * - * Result: - * Signed 64-bit integer product. - * - *----------------------------------------------------------------------------- - */ - -static INLINE int64 -Muls64x32s64(int64 multiplicand, uint32 multiplier, uint32 shift) -{ - return Muls64x64s64(multiplicand, multiplier, shift); -} -#endif - /* *----------------------------------------------------------------------------- * @@ -1000,6 +875,139 @@ DCacheClean(VA va, uint64 len) #endif // ifndef _MSC_VER +#if defined _MSC_VER +/* Until we implement Mul64x6464() with Windows intrinsics... */ +#define MUL64_NO_ASM 1 +#endif + +#ifdef MUL64_NO_ASM +#include "mul64.h" +#else +/* + *----------------------------------------------------------------------------- + * + * Mul64x6464 -- + * + * Unsigned integer by fixed point multiplication, with rounding: + * result = floor(multiplicand * multiplier * 2**(-shift) + 0.5) + * + * Unsigned 64-bit integer multiplicand. + * Unsigned 64-bit fixed point multiplier, represented as + * (multiplier, shift), where shift < 64. + * + * Result: + * Unsigned 64-bit integer product. + * + *----------------------------------------------------------------------------- + */ + +static INLINE uint64 +Mul64x6464(uint64 multiplicand, + uint64 multiplier, + uint32 shift) +{ + if (shift == 0) { + return multiplicand * multiplier; + } else { + uint64 lo, hi; + + asm("mul %0, %2, %3" "\n\t" + "umulh %1, %2, %3" + : "=&r" (lo), "=r" (hi) + : "r" (multiplicand), "r" (multiplier)); + return (hi << (64 - shift) | lo >> shift) + (lo >> (shift - 1) & 1); + } +} + + +/* + *----------------------------------------------------------------------------- + * + * Muls64x64s64 -- + * + * Signed integer by fixed point multiplication, with rounding: + * result = floor(multiplicand * multiplier * 2**(-shift) + 0.5) + * + * Signed 64-bit integer multiplicand. + * Unsigned 64-bit fixed point multiplier, represented as + * (multiplier, shift), where shift < 64. + * + * Result: + * Signed 64-bit integer product. + * + *----------------------------------------------------------------------------- + */ + +static INLINE int64 +Muls64x64s64(int64 multiplicand, + int64 multiplier, + uint32 shift) +{ + if (shift == 0) { + return multiplicand * multiplier; + } else { + uint64 lo, hi; + + asm("mul %0, %2, %3" "\n\t" + "smulh %1, %2, %3" + : "=&r" (lo), "=r" (hi) + : "r" (multiplicand), "r" (multiplier)); + return (hi << (64 - shift) | lo >> shift) + (lo >> (shift - 1) & 1); + } +} + + +/* + *----------------------------------------------------------------------------- + * + * Mul64x3264 -- + * + * Unsigned integer by fixed point multiplication, with rounding: + * result = floor(multiplicand * multiplier * 2**(-shift) + 0.5) + * + * Unsigned 64-bit integer multiplicand. + * Unsigned 32-bit fixed point multiplier, represented as + * (multiplier, shift), where shift < 64. + * + * Result: + * Unsigned 64-bit integer product. + * + *----------------------------------------------------------------------------- + */ + +static INLINE uint64 +Mul64x3264(uint64 multiplicand, uint32 multiplier, uint32 shift) +{ + return Mul64x6464(multiplicand, multiplier, shift); +} + + +/* + *----------------------------------------------------------------------------- + * + * Muls64x32s64 -- + * + * Signed integer by fixed point multiplication, with rounding: + * result = floor(multiplicand * multiplier * 2**(-shift) + 0.5) + * + * Signed 64-bit integer multiplicand. + * Unsigned 32-bit fixed point multiplier, represented as + * (multiplier, shift), where shift < 64. + * + * Result: + * Signed 64-bit integer product. + * + *----------------------------------------------------------------------------- + */ + +static INLINE int64 +Muls64x32s64(int64 multiplicand, uint32 multiplier, uint32 shift) +{ + return Muls64x64s64(multiplicand, multiplier, shift); +} +#endif + + #if defined __cplusplus } // extern "C" #endif diff --git a/open-vm-tools/lib/include/vm_basic_types.h b/open-vm-tools/lib/include/vm_basic_types.h index 5cc3f700e..1d952da86 100644 --- a/open-vm-tools/lib/include/vm_basic_types.h +++ b/open-vm-tools/lib/include/vm_basic_types.h @@ -78,11 +78,11 @@ /* * Standardize MSVC arch macros to GCC arch macros. */ -#if defined _MSC_VER && defined _M_X64 +#if defined _MSC_VER && defined _M_X64 && !defined _M_ARM64EC # define __x86_64__ 1 #elif defined _MSC_VER && defined _M_IX86 # define __i386__ 1 -#elif defined _MSC_VER && defined _M_ARM64 +#elif defined _MSC_VER && (defined _M_ARM64 || defined _M_ARM64EC) # define __aarch64__ 1 #elif defined _MSC_VER && defined _M_ARM # define __arm__ 1