<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@DengXian";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:#954F72;
text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.25in 1.0in 1.25in;}
div.WordSection1
{page:WordSection1;}
/* List Definitions */
@list l0
{mso-list-id:1085610617;
mso-list-type:hybrid;
mso-list-template-ids:-1304291726 -1 67698713 67698715 67698703 67698713 67698715 67698703 67698713 67698715;}
@list l0:level1
{mso-level-text:"%1\)";
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level2
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level3
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level4
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level5
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level6
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
@list l0:level7
{mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level8
{mso-level-number-format:alpha-lower;
mso-level-tab-stop:none;
mso-level-number-position:left;
text-indent:-.25in;}
@list l0:level9
{mso-level-number-format:roman-lower;
mso-level-tab-stop:none;
mso-level-number-position:right;
text-indent:-9.0pt;}
ol
{margin-bottom:0in;}
ul
{margin-bottom:0in;}
--></style></head><body lang=EN-US link=blue vlink="#954F72"><div class=WordSection1><p class=MsoNormal>Because we have the requirement to stop trapping it immediately.</p><p class=MsoNormal><o:p> </o:p></p><ol style='margin-top:0in' start=1 type=1><li class=MsoListParagraph style='margin-left:0in;mso-list:l0 level1 lfo1'>Invalid PTE entries in PTE pages cost more efforts in GVT-g. Malicious guest can submit a lot of this kinds of page table with workload. It’s like a DDOS</li><li class=MsoListParagraph style='margin-left:0in;mso-list:l0 level1 lfo1'>If it’s not an valid PTE page and we trapped it, there will be risk of instruction which is not supported by instruction emulator in hypervisor.</li></ol><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>That’s the reason why I call lazy shadow as root fix.</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>Sent from <a href="https://go.microsoft.com/fwlink/?LinkId=550986">Mail</a> for Windows 10</p><p class=MsoNormal><o:p> </o:p></p><div style='mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in'><p class=MsoNormal style='border:none;padding:0in'><b>From: </b><a href="mailto:changbin.du@intel.com">Du, Changbin</a><br><b>Sent: </b>Thursday, October 19, 2017 9:14 AM<br><b>To: </b><a href="mailto:zhi.a.wang@intel.com">Wang, Zhi A</a><br><b>Cc: </b><a href="mailto:changbin.du@intel.com">Du, Changbin</a>; <a href="mailto:zhi.wang.linux@gmail.com">Zhi Wang</a>; <a href="mailto:intel-gvt-dev@lists.freedesktop.org">intel-gvt-dev@lists.freedesktop.org</a><br><b>Subject: </b>Re: [PATCH 2/2] drm/i915/gvt: A workaround for an regression causedby one i915 PPGTT optimization</p></div><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>On Wed, Oct 18, 2017 at 11:07:24PM -0700, Wang, Zhi A wrote:</p><p class=MsoNormal>> Practically yes. But we cannot assume guest is always behaving good. That's the reason why I call it a workaround and the root cause of fix should be the lazy shadow, which I hope I can make it work this week.</p><p class=MsoNormal>><o:p> </o:p></p><p class=MsoNormal>I'd think that's an optimization. Lazy shadowing doesn't mean invalid PTE case</p><p class=MsoNormal>is gone, right? (dont aussme guest's behaviour.)</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>> Thanks,</p><p class=MsoNormal>> Zhi.</p><p class=MsoNormal>> </p><p class=MsoNormal>> -----Original Message-----</p><p class=MsoNormal>> From: intel-gvt-dev [mailto:intel-gvt-dev-bounces@lists.freedesktop.org] On Behalf Of Du, Changbin</p><p class=MsoNormal>> Sent: Thursday, October 19, 2017 5:55 AM</p><p class=MsoNormal>> To: Zhi Wang <zhi.wang.linux@gmail.com></p><p class=MsoNormal>> Cc: Du, Changbin <changbin.du@intel.com>; intel-gvt-dev@lists.freedesktop.org; Wang, Zhi A <zhi.a.wang@intel.com></p><p class=MsoNormal>> Subject: Re: [PATCH 2/2] drm/i915/gvt: A workaround for an regression caused by one i915 PPGTT optimization</p><p class=MsoNormal>> </p><p class=MsoNormal>> I think this is not a workaround but a fix. GTE always has valid value is not a true assumption. Shadowing code should cover this case, and it is not an error (the error msg should remove).</p><p class=MsoNormal>> </p><p class=MsoNormal>> On Thu, Oct 19, 2017 at 02:30:09AM +0800, Zhi Wang wrote:</p><p class=MsoNormal>> > In the commit:</p><p class=MsoNormal>> > </p><p class=MsoNormal>> > commit 14826673247eaf36b16fd821fac27efa663f3fa6</p><p class=MsoNormal>> > Author: Chris Wilson <chris@chris-wilson.co.uk></p><p class=MsoNormal>> > Date: Fri Sep 8 19:16:22 2017 +0100</p><p class=MsoNormal>> > </p><p class=MsoNormal>> > drm/i915: Only initialize partially filled pagetables</p><p class=MsoNormal>> > </p><p class=MsoNormal>> > If we know that we will completely fill a pagetable (i.e. we are</p><p class=MsoNormal>> > inserting a complete set of 512 pages), we can skip prefilling that PT</p><p class=MsoNormal>> > with scratch entries. If we have to abort the insertion prior to writing</p><p class=MsoNormal>> > the real entries, we will teardown the pagetable and remove it from the</p><p class=MsoNormal>> > page directory (so that we will restart the allocation next time).</p><p class=MsoNormal>> > </p><p class=MsoNormal>> > We could do similar tricks for the PD and PDP, but the likelihood of a</p><p class=MsoNormal>> > single insertion covering the entire 512 entries diminishes, as do the</p><p class=MsoNormal>> > cycle savings. The saving are even greater (relatively) when we are</p><p class=MsoNormal>> > preallocating page tables for huge pages, as then we never need to fill</p><p class=MsoNormal>> > the page table.</p><p class=MsoNormal>> > </p><p class=MsoNormal>> > It will link an un-initialized PTE page into a PPGTT page table </p><p class=MsoNormal>> > tracked by GVT-g, which leads to linux guest failing to boot. Since </p><p class=MsoNormal>> > the fix of root casue still needs some time to be ready, a temporary </p><p class=MsoNormal>> > workaround is introduced first.</p><p class=MsoNormal>> > </p><p class=MsoNormal>> > Signed-off-by: Zhi Wang <zhi.a.wang@intel.com></p><p class=MsoNormal>> > ---</p><p class=MsoNormal>> > drivers/gpu/drm/i915/gvt/gtt.c | 7 ++-----</p><p class=MsoNormal>> > 1 file changed, 2 insertions(+), 5 deletions(-)</p><p class=MsoNormal>> > </p><p class=MsoNormal>> > diff --git a/drivers/gpu/drm/i915/gvt/gtt.c </p><p class=MsoNormal>> > b/drivers/gpu/drm/i915/gvt/gtt.c index 6fa9271..d24d52d 100644</p><p class=MsoNormal>> > --- a/drivers/gpu/drm/i915/gvt/gtt.c</p><p class=MsoNormal>> > +++ b/drivers/gpu/drm/i915/gvt/gtt.c</p><p class=MsoNormal>> > @@ -767,7 +767,6 @@ static int ppgtt_write_protection_handler(void </p><p class=MsoNormal>> > *data, u64 pa, {</p><p class=MsoNormal>> > struct intel_vgpu_page_track *t = data;</p><p class=MsoNormal>> > struct intel_vgpu_guest_page *p = page_track_to_guest_page(t);</p><p class=MsoNormal>> > - int ret;</p><p class=MsoNormal>> > </p><p class=MsoNormal>> > if (bytes != 4 && bytes != 8)</p><p class=MsoNormal>> > return -EINVAL;</p><p class=MsoNormal>> > @@ -775,11 +774,9 @@ static int ppgtt_write_protection_handler(void *data, u64 pa,</p><p class=MsoNormal>> > if (!t->tracked)</p><p class=MsoNormal>> > return -EINVAL;</p><p class=MsoNormal>> > </p><p class=MsoNormal>> > - ret = ppgtt_handle_guest_write_page_table_bytes(p,</p><p class=MsoNormal>> > + ppgtt_handle_guest_write_page_table_bytes(p,</p><p class=MsoNormal>> > pa, p_data, bytes);</p><p class=MsoNormal>> > - if (ret)</p><p class=MsoNormal>> > - return ret;</p><p class=MsoNormal>> > - return ret;</p><p class=MsoNormal>> > + return 0;</p><p class=MsoNormal>> > }</p><p class=MsoNormal>> > </p><p class=MsoNormal>> > static int reclaim_one_mm(struct intel_gvt *gvt);</p><p class=MsoNormal>> > --</p><p class=MsoNormal>> > 2.7.4</p><p class=MsoNormal>> > </p><p class=MsoNormal>> > _______________________________________________</p><p class=MsoNormal>> > intel-gvt-dev mailing list</p><p class=MsoNormal>> > intel-gvt-dev@lists.freedesktop.org</p><p class=MsoNormal>> > https://lists.freedesktop.org/mailman/listinfo/intel-gvt-dev</p><p class=MsoNormal>> </p><p class=MsoNormal>> --</p><p class=MsoNormal>> Thanks,</p><p class=MsoNormal>> Changbin Du</p><p class=MsoNormal><o:p> </o:p></p><p class=MsoNormal>-- </p><p class=MsoNormal>Thanks,</p><p class=MsoNormal>Changbin Du</p><p class=MsoNormal><o:p> </o:p></p></div></body></html>