From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7F3DA1CBEB5 for ; Thu, 22 Aug 2024 14:39:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724337562; cv=none; b=ot+wP0PcBI7DvlMU2lHbs+HlOLdhFgEXZBs1//cXZLJEnZhrd9sFWAHARFeP9eGq6dGpBLmR0De3Gh/TXpBCUwLWq0Y+lufMjIsGM5Nuidyqk8Cd+VBWm6WRYkW8qy3TmFl6vaGrq0AL+cRl93Mi3XQWKMuM8rhTsqpFM5SC6+k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1724337562; c=relaxed/simple; bh=X8KSExe0JVjcfIOQiQemA3j9+WycDlheDhru+uxRmKE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=JzXb69qoBfN7RgGIsvYMcMsAZBV+ghpEzQTT4mCJ3VGEt/bC7VSoQE0d55IVbnhC/tBCml6sqoa0g3/sTkag1X3BdSP5QcH3sLjKogos/qrjrtkz9GWgY4fThdsmBIAbXVZuhrkENlDy29G3u1Fh0/cBkMdoADlLb6sYqXHb8uA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vGxVkLqd; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vGxVkLqd" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3FBCC32782; Thu, 22 Aug 2024 14:39:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1724337562; bh=X8KSExe0JVjcfIOQiQemA3j9+WycDlheDhru+uxRmKE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=vGxVkLqd5D67VB73eVX0juEB/LJJoRao2+DOlHljlCrmwVRXDg0njq9LyoDJbAxFg FxaguYnEP7+G1loo/FICsAYslU7MtHiHIGmTlVit7B3qVKnG2yzDGoKiONfr0CqlM/ 1G8tGNCxmpt8oBTlhdBoEFfOs6vrG9N9DWeCFGU/2B1rUcZhahi6k1UbApmpEyBaQN dfzFJEnIKVW/jzbmp71ICt1O+NSAFqoWSobDvQ12gWlIWA/6tdzSHfOtOATaPFuZlh jJo6BlPo7KHc4Tio+k6m86k117eseUkSji/fypxk4ZZ3iAEw6JWHTwYN5zSRf+/TtO pQqQHFs5roJGw== Date: Thu, 22 Aug 2024 08:39:19 -0600 From: Keith Busch To: Tao Su Cc: Keith Busch , kvm@vger.kernel.org, x86@kernel.org, Alex Williamson , Paolo Bonzini , Xu Liu Subject: Re: [PATCH RFC] kvm: emulate avx vmovdq Message-ID: References: <20240820230431.3850991-1-kbusch@meta.com> Precedence: bulk X-Mailing-List: kvm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Thu, Aug 22, 2024 at 03:22:35PM +0800, Tao Su wrote: > On Tue, Aug 20, 2024 at 04:04:31PM -0700, Keith Busch wrote: > > + if (map == 1 && !v) > > + return avx_0f_table[ctxt->b]; > > + return (struct opcode){.flags = NotImpl}; > > Can we check whether the host supports AVX? I.e. if the host does not support > AVX, set NotImpl. I am thinking that if the host does not support AVX, perhaps > the guest executing AVX instructions will cause the host to panic, because the > host will execute AVX instructions during the simulation. > > Yeah if the host does not support AVX, it may not report AVX to the guest, but > the guest can always ignore the AVX check, such as the code in the commit. That's a good thought. Here is how I rationalized not adding additional checks for it: If the guest cpu doesn't support AVX, I think it should fail then and there rather than trap to the hypervisor running on the host, so this new code wouldn't get a chance to attempt emulating it. In the case where the host doesn't support AVX, but the guest does support it, then I assume the VM is running on an emulated CPU and not using kvm acceleration anymore. Anyway, I haven't tried it, so not entirely confident that's how this all works. I was mainly following the existing SSE emulations, which don't have CPU support checks either. I don't think it's a problem to add such checks though, so happy to do it if needed.