Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1543049lqe; Mon, 8 Apr 2024 11:58:06 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUjU5aS8g7Mv3Vnj999Y7r0Xl3G4nuiUjP0iHNjmkNpmoGKEVnu2eUYljPxLjTx/XBAbRd6heH25cRGEd2DDDxAIagOoy4YNeOhlgLckg== X-Google-Smtp-Source: AGHT+IGV0xqZh8tEx9zcFXtHSCQFvoTXwfn668ma3Q9Jt6BYxvML58ZBpTIrrYOxC7Q26hXUyVAw X-Received: by 2002:a05:6a21:7888:b0:1a1:6803:69a3 with SMTP id bf8-20020a056a21788800b001a1680369a3mr12599185pzc.0.1712602686579; Mon, 08 Apr 2024 11:58:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712602686; cv=pass; d=google.com; s=arc-20160816; b=cq/thObEcPssL3iwRclrUj5oML8EENwY5oftrIUDPo1dYz2E/etecgtnff62WMhltD b+L454uMMaavmy1mj6zT6ByBwPWKYrL6VlxMjMB4lRteUqPKS/1VmU41GJQeWIdqR1jp WMzs5AvtSXS1yishTcZ5QNoADicuR+hSUeGuEvsZHyzlmLT2/5EKKn7XrNdcODBBkcYm nC7KSQPP1SQ3hMFBn7FDBhyE/F/1wdXGEttL7pdPDZ44n7vI0flbybGdYHNW0qcWL8FY GWGPYdcChSshtiDicWRlcmv0uNloqofWzd6IYdPUDSvCzoFNOm/zgC5644rb4r6oGxXD s25w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=DAfp8rjggGIrC82n5MMJJ4pl3Mik6vrYCInPRi9xRbQ=; fh=NZcR+kKIrgUScp9qOYWnNUtCooUX7jZPQIF1HqqoEm4=; b=PVZRdQH0ca/sMOB7Vl/zBHslBtlDfKzghRmZBDTPCJ1Y4agZwW8X6UXKUQdp25iVeg 4G+tbYbj9xTT4qPKYW+cwhNcfA3rWQJPR8WJofxkw0AgdNiqO7C3dovi+gHA1bFDLxiB j3HV6l/VDG8Cz7C0EZt76Rh7aVtdTMfhN1eyw6I0yIJXsEGdGZfDkMoF5o9KS3UkV8k3 JsibSsbnwnX0haJZqOYN+WbUokJ3xv5n3S5SpZ222Xb/kW+va9E0zpNFSgiVuSgp6vQN suph3gCPztBSak+8XHp0OkBDp9tL4DuRY+6wq5HGBNC6/npQROsDXLsoS8RDJnhJDiuY zRVQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="kG//dSCO"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-135854-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135854-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id iw3-20020a170903044300b001e2a7f6285dsi6562020plb.629.2024.04.08.11.58.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 11:58:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135854-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="kG//dSCO"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=intel.com); spf=pass (google.com: domain of linux-kernel+bounces-135854-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135854-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 46416284F64 for ; Mon, 8 Apr 2024 18:58:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4A33E145359; Mon, 8 Apr 2024 18:56:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="kG//dSCO" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) (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 5EF44144D3F; Mon, 8 Apr 2024 18:56:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.10 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712602576; cv=none; b=MewELXMLK6bNRaogTCX2XXG4tOPNU8uIjEekgko7aAXPTmq/0eTc/lnZUieE1plDkLkn1sTfjx1ysXDnQTIZE54DBUL+p4l4Hd1aiE0FQSyZK/eHd88aOHxYSxQDqnIuMscZ3qNBN8C5Ll7vNcoiwMtK9z9eIOhxX3SetdGeFpI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712602576; c=relaxed/simple; bh=GT8DmlYW4wP87a6DyCfEapNSv2ZZRQv8FnHKuwMlPMk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=itzTZ3HLtG8rIYlylsrePBXn3EJRH4xEToQEWAWmTFPcW7FNq93IcarX8Dka4EgO23jcDthc7uoU8y+Oix25ZR1rCmyrJku1YOlXs0kIro3mSaAaLuI6lMZqLLFZGkUqPLcpYxplzk0gZljyXjqzRYvTuwTCbCJwKbQ7aI+/DZw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=kG//dSCO; arc=none smtp.client-ip=198.175.65.10 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712602574; x=1744138574; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=GT8DmlYW4wP87a6DyCfEapNSv2ZZRQv8FnHKuwMlPMk=; b=kG//dSCOlaC0bbY7USlueejZDVlPJ/d5rASSkTTu6UEpiBo9548pQ14l ai/ojCFJgtsp72BIq0H/wr8KNy5XoHSMFzATlFCHhDWQs+D+mtH8RGmi1 JJnam49mkl7/vBYOk2fT07uk1DmQkH+8RN6PNQrGKGY5weBKXEkPgBFT/ t1BxeZ4LqmmI/vWP1178RkEPJ8sF4WBKNLQidRIMkeUAJ4xxlkL4B5DeK yRkIMl1avvWYDkMwgunCg8U+iHFiNbVLacq+aeRjuVyGwRD4ThbHl3UMf 63to/DWvO7VZGJM/mWAX32O/5r7fFVinZnJtVkyz5vO/LQ3X5tyDOvwQy g==; X-CSE-ConnectionGUID: qmUW/ol0R8Svv5fxMj8mWg== X-CSE-MsgGUID: aiGmqWLSTsmLd/t0xnb2kA== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="25342975" X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="25342975" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 11:56:14 -0700 X-CSE-ConnectionGUID: 4s75vRUOSFy5s5xzZjEywQ== X-CSE-MsgGUID: iKPoeOtZTQ+Ussm+qhsdgw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,187,1708416000"; d="scan'208";a="19928342" Received: from ls.sc.intel.com (HELO localhost) ([172.25.112.31]) by fmviesa010-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 11:56:13 -0700 Date: Mon, 8 Apr 2024 11:56:13 -0700 From: Isaku Yamahata To: Chao Gao Cc: Isaku Yamahata , Sean Christopherson , kvm@vger.kernel.org, linux-kernel@vger.kernel.org, isaku.yamahata@gmail.com, Paolo Bonzini , erdemaktas@google.com, Sagi Shahar , Kai Huang , chen.bo@intel.com, hang.yuan@intel.com, tina.zhang@intel.com, isaku.yamahata@linux.intel.com Subject: Re: [PATCH v19 108/130] KVM: TDX: Handle TDX PV HLT hypercall Message-ID: <20240408185613.GX2444378@ls.amr.corp.intel.com> References: <20240404232537.GV2444378@ls.amr.corp.intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: On Sun, Apr 07, 2024 at 11:50:04AM +0800, Chao Gao wrote: > >> > >+ union tdx_vcpu_state_details details; > >> > >+ struct vcpu_tdx *tdx = to_tdx(vcpu); > >> > >+ > >> > >+ if (ret || vcpu->arch.mp_state != KVM_MP_STATE_HALTED) > >> > >+ return true; > >> > > >> > Question: why mp_state matters here? > >> > >+ > >> > >+ if (tdx->interrupt_disabled_hlt) > >> > >+ return false; > >> > > >> > Shouldn't we move this into vt_interrupt_allowed()? VMX calls the function to > >> > check if interrupt is disabled. > > > >Chao, are you suggesting to implement tdx_interrupt_allowed() as > >"EXIT_REASON_HLT && a0" instead of "return true"? > >I don't think it makes sense because it's rare case and we can't avoid spurious > >wakeup for TDX case. > > Yes. KVM differeniates "interrupt allowed" from "has interrupt", e.g., > > static inline bool kvm_vcpu_has_events(struct kvm_vcpu *vcpu) > ... > > if (kvm_arch_interrupt_allowed(vcpu) && > (kvm_cpu_has_interrupt(vcpu) || > kvm_guest_apic_has_interrupt(vcpu))) > return true; > > > I think tdx_protected_apic_has_interrupt() mixes them together, which isn't > good. Your point is code clarity. Ok, we can code in that way. I don't expect any performance difference. -- Isaku Yamahata