From: Tim Deegan Subject: Re: [RFC Patch v3 18/18] x86/hvm: Always set pending event injection when loading VMC[BS] state. Date: Thu, 11 Sep 2014 12:35:16 +0200 Message-ID: <20140911103516.GB31323@deinos.phlegethon.org> References: <1409908261-18682-1-git-send-email-wency@cn.fujitsu.com> <1409908261-18682-19-git-send-email-wency@cn.fujitsu.com> <54106910.1080207@amd.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="0F1p//8PRICkK4MW" Return-path: Content-Disposition: inline In-Reply-To: <54106910.1080207@amd.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Aravind Gopalakrishnan Cc: Ian Campbell , Wen Congyang , Ian Jackson , Jiang Yunhong , Dong Eddie , xen devel , Jun Nakajima , Yang Hongyang , Suravee Suthikulpanit , Lai Jiangshan List-Id: xen-devel@lists.xenproject.org --0F1p//8PRICkK4MW Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline At 10:06 -0500 on 10 Sep (1410340016), Aravind Gopalakrishnan wrote: > Hi, > You mention that this 'fix' is just copied for svm. But you have not > seen the problem of "VM_ENTRY_INTR_INFO may be valid" (whose svm > equivalent is "vmcb->eventinj.bytes is valid"). > My concern is that we should test colo mode for svm first, since, if the > problem is never really seen on svm, then fix may not be _necessary_ I think it's obvious by inspection of the code (and indeed the patch) that SVM has the equivalent bug. > At this point, my problems are with test setups. I can help testing > scenarios, but as Wen had mentioned, 'colo testing' might be the way to > test. > So, if I can get some pointers to how I can reproduce the issue at hand, > then it would be very helpful. > > (Tim had mentioned we could try to simulate it by running a guest that > takes lot of faults and save-restore another guest over it. However, > I am not having much luck following this route. I got a hvm guest to > continuously take SW exceptions on all vcpus and tried to save-restore. > I can't see vmcb->eventinj.bytes containing any valid info.) Although I think that getting COLO running on SVM is a gret idea, it shouldn't block acceptance of this fix. I've attached a program that tests for the bug. Run it against any HVM guest (and then destroy the guest because the test will have corrupted its state). Cheers, Tim. --0F1p//8PRICkK4MW Content-Type: text/x-csrc; charset=iso-8859-1 Content-Disposition: attachment; filename="injectiontest.c" #include #include #include #include #include int main(int argc, char **argv) { xc_interface *xch; int dom; struct { struct hvm_save_descriptor hdesc; struct hvm_save_header header; struct hvm_save_descriptor cdesc; struct hvm_hw_cpu cpu; struct hvm_save_descriptor ndesc; } buf; if (argc != 2 || (dom = atoi(argv[1])) <= 0) errx(1, "usage: injectiontest "); buf.hdesc = (struct hvm_save_descriptor) { .typecode = HVM_SAVE_CODE(HEADER), .instance = 0, .length = sizeof buf.header, }; buf.header = (struct hvm_save_header) { .magic = HVM_FILE_MAGIC, .version = HVM_FILE_VERSION, }; buf.cdesc = (struct hvm_save_descriptor) { .typecode = HVM_SAVE_CODE(CPU), .instance = 0, .length = sizeof buf.cpu, }; buf.ndesc = (struct hvm_save_descriptor) { 0 }; xch = xc_interface_open(NULL, NULL, 0); printf("pausing domain\n"); if (xc_domain_pause(xch, dom)) err(1, "could not pause"); printf("reading vcpu 0\n"); if (xc_domain_hvm_getcontext_partial(xch, dom, HVM_SAVE_CODE(CPU), 0, &buf.cpu, sizeof(buf.cpu))) err(1, "could not read vcpu state"); printf("injecting an event\n"); buf.cpu.pending_valid = 1; buf.cpu.pending_vector = 14; // page fault buf.cpu.pending_type = 3; // H/W exception buf.cpu.pending_error_valid = 1; buf.cpu.error_code = 1; if (xc_domain_hvm_setcontext(xch, dom, (uint8_t *)&buf, sizeof buf)) err(1, "could not set vcpu state"); if (xc_domain_hvm_getcontext_partial(xch, dom, HVM_SAVE_CODE(CPU), 0, &buf.cpu, sizeof(buf.cpu))) err(1, "could not read vcpu state"); if (buf.cpu.pending_valid) printf("good: vcpu shows an event is pending\n"); else { printf("bad: no event pending after one was injected\n"); exit(-1); } printf("clearing the event\n"); buf.cpu.pending_event = 0; if (xc_domain_hvm_setcontext(xch, dom, (uint8_t *)&buf, sizeof buf)) err(1, "could not set vcpu state"); if (xc_domain_hvm_getcontext_partial(xch, dom, HVM_SAVE_CODE(CPU), 0, &buf.cpu, sizeof(buf.cpu))) err(1, "could not read vcpu state"); if (!buf.cpu.pending_valid) printf("good: vcpu shows no event pending\n"); else { printf("bad: existing event is still pending\n"); exit(-1); } return 0; } --0F1p//8PRICkK4MW Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --0F1p//8PRICkK4MW--