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 DA5121803A; Mon, 5 Aug 2024 12:49:16 +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=1722862157; cv=none; b=buqRq7LPdTVYqZLa0DXTFIqr8gVqRIAyZsh923nwkcIszIcdpkFK4TUuvWDxm1wQbIJQyLnjJG+tn6HjeyXvthw0tvtw27pYlnvk1eXN+3NjIxHWQpydhUi2XtUh3d/vXpFyC+sLxoKIl/t1z+FYkHPOU6Vy5nYwJyz2Hqlf8s0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722862157; c=relaxed/simple; bh=oN7yTkA6xDQEBuG5GHtsavQUXvE6qMEyPms4UKJujZ0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fXveR7xKw7koDxZtQk4QwjP3dCLxTWrja0MRnjqkPSZJffzzROCDznnqBouucor8qBHwsGXgpoalZcXeaBdfs1fIg/sLhYF/KgBXTeJRcto4aVuf153Amt/eclnZMAJeN1+90YeInCr7JEV5uoZ3maGKPDhsuBDb8hRu06OcfAU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Jns5Bsv+; 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="Jns5Bsv+" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1BEBCC32782; Mon, 5 Aug 2024 12:49:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1722862156; bh=oN7yTkA6xDQEBuG5GHtsavQUXvE6qMEyPms4UKJujZ0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Jns5Bsv+cmAHvFdiZg6V+2Bp8tNXE1xLIBOw/iUkm8Pepos3gc0Phl+oJBkRssHec w+tjZcbDqguSojELJ2WdbH6ag5V8gnIkfJU12sv9fgwXbCGtapnQx5DpU+tbc+BAI6 iq7RdwJQLIon4JnpV4dxohnPFOwzSrjBI8ws74meyM2ZZpfl03y5Lh/WgrRjIFlzoo GF3MMzv+NPh4zkyJdwh1AnlLvmqC3ahncXvpnFFoDqsdMyFSbP5CPYXpk3QPNoQJWe nnpLsqbrUaf2EhwYjARw10M3nVR1oatdmQHcDTEeKb31e3ZNKrF4ccduisJC7qRqyc zqbp5Q8BiM4Zg== Date: Mon, 5 Aug 2024 14:48:59 +0200 From: Alexey Gladkov To: Thomas Gleixner Cc: linux-kernel@vger.kernel.org, linux-coco@lists.linux.dev, Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , "Kirill A. Shutemov" , Andrew Morton , Yuan Yao , Geert Uytterhoeven , Yuntao Wang , Kai Huang , Baoquan He , Oleg Nesterov , cho@microsoft.com, decui@microsoft.com, John.Starks@microsoft.com Subject: Re: [PATCH v1 1/4] x86/tdx: Split MMIO read and write operations Message-ID: References: <87a5hy7mvg.ffs@tglx> Precedence: bulk X-Mailing-List: linux-coco@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87a5hy7mvg.ffs@tglx> On Tue, Jul 30, 2024 at 08:31:15PM +0200, Thomas Gleixner wrote: > On Tue, Jul 30 2024 at 19:35, Alexey Gladkov wrote: > > To implement MMIO in userspace, additional memory checks need to be > > implemented. To avoid overly complicating the handle_mmio() function > > and to separate checks from actions, it will be split into two separate > > functions for handling read and write operations. > > It will be split? The patch splits it, no? Yes. Sorry for my english. I will reword it. > > > > +static int handle_mmio_write(struct insn *insn, enum insn_mmio_type mmio, int size, > > + struct pt_regs *regs, struct ve_info *ve) > > Please align the second line argument with the first argument in the > first line. > > > +static int handle_mmio_read(struct insn *insn, enum insn_mmio_type mmio, int size, > > + struct pt_regs *regs, struct ve_info *ve) > > +{ > > + unsigned long *reg, val; > > + int extend_size; > > + u8 extend_val = 0; > > https://www.kernel.org/doc/html/latest/process/maintainer-tip.html#variable-declarations Ok. I will fix the coding style here and in other patches. > > static int handle_mmio(struct pt_regs *regs, struct ve_info *ve) > > { > > - unsigned long *reg, val, vaddr; > > + unsigned long vaddr; > > char buffer[MAX_INSN_SIZE]; > > enum insn_mmio_type mmio; > > struct insn insn = {}; > > - int size, extend_size; > > - u8 extend_val = 0; > > + int size; > > Ditto > > > /* Only in-kernel MMIO is supported */ > > if (WARN_ON_ONCE(user_mode(regs))) > > @@ -428,12 +504,6 @@ static int handle_mmio(struct pt_regs *regs, struct ve_info *ve) > > if (WARN_ON_ONCE(mmio == INSN_MMIO_DECODE_FAILED)) > > return -EINVAL; > > Thanks, > > tglx > -- Rgrds, legion