mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Naman Jain <namjain@linux.microsoft.com>
To: Michael Kelley <mhklinux@outlook.com>,
	Roman Kisel <romank@linux.microsoft.com>,
	Saurabh Singh Sengar <ssengar@microsoft.com>,
	Wei Liu <wei.liu@kernel.org>
Cc: KY Srinivasan <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Dexuan Cui <decui@microsoft.com>,
	Anirudh Rayabharam <anrayabh@linux.microsoft.com>,
	Saurabh Sengar <ssengar@linux.microsoft.com>,
	Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>,
	Nuno Das Neves <nunodasneves@linux.microsoft.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>
Subject: Re: [EXTERNAL] Re: [PATCH] Drivers: hv: Introduce mshv_vtl driver
Date: Tue, 13 May 2025 22:04:06 +0530	[thread overview]
Message-ID: <d061ea43-8aec-49ff-b013-8c9df4a7b0b5@linux.microsoft.com> (raw)
In-Reply-To: <SN6PR02MB4157D8770347E8C2EC49EBBBD496A@SN6PR02MB4157.namprd02.prod.outlook.com>



On 5/13/2025 9:00 PM, Michael Kelley wrote:
> From: Roman Kisel <romank@linux.microsoft.com> Sent: Friday, May 9, 2025 11:05 AM
>>
>> On 5/9/2025 11:02 AM, Saurabh Singh Sengar wrote:
>>>
>>>
>>
>> [...]
>>
>>>> Yep. We don't rely on user land software doing sane things to maintain
>>>> correctness in kernel, so this needs to be fixed.
>>>>
>>>> Thanks,
>>>> Wei.
>>>
>>>
>>> How about fixing this for normal x86 for now and put a TODO for CVM to be fixed
>> later, when we bring in CVM support ?
>>
>> That seems to strike the right balance ihmo :)
>> Thanks for coming up with the suggestion!
>>
> 
> FWIW, it seems like it would be pretty easy to fix the CVM case as well.  Do
> the following:
> 
> 1. Allocate memory at runtime using the normal kmalloc()
> 2. Copy from user space to that allocated memory
> 3. Disable interrupts as usual for using the per-cpu hypercall arg pages
> 4. Copy from the allocated memory to the per-cpu hypercall arg pages.
>     In a CVM this will do the conversion from encrypted memory to
>     decrypted memory.
> 5. Make the hypercall
> 6. Copy out any results to the allocated memory. Again, this will do
>     the conversion from decrypted to encrypted.
> 7. Enable interrupts
> 8. Copy results from the allocated memory to user space
> 9. Free the allocated memory
> 
> (And maybe Steps 6 and 8 don't apply if there's no output data to copy
> back to user space.)
> 
> The performance penalty is the memory allocation/free, plus the extra
> copying of the input/output hypercall arguments. But I'm guessing the
> arguments are usually on the small side, so the extra copy isn't a big issue.
> 
> Michael

Thanks for looking into this Michael. The steps you have highlighted
makes sense. There is an implementation for this here:

https://github.com/microsoft/OHCL-Linux-Kernel/blob/product/hcl-main/6.12/drivers/hv/mshv_vtl_main.c#L2275

Since CVM use-case does not exist as of today in my patch, we thought of
adding this in future patches when we add CVM support.

Regards,
Naman

  reply	other threads:[~2025-05-13 16:34 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-06  8:49 Naman Jain
2025-05-06 15:48 ` Roman Kisel
2025-05-07 10:19 ` Saurabh Singh Sengar
2025-05-07 11:21   ` Naman Jain
2025-05-07 20:31     ` Roman Kisel
2025-05-08  3:00       ` Saurabh Singh Sengar
2025-05-08 15:44         ` Roman Kisel
2025-05-08 17:44           ` Wei Liu
2025-05-08 18:13             ` Roman Kisel
2025-05-07 13:02 ` Saurabh Singh Sengar
2025-05-07 19:20   ` Roman Kisel
2025-05-08  2:59     ` Saurabh Singh Sengar
2025-05-09 18:07       ` Roman Kisel
2025-05-08  4:03     ` Michael Kelley
2025-05-08 15:34       ` Roman Kisel
2025-05-08 18:03     ` Wei Liu
2025-05-09 18:02       ` [EXTERNAL] " Saurabh Singh Sengar
2025-05-09 18:05         ` Roman Kisel
2025-05-12  4:57           ` Naman Jain
2025-05-13 15:30           ` Michael Kelley
2025-05-13 16:34             ` Naman Jain [this message]
2025-05-12  4:55   ` Naman Jain
2025-05-10 20:55 ` [External] : " ALOK TIWARI
2025-05-12 14:04   ` Naman Jain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d061ea43-8aec-49ff-b013-8c9df4a7b0b5@linux.microsoft.com \
    --to=namjain@linux.microsoft.com \
    --cc=anrayabh@linux.microsoft.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=kys@microsoft.com \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhklinux@outlook.com \
    --cc=nunodasneves@linux.microsoft.com \
    --cc=romank@linux.microsoft.com \
    --cc=skinsburskii@linux.microsoft.com \
    --cc=ssengar@linux.microsoft.com \
    --cc=ssengar@microsoft.com \
    --cc=wei.liu@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®