Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1011248rdb; Mon, 19 Feb 2024 00:53:43 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUx4BkT6xyotRugyzpbBF0pAUdE0OrCTj1RM+dnH+USZC91e6xYIB2qBT9Vve+t+cz8ksL+xuQ8UCZsMBOpLP1kVsjf5TPTEpdnN2FIMg== X-Google-Smtp-Source: AGHT+IFoSDTQSv9pOtHkCPziXjkwGO39OoWaJm4ksFuXBdjDL+sl/46dMD9rcP2N2GpI6dAqKvjF X-Received: by 2002:a05:6102:1626:b0:470:4a6e:4a4e with SMTP id cu38-20020a056102162600b004704a6e4a4emr2806603vsb.29.1708332823313; Mon, 19 Feb 2024 00:53:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708332823; cv=pass; d=google.com; s=arc-20160816; b=S7lJLa3HeW8bIzR3zGVWIVN+0pv547PkRO7WLq2Hsn/409TfkX54ko4F1fVjLGI51q GBuyLXREYYdacoWt71t1rh5K/dck7tisWv8lDJdT6KQAxHzlv4qMYSL/6g9aXtkthfcm cAJqlMUkNQtZSIgncnls0q5+ly+B5yqb/39YJb1GzTfAPqfT7avYqYdZACU9JSYtKX2p 3gRtK+dZWt/v+NrUp7FCT5ohx9T9kL5MprWl+WNODBcD4g12LxHVbiaTsKPcS8SS1wkX BI7QsH6Xba/qkEdpQukmFyjW7JlNWHzBR+5oOzbPzhAquUrobaPCfn3ozRjVltxebll5 GMgA== 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=Uhl/NLzf1pKWTOib4Hh+8rrjyfqGCP+dqs0vowhNxH8=; fh=085oS1yyf5kX9qNxDuDBeQjXOhxwKWygNYWYyGVvWXs=; b=nNhlvC//oCMXFMc3B074VklQmzb7eQDWSjBExCkdcqgWc0Og9HHrtr0IAH69/2Sb9c XmCASj4bgbnZ1Lwkxxox5yHYABUWPf5TwaMi8U/0iKVH2jXZTsrpQsOUJAOcBoeUaowX HlxMJLZJkweuk/UBjGRU6KeKJoSwgSpq+vZQaXjKsv7sW25Ezd/Fd9dGUD0Q1286X55L sZlO/Fvzg4q88Z5mQZ504cjZ8zF8m/3GCXDPNC4cUGV782ZgZ/gAy00NNaxELzLEcGqV skIenPqlYm7K1Fjjq+lb/5REgfzLQjFhl25yGknV4PRP+6OXBGBq5C0Js88YZWnAeAQ4 tp2g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=usZaX8Cp; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-70973-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70973-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id z25-20020ac84559000000b0042d4c9bac63si5315113qtn.273.2024.02.19.00.53.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 00:53:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-70973-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=usZaX8Cp; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-70973-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-70973-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 160FF1C20FD8 for ; Mon, 19 Feb 2024 08:53:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 93A4023765; Mon, 19 Feb 2024 08:53:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="usZaX8Cp" 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 A547923757; Mon, 19 Feb 2024 08:53:04 +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=1708332784; cv=none; b=Q792QOum8P6ym5il6nAzt73mUjWHoQIY/HIv49P0lqx0MJmpKnD0b5pjdd3VHNuKfNBjl3RV59RJ0Tm0DI7ucKgIuP5n1hvOpEzkREpfOuT24IeAv33tA9TQYgA6Fe6pimyt3iA8+Ol47ek3N2P1cWl2nRsqm6cUIm4AaFL1tWg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708332784; c=relaxed/simple; bh=SDQufJ9z5aiPeuINsDKd9XXb7cmghsbeEma5FC1MrU0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VPGQ1FpmwXDbGcewRZYES2/qI8M899vNE/0qoXKeAtY8RPq2u4CEB8TjRg+UdIIN4aYBUAn75+QV2z+x3ARIEnTfOxPQkGqiNNBDI/NQr2dAv8cw+7q7QvrKF8s2ckQtPsZfMGOz5f15PBw04IMYQ5TVTl9TRreDs/FSPmWZ/HM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=usZaX8Cp; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA5DCC433F1; Mon, 19 Feb 2024 08:53:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1708332784; bh=SDQufJ9z5aiPeuINsDKd9XXb7cmghsbeEma5FC1MrU0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=usZaX8CpwwzXVWtYNNvZz3zqkH5sbHb5Q7ImfBBj7c1ILt/jj38fmd5torqaemTBL 9rAKxRPStF6bWaiosQc/XDTT9TzgBf5ysirRQs0iWAn8jXS0F1YWJ0xSJ+pmLu3Oft rHhjXwdWv+orYqpGX5ark3KBTkECiXpiuq02aE7w= Date: Mon, 19 Feb 2024 09:53:01 +0100 From: Greg KH To: Saurabh Sengar Cc: kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org, decui@microsoft.com, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, ssengar@microsoft.com Subject: Re: [PATCH 5/6] tools: hv: Add new fcopy application based on uio driver Message-ID: <2024021908-royal-sequester-84be@gregkh> References: <1708193020-14740-1-git-send-email-ssengar@linux.microsoft.com> <1708193020-14740-6-git-send-email-ssengar@linux.microsoft.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=us-ascii Content-Disposition: inline In-Reply-To: <1708193020-14740-6-git-send-email-ssengar@linux.microsoft.com> On Sat, Feb 17, 2024 at 10:03:39AM -0800, Saurabh Sengar wrote: > New fcopy application which utilizes uio_hv_vmbus_client driver What does this "application" do? > > Signed-off-by: Saurabh Sengar > --- > tools/hv/Build | 3 +- > tools/hv/Makefile | 10 +- > tools/hv/hv_fcopy_uio_daemon.c | 488 +++++++++++++++++++++++++++++++++ > 3 files changed, 495 insertions(+), 6 deletions(-) > create mode 100644 tools/hv/hv_fcopy_uio_daemon.c > > diff --git a/tools/hv/Build b/tools/hv/Build > index 6cf51fa4b306..7d1f1698069b 100644 > --- a/tools/hv/Build > +++ b/tools/hv/Build > @@ -1,3 +1,4 @@ > hv_kvp_daemon-y += hv_kvp_daemon.o > hv_vss_daemon-y += hv_vss_daemon.o > -hv_fcopy_daemon-y += hv_fcopy_daemon.o > +hv_fcopy_uio_daemon-y += hv_fcopy_uio_daemon.o > +hv_fcopy_uio_daemon-y += vmbus_bufring.o > diff --git a/tools/hv/Makefile b/tools/hv/Makefile > index fe770e679ae8..944180cf916e 100644 > --- a/tools/hv/Makefile > +++ b/tools/hv/Makefile > @@ -17,7 +17,7 @@ MAKEFLAGS += -r > > override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include > > -ALL_TARGETS := hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon > +ALL_TARGETS := hv_kvp_daemon hv_vss_daemon hv_fcopy_uio_daemon > ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS)) > > ALL_SCRIPTS := hv_get_dhcp_info.sh hv_get_dns_info.sh hv_set_ifconfig.sh > @@ -39,10 +39,10 @@ $(HV_VSS_DAEMON_IN): FORCE > $(OUTPUT)hv_vss_daemon: $(HV_VSS_DAEMON_IN) > $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ > > -HV_FCOPY_DAEMON_IN := $(OUTPUT)hv_fcopy_daemon-in.o > -$(HV_FCOPY_DAEMON_IN): FORCE > - $(Q)$(MAKE) $(build)=hv_fcopy_daemon > -$(OUTPUT)hv_fcopy_daemon: $(HV_FCOPY_DAEMON_IN) > +HV_FCOPY_UIO_DAEMON_IN := $(OUTPUT)hv_fcopy_uio_daemon-in.o > +$(HV_FCOPY_UIO_DAEMON_IN): FORCE > + $(Q)$(MAKE) $(build)=hv_fcopy_uio_daemon > +$(OUTPUT)hv_fcopy_uio_daemon: $(HV_FCOPY_UIO_DAEMON_IN) > $(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@ > > clean: > diff --git a/tools/hv/hv_fcopy_uio_daemon.c b/tools/hv/hv_fcopy_uio_daemon.c > new file mode 100644 > index 000000000000..f72c899328fc > --- /dev/null > +++ b/tools/hv/hv_fcopy_uio_daemon.c > @@ -0,0 +1,488 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * An implementation of host to guest copy functionality for Linux. host to guest of what? I think it's a specific type of host and guest, right? > + * > + * Copyright (C) 2023, Microsoft, Inc. > + * > + * Author : K. Y. Srinivasan > + * Author : Saurabh Sengar > + * > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include "vmbus_bufring.h" > + > +#define ICMSGTYPE_NEGOTIATE 0 > +#define ICMSGTYPE_FCOPY 7 > + > +#define WIN8_SRV_MAJOR 1 > +#define WIN8_SRV_MINOR 1 > +#define WIN8_SRV_VERSION (WIN8_SRV_MAJOR << 16 | WIN8_SRV_MINOR) > + > +#define MAX_FOLDER_NAME 15 > +#define MAX_PATH_LEN 15 > +#define FCOPY_UIO "/sys/bus/vmbus/devices/eb765408-105f-49b6-b4aa-c123b64d17d4/uio" > + > +#define FCOPY_VER_COUNT 1 > +static const int fcopy_versions[] = { > + WIN8_SRV_VERSION > +}; > + > +#define FW_VER_COUNT 1 > +static const int fw_versions[] = { > + UTIL_FW_VERSION > +}; > + > +#define HV_RING_SIZE (4 * 4096) Hey, that doesn't match the kernel driver! Why these values? > + > +unsigned char desc[HV_RING_SIZE]; > + > +static int target_fd; > +static char target_fname[PATH_MAX]; > +static unsigned long long filesize; > + > +static int hv_fcopy_create_file(char *file_name, char *path_name, __u32 flags) > +{ > + int error = HV_E_FAIL; > + char *q, *p; > + > + filesize = 0; > + p = (char *)path_name; Why the unneeded cast? > + snprintf(target_fname, sizeof(target_fname), "%s/%s", > + (char *)path_name, (char *)file_name); Again, why all of the unneeded casts? This feels very odd, so I've stopped reading here, perhaps get an internal review first before sending this out again? thanks, greg k-h