Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2750795pxk; Tue, 15 Sep 2020 01:00:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyrO1QKayJT7QAMwG5cO+t2cYsHyKtQOBDyGVd2vMg7xN+GfbLIZsE6TYKKv9WU2ayrtQIh X-Received: by 2002:a50:d7d0:: with SMTP id m16mr21446428edj.105.1600156823315; Tue, 15 Sep 2020 01:00:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600156823; cv=none; d=google.com; s=arc-20160816; b=Qb5htDshQOo3HhtnvTV9vgEIs9b4/jrQfKLiseW1m3ifkkPz7R81YNkopNllHOlhbB vrVlJxdyP02tujLEJL1ZVIhVeQ4DKJI7L7mxNHmUGRfQtASLfUuL6XoKhB5zfIYUMLkM SrEJ7uzc6X8LwR+Ob25g+xug0+3k3OpX1KR9X4niE7z32O8vpBTSa8NdywW9nBuAVO/A JPUOhSSzyIoib2Q8H+NKqQu2XAYb4h2iNkEa6Wana31oZxmFbRvSznPu1GiV0unaU/2k zWHbpdu4jTgkoIEFjBPelcTeDbmnlqEZC61fvQnBCv8NWZGi5vJoIW6gu1ACqGmWOx19 6T/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ks0EcIEGIK3AL4qrGbg0K7L3TxGS5zRG2FJAe08U/nI=; b=WzPHJyxJCTz63CFRn7DXE9TEp9Ml3BhOZpoLii034c1GcEypav0Vip8HsVXIXM56z7 aK0XFs+gY5n1+OmwPu50x78Qy58Oo+RQUDY7K2iici6l7EMqNRshci04lJOD84nsL6eR VKi+xjHiMUyiuNI0CT/0ta0QUiCDx2BcEmb49chJTuQkTQd1NFPUNztYruGN70/k6s+F ZG8o2QDGm4238K+xodOCGjb0g5BXNXk60kYDdqeS9bpnWv1X/SEztsKRqyq9sG9hHs8b ijqqFwcTjDXAMlp7nIfybgNelcMXPMw5TdJrCVdDt0v63MpllCcevN0iaGctXFWqfnCx LfpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ltM9vprM; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b24si9034721edv.245.2020.09.15.01.00.01; Tue, 15 Sep 2020 01:00:23 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=ltM9vprM; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726269AbgIOHzT (ORCPT + 99 others); Tue, 15 Sep 2020 03:55:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726212AbgIOHxj (ORCPT ); Tue, 15 Sep 2020 03:53:39 -0400 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7314DC06174A; Tue, 15 Sep 2020 00:53:38 -0700 (PDT) Received: by mail-ej1-x642.google.com with SMTP id j11so3721231ejk.0; Tue, 15 Sep 2020 00:53:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=ks0EcIEGIK3AL4qrGbg0K7L3TxGS5zRG2FJAe08U/nI=; b=ltM9vprMJ7YIEK7/iTKJLI6oQqGgV6KP6ymY+BdP8uNwHVs4BaSWMddqU+sJ29pUjh zHaCNvt1Bg83H7Fpe0X8PFcrA4u24WIClcwJuY+VF2JRAbF4cjpocbuE6aArgDc0IJHs 2Xpy2OypBp9Dldtm9+e02YEeUcDL3sITMHnTkyn6TDkmmCdWj3Rg1gqj11LLZ+8WEG6m TK1pC1EOhKCAKpsthRzEHYQsrZ+q8vZu7Sm/aVo82RCcTRKRENQyI/d6KL+VvAzG6TxO GAqB3X49/If0dNao5s5tve6GLM17FACMokLYF7c34xxIMVE2Sai+SBzXIRKv3FeGHqM8 px+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=ks0EcIEGIK3AL4qrGbg0K7L3TxGS5zRG2FJAe08U/nI=; b=WBtz+nQwHuVPdwH7ldr9zEU1cZvpqI086Qeqcys7oR2xyX/H7HpjG+9uEOdl1HKtNV BLDHXkb9FFLg76+CxwVOf19RuvZ+TnB+wqVT6XYK0pSWLS8awc9N6wCcLKjlILqax4K+ CQdfnisEBvPFqluhsHNvHc8S0aaE56f+glbYK39KFkSDvbTSoMHUT0ChrgfmijhGrZJq BQMCx8CoEgc8mV4gVM40F+RFonJt4kQWwoVodL3C30PcntG86YQ1bZjWC2iYjyTfSkZe vxSDB477wzB9Yaa4qm4Xybpi6qa2FSIdLfO5wGGdoqCwpfIBPh3WpLN5JJ8uljOE+KzB OD/g== X-Gm-Message-State: AOAM533NHJiClpFQRD55TD0KQxDkQrGqqWzfehekGEt4CvS5nfNGtBHp 8UXxLvgkQTn1kgzDuz5wY68= X-Received: by 2002:a17:906:a293:: with SMTP id i19mr19146423ejz.428.1600156416855; Tue, 15 Sep 2020 00:53:36 -0700 (PDT) Received: from andrea (ip-213-220-210-175.net.upcbroadband.cz. [213.220.210.175]) by smtp.gmail.com with ESMTPSA id q1sm5436583ejy.37.2020.09.15.00.53.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 00:53:36 -0700 (PDT) Date: Tue, 15 Sep 2020 09:53:30 +0200 From: Andrea Parri To: Michael Kelley Cc: "linux-kernel@vger.kernel.org" , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Wei Liu , "linux-hyperv@vger.kernel.org" , Andres Beltran , Saruhan Karademir , Juan Vazquez Subject: Re: [PATCH v7 1/3] Drivers: hv: vmbus: Add vmbus_requestor data structure for VMBus hardening Message-ID: <20200915075253.GA3235@andrea> References: <20200907161920.71460-1-parri.andrea@gmail.com> <20200907161920.71460-2-parri.andrea@gmail.com> <20200908075216.GA5638@andrea> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 14, 2020 at 05:29:11PM +0000, Michael Kelley wrote: > From: Andrea Parri Sent: Tuesday, September 8, 2020 12:54 AM > > > > > > @@ -300,6 +303,22 @@ int hv_ringbuffer_write(struct vmbus_channel *channel, > > > > kv_list[i].iov_len); > > > > } > > > > > > > > + /* > > > > + * Allocate the request ID after the data has been copied into the > > > > + * ring buffer. Once this request ID is allocated, the completion > > > > + * path could find the data and free it. > > > > + */ > > > > + > > > > + if (desc->flags == VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED) { > > > > + rqst_id = vmbus_next_request_id(&channel->requestor, requestid); > > > > + if (rqst_id == VMBUS_RQST_ERROR) { > > > > + pr_err("No request id available\n"); > > > > + return -EAGAIN; > > > > + } > > > > + } > > > > + desc = hv_get_ring_buffer(outring_info) + old_write; > > > > + desc->trans_id = (rqst_id == VMBUS_NO_RQSTOR) ? requestid : rqst_id; > > > > + > > > > > > This is a nit, but the above would be clearer to me if written like this: > > > > > > flags = desc->flags; > > > if (flags == VMBUS_DATA_PACKET_FLAG_COMPLETION_REQUESTED) { > > > rqst_id = vmbus_next_request_id(&channel->requestor, requestid); > > > if (rqst_id == VMBUS_RQST_ERROR) { > > > pr_err("No request id available\n"); > > > return -EAGAIN; > > > } > > > } else { > > > rqst_id = requestid; > > > } > > > desc = hv_get_ring_buffer(outring_info) + old_write; > > > desc->trans_id = rqst_id; > > > > > > The value of the flags field controls what will be used as the value for the > > > rqst_id. Having another test to see which value will be used as the trans_id > > > somehow feels a bit redundant. And then rqst_id doesn't have to be initialized. > > > > Agreed, will apply in the next version. > > > > In an offline conversation, Andrea has pointed out that my proposed changes > don't work. After a second look, I'll agreed that Andrea's code is the best that > can be done, so my comments can be ignored. Thanks for the confirmation, Michael. So, I plan to keep this patch as is for the next submission of the series (to be submitted shortly...). Thanks, Andrea