Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp122378iob; Tue, 17 May 2022 20:58:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwXnnEouYnL6aIpWHXbIfVMp1j1ZOlu+5hzWkAVoYq7zztX1YOan6F9NcDWMii4nP/+Bme8 X-Received: by 2002:a17:90a:ec01:b0:1df:56aa:6b7b with SMTP id l1-20020a17090aec0100b001df56aa6b7bmr13928162pjy.230.1652846322449; Tue, 17 May 2022 20:58:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652846322; cv=none; d=google.com; s=arc-20160816; b=mKbN2mkFK6TgovZnVYhI+kqVWmrRrrDV6vLk5PLdqO85EqBJKSgJrpGEBMoCpD6NcM tiPL8AQ34mfpM6TK3HHWbd1vj9JCrcjMT8PEw3GiF7AlG0Y83sLezfuwkyWDRWB6Mka7 ZP/iROiZQzIX3OjvB8++d9VQLr/4g+JpQiqALglrjGNsWNkiudU3dHvcywHjr0Ki9ACG M2ctfbG8SceTB+HdwP4gfMywxF9PR5PROpqFmuvWwN6CD4k/9HtoyrgENPzy8HnBGbK3 2pZvjqvDZajdyB03JPsuGjMcHomEFtI1Cogb37mUm9pI1uWqAPdisGoRYah/Bew7SKIO abYg== 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=XnAGiXdnHDqEECKkXT94eDsdZlfdtVgWYYcueJynkfM=; b=bZ8HcwPkl6gf6ESYFFRshP3r3K6Z8uAp8zNLnKLGboHxuMAGP58HPdWT16aF6fKJ9c wlH4zcmnrofgPhj0NGwCEyxAiLThi2rYf9p/Q4P75jHU2nCDRGYV98RWpbEAK/dTBGA2 m8p2twvdfvB8xdhZ1XMcwIxJLzLrXyfSfQVhdM3gSO8dWSPQZ2+Tzr+upshXEeSp2Rhs Q7gYeOwi4g8b56fWCjaepWsJbdUsaRvt5n7Qt1dUwgT0Gk2iWPSobt8uB3HXHDlLRloU vBzfQBxcSJJ6pNedmiCfOzNTHbqjrZK1QVGhbPoTGgBZYYaLON+aSb5xmHhMttUcgFFM Xjgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IuXXudhz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g10-20020a17090a67ca00b001d9a26d5275si5315326pjm.71.2022.05.17.20.58.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 20:58:42 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=IuXXudhz; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6ECDA11A0C; Tue, 17 May 2022 20:35:53 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352904AbiEQURR (ORCPT + 99 others); Tue, 17 May 2022 16:17:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231774AbiEQURP (ORCPT ); Tue, 17 May 2022 16:17:15 -0400 Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6140A51E65 for ; Tue, 17 May 2022 13:17:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1652818634; x=1684354634; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=jWdssyub1ndaTO5AKMJmUoU3GkFbxb2fOG5t9/sxMwI=; b=IuXXudhzM0cWG32mjqrYPHUqPnNF06PgprnwP+eHuO4dgaJSwcoUNvyq O/Hk6/Yl3F3RLIErmuenZgoOEAeUqPrbCM6H1AvPyc7Akqefj38sm7som /+lWP+OQLC2d5Zx3fk5qIe+SZ+MBXFeUuLzFbFgAjDsqDak1s4R20Tz8A sq+qCwQedPxAiwg174FdIO6Gpj6NTgyzW599m2ZiOrHiOpalkQWgGmFSC TZW3F3Um5TjiPgBh/DxnRYln9Y7fNbHd8OJb0U/gbTNO1UiTVKonY3lUM qfcu+J+buA5iIumRivgFxSX1UIkiDg9uxWKYmKhZgrJ7oJcs2RSrW9+Zz w==; X-IronPort-AV: E=McAfee;i="6400,9594,10350"; a="251214887" X-IronPort-AV: E=Sophos;i="5.91,233,1647327600"; d="scan'208";a="251214887" Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 May 2022 13:17:13 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,233,1647327600"; d="scan'208";a="897847237" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga005.fm.intel.com with ESMTP; 17 May 2022 13:17:10 -0700 Received: by black.fi.intel.com (Postfix, from userid 1000) id 49364CE; Tue, 17 May 2022 23:17:10 +0300 (EEST) Date: Tue, 17 May 2022 23:17:10 +0300 From: "Kirill A. Shutemov" To: Dave Hansen , seanjc@google.com Cc: tglx@linutronix.de, mingo@redhat.com, bp@alien8.de, luto@kernel.org, peterz@infradead.org, sathyanarayanan.kuppuswamy@linux.intel.com, ak@linux.intel.com, dan.j.williams@intel.com, david@redhat.com, hpa@zytor.com, thomas.lendacky@amd.com, x86@kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] x86/tdx: Handle load_unaligned_zeropad() page-cross to a shared page Message-ID: <20220517201710.ixbpsaga5jzvokvy@black.fi.intel.com> References: <20220517153021.11116-1-kirill.shutemov@linux.intel.com> <20220517174042.v6s7wm3u5j2ebaoq@black.fi.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 17, 2022 at 11:14:13AM -0700, Dave Hansen wrote: > On 5/17/22 10:40, Kirill A. Shutemov wrote: > >> > >> ve_info is a software structure. Why not just add a: > >> > >> bool ip_adjusted; > >> > >> which defaults to false, then we have: > >> > >> /* > >> * Adjust RIP if the exception was handled > >> * but RIP was not adjusted. > >> */ > >> if (!ret && !ve_info->ip_adjusted) > >> regs->ip += ve_info->instr_len; > >> > >> One other oddity I just stumbled upon: > >> > >> static bool handle_mmio(struct pt_regs *regs, struct ve_info *ve) > >> { > >> ... > >> ve->instr_len = insn.length; > >> > >> Why does that need to override 've->instr_len'? What was wrong with the > >> gunk in r10 that came out of TDX_GET_VEINFO? > > TDX module doesn't decode MMIO instruction and does not provide valid size > > of it. We had to do it manually, based on decoding. > > That's worth a comment, don't you think? I'd add one both in where the > ve_info is filled and where ve->instr_len is adjusted. Okay. Will do. > > Given that we had to adjust IP in handle_mmio() anyway, do you still think > > "ve->instr_len = 0;" is wrong? I dislike ip_adjusted more. > > Something is wrong about it. > > You could call it 've->instr_bytes_to_handle' or something. Then it > makes actual logical sense when you handle it to zero it out. I just > want it to be more explicit when the upper levels need to do something. > > Does ve->instr_len==0 both when the TDX module isn't providing > instruction sizes *and* when no handling is necessary? That seems like > an unfortunate logical multiplexing of 0. For EPT violation, ve->instr_len has *something* (not zero) that doesn't match the actual instruction size. I dig out that it is filled with data from VMREAD(0x440C), but I don't know where is the ultimate origin of the data. I don't understand virtualization side of the thing well enough. Maybe someone who knows virtualtion could comment here. Sean? -- Kirill A. Shutemov