Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3347328pxx; Mon, 2 Nov 2020 06:39:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJz4maU1ic0BiSmR1ciTLp2I2nlfr2ef/+VmvYlHJTzZcBxmjEEP8qwrq+u/tEktmsIlcTcw X-Received: by 2002:a17:907:2706:: with SMTP id w6mr2275314ejk.107.1604327983381; Mon, 02 Nov 2020 06:39:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604327983; cv=none; d=google.com; s=arc-20160816; b=o8bhxJHLfbZLqmVCQzTq/8OcPCFZtdC4Aj0aEYGLGQbAAZ4Wm0D6tjcNbc0X3rijJ2 bLl5cjpNad6PUMavWYSysAQjPNbKsnGcfcvna4B/3/VxgoAh+vCqjBkqpiOph9KSk4kx 79g7DZY/G7AG7NSHaBLDWKVWsZ1j2kjNKNXPS+SW37pc5m/cMtl8TGPC9+J3kuaXSuKr NNI2DARlTorXEmZM4Npusle/iS1X8SLK+qbuSYM5Chl39JPFTnHv/fajw919t4ppWzzj nPyO5manSAuuSYiQfFc17J+ooluYNVvQx7fF7SZxQeI4OWbKCMBrPQjryvFA8872qG7U AmLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=CrGg9rK4uvm4Q0y8bZd5vyUgp74wB3OKjww/RvmQ3bc=; b=AnYDD0R0txXyx7zKxxA1ND15DnQaHIRBAorNP8rRQutMssyqosBioOsUk93kwAQVbb TL6igptzNDBim2UMejXiBEt0nbLSi5zkKrxKoCmRZe1gKZ2yX9xWFqItLhVCT3bIH1oJ EmkBWqZtl1CT2yC1CczB9G0koas+gTwvI2e9lO3Sk2PP3TFNMbkvl/HryeBLUx+ZRAx7 T8PnMVHy4g47PxyWvuuTogKxF2iB2yt94HiunJ6RACxjrhLnsXuk/WxYRKnAATItMeRO NL04zvboV45xAybVJqobruTIG7ysfe2p4xehxDMsSevqRszW45kxM0uyaU9jffkXPCP3 9g0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=VKYNztmH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l3si10583046eja.544.2020.11.02.06.39.20; Mon, 02 Nov 2020 06:39:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@alien8.de header.s=dkim header.b=VKYNztmH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=alien8.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725995AbgKBOhU (ORCPT + 99 others); Mon, 2 Nov 2020 09:37:20 -0500 Received: from mail.skyhub.de ([5.9.137.197]:47324 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725788AbgKBOhU (ORCPT ); Mon, 2 Nov 2020 09:37:20 -0500 Received: from zn.tnic (p200300ec2f086a005eef14ece2bfc9a7.dip0.t-ipconnect.de [IPv6:2003:ec:2f08:6a00:5eef:14ec:e2bf:c9a7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.skyhub.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 5B96D1EC0328; Mon, 2 Nov 2020 15:37:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=dkim; t=1604327839; 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:in-reply-to:in-reply-to: references:references; bh=CrGg9rK4uvm4Q0y8bZd5vyUgp74wB3OKjww/RvmQ3bc=; b=VKYNztmH3e6yxoLu4KiMwGTgYAffpJTGSTVnIVpUx9RR78Znmnop8oXFmtYiubFMpjo01O bf7LQOakzENwY7f62FyaTm5bZGTiEyJz0hLZzUDj66CNU8w87Wwd2wsNTcG4T69rE+w8ht JLrcZFjemQ4ntG50P9FQVZFpCCVxN/c= Date: Mon, 2 Nov 2020 15:37:07 +0100 From: Borislav Petkov To: shuo.a.liu@intel.com Cc: linux-kernel@vger.kernel.org, x86@kernel.org, Greg Kroah-Hartman , "H . Peter Anvin" , Thomas Gleixner , Ingo Molnar , Sean Christopherson , Yu Wang , Reinette Chatre , Yin Fengwei , Dave Hansen , Dan Williams , Zhi Wang , Zhenyu Wang Subject: Re: [PATCH v5 03/17] x86/acrn: Introduce an API to check if a VM is privileged Message-ID: <20201102143707.GC15392@zn.tnic> References: <20201019061803.13298-1-shuo.a.liu@intel.com> <20201019061803.13298-4-shuo.a.liu@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20201019061803.13298-4-shuo.a.liu@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 19, 2020 at 02:17:49PM +0800, shuo.a.liu@intel.com wrote: > +bool acrn_is_privileged_vm(void) > +{ > + return cpuid_eax(acrn_cpuid_base() | ACRN_CPUID_FEATURES) & > + ACRN_FEATURE_PRIVILEGED_VM; I asked in the previous review why that acrn_cpuid_base() is used here, you said that the base might vary. Looking at hypervisor_cpuid_base(), it searches in the range [0x40000000, 0x40010000] with an 0x100 offset. So you're saying that ACRN_CPUID_FEATURES is the first leaf beyond the base. Close? If so, why isn't the code doing this? return cpuid_eax(acrn_cpuid_base() + 1)... and why doesn't it have a comment above it explaining that the base can change and it needs to be discovered each time? > +EXPORT_SYMBOL_GPL(acrn_is_privileged_vm); Also, that acrn_is_privileged_vm() silly helper is used only once and I don't like the exported symbols pollution we're doing. So make that function give you the eax of ACRN_CPUID_FEATURES and callers can do their testing themselves. When it turns out that code patterns get repeated, you can then aggregate stuff into a helper. Thx. -- Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette