[Xen-devel] [linux-3.18 test] 112843: trouble: blocked/broken/fail/pass

2017-08-23 Thread osstest service owner
flight 112843 linux-3.18 real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112843/

Failures and problems with tests :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 build-arm64-pvops 3 capture-logs   broken REGR. vs. 112102

Tests which are failing intermittently (not blocking):
 test-amd64-amd64-xl-multivcpu  7 xen-boot  fail pass in 112817

Regressions which are regarded as allowable (not blocking):
 build-arm64   2 hosts-allocate broken REGR. vs. 112102
 build-arm64-xsm   2 hosts-allocate broken REGR. vs. 112102
 build-arm64-pvops 2 hosts-allocate broken REGR. vs. 112102

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-libvirt-xsm  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl   1 build-check(1)   blocked  n/a
 build-arm64-libvirt   1 build-check(1)   blocked  n/a
 test-arm64-arm64-examine  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-credit2   1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64-xsm   3 capture-logs  broken blocked in 112102
 build-arm64   3 capture-logs  broken blocked in 112102
 test-amd64-i386-xl-qemuu-win7-amd64 18 guest-start/win.repeat fail blocked in 
112102
 test-amd64-i386-xl-qemut-win7-amd64 17 guest-stop   fail blocked in 112102
 test-amd64-amd64-xl-qemuu-win7-amd64 17 guest-stop  fail blocked in 112102
 test-amd64-amd64-xl-qemut-win7-amd64 18 guest-start/win.repeat fail in 112817 
blocked in 112102
 test-amd64-i386-xl-qemut-win7-amd64 16 guest-localmigrate/x10 fail in 112817 
like 112102
 test-amd64-amd64-xl-qemut-win7-amd64 17 guest-stopfail like 112085
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail  like 112102
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail  like 112102
 test-amd64-amd64-xl-rtds 10 debian-install   fail  like 112102
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail  like 112102
 test-amd64-amd64-xl-qemuu-ws16-amd64 10 windows-installfail never pass
 test-amd64-amd64-xl-qemut-ws16-amd64 10 windows-installfail never pass
 test-amd64-i386-libvirt  13 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt-xsm  13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-amd64-libvirt-vhd 12 migrate-support-checkfail   never pass
 test-amd64-i386-xl-qemuu-ws16-amd64 13 guest-saverestore   fail never pass
 test-amd64-amd64-qemuu-nested-amd 17 debian-hvm-install/l1/l2  fail never pass
 test-armhf-armhf-xl-xsm  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 13 migrate-support-checkfail  never pass
 test-armhf-armhf-xl-xsm  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 14 saverestore-support-checkfail  never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-amd64-i386-xl-qemut-ws16-amd64 13 guest-saverestore   fail never pass
 test-armhf-armhf-xl-vhd  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 14 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt-raw 12 migrate-support-checkfail   never pass
 test-amd64-amd64-xl-qemut-win10-i386 10 windows-installfail never pass
 test-amd64-i386-xl-qemuu-win10-i386 10 windows-install fail never pass
 test-amd64-amd64-xl-qemuu-win10-i386 10 windows-installfail never pass
 test-amd64-i386-xl-qemut-win10-i386 10 windows-install fail never pass
 test-armhf-armhf-xl-cubietruck 13 migrate-support-checkfail never pass
 

Re: [Xen-devel] [PATCH V2 16/25] x86/vioapic: Hook interrupt delivery of vIOAPIC

2017-08-23 Thread Lan Tianyu
On 2017年08月23日 17:59, Roger Pau Monné wrote:
> On Wed, Aug 09, 2017 at 04:34:17PM -0400, Lan Tianyu wrote:
>> From: Chao Gao 
>>
>> When irq remapping is enabled, IOAPIC Redirection Entry may be in remapping
>> format. If that, generate an irq_remapping_request and call the common
>> VIOMMU abstraction's callback to handle this interrupt request. Device
>> model is responsible for checking the request's validity.
>>
>> Signed-off-by: Chao Gao 
>> Signed-off-by: Lan Tianyu 
>> ---
>>  xen/arch/x86/hvm/vioapic.c | 14 ++
>>  1 file changed, 14 insertions(+)
>>
>> diff --git a/xen/arch/x86/hvm/vioapic.c b/xen/arch/x86/hvm/vioapic.c
>> index 72cae93..322f33c 100644
>> --- a/xen/arch/x86/hvm/vioapic.c
>> +++ b/xen/arch/x86/hvm/vioapic.c
>> @@ -30,6 +30,7 @@
>>  #include 
>>  #include 
>>  #include 
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -39,6 +40,8 @@
>>  #include 
>>  #include 
>>  
>> +#include "../../../drivers/passthrough/vtd/vtd.h"
> 
> Ouch, that's not very nice. Why do you need this? I though that you
> introduced an arch-agnostic layer that should be suitable?

Yes, agree. So far, I think of introducing a callback of checking
remapping mode in viommu ops and let vIOMMU device model to check
whether vioapic is in interrupt remapping mode. Device model can use
Intel or AMD IOAPIC remapping format to parse IOAPIC entry.

> 
>>  /* HACK: Route IRQ0 only to VCPU0 to prevent time jumps. */
>>  #define IRQ0_SPECIAL_ROUTING 1
>>  
>> @@ -387,9 +390,20 @@ static void vioapic_deliver(struct hvm_vioapic 
>> *vioapic, unsigned int pin)
>>  struct vlapic *target;
>>  struct vcpu *v;
>>  unsigned int irq = vioapic->base_gsi + pin;
>> +struct IO_APIC_route_remap_entry rte = { { vioapic->redirtbl[pin].bits 
>> } };
> 
> Designated initializers please.
> 
> Roger.
> 


-- 
Best regards
Tianyu Lan

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v4] hvm: vmx/svm_cpu_up_prepare should be called only once

2017-08-23 Thread Tian, Kevin
> From: Boris Ostrovsky [mailto:boris.ostrov...@oracle.com]
> Sent: Tuesday, August 22, 2017 10:08 AM
> 
> These routines are first called via CPU_UP_PREPARE notifier by
> the BSP and then by the booting ASP from vmx_cpu_up()/_svm_cpu_up().
> 
> Avoid the unnecessary second call. Because BSP doesn't go through
> CPU_UP_PREPARE it is a special case. We pass 'bsp' flag to newly
> added _vmx_cpu_up() (just like it's already done for _svm_cpu_up())
> so they can decide whether or not to call vmx/svm_cpu_up_prepare().
> 
> Signed-off-by: Boris Ostrovsky 
> Reported-by: Andrew Cooper 

Reviewed-by: Kevin Tian 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH] x86: enable RCU based table free when PARAVIRT

2017-08-23 Thread Kirill A. Shutemov
On Wed, Aug 23, 2017 at 08:27:18PM +, Linus Torvalds wrote:
> On Wed, Aug 23, 2017 at 12:59 PM, Kirill A. Shutemov
>  wrote:
> >
> > In this case we need performance numbers for !PARAVIRT kernel.
> 
> Yes.
> 
> > Numbers for tight loop of "mmap(MAP_POPULATE); munmap()" might be
> > interesting too for worst case scenario.
> 
> Actually, I don't think you want to populate all the pages. You just
> want to populate *one* page, in order to build up the page directory
> structure, not allocate all the final points.
> 
> And we only free the actual page tables when there is nothing around,
> so it should be at least a 2MB-aligned region etc.
> 
> So you should do a *big* allocation, and then touch a single page in
> the middle, and then minmap it - that should give you maximal page
> table activity. Otherwise the page tables will generally just stay
> around.
> 
> Realistically, it's mainly exit() that frees page tables. Yes, you may
> have a few page tables free'd by a normal munmap(), but it's usually
> very limited. Which is why I suggested that script-heavy thing with
> lots of small executables. That tends to be the main realistic load
> that really causes a ton of page directory activity.

Below is test cases that allocates a lot of page tables and measuare
fork/exit time. (I'm not entirely sure it's the best way to stress the
codepath.)

Unpatched:  average 4.8322s, stddev 0.114s
Patched:average 4.8362s, stddev 0.111s

Both without PARAVIRT. Patch is modified to enable HAVE_RCU_TABLE_FREE for
!PARAVIRT too.

The test-case requires "echo 1 > /proc/sys/vm/overcommit_memory".

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

#define PUD_SIZE (1UL << 30)
#define PMD_SIZE (1UL << 21)

#define NR_PUD 4096

#define NSEC_PER_SEC10L

int main(void)
{
char *addr = NULL;
unsigned long i, j;
struct timespec start, finish;
long long nsec;

prctl(PR_SET_THP_DISABLE);
for (i = 0; i < NR_PUD ; i++) {
addr = mmap(addr + PUD_SIZE, PUD_SIZE, PROT_WRITE|PROT_READ,
MAP_ANONYMOUS|MAP_PRIVATE, -1, 0);
if (addr == MAP_FAILED) {
perror("mmap");
break;
}

for (j = 0; j < PUD_SIZE; j += PMD_SIZE)
assert(addr[j] == 0);
}

for (i = 0; i < 10; i++) {
pid_t pid;

clock_gettime(CLOCK_MONOTONIC, );
pid = fork();
if (pid == -1)
perror("fork");
if (!pid)
exit(0);
wait(NULL);
clock_gettime(CLOCK_MONOTONIC, );

nsec = (finish.tv_sec - start.tv_sec) * NSEC_PER_SEC +
(finish.tv_nsec - start.tv_nsec);
printf("%lld\n", nsec);
}

return 0;
}
-- 
 Kirill A. Shutemov

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH RESEND1 00/12] ALSA: vsnd: Add Xen para-virtualized frontend driver

2017-08-23 Thread Takashi Sakamoto

On Aug 23 2017 23:51, Oleksandr Grytsov wrote:

Hi,

Thank you for detailed explanation.

We understand that emulated interrupt on the frontend side is completely not
acceptable and definitely we need to provide some feedback mechanism from
Dom0 to DomU.

In our case it is technically impossible to provide precise period interrupt
(mostly because our backend is a user space application).
The best we can implement it is provide number of frames (time, bytes etc.)
consumed by real HW. This info will be outdated due to different delays but
we can provide precise timestamps when this info was acquired.


Stuffs of ALSA PCM in kernel land is an abstraction layer for actual
hardware for data transmission. The stuffs get affects from a design of
actual hardware. Furthermore, sound subsystems on the other operating
systems such as Microsoft Windows are also designed with a consideration
about actual hardware. When you design any interfaces as an abstraction
for such software layer, it's better to understand actual hardware and
design of low-level software layer somehow.

Actually the 'sndif' has no good abstraction for actual hardware,
therefore an idea to implement frontend driver as an ALSA driver is not
reasonable at all. It's better to implement it as an application in
the other software layer, e.g. sinks/sources of PulseAudio in DomU via
Xenbus. This idea is nearer an original concept of Xen framework, I
guess. But I don't know we can write any applications of Xenbus in user
land of DomU or not.

Anyway, it's not a good idea to have an ALSA driver for the present 
'sndif', in my opinion.



Regards

Takashi Sakamoto

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH V2 9/25] tools/libxl: build DMAR table for a guest with one virtual VTD

2017-08-23 Thread Lan Tianyu
On 2017年08月23日 16:34, Wei Liu wrote:
> On Wed, Aug 23, 2017 at 01:35:17PM +0800, Lan Tianyu wrote:
>> On 2017年08月22日 21:48, Wei Liu wrote:
> Hi, Wei
> Thanks for your comments.
>
> iirc, HVM only supports one module; DMAR cannot be a new module. Joining 
> to
> the existing one is the approach we are taking. 
>
> Which kind of conflicts you think should be resolved? If you mean I
> forget to free the old buf, I will fix this. If you mean the potential
> overlap between the binary passed by admin and DMAR table built here, I
> don't have much idea on this. Even without the DMAR table, the binary
> may contains MADT or other tables and tool stacks don't intrepret the
> binary and check whether there are conflicts, right?
>
>>> Thinking a bit more about this, when I first said "conflicts" I didn't
>>> mean to parse the content. I was referring to the code in
>>> libxl_x86_apci.c which also seems to manipulate acpi_modules.
>>
>> Code in libxl_x86_acpi.c works for Hvmlite/PVHv2. The code we added is
>> for hvm guest.
>>
> 
> That's correct for the code as-is but what is preventing the code there
> from working with HVM? Assuming correct checks and branches are added
> to appropriate places?
> 
> I'm against having multiple locations doing things that could
> potentially clash with each other. In the foreseeable future PVH is
> going to get need similar functionality.
> 
> My expectation is that if the existing code needs to be taken into
> consideration and the contributors need to figure out if and how it can
> be modified to suite their needs. If everyone is doing their own thing
> in their own little function Xen will eventually become unmaintainable.
> 
>>>
>>> I would like the code to generate dmar take into consideration
>>> libxl__dom_load_acpi.
>>>
>>
>> If add dmar table for hvmlite, we should combine dmar table with other
>> ACPI table and populate into acpi_modules[2]. This is how hvmlite add
>> other ACPI tables in libxl__dom_load_acpi().
>>
> 
> Sure, that sounds plausible.
> 
> What I would like to see is to have one entry point to manipulate APCI
> tables.
> 
> Given the patch volume we're seeing now, we expect contributors to drive
> the discussion forward. If you're not sure, feel free to ask more questions.

I am not sure whether I understood correctly.

PVHv2 builds all ACPI table in tool stack and uses acpi_module[0, 1, 2]
to pass related table content.

HVM builds ACPI tables in hvmloader and just use acpi_module[0] to pass
additional ACPI firmware or table.

These two modes have different way to use acpi_modules[]. So I think we
can't combine them, right?

For build dmar table, we have introduced construct_dmar() in under
libacpi to build dmar table and PVHv2 also can use it in
libxl__dom_load_acpi().


-- 
Best regards
Tianyu Lan

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH V2 7/25] tools/libacpi: Add new fields in acpi_config for DMAR table

2017-08-23 Thread Lan Tianyu
On 2017年08月23日 16:04, Roger Pau Monné wrote:
> On Wed, Aug 23, 2017 at 03:52:01PM +0800, Lan Tianyu wrote:
>> On 2017年08月23日 00:41, Roger Pau Monné wrote:
> +drhd = (struct acpi_dmar_hardware_unit *)((void*)dmar + 
> sizeof(*dmar));
> +drhd->type = ACPI_DMAR_TYPE_HARDWARE_UNIT;
> +drhd->length = sizeof(*drhd) + ioapic_scope_size;
> +drhd->flags = ACPI_DMAR_INCLUDE_PCI_ALL;
> +drhd->pci_segment = 0;
> +drhd->base_address = config->iommu_base_addr;
> +
> +scope = >scope[0];
> +scope->type = ACPI_DMAR_DEVICE_SCOPE_IOAPIC;
> +scope->length = ioapic_scope_size;
> +scope->enumeration_id = config->ioapic_id;
> +scope->bus = I440_PSEUDO_BUS_PLATFORM;
> +scope->path[0] = I440_PSEUDO_DEVFN_IOAPIC;
>>> I'm not sure whether this constants should instead be fields in the
>>> acpi_config struct passed down from libxl. libxc shouldn't really need
>>> to know anything about which chipset a VM is using.
>>
>> How about rename I440_PSEUDO_XXX to VIOMMU_PSEUDO_XXX?
> 
> I'm not really complaining about the naming, I'm just saying that I'm
> not sure whether this constants should live in libxl. It would be
> better IMHO if they where defined in some libxl x86 specific header,
> and passed to libxc inside of the acpi_config struct.
> 
> At the end it is libxl which decides which chipset the VM is going to
> use, not libxc.

We can do that but the bdf is reserved for IOAPIC and should be same for
different chipset. Do we still need to pass it via acpi_config?


> 
> Roger.
> 


-- 
Best regards
Tianyu Lan

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [xen-unstable test] 112841: regressions - trouble: blocked/broken/fail/pass

2017-08-23 Thread osstest service owner
flight 112841 xen-unstable real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112841/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-amd64-amd64-xl-qemuu-win7-amd64 18 guest-start/win.repeat fail REGR. vs. 
112809
 test-amd64-amd64-xl-qemut-win7-amd64 10 windows-install  fail REGR. vs. 112809
 test-amd64-i386-xl-qemut-win7-amd64 10 windows-install   fail REGR. vs. 112809
 test-amd64-i386-xl-qemut-ws16-amd64 10 windows-install   fail REGR. vs. 112809

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-libvirt-xsm  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl   1 build-check(1)   blocked  n/a
 build-arm64-libvirt   1 build-check(1)   blocked  n/a
 test-arm64-arm64-examine  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-credit2   1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64   2 hosts-allocate  broken like 112809
 build-arm64-pvops 2 hosts-allocate  broken like 112809
 build-arm64-xsm   2 hosts-allocate  broken like 112809
 build-arm64   3 capture-logsbroken like 112809
 build-arm64-xsm   3 capture-logsbroken like 112809
 build-arm64-pvops 3 capture-logsbroken like 112809
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail  like 112809
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail  like 112809
 test-amd64-i386-xl-qemuu-win7-amd64 17 guest-stop fail like 112809
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail  like 112809
 test-amd64-amd64-xl-rtds 10 debian-install   fail  like 112809
 test-armhf-armhf-xl-rtds 16 guest-start/debian.repeatfail  like 112809
 test-amd64-amd64-xl-qemuu-ws16-amd64 10 windows-installfail never pass
 test-amd64-amd64-xl-qemut-ws16-amd64 10 windows-installfail never pass
 test-amd64-i386-libvirt  13 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt-xsm  13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-armhf-armhf-xl-arndale  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  14 saverestore-support-checkfail   never pass
 test-amd64-amd64-qemuu-nested-amd 17 debian-hvm-install/l1/l2  fail never pass
 test-amd64-i386-xl-qemuu-ws16-amd64 13 guest-saverestore   fail never pass
 test-armhf-armhf-xl-xsm  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 13 migrate-support-checkfail  never pass
 test-armhf-armhf-xl-multivcpu 14 saverestore-support-checkfail  never pass
 test-armhf-armhf-xl-cubietruck 13 migrate-support-checkfail never pass
 test-armhf-armhf-xl-cubietruck 14 saverestore-support-checkfail never pass
 test-armhf-armhf-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-raw 12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  13 saverestore-support-checkfail   never pass
 test-amd64-amd64-libvirt-vhd 12 migrate-support-checkfail   never pass
 test-amd64-i386-xl-qemut-win10-i386 10 windows-install fail never pass
 test-amd64-amd64-xl-qemuu-win10-i386 10 windows-installfail never pass
 test-amd64-i386-xl-qemuu-win10-i386 10 windows-install fail never pass
 test-amd64-amd64-xl-qemut-win10-i386 10 windows-installfail never pass

version targeted for testing:
 xen  4a0485c3d343e1c582fa824e4896b9b613a14efe
baseline version:
 xen  9053a74c08fd6abf43bb45ff932b4386de7e8510

Last test of basis   112809  2017-08-22 04:57:01 Z1 days
Testing same since   

Re: [Xen-devel] [PATCH V2 11/25] x86/hvm: Introduce a emulated VTD for HVM

2017-08-23 Thread Lan Tianyu
On 2017年08月23日 15:58, Roger Pau Monné wrote:
> On Wed, Aug 09, 2017 at 04:34:12PM -0400, Lan Tianyu wrote:
>> From: Chao Gao 
>>
>> This patch adds create/destroy/query function for the emulated VTD
>> and adapts it to the common VIOMMU abstraction.
>>
>> Signed-off-by: Chao Gao 
>> Signed-off-by: Lan Tianyu 
>> ---
>>  xen/drivers/passthrough/vtd/Makefile |   7 +-
>>  xen/drivers/passthrough/vtd/iommu.h  |  99 +-
>>  xen/drivers/passthrough/vtd/vvtd.c   | 158 
>> +++
>>  xen/include/asm-x86/viommu.h |   3 +
>>  4 files changed, 241 insertions(+), 26 deletions(-)
>>  create mode 100644 xen/drivers/passthrough/vtd/vvtd.c
>>
>> diff --git a/xen/drivers/passthrough/vtd/Makefile 
>> b/xen/drivers/passthrough/vtd/Makefile
>> index f302653..163c7fe 100644
>> --- a/xen/drivers/passthrough/vtd/Makefile
>> +++ b/xen/drivers/passthrough/vtd/Makefile
>> @@ -1,8 +1,9 @@
>>  subdir-$(CONFIG_X86) += x86
>>  
>> -obj-y += iommu.o
>>  obj-y += dmar.o
>> -obj-y += utils.o
>> -obj-y += qinval.o
>>  obj-y += intremap.o
>> +obj-y += iommu.o
>> +obj-y += qinval.o
>>  obj-y += quirks.o
>> +obj-y += utils.o
>> +obj-$(CONFIG_VIOMMU) += vvtd.o
>> diff --git a/xen/drivers/passthrough/vtd/iommu.h 
>> b/xen/drivers/passthrough/vtd/iommu.h
>> index 72c1a2e..55f3b6e 100644
>> --- a/xen/drivers/passthrough/vtd/iommu.h
>> +++ b/xen/drivers/passthrough/vtd/iommu.h
>> @@ -23,31 +23,54 @@
>>  #include 
>>  
>>  /*
>> - * Intel IOMMU register specification per version 1.0 public spec.
>> + * Intel IOMMU register specification per version 2.4 public spec.
>>   */
>>  
>> -#defineDMAR_VER_REG0x0/* Arch version supported by this IOMMU */
>> -#defineDMAR_CAP_REG0x8/* Hardware supported capabilities */
>> -#defineDMAR_ECAP_REG0x10/* Extended capabilities supported */
>> -#defineDMAR_GCMD_REG0x18/* Global command register */
>> -#defineDMAR_GSTS_REG0x1c/* Global status register */
>> -#defineDMAR_RTADDR_REG0x20/* Root entry table */
>> -#defineDMAR_CCMD_REG0x28/* Context command reg */
>> -#defineDMAR_FSTS_REG0x34/* Fault Status register */
>> -#defineDMAR_FECTL_REG0x38/* Fault control register */
>> -#defineDMAR_FEDATA_REG0x3c/* Fault event interrupt data 
>> register */
>> -#defineDMAR_FEADDR_REG0x40/* Fault event interrupt addr 
>> register */
>> -#defineDMAR_FEUADDR_REG 0x44/* Upper address register */
>> -#defineDMAR_AFLOG_REG0x58/* Advanced Fault control */
>> -#defineDMAR_PMEN_REG0x64/* Enable Protected Memory Region */
>> -#defineDMAR_PLMBASE_REG 0x68/* PMRR Low addr */
>> -#defineDMAR_PLMLIMIT_REG 0x6c/* PMRR low limit */
>> -#defineDMAR_PHMBASE_REG 0x70/* pmrr high base addr */
>> -#defineDMAR_PHMLIMIT_REG 0x78/* pmrr high limit */
>> -#defineDMAR_IQH_REG0x80/* invalidation queue head */
>> -#defineDMAR_IQT_REG0x88/* invalidation queue tail */
>> -#defineDMAR_IQA_REG0x90/* invalidation queue addr */
>> -#defineDMAR_IRTA_REG   0xB8/* intr remap */
>> +#define DMAR_VER_REG0x0  /* Arch version supported by this 
>> IOMMU */
>> +#define DMAR_CAP_REG0x8  /* Hardware supported capabilities */
>> +#define DMAR_ECAP_REG   0x10 /* Extended capabilities supported */
>> +#define DMAR_GCMD_REG   0x18 /* Global command register */
>> +#define DMAR_GSTS_REG   0x1c /* Global status register */
>> +#define DMAR_RTADDR_REG 0x20 /* Root entry table */
>> +#define DMAR_CCMD_REG   0x28 /* Context command reg */
>> +#define DMAR_FSTS_REG   0x34 /* Fault Status register */
>> +#define DMAR_FECTL_REG  0x38 /* Fault control register */
>> +#define DMAR_FEDATA_REG 0x3c /* Fault event interrupt data register 
>> */
>> +#define DMAR_FEADDR_REG 0x40 /* Fault event interrupt addr register 
>> */
>> +#define DMAR_FEUADDR_REG0x44 /* Upper address register */
>> +#define DMAR_AFLOG_REG  0x58 /* Advanced Fault control */
>> +#define DMAR_PMEN_REG   0x64 /* Enable Protected Memory Region */
>> +#define DMAR_PLMBASE_REG0x68 /* PMRR Low addr */
>> +#define DMAR_PLMLIMIT_REG   0x6c /* PMRR low limit */
>> +#define DMAR_PHMBASE_REG0x70 /* pmrr high base addr */
>> +#define DMAR_PHMLIMIT_REG   0x78 /* pmrr high limit */
>> +#define DMAR_IQH_REG0x80 /* invalidation queue head */
>> +#define DMAR_IQT_REG0x88 /* invalidation queue tail */
>> +#define DMAR_IQT_REG_HI 0x8c
>> +#define DMAR_IQA_REG0x90 /* invalidation queue addr */
>> +#define DMAR_IQA_REG_HI 0x94
>> +#define DMAR_ICS_REG0x9c /* Invalidation complete status */
>> +#define DMAR_IECTL_REG  0xa0 /* Invalidation event control */
>> +#define 

[Xen-devel] [xen-4.5-testing test] 112838: tolerable FAIL - PUSHED

2017-08-23 Thread osstest service owner
flight 112838 xen-4.5-testing real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112838/

Failures :-/ but no regressions.

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-xl-rtds  7 xen-boot fail  like 110906
 test-xtf-amd64-amd64-2   59 leak-check/check fail  like 110906
 test-xtf-amd64-amd64-3   59 leak-check/check fail  like 110906
 test-xtf-amd64-amd64-4   59 leak-check/check fail  like 110906
 test-xtf-amd64-amd64-5   59 leak-check/check fail  like 110906
 test-xtf-amd64-amd64-1   59 leak-check/check fail  like 110906
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail  like 110906
 test-armhf-armhf-xl-rtds 16 guest-start/debian.repeatfail  like 110906
 test-amd64-amd64-xl-qemuu-win7-amd64 17 guest-stopfail like 110906
 test-amd64-i386-xl-qemut-win7-amd64 17 guest-stop fail like 110906
 test-amd64-i386-xl-qemuu-win7-amd64 16 guest-localmigrate/x10 fail like 110906
 test-amd64-amd64-xl-qemut-win7-amd64 17 guest-stopfail like 110906
 test-xtf-amd64-amd64-2   19 xtf/test-hvm32-cpuid-faulting fail  never pass
 test-xtf-amd64-amd64-2 33 xtf/test-hvm32pae-cpuid-faulting fail never pass
 test-xtf-amd64-amd64-2 40 xtf/test-hvm32pse-cpuid-faulting fail never pass
 test-xtf-amd64-amd64-2   44 xtf/test-hvm64-cpuid-faulting fail  never pass
 test-xtf-amd64-amd64-4   19 xtf/test-hvm32-cpuid-faulting fail  never pass
 test-xtf-amd64-amd64-5   19 xtf/test-hvm32-cpuid-faulting fail  never pass
 test-xtf-amd64-amd64-4 33 xtf/test-hvm32pae-cpuid-faulting fail never pass
 test-xtf-amd64-amd64-5 33 xtf/test-hvm32pae-cpuid-faulting fail never pass
 test-xtf-amd64-amd64-4 40 xtf/test-hvm32pse-cpuid-faulting fail never pass
 test-xtf-amd64-amd64-4   44 xtf/test-hvm64-cpuid-faulting fail  never pass
 test-xtf-amd64-amd64-5 40 xtf/test-hvm32pse-cpuid-faulting fail never pass
 test-xtf-amd64-amd64-5   44 xtf/test-hvm64-cpuid-faulting fail  never pass
 test-xtf-amd64-amd64-1   19 xtf/test-hvm32-cpuid-faulting fail  never pass
 test-xtf-amd64-amd64-1 33 xtf/test-hvm32pae-cpuid-faulting fail never pass
 test-amd64-amd64-xl-pvh-intel 15 guest-saverestorefail  never pass
 test-xtf-amd64-amd64-1 40 xtf/test-hvm32pse-cpuid-faulting fail never pass
 test-amd64-amd64-xl-pvh-amd  12 guest-start  fail   never pass
 test-xtf-amd64-amd64-1   44 xtf/test-hvm64-cpuid-faulting fail  never pass
 test-xtf-amd64-amd64-2   58 xtf/test-hvm64-xsa-195   fail   never pass
 test-amd64-i386-libvirt  13 migrate-support-checkfail   never pass
 test-xtf-amd64-amd64-3   58 xtf/test-hvm64-xsa-195   fail   never pass
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-xtf-amd64-amd64-4   58 xtf/test-hvm64-xsa-195   fail   never pass
 test-xtf-amd64-amd64-5   58 xtf/test-hvm64-xsa-195   fail   never pass
 test-xtf-amd64-amd64-1   58 xtf/test-hvm64-xsa-195   fail   never pass
 test-armhf-armhf-xl-arndale  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  14 saverestore-support-checkfail   never pass
 test-amd64-amd64-libvirt-vhd 12 migrate-support-checkfail   never pass
 test-amd64-amd64-qemuu-nested-amd 17 debian-hvm-install/l1/l2  fail never pass
 test-amd64-amd64-xl-qemuu-ws16-amd64 13 guest-saverestore  fail never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-cubietruck 13 migrate-support-checkfail never pass
 test-armhf-armhf-xl-cubietruck 14 saverestore-support-checkfail never pass
 test-armhf-armhf-libvirt 13 migrate-support-checkfail   never pass
 test-amd64-amd64-xl-qemut-ws16-amd64 13 guest-saverestore  fail never pass
 test-armhf-armhf-xl-rtds 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  11 guest-start  fail   never pass
 test-amd64-i386-xl-qemuu-ws16-amd64 13 guest-saverestore   fail never pass
 test-amd64-i386-xl-qemut-ws16-amd64 13 guest-saverestore   fail never pass
 test-armhf-armhf-xl-multivcpu 13 migrate-support-checkfail  never pass
 test-armhf-armhf-xl-multivcpu 14 saverestore-support-checkfail  never pass
 test-amd64-amd64-xl-qemut-win10-i386 10 windows-installfail never pass
 test-amd64-i386-xl-qemuu-win10-i386 10 windows-install fail never pass
 test-amd64-i386-xl-qemut-win10-i386 10 windows-install fail never pass
 

[Xen-devel] [PATCH v2 14/15] tools: implement new generic set value interface and MBA set value command

2017-08-23 Thread Yi Sun
This patch implements new generic set value interfaces in libxc and libxl.
These interfaces are suitable for all allocation features. It also adds a
new MBA set value command in xl.

Signed-off-by: Yi Sun 
---
 tools/libxc/include/xenctrl.h |  6 ++---
 tools/libxc/xc_psr.c  |  9 ---
 tools/libxl/libxl_psr.c   | 56 +--
 tools/xl/xl.h |  1 +
 tools/xl/xl_cmdtable.c|  6 +
 tools/xl/xl_psr.c | 55 ++
 6 files changed, 99 insertions(+), 34 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index d7eabfb..3161bf6 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -2499,9 +2499,9 @@ int xc_psr_cmt_get_data(xc_interface *xch, uint32_t rmid, 
uint32_t cpu,
 uint64_t *tsc);
 int xc_psr_cmt_enabled(xc_interface *xch);
 
-int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid,
-   xc_psr_val_type type, uint32_t target,
-   uint64_t data);
+int xc_psr_set_domain_data(xc_interface *xch, uint32_t domid,
+   xc_psr_val_type type, uint32_t target,
+   uint64_t data);
 int xc_psr_get_domain_data(xc_interface *xch, uint32_t domid,
xc_psr_val_type type, uint32_t target,
uint64_t *data);
diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
index de501b0..4dde76f 100644
--- a/tools/libxc/xc_psr.c
+++ b/tools/libxc/xc_psr.c
@@ -248,9 +248,9 @@ int xc_psr_cmt_enabled(xc_interface *xch)
 
 return 0;
 }
-int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid,
-   xc_psr_val_type type, uint32_t target,
-   uint64_t data)
+int xc_psr_set_domain_data(xc_interface *xch, uint32_t domid,
+   xc_psr_val_type type, uint32_t target,
+   uint64_t data)
 {
 DECLARE_DOMCTL;
 uint32_t cmd;
@@ -269,6 +269,9 @@ int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t 
domid,
 case XC_PSR_CAT_L2_CBM:
 cmd = XEN_DOMCTL_PSR_CAT_OP_SET_L2_CBM;
 break;
+case XC_PSR_MBA_THRTL:
+cmd = XEN_DOMCTL_PSR_MBA_OP_SET_THRTL;
+break;
 default:
 errno = EINVAL;
 return -1;
diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index 1f2eee2..bd10e8b 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -328,33 +328,7 @@ int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid,
   libxl_psr_cbm_type type, libxl_bitmap *target_map,
   uint64_t cbm)
 {
-GC_INIT(ctx);
-int rc;
-int socketid, nr_sockets;
-
-rc = libxl__count_physical_sockets(gc, _sockets);
-if (rc) {
-LOGED(ERROR, domid, "failed to get system socket count");
-goto out;
-}
-
-libxl_for_each_set_bit(socketid, *target_map) {
-xc_psr_val_type xc_type;
-
-if (socketid >= nr_sockets)
-break;
-
-xc_type = libxl__psr_cbm_type_to_libxc_psr_val_type(type);
-if (xc_psr_cat_set_domain_data(ctx->xch, domid, xc_type,
-   socketid, cbm)) {
-libxl__psr_alloc_log_err_msg(gc, errno, type);
-rc = ERROR_FAIL;
-}
-}
-
-out:
-GC_FREE;
-return rc;
+return libxl_psr_set_val(ctx, domid, type, target_map, cbm);
 }
 
 int libxl_psr_cat_get_cbm(libxl_ctx *ctx, uint32_t domid,
@@ -457,7 +431,33 @@ int libxl_psr_set_val(libxl_ctx *ctx, uint32_t domid,
   libxl_psr_cbm_type type, libxl_bitmap *target_map,
   uint64_t val)
 {
-return ERROR_FAIL;
+GC_INIT(ctx);
+int rc;
+int socketid, nr_sockets;
+
+rc = libxl__count_physical_sockets(gc, _sockets);
+if (rc) {
+LOGED(ERROR, domid, "failed to get system socket count");
+goto out;
+}
+
+libxl_for_each_set_bit(socketid, *target_map) {
+xc_psr_val_type xc_type;
+
+if (socketid >= nr_sockets)
+break;
+
+xc_type = libxl__psr_cbm_type_to_libxc_psr_val_type(type);
+if (xc_psr_set_domain_data(ctx->xch, domid, xc_type,
+   socketid, val)) {
+libxl__psr_alloc_log_err_msg(gc, errno, type);
+rc = ERROR_FAIL;
+}
+}
+
+out:
+GC_FREE;
+return rc;
 }
 
 int libxl_psr_get_val(libxl_ctx *ctx, uint32_t domid,
diff --git a/tools/xl/xl.h b/tools/xl/xl.h
index 59065c4..2cbe89c 100644
--- a/tools/xl/xl.h
+++ b/tools/xl/xl.h
@@ -206,6 +206,7 @@ int main_psr_cmt_show(int argc, char **argv);
 #ifdef LIBXL_HAVE_PSR_CAT
 int main_psr_cat_cbm_set(int argc, char **argv);
 int main_psr_cat_show(int argc, char **argv);
+int main_psr_mba_set(int argc, char **argv);
 int 

[Xen-devel] [PATCH v2 15/15] docs: add MBA description in docs

2017-08-23 Thread Yi Sun
This patch adds MBA description in related documents.

Signed-off-by: Yi Sun 
Acked-by: Wei Liu 
---
v2:
- state the value type shown by 'psr-mba-show'. For linear mode,
  it shows decimal value. For non-linear mode, it shows hexadecimal
  value.
  (suggested by Chao Peng)
---
 docs/man/xl.pod.1.in  | 34 +
 docs/misc/xl-psr.markdown | 63 +++
 2 files changed, 97 insertions(+)

diff --git a/docs/man/xl.pod.1.in b/docs/man/xl.pod.1.in
index 16c8306..e644b19 100644
--- a/docs/man/xl.pod.1.in
+++ b/docs/man/xl.pod.1.in
@@ -1798,6 +1798,40 @@ processed.
 
 =back
 
+=head2 Memory Bandwidth Allocation
+
+Intel Skylake and later server platforms offer capabilities to configure and
+make use of the Memory Bandwidth Allocation (MBA) mechanisms, which provides
+OS/VMMs the ability to slow misbehaving apps/VMs or create advanced closed-loop
+control system via exposing control over a credit-based throttling mechanism.
+In the Xen implementation, MBA is used to control memory bandwidth on VM basis.
+To enforce bandwidth on a specific domain, just set throttling value (THRTL)
+for the domain.
+
+=over 4
+
+=item B [I] I I
+
+Set throttling value (THRTL) for a domain. For how to specify I
+please refer to L.
+
+B
+
+=over 4
+
+=item B<-s SOCKET>, B<--socket=SOCKET>
+
+Specify the socket to process, otherwise all sockets are processed.
+
+=back
+
+=item B [I]
+
+Show MBA settings for a certain domain or all domains. For linear mode, it
+shows the decimal value. For non-linear mode, it shows hexadecimal value.
+
+=back
+
 =head1 IGNORED FOR COMPATIBILITY WITH XM
 
 xl is mostly command-line compatible with the old xm utility used with
diff --git a/docs/misc/xl-psr.markdown b/docs/misc/xl-psr.markdown
index 04dd957..39fc801 100644
--- a/docs/misc/xl-psr.markdown
+++ b/docs/misc/xl-psr.markdown
@@ -186,6 +186,69 @@ Setting data CBM for a domain:
 Setting the same code and data CBM for a domain:
 `xl psr-cat-set  `
 
+## Memory Bandwidth Allocation (MBA)
+
+Memory Bandwidth Allocation (MBA) is a new feature available on Intel
+Skylake and later server platforms that allows an OS or Hypervisor/VMM to
+slow misbehaving apps/VMs or create advanced closed-loop control system via
+exposing control over a credit-based throttling mechanism. To enforce bandwidth
+on a specific domain, just set throttling value (THRTL) into Class of Service
+(COS). MBA provides two THRTL mode. One is linear mode and the other is
+non-linear mode.
+
+In the linear mode the input precision is defined as 100-(THRTL_MAX). Values
+not an even multiple of the precision (e.g., 12%) will be rounded down (e.g.,
+to 10% delay applied).
+
+If linear values are not supported then input delay values are powers-of-two
+from zero to the THRTL_MAX value from CPUID. In this case any values not a 
power
+of two will be rounded down the next nearest power of two.
+
+For example, assuming a system with 2 domains:
+
+ * A THRTL of 0x0 for every domain means each domain can access the whole cache
+   without any delay. This is the default.
+
+ * Linear mode: Giving one domain a THRTL of 0xC and the other domain's 0 means
+   that the first domain gets 10% delay to access the cache and the other one
+   without any delay.
+
+ * Non-linear mode: Giving one domain a THRTL of 0xC and the other domain's 0
+   means that the first domain gets 8% delay to access the cache and the other
+   one without any delay.
+
+For more detailed information please refer to Intel SDM chapter
+"Introduction to Memory Bandwidth Allocation".
+
+In Xen's implementation, THRTL can be configured with libxl/xl interfaces but
+COS is maintained in hypervisor only. The cache partition granularity is per
+domain, each domain has COS=0 assigned by default, the corresponding THRTL is
+0, which means all the cache resource can be accessed without delay.
+
+### xl interfaces
+
+System MBA information such as maximum COS and maximum THRTL can be obtained 
by:
+
+`xl psr-hwinfo --mba`
+
+The simplest way to change a domain's THRTL from its default is running:
+
+`xl psr-mba-set  [OPTIONS]  `
+
+In a multi-socket system, the same thrtl will be set on each socket by default.
+Per socket thrtl can be specified with the `--socket SOCKET` option.
+
+Setting the THRTL may not be successful if insufficient COS is available. In
+such case unused COS(es) may be freed by setting THRTL of all related domains 
to
+its default value(0).
+
+Per domain THRTL settings can be shown by:
+
+`xl psr-mba-show [OPTIONS] `
+
+For linear mode, it shows the decimal value. For non-linear mode, it shows
+hexadecimal value.
+
 ## Reference
 
 [1] Intel SDM
-- 
1.9.1


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 03/15] x86: rename 'cbm_type' to 'psr_val_type' to make it general

2017-08-23 Thread Yi Sun
This patch renames 'cbm_type' to 'psr_val_type' to make it be general.
Then, we can reuse this for all psr allocation features.

Signed-off-by: Yi Sun 
Reviewed-by: Wei Liu 
---
v2:
- replace 'PSR_VAL_TYPE_{L3, L2}' to 'PSR_VAL_TYPE_{L3, L2}_CBM'.
  (suggested by Chao Peng)
---
 xen/arch/x86/domctl.c | 16 ++--
 xen/arch/x86/psr.c| 62 +--
 xen/arch/x86/sysctl.c |  4 +--
 xen/include/asm-x86/psr.h | 18 +++---
 4 files changed, 52 insertions(+), 48 deletions(-)

diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 24b998b..e1c7c70 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -1447,51 +1447,51 @@ long arch_do_domctl(
 case XEN_DOMCTL_PSR_CAT_OP_SET_L3_CBM:
 ret = psr_set_val(d, domctl->u.psr_alloc_op.target,
   domctl->u.psr_alloc_op.data,
-  PSR_CBM_TYPE_L3);
+  PSR_VAL_TYPE_L3_CBM);
 break;
 
 case XEN_DOMCTL_PSR_CAT_OP_SET_L3_CODE:
 ret = psr_set_val(d, domctl->u.psr_alloc_op.target,
   domctl->u.psr_alloc_op.data,
-  PSR_CBM_TYPE_L3_CODE);
+  PSR_VAL_TYPE_L3_CODE);
 break;
 
 case XEN_DOMCTL_PSR_CAT_OP_SET_L3_DATA:
 ret = psr_set_val(d, domctl->u.psr_alloc_op.target,
   domctl->u.psr_alloc_op.data,
-  PSR_CBM_TYPE_L3_DATA);
+  PSR_VAL_TYPE_L3_DATA);
 break;
 
 case XEN_DOMCTL_PSR_CAT_OP_SET_L2_CBM:
 ret = psr_set_val(d, domctl->u.psr_alloc_op.target,
   domctl->u.psr_alloc_op.data,
-  PSR_CBM_TYPE_L2);
+  PSR_VAL_TYPE_L2_CBM);
 break;
 
 case XEN_DOMCTL_PSR_CAT_OP_GET_L3_CBM:
 ret = psr_get_val(d, domctl->u.psr_alloc_op.target,
-  , PSR_CBM_TYPE_L3);
+  , PSR_VAL_TYPE_L3_CBM);
 domctl->u.psr_alloc_op.data = val32;
 copyback = true;
 break;
 
 case XEN_DOMCTL_PSR_CAT_OP_GET_L3_CODE:
 ret = psr_get_val(d, domctl->u.psr_alloc_op.target,
-  , PSR_CBM_TYPE_L3_CODE);
+  , PSR_VAL_TYPE_L3_CODE);
 domctl->u.psr_alloc_op.data = val32;
 copyback = true;
 break;
 
 case XEN_DOMCTL_PSR_CAT_OP_GET_L3_DATA:
 ret = psr_get_val(d, domctl->u.psr_alloc_op.target,
-  , PSR_CBM_TYPE_L3_DATA);
+  , PSR_VAL_TYPE_L3_DATA);
 domctl->u.psr_alloc_op.data = val32;
 copyback = true;
 break;
 
 case XEN_DOMCTL_PSR_CAT_OP_GET_L2_CBM:
 ret = psr_get_val(d, domctl->u.psr_alloc_op.target,
-  , PSR_CBM_TYPE_L2);
+  , PSR_VAL_TYPE_L2_CBM);
 domctl->u.psr_alloc_op.data = val32;
 copyback = true;
 break;
diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c
index 3622de0..da62f81 100644
--- a/xen/arch/x86/psr.c
+++ b/xen/arch/x86/psr.c
@@ -100,24 +100,24 @@ static const struct feat_props {
 unsigned int cos_num;
 
 /*
- * An array to save all 'enum cbm_type' values of the feature. It is
+ * An array to save all 'enum psr_val_type' values of the feature. It is
  * used with cos_num together to get/write a feature's COS registers
  * values one by one.
  */
-enum cbm_type type[MAX_COS_NUM];
+enum psr_val_type type[MAX_COS_NUM];
 
 /*
  * alt_type is 'alternative type'. When this 'alt_type' is input, the
  * feature does some special operations.
  */
-enum cbm_type alt_type;
+enum psr_val_type alt_type;
 
 /* get_feat_info is used to return feature HW info through sysctl. */
 bool (*get_feat_info)(const struct feat_node *feat,
   uint32_t data[], unsigned int array_len);
 
 /* write_msr is used to write out feature MSR register. */
-void (*write_msr)(unsigned int cos, uint32_t val, enum cbm_type type);
+void (*write_msr)(unsigned int cos, uint32_t val, enum psr_val_type type);
 } *feat_props[FEAT_TYPE_NUM];
 
 /*
@@ -216,13 +216,13 @@ static void free_socket_resources(unsigned int socket)
 bitmap_zero(info->dom_set, DOMID_IDLE + 1);
 }
 
-static enum psr_feat_type psr_cbm_type_to_feat_type(enum cbm_type type)
+static enum psr_feat_type psr_val_type_to_feat_type(enum psr_val_type type)
 {
 enum psr_feat_type feat_type = FEAT_TYPE_UNKNOWN;
 
 switch ( type )
 {
-case PSR_CBM_TYPE_L3:
+case PSR_VAL_TYPE_L3_CBM:
 feat_type = FEAT_TYPE_L3_CAT;
 
 /*
@@ 

[Xen-devel] [PATCH v2 11/15] tools: implement the new xl get hw info interface

2017-08-23 Thread Yi Sun
This patch implements a new xl get HW info interface. A new argument
is added for psr-hwinfo command to get and show MBA HW info.

Signed-off-by: Yi Sun 
---
v2:
- split out this patch from a big patch in v1.
  (suggested by Wei Liu)
- change 'MBA_INFO' to 'MBA'. Also, change 'mba_info' to 'mba'.
  (suggested by Chao Peng)
---
 tools/xl/xl_cmdtable.c |  1 +
 tools/xl/xl_psr.c  | 39 +--
 2 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index 2c71a9f..5ac8a7e 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -524,6 +524,7 @@ struct cmd_spec cmd_table[] = {
   "[options]",
   "-m, --cmt   Show Cache Monitoring Technology (CMT) hardware info\n"
   "-a, --cat   Show Cache Allocation Technology (CAT) hardware info\n"
+  "-b, --mba   Show Memory Bandwidth Allocation (MBA) hardware info\n"
 },
 { "psr-cmt-attach",
   _psr_cmt_attach, 0, 1,
diff --git a/tools/xl/xl_psr.c b/tools/xl/xl_psr.c
index 7309d4f..ea37967 100644
--- a/tools/xl/xl_psr.c
+++ b/tools/xl/xl_psr.c
@@ -479,6 +479,33 @@ static int psr_l2_cat_hwinfo(void)
 return rc;
 }
 
+static int psr_mba_hwinfo(void)
+{
+int rc;
+unsigned int i, nr;
+libxl_psr_hw_info *info;
+
+rc = libxl_psr_get_hw_info(ctx, , ,
+   LIBXL_PSR_FEAT_TYPE_MBA, 0);
+if (rc)
+return rc;
+
+printf("Memory Bandwidth Allocation (MBA):\n");
+
+for (i = 0; i < nr; i++) {
+printf("%-16s: %u\n", "Socket ID", info[i].id);
+printf("%-16s: %s\n", "Linear Mode",
+   info[i].u.mba.linear ? "Enabled" : "Disabled");
+printf("%-16s: %u\n", "Maximum COS", info[i].u.mba.cos_max);
+printf("%-16s: %u\n", "Maximum Throttling Value",
+   info[i].u.mba.thrtl_max);
+printf("%-16s: %u\n", "Default Throttling Value", 0);
+}
+
+libxl_psr_hw_info_list_free(info, nr);
+return rc;
+}
+
 int main_psr_cat_cbm_set(int argc, char **argv)
 {
 uint32_t domid;
@@ -597,20 +624,24 @@ int main_psr_cat_show(int argc, char **argv)
 int main_psr_hwinfo(int argc, char **argv)
 {
 int opt, ret = 0;
-bool all = true, cmt = false, cat = false;
+bool all = true, cmt = false, cat = false, mba = false;
 static struct option opts[] = {
 {"cmt", 0, 0, 'm'},
 {"cat", 0, 0, 'a'},
+{"mba", 0, 0, 'b'},
 COMMON_LONG_OPTS
 };
 
-SWITCH_FOREACH_OPT(opt, "ma", opts, "psr-hwinfo", 0) {
+SWITCH_FOREACH_OPT(opt, "mab", opts, "psr-hwinfo", 0) {
 case 'm':
 all = false; cmt = true;
 break;
 case 'a':
 all = false; cat = true;
 break;
+case 'b':
+all = false; mba = true;
+break;
 }
 
 if (!ret && (all || cmt))
@@ -623,6 +654,10 @@ int main_psr_hwinfo(int argc, char **argv)
 if (all || cat)
 ret = psr_l2_cat_hwinfo();
 
+/* MBA is independent of CMT and CAT */
+if (all || mba)
+ret = psr_mba_hwinfo();
+
 return ret;
 }
 
-- 
1.9.1


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 13/15] tools: implement new generic get value interface and MBA get value command

2017-08-23 Thread Yi Sun
This patch implements generic get value interfaces in libxc and libxl.
It also refactors the get value flow in xl to make it be suitable for all
allocation features. Based on that, a new MBA get value command is added in xl.

Signed-off-by: Yi Sun 
Acked-by: Wei Liu 
---
v2:
- change 'CAT_INFO'/'MBA_INFO' to 'CAT'/'MBA'. The related structure names
  are changed too.
  (suggested by Chao Peng)
---
 tools/libxc/include/xenctrl.h |   7 +-
 tools/libxc/xc_psr.c  |   9 +-
 tools/libxl/libxl_psr.c   |  51 
 tools/xl/xl.h |   1 +
 tools/xl/xl_cmdtable.c|   5 ++
 tools/xl/xl_psr.c | 185 +-
 6 files changed, 179 insertions(+), 79 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index f1c629e..d7eabfb 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -2455,6 +2455,7 @@ enum xc_psr_val_type {
 XC_PSR_CAT_L3_CBM_CODE = 2,
 XC_PSR_CAT_L3_CBM_DATA = 3,
 XC_PSR_CAT_L2_CBM  = 4,
+XC_PSR_MBA_THRTL   = 5,
 };
 typedef enum xc_psr_val_type xc_psr_val_type;
 
@@ -2501,9 +2502,9 @@ int xc_psr_cmt_enabled(xc_interface *xch);
 int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid,
xc_psr_val_type type, uint32_t target,
uint64_t data);
-int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid,
-   xc_psr_val_type type, uint32_t target,
-   uint64_t *data);
+int xc_psr_get_domain_data(xc_interface *xch, uint32_t domid,
+   xc_psr_val_type type, uint32_t target,
+   uint64_t *data);
 int xc_psr_get_hw_info(xc_interface *xch, uint32_t socket,
xc_psr_feat_type type, xc_psr_hw_info *hw_info);
 
diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
index c69e943..de501b0 100644
--- a/tools/libxc/xc_psr.c
+++ b/tools/libxc/xc_psr.c
@@ -283,9 +283,9 @@ int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t 
domid,
 return do_domctl(xch, );
 }
 
-int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid,
-   xc_psr_val_type type, uint32_t target,
-   uint64_t *data)
+int xc_psr_get_domain_data(xc_interface *xch, uint32_t domid,
+   xc_psr_val_type type, uint32_t target,
+   uint64_t *data)
 {
 int rc;
 DECLARE_DOMCTL;
@@ -305,6 +305,9 @@ int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t 
domid,
 case XC_PSR_CAT_L2_CBM:
 cmd = XEN_DOMCTL_PSR_CAT_OP_GET_L2_CBM;
 break;
+case XC_PSR_MBA_THRTL:
+cmd = XEN_DOMCTL_PSR_MBA_OP_GET_THRTL;
+break;
 default:
 errno = EINVAL;
 return -1;
diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index c97dca4..1f2eee2 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -71,16 +71,30 @@ static void libxl__psr_cmt_log_err_msg(libxl__gc *gc, int 
err)
 LOGE(ERROR, "%s", msg);
 }
 
-static void libxl__psr_cat_log_err_msg(libxl__gc *gc, int err)
+static void libxl__psr_alloc_log_err_msg(libxl__gc *gc,
+ int err,
+ libxl_psr_cbm_type type)
 {
+/*
+ * Index is 'libxl_psr_cbm_type' so we set two 'CDP' to correspond to
+ * DATA and CODE.
+ */
+const char * const feat_name[6] = {
+"UNKNOWN",
+"L3 CAT",
+"CDP",
+"CDP",
+"L2 CAT",
+"MBA",
+};
 char *msg;
 
 switch (err) {
 case ENODEV:
-msg = "CAT is not supported in this system";
+msg = "is not supported in this system";
 break;
 case ENOENT:
-msg = "CAT is not enabled on the socket";
+msg = "is not enabled on the socket";
 break;
 case EOVERFLOW:
 msg = "no free COS available";
@@ -106,7 +120,7 @@ static void libxl__psr_cat_log_err_msg(libxl__gc *gc, int 
err)
 return;
 }
 
-LOGE(ERROR, "%s", msg);
+LOGE(ERROR, "%s: %s", feat_name[type], msg);
 }
 
 static int libxl__pick_socket_cpu(libxl__gc *gc, uint32_t socketid)
@@ -333,7 +347,7 @@ int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid,
 xc_type = libxl__psr_cbm_type_to_libxc_psr_val_type(type);
 if (xc_psr_cat_set_domain_data(ctx->xch, domid, xc_type,
socketid, cbm)) {
-libxl__psr_cat_log_err_msg(gc, errno);
+libxl__psr_alloc_log_err_msg(gc, errno, type);
 rc = ERROR_FAIL;
 }
 }
@@ -347,18 +361,7 @@ int libxl_psr_cat_get_cbm(libxl_ctx *ctx, uint32_t domid,
   libxl_psr_cbm_type type, uint32_t target,
   uint64_t *cbm_r)
 {
-

[Xen-devel] [PATCH v2 12/15] tools: rename 'xc_psr_cat_type' to 'xc_psr_val_type'

2017-08-23 Thread Yi Sun
This patch renames 'xc_psr_cat_type' to 'xc_psr_val_type' so that
the structure name is common for all allocation features.

Signed-off-by: Yi Sun 
Acked-by: Wei Liu 
Reviewed-by: Chao Peng 
---
 tools/libxc/include/xenctrl.h |  8 
 tools/libxc/xc_psr.c  |  4 ++--
 tools/libxl/libxl_psr.c   | 12 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index 81a6f48..f1c629e 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -2450,13 +2450,13 @@ enum xc_psr_cmt_type {
 };
 typedef enum xc_psr_cmt_type xc_psr_cmt_type;
 
-enum xc_psr_cat_type {
+enum xc_psr_val_type {
 XC_PSR_CAT_L3_CBM  = 1,
 XC_PSR_CAT_L3_CBM_CODE = 2,
 XC_PSR_CAT_L3_CBM_DATA = 3,
 XC_PSR_CAT_L2_CBM  = 4,
 };
-typedef enum xc_psr_cat_type xc_psr_cat_type;
+typedef enum xc_psr_val_type xc_psr_val_type;
 
 enum xc_psr_feat_type {
 XC_PSR_FEAT_UNKNOWN,
@@ -2499,10 +2499,10 @@ int xc_psr_cmt_get_data(xc_interface *xch, uint32_t 
rmid, uint32_t cpu,
 int xc_psr_cmt_enabled(xc_interface *xch);
 
 int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid,
-   xc_psr_cat_type type, uint32_t target,
+   xc_psr_val_type type, uint32_t target,
uint64_t data);
 int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid,
-   xc_psr_cat_type type, uint32_t target,
+   xc_psr_val_type type, uint32_t target,
uint64_t *data);
 int xc_psr_get_hw_info(xc_interface *xch, uint32_t socket,
xc_psr_feat_type type, xc_psr_hw_info *hw_info);
diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
index ba412e4..c69e943 100644
--- a/tools/libxc/xc_psr.c
+++ b/tools/libxc/xc_psr.c
@@ -249,7 +249,7 @@ int xc_psr_cmt_enabled(xc_interface *xch)
 return 0;
 }
 int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t domid,
-   xc_psr_cat_type type, uint32_t target,
+   xc_psr_val_type type, uint32_t target,
uint64_t data)
 {
 DECLARE_DOMCTL;
@@ -284,7 +284,7 @@ int xc_psr_cat_set_domain_data(xc_interface *xch, uint32_t 
domid,
 }
 
 int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid,
-   xc_psr_cat_type type, uint32_t target,
+   xc_psr_val_type type, uint32_t target,
uint64_t *data)
 {
 int rc;
diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index d7da7d7..c97dca4 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -303,11 +303,11 @@ out:
 return rc;
 }
 
-static inline xc_psr_cat_type libxl__psr_cbm_type_to_libxc_psr_cat_type(
+static inline xc_psr_val_type libxl__psr_cbm_type_to_libxc_psr_val_type(
 libxl_psr_cbm_type type)
 {
-BUILD_BUG_ON(sizeof(libxl_psr_cbm_type) != sizeof(xc_psr_cat_type));
-return (xc_psr_cat_type)type;
+BUILD_BUG_ON(sizeof(libxl_psr_cbm_type) != sizeof(xc_psr_val_type));
+return (xc_psr_val_type)type;
 }
 
 int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid,
@@ -325,12 +325,12 @@ int libxl_psr_cat_set_cbm(libxl_ctx *ctx, uint32_t domid,
 }
 
 libxl_for_each_set_bit(socketid, *target_map) {
-xc_psr_cat_type xc_type;
+xc_psr_val_type xc_type;
 
 if (socketid >= nr_sockets)
 break;
 
-xc_type = libxl__psr_cbm_type_to_libxc_psr_cat_type(type);
+xc_type = libxl__psr_cbm_type_to_libxc_psr_val_type(type);
 if (xc_psr_cat_set_domain_data(ctx->xch, domid, xc_type,
socketid, cbm)) {
 libxl__psr_cat_log_err_msg(gc, errno);
@@ -349,7 +349,7 @@ int libxl_psr_cat_get_cbm(libxl_ctx *ctx, uint32_t domid,
 {
 GC_INIT(ctx);
 int rc = 0;
-xc_psr_cat_type xc_type = libxl__psr_cbm_type_to_libxc_psr_cat_type(type);
+xc_psr_val_type xc_type = libxl__psr_cbm_type_to_libxc_psr_val_type(type);
 
 if (xc_psr_cat_get_domain_data(ctx->xch, domid, xc_type,
target, cbm_r)) {
-- 
1.9.1


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 01/15] docs: create Memory Bandwidth Allocation (MBA) feature document

2017-08-23 Thread Yi Sun
This patch creates MBA feature document in doc/features/. It describes
key points to implement MBA which is described in details in Intel SDM
"Introduction to Memory Bandwidth Allocation".

Signed-off-by: Yi Sun 
---
v2:
- declare 'HW' in Terminology.
  (suggested by Chao Peng)
- replace 'COS ID of VCPU' to 'COS ID of domain'.
  (suggested by Chao Peng)
- replace 'COS register' to 'Thrtl MSR'.
  (suggested by Chao Peng)
- add description for 'psr-mba-show' to state that the decimal value is
  shown for linear mode but hexadecimal value is shown for non-linear mode.
  (suggested by Chao Peng)
- remove content in 'Areas for improvement'.
  (suggested by Chao Peng)
- use '<>' to specify mandatory argument to a command.
  (suggested by Wei Liu)
v1:
- remove a special character to avoid the error when building pandoc.
---
 docs/features/intel_psr_mba.pandoc | 256 +
 1 file changed, 256 insertions(+)
 create mode 100644 docs/features/intel_psr_mba.pandoc

diff --git a/docs/features/intel_psr_mba.pandoc 
b/docs/features/intel_psr_mba.pandoc
new file mode 100644
index 000..21592e8
--- /dev/null
+++ b/docs/features/intel_psr_mba.pandoc
@@ -0,0 +1,256 @@
+% Intel Memory Bandwidth Allocation (MBA) Feature
+% Revision 1.4
+
+\clearpage
+
+# Basics
+
+ 
+ Status: **Tech Preview**
+
+Architecture(s): Intel x86
+
+   Component(s): Hypervisor, toolstack
+
+   Hardware: MBA is supported on Skylake Server and beyond
+ 
+
+# Terminology
+
+* CAT Cache Allocation Technology
+* CBM Capacity BitMasks
+* CDP Code and Data Prioritization
+* COS/CLOSClass of Service
+* HW  Hardware
+* MBA Memory Bandwidth Allocation
+* MSRsMachine Specific Registers
+* PSR Intel Platform Shared Resource
+* THRTL   Throttle value or delay value
+
+# Overview
+
+The Memory Bandwidth Allocation (MBA) feature provides indirect and approximate
+control over memory bandwidth available per-core. This feature provides OS/
+hypervisor the ability to slow misbehaving apps/domains or create advanced
+closed-loop control system via exposing control over a credit-based throttling
+mechanism.
+
+# User details
+
+* Feature Enabling:
+
+  Add "psr=mba" to boot line parameter to enable MBA feature.
+
+* xl interfaces:
+
+  1. `psr-mba-show [domain-id]`:
+
+ Show memory bandwidth throttling for domain. For linear mode, it shows the
+ decimal value. For non-linear mode, it shows hexadecimal value.
+
+  2. `psr-mba-set [OPTIONS]  `:
+
+ Set memory bandwidth throttling for domain.
+
+ Options:
+ '-s': Specify the socket to process, otherwise all sockets are processed.
+
+ Throttling value set in register implies memory bandwidth blocked, i.e.
+ higher throttling value results in lower bandwidth. The max throttling
+ value can be got through CPUID.
+
+ The response of the throttling value could be linear mode or non-linear
+ mode.
+
+ Linear mode: the input precision is defined as 100-(MBA_MAX). For 
instance,
+ if the MBA_MAX value is 90, the input precision is 10%. Values not an even
+ multiple of the precision (e.g., 12%) will be rounded down (e.g., to 10%
+ delay applied) by HW automatically.
+
+ Non-linear mode: input delay values are powers-of-two from zero to the
+ MBA_MAX value from CPUID. In this case any values not a power of two will
+ be rounded down the next nearest power of two by HW automatically.
+
+# Technical details
+
+MBA is a member of Intel PSR features, it shares the base PSR infrastructure
+in Xen.
+
+## Hardware perspective
+
+  MBA defines a range of MSRs to support specifying a delay value (Thrtl) per
+  COS, with details below.
+
+  ```
+   +++
+   | MSR (per socket)   |Address |
+   +++
+   | IA32_L2_QOS_Ext_BW_Thrtl_0 | 0xD50  |
+   +++
+   | ...|  ...   |
+   +++
+   | IA32_L2_QOS_Ext_BW_Thrtl_n | 0xD50+n (n<64) |
+   +++
+  ```
+
+  When context switch happens, the COS ID of domain is written to per-thread 
MSR
+  `IA32_PQR_ASSOC`, and then hardware enforces bandwidth allocation according
+  to the throttling value stored in the Thrtl MSR register.
+
+## The relationship between MBA and CAT/CDP
+
+  Generally speaking, MBA is completely independent of CAT/CDP, and any
+  combination may be applied at any time, e.g. enabling MBA with CAT
+  disabled.
+
+  But it needs to be noticed that MBA shares COS infrastructure with CAT,
+  although MBA is enumerated by different 

[Xen-devel] [PATCH v2 04/15] x86: implement data structure and CPU init flow for MBA

2017-08-23 Thread Yi Sun
This patch implements main data structures of MBA.

Like CAT features, MBA HW info has cos_max which means the max thrtl
register number, and thrtl_max which means the max throttle value
(delay value). It also has a flag to represent if the throttle
value is linear or not.

One thrtl register of MBA stores a throttle value for one or more
domains. The throttle value means the transaction time between L2
cache and next level memory to be delayed.

This patch also implements init flow for MBA and register stub
callback functions.

Signed-off-by: Yi Sun 
---
v2:
- modify commit message to replace 'cos register' to 'thrtl register' to
  make it accurate.
  (suggested by Chao Peng)
- restore the place of the sentence to assign value to 'feat->cbm_len'
  because the MBA init flow is splitted out as a separate function in v1.
  (suggested by Chao Peng)
- add comment to explain what the MBA thrtl defaul value '0' stands for.
  (suggested by Chao Peng)
- check 'thrtl_max' under linear mode. It could not be euqal or larger than
  100.
  (suggested by Chao Peng)
v1:
- rebase codes onto L2 CAT v15.
- move comment to appropriate place.
  (suggested by Chao Peng)
- implement 'mba_init_feature' and keep 'cat_init_feature'.
  (suggested by Chao Peng)
- keep 'regs.b' into a local variable to avoid reading CPUID every time.
  (suggested by Chao Peng)
---
 xen/arch/x86/psr.c  | 141 +++-
 xen/include/asm-x86/msr-index.h |   1 +
 xen/include/asm-x86/psr.h   |   2 +
 3 files changed, 126 insertions(+), 18 deletions(-)

diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c
index da62f81..f5e99ce 100644
--- a/xen/arch/x86/psr.c
+++ b/xen/arch/x86/psr.c
@@ -27,13 +27,16 @@
  * - CMT Cache Monitoring Technology
  * - COS/CLOSClass of Service. Also mean COS registers.
  * - COS_MAX Max number of COS for the feature (minus 1)
+ * - MBA Memory Bandwidth Allocation
  * - MSRsMachine Specific Registers
  * - PSR Intel Platform Shared Resource
+ * - THRTL_MAX   Max throttle value (delay value) of MBA
  */
 
 #define PSR_CMT(1u << 0)
 #define PSR_CAT(1u << 1)
 #define PSR_CDP(1u << 2)
+#define PSR_MBA(1u << 3)
 
 #define CAT_CBM_LEN_MASK 0x1f
 #define CAT_COS_MAX_MASK 0x
@@ -60,10 +63,14 @@
  */
 #define MAX_COS_NUM 2
 
+#define MBA_LINEAR (1u << 2)
+#define MBA_THRTL_MAX_MASK 0xfff
+
 enum psr_feat_type {
 FEAT_TYPE_L3_CAT,
 FEAT_TYPE_L3_CDP,
 FEAT_TYPE_L2_CAT,
+FEAT_TYPE_MBA,
 FEAT_TYPE_NUM,
 FEAT_TYPE_UNKNOWN,
 };
@@ -71,7 +78,6 @@ enum psr_feat_type {
 /*
  * This structure represents one feature.
  * cos_max - The max COS registers number got through CPUID.
- * cbm_len - The length of CBM got through CPUID.
  * cos_reg_val - Array to store the values of COS registers. One entry stores
  *   the value of one COS register.
  *   For L3 CAT and L2 CAT, one entry corresponds to one COS_ID.
@@ -80,9 +86,23 @@ enum psr_feat_type {
  *   cos_reg_val[1] (Code).
  */
 struct feat_node {
-/* cos_max and cbm_len are common values for all features so far. */
+/* cos_max is common values for all features so far. */
 unsigned int cos_max;
-unsigned int cbm_len;
+
+/* Feature specific HW info. */
+union {
+struct {
+/* The length of CBM got through CPUID. */
+unsigned int cbm_len;
+} cat_info;
+
+struct {
+/* The max throttling value got through CPUID. */
+unsigned int thrtl_max;
+unsigned int linear;
+} mba_info;
+};
+
 uint32_t cos_reg_val[MAX_COS_REG_CNT];
 };
 
@@ -161,6 +181,7 @@ static DEFINE_PER_CPU(struct psr_assoc, psr_assoc);
  */
 static struct feat_node *feat_l3;
 static struct feat_node *feat_l2_cat;
+static struct feat_node *feat_mba;
 
 /* Common functions */
 #define cat_default_val(len) (0x >> (32 - (len)))
@@ -273,7 +294,7 @@ static bool psr_check_cbm(unsigned int cbm_len, unsigned 
long cbm)
 return true;
 }
 
-/* CAT common functions implementation. */
+/* Implementation of allocation features' functions. */
 static int cat_init_feature(const struct cpuid_leaf *regs,
 struct feat_node *feat,
 struct psr_socket_info *info,
@@ -289,8 +310,8 @@ static int cat_init_feature(const struct cpuid_leaf *regs,
 if ( !regs->a || !regs->d )
 return -ENOENT;
 
-feat->cbm_len = (regs->a & CAT_CBM_LEN_MASK) + 1;
 feat->cos_max = min(opt_cos_max, regs->d & CAT_COS_MAX_MASK);
+feat->cat_info.cbm_len = (regs->a & CAT_CBM_LEN_MASK) + 1;
 
 switch ( type )
 {
@@ -300,12 +321,12 @@ static int cat_init_feature(const struct cpuid_leaf *regs,
 return -ENOENT;
 
 /* We reserve cos=0 as default cbm (all bits within 

[Xen-devel] [PATCH v2 02/15] Rename PSR sysctl/domctl interfaces and xsm policy to make them be general

2017-08-23 Thread Yi Sun
This patch renames PSR sysctl/domctl interfaces and related xsm policy to
make them be general for all resource allocation features but not only
for CAT. Then, we can resuse the interfaces for all allocation features.

Basically, it changes 'cat' to 'alloc'. E.g.:
1. psr_cat_op -> psr_alloc_op
2. XEN_DOMCTL_psr_cat_op -> XEN_DOMCTL_psr_alloc_op
3. XEN_SYSCTL_psr_cat_op -> XEN_SYSCTL_psr_alloc_op

The sysctl/domctl version numbers are bumped.

Signed-off-by: Yi Sun 
Reviewed-by: Wei Liu 
Acked-by: Daniel De Graaf 
---
v1:
- add description about what to be changed in commit message.
  (suggested by Wei Liu)
- bump sysctl/domctl version numbers.
  (suggested by Wei Liu)
---
 tools/flask/policy/modules/dom0.te  |  4 ++--
 tools/libxc/xc_psr.c| 34 +-
 xen/arch/x86/domctl.c   | 36 ++--
 xen/arch/x86/sysctl.c   | 24 
 xen/include/public/domctl.h | 12 ++--
 xen/include/public/sysctl.h | 12 ++--
 xen/xsm/flask/hooks.c   |  8 
 xen/xsm/flask/policy/access_vectors |  8 
 8 files changed, 69 insertions(+), 69 deletions(-)

diff --git a/tools/flask/policy/modules/dom0.te 
b/tools/flask/policy/modules/dom0.te
index d0a4d91..1a376ac 100644
--- a/tools/flask/policy/modules/dom0.te
+++ b/tools/flask/policy/modules/dom0.te
@@ -14,7 +14,7 @@ allow dom0_t xen_t:xen {
tmem_control getscheduler setscheduler
 };
 allow dom0_t xen_t:xen2 {
-   resource_op psr_cmt_op psr_cat_op pmu_ctrl get_symbol
+   resource_op psr_cmt_op psr_alloc_op pmu_ctrl get_symbol
get_cpu_levelling_caps get_cpu_featureset livepatch_op
gcov_op
 };
@@ -39,7 +39,7 @@ allow dom0_t dom0_t:domain {
 };
 allow dom0_t dom0_t:domain2 {
set_cpuid gettsc settsc setscheduler set_max_evtchn set_vnumainfo
-   get_vnumainfo psr_cmt_op psr_cat_op
+   get_vnumainfo psr_cmt_op psr_alloc_op
 };
 allow dom0_t dom0_t:resource { add remove };
 
diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
index 039b920..73d05f2 100644
--- a/tools/libxc/xc_psr.c
+++ b/tools/libxc/xc_psr.c
@@ -274,11 +274,11 @@ int xc_psr_cat_set_domain_data(xc_interface *xch, 
uint32_t domid,
 return -1;
 }
 
-domctl.cmd = XEN_DOMCTL_psr_cat_op;
+domctl.cmd = XEN_DOMCTL_psr_alloc_op;
 domctl.domain = (domid_t)domid;
-domctl.u.psr_cat_op.cmd = cmd;
-domctl.u.psr_cat_op.target = target;
-domctl.u.psr_cat_op.data = data;
+domctl.u.psr_alloc_op.cmd = cmd;
+domctl.u.psr_alloc_op.target = target;
+domctl.u.psr_alloc_op.data = data;
 
 return do_domctl(xch, );
 }
@@ -310,15 +310,15 @@ int xc_psr_cat_get_domain_data(xc_interface *xch, 
uint32_t domid,
 return -1;
 }
 
-domctl.cmd = XEN_DOMCTL_psr_cat_op;
+domctl.cmd = XEN_DOMCTL_psr_alloc_op;
 domctl.domain = (domid_t)domid;
-domctl.u.psr_cat_op.cmd = cmd;
-domctl.u.psr_cat_op.target = target;
+domctl.u.psr_alloc_op.cmd = cmd;
+domctl.u.psr_alloc_op.target = target;
 
 rc = do_domctl(xch, );
 
 if ( !rc )
-*data = domctl.u.psr_cat_op.data;
+*data = domctl.u.psr_alloc_op.data;
 
 return rc;
 }
@@ -329,29 +329,29 @@ int xc_psr_cat_get_info(xc_interface *xch, uint32_t 
socket, unsigned int lvl,
 int rc = -1;
 DECLARE_SYSCTL;
 
-sysctl.cmd = XEN_SYSCTL_psr_cat_op;
-sysctl.u.psr_cat_op.target = socket;
+sysctl.cmd = XEN_SYSCTL_psr_alloc_op;
+sysctl.u.psr_alloc_op.target = socket;
 
 switch ( lvl )
 {
 case 2:
-sysctl.u.psr_cat_op.cmd = XEN_SYSCTL_PSR_CAT_get_l2_info;
+sysctl.u.psr_alloc_op.cmd = XEN_SYSCTL_PSR_CAT_get_l2_info;
 rc = xc_sysctl(xch, );
 if ( !rc )
 {
-*cos_max = sysctl.u.psr_cat_op.u.cat_info.cos_max;
-*cbm_len = sysctl.u.psr_cat_op.u.cat_info.cbm_len;
+*cos_max = sysctl.u.psr_alloc_op.u.cat_info.cos_max;
+*cbm_len = sysctl.u.psr_alloc_op.u.cat_info.cbm_len;
 *cdp_enabled = false;
 }
 break;
 case 3:
-sysctl.u.psr_cat_op.cmd = XEN_SYSCTL_PSR_CAT_get_l3_info;
+sysctl.u.psr_alloc_op.cmd = XEN_SYSCTL_PSR_CAT_get_l3_info;
 rc = xc_sysctl(xch, );
 if ( !rc )
 {
-*cos_max = sysctl.u.psr_cat_op.u.cat_info.cos_max;
-*cbm_len = sysctl.u.psr_cat_op.u.cat_info.cbm_len;
-*cdp_enabled = sysctl.u.psr_cat_op.u.cat_info.flags &
+*cos_max = sysctl.u.psr_alloc_op.u.cat_info.cos_max;
+*cbm_len = sysctl.u.psr_alloc_op.u.cat_info.cbm_len;
+*cdp_enabled = sysctl.u.psr_alloc_op.u.cat_info.flags &
XEN_SYSCTL_PSR_CAT_L3_CDP;
 }
 break;
diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 127c84e..24b998b 100644
--- 

[Xen-devel] [PATCH v2 07/15] x86: implement set value flow for MBA

2017-08-23 Thread Yi Sun
This patch implements set value flow for MBA including its callback
function and domctl interface.

It also changes the memebers in 'cos_write_info' to transfer the
feature array, feature properties array and value array. Then, we
can write all features values on the cos id into MSRs.

Because multiple features may co-exist, we need handle all features to write
values of them into a COS register with new COS ID. E.g:
1. L3 CAT and MBA co-exist.
2. Dom1 and Dom2 share a same COS ID (2). The L3 CAT CBM of Dom1 is 0x1ff,
   the MBA Thrtle of Dom1 is 0xa.
3. User wants to change MBA Thrtl of Dom1 to be 0x14. Because COS ID 2 is
   used by Dom2 too, we have to pick a new COS ID 3. The original values of
   Dom1 on COS ID 3 may be below:
   -
   | COS 3 |
   -
   L3 CAT  | 0x7ff |
   -
   MBA | 0x0   |
   -
4. After setting, the L3 CAT CBM value of Dom1 should be kept and the new MBA
   Thrtl is set. So, the values on COS ID 3 should be below.
   -
   | COS 3 |
   -
   L3 CAT  | 0x1ff |
   -
   MBA | 0x14  |
   -

So, we should write all features values into their MSRs. That requires the
feature array, feature properties array and value array are input.

Signed-off-by: Yi Sun 
---
v2:
- remove linear mode 'thrtl_max' check in 'mba_check_thrtl' because it has
  been checked in 'mba_init_feature'.
  (suggested by Chao Peng)
- for non-linear mode, check if '*thrtl' is not 0 in 'mba_check_thrtl'. If
  it is 0, we do not need to change it.
  (suggested by Chao Peng)
- move comments to explain changes of 'cos_write_info' from psr.c to commit
  message.
  (suggested by Chao Peng)
---
 xen/arch/x86/domctl.c   |   6 ++
 xen/arch/x86/psr.c  | 150 ++--
 xen/include/public/domctl.h |   1 +
 3 files changed, 109 insertions(+), 48 deletions(-)

diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index 4936bcb..0ae4799 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -1468,6 +1468,12 @@ long arch_do_domctl(
   PSR_VAL_TYPE_L2_CBM);
 break;
 
+case XEN_DOMCTL_PSR_MBA_OP_SET_THRTL:
+ret = psr_set_val(d, domctl->u.psr_alloc_op.target,
+  domctl->u.psr_alloc_op.data,
+  PSR_VAL_TYPE_MBA);
+break;
+
 case XEN_DOMCTL_PSR_CAT_OP_GET_L3_CBM:
 ret = psr_get_val(d, domctl->u.psr_alloc_op.target,
   , PSR_VAL_TYPE_L3_CBM);
diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c
index 4a0c982..ce82975 100644
--- a/xen/arch/x86/psr.c
+++ b/xen/arch/x86/psr.c
@@ -138,6 +138,12 @@ static const struct feat_props {
 
 /* write_msr is used to write out feature MSR register. */
 void (*write_msr)(unsigned int cos, uint32_t val, enum psr_val_type type);
+
+/*
+ * check_val is used to check if input val fulfills SDM requirement.
+ * Change it to valid value if SDM allows.
+ */
+bool (*check_val)(const struct feat_node *feat, unsigned long *val);
 } *feat_props[FEAT_TYPE_NUM];
 
 /*
@@ -275,29 +281,6 @@ static enum psr_feat_type psr_val_type_to_feat_type(enum 
psr_val_type type)
 return feat_type;
 }
 
-static bool psr_check_cbm(unsigned int cbm_len, unsigned long cbm)
-{
-unsigned int first_bit, zero_bit;
-
-/* Set bits should only in the range of [0, cbm_len]. */
-if ( cbm & (~0ul << cbm_len) )
-return false;
-
-/* At least one bit need to be set. */
-if ( cbm == 0 )
-return false;
-
-first_bit = find_first_bit(, cbm_len);
-zero_bit = find_next_zero_bit(, cbm_len, first_bit);
-
-/* Set bits should be contiguous. */
-if ( zero_bit < cbm_len &&
- find_next_bit(, cbm_len, zero_bit) < cbm_len )
-return false;
-
-return true;
-}
-
 /* Implementation of allocation features' functions. */
 static int cat_init_feature(const struct cpuid_leaf *regs,
 struct feat_node *feat,
@@ -433,6 +416,30 @@ static bool cat_get_feat_info(const struct feat_node *feat,
 return true;
 }
 
+static bool cat_check_cbm(const struct feat_node *feat, unsigned long *cbm)
+{
+unsigned int first_bit, zero_bit;
+unsigned int cbm_len = feat->cat_info.cbm_len;
+
+/* Set bits should only in the range of [0, cbm_len]. */
+if ( *cbm & (~0ul << cbm_len) )
+return false;
+
+/* At least one bit need to be set. */
+if ( *cbm == 0 )
+return false;
+
+first_bit = find_first_bit(cbm, cbm_len);
+zero_bit = find_next_zero_bit(cbm, cbm_len, first_bit);
+
+/* Set bits should be contiguous. */
+if ( zero_bit < cbm_len &&
+ find_next_bit(cbm, cbm_len, zero_bit) < cbm_len )
+return false;
+
+return true;
+}
+
 /* L3 CAT props */
 static 

[Xen-devel] [PATCH v2 10/15] tools: implement the new libxl get hw info interface

2017-08-23 Thread Yi Sun
This patch implements the new libxl get hw info interface,
'libxl_psr_get_hw_info', which is suitable to all psr allocation
features. It also implements corresponding list free function,
'libxl_psr_hw_info_list_free' and make 'libxl_psr_cat_get_info' to call
'libxl_psr_get_hw_info' to avoid redundant codes in libxl_psr.c.

Signed-off-by: Yi Sun 
---
v2:
- split this patch out from a big patch in v1.
  (suggested by Wei Liu)
- change 'CAT_INFO'/'MBA_INFO' to 'CAT' and 'MBA. Also the libxl structure
  name 'cat_info'/'mba_info' is changed to 'cat'/'mba'.
  (suggested by Chao Peng)
- call 'libxl_psr_hw_info_list_free' in 'libxl_psr_cat_get_info' to free
  allocated resources.
  (suggested by Chao Peng)
---
 tools/libxl/libxl_psr.c | 145 +---
 1 file changed, 112 insertions(+), 33 deletions(-)

diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index b183305..d7da7d7 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -382,56 +382,51 @@ static inline xc_psr_feat_type 
libxl__psr_feat_type_to_libxc_psr_feat_type(
 return xc_type;
 }
 
+static inline int libxl__psr_hw_info_to_libxl_psr_cat_info(
+  libxl_psr_feat_type type, libxl_psr_hw_info *hw_info,
+  libxl_psr_cat_info *cat_info)
+{
+if (type != LIBXL_PSR_FEAT_TYPE_CAT)
+return ERROR_INVAL;
+
+cat_info->id = hw_info->id;
+cat_info->cos_max = hw_info->u.cat.cos_max;
+cat_info->cbm_len = hw_info->u.cat.cbm_len;
+cat_info->cdp_enabled = hw_info->u.cat.cdp_enabled;
+
+return 0;
+}
+
 int libxl_psr_cat_get_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
int *nr, unsigned int lvl)
 {
 GC_INIT(ctx);
 int rc;
-int i = 0, socketid, nr_sockets;
-libxl_bitmap socketmap;
+unsigned int i;
+libxl_psr_hw_info *hw_info;
 libxl_psr_cat_info *ptr;
-xc_psr_hw_info hw_info;
-xc_psr_feat_type xc_type;
-
-libxl_bitmap_init();
-
-rc = libxl__count_physical_sockets(gc, _sockets);
-if (rc) {
-LOGE(ERROR, "failed to get system socket count");
-goto out;
-}
 
-libxl_socket_bitmap_alloc(ctx, , nr_sockets);
-rc = libxl_get_online_socketmap(ctx, );
-if (rc < 0) {
-LOGE(ERROR, "failed to get available sockets");
+rc = libxl_psr_get_hw_info(ctx, _info, (unsigned int *)nr,
+   LIBXL_PSR_FEAT_TYPE_CAT, lvl);
+if (rc)
 goto out;
-}
 
-xc_type = libxl__psr_feat_type_to_libxc_psr_feat_type(
-  LIBXL_PSR_FEAT_TYPE_CAT, lvl);
+ptr = libxl__malloc(NOGC, *nr * sizeof(libxl_psr_cat_info));
 
-ptr = libxl__malloc(NOGC, nr_sockets * sizeof(libxl_psr_cat_info));
-
-libxl_for_each_set_bit(socketid, socketmap) {
-ptr[i].id = socketid;
-if (xc_psr_get_hw_info(ctx->xch, socketid, xc_type, _info)) {
+for (i = 0; i < *nr; i++) {
+if (libxl__psr_hw_info_to_libxl_psr_cat_info(
+LIBXL_PSR_FEAT_TYPE_CAT,
+_info[i], [i])) {
+libxl_psr_hw_info_list_free(hw_info, (unsigned int)*nr);
 rc = ERROR_FAIL;
 free(ptr);
 goto out;
 }
-
-ptr[i].cos_max = hw_info.u.xc_cat_info.cos_max;
-ptr[i].cbm_len = hw_info.u.xc_cat_info.cbm_len;
-ptr[i].cdp_enabled = hw_info.u.xc_cat_info.cdp_enabled;
-
-i++;
 }
 
 *info = ptr;
-*nr = i;
+libxl_psr_hw_info_list_free(hw_info, (unsigned int)*nr);
 out:
-libxl_bitmap_dispose();
 GC_FREE;
 return rc;
 }
@@ -469,15 +464,99 @@ int libxl_psr_get_val(libxl_ctx *ctx, uint32_t domid,
 return ERROR_FAIL;
 }
 
+static inline int libxc__psr_hw_info_to_libxl_psr_hw_info(
+  libxl_psr_feat_type type, xc_psr_hw_info *xc_hw_info,
+  libxl_psr_hw_info *xl_hw_info)
+{
+switch (type) {
+case LIBXL_PSR_FEAT_TYPE_CAT:
+xl_hw_info->u.cat.cos_max = xc_hw_info->u.xc_cat_info.cos_max;
+xl_hw_info->u.cat.cbm_len = xc_hw_info->u.xc_cat_info.cbm_len;
+xl_hw_info->u.cat.cdp_enabled =
+xc_hw_info->u.xc_cat_info.cdp_enabled;
+break;
+case LIBXL_PSR_FEAT_TYPE_MBA:
+xl_hw_info->u.mba.cos_max = xc_hw_info->u.xc_mba_info.cos_max;
+xl_hw_info->u.mba.thrtl_max = xc_hw_info->u.xc_mba_info.thrtl_max;
+xl_hw_info->u.mba.linear = xc_hw_info->u.xc_mba_info.linear;
+break;
+default:
+return ERROR_INVAL;
+}
+
+return 0;
+}
+
 int libxl_psr_get_hw_info(libxl_ctx *ctx, libxl_psr_hw_info **info,
   unsigned int *nr, libxl_psr_feat_type type,
   unsigned int lvl)
 {
-return ERROR_FAIL;
+GC_INIT(ctx);
+int rc, nr_sockets;
+unsigned int i = 0, socketid;
+libxl_bitmap socketmap;
+libxl_psr_hw_info *ptr;
+

[Xen-devel] [PATCH v2 00/15] Enable Memory Bandwidth Allocation in Xen

2017-08-23 Thread Yi Sun
Hi, all,

We plan to bring a new PSR (Platform Shared Resource) feature called
Intel Memory Bandwidth Allocation (MBA) to Xen.

Besides the MBA enabling, we change some interfaces to make them more
general but not only for CAT.

Any comments are welcome!

You can find this patch set at:
https://github.com/yisun-git/xen_mba mba_v2-2

---
Acked and Reviewed list before V2:

a - Acked-by
r - Reviewed-by

  ar patch 2  - Rename PSR sysctl/domctl interfaces and xsm policy to make them 
be general
  r  patch 3  - x86: rename 'cbm_type' to 'psr_val_type' to make it general
  ar patch 12 - tools: rename 'xc_psr_cat_type' to 'xc_psr_val_type'
  a  patch 13 - tools: implement new generic get value interface and MBA get 
value command
  a  patch 15 - docs: add MBA description in docs

---
V2 change list:

Patch 1:
- declare 'HW' in Terminology.
  (suggested by Chao Peng)
- replace 'COS ID of VCPU' to 'COS ID of domain'.
  (suggested by Chao Peng)
- replace 'COS register' to 'Thrtl MSR'.
  (suggested by Chao Peng)
- add description for 'psr-mba-show' to state that the decimal value is
  shown for linear mode but hexadecimal value is shown for non-linear mode.
  (suggested by Chao Peng)
- remove content in 'Areas for improvement'.
  (suggested by Chao Peng)
- use '<>' to specify mandatory argument to a command.
  (suggested by Wei Liu)
Patch3:
- replace 'PSR_VAL_TYPE_{L3, L2}' to 'PSR_VAL_TYPE_{L3, L2}_CBM'.
  (suggested by Chao Peng)
Patch 4:
- modify commit message to replace 'cos register' to 'thrtl register' to
  make it accurate.
  (suggested by Chao Peng)
- restore the place of the sentence to assign value to 'feat->cbm_len'
  because the MBA init flow is splitted out as a separate function in v1.
  (suggested by Chao Peng)
- add comment to explain what the MBA thrtl defaul value '0' stands for.
  (suggested by Chao Peng)
- check 'thrtl_max' under linear mode. It could not be euqal or larger than
  100.
  (suggested by Chao Peng)
Patch 5:
- use 'XEN_SYSCTL_PSR_MBA_LINEAR' to set MBA feature HW info.
  (suggested by Chao Peng)
Patch 7:
- remove linear mode 'thrtl_max' check in 'mba_check_thrtl' because it has
  been checked in 'mba_init_feature'.
  (suggested by Chao Peng)
- for non-linear mode, check if '*thrtl' is not 0 in 'mba_check_thrtl'. If
  it is 0, we do not need to change it.
  (suggested by Chao Peng)
- move comments to explain changes of 'cos_write_info' from psr.c to commit
  message.
  (suggested by Chao Peng)
Patch 8:
- remove '_INFO' in 'libxl_psr_feat_type' and make corresponding
  changes in 'libxl_psr_hw_info'.
  (suggested by Chao Peng)
Patch 9:
- split this patch out from a big patch in v1.
  (suggested by Wei Liu)
- change 'CAT_INFO' and 'MBA_INFO' to 'CAT' and 'MBA'.
  (suggested by Chao Peng)
Patch 10:
- split this patch out from a big patch in v1.
  (suggested by Wei Liu)
- change 'CAT_INFO'/'MBA_INFO' to 'CAT' and 'MBA. Also the libxl structure
  name 'cat_info'/'mba_info' is changed to 'cat'/'mba'.
  (suggested by Chao Peng)
- call 'libxl_psr_hw_info_list_free' in 'libxl_psr_cat_get_info' to free
  allocated resources.
  (suggested by Chao Peng)
Patch 11:
- split out this patch from a big patch in v1.
  (suggested by Wei Liu)
- change 'MBA_INFO' to 'MBA'. Also, change 'mba_info' to 'mba'.
  (suggested by Chao Peng)
Patch 13:
- change 'CAT_INFO'/'MBA_INFO' to 'CAT'/'MBA'. The related structure names
  are changed too.
  (suggested by Chao Peng)
Patch 15:
- state the value type shown by 'psr-mba-show'. For linear mode,
  it shows decimal value. For non-linear mode, it shows hexadecimal
  value.
  (suggested by Chao Peng)

Yi Sun (15):
  docs: create Memory Bandwidth Allocation (MBA) feature document
  Rename PSR sysctl/domctl interfaces and xsm policy to make them be
general
  x86: rename 'cbm_type' to 'psr_val_type' to make it general
  x86: implement data structure and CPU init flow for MBA
  x86: implement get hw info flow for MBA
  x86: implement get value interface for MBA
  x86: implement set value flow for MBA
  tools: create general interfaces to support psr allocation features
  tools: implement the new libxc get hw info interface
  tools: implement the new libxl get hw info interface
  tools: implement the new xl get hw info interface
  tools: rename 'xc_psr_cat_type' to 'xc_psr_val_type'
  tools: implement new generic get value interface and MBA get value
command
  tools: implement new generic set value interface and MBA set value
command
  docs: add MBA description in docs

 docs/features/intel_psr_mba.pandoc  | 256 +
 docs/man/xl.pod.1.in|  34 
 docs/misc/xl-psr.markdown   |  63 +++
 tools/flask/policy/modules/dom0.te  |   4 +-
 tools/libxc/include/xenctrl.h 

[Xen-devel] [PATCH v2 09/15] tools: implement the new libxc get hw info interface

2017-08-23 Thread Yi Sun
This patch implements a new libxc get hw info interface and corresponding
data structures. It also changes libxl_psr.c to call this new interface.

Signed-off-by: Yi Sun 
---
v2:
- split this patch out from a big patch in v1.
  (suggested by Wei Liu)
- change 'CAT_INFO' and 'MBA_INFO' to 'CAT' and 'MBA'.
  (suggested by Chao Peng)
---
 tools/libxc/include/xenctrl.h | 30 +---
 tools/libxc/xc_psr.c  | 46 ---
 tools/libxl/libxl_psr.c   | 34 ++--
 3 files changed, 93 insertions(+), 17 deletions(-)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index c7710b8..81a6f48 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -2458,6 +2458,31 @@ enum xc_psr_cat_type {
 };
 typedef enum xc_psr_cat_type xc_psr_cat_type;
 
+enum xc_psr_feat_type {
+XC_PSR_FEAT_UNKNOWN,
+XC_PSR_FEAT_CAT_L3,
+XC_PSR_FEAT_CAT_L2,
+XC_PSR_FEAT_MBA,
+};
+typedef enum xc_psr_feat_type xc_psr_feat_type;
+
+struct xc_psr_hw_info {
+union {
+struct {
+uint32_t cos_max;
+uint32_t cbm_len;
+bool cdp_enabled;
+} xc_cat_info;
+
+struct {
+uint32_t cos_max;
+uint32_t thrtl_max;
+bool linear;
+} xc_mba_info;
+} u;
+};
+typedef struct xc_psr_hw_info xc_psr_hw_info;
+
 int xc_psr_cmt_attach(xc_interface *xch, uint32_t domid);
 int xc_psr_cmt_detach(xc_interface *xch, uint32_t domid);
 int xc_psr_cmt_get_domain_rmid(xc_interface *xch, uint32_t domid,
@@ -2479,9 +2504,8 @@ int xc_psr_cat_set_domain_data(xc_interface *xch, 
uint32_t domid,
 int xc_psr_cat_get_domain_data(xc_interface *xch, uint32_t domid,
xc_psr_cat_type type, uint32_t target,
uint64_t *data);
-int xc_psr_cat_get_info(xc_interface *xch, uint32_t socket, unsigned int lvl,
-uint32_t *cos_max, uint32_t *cbm_len,
-bool *cdp_enabled);
+int xc_psr_get_hw_info(xc_interface *xch, uint32_t socket,
+   xc_psr_feat_type type, xc_psr_hw_info *hw_info);
 
 int xc_get_cpu_levelling_caps(xc_interface *xch, uint32_t *caps);
 int xc_get_cpu_featureset(xc_interface *xch, uint32_t index,
diff --git a/tools/libxc/xc_psr.c b/tools/libxc/xc_psr.c
index 73d05f2..ba412e4 100644
--- a/tools/libxc/xc_psr.c
+++ b/tools/libxc/xc_psr.c
@@ -323,36 +323,58 @@ int xc_psr_cat_get_domain_data(xc_interface *xch, 
uint32_t domid,
 return rc;
 }
 
-int xc_psr_cat_get_info(xc_interface *xch, uint32_t socket, unsigned int lvl,
-uint32_t *cos_max, uint32_t *cbm_len, bool 
*cdp_enabled)
+int xc_psr_get_hw_info(xc_interface *xch, uint32_t socket,
+   xc_psr_feat_type type, xc_psr_hw_info *hw_info)
 {
 int rc = -1;
 DECLARE_SYSCTL;
 
+if ( !hw_info )
+return rc;
+
 sysctl.cmd = XEN_SYSCTL_psr_alloc_op;
 sysctl.u.psr_alloc_op.target = socket;
 
-switch ( lvl )
+switch ( type )
 {
-case 2:
+case XC_PSR_FEAT_CAT_L2:
 sysctl.u.psr_alloc_op.cmd = XEN_SYSCTL_PSR_CAT_get_l2_info;
 rc = xc_sysctl(xch, );
 if ( !rc )
 {
-*cos_max = sysctl.u.psr_alloc_op.u.cat_info.cos_max;
-*cbm_len = sysctl.u.psr_alloc_op.u.cat_info.cbm_len;
-*cdp_enabled = false;
+hw_info->u.xc_cat_info.cos_max =
+sysctl.u.psr_alloc_op.u.cat_info.cos_max;
+hw_info->u.xc_cat_info.cbm_len =
+sysctl.u.psr_alloc_op.u.cat_info.cbm_len;
+hw_info->u.xc_cat_info.cdp_enabled = false;
 }
 break;
-case 3:
+case XC_PSR_FEAT_CAT_L3:
 sysctl.u.psr_alloc_op.cmd = XEN_SYSCTL_PSR_CAT_get_l3_info;
 rc = xc_sysctl(xch, );
 if ( !rc )
 {
-*cos_max = sysctl.u.psr_alloc_op.u.cat_info.cos_max;
-*cbm_len = sysctl.u.psr_alloc_op.u.cat_info.cbm_len;
-*cdp_enabled = sysctl.u.psr_alloc_op.u.cat_info.flags &
-   XEN_SYSCTL_PSR_CAT_L3_CDP;
+hw_info->u.xc_cat_info.cos_max =
+sysctl.u.psr_alloc_op.u.cat_info.cos_max;
+hw_info->u.xc_cat_info.cbm_len =
+sysctl.u.psr_alloc_op.u.cat_info.cbm_len;
+hw_info->u.xc_cat_info.cdp_enabled =
+sysctl.u.psr_alloc_op.u.cat_info.flags &
+XEN_SYSCTL_PSR_CAT_L3_CDP;
+}
+break;
+case XC_PSR_FEAT_MBA:
+sysctl.u.psr_alloc_op.cmd = XEN_SYSCTL_PSR_MBA_get_info;
+rc = xc_sysctl(xch, );
+if ( !rc )
+{
+hw_info->u.xc_mba_info.cos_max =
+sysctl.u.psr_alloc_op.u.mba_info.cos_max;
+hw_info->u.xc_mba_info.thrtl_max =
+  

[Xen-devel] [PATCH v2 06/15] x86: implement get value interface for MBA

2017-08-23 Thread Yi Sun
This patch implements get value domctl interface for MBA.

Signed-off-by: Yi Sun 
---
 xen/arch/x86/domctl.c   | 7 +++
 xen/include/public/domctl.h | 1 +
 2 files changed, 8 insertions(+)

diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c
index e1c7c70..4936bcb 100644
--- a/xen/arch/x86/domctl.c
+++ b/xen/arch/x86/domctl.c
@@ -1496,6 +1496,13 @@ long arch_do_domctl(
 copyback = true;
 break;
 
+case XEN_DOMCTL_PSR_MBA_OP_GET_THRTL:
+ret = psr_get_val(d, domctl->u.psr_alloc_op.target,
+  , PSR_VAL_TYPE_MBA);
+domctl->u.psr_alloc_op.data = val32;
+copyback = true;
+break;
+
 default:
 ret = -EOPNOTSUPP;
 break;
diff --git a/xen/include/public/domctl.h b/xen/include/public/domctl.h
index 4bb4399..a577a3e 100644
--- a/xen/include/public/domctl.h
+++ b/xen/include/public/domctl.h
@@ -1144,6 +1144,7 @@ struct xen_domctl_psr_alloc_op {
 #define XEN_DOMCTL_PSR_CAT_OP_GET_L3_DATA5
 #define XEN_DOMCTL_PSR_CAT_OP_SET_L2_CBM 6
 #define XEN_DOMCTL_PSR_CAT_OP_GET_L2_CBM 7
+#define XEN_DOMCTL_PSR_MBA_OP_GET_THRTL  9
 uint32_t cmd;   /* IN: XEN_DOMCTL_PSR_CAT_OP_* */
 uint32_t target;/* IN */
 uint64_t data;  /* IN/OUT */
-- 
1.9.1


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 08/15] tools: create general interfaces to support psr allocation features

2017-08-23 Thread Yi Sun
This patch creates general interfaces in libxl to support all psr
allocation features.

Add 'LIBXL_HAVE_PSR_MBA' to indicate interface change.

Please note, the functionality cannot work until later patches
are applied.

Signed-off-by: Yi Sun 
---
v2:
- remove '_INFO' in 'libxl_psr_feat_type' and make corresponding
  changes in 'libxl_psr_hw_info'.
  (suggested by Chao Peng)
---
 tools/libxl/libxl.h | 35 ++-
 tools/libxl/libxl_psr.c | 25 +
 tools/libxl/libxl_types.idl | 22 ++
 3 files changed, 81 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 229e289..c1d804c 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -931,6 +931,13 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, const 
libxl_mac *src);
 #define LIBXL_HAVE_PSR_L2_CAT 1
 
 /*
+ * LIBXL_HAVE_PSR_MBA
+ *
+ * If this is defined, the Memory Bandwidth Allocation feature is supported.
+ */
+#define LIBXL_HAVE_PSR_MBA 1
+
+/*
  * LIBXL_HAVE_MCA_CAPS
  *
  * If this is defined, setting MCA capabilities for HVM domain is supported.
@@ -2219,7 +2226,33 @@ int libxl_psr_cat_get_info(libxl_ctx *ctx, 
libxl_psr_cat_info **info,
 int libxl_psr_cat_get_l3_info(libxl_ctx *ctx, libxl_psr_cat_info **info,
   int *nr);
 void libxl_psr_cat_info_list_free(libxl_psr_cat_info *list, int nr);
-#endif
+
+#ifdef LIBXL_HAVE_PSR_MBA
+/*
+ * Function to set a domain's value. It operates on a single or multiple
+ * target(s) defined in 'target_map'. 'target_map' specifies all the sockets
+ * to be operated on.
+ */
+int libxl_psr_set_val(libxl_ctx *ctx, uint32_t domid,
+  libxl_psr_cbm_type type, libxl_bitmap *target_map,
+  uint64_t val);
+/*
+ * Function to get a domain's cbm. It operates on a single 'target'.
+ * 'target' specifies which socket to be operated on.
+ */
+int libxl_psr_get_val(libxl_ctx *ctx, uint32_t domid,
+  libxl_psr_cbm_type type, unsigned int target,
+  uint64_t *val);
+/*
+ * On success, the function returns an array of elements in 'info',
+ * and the length in 'nr'.
+ */
+int libxl_psr_get_hw_info(libxl_ctx *ctx, libxl_psr_hw_info **info,
+  unsigned int *nr, libxl_psr_feat_type type,
+  unsigned int lvl);
+void libxl_psr_hw_info_list_free(libxl_psr_hw_info *list, unsigned int nr);
+#endif /* LIBXL_HAVE_PSR_MBA */
+#endif /* LIBXL_HAVE_PSR_CAT */
 
 /* misc */
 
diff --git a/tools/libxl/libxl_psr.c b/tools/libxl/libxl_psr.c
index f55ba1e..cf368ba 100644
--- a/tools/libxl/libxl_psr.c
+++ b/tools/libxl/libxl_psr.c
@@ -425,6 +425,31 @@ void libxl_psr_cat_info_list_free(libxl_psr_cat_info 
*list, int nr)
 free(list);
 }
 
+int libxl_psr_set_val(libxl_ctx *ctx, uint32_t domid,
+  libxl_psr_cbm_type type, libxl_bitmap *target_map,
+  uint64_t val)
+{
+return ERROR_FAIL;
+}
+
+int libxl_psr_get_val(libxl_ctx *ctx, uint32_t domid,
+  libxl_psr_cbm_type type, unsigned int target,
+  uint64_t *val)
+{
+return ERROR_FAIL;
+}
+
+int libxl_psr_get_hw_info(libxl_ctx *ctx, libxl_psr_hw_info **info,
+  unsigned int *nr, libxl_psr_feat_type type,
+  unsigned int lvl)
+{
+return ERROR_FAIL;
+}
+
+void libxl_psr_hw_info_list_free(libxl_psr_hw_info *list, unsigned int nr)
+{
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 6e80d36..ab847f8 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -977,6 +977,7 @@ libxl_psr_cbm_type = Enumeration("psr_cbm_type", [
 (2, "L3_CBM_CODE"),
 (3, "L3_CBM_DATA"),
 (4, "L2_CBM"),
+(5, "MBA_THRTL"),
 ])
 
 libxl_psr_cat_info = Struct("psr_cat_info", [
@@ -985,3 +986,24 @@ libxl_psr_cat_info = Struct("psr_cat_info", [
 ("cbm_len", uint32),
 ("cdp_enabled", bool),
 ])
+
+libxl_psr_feat_type = Enumeration("psr_feat_type", [
+(1, "CAT"),
+(2, "MBA"),
+])
+
+libxl_psr_hw_info = Struct("psr_hw_info", [
+("id", uint32),
+("u", KeyedUnion(None, libxl_psr_feat_type, "type",
+  [("cat", Struct(None, [
+("cos_max", uint32),
+("cbm_len", uint32),
+("cdp_enabled", bool),
+   ])),
+   ("mba", Struct(None, [
+("cos_max", uint32),
+("thrtl_max",   uint32),
+("linear",  bool),
+   ])),
+  ]))
+], dir=DIR_OUT)
-- 
1.9.1


___
Xen-devel mailing list
Xen-devel@lists.xen.org

[Xen-devel] [PATCH v2 05/15] x86: implement get hw info flow for MBA

2017-08-23 Thread Yi Sun
This patch implements get HW info flow for MBA including its callback
function and sysctl interface.

Signed-off-by: Yi Sun 
---
v2:
- use 'XEN_SYSCTL_PSR_MBA_LINEAR' to set MBA feature HW info.
  (suggested by Chao Peng)
v1:
- sort 'PSR_INFO_IDX_' macros as feature.
  (suggested by Chao Peng)
- rename 'PSR_INFO_IDX_MBA_LINEAR' to 'PSR_INFO_IDX_MBA_FLAG'.
- rename 'linear' in 'struct mba_info' to 'flags' for future extension.
  (suggested by Chao Peng)
---
 xen/arch/x86/psr.c  | 17 -
 xen/arch/x86/sysctl.c   | 19 +++
 xen/include/asm-x86/psr.h   |  2 ++
 xen/include/public/sysctl.h |  8 
 4 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c
index f5e99ce..4a0c982 100644
--- a/xen/arch/x86/psr.c
+++ b/xen/arch/x86/psr.c
@@ -264,6 +264,10 @@ static enum psr_feat_type psr_val_type_to_feat_type(enum 
psr_val_type type)
 feat_type = FEAT_TYPE_L2_CAT;
 break;
 
+case PSR_VAL_TYPE_MBA:
+feat_type = FEAT_TYPE_MBA;
+break;
+
 default:
 ASSERT_UNREACHABLE();
 }
@@ -493,7 +497,18 @@ static const struct feat_props l2_cat_props = {
 static bool mba_get_feat_info(const struct feat_node *feat,
   uint32_t data[], unsigned int array_len)
 {
-return false;
+if ( array_len != PSR_INFO_ARRAY_SIZE )
+return false;
+
+data[PSR_INFO_IDX_COS_MAX] = feat->cos_max;
+data[PSR_INFO_IDX_MBA_THRTL_MAX] = feat->mba_info.thrtl_max;
+
+if ( feat->mba_info.linear )
+data[PSR_INFO_IDX_MBA_FLAG] |= XEN_SYSCTL_PSR_MBA_LINEAR;
+else
+data[PSR_INFO_IDX_MBA_FLAG] &= ~XEN_SYSCTL_PSR_MBA_LINEAR;
+
+return true;
 }
 
 static void mba_write_msr(unsigned int cos, uint32_t val,
diff --git a/xen/arch/x86/sysctl.c b/xen/arch/x86/sysctl.c
index df54d38..cbab85a 100644
--- a/xen/arch/x86/sysctl.c
+++ b/xen/arch/x86/sysctl.c
@@ -214,6 +214,25 @@ long arch_do_sysctl(
 break;
 }
 
+case XEN_SYSCTL_PSR_MBA_get_info:
+{
+ret = psr_get_info(sysctl->u.psr_alloc_op.target,
+   PSR_VAL_TYPE_MBA, data, ARRAY_SIZE(data));
+if ( ret )
+break;
+
+sysctl->u.psr_alloc_op.u.mba_info.cos_max =
+  data[PSR_INFO_IDX_COS_MAX];
+sysctl->u.psr_alloc_op.u.mba_info.thrtl_max =
+  data[PSR_INFO_IDX_MBA_THRTL_MAX];
+sysctl->u.psr_alloc_op.u.mba_info.flags =
+  data[PSR_INFO_IDX_MBA_FLAG];
+
+if ( !ret && __copy_field_to_guest(u_sysctl, sysctl, 
u.psr_alloc_op) )
+ret = -EFAULT;
+break;
+}
+
 default:
 ret = -EOPNOTSUPP;
 break;
diff --git a/xen/include/asm-x86/psr.h b/xen/include/asm-x86/psr.h
index 10043ac..a7fb625 100644
--- a/xen/include/asm-x86/psr.h
+++ b/xen/include/asm-x86/psr.h
@@ -39,6 +39,8 @@
 #define PSR_INFO_IDX_COS_MAX0
 #define PSR_INFO_IDX_CAT_CBM_LEN1
 #define PSR_INFO_IDX_CAT_FLAG   2
+#define PSR_INFO_IDX_MBA_THRTL_MAX  1
+#define PSR_INFO_IDX_MBA_FLAG   2
 #define PSR_INFO_ARRAY_SIZE 3
 
 struct psr_cmt_l3 {
diff --git a/xen/include/public/sysctl.h b/xen/include/public/sysctl.h
index fcebab1..169e7e6 100644
--- a/xen/include/public/sysctl.h
+++ b/xen/include/public/sysctl.h
@@ -745,6 +745,7 @@ DEFINE_XEN_GUEST_HANDLE(xen_sysctl_pcitopoinfo_t);
 
 #define XEN_SYSCTL_PSR_CAT_get_l3_info   0
 #define XEN_SYSCTL_PSR_CAT_get_l2_info   1
+#define XEN_SYSCTL_PSR_MBA_get_info  2
 struct xen_sysctl_psr_alloc_op {
 uint32_t cmd;   /* IN: XEN_SYSCTL_PSR_CAT_* */
 uint32_t target;/* IN */
@@ -755,6 +756,13 @@ struct xen_sysctl_psr_alloc_op {
 #define XEN_SYSCTL_PSR_CAT_L3_CDP   (1u << 0)
 uint32_t flags; /* OUT: CAT flags */
 } cat_info;
+
+struct {
+uint32_t thrtl_max; /* OUT: Maximum throttle */
+uint32_t cos_max;   /* OUT: Maximum COS */
+#define XEN_SYSCTL_PSR_MBA_LINEAR  (1u << 0)
+uint32_t flags; /* OUT: MBA flags */
+} mba_info;
 } u;
 };
 typedef struct xen_sysctl_psr_alloc_op xen_sysctl_psr_alloc_op_t;
-- 
1.9.1


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [xen-4.6-testing baseline-only test] 72008: regressions - FAIL

2017-08-23 Thread Platform Team regression test user
This run is configured for baseline tests only.

flight 72008 xen-4.6-testing real [real]
http://osstest.xs.citrite.net/~osstest/testlogs/logs/72008/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-amd64-amd64-xl-qemut-stubdom-debianhvm-amd64-xsm 10 debian-hvm-install 
fail REGR. vs. 71984
 test-armhf-armhf-xl-midway   12 guest-start   fail REGR. vs. 71984
 test-amd64-amd64-xl-qemut-debianhvm-amd64-xsm 10 debian-hvm-install fail REGR. 
vs. 71984
 test-amd64-i386-xl-qemuu-win7-amd64 10 windows-installfail REGR. vs. 71984
 test-amd64-i386-qemut-rhel6hvm-intel 15 leak-check/check  fail REGR. vs. 71984
 test-amd64-amd64-libvirt-xsm 18 guest-start/debian.repeat fail REGR. vs. 71984
 test-amd64-i386-xl-qemut-ws16-amd64 10 windows-installfail REGR. vs. 71984
 test-amd64-amd64-xl-qemuu-win10-i386 16 guest-localmigrate/x10 fail REGR. vs. 
71984
 test-amd64-i386-xl-raw   10 debian-di-install fail REGR. vs. 71984
 test-amd64-i386-xl-qemuu-debianhvm-amd64 19 guest-start.2 fail REGR. vs. 71984
 test-amd64-i386-xl-qemuu-win10-i386 10 windows-installfail REGR. vs. 71984

Regressions which are regarded as allowable (not blocking):
 test-amd64-i386-xl-qemuu-ovmf-amd64 14 guest-localmigrate fail REGR. vs. 71984

Tests which did not succeed, but are not blocking:
 test-xtf-amd64-amd64-1   21 xtf/test-hvm32-invlpg~shadow fail   like 71984
 test-xtf-amd64-amd64-1  35 xtf/test-hvm32pae-invlpg~shadow fail like 71984
 test-xtf-amd64-amd64-3   21 xtf/test-hvm32-invlpg~shadow fail   like 71984
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail   like 71984
 test-xtf-amd64-amd64-1   47 xtf/test-hvm64-invlpg~shadow fail   like 71984
 test-xtf-amd64-amd64-3  35 xtf/test-hvm32pae-invlpg~shadow fail like 71984
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail   like 71984
 test-xtf-amd64-amd64-3   47 xtf/test-hvm64-invlpg~shadow fail   like 71984
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail   like 71984
 test-amd64-amd64-qemuu-nested-intel 14 xen-boot/l1 fail like 71984
 test-amd64-amd64-xl-qemuu-win7-amd64 17 guest-stop fail like 71984
 test-amd64-amd64-xl-qemut-win7-amd64 17 guest-stop fail like 71984
 test-amd64-i386-xl-qemut-win7-amd64 17 guest-stop  fail like 71984
 test-amd64-amd64-xl-qemut-win10-i386 10 windows-installfail never pass
 test-xtf-amd64-amd64-5   70 xtf/test-pv32pae-xsa-194 fail   never pass
 test-amd64-i386-libvirt-xsm  13 migrate-support-checkfail   never pass
 test-amd64-amd64-xl-qemut-ws16-amd64 10 windows-installfail never pass
 test-xtf-amd64-amd64-4   70 xtf/test-pv32pae-xsa-194 fail   never pass
 test-amd64-i386-xl-qemut-win10-i386 10 windows-install fail never pass
 test-amd64-amd64-xl-qemuu-ws16-amd64 10 windows-installfail never pass
 test-amd64-amd64-xl-pvh-intel 15 guest-saverestorefail  never pass
 test-armhf-armhf-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  14 saverestore-support-checkfail   never pass
 test-amd64-i386-libvirt  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 13 migrate-support-checkfail  never pass
 test-armhf-armhf-xl-multivcpu 14 saverestore-support-checkfail  never pass
 test-armhf-armhf-xl-credit2  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-xtf-amd64-amd64-2   70 xtf/test-pv32pae-xsa-194 fail   never pass
 test-xtf-amd64-amd64-1   70 xtf/test-pv32pae-xsa-194 fail   never pass
 test-xtf-amd64-amd64-3   70 xtf/test-pv32pae-xsa-194 fail   never pass
 test-amd64-amd64-xl-pvh-amd  12 guest-start  fail   never pass
 test-armhf-armhf-xl-rtds 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 14 saverestore-support-checkfail   never pass
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-raw 12 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-armhf-armhf-xl-vhd  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  13 saverestore-support-checkfail   never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 

[Xen-devel] [linux-linus test] 112834: regressions - trouble: blocked/broken/fail/pass

2017-08-23 Thread osstest service owner
flight 112834 linux-linus real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112834/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-amd64-amd64-examine  7 reboot   fail REGR. vs. 110515
 test-amd64-amd64-i386-pvgrub  7 xen-boot fail REGR. vs. 110515
 test-amd64-amd64-libvirt  7 xen-boot fail REGR. vs. 110515
 test-amd64-amd64-xl-qemuu-ovmf-amd64  7 xen-boot fail REGR. vs. 110515
 test-amd64-amd64-qemuu-nested-intel  7 xen-boot  fail REGR. vs. 110515
 test-amd64-amd64-amd64-pvgrub  7 xen-bootfail REGR. vs. 110515
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 7 xen-boot fail REGR. vs. 
110515
 test-amd64-amd64-xl-qemut-stubdom-debianhvm-amd64-xsm 7 xen-boot fail REGR. 
vs. 110515
 test-amd64-amd64-libvirt-pair 10 xen-boot/src_host   fail REGR. vs. 110515
 test-amd64-amd64-libvirt-pair 11 xen-boot/dst_host   fail REGR. vs. 110515
 test-amd64-amd64-libvirt-vhd  7 xen-boot fail REGR. vs. 110515
 test-amd64-amd64-libvirt-xsm  7 xen-boot fail REGR. vs. 110515
 test-amd64-amd64-xl-qemut-debianhvm-amd64  7 xen-bootfail REGR. vs. 110515
 test-amd64-amd64-xl-xsm   7 xen-boot fail REGR. vs. 110515
 test-amd64-amd64-xl-qcow2 7 xen-boot fail REGR. vs. 110515
 test-amd64-amd64-xl-pvh-intel  7 xen-bootfail REGR. vs. 110515
 test-amd64-amd64-rumprun-amd64  7 xen-boot   fail REGR. vs. 110515
 test-amd64-amd64-pygrub   7 xen-boot fail REGR. vs. 110515
 test-amd64-i386-libvirt  10 debian-install   fail REGR. vs. 110515
 test-amd64-i386-pair 16 debian-install/dst_host  fail REGR. vs. 110515
 test-amd64-amd64-xl-multivcpu 10 debian-install  fail REGR. vs. 110515
 test-amd64-amd64-xl-credit2  10 debian-install   fail REGR. vs. 110515
 test-amd64-i386-xl   10 debian-install   fail REGR. vs. 110515
 test-amd64-i386-libvirt-xsm  10 debian-install   fail REGR. vs. 110515
 test-amd64-i386-libvirt-pair 16 debian-install/dst_host  fail REGR. vs. 110515
 test-amd64-i386-xl-xsm   10 debian-install   fail REGR. vs. 110515
 test-amd64-amd64-xl-pvh-amd  10 debian-install   fail REGR. vs. 110515
 test-armhf-armhf-libvirt-xsm 10 debian-install   fail REGR. vs. 110515
 test-armhf-armhf-libvirt 10 debian-install   fail REGR. vs. 110515
 test-armhf-armhf-xl-cubietruck 10 debian-install fail REGR. vs. 110515
 test-armhf-armhf-xl-multivcpu 10 debian-install  fail REGR. vs. 110515
 test-armhf-armhf-xl-xsm  10 debian-install   fail REGR. vs. 110515
 test-amd64-amd64-xl-qemuu-win7-amd64 16 guest-localmigrate/x10 fail REGR. vs. 
110515
 test-amd64-amd64-xl   7 xen-boot fail REGR. vs. 110515
 test-amd64-amd64-pair10 xen-boot/src_hostfail REGR. vs. 110515
 test-amd64-amd64-pair11 xen-boot/dst_hostfail REGR. vs. 110515
 test-armhf-armhf-xl  10 debian-install   fail REGR. vs. 110515
 test-armhf-armhf-xl-arndale  10 debian-install   fail REGR. vs. 110515
 test-armhf-armhf-xl-credit2  10 debian-install   fail REGR. vs. 110515

Regressions which are regarded as allowable (not blocking):
 build-arm64-pvops 2 hosts-allocate broken REGR. vs. 110515
 build-arm64-xsm   2 hosts-allocate broken REGR. vs. 110515
 build-arm64   2 hosts-allocate broken REGR. vs. 110515
 test-armhf-armhf-xl-rtds 10 debian-install   fail REGR. vs. 110515

Tests which did not succeed, but are not blocking:
 build-arm64-libvirt   1 build-check(1)   blocked  n/a
 test-arm64-arm64-examine  1 build-check(1)   blocked  n/a
 test-arm64-arm64-libvirt-xsm  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl   1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-credit2   1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64-pvops 3 capture-logs  broken blocked in 110515
 build-arm64-xsm   3 capture-logs  broken blocked in 110515
 build-arm64   3 capture-logs  broken blocked in 110515
 test-amd64-amd64-xl-qemut-win7-amd64 18 guest-start/win.repeat fail blocked in 
110515
 test-amd64-i386-xl-qemuu-win7-amd64 17 guest-stop fail like 110515
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail  like 110515
 test-amd64-amd64-xl-rtds 10 debian-install   fail  like 110515
 test-amd64-amd64-xl-qemut-ws16-amd64 10 windows-installfail never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 

[Xen-devel] [ovmf baseline-only test] 72009: all pass

2017-08-23 Thread Platform Team regression test user
This run is configured for baseline tests only.

flight 72009 ovmf real [real]
http://osstest.xs.citrite.net/~osstest/testlogs/logs/72009/

Perfect :-)
All tests in this flight passed as required
version targeted for testing:
 ovmf 27ee96701a9495644aefae3690ca6849a79f7631
baseline version:
 ovmf bb3d1a6198cc5a8f2672927295c9f8d5ede9187c

Last test of basis72003  2017-08-22 08:20:08 Z1 days
Testing same since72009  2017-08-23 16:28:34 Z0 days1 attempts


People who touched revisions under test:
  Jiaxin Wu 
  Wu Jiaxin 

jobs:
 build-amd64-xsm  pass
 build-i386-xsm   pass
 build-amd64  pass
 build-i386   pass
 build-amd64-libvirt  pass
 build-i386-libvirt   pass
 build-amd64-pvopspass
 build-i386-pvops pass
 test-amd64-amd64-xl-qemuu-ovmf-amd64 pass
 test-amd64-i386-xl-qemuu-ovmf-amd64  pass



sg-report-flight on osstest.xs.citrite.net
logs: /home/osstest/logs
images: /home/osstest/images

Logs, config files, etc. are available at
http://osstest.xs.citrite.net/~osstest/testlogs/logs

Test harness code can be found at
http://xenbits.xensource.com/gitweb?p=osstest.git;a=summary


Push not applicable.


commit 27ee96701a9495644aefae3690ca6849a79f7631
Author: Jiaxin Wu 
Date:   Fri Aug 18 10:50:59 2017 +0800

MdeModulePkg/Library: Remove the self-reference in UdpIoLib/TcpIoLib/IpIoLib

Cc: Ye Ting 
Cc: Fu Siyuan 
Cc: Shao Ming 
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Wu Jiaxin 
Reviewed-by: Fu Siyuan 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [stage1-xen (RFC) PATCH 06/10] build/fedora: Add `xen-unstable-runit/*` scripts

2017-08-23 Thread Stefano Stabellini
On Mon, 21 Aug 2017, Rajiv Ranganath wrote:
> From: Rajiv M Ranganath 
> 
> 
> ---
>  build/fedora/xen-unstable-runit/setup.sh   |   21 
> 
>  build/fedora/xen-unstable-runit/teardown.sh|   21 
> 
>  .../xen-init-dom0-disk-backend/run |8 
>  build/fedora/xen-unstable-runit/xen-init-dom0/run  |6 ++
>  build/fedora/xen-unstable-runit/xenconsoled/run|   10 ++
>  build/fedora/xen-unstable-runit/xenstored/run  |   20 +++
>  6 files changed, 86 insertions(+)
>  create mode 100755 build/fedora/xen-unstable-runit/setup.sh
>  create mode 100755 build/fedora/xen-unstable-runit/teardown.sh
>  create mode 100755 
> build/fedora/xen-unstable-runit/xen-init-dom0-disk-backend/run
>  create mode 100755 build/fedora/xen-unstable-runit/xen-init-dom0/run
>  create mode 100755 build/fedora/xen-unstable-runit/xenconsoled/run
>  create mode 100755 build/fedora/xen-unstable-runit/xenstored/run
> 
> diff --git a/build/fedora/xen-unstable-runit/setup.sh 
> b/build/fedora/xen-unstable-runit/setup.sh
> new file mode 100755
> index 000..16699be
> --- /dev/null
> +++ b/build/fedora/xen-unstable-runit/setup.sh
> @@ -0,0 +1,21 @@
> +#!/bin/bash
> +
> +set -e
> +set -o pipefail

In most of my script I tend not to use pipefail because if I use a pipe
is exactly because one of the commands might fail. I do it on purpose.
This script doesn't even have any pipes, I would drop it.


> +# runit RPM creates `/etc/service` directory
> +if [ ! -d "/etc/service" ]; then
> +echo "/etc/service directory not found. Please install runit RPM."
> +exit 1
> +fi
> +
> +runit_services="xenconsoled xen-init-dom0 xen-init-dom0-disk-backend 
> xenstored"
> +
> +pushd /etc/service > /dev/null
> +for service in $runit_services; do
> +ln -sf /opt/xen-unstable-runit/$service $service
> +done
> +popd > /dev/null

pushd and popd are not useful in this script, I would remove them


> +echo "Successfully created symlinks in /etc/service directory."
> +exit 0
> diff --git a/build/fedora/xen-unstable-runit/teardown.sh 
> b/build/fedora/xen-unstable-runit/teardown.sh
> new file mode 100755
> index 000..c0895f4
> --- /dev/null
> +++ b/build/fedora/xen-unstable-runit/teardown.sh
> @@ -0,0 +1,21 @@
> +#!/bin/bash
> +
> +set -e
> +set -o pipefail

same comment on pipefail


> +# runit RPM creates `/etc/service` directory
> +if [ ! -d "/etc/service" ]; then
> +echo "/etc/service directory not found."
> +exit 1
> +fi
> +
> +runit_services="xenconsoled xen-init-dom0 xen-init-dom0-disk-backend 
> xenstored"
> +
> +pushd /etc/service > /dev/null
> +for service in $runit_services; do
> +rm -f $service
> +done
> +popd > /dev/null

same comment on pushd and popd


> +echo "Successfully deleted symlinks in /etc/service directory."
> +exit 0
> diff --git a/build/fedora/xen-unstable-runit/xen-init-dom0-disk-backend/run 
> b/build/fedora/xen-unstable-runit/xen-init-dom0-disk-backend/run
> new file mode 100755
> index 000..a952890
> --- /dev/null
> +++ b/build/fedora/xen-unstable-runit/xen-init-dom0-disk-backend/run
> @@ -0,0 +1,8 @@
> +#!/bin/sh

Why /bin/sh instead of bash? The container should have bash installed,
right?

If we are using bash, I would consider adding a set -e, also in the
other sh scripts below.


> +sv check xenstored >/dev/null || exit 1
> +sv check xenconsoled >/dev/null || exit 1
> +
> +# In case of failure, allow user to run teardown script
> +sleep 5s
> +
> +exec /opt/xen-unstable/lib/xen/bin/qemu-system-i386 -xen-domid 0 -xen-attach 
> -name dom0 -nographic -M xenpv -monitor /dev/null -serial /dev/null -parallel 
> /dev/null -nodefaults -no-user-config
> diff --git a/build/fedora/xen-unstable-runit/xen-init-dom0/run 
> b/build/fedora/xen-unstable-runit/xen-init-dom0/run
> new file mode 100755
> index 000..f7f56ed
> --- /dev/null
> +++ b/build/fedora/xen-unstable-runit/xen-init-dom0/run
> @@ -0,0 +1,6 @@
> +#!/bin/sh
> +sv check xenstored >/dev/null || exit 1
> +
> +/opt/xen-unstable/lib/xen/bin/xen-init-dom0
> +
> +exec chpst -b xen-init-dom0 runit-pause
> diff --git a/build/fedora/xen-unstable-runit/xenconsoled/run 
> b/build/fedora/xen-unstable-runit/xenconsoled/run
> new file mode 100755
> index 000..7a3ab4e
> --- /dev/null
> +++ b/build/fedora/xen-unstable-runit/xenconsoled/run
> @@ -0,0 +1,10 @@
> +#!/bin/sh
> +sv check xen-init-dom0 >/dev/null || exit 1
> +
> +[ ! -d /var/log/xen/console ] && mkdir -p /var/log/xen/console
> +
> +# In case of failure, allow user to run teardown script
> +sleep 5s
> +
> +# --log=[none|guest|hv|all]
> +exec /opt/xen-unstable/sbin/xenconsoled -i --log=none
> diff --git a/build/fedora/xen-unstable-runit/xenstored/run 
> b/build/fedora/xen-unstable-runit/xenstored/run
> new file mode 100755
> index 000..42e5e41
> --- /dev/null
> +++ b/build/fedora/xen-unstable-runit/xenstored/run
> @@ -0,0 +1,20 @@
> +#!/bin/sh
> +[ ! -d 

Re: [Xen-devel] [PATCH 4/6] xsm: flask: change the interface and default policy for xsm_map_gmfn_foregin

2017-08-23 Thread Zhongze Liu
Hi Jan,

Thanks for reviewing my patch.

2017-08-23 17:55 GMT+08:00 Jan Beulich :
 On 22.08.17 at 20:08,  wrote:
>> The original xsm_map_gmfn_foregin policy checks if source domain has the 
>> proper
>> privileges over the target domain. Under this policy, it's not allowed if a 
>> Dom0
>> wants to map pages from one DomU to another, this restricts some useful yet 
>> not
>> dangerous usages of the API, such as sharing pages among DomU's by calling
>> XENMEM_add_to_physmap from Dom0.
>>
>> Change the policy to: IIF current domain has the proper privilege on the
>> target domain and source domain, grant the access.
>
> You say "and here", yet ...
>
>> --- a/xen/include/xsm/dummy.h
>> +++ b/xen/include/xsm/dummy.h
>> @@ -525,10 +525,12 @@ static XSM_INLINE int 
>> xsm_remove_from_physmap(XSM_DEFAULT_ARG struct domain *d1,
>>  return xsm_default_action(action, d1, d2);
>>  }
>>
>> -static XSM_INLINE int xsm_map_gmfn_foreign(XSM_DEFAULT_ARG struct domain 
>> *d, struct domain *t)
>> +static XSM_INLINE int xsm_map_gmfn_foreign(XSM_DEFAULT_ARG struct domain 
>> *cd,
>> +   struct domain *d, struct domain 
>> *t)
>>  {
>>  XSM_ASSERT_ACTION(XSM_TARGET);
>> -return xsm_default_action(action, d, t);
>> +return xsm_default_action(action, cd, d) ||
>> +xsm_default_action(action, cd, t);
>>  }
>
> ... you use "or" here and ...

This might be confusing. But think of returning 0 as "allowed", the
only condition where this
statement returns a 0 is when both calls return 0 -- so it's actually
an "and". (Think of de-morgan's law.)

But as Stefano has pointed out, I should preserve the error code.
And as Daniel has pointed out, I should also check if d and t can share memory.

>
>> --- a/xen/xsm/flask/hooks.c
>> +++ b/xen/xsm/flask/hooks.c
>> @@ -1165,9 +1165,11 @@ static int flask_remove_from_physmap(struct domain 
>> *d1, struct domain *d2)
>>  return domain_has_perm(d1, d2, SECCLASS_MMU, MMU__PHYSMAP);
>>  }
>>
>> -static int flask_map_gmfn_foreign(struct domain *d, struct domain *t)
>> +static int flask_map_gmfn_foreign(struct domain *cd,
>> +  struct domain *d, struct domain *t)
>>  {
>> -return domain_has_perm(d, t, SECCLASS_MMU, MMU__MAP_READ | 
>> MMU__MAP_WRITE);
>> +return domain_has_perm(cd, d, SECCLASS_MMU, MMU__MAP_READ | 
>> MMU__MAP_WRITE) ||
>> +domain_has_perm(cd, t, SECCLASS_MMU, MMU__MAP_READ | 
>> MMU__MAP_WRITE);
>>  }
>
> ... here. A domain can't have XSM_TARGET permission over two
> other domains, so what you want to do here can't work at all,
> afaict.

I agree with what Stefano has said below.

Cheers,

Zhongze Liu.

>
> Jan
>

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [stage1-xen (RFC) PATCH 10/10] BUILDING.md: Add Fedora instructions

2017-08-23 Thread Stefano Stabellini
On Mon, 21 Aug 2017, Rajiv Ranganath wrote:
> ---
>  BUILDING.md |   35 ++-
>  1 file changed, 30 insertions(+), 5 deletions(-)
> 
> diff --git a/BUILDING.md b/BUILDING.md
> index 3ef5311..b9ca404 100644
> --- a/BUILDING.md
> +++ b/BUILDING.md
> @@ -1,7 +1,13 @@
>  # Build
> -stage1-xen requires new Xen and QEMU versions at the time of writing. You 
> are unlikely to find them already packaged with your distro. This document 
> describes how to build and install the latest Xen and QEMU from scratch. In 
> addition, given that CoreOS rkt is also missing from reasonably new distros 
> such as Ubuntu Xenial Xerus, I added instructions on how to build that too. 
> The document includes the dependencies needed for the build based on Ubuntu 
> Xenial Xerus.
> +stage1-xen requires new Xen and QEMU versions at the time of writing. You 
> are unlikely to find them already packaged with your distro. This document 
> describes how to build and install the latest Xen, QEMU and rkt from scratch 
> for Ubuntu Xenial Xerus and Fedora.

I would clarify that the build and installation method for Ubuntu and
the one for Fedora use very different approaches. I would add:

  ... "for Ubuntu Xenial Xerus and Fedora. Differently from the
  documentation for Ubuntu, the documentation for Fedora uses a separate
  Docker container for the build."


> -## Building Xen
> + * [Ubuntu Xenial Xerus](#build_ubuntu)
> + * [Fedora](#build_fedora)

  [Fedora via container]



> +
> +## Ubuntu Xenial Xerus
> +
> +### Building Xen
>  ```
>  apt-get install git build-essential python-dev gettext uuid-dev 
> libncurses5-dev libyajl-dev libaio-dev pkg-config libglib2.0-dev libssl-dev 
> libpixman-1-dev bridge-utils wget libfdt-dev bin86 bcc liblzma-dev iasl 
> libc6-dev-i386
>  
> @@ -17,7 +23,7 @@ reboot
>  Make sure to select Xen at boot, or edit /boot/grub/grub.cfg to make it the 
> default, changing "set default="0" to point to the appropriate entry below 
> (the one booting xen.gz), which could be entry number "4" for example.
>  
>  
> -## Building QEMU
> +### Building QEMU
>  ```
>  apt-get install libglib2.0-dev libpixman-1-dev libcap-dev libattr1-dev
>  
> @@ -54,7 +60,7 @@ make install
>  cp i386-softmmu/qemu-system-i386 /usr/lib/xen/bin/
>  ```
>  
> -## Building CoreOS rkt
> +### Building CoreOS rkt
>  ```
>  apt-get install golang automake libacl1-dev libsystemd-dev
>  ./configure --disable-tpm --with-stage1-flavors=coreos
> @@ -62,7 +68,7 @@ make
>  cp build-rkt-1.26.0+git/target/bin/rkt /usr/sbin
>  ```
>  
> -## Building stage1-xen
> +### Building stage1-xen
>  ```
>  apt-get install busybox-static jq
>  
> @@ -72,3 +78,22 @@ export GOPATH=/path/to/gopath
>  bash build.sh
>  cp stage1-xen.aci /home/username
>  ```
> +
> +
> +## Fedora
> +
> +On Fedora we build stage1-xen artifacts (Xen, QEMU and rkt) in a docker 
> container as follows 
> +
> +```
> +cd stage1-xen
> +
> +docker pull lambdalinuxfedora/stage1-xen-fedora-buildroot
> +
> +docker run --rm \
> +  -v `pwd`:/root/gopath/src/github.com/rkt/stage1-xen \
> +  -v /tmp:/tmp \
> +  -t -i lambdalinuxfedora/stage1-xen-fedora-buildroot \
> +  /sbin/my_init -- /root/bin/run
> +```
> +
> +Once `docker run` completes, the build artifact `stage1-xen-build.tar.gz` is 
> generated in `/tmp` directory. Please see 
> [RUNNING_STAGE1_XEN.md](build/fedora/RUNNING_STAGE1_XEN.md) for details on 
> how to setup Fedora for running stage1-xen.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [stage1-xen (RFC) PATCH 09/10] build/fedora: Add `RUNNING_STAGE1_XEN.md`

2017-08-23 Thread Stefano Stabellini
On Mon, 21 Aug 2017, Rajiv Ranganath wrote:

This is a great and well detailed document. I have a few suggestions
below to provide some info for people that wants to do it manually.


> ---
>  build/fedora/RUNNING_STAGE1_XEN.md |  383 
> 
>  1 file changed, 383 insertions(+)
>  create mode 100644 build/fedora/RUNNING_STAGE1_XEN.md
> 
> diff --git a/build/fedora/RUNNING_STAGE1_XEN.md 
> b/build/fedora/RUNNING_STAGE1_XEN.md
> new file mode 100644
> index 000..705e7e4
> --- /dev/null
> +++ b/build/fedora/RUNNING_STAGE1_XEN.md
> @@ -0,0 +1,383 @@
> +# Running Stage1 Xen on Fedora
> +
> +This document outlines the steps to get started with stage1-xen on Fedora. 
> They are 
> +
> + * [Preparing your machine and installing minimal 
> Fedora](#preparing_your_machine_and_installing_minimal_fedora)
> + * [Booting into Xen](#booting_into_xen)
> + * [Launching Xen services](#launching_xen_services)
> + * [Setting up Xen networking](#setting_up_xen_networking)
> + * [Running stage1-xen](#running_stage1-xen)
> +
> +
> +## Preparing your machine and installing minimal Fedora
> +
> +On x86 platform there are two ways to start an operating system or a 
> hypervisor. They are 
> +
> + * Legacy BIOS Mode
> + * EFI Mode
> +
> +Latest operating systems and hypervisors including Fedora and Xen has 
> support for EFI mode. If you are unfamiliar with EFI we recommend checking 
> out this [article](http://www.rodsbooks.com/efi-bootloaders/principles.html).
> +
> +By default, most BIOS now boot using EFI Mode. In your BIOS menu, there 
> might be an option to toggle _Legacy BIOS Mode_. Do not toggle that option.
> +
> +### Enable VT-x and VT-d
> +
> +Please ensure that you have enabled VT-x and if available VT-d.
> +
> +### Disable Secure Boot
> +
> +As we will be booting a custom build of Xen, we need to disable secure boot. 
> You will find an option in your BIOS menu to disable secure boot.
> +
> +### Installing minimal Fedora
> +
> +The default Fedora installation installs packages that we do not require 
> when running Xen. We recommend doing a minimal Fedora as follows.
> +
> + 1. Download Net Install image
> +
> + 2. Prepare a USB drive
> +
> + 3. Do a minimal Fedora Install
> +
> +You can download the Fedora net install image 
> [here](https://alt.fedoraproject.org/). You can select either the Fedora 
> Server or Fedora Workstation image, it doesn't really matter.
> +
> +After downloading the net install images, please copy the raw image onto a 
> USB drive. Please see 
> [this](https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Installation_Guide/sect-making-usb-media.html)
>  link on how to prepare USB drive.
> +
> +EFI BIOS comes with a _BIOS Boot Menu_ using which you can select the device 
> to boot from. Insert the USB drive, then go into your BIOS Boot Menu and boot 
> using the USB drive. This should start the Fedora Network Installer.
> +
> +In the Fedora Installer, there is a section for under _SOFTWARE_ called 
> _SOFTWARE SELECTION_. In this section please **select** either _Minimal 
> Install_ or _Basic Desktop_, **without** any add-ons. 
> +
> +**Note:** If there is existing data on the hard disk, please ensure that 
> _INSTALLATION DESTINATION_ under _SYSTEM_ section is appropriately 
> configured. 
> +
> +Then click on _Begin Installation_ to complete the installation.
> +
> +Once the installation is complete, please disable SELinux by editing 
> `/etc/selinux/config`.
> +
> +You now have a minimal Fedora Installation, which is good for working with 
> Xen.
> +
> +
> +## Booting into Xen
> +
> +Log into Fedora as root and copy over `stage1-xen-build.tar.gz`. Extract 
> `stage1-xen-build.tar.gz` into `/opt` directory.

The doc is good. As for other patches in this series, I spend a couple
of words on the build without a Docker container. In this case, I would
say:

  "Build and Install Xen and stage1-xen. Please see buildroot-README.md on
  how to do it. If you follow the automatic build with Docker, then copy
  over `stage1-xen-build.tar.gz`. Extract `stage1-xen-build.tar.gz` into
  `/opt` directory."


> +```shell
> +[root@localhost ~]# tar zxvf stage1-xen-build.tar.gz -C /opt
> +
> +[root@localhost ~]# ls /opt
> +qemu-unstable  stage1-xen  xen-unstable  xen-unstable-runit
> +```
> +
> +This will extract all the build artifacts into `/opt` directory.
> +
> +Next we will create a BIOS Boot Menu entry to boot `xen-4.10-unstable.efi`. 
> This will start Xen hypervisor. Xen will then start Fedora as Dom-0 guest.
> +
> +On Fedora, EFI system partition (ESP) is usually mounted at `/boot/efi`. 
> This is a `vfat` partition. You can check if EFI system partition is mounted 
> as follows 
> +
> +```shell
> +[root@localhost ~]# mount | grep '\/boot\/efi'
> +/dev/sda1 on /boot/efi type vfat 
> (rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,errors=remount-ro)
> +```
> +
> +Create a directory for Xen under 

Re: [Xen-devel] [stage1-xen (RFC) PATCH 08/10] README.md: Add CircleCI badge

2017-08-23 Thread Stefano Stabellini
On Mon, 21 Aug 2017, Rajiv Ranganath wrote:
> From: Rajiv M Ranganath 

Reviewed-by: Stefano Stabellini 

 
> ---
>  README.md |2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/README.md b/README.md
> index 9ea6adf..e1cd40c 100644
> --- a/README.md
> +++ b/README.md
> @@ -1,5 +1,7 @@
>  # stage1-xen - A Xen based stage1 for CoreOS rkt
>  
> +[![Build 
> Status](https://circleci.com/gh/rkt/stage1-xen/tree/master.svg?style=shield=:circle-token)](https://circleci.com/gh/rkt/stage1-xen/tree/master)
> +
>  ## Goal
>  
>  CoreOS rkt is a modular container engine with [three stages of 
> execution](https://coreos.com/rkt/docs/latest/devel/stage1-implementors-guide.html).
>  Stage1 is responsible for creating the execution environment for the 
> contained applications.
> 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [stage1-xen (RFC) PATCH 07/10] .circleci/config.yml: Add

2017-08-23 Thread Stefano Stabellini
On Mon, 21 Aug 2017, Rajiv Ranganath wrote:
> From: Rajiv M Ranganath 

Does .circleci need to be in the top directory or could it be under
fedora? If possible, I think it would make more sense to introduce it
there.

> 
> ---
>  .circleci/config.yml |   21 +
>  1 file changed, 21 insertions(+)
>  create mode 100644 .circleci/config.yml
> 
> diff --git a/.circleci/config.yml b/.circleci/config.yml
> new file mode 100644
> index 000..67ac964
> --- /dev/null
> +++ b/.circleci/config.yml
> @@ -0,0 +1,21 @@
> +version: 2
> +jobs:
> +  build:
> +working_directory: /root
> +docker:
> +  - image: lambdalinuxfedora/stage1-xen-fedora-buildroot:1708171409
> +command: /sbin/my_init
> +steps:
> +  - run:
> +  # We create `stage1-xen` directory in Dockerfile for local dev
> +  # environment. Removing it here so CircleCI checkout step can work
> +  # correctly
> +  name: Removing stage1-xen directory from GOPATH...
> +  command: |
> +rm -rf /root/gopath/src/github.com/rkt/stage1-xen
> +  - checkout:
> +  path: /root/gopath/src/github.com/rkt/stage1-xen
> +  - run:
> +  name: Starting run...
> +  command: |
> +/root/bin/run
> 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [stage1-xen (RFC) PATCH 02/10] build/fedora: Add `buildroot-README.md`

2017-08-23 Thread Stefano Stabellini
On Mon, 21 Aug 2017, Rajiv Ranganath wrote:
> From: Rajiv M Ranganath 

In addition to the instructions below, please mention how to build
stage1-xen manually by installing the dependencies listed in
buildroot-Dockerfile and executing build/fedora/run by hand.


>  build/fedora/buildroot-README.md |   50 
> ++
>  1 file changed, 50 insertions(+)
>  create mode 100644 build/fedora/buildroot-README.md
> 
> diff --git a/build/fedora/buildroot-README.md 
> b/build/fedora/buildroot-README.md
> new file mode 100644
> index 000..0efb150
> --- /dev/null
> +++ b/build/fedora/buildroot-README.md
> @@ -0,0 +1,50 @@
> +## stage1-xen Fedora Buildroot
> +
> +stage1-xen build artifacts for Fedora is built in two phases. In the first 
> phase
> +a docker container is prepared with all the build dependencies. We refer to 
> it
> +as `stage1-xen-fedora-buildroot`. In the next phase we execute the `run` 
> script
> +that uses `stage1-xen-fedora-buildroot` and to produce the build artifacts.
> +
> +### Building `stage1-xen-fedora-buildroot`
> +
> +`stage1-xen-fedora-buildroot` has a external dependency
> +on [`binutils`](https://github.com/lambda-linux-fedora/binutils) package 
> that is
> +compiled with `i386pe` support. You can download the pre-built RPMs
> +from [here](https://drive.google.com/open?id=0B_tTbuxmuRzIR05wQ3E1eWVyaGs).
> +Please download `binutils-2.26.1-1.1.fc25.tar`.
> +
> +To build docker image
> +
> +```
> +cd stage1-xen/build/fedora
> +
> +docker build -f buildroot-Dockerfile -t stage1-xen-fedora-buildroot .
> +```
> +
> +### Running `stage1-xen-fedora-buildroot`
> +
> +```
> +cd stage1-xen
> +
> +docker run --rm \
> +  -v `pwd`:/root/gopath/src/github.com/rkt/stage1-xen \
> +  -v /tmp:/tmp \
> +  -t -i stage1-xen-fedora-buildroot \
> +  /sbin/my_init -- /root/bin/run
> +```
> +
> +The generated build artifacts are in `/tmp` directory.
> +
> +To debug build issues -
> +
> +```
> +cd stage1-xen
> +
> +docker run --rm \
> +  -v `pwd`:/root/gopath/src/github.com/rkt/stage1-xen \
> +  -v /tmp:/tmp \
> +  -t -i stage1-xen-fedora-buildroot \
> +  /sbin/my_init -- /bin/bash
> +```
> +
> +Also see section on `ipdb` in `buildroot-Dockerfile`.
> 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [stage1-xen (RFC) PATCH 04/10] build/fedora: Add `run`

2017-08-23 Thread Stefano Stabellini
On Mon, 21 Aug 2017, Rajiv Ranganath wrote:
> From: Rajiv M Ranganath 

This is great, just a couple of comments. Please split it into two
scripts: one to build the dependecies (xen, qemu, etc.), and the other
to build stage1-xen. Of course, you could have one `run' script that
calls both scripts for convenience.

That way, a user could call the dependency builder once on her system,
then call the stage1-xen builder as many times as needed. The script
will be more reusable.

You won't like this final suggestion, but I'll try anyway :-) I would
prefer if this script was in bash. I have nothing against python (in
fact I know python better than other scripting languages) but I try to
minimize the number of languages required to contribute to stage1-xen.
But if it is python or nothing, I'll take python.


>  build/fedora/run |   87 
> ++
>  1 file changed, 87 insertions(+)
>  create mode 100755 build/fedora/run
> 
> diff --git a/build/fedora/run b/build/fedora/run
> new file mode 100755
> index 000..37e1dac
> --- /dev/null
> +++ b/build/fedora/run
> @@ -0,0 +1,87 @@
> +#!/usr/bin/python2
> +
> +import shlex
> +import subprocess
> +import sys
> +import os
> +
> +
> +# helper function to capture stdout from a long running process
> +def subprocess_stdout(cmd, cwd, env):
> +p = subprocess.Popen(
> +shlex.split(cmd), cwd=cwd, env=env, stdout=subprocess.PIPE)
> +while p.poll() is None:
> +l = p.stdout.readline()
> +sys.stdout.write(l)
> +
> +
> +env = os.environ.copy()
> +
> +# build and install xen-unstable
> +print "Cloning xen-unstable..."
> +cmd = 'git clone git://xenbits.xen.org/xen.git'
> +subprocess.check_output(shlex.split(cmd), cwd='/root')
> +
> +steps = [
> +'./configure --prefix=/opt/xen-unstable 
> --with-system-qemu=/opt/xen-unstable/lib/xen/bin/qemu-system-i386 
> --disable-stubdom --disable-qemu-traditional --disable-rombios 
> --sysconfdir=/opt/xen-unstable/etc --enable-rpath --disable-systemd',

I think it is fine to install things under /opt by default, but I would
like it to be configurable. A global variable at the top of the script
to set the destination directory is good enough.


> +'make',
> +'make install BOOT_DIR=/opt/xen-unstable/boot 
> DEBUG_DIR=/opt/xen-unstable/lib/debug 
> EFI_DIR=/opt/xen-unstable/boot/efi/EFI/xen'
> +]
> +for cmd in steps:
> +cwd = '/root/xen'
> +subprocess_stdout(cmd, cwd, env)
> +
> +# build and install qemu-unstable
> +print "Cloning qemu-unstable..."
> +cmd = 'git clone git://git.qemu.org/qemu.git'
> +subprocess.check_output(shlex.split(cmd), cwd='/root')
> +
> +steps = [
> +'./configure --prefix=/opt/qemu-unstable --enable-xen 
> --target-list=i386-softmmu --extra-cflags="-I/opt/xen-unstable/include" 
> --extra-ldflags="-L/opt/xen-unstable/lib -Wl,-rpath,/opt/xen-unstable/lib" 
> --disable-kvm --enable-virtfs --enable-linux-aio',
> +'make', 'make install'

Same here about the destination directory


> +]
> +for cmd in steps:
> +cwd = '/root/qemu'
> +subprocess_stdout(cmd, cwd, env)
> +
> +cmd = 'cp i386-softmmu/qemu-system-i386 
> /opt/xen-unstable/lib/xen/bin/qemu-system-i386'
> +subprocess.check_output(shlex.split(cmd), cwd='/root/qemu')
> +
> +# build rkt
> +print "Cloning rkt..."
> +cmd = 'git clone https://github.com/rkt/rkt.git'
> +subprocess.check_output(shlex.split(cmd), cwd='/root')
> +
> +steps = [
> +'./autogen.sh', './configure --disable-tpm --with-stage1-flavors=coreos',
> +'make'
> +]
> +for cmd in steps:
> +cwd = '/root/rkt'
> +subprocess_stdout(cmd, cwd, env)
> +
> +# build stage1-xen
> +env['GOPATH'] = '/root/gopath'
> +cwd = '/root/gopath/src/github.com/rkt/stage1-xen'
> +cmd = 'bash build.sh'
> +subprocess_stdout(cmd, cwd, env)
> +
> +# install build artifacts to `/opt/`
> +steps = [
> +'mkdir -p /opt/stage1-xen/bin', 'mkdir -p /opt/stage1-xen/aci',
> +'cp /root/rkt/build-rkt-1.28.1+git/target/bin/rkt 
> /opt/stage1-xen/bin/rkt',
> +'cp /root/gopath/src/github.com/rkt/stage1-xen/stage1-xen.aci 
> /opt/stage1-xen/aci/stage1-xen.aci',
> +'cp 
> /root/gopath/src/github.com/rkt/stage1-xen/build/fedora/source_path.sh 
> /opt/stage1-xen/bin/source_path.sh',
> +'cp -r 
> /root/gopath/src/github.com/rkt/stage1-xen/build/fedora/xen-unstable-runit 
> /opt/xen-unstable-runit'
> +]
> +for cmd in steps:
> +cwd = '/root'
> +subprocess_stdout(cmd, cwd, env)
> +
> +cwd = '/opt'
> +cmd = 'tar zcvf /root/stage1-xen-build.tar.gz qemu-unstable/ stage1-xen/ 
> xen-unstable/ xen-unstable-runit/'
> +subprocess_stdout(cmd, cwd, env)
> +
> +cwd = '/root'
> +cmd = 'mv /root/stage1-xen-build.tar.gz /tmp'
> +subprocess_stdout(cmd, cwd, env)
> 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [stage1-xen (RFC) PATCH 00/10] Add Fedora support

2017-08-23 Thread Stefano Stabellini
On Mon, 21 Aug 2017, Rajiv Ranganath wrote:
> Hi Stefanao,
> 
> Following series adds documentation on how to use stage1-xen on Fedora.
> It also adds continuous build support using CircleCI.
> 
> Xen, Qemu, rkt and stage1 ACI image are built using a Fedora based
> container. This setup allows for a reproducible build environment that
> we can use locally and also within a CI system.
> 
> Below is an overview of the series -
> 
> build/fedora: Add `buildroot-README.md`
> build/fedora: Add `buildroot-Dockerfile`
> build/fedora: Add `run`
> 
> `build/fedora` directory is introduced. In this directory we can
> maintain documentation, scripts and patches relating to Fedora support
> for stage1-xen.
> 
> `buildroot-README.md` describes a two stage container build process.
> This is modeled on how we do builds for distro packages, but using
> containers instead of a mock/chroot environment. The build artifact
> produced by `run` script is a tarball, instead of a rpm or deb file.
> 
> build/fedora: Add `source_path.sh`
> build/fedora: Add `xen-unstable-runit/*` scripts
> 
> Scripts used within build artifact tarball.
> 
> .circleci/config.yml: Add
> README.md: Add CircleCI badge
> 
> Adds CircleCI support. Here [1][2] is a temporary repo with Circle CI
> support enabled.
> 
> build/fedora: Add `RUNNING_STAGE1_XEN.md`
> BUILDING.md: Add Fedora instructions
> 
> Update docs.
> 
> Please let me know your comments. Thank you!
> 
> Best,
> Rajiv
> 
> [1]: https://github.com/lambda-linux-fedora/stage1-xen/tree/wip
> [2]: https://circleci.com/gh/lambda-linux-fedora/stage1-xen/tree/wip


Hi Rajiv,

Thank you very much for your work on this! From an high level, I think
it is very good.

One thing I would like to ask is that you make it just a bit more
modular. I think it is OK to use a Docker container for the build, but I
would like to support users that prefer to build on their own system by
calling build/fedora/run manually, the same script used by the Docker
container.

I don't think it would be a lot of effort to change the docs and the
script to allow that but it would be of great benefit.

I'll add more comments on the patches.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH] x86: enable RCU based table free when PARAVIRT

2017-08-23 Thread Linus Torvalds
On Wed, Aug 23, 2017 at 3:36 PM, Kirill A. Shutemov
 wrote:
>
> Below is test cases that allocates a lot of page tables and measuare
> fork/exit time. (I'm not entirely sure it's the best way to stress the
> codepath.)

Looks ok to me. Doing a profile (without the RCU freeing, obviously) gives me

   0.77%  a.out[kernel.vmlinux]  [k] free_pgd_range


  ▒

so it does seem to spend time in the page directory code.

> Unpatched:  average 4.8322s, stddev 0.114s
> Patched:average 4.8362s, stddev 0.111s

Ok, I vote for avoiding the complexity of two different behaviors, and
just making the page table freeing use RCU unconditionally.

If actively trying to trigger that code doesn't show a real measurable
difference, I don't think it matters, and the fewer different code
paths we have, the better.

  Linus

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH] xen: Don't try to call xen_alloc_p2m_entry() on autotranslating guests

2017-08-23 Thread Boris Ostrovsky
Commit aba831a69632 ("xen: remove tests for pvh mode in pure pv paths")
removed XENFEAT_auto_translated_physmap test in xen_alloc_p2m_entry()
since it is assumed that the routine is never called by non-PV guests.

However, alloc_xenballooned_pages() may make this call on a PVH guest.
Prevent this from happening by adding XENFEAT_auto_translated_physmap
check there.

Signed-off-by: Boris Ostrovsky 
Fixes: aba831a69632 ("xen: remove tests for pvh mode in pure pv paths")
---
 drivers/xen/balloon.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/xen/balloon.c b/drivers/xen/balloon.c
index ab60925..f77e499 100644
--- a/drivers/xen/balloon.c
+++ b/drivers/xen/balloon.c
@@ -664,9 +664,11 @@ int alloc_xenballooned_pages(int nr_pages, struct page 
**pages)
 */
BUILD_BUG_ON(XEN_PAGE_SIZE != PAGE_SIZE);
 
-   ret = xen_alloc_p2m_entry(page_to_pfn(page));
-   if (ret < 0)
-   goto out_undo;
+   if (!xen_feature(XENFEAT_auto_translated_physmap)) {
+   ret = xen_alloc_p2m_entry(page_to_pfn(page));
+   if (ret < 0)
+   goto out_undo;
+   }
 #endif
} else {
ret = add_ballooned_pages(nr_pages - pgno);
-- 
1.8.3.1


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH 1/1] xen-blkback: stop blkback thread of every queue in xen_blkif_disconnect

2017-08-23 Thread Konrad Rzeszutek Wilk
.snip..
> > 
> > Acked-by: Roger Pau Monné 
> 
> Forgot to add, this needs to be backported to stable branches, so:

Annie, could you resend the patch with the tags and an update
to the description to me please?
> 
> Cc: sta...@vger.kernel.org
> 
> Roger.
> 
> ___
> Xen-devel mailing list
> Xen-devel@lists.xen.org
> https://lists.xen.org/xen-devel

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH] x86: enable RCU based table free when PARAVIRT

2017-08-23 Thread Linus Torvalds
On Wed, Aug 23, 2017 at 12:59 PM, Kirill A. Shutemov
 wrote:
>
> In this case we need performance numbers for !PARAVIRT kernel.

Yes.

> Numbers for tight loop of "mmap(MAP_POPULATE); munmap()" might be
> interesting too for worst case scenario.

Actually, I don't think you want to populate all the pages. You just
want to populate *one* page, in order to build up the page directory
structure, not allocate all the final points.

And we only free the actual page tables when there is nothing around,
so it should be at least a 2MB-aligned region etc.

So you should do a *big* allocation, and then touch a single page in
the middle, and then minmap it - that should give you maximal page
table activity. Otherwise the page tables will generally just stay
around.

Realistically, it's mainly exit() that frees page tables. Yes, you may
have a few page tables free'd by a normal munmap(), but it's usually
very limited. Which is why I suggested that script-heavy thing with
lots of small executables. That tends to be the main realistic load
that really causes a ton of page directory activity.

  Linus

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [libvirt test] 112840: tolerable trouble: blocked/broken/pass - PUSHED

2017-08-23 Thread osstest service owner
flight 112840 libvirt real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112840/

Failures :-/ but no regressions.

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-libvirt-xsm  1 build-check(1)   blocked  n/a
 build-arm64-libvirt   1 build-check(1)   blocked  n/a
 test-arm64-arm64-libvirt-qcow2  1 build-check(1)   blocked  n/a
 test-arm64-arm64-libvirt  1 build-check(1)   blocked  n/a
 build-arm64-xsm   2 hosts-allocate  broken like 112808
 build-arm64-pvops 2 hosts-allocate  broken like 112808
 build-arm64-xsm   3 capture-logsbroken like 112808
 build-arm64   2 hosts-allocate  broken like 112808
 build-arm64-pvops 3 capture-logsbroken like 112808
 build-arm64   3 capture-logsbroken like 112808
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail  like 112808
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail  like 112808
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail  like 112808
 test-amd64-amd64-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt  13 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt-xsm  13 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-amd64-libvirt-vhd 12 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-raw 12 migrate-support-checkfail   never pass

version targeted for testing:
 libvirt  a530078cd2d7d9a47a6e96a64f70497fb7b2ff10
baseline version:
 libvirt  0f1993aa15f281b3812806e29df729149a5b64c6

Last test of basis   112808  2017-08-22 04:24:14 Z1 days
Testing same since   112840  2017-08-23 04:21:20 Z0 days1 attempts


People who touched revisions under test:
  Ján Tomko 
  Pavel Hrdina 

jobs:
 build-amd64-xsm  pass
 build-arm64-xsm  broken  
 build-armhf-xsm  pass
 build-i386-xsm   pass
 build-amd64  pass
 build-arm64  broken  
 build-armhf  pass
 build-i386   pass
 build-amd64-libvirt  pass
 build-arm64-libvirt  blocked 
 build-armhf-libvirt  pass
 build-i386-libvirt   pass
 build-amd64-pvopspass
 build-arm64-pvopsbroken  
 build-armhf-pvopspass
 build-i386-pvops pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm   pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsmpass
 test-amd64-amd64-libvirt-xsm pass
 test-arm64-arm64-libvirt-xsm blocked 
 test-armhf-armhf-libvirt-xsm pass
 test-amd64-i386-libvirt-xsm  pass
 test-amd64-amd64-libvirt pass
 test-arm64-arm64-libvirt blocked 
 test-armhf-armhf-libvirt pass
 test-amd64-i386-libvirt  pass
 test-amd64-amd64-libvirt-pairpass
 test-amd64-i386-libvirt-pair pass
 test-arm64-arm64-libvirt-qcow2   blocked 
 test-armhf-armhf-libvirt-raw pass
 test-amd64-amd64-libvirt-vhd pass



sg-report-flight on osstest.test-lab.xenproject.org
logs: /home/logs/logs
images: /home/logs/images

Logs, config files, etc. are available at
http://logs.test-lab.xenproject.org/osstest/logs

Explanation of these 

Re: [Xen-devel] [PATCH] x86: enable RCU based table free when PARAVIRT

2017-08-23 Thread Kirill A. Shutemov
On Wed, Aug 23, 2017 at 11:26:46AM -0700, Linus Torvalds wrote:
> On Wed, Aug 23, 2017 at 6:45 AM, Vitaly Kuznetsov  wrote:
> >
> > Solve the issue by enabling RCU-based table free mechanism when PARAVIRT
> > is selected in config. Testing with kernbench doesn't show any notable
> > performance impact:
> 
> I wonder if we should just make it unconditional if it doesn't really
> show any performance difference. One less config complexity to worry
> about (and in this case I'm not so much worried about Kconfig itself,
> as just "oh, you have totally different paths in the core VM depending
> on PARAVIRT".

In this case we need performance numbers for !PARAVIRT kernel.

> That said, the thing to test for these kinds of things is often
> heavily scripted loads that just run thousands and thousands of really
> small processes, and build up and tear down page tables all the time
> because of fork/exit.
> 
> The load I've used occasionally is just "make test" in the git source
> tree. Tons and tons of trivial fork/exec/exit things for all those
> small tests and shell scripts.

Numbers for tight loop of "mmap(MAP_POPULATE); munmap()" might be
interesting too for worst case scenario.

-- 
 Kirill A. Shutemov

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [xen-4.9-testing baseline-only test] 72007: regressions - trouble: blocked/broken/fail/pass

2017-08-23 Thread Platform Team regression test user
This run is configured for baseline tests only.

flight 72007 xen-4.9-testing real [real]
http://osstest.xs.citrite.net/~osstest/testlogs/logs/72007/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-amd64-i386-pair 11 xen-boot/dst_host fail REGR. vs. 71979
 test-amd64-amd64-migrupgrade 10 xen-boot/src_host fail REGR. vs. 71979
 test-amd64-i386-xl-qemuu-win7-amd64 18 guest-start/win.repeat fail REGR. vs. 
71979
 test-amd64-i386-xl-qemut-ws16-amd64 10 windows-installfail REGR. vs. 71979
 test-amd64-amd64-qemuu-nested-intel 17 debian-hvm-install/l1/l2 fail REGR. vs. 
71979
 test-amd64-amd64-xl-qemut-win7-amd64 18 guest-start/win.repeat fail REGR. vs. 
71979

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-libvirt-xsm  1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl   1 build-check(1)   blocked  n/a
 build-arm64-libvirt   1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-credit2   1 build-check(1)   blocked  n/a
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64   2 hosts-allocate   broken never pass
 build-arm64-pvops 2 hosts-allocate   broken never pass
 build-arm64-xsm   2 hosts-allocate   broken never pass
 build-arm64   3 capture-logs broken never pass
 build-arm64-pvops 3 capture-logs broken never pass
 build-arm64-xsm   3 capture-logs broken never pass
 test-amd64-amd64-xl-qemuu-win7-amd64 17 guest-stop   fail blocked in 71979
 test-amd64-i386-xl-qemut-win10-i386 10 windows-install fail like 71979
 test-amd64-amd64-xl-qemuu-win10-i386 10 windows-installfail like 71979
 test-amd64-i386-xl-qemuu-ws16-amd64 10 windows-install fail never pass
 test-amd64-i386-xl-qemuu-win10-i386 10 windows-install fail never pass
 test-amd64-amd64-xl-qemut-win10-i386 10 windows-installfail never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-midway   13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-midway   14 saverestore-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  14 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu 13 migrate-support-checkfail  never pass
 test-armhf-armhf-xl-multivcpu 14 saverestore-support-checkfail  never pass
 test-armhf-armhf-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt 14 saverestore-support-checkfail   never pass
 test-amd64-i386-libvirt  13 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt-xsm  13 migrate-support-checkfail   never pass
 test-amd64-amd64-xl-qemut-ws16-amd64 10 windows-installfail never pass
 test-amd64-amd64-xl-qemuu-ws16-amd64 10 windows-installfail never pass
 test-amd64-amd64-libvirt-xsm 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 14 saverestore-support-checkfail   never pass
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-raw 12 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-raw 13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-vhd  13 saverestore-support-checkfail   never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 11 migrate-support-check 
fail never pass
 test-amd64-amd64-qemuu-nested-amd 17 debian-hvm-install/l1/l2  fail never pass
 test-amd64-amd64-libvirt-vhd 12 migrate-support-checkfail   never pass

version targeted for testing:
 xen  9bf14bbf990843bfec16a5d69d36cf46c7593d88
baseline version:
 xen  0e186e33c0487a81c48dccdede206e63db22dd7d

Last test of basis71979  2017-08-16 03:50:15 Z7 days
Testing same since72007  2017-08-23 12:22:55 Z0 days1 attempts


People who touched revisions under test:
  Jan Beulich 

Re: [Xen-devel] [PATCH 14/27] xen/arm: traps: Improve logging for data/prefetch abort fault

2017-08-23 Thread Julien Grall



On 08/22/2017 06:20 PM, Andre Przywara wrote:

Hi,


Hi Andre,



On 14/08/17 15:24, Julien Grall wrote:

Walk the hypervisor page table for data/prefetch abort fault to help
diagnostics error in the page tables.

Signed-off-by: Julien Grall 
---
  xen/arch/arm/traps.c | 19 +++
  1 file changed, 19 insertions(+)

diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 819bdbc69e..dac4e54fa7 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -2967,7 +2967,26 @@ asmlinkage void do_trap_hyp_sync(struct cpu_user_regs 
*regs)
  do_trap_brk(regs, hsr);
  break;
  #endif
+case HSR_EC_DATA_ABORT_CURR_EL:
+case HSR_EC_INSTR_ABORT_CURR_EL:
+{
+bool is_data = (hsr.ec == HSR_EC_DATA_ABORT_CURR_EL);
+const char *fault = (is_data) ? "Data Abort" : "Instruction Abort";
+
+printk("%s Trap. Syndrome=%#x\n", fault, hsr.iss);
+/*
+ * FAR may not be valid for a Synchronous External abort other
+ * than translation table walk.
+ */
+if ( hsr.xabt.fsc != FSC_SEA || !hsr.xabt.fnv )


This is quite hard to read. Would the DeMorgan'ed version be better?
   if ( hsr.xabt.fsc == FSC_SEA && hsr.xabt.fnv )
   printk 
else
   dump_hyp_walk ...


Indeed it is better. I will use that.

Cheers,




+dump_hyp_walk(get_hfar(is_data));
+else
+printk("Invalid FAR, don't walk the hypervisor tables\n");


Nit: "not walking" sounds less ambiguous.


+do_unexpected_trap(fault, regs);
  
+break;

+}
  default:
  printk("Hypervisor Trap. HSR=0x%x EC=0x%x IL=%x 
Syndrome=0x%"PRIx32"\n",
 hsr.bits, hsr.ec, hsr.len, hsr.iss);


Ignoring the nits above:


I will fix both and keep the reviewed-by if you don't mind.


Reviewed-by: Andre Przywara 


Cheers,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH 11/27] xen/arm: Add FnV field in hsr_*abt

2017-08-23 Thread Julien Grall

On 08/22/2017 05:07 PM, Andre Przywara wrote:

Hi,


Hi Andre,


On 14/08/17 15:24, Julien Grall wrote:

FnV (FAR not Valid) bit was introduced by ARMv8 in both AArch32 and
AArch64 (See D7-2275, D7-2277, G6-4958, G6-4962 in ARM DDI 0487B.a).


I understand that this just prepares the data structures for patch #14,
but I was wondering if we should update the other fields on the way as
well, for instance there is now "ar" in Aarch32 also.


I didn't want to do it because hsr_dabt will get a bit messy for 
AArch32. For instance bit[10] has a different meaning depending on the 
value of DFSC.


So if you don't mind, I would stick on FnV for now and will add the 
others when we really need them :).


Cheers,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH] x86/pv: Minor improvements to guest_get_eff_{, kern}_l1e()

2017-08-23 Thread Andrew Cooper
 * These functions work in terms of linear addresses, not virtual addresses.
   Update the comments and parameter names.
 * Drop unnecessary inlines.
 * Drop vcpu parameter from guest_get_eff_kern_l1e().  Its sole caller passes
   current, and its callee strictly operates on current.
 * Switch guest_get_eff_kern_l1e()'s parameter from void * to l1_pgentry_t *.
   Both its caller and callee already use the correct type already.

Signed-off-by: Andrew Cooper 
---
CC: Jan Beulich 
CC: Wei Liu 
---
 xen/arch/x86/mm.c | 22 +++---
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 3262499..8993e6d 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -561,15 +561,15 @@ static inline void guest_unmap_l1e(void *p)
 unmap_domain_page(p);
 }
 
-/* Read a PV guest's l1e that maps this virtual address. */
-static inline void guest_get_eff_l1e(unsigned long addr, l1_pgentry_t *eff_l1e)
+/* Read a PV guest's l1e that maps this linear address. */
+static void guest_get_eff_l1e(unsigned long linear, l1_pgentry_t *eff_l1e)
 {
 ASSERT(!paging_mode_translate(current->domain));
 ASSERT(!paging_mode_external(current->domain));
 
-if ( unlikely(!__addr_ok(addr)) ||
+if ( unlikely(!__addr_ok(linear)) ||
  __copy_from_user(eff_l1e,
-  &__linear_l1_table[l1_linear_offset(addr)],
+  &__linear_l1_table[l1_linear_offset(linear)],
   sizeof(l1_pgentry_t)) )
 *eff_l1e = l1e_empty();
 }
@@ -578,18 +578,18 @@ static inline void guest_get_eff_l1e(unsigned long addr, 
l1_pgentry_t *eff_l1e)
  * Read the guest's l1e that maps this address, from the kernel-mode
  * page tables.
  */
-static inline void guest_get_eff_kern_l1e(struct vcpu *v, unsigned long addr,
-  void *eff_l1e)
+static void guest_get_eff_kern_l1e(unsigned long linear, l1_pgentry_t *eff_l1e)
 {
-const bool user_mode = !(v->arch.flags & TF_kernel_mode);
+struct vcpu *curr = current;
+const bool user_mode = !(curr->arch.flags & TF_kernel_mode);
 
 if ( user_mode )
-toggle_guest_mode(v);
+toggle_guest_mode(curr);
 
-guest_get_eff_l1e(addr, eff_l1e);
+guest_get_eff_l1e(linear, eff_l1e);
 
 if ( user_mode )
-toggle_guest_mode(v);
+toggle_guest_mode(curr);
 }
 
 static inline void page_set_tlbflush_timestamp(struct page_info *page)
@@ -676,7 +676,7 @@ int map_ldt_shadow_page(unsigned int off)
 
 if ( is_pv_32bit_domain(d) )
 gva = (u32)gva;
-guest_get_eff_kern_l1e(v, gva, );
+guest_get_eff_kern_l1e(gva, );
 if ( unlikely(!(l1e_get_flags(l1e) & _PAGE_PRESENT)) )
 return 0;
 
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH 10/27] xen/arm: arm32: Don't define FAR_EL1

2017-08-23 Thread Julien Grall



On 08/22/2017 03:37 PM, Andre Przywara wrote:

Hi,


Hi Andre,


On 14/08/17 15:24, Julien Grall wrote:

Aliasing FAR_EL1 to IFAR is wrong because on ARMv8 FAR_EL1[31:0] is
architecturally mapped to DFAR and FAR_EL1[63:32] to DFAR.


Should be IFAR, I guess?


Yep. I will fix it.


Please put a quid into the copy-and-paste piggy bank ;-)


2 quite with the copy-paste in patch #9 :).

Cheers,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH 09/27] xen/arm: traps: Don't define FAR_EL2 for ARM32

2017-08-23 Thread Julien Grall

On 08/22/2017 03:12 PM, Andre Przywara wrote:

Hi,


Hi Andre,


On 14/08/17 15:24, Julien Grall wrote:

Aliasing FAR_EL2 to HIFAR makes the code confusing because on ARMv8
FAR_EL2[31:0] is architecturally mapped to HDFAR and FAR_EL2[63:32] to
FAR_EL2.

   ^^^
I guess you mean HIFAR here.
Otherwise the patch makes sense.

Whoops yes. I will fix it in the next version.

Cheers,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH 25/27] xen/arm: mm: Embed permission in the flags

2017-08-23 Thread Julien Grall



On 08/23/2017 03:37 PM, Andre Przywara wrote:

Hi,

Hi Andre,


On 23/08/17 15:26, Julien Grall wrote:

On 08/23/2017 03:08 PM, Andre Przywara wrote:

Hi,


Hi,


On 14/08/17 15:24, Julien Grall wrote:

Currently, it is not possible to specify the permission of a new
mapping. It would be necessary to use the function modify_xen_mappings
with a different set of flags.



Just saw that I forgot the typos here:


Add introduce a couple of new flags for the permissions (Non-eXecutable,


Either "add" or "introduce", I guess.


I guess my mind disagree with my hands :). I will use "introduce" here.




Read-Only) and also provides define that combine the memory attribute
and permission for common combination.


Somehow the plural/singular is messed up here, I needed to read that
sentence multiple times.



If I haven't been lost in the definitions, this now adds "not
executable" to the existing definitions, which seems to make sense, but
is a change that might trigger regressions (especially for
PAGE_HYPERVISOR). So I wonder if that should be mentioned in the commit
message then?


It will not trigger regression because mfn_to_xen_entry is setting xn to
1 by default. So all the mapping will be execute never when using
PAGE_HYPERVISOR.


Ah right, I missed that. Might still be worth to mention in the commit
message, as this isn't obvious from just that patch.


I can do that. Below the suggested commit message:

"Currently, it is not possible to specify the permission of a new
mapping. It would be necessary to use the function modify_xen_mappings
with a different set of flags.

Introduce a couple of new flags for the permissions (Non-eXecutable,
Read-Only) and also provides define that combine the memory attribute
and permission for common combination.

PAGE_HYPERVISOR is now an alias to PAGE_HYPERVISOR_RW (read-write 
non-executable mappings). This does not affect the current mapping using 
PAGE_HYPERVISOR because this


A follow-up patch will change modify_xen_mappings to use the new flags."

Can I keep your reviewed-by?

Cheers,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH 19/27] xen/arm: page: Clean-up the definition of MAIRVAL

2017-08-23 Thread Julien Grall



On 08/23/2017 12:42 PM, Andre Przywara wrote:

Hi,


Hi Andre,


On 14/08/17 15:24, Julien Grall wrote:

Currently MAIRVAL is defined in term of MAIR0VAL and MAIR1VAL which are
both hardcoded value. This makes quite difficult to understand the value
written in both registers.

Rework the definition by using value of each attribute shifted by their
associated index.

Signed-off-by: Julien Grall 


I checked all the bits and encoding against the ARMv8 ARM, they look
correct to me.
However I feel that the attribute renaming patch (20/27) should come
before this one.


I can invert the two patches. I don't plan to keep your tags in both 
patches as this would sensibly change some bits.


Cheers,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH 18/27] xen/arm: page: Prefix memory types with MT_

2017-08-23 Thread Julien Grall

On 08/23/2017 12:41 PM, Andre Przywara wrote:

Hi,


Hi Andre,


On 14/08/17 15:24, Julien Grall wrote: >> diff --git 
a/xen/include/asm-arm/page.h b/xen/include/asm-arm/page.h

index 660e1779c5..d7a048b64d 100644
--- a/xen/include/asm-arm/page.h
+++ b/xen/include/asm-arm/page.h
@@ -25,17 +25,17 @@
   * LPAE Memory region attributes. Indexed by the AttrIndex bits of a
   * LPAE entry; the 8-bit fields are packed little-endian into MAIR0 and MAIR1.
   *
- * aiencoding
- *   UNCACHED  000      -- Strongly Ordered
- *   BUFFERABLE001   0100 0100  -- Non-Cacheable
- *   WRITETHROUGH  010   1010 1010  -- Write-through
- *   WRITEBACK 011   1110 1110  -- Write-back
- *   DEV_SHARED100    0100  -- Device
- *   ??101
- *   reserved  110
- *   WRITEALLOC111      -- Write-back write-allocate
+ *aiencoding
+ *   MT_UNCACHED  000      -- Strongly Ordered
+ *   MT_BUFFERABLE001   0100 0100  -- Non-Cacheable
+ *   MT_WRITETHROUGH  010   1010 1010  -- Write-through
+ *   MT_WRITEBACK 011   1110 1110  -- Write-back
+ *   MT_DEV_SHARED100    0100  -- Device
+ *   ??   101
+ *   reserved 110
+ *   MT_WRITEALLOC111      -- Write-back write-allocate
   *
- *   DEV_WC001   (== BUFFERABLE)
+ *   MT_DEV_WC001   (== BUFFERABLE)


It's just a comment, but for consistency this should be MT_BUFFERABLE
here as well, I guess.

Apart from that nit the rest looks correct.


Hmm, I dropped DEV_WC in patch #17 but forgot to remove it from the 
comment. I will drop it in that patch and ...




Reviewed-by: Andre Przywara 


... keep you reviewed-by here and the #17 if you are happy with it.

Cheers,

--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH] x86: enable RCU based table free when PARAVIRT

2017-08-23 Thread Linus Torvalds
On Wed, Aug 23, 2017 at 6:45 AM, Vitaly Kuznetsov  wrote:
>
> Solve the issue by enabling RCU-based table free mechanism when PARAVIRT
> is selected in config. Testing with kernbench doesn't show any notable
> performance impact:

I wonder if we should just make it unconditional if it doesn't really
show any performance difference. One less config complexity to worry
about (and in this case I'm not so much worried about Kconfig itself,
as just "oh, you have totally different paths in the core VM depending
on PARAVIRT".

That said, the thing to test for these kinds of things is often
heavily scripted loads that just run thousands and thousands of really
small processes, and build up and tear down page tables all the time
because of fork/exit.

The load I've used occasionally is just "make test" in the git source
tree. Tons and tons of trivial fork/exec/exit things for all those
small tests and shell scripts.

I think 'kernbench' just does kernel compiles. Which is not very
kernel or VM intensive at all. It's mostly just user mode compilers in
parallel.

   Linus

___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH] x86/pv: Drop create_pae_xen_mappings()

2017-08-23 Thread Andrew Cooper
This is leftovers from the 32bit hypervisor days.  The only Xen content in
this virtual range for 32bit PV guests is the compat M2P.  It is not critical
that the mapping is present, nor is it critical that the slot is unshared.

Signed-off-by: Andrew Cooper 
---
CC: Jan Beulich 
CC: Wei Liu 
CC: Tim Deegan 
CC: George Dunlap 
---
 xen/arch/x86/mm.c | 46 --
 1 file changed, 46 deletions(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index ed77270..3262499 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -1429,46 +1429,6 @@ static int alloc_l1_table(struct page_info *page)
 return ret;
 }
 
-static int create_pae_xen_mappings(struct domain *d, l3_pgentry_t *pl3e)
-{
-struct page_info *page;
-l3_pgentry_t l3e3;
-
-if ( !is_pv_32bit_domain(d) )
-return 1;
-
-pl3e = (l3_pgentry_t *)((unsigned long)pl3e & PAGE_MASK);
-
-/* 3rd L3 slot contains L2 with Xen-private mappings. It *must* exist. */
-l3e3 = pl3e[3];
-if ( !(l3e_get_flags(l3e3) & _PAGE_PRESENT) )
-{
-gdprintk(XENLOG_WARNING, "PAE L3 3rd slot is empty\n");
-return 0;
-}
-
-/*
- * The Xen-private mappings include linear mappings. The L2 thus cannot
- * be shared by multiple L3 tables. The test here is adequate because:
- *  1. Cannot appear in slots != 3 because get_page_type() checks the
- * PGT_pae_xen_l2 flag, which is asserted iff the L2 appears in slot 3
- *  2. Cannot appear in another page table's L3:
- * a. alloc_l3_table() calls this function and this check will fail
- * b. mod_l3_entry() disallows updates to slot 3 in an existing table
- */
-page = l3e_get_page(l3e3);
-BUG_ON(page->u.inuse.type_info & PGT_pinned);
-BUG_ON((page->u.inuse.type_info & PGT_count_mask) == 0);
-BUG_ON(!(page->u.inuse.type_info & PGT_pae_xen_l2));
-if ( (page->u.inuse.type_info & PGT_count_mask) != 1 )
-{
-gdprintk(XENLOG_WARNING, "PAE L3 3rd slot is shared\n");
-return 0;
-}
-
-return 1;
-}
-
 static int alloc_l2_table(struct page_info *page, unsigned long type,
   int preemptible)
 {
@@ -1573,8 +1533,6 @@ static int alloc_l3_table(struct page_info *page)
 adjust_guest_l3e(pl3e[i], d);
 }
 
-if ( rc >= 0 && !create_pae_xen_mappings(d, pl3e) )
-rc = -EINVAL;
 if ( rc < 0 && rc != -ERESTART && rc != -EINTR )
 {
 gdprintk(XENLOG_WARNING, "Failure in alloc_l3_table: slot %#x\n", i);
@@ -2120,10 +2078,6 @@ static int mod_l3_entry(l3_pgentry_t *pl3e,
 return -EFAULT;
 }
 
-if ( likely(rc == 0) )
-if ( !create_pae_xen_mappings(d, pl3e) )
-BUG();
-
 put_page_from_l3e(ol3e, pfn, 0, 1);
 return rc;
 }
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [xen-unstable-smoke test] 112847: tolerable trouble: broken/pass - PUSHED

2017-08-23 Thread osstest service owner
flight 112847 xen-unstable-smoke real [real]
http://logs.test-lab.xenproject.org/osstest/logs/112847/

Failures :-/ but no regressions.

Tests which did not succeed, but are not blocking:
 test-arm64-arm64-xl-xsm   1 build-check(1)   blocked  n/a
 build-arm64-pvops 2 hosts-allocate  broken like 112825
 build-arm64   2 hosts-allocate  broken like 112825
 build-arm64-pvops 3 capture-logsbroken like 112825
 build-arm64   3 capture-logsbroken like 112825
 test-amd64-amd64-libvirt 13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  13 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  14 saverestore-support-checkfail   never pass

version targeted for testing:
 xen  98df75f2782e47c47002d57ca5c5832de4e903fc
baseline version:
 xen  4a0485c3d343e1c582fa824e4896b9b613a14efe

Last test of basis   112825  2017-08-22 16:03:07 Z1 days
Testing same since   112847  2017-08-23 16:01:33 Z0 days1 attempts


People who touched revisions under test:
  Christopher Clark 
  Daniel De Graaf 
  Jan Beulich 
  Roger Pau Monné 

jobs:
 build-amd64  pass
 build-arm64  broken  
 build-armhf  pass
 build-amd64-libvirt  pass
 build-arm64-pvopsbroken  
 test-armhf-armhf-xl  pass
 test-arm64-arm64-xl-xsm  broken  
 test-amd64-amd64-xl-qemuu-debianhvm-i386 pass
 test-amd64-amd64-libvirt pass



sg-report-flight on osstest.test-lab.xenproject.org
logs: /home/logs/logs
images: /home/logs/images

Logs, config files, etc. are available at
http://logs.test-lab.xenproject.org/osstest/logs

Explanation of these reports, and of osstest in general, is at
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README.email;hb=master
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README;hb=master

Test harness code can be found at
http://xenbits.xen.org/gitweb?p=osstest.git;a=summary

broken-step build-arm64-pvops hosts-allocate
broken-step build-arm64 hosts-allocate
broken-step build-arm64-pvops capture-logs
broken-step build-arm64 capture-logs

Pushing revision :

+ branch=xen-unstable-smoke
+ revision=98df75f2782e47c47002d57ca5c5832de4e903fc
+ . ./cri-lock-repos
++ . ./cri-common
+++ . ./cri-getconfig
+++ umask 002
+++ getrepos
 getconfig Repos
 perl -e '
use Osstest;
readglobalconfig();
print $c{"Repos"} or die $!;
'
+++ local repos=/home/osstest/repos
+++ '[' -z /home/osstest/repos ']'
+++ '[' '!' -d /home/osstest/repos ']'
+++ echo /home/osstest/repos
++ repos=/home/osstest/repos
++ repos_lock=/home/osstest/repos/lock
++ '[' x '!=' x/home/osstest/repos/lock ']'
++ OSSTEST_REPOS_LOCK_LOCKED=/home/osstest/repos/lock
++ exec with-lock-ex -w /home/osstest/repos/lock ./ap-push xen-unstable-smoke 
98df75f2782e47c47002d57ca5c5832de4e903fc
+ branch=xen-unstable-smoke
+ revision=98df75f2782e47c47002d57ca5c5832de4e903fc
+ . ./cri-lock-repos
++ . ./cri-common
+++ . ./cri-getconfig
+++ umask 002
+++ getrepos
 getconfig Repos
 perl -e '
use Osstest;
readglobalconfig();
print $c{"Repos"} or die $!;
'
+++ local repos=/home/osstest/repos
+++ '[' -z /home/osstest/repos ']'
+++ '[' '!' -d /home/osstest/repos ']'
+++ echo /home/osstest/repos
++ repos=/home/osstest/repos
++ repos_lock=/home/osstest/repos/lock
++ '[' x/home/osstest/repos/lock '!=' x/home/osstest/repos/lock ']'
+ . ./cri-common
++ . ./cri-getconfig
++ umask 002
+ select_xenbranch
+ case "$branch" in
+ tree=xen
+ xenbranch=xen-unstable-smoke
+ qemuubranch=qemu-upstream-unstable
+ '[' xxen = xlinux ']'
+ linuxbranch=
+ '[' xqemu-upstream-unstable = x ']'
+ select_prevxenbranch
++ ./cri-getprevxenbranch xen-unstable-smoke
+ prevxenbranch=xen-4.9-testing
+ '[' x98df75f2782e47c47002d57ca5c5832de4e903fc = x ']'
+ : tested/2.6.39.x
+ . ./ap-common
++ : osst...@xenbits.xen.org
+++ getconfig OsstestUpstream
+++ perl -e '
use Osstest;
readglobalconfig();
print $c{"OsstestUpstream"} or die $!;
'
++ :
++ : git://xenbits.xen.org/xen.git
++ : osst...@xenbits.xen.org:/home/xen/git/xen.git
++ : git://xenbits.xen.org/qemu-xen-traditional.git
++ : git://git.kernel.org
++ : 

[Xen-devel] [PATCH v4 10/53] xen/arch/x86/hvm/viridian.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/x86/hvm/viridian.c

to indicate whether the parameter value was parsed successfully.

Fix an error in the parsing function: up to now it would overwrite the
stack in case more than 3 values are specified.

Cc: Paul Durrant 
Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
Acked-by: Paul Durrant 
---
V3:
- dont modify option value in parsing function
- fix error in parsing routine
---
 xen/arch/x86/hvm/viridian.c | 28 ++--
 1 file changed, 18 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/hvm/viridian.c b/xen/arch/x86/hvm/viridian.c
index aa9b87c0ab..2edf9d0b23 100644
--- a/xen/arch/x86/hvm/viridian.c
+++ b/xen/arch/x86/hvm/viridian.c
@@ -1083,7 +1083,7 @@ static int viridian_load_vcpu_ctxt(struct domain *d, 
hvm_domain_context_t *h)
 HVM_REGISTER_SAVE_RESTORE(VIRIDIAN_VCPU, viridian_save_vcpu_ctxt,
   viridian_load_vcpu_ctxt, 1, HVMSR_PER_VCPU);
 
-static void __init parse_viridian_version(char *arg)
+static int __init parse_viridian_version(const char *arg)
 {
 const char *t;
 unsigned int n[3];
@@ -1093,17 +1093,24 @@ static void __init parse_viridian_version(char *arg)
 n[1] = viridian_minor;
 n[2] = viridian_build;
 
-while ( (t = strsep(, ",")) != NULL )
-{
+do {
 const char *e;
 
-if ( *t == '\0' )
-continue;
+t = strchr(arg, ',');
+if ( !t )
+t = strchr(arg, '\0');
+
+if ( *arg && *arg != ',' && i < 3 )
+{
+n[i] = simple_strtoul(arg, , 0);
+if ( e != t )
+goto fail;
+}
+
+i++;
+arg = t + 1;
+} while ( *t );
 
-n[i++] = simple_strtoul(t, , 0);
-if ( *e != '\0' )
-goto fail;
-}
 if ( i != 3 )
 goto fail;
 
@@ -1118,10 +1125,11 @@ static void __init parse_viridian_version(char *arg)
 
 printk("viridian-version = %#x,%#x,%#x\n",
viridian_major, viridian_minor, viridian_build);
-return;
+return 0;
 
  fail:
 printk(XENLOG_WARNING "Invalid viridian-version, using default\n");
+return -EINVAL;
 }
 custom_param("viridian-version", parse_viridian_version);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 51/53] libxl: add libxl_set_parameters() function

2017-08-23 Thread Juergen Gross
Add a new libxl function to set hypervisor parameters at runtime
similar to boot time parameters via command line.

Cc: Ian Jackson 
Cc: Wei Liu 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
---
V2:
- corrected coding style (Wei Liu)
- removed superfluous #ifdef (Wei Liu)

V3:
- use LOGEV() for error message
---
 tools/libxl/libxl.c | 15 +++
 tools/libxl/libxl.h |  8 
 2 files changed, 23 insertions(+)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 0ef874406f..247c56cf83 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -652,6 +652,21 @@ int libxl_send_debug_keys(libxl_ctx *ctx, char *keys)
 return 0;
 }
 
+int libxl_set_parameters(libxl_ctx *ctx, char *params)
+{
+int ret;
+GC_INIT(ctx);
+
+ret = xc_set_parameters(ctx->xch, params);
+if (ret < 0) {
+LOGEV(ERROR, ret, "setting parameters");
+GC_FREE;
+return ERROR_FAIL;
+}
+GC_FREE;
+return 0;
+}
+
 static int fd_set_flags(libxl_ctx *ctx, int fd,
 int fcntlgetop, int fcntlsetop, const char *fl,
 int flagmask, int set_p)
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 229e289750..17045253ab 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -1051,6 +1051,13 @@ void libxl_mac_copy(libxl_ctx *ctx, libxl_mac *dst, 
const libxl_mac *src);
  */
 #define LIBXL_HAVE_QED 1
 
+/*
+ * LIBXL_HAVE_SET_PARAMETERS
+ *
+ * If this is defined setting hypervisor parameters is supported.
+ */
+#define LIBXL_HAVE_SET_PARAMETERS 1
+
 typedef char **libxl_string_list;
 void libxl_string_list_dispose(libxl_string_list *sl);
 int libxl_string_list_length(const libxl_string_list *sl);
@@ -2105,6 +2112,7 @@ int libxl_send_trigger(libxl_ctx *ctx, uint32_t domid,
libxl_trigger trigger, uint32_t vcpuid);
 int libxl_send_sysrq(libxl_ctx *ctx, uint32_t domid, char sysrq);
 int libxl_send_debug_keys(libxl_ctx *ctx, char *keys);
+int libxl_set_parameters(libxl_ctx *ctx, char *params);
 
 typedef struct libxl__xen_console_reader libxl_xen_console_reader;
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 31/53] xen/drivers/char/console.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/drivers/char/console.c

to indicate whether the parameter value was parsed successfully.

Cc: Andrew Cooper 
Cc: George Dunlap 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Konrad Rzeszutek Wilk 
Cc: Stefano Stabellini 
Cc: Tim Deegan 
Cc: Wei Liu 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
 xen/drivers/char/console.c | 31 +++
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 8f2a24496a..36f94e6b94 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -67,7 +67,7 @@ enum con_timestamp_mode
 
 static enum con_timestamp_mode __read_mostly opt_con_timestamp_mode = TSM_NONE;
 
-static void parse_console_timestamps(char *s);
+static int parse_console_timestamps(const char *s);
 custom_param("console_timestamps", parse_console_timestamps);
 
 /* conring_size: allows a large console ring than default (16kB). */
@@ -123,8 +123,8 @@ static int __read_mostly xenlog_guest_upper_thresh =
 static int __read_mostly xenlog_guest_lower_thresh =
 XENLOG_GUEST_LOWER_THRESHOLD;
 
-static void parse_loglvl(char *s);
-static void parse_guest_loglvl(char *s);
+static int parse_loglvl(const char *s);
+static int parse_guest_loglvl(const char *s);
 
 /*
  *  := none|error|warning|info|debug|all
@@ -145,7 +145,7 @@ static atomic_t print_everything = ATOMIC_INIT(0);
 return (lvlnum);\
 }
 
-static int __init __parse_loglvl(char *s, char **ps)
+static int __init __parse_loglvl(const char *s, const char **ps)
 {
 ___parse_loglvl(s, ps, "none",0);
 ___parse_loglvl(s, ps, "error",   1);
@@ -156,23 +156,26 @@ static int __init __parse_loglvl(char *s, char **ps)
 return 2; /* sane fallback */
 }
 
-static void __init _parse_loglvl(char *s, int *lower, int *upper)
+static int __init _parse_loglvl(const char *s, int *lower, int *upper)
 {
 *lower = *upper = __parse_loglvl(s, );
 if ( *s == '/' )
 *upper = __parse_loglvl(s+1, );
 if ( *upper < *lower )
 *upper = *lower;
+
+return *s ? -EINVAL : 0;
 }
 
-static void __init parse_loglvl(char *s)
+static int __init parse_loglvl(const char *s)
 {
-_parse_loglvl(s, _lower_thresh, _upper_thresh);
+return _parse_loglvl(s, _lower_thresh, _upper_thresh);
 }
 
-static void __init parse_guest_loglvl(char *s)
+static int __init parse_guest_loglvl(const char *s)
 {
-_parse_loglvl(s, _guest_lower_thresh, _guest_upper_thresh);
+return _parse_loglvl(s, _guest_lower_thresh,
+ _guest_upper_thresh);
 }
 
 static char *loglvl_str(int lvl)
@@ -603,16 +606,16 @@ static int printk_prefix_check(char *p, char **pp)
 ((loglvl < upper_thresh) && printk_ratelimit()));
 } 
 
-static void __init parse_console_timestamps(char *s)
+static int __init parse_console_timestamps(const char *s)
 {
 switch ( parse_bool(s, NULL) )
 {
 case 0:
 opt_con_timestamp_mode = TSM_NONE;
-return;
+return 0;
 case 1:
 opt_con_timestamp_mode = TSM_DATE;
-return;
+return 0;
 }
 if ( *s == '\0' || /* Compat for old booleanparam() */
  !strcmp(s, "date") )
@@ -623,6 +626,10 @@ static void __init parse_console_timestamps(char *s)
 opt_con_timestamp_mode = TSM_BOOT;
 else if ( !strcmp(s, "none") )
 opt_con_timestamp_mode = TSM_NONE;
+else
+return -EINVAL;
+
+return 0;
 }
 
 static void printk_start_of_line(const char *prefix)
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 35/53] xen/drivers/passthrough/pci.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/drivers/passthrough/pci.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich 
Signed-off-by: Juergen Gross 
---
V4:
- differentiate error return values (Jan Beulich)
- drop pointless test for input parameter being NULL (Jan Beulich)

V3:
- cosmetic changes (Jan Beulich)
- dont modify option value in parsing funtion
---
 xen/drivers/passthrough/pci.c | 38 --
 1 file changed, 24 insertions(+), 14 deletions(-)

diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c
index 27bdb7163c..ce22aa41a4 100644
--- a/xen/drivers/passthrough/pci.c
+++ b/xen/drivers/passthrough/pci.c
@@ -149,17 +149,20 @@ static struct phantom_dev {
 } phantom_devs[8];
 static unsigned int nr_phantom_devs;
 
-static void __init parse_phantom_dev(char *str) {
-const char *s = str;
+static int __init parse_phantom_dev(const char *str)
+{
+const char *s;
 unsigned int seg, bus, slot;
 struct phantom_dev phantom;
 
-if ( !s || !*s || nr_phantom_devs >= ARRAY_SIZE(phantom_devs) )
-return;
+if ( !*str )
+return -EINVAL;
+if ( nr_phantom_devs >= ARRAY_SIZE(phantom_devs) )
+return -E2BIG;
 
-s = parse_pci(s, , , , NULL);
+s = parse_pci(str, , , , NULL);
 if ( !s || *s != ',' )
-return;
+return -EINVAL;
 
 phantom.seg = seg;
 phantom.bus = bus;
@@ -170,10 +173,12 @@ static void __init parse_phantom_dev(char *str) {
 case 1: case 2: case 4:
 if ( *s )
 default:
-return;
+return -EINVAL;
 }
 
 phantom_devs[nr_phantom_devs++] = phantom;
+
+return 0;
 }
 custom_param("pci-phantom", parse_phantom_dev);
 
@@ -189,9 +194,10 @@ static u16 __read_mostly bridge_ctl_mask;
  *   perr   don't suppress parity errors (default)
  *   no-perrsuppress parity errors
  */
-static void __init parse_pci_param(char *s)
+static int __init parse_pci_param(const char *s)
 {
-char *ss;
+const char *ss;
+int rc = 0;
 
 do {
 bool_t on = !!strncmp(s, "no-", 3);
@@ -201,19 +207,21 @@ static void __init parse_pci_param(char *s)
 s += 3;
 
 ss = strchr(s, ',');
-if ( ss )
-*ss = '\0';
+if ( !ss )
+ss = strchr(s, '\0');
 
-if ( !strcmp(s, "serr") )
+if ( !strncmp(s, "serr", ss - s) )
 {
 cmd_mask = PCI_COMMAND_SERR;
 brctl_mask = PCI_BRIDGE_CTL_SERR | PCI_BRIDGE_CTL_DTMR_SERR;
 }
-else if ( !strcmp(s, "perr") )
+else if ( !strncmp(s, "perr", ss - s) )
 {
 cmd_mask = PCI_COMMAND_PARITY;
 brctl_mask = PCI_BRIDGE_CTL_PARITY;
 }
+else
+rc = -EINVAL;
 
 if ( on )
 {
@@ -227,7 +235,9 @@ static void __init parse_pci_param(char *s)
 }
 
 s = ss + 1;
-} while ( ss );
+} while ( *ss );
+
+return rc;
 }
 custom_param("pci", parse_pci_param);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 07/53] xen/arch/x86/cpu/vpmu.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/x86/cpu/vpmu.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
 xen/arch/x86/cpu/vpmu.c | 11 ++-
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/cpu/vpmu.c b/xen/arch/x86/cpu/vpmu.c
index 1c0ea10777..fd2fcacc26 100644
--- a/xen/arch/x86/cpu/vpmu.c
+++ b/xen/arch/x86/cpu/vpmu.c
@@ -53,7 +53,7 @@ CHECK_pmu_params;
 static unsigned int __read_mostly opt_vpmu_enabled;
 unsigned int __read_mostly vpmu_mode = XENPMU_MODE_OFF;
 unsigned int __read_mostly vpmu_features = 0;
-static void parse_vpmu_params(char *s);
+static int parse_vpmu_params(const char *s);
 custom_param("vpmu", parse_vpmu_params);
 
 static DEFINE_SPINLOCK(vpmu_lock);
@@ -61,7 +61,7 @@ static unsigned vpmu_count;
 
 static DEFINE_PER_CPU(struct vcpu *, last_vcpu);
 
-static int parse_vpmu_param(char *s, unsigned int len)
+static int parse_vpmu_param(const char *s, unsigned int len)
 {
 if ( !*s || !len )
 return 0;
@@ -76,9 +76,9 @@ static int parse_vpmu_param(char *s, unsigned int len)
 return 0;
 }
 
-static void __init parse_vpmu_params(char *s)
+static int __init parse_vpmu_params(const char *s)
 {
-char *sep, *p = s;
+const char *sep, *p = s;
 
 switch ( parse_bool(s, NULL) )
 {
@@ -104,10 +104,11 @@ static void __init parse_vpmu_params(char *s)
 opt_vpmu_enabled = 1;
 break;
 }
-return;
+return 0;
 
  error:
 printk("VPMU: unknown flags: %s - vpmu disabled!\n", s);
+return -EINVAL;
 }
 
 void vpmu_lvtpc_update(uint32_t val)
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 11/53] xen/arch/x86/hvm/vmx/vmcs.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/x86/hvm/vmx/vmcs.c

to indicate whether the parameter value was parsed successfully.

Cc: Jun Nakajima 
Cc: Kevin Tian 
Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
---
V3:
- dont modify option value in parsing function
---
 xen/arch/x86/hvm/vmx/vmcs.c | 19 ---
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c
index 7854802cba..02f54e7f84 100644
--- a/xen/arch/x86/hvm/vmx/vmcs.c
+++ b/xen/arch/x86/hvm/vmx/vmcs.c
@@ -74,9 +74,10 @@ static s8 __read_mostly opt_ept_ad = -1;
  *  pml Enable PML
  *  ad  Use A/D bits
  */
-static void __init parse_ept_param(char *s)
+static int __init parse_ept_param(const char *s)
 {
-char *ss;
+const char *ss;
+int rc = 0;
 
 do {
 bool_t val = !!strncmp(s, "no-", 3);
@@ -85,16 +86,20 @@ static void __init parse_ept_param(char *s)
 s += 3;
 
 ss = strchr(s, ',');
-if ( ss )
-*ss = '\0';
+if ( !ss )
+ss = strchr(s, '\0');
 
-if ( !strcmp(s, "pml") )
+if ( !strncmp(s, "pml", ss - s) )
 opt_pml_enabled = val;
-else if ( !strcmp(s, "ad") )
+else if ( !strncmp(s, "ad", ss - s) )
 opt_ept_ad = val;
+else
+rc = -EINVAL;
 
 s = ss + 1;
-} while ( ss );
+} while ( *ss );
+
+return rc;
 }
 custom_param("ept", parse_ept_param);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 40/53] xen: check parameter validity when parsing command line

2017-08-23 Thread Juergen Gross
Where possible check validity of parameters in _cmdline_parse() and
issue a warning message in case of an error detected.

In order to make sure a custom parameter parsing function really
returns a value (error or success), don't use a void pointer for
storing the function address, but a proper typed function pointer.

Cc: Andrew Cooper 
Cc: George Dunlap 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Konrad Rzeszutek Wilk 
Cc: Stefano Stabellini 
Cc: Tim Deegan 
Cc: Wei Liu 
Signed-off-by: Juergen Gross 
---
V4:
- removed test for empty string from parse_bool() again, avoid calling
  parse_bool() in that case (Jan Beulich)
- print error number in failure case (Jan Beulich)
- limit scope of some variables (Jan Beulich)
- use type bool for bool_assert (Jan Beulich)

V3:
- use function pointer in struct kernel_param (Jan Beulich)
- better range check in assign_integer_param() (Jan Beulich)
- dont assign int values in case of overflow (Jan Beulich)
- allow multiple handlers for a parameter (Jan Beulich)

V2:
- replaced literal 8 by BITS_PER_BYTE (Wei Liu)
- added test for empty string to parse_bool()
---
 xen/common/kernel.c | 68 ++---
 xen/include/xen/init.h  | 30 +-
 xen/include/xen/types.h |  3 +++
 3 files changed, 80 insertions(+), 21 deletions(-)

diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index 4979e1c49b..063ac99bff 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -23,34 +23,43 @@ enum system_state system_state = SYS_STATE_early_boot;
 xen_commandline_t saved_cmdline;
 static const char __initconst opt_builtin_cmdline[] = CONFIG_CMDLINE;
 
-static void __init assign_integer_param(
+static int __init assign_integer_param(
 const struct kernel_param *param, uint64_t val)
 {
 switch ( param->len )
 {
 case sizeof(uint8_t):
-*(uint8_t *)param->var = val;
+if ( val > UINT8_MAX && val < (uint64_t)INT8_MIN )
+return -EOVERFLOW;
+*(uint8_t *)param->par.var = val;
 break;
 case sizeof(uint16_t):
-*(uint16_t *)param->var = val;
+if ( val > UINT16_MAX && val < (uint64_t)INT16_MIN )
+return -EOVERFLOW;
+*(uint16_t *)param->par.var = val;
 break;
 case sizeof(uint32_t):
-*(uint32_t *)param->var = val;
+if ( val > UINT32_MAX && val < (uint64_t)INT32_MIN )
+return -EOVERFLOW;
+*(uint32_t *)param->par.var = val;
 break;
 case sizeof(uint64_t):
-*(uint64_t *)param->var = val;
+*(uint64_t *)param->par.var = val;
 break;
 default:
 BUG();
 }
+
+return 0;
 }
 
 static void __init _cmdline_parse(const char *cmdline)
 {
 char opt[128], *optval, *optkey, *q;
-const char *p = cmdline;
+const char *p = cmdline, *key;
 const struct kernel_param *param;
-int bool_assert;
+int rc;
+bool bool_assert, found;
 
 for ( ; ; )
 {
@@ -84,46 +93,66 @@ static void __init _cmdline_parse(const char *cmdline)
 }
 
 /* Boolean parameters can be inverted with 'no-' prefix. */
+key = optkey;
 bool_assert = !!strncmp("no-", optkey, 3);
 if ( !bool_assert )
 optkey += 3;
 
+rc = 0;
+found = false;
 for ( param = __setup_start; param < __setup_end; param++ )
 {
+int rctmp;
+const char *s;
+
 if ( strcmp(param->name, optkey) )
 {
 if ( param->type == OPT_CUSTOM && q &&
  strlen(param->name) == q + 1 - opt &&
  !strncmp(param->name, opt, q + 1 - opt) )
 {
+found = true;
 optval[-1] = '=';
-((void (*)(const char *))param->var)(q);
+rctmp = param->par.func(q);
 optval[-1] = '\0';
+if ( !rc )
+rc = rctmp;
 }
 continue;
 }
 
+rctmp = 0;
+found = true;
 switch ( param->type )
 {
 case OPT_STR:
-strlcpy(param->var, optval, param->len);
+strlcpy(param->par.var, optval, param->len);
 break;
 case OPT_UINT:
-assign_integer_param(
+rctmp = assign_integer_param(
 param,
-simple_strtoll(optval, NULL, 0));
+simple_strtoll(optval, , 0));
+if ( *s )
+rctmp = -EINVAL;
 break;
 case OPT_BOOL:
-if ( !parse_bool(optval, NULL) )
+rctmp = *optval ? 

[Xen-devel] [PATCH v4 19/53] xen/arch/x86/psr.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/x86/psr.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
---
V4:
- pass end of parameter value to parse_bool()

V3:
- let parse_psr_bool() return bool value (Jan Beulich)
- return error in case no string matches (Jan Beulich)
- dont modify option value in parsing function
---
 xen/arch/x86/psr.c | 56 +++---
 1 file changed, 36 insertions(+), 20 deletions(-)

diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c
index 25a85b65b2..4594461de5 100644
--- a/xen/arch/x86/psr.c
+++ b/xen/arch/x86/psr.c
@@ -418,50 +418,66 @@ static const struct feat_props l2_cat_props = {
 .write_msr = l2_cat_write_msr,
 };
 
-static void __init parse_psr_bool(char *s, char *value, char *feature,
+static bool __init parse_psr_bool(const char *s, const char *value,
+  const char *ss, const char *feature,
   unsigned int mask)
 {
-if ( !strcmp(s, feature) )
+if ( !strncmp(s, feature, value - s) )
 {
-if ( !value )
+if ( !*value )
 opt_psr |= mask;
 else
 {
-int val_int = parse_bool(value, NULL);
+int val_int = parse_bool(value + 1, ss);
 
 if ( val_int == 0 )
 opt_psr &= ~mask;
 else if ( val_int == 1 )
 opt_psr |= mask;
+else
+return false;
 }
+return true;
 }
+return false;
 }
 
-static void __init parse_psr_param(char *s)
+static int __init parse_psr_param(const char *s)
 {
-char *ss, *val_str;
+const char *ss, *val_str;
+const char *q;
+int rc = 0;
 
 do {
 ss = strchr(s, ',');
-if ( ss )
-*ss = '\0';
+if ( !ss )
+ss = strchr(s, '\0');
 
 val_str = strchr(s, ':');
-if ( val_str )
-*val_str++ = '\0';
-
-parse_psr_bool(s, val_str, "cmt", PSR_CMT);
-parse_psr_bool(s, val_str, "cat", PSR_CAT);
-parse_psr_bool(s, val_str, "cdp", PSR_CDP);
+if ( !val_str )
+val_str = strchr(s, '\0');
 
-if ( val_str && !strcmp(s, "rmid_max") )
-opt_rmid_max = simple_strtoul(val_str, NULL, 0);
-
-if ( val_str && !strcmp(s, "cos_max") )
-opt_cos_max = simple_strtoul(val_str, NULL, 0);
+if ( *val_str && !strncmp(s, "rmid_max", val_str - s) )
+{
+opt_rmid_max = simple_strtoul(val_str + 1, , 0);
+if ( *q && *q != ',' )
+rc = -EINVAL;
+}
+else if ( *val_str && !strncmp(s, "cos_max", val_str - s) )
+{
+opt_cos_max = simple_strtoul(val_str + 1, , 0);
+if ( *q && *q != ',' )
+rc = -EINVAL;
+}
+else if ( !parse_psr_bool(s, val_str, ss, "cmt", PSR_CMT) &&
+  !parse_psr_bool(s, val_str, ss, "cat", PSR_CAT) &&
+  !parse_psr_bool(s, val_str, ss, "cdp", PSR_CDP) )
+rc = -EINVAL;
 
 s = ss + 1;
-} while ( ss );
+} while ( *ss );
+
+return rc;
 }
 custom_param("psr", parse_psr_param);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 17/53] xen/arch/x86/numa.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/x86/numa.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
 xen/arch/x86/numa.c | 16 +---
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/xen/arch/x86/numa.c b/xen/arch/x86/numa.c
index ffeba6e180..32914bce27 100644
--- a/xen/arch/x86/numa.c
+++ b/xen/arch/x86/numa.c
@@ -18,7 +18,7 @@
 #include 
 #include 
 
-static int numa_setup(char *s);
+static int numa_setup(const char *s);
 custom_param("numa", numa_setup);
 
 #ifndef Dprintk
@@ -291,14 +291,14 @@ void numa_set_node(int cpu, nodeid_t node)
 }
 
 /* [numa=off] */
-static __init int numa_setup(char *opt) 
-{ 
+static __init int numa_setup(const char *opt)
+{
 if ( !strncmp(opt,"off",3) )
 numa_off = true;
-if ( !strncmp(opt,"on",2) )
+else if ( !strncmp(opt,"on",2) )
 numa_off = false;
 #ifdef CONFIG_NUMA_EMU
-if ( !strncmp(opt, "fake=", 5) )
+else if ( !strncmp(opt, "fake=", 5) )
 {
 numa_off = false;
 numa_fake = simple_strtoul(opt+5,NULL,0);
@@ -307,14 +307,16 @@ static __init int numa_setup(char *opt)
 }
 #endif
 #ifdef CONFIG_ACPI_NUMA
-if ( !strncmp(opt,"noacpi",6) )
+else if ( !strncmp(opt,"noacpi",6) )
 {
 numa_off = false;
 acpi_numa = -1;
 }
 #endif
+else
+return -EINVAL;
 
-return 1;
+return 0;
 } 
 
 /*
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 37/53] xen/drivers/passthrough/vtd/quirks.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/drivers/passthrough/vtd/quirks.c

to indicate whether the parameter value was parsed successfully.

Cc: Kevin Tian 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
---
 xen/drivers/passthrough/vtd/quirks.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/xen/drivers/passthrough/vtd/quirks.c 
b/xen/drivers/passthrough/vtd/quirks.c
index d6dd671dbf..d6db862678 100644
--- a/xen/drivers/passthrough/vtd/quirks.c
+++ b/xen/drivers/passthrough/vtd/quirks.c
@@ -247,9 +247,10 @@ void vtd_ops_postamble_quirk(struct iommu* iommu)
 }
 }
 
-static void __init parse_snb_timeout(const char *s)
+static int __init parse_snb_timeout(const char *s)
 {
 int t;
+const char *q = NULL;
 
 t = parse_bool(s, NULL);
 if ( t < 0 )
@@ -259,13 +260,13 @@ static void __init parse_snb_timeout(const char *s)
 else if ( strcmp(s, "cap") == 0 )
 t = SNB_IGD_TIMEOUT;
 else
-t = strtoul(s, NULL, 0);
+t = strtoul(s, , 0);
 }
 else
 t = t ? SNB_IGD_TIMEOUT_LEGACY : 0;
 snb_igd_timeout = MILLISECS(t);
 
-return;
+return (q && *q) ? -EINVAL : 0;
 }
 custom_param("snb_igd_quirk", parse_snb_timeout);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 32/53] xen/drivers/cpufreq/cpufreq.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/drivers/cpufreq/cpufreq.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich 
Signed-off-by: Juergen Gross 
---
V4:
- add __initdata (Jan Beulich)
- adapt parse_bool() call

V3:
- dont modify option value in handling function
- remove prototype of cpufreq_cmdline_parse() from cpufreq.h and make
  it static
---
 xen/drivers/cpufreq/cpufreq.c  | 39 +-
 xen/include/acpi/cpufreq/cpufreq.h |  2 --
 2 files changed, 26 insertions(+), 15 deletions(-)

diff --git a/xen/drivers/cpufreq/cpufreq.c b/xen/drivers/cpufreq/cpufreq.c
index 5580bd370d..212f48f9f4 100644
--- a/xen/drivers/cpufreq/cpufreq.c
+++ b/xen/drivers/cpufreq/cpufreq.c
@@ -62,37 +62,41 @@ LIST_HEAD_READ_MOSTLY(cpufreq_governor_list);
 /* set xen as default cpufreq */
 enum cpufreq_controller cpufreq_controller = FREQCTL_xen;
 
-static void __init setup_cpufreq_option(char *str)
+static int __init cpufreq_cmdline_parse(const char *s);
+
+static int __init setup_cpufreq_option(const char *str)
 {
-char *arg = strpbrk(str, ",:");
+const char *arg = strpbrk(str, ",:");
 int choice;
 
-if ( arg )
-*arg++ = '\0';
-choice = parse_bool(str, NULL);
+if ( !arg )
+arg = strchr(str, '\0');
+choice = parse_bool(str, arg);
 
-if ( choice < 0 && !strcmp(str, "dom0-kernel") )
+if ( choice < 0 && !strncmp(str, "dom0-kernel", arg - str) )
 {
 xen_processor_pmbits &= ~XEN_PROCESSOR_PM_PX;
 cpufreq_controller = FREQCTL_dom0_kernel;
 opt_dom0_vcpus_pin = 1;
-return;
+return 0;
 }
 
-if ( choice == 0 || !strcmp(str, "none") )
+if ( choice == 0 || !strncmp(str, "none", arg - str) )
 {
 xen_processor_pmbits &= ~XEN_PROCESSOR_PM_PX;
 cpufreq_controller = FREQCTL_none;
-return;
+return 0;
 }
 
-if ( choice > 0 || !strcmp(str, "xen") )
+if ( choice > 0 || !strncmp(str, "xen", arg - str) )
 {
 xen_processor_pmbits |= XEN_PROCESSOR_PM_PX;
 cpufreq_controller = FREQCTL_xen;
-if ( arg && *arg )
-cpufreq_cmdline_parse(arg);
+if ( *arg && *(arg + 1) )
+return cpufreq_cmdline_parse(arg + 1);
 }
+
+return (choice < 0) ? -EINVAL : 0;
 }
 custom_param("cpufreq", setup_cpufreq_option);
 
@@ -571,7 +575,7 @@ static int __init cpufreq_handle_common_option(const char 
*name, const char *val
 return 0;
 }
 
-void __init cpufreq_cmdline_parse(char *str)
+static int __init cpufreq_cmdline_parse(const char *s)
 {
 static struct cpufreq_governor *__initdata cpufreq_governors[] =
 {
@@ -581,8 +585,12 @@ void __init cpufreq_cmdline_parse(char *str)
 _gov_performance,
 _gov_powersave
 };
+static char __initdata buf[128];
+char *str = buf;
 unsigned int gov_index = 0;
+int rc = 0;
 
+strlcpy(buf, s, sizeof(buf));
 do {
 char *val, *end = strchr(str, ',');
 unsigned int i;
@@ -611,11 +619,16 @@ void __init cpufreq_cmdline_parse(char *str)
 if (str && !cpufreq_handle_common_option(str, val) &&
 (!cpufreq_governors[gov_index]->handle_option ||
  !cpufreq_governors[gov_index]->handle_option(str, val)))
+{
 printk(XENLOG_WARNING "cpufreq/%s: option '%s' not recognized\n",
cpufreq_governors[gov_index]->name, str);
+rc = -EINVAL;
+}
 
 str = end;
 } while (str);
+
+return rc;
 }
 
 static int cpu_callback(
diff --git a/xen/include/acpi/cpufreq/cpufreq.h 
b/xen/include/acpi/cpufreq/cpufreq.h
index 48ad1d0004..a5cd7d08a1 100644
--- a/xen/include/acpi/cpufreq/cpufreq.h
+++ b/xen/include/acpi/cpufreq/cpufreq.h
@@ -79,8 +79,6 @@ DECLARE_PER_CPU(struct cpufreq_policy *, cpufreq_cpu_policy);
 extern int __cpufreq_set_policy(struct cpufreq_policy *data,
 struct cpufreq_policy *policy);
 
-void cpufreq_cmdline_parse(char *);
-
 #define CPUFREQ_SHARED_TYPE_NONE (0) /* None */
 #define CPUFREQ_SHARED_TYPE_HW   (1) /* HW does needed coordination */
 #define CPUFREQ_SHARED_TYPE_ALL  (2) /* All dependent CPUs should set freq */
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 53/53] xen: make some console related parameters settable at runtime

2017-08-23 Thread Juergen Gross
Support modifying conswitch, console_timestamps, loglvl and
guest_loglvl at runtime.

Cc: Andrew Cooper 
Cc: George Dunlap 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Konrad Rzeszutek Wilk 
Cc: Stefano Stabellini 
Cc: Tim Deegan 
Cc: Wei Liu 
Signed-off-by: Juergen Gross 
Reviewed-by: Wei Liu 
Reviewed-by: Jan Beulich 
---
V3:
- *_runtime_param() now includes boot parameter setting (Jan Beulich)
---
 docs/misc/xen-command-line.markdown |  8 
 xen/drivers/char/console.c  | 18 +-
 2 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/docs/misc/xen-command-line.markdown 
b/docs/misc/xen-command-line.markdown
index 4002eab08b..9797c8db2d 100644
--- a/docs/misc/xen-command-line.markdown
+++ b/docs/misc/xen-command-line.markdown
@@ -391,6 +391,8 @@ makes sense on its own.
 
 > Default: `none`
 
+> Can be modified at runtime
+
 Specify which timestamp format Xen should use for each console line.
 
 * `none`: No timestamps
@@ -417,6 +419,8 @@ into the console ring buffer.
 
 > Default: `conswitch=a`
 
+> Can be modified at runtime
+
 Specify which character should be used to switch serial input between
 Xen and dom0.  The required sequence is CTRL-switch char three
 times.
@@ -898,6 +902,8 @@ maximum number of maptrack frames domain.
 
 > Default: `guest_loglvl=none/warning`
 
+> Can be modified at runtime
+
 Set the logging level for Xen guests.  Any log message with equal more
 more importance will be printed.
 
@@ -1164,6 +1170,8 @@ if left disabled by the BIOS.
 
 > Default: `loglvl=warning`
 
+> Can be modified at runtime
+
 Set the logging level for Xen.  Any log message with equal more more
 importance will be printed.
 
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 36f94e6b94..19d0e74f17 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -40,7 +40,7 @@ string_param("console", opt_console);
 /* Char 2: If this character is 'x', then do not auto-switch to DOM0 when it */
 /* boots. Any other value, or omitting the char, enables auto-switch */
 static unsigned char __read_mostly opt_conswitch[3] = "a";
-string_param("conswitch", opt_conswitch);
+string_runtime_param("conswitch", opt_conswitch);
 
 /* sync_console: force synchronous console output (useful for debugging). */
 static bool_t __initdata opt_sync_console;
@@ -68,7 +68,7 @@ enum con_timestamp_mode
 static enum con_timestamp_mode __read_mostly opt_con_timestamp_mode = TSM_NONE;
 
 static int parse_console_timestamps(const char *s);
-custom_param("console_timestamps", parse_console_timestamps);
+custom_runtime_param("console_timestamps", parse_console_timestamps);
 
 /* conring_size: allows a large console ring than default (16kB). */
 static uint32_t __initdata opt_conring_size;
@@ -134,8 +134,8 @@ static int parse_guest_loglvl(const char *s);
  * Similar definitions for guest_loglvl, but applies to guest tracing.
  * Defaults: loglvl=warning ; guest_loglvl=none/warning
  */
-custom_param("loglvl", parse_loglvl);
-custom_param("guest_loglvl", parse_guest_loglvl);
+custom_runtime_param("loglvl", parse_loglvl);
+custom_runtime_param("guest_loglvl", parse_guest_loglvl);
 
 static atomic_t print_everything = ATOMIC_INIT(0);
 
@@ -145,7 +145,7 @@ static atomic_t print_everything = ATOMIC_INIT(0);
 return (lvlnum);\
 }
 
-static int __init __parse_loglvl(const char *s, const char **ps)
+static int __parse_loglvl(const char *s, const char **ps)
 {
 ___parse_loglvl(s, ps, "none",0);
 ___parse_loglvl(s, ps, "error",   1);
@@ -156,7 +156,7 @@ static int __init __parse_loglvl(const char *s, const char 
**ps)
 return 2; /* sane fallback */
 }
 
-static int __init _parse_loglvl(const char *s, int *lower, int *upper)
+static int _parse_loglvl(const char *s, int *lower, int *upper)
 {
 *lower = *upper = __parse_loglvl(s, );
 if ( *s == '/' )
@@ -167,12 +167,12 @@ static int __init _parse_loglvl(const char *s, int 
*lower, int *upper)
 return *s ? -EINVAL : 0;
 }
 
-static int __init parse_loglvl(const char *s)
+static int parse_loglvl(const char *s)
 {
 return _parse_loglvl(s, _lower_thresh, _upper_thresh);
 }
 
-static int __init parse_guest_loglvl(const char *s)
+static int parse_guest_loglvl(const char *s)
 {
 return _parse_loglvl(s, _guest_lower_thresh,
  _guest_upper_thresh);
@@ -606,7 +606,7 @@ static int printk_prefix_check(char *p, char **pp)
 ((loglvl < upper_thresh) && printk_ratelimit()));
 } 
 
-static int __init parse_console_timestamps(const char *s)
+static int parse_console_timestamps(const char *s)
 {
 switch ( parse_bool(s, NULL) )
 {
-- 
2.12.3



[Xen-devel] [PATCH v4 47/53] xen: carve out a generic parsing function from _cmdline_parse()

2017-08-23 Thread Juergen Gross
In order to support generic parameter parsing carve out the parser from
_cmdline_parse(). As this generic function might be called after boot
remove the __init annotations from all called sub-functions.

Cc: Andrew Cooper 
Cc: George Dunlap 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Konrad Rzeszutek Wilk 
Cc: Stefano Stabellini 
Cc: Tim Deegan 
Cc: Wei Liu 
Signed-off-by: Juergen Gross 
Reviewed-by: Wei Liu 
Acked-by: Jan Beulich 
---
 xen/common/kernel.c | 25 +++--
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index 063ac99bff..65cd3a92ba 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -23,8 +23,7 @@ enum system_state system_state = SYS_STATE_early_boot;
 xen_commandline_t saved_cmdline;
 static const char __initconst opt_builtin_cmdline[] = CONFIG_CMDLINE;
 
-static int __init assign_integer_param(
-const struct kernel_param *param, uint64_t val)
+static int assign_integer_param(const struct kernel_param *param, uint64_t val)
 {
 switch ( param->len )
 {
@@ -53,12 +52,13 @@ static int __init assign_integer_param(
 return 0;
 }
 
-static void __init _cmdline_parse(const char *cmdline)
+static int parse_params(const char *cmdline, const struct kernel_param *start,
+const struct kernel_param *end)
 {
 char opt[128], *optval, *optkey, *q;
 const char *p = cmdline, *key;
 const struct kernel_param *param;
-int rc;
+int rc, final_rc = 0;
 bool bool_assert, found;
 
 for ( ; ; )
@@ -100,7 +100,7 @@ static void __init _cmdline_parse(const char *cmdline)
 
 rc = 0;
 found = false;
-for ( param = __setup_start; param < __setup_end; param++ )
+for ( param = start; param < end; param++ )
 {
 int rctmp;
 const char *s;
@@ -172,11 +172,24 @@ static void __init _cmdline_parse(const char *cmdline)
 }
 
 if ( rc )
+{
 printk("parameter \"%s\" has invalid value \"%s\", rc=%d!\n",
 key, optval, rc);
+final_rc = rc;
+}
 if ( !found )
+{
 printk("parameter \"%s\" unknown!\n", key);
+final_rc = -EINVAL;
+}
 }
+
+return final_rc;
+}
+
+static void __init _cmdline_parse(const char *cmdline)
+{
+parse_params(cmdline, __setup_start, __setup_end);
 }
 
 /**
@@ -201,7 +214,7 @@ void __init cmdline_parse(const char *cmdline)
 #endif
 }
 
-int __init parse_bool(const char *s, const char *e)
+int parse_bool(const char *s, const char *e)
 {
 unsigned int len;
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 41/53] xen/arch/x86/apic.c: remove custom_param() error messages

2017-08-23 Thread Juergen Gross
With _cmdline_parse() now issuing error messages in case of illegal
parameters signalled by parsing functions specified in custom_param()
the message issued by apic_set_verbosity() can be removed.

Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
Acked-by: Jan Beulich 
---
 xen/arch/x86/apic.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/xen/arch/x86/apic.c b/xen/arch/x86/apic.c
index 325b48074a..2638414e08 100644
--- a/xen/arch/x86/apic.c
+++ b/xen/arch/x86/apic.c
@@ -800,11 +800,8 @@ static int __init apic_set_verbosity(const char *str)
 apic_verbosity = APIC_DEBUG;
 else if (strcmp("verbose", str) == 0)
 apic_verbosity = APIC_VERBOSE;
-else {
-printk(KERN_WARNING "APIC Verbosity level %s not recognised"
-   " use apic_verbosity=verbose or apic_verbosity=debug", str);
+else
 return -EINVAL;
-}
 
 return 0;
 }
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 02/53] xen/arch/arm/acpi/boot.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/arm/acpi/boot.c

to indicate whether the parameter value was parsed successfully.

Cc: Stefano Stabellini 
Cc: Julien Grall 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Julien Grall 
---
 xen/arch/arm/acpi/boot.c | 8 ++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
index a5a6f55f0e..6101bf39c9 100644
--- a/xen/arch/arm/acpi/boot.c
+++ b/xen/arch/arm/acpi/boot.c
@@ -193,16 +193,20 @@ static int __init acpi_parse_fadt(struct 
acpi_table_header *table)
 static bool_t __initdata param_acpi_off;
 static bool_t __initdata param_acpi_force;
 
-static void __init parse_acpi_param(char *arg)
+static int __init parse_acpi_param(const char *arg)
 {
 if ( !arg )
-return;
+return -EINVAL;
 
 /* Interpret the parameter for use within Xen. */
 if ( !parse_bool(arg, NULL) )
 param_acpi_off = true;
 else if ( !strcmp(arg, "force") ) /* force ACPI to be enabled */
 param_acpi_force = true;
+else
+return -EINVAL;
+
+return 0;
 }
 custom_param("acpi", parse_acpi_param);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 03/53] xen/arch/arm/domain_build.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/arm/domain_build.c

to indicate whether the parameter value was parsed successfully.

Cc: Stefano Stabellini 
Cc: Julien Grall 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Julien Grall 
---
 xen/arch/arm/domain_build.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index 1bec4fa23d..d6f9585503 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -33,9 +33,11 @@ int dom0_11_mapping = 1;
 
 static u64 __initdata dom0_mem;
 
-static void __init parse_dom0_mem(const char *s)
+static int __init parse_dom0_mem(const char *s)
 {
 dom0_mem = parse_size_and_unit(s, );
+
+return *s ? -EINVAL : 0;
 }
 custom_param("dom0_mem", parse_dom0_mem);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 00/53] Support for modifying parameters at runtime

2017-08-23 Thread Juergen Gross
Currently parameters of the hypervisor (e.g. console log level) can be
set via boot command line. Instead of having to reboot the system in
case another setting is desired, being able to modify many of those
parameters at runtime would be the better option.

This patch series addresses this by adding a new xl command
"xl set-parameters" which takes a string similar to the boot command
line as parameter and passes this string to the hypervisor which will
then use the same parsing infrastructure as for the command line in
order to apply the parameter settings.

As error checks for invalid parameters or parameter values have been
very sparse if present at all in the hypervisor, a major part of this
patch series addresses this problem first: all custom parameter parsing
functions are being changed to return success or an error. The main
parsing function tests for generic parameter value errors (like e.g.
overflow) or invalid parameters and issues a message in case an error
has been detected. Most error messages in the custom parsing functions
are removed then.

While not strictly required for runtime parameter modification I
believe an improved parameter validation is a win with or without the
runtime parameter modification support.

* Patch 1 prepares the following patches by adding an end pointer to
  parse_bool()
* Patches 2-39 are modifying the custom parameter parsing functions to
  return success or error
* Patch 40 adds generic parameter error tests in the core parameter
  parsing functions
* Patches 41-46 remove custom parsing function error messages
* Patches 47-52 add the runtime parameter modification support
* Patch 53 adds support for runtime modification of some console related
  parameters 

Changes in V4:
- added new patch 01
- patches 19, 23, 32, 34: pass end of parameter value to parse_bool()
(Jan Beulich)
- patch 21: issue a message in case of reboot=efi and no EFI runtime services
(Jan Beulich)
- patch 23: style correction (Jan Beulich)
- patch 32: add __initdata (Jan Beulich)
- patch 35: differentiate error return values (Jan Beulich)
- patch 35: drop pointless test for input parameter being NULL (Jan Beulich)
- patch 40: removed test for empty string from parse_bool() again, avoid
calling parse_bool() in that case (Jan Beulich)
- patch 40: print error number in failure case (Jan Beulich)
- patch 40: limit scope of some variables (Jan Beulich)
- patch 40: use type bool for bool_assert (Jan Beulich)
- patch 49: use copy_from_guest() (Jan Beulich)
- patch 49: add more descriptive comment to sysctl.h (Jan Beulich)

Changes in V3:
- patches 7, 14, 15, 24, 27, 34: cosmetic changes (Jan Beulich)
- patches 7, 9, 10, 18, 22, 25, 31, 33, 34: dont modify option value in
parsing function
- patches 8, 22, 25: dont return out of loop (Jan Beulich)
- patch 9: fix error in parsing routine
- patch 18: let parse_psr_bool() return bool value (Jan Beulich)
- patch 18: return error in case no string matches (Jan Beulich)
- patch 20: dont stop loop at first invalid character (Jan Beulich)
- patch 31: remove prototype of cpufreq_cmdline_parse() from cpufreq.h
and make it static
- patch 39: use function pointer in struct kernel_param (Jan Beulich)
- patch 39: better range check in assign_integer_param() (Jan Beulich)
- patch 39: dont assign int values in case of overflow (Jan Beulich)
- patch 39: allow multiple handlers for a parameter (Jan Beulich)
- patch 47: moved runtime parameter array in linker scripts (Jan Beulich)
- patch 47: renamed macros to *_runtime_param() (Jan Beulich)
- patch 47: added *runtime_only_param() macros (Jan Beulich)
- patch 47: let *_runtime_param() macros include boot param functionality
(Jan Beulich)
- patch 48: check pad[] to be zero (Jan Beulich)
- patch 48: return E2BIG in case of parameters too long (Jan Beulich)
- patch 48: move max. parameter size define to sysctl.c (Jan Beulich)
- patch 49: zero padding fields in sysctl.u.set_parameter
- patch 50: use LOGEV() for error message
- patch 52: *_runtime_param() now includes boot parameter setting
(Jan Beulich)

Changes in V2:
- patch 39 (xen: check parameter validity when parsing command line):
  replaced literal 8 by BITS_PER_BYTE (Wei Liu)
  added test for empty string to parse_bool()
- patch 47 (xen: add basic support for runtime parameter changing):
  added modification of ARM linker script (Wei Liu)
- patch 48 (xen: add hypercall for setting parameters at runtime):
  corrected XSM test (Daniel De Graaf)
- patch 50 (libxl: add libxl_set_parameters() function):
  corrected coding style (Wei Liu)


Juergen Gross (53):
  xen: add an optional string end parameter to parse_bool()
  xen/arch/arm/acpi/boot.c: let custom parameter parsing routines return
errno
  xen/arch/arm/domain_build.c: let custom parameter parsing routines
return errno
  xen/arch/arm/traps.c: let custom parameter parsing routines return
errno
  xen/arch/x86/apic.c: let custom parameter parsing routines return
errno
  

[Xen-devel] [PATCH v4 15/53] xen/arch/x86/mm.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/x86/mm.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
V3:
- cosmetic changes (Jan Beulich)
---
 xen/arch/x86/mm.c | 8 +++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index 5b0e55d7d9..3052cb0788 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -179,14 +179,20 @@ static uint32_t base_disallow_mask;
  L1_DISALLOW_MASK : (L1_DISALLOW_MASK & ~PAGE_CACHE_ATTRS))
 
 static s8 __read_mostly opt_mmio_relax;
-static void __init parse_mmio_relax(const char *s)
+
+static int __init parse_mmio_relax(const char *s)
 {
 if ( !*s )
 opt_mmio_relax = 1;
 else
 opt_mmio_relax = parse_bool(s, NULL);
 if ( opt_mmio_relax < 0 && strcmp(s, "all") )
+{
 opt_mmio_relax = 0;
+return -EINVAL;
+}
+
+return 0;
 }
 custom_param("mmio-relax", parse_mmio_relax);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 22/53] xen/arch/x86/time.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/x86/time.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
 xen/arch/x86/time.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
index b988b94d2e..eba7aed72d 100644
--- a/xen/arch/x86/time.c
+++ b/xen/arch/x86/time.c
@@ -1870,7 +1870,7 @@ int hwdom_pit_access(struct ioreq *ioreq)
  * tsc=skewed: Assume TSCs are individually reliable, but skewed across CPUs.
  * tsc=stable:socket: Assume TSCs are reliable across sockets.
  */
-static void __init tsc_parse(const char *s)
+static int __init tsc_parse(const char *s)
 {
 if ( !strcmp(s, "unstable") )
 {
@@ -1882,6 +1882,10 @@ static void __init tsc_parse(const char *s)
 setup_clear_cpu_cap(X86_FEATURE_TSC_RELIABLE);
 else if ( !strcmp(s, "stable:socket") )
 tsc_flags |= TSC_RELIABLE_SOCKET;
+else
+return -EINVAL;
+
+return 0;
 }
 custom_param("tsc", tsc_parse);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 44/53] xen/arch/x86/io_apic.c: remove custom_param() error messages

2017-08-23 Thread Juergen Gross
With _cmdline_parse() now issuing error messages in case of illegal
parameters signalled by parsing functions specified in custom_param()
the message issued by setup_ioapic_ack() can be removed.

Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
Acked-by: Jan Beulich 
---
 xen/arch/x86/io_apic.c | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c
index f767c4560c..f959090ca0 100644
--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -1594,10 +1594,7 @@ static int __init setup_ioapic_ack(const char *s)
 ioapic_ack_forced = true;
 }
 else
-{
-printk("Unknown ioapic_ack value specified: '%s'\n", s);
 return -EINVAL;
-}
 
 return 0;
 }
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 52/53] xl: add new xl command set-parameters

2017-08-23 Thread Juergen Gross
Add a new xl command "set-parameters" to set hypervisor parameters at
runtime similar to boot time parameters via command line.

Cc: Ian Jackson 
Cc: Wei Liu 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
---
 docs/man/xl.pod.1.in   |  5 +
 tools/xl/xl.h  |  1 +
 tools/xl/xl_cmdtable.c |  5 +
 tools/xl/xl_misc.c | 20 
 4 files changed, 31 insertions(+)

diff --git a/docs/man/xl.pod.1.in b/docs/man/xl.pod.1.in
index 16c83066fe..3d5f2f7359 100644
--- a/docs/man/xl.pod.1.in
+++ b/docs/man/xl.pod.1.in
@@ -822,6 +822,11 @@ Pass the VNC password to vncviewer via stdin.
 Send debug I to Xen. It is the same as pressing the Xen
 "conswitch" (Ctrl-A by default) three times and then pressing "keys".
 
+=item B I
+
+Set hypervisor parameters as specified in I. This allows for some
+boot parameters of the hypervisor to be modified in the running systems.
+
 =item B [I]
 
 Reads the Xen message buffer, similar to dmesg on a Linux system.  The
diff --git a/tools/xl/xl.h b/tools/xl/xl.h
index aa95b77146..5d3d2a4835 100644
--- a/tools/xl/xl.h
+++ b/tools/xl/xl.h
@@ -154,6 +154,7 @@ int main_rename(int argc, char **argv);
 int main_trigger(int argc, char **argv);
 int main_sysrq(int argc, char **argv);
 int main_debug_keys(int argc, char **argv);
+int main_set_parameters(int argc, char **argv);
 int main_dmesg(int argc, char **argv);
 int main_top(int argc, char **argv);
 int main_networkattach(int argc, char **argv);
diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index 2c71a9f776..ba0159df67 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -309,6 +309,11 @@ struct cmd_spec cmd_table[] = {
   "Send debug keys to Xen",
   "",
 },
+{ "set-parameters",
+  _set_parameters, 0, 1,
+  "Set hypervisor parameters",
+  "",
+},
 { "dmesg",
   _dmesg, 0, 0,
   "Read and/or clear dmesg buffer",
diff --git a/tools/xl/xl_misc.c b/tools/xl/xl_misc.c
index 9c6227af23..dcf940a6d4 100644
--- a/tools/xl/xl_misc.c
+++ b/tools/xl/xl_misc.c
@@ -155,6 +155,26 @@ int main_debug_keys(int argc, char **argv)
 return EXIT_SUCCESS;
 }
 
+int main_set_parameters(int argc, char **argv)
+{
+int opt;
+char *params;
+
+SWITCH_FOREACH_OPT(opt, "", NULL, "set-parameters", 1) {
+/* No options */
+}
+
+params = argv[optind];
+
+if (libxl_set_parameters(ctx, params)) {
+fprintf(stderr, "cannot set parameters: %s\n", params);
+fprintf(stderr, "Use \"xl dmesg\" to look for possible reason.\n");
+return EXIT_FAILURE;
+}
+
+return EXIT_SUCCESS;
+}
+
 int main_devd(int argc, char **argv)
 {
 int ret = 0, opt = 0, daemonize = 1;
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 25/53] xen/common/domain.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/common/domain.c

to indicate whether the parameter value was parsed successfully.

Cc: Andrew Cooper 
Cc: George Dunlap 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Konrad Rzeszutek Wilk 
Cc: Stefano Stabellini 
Cc: Tim Deegan 
Cc: Wei Liu 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
V3:
- cosmetic changes (Jan Beulich)
---
 xen/common/domain.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/xen/common/domain.c b/xen/common/domain.c
index b22aacc57e..acd420a1a5 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -245,12 +245,15 @@ static int late_hwdom_init(struct domain *d)
 
 static unsigned int __read_mostly extra_hwdom_irqs;
 static unsigned int __read_mostly extra_domU_irqs = 32;
-static void __init parse_extra_guest_irqs(const char *s)
+
+static int __init parse_extra_guest_irqs(const char *s)
 {
 if ( isdigit(*s) )
 extra_domU_irqs = simple_strtoul(s, , 0);
 if ( *s == ',' && isdigit(*++s) )
 extra_hwdom_irqs = simple_strtoul(s, , 0);
+
+return *s ? -EINVAL : 0;
 }
 custom_param("extra_guest_irqs", parse_extra_guest_irqs);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 04/53] xen/arch/arm/traps.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/arm/traps.c

to indicate whether the parameter value was parsed successfully.

Cc: Stefano Stabellini 
Cc: Julien Grall 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Julien Grall 
---
 xen/arch/arm/traps.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
index 2e92223c2f..aa838e8e77 100644
--- a/xen/arch/arm/traps.c
+++ b/xen/arch/arm/traps.c
@@ -108,12 +108,14 @@ static enum {
NATIVE,
 } vwfi;
 
-static void __init parse_vwfi(const char *s)
+static int __init parse_vwfi(const char *s)
 {
if ( !strcmp(s, "native") )
vwfi = NATIVE;
else
vwfi = TRAP;
+
+   return 0;
 }
 custom_param("vwfi", parse_vwfi);
 
@@ -130,7 +132,7 @@ static enum {
 SERRORS_PANIC,
 } serrors_op;
 
-static void __init parse_serrors_behavior(const char *str)
+static int __init parse_serrors_behavior(const char *str)
 {
 if ( !strcmp(str, "forward") )
 serrors_op = SERRORS_FORWARD;
@@ -139,7 +141,7 @@ static void __init parse_serrors_behavior(const char *str)
 else
 serrors_op = SERRORS_DIVERSE;
 
-return;
+return 0;
 }
 custom_param("serrors", parse_serrors_behavior);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 18/53] xen/arch/x86/oprofile/nmi_int.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/x86/oprofile/nmi_int.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
 xen/arch/x86/oprofile/nmi_int.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/arch/x86/oprofile/nmi_int.c b/xen/arch/x86/oprofile/nmi_int.c
index 126f7a8d9f..84ba108fdb 100644
--- a/xen/arch/x86/oprofile/nmi_int.c
+++ b/xen/arch/x86/oprofile/nmi_int.c
@@ -323,12 +323,15 @@ static int __init p4_init(char ** cpu_type)
 
 
 static int force_arch_perfmon;
+
 static int force_cpu_type(const char *str)
 {
if (!strcmp(str, "arch_perfmon")) {
force_arch_perfmon = 1;
printk(KERN_INFO "oprofile: forcing architectural perfmon\n");
}
+   else
+   return -EINVAL;
 
return 0;
 }
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 12/53] xen/arch/x86/io_apic.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/x86/io_apic.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
 xen/arch/x86/io_apic.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c
index 2838f6bd99..f767c4560c 100644
--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -1581,7 +1581,7 @@ static unsigned int startup_level_ioapic_irq(struct 
irq_desc *desc)
 return 0; /* don't check for pending */
 }
 
-static void __init setup_ioapic_ack(char *s)
+static int __init setup_ioapic_ack(const char *s)
 {
 if ( !strcmp(s, "old") )
 {
@@ -1594,7 +1594,12 @@ static void __init setup_ioapic_ack(char *s)
 ioapic_ack_forced = true;
 }
 else
+{
 printk("Unknown ioapic_ack value specified: '%s'\n", s);
+return -EINVAL;
+}
+
+return 0;
 }
 custom_param("ioapic_ack", setup_ioapic_ack);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 46/53] xen/common/sched_credit2.c: remove custom_param() error messages

2017-08-23 Thread Juergen Gross
With _cmdline_parse() now issuing error messages in case of illegal
parameters signalled by parsing functions specified in custom_param()
the message issued by parse_credit2_runqueue() can be removed.

Cc: George Dunlap 
Cc: Dario Faggioli 
Signed-off-by: Juergen Gross 
Acked-by: Dario Faggioli 
---
 xen/common/sched_credit2.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c
index 9b1db1351f..2da9cc2ffb 100644
--- a/xen/common/sched_credit2.c
+++ b/xen/common/sched_credit2.c
@@ -352,8 +352,6 @@ static int parse_credit2_runqueue(const char *s)
 }
 }
 
-printk("WARNING, unrecognized value of credit2_runqueue option!\n");
-
 return -EINVAL;
 }
 custom_param("credit2_runqueue", parse_credit2_runqueue);
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 48/53] xen: add basic support for runtime parameter changing

2017-08-23 Thread Juergen Gross
Add the needed infrastructure for runtime parameter changing similar
to that used at boot time via cmdline. We are using the same parsing
functions as for cmdline parsing, but with a different array of
parameter definitions.

Cc: Andrew Cooper 
Cc: George Dunlap 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Konrad Rzeszutek Wilk 
Cc: Stefano Stabellini 
Cc: Tim Deegan 
Cc: Wei Liu 
Signed-off-by: Juergen Gross 
Reviewed-by: Jan Beulich 
---
V2:
- added modification of ARM linker script (Wei Liu)

V3:
- moved runtime parameter array in linker scripts (Jan Beulich)
- renamed macros to *_runtime_param() (Jan Beulich)
- added *runtime_only_param() macros (Jan Beulich)
- let *_runtime_param() macros include boot param functionality
  (Jan Beulich)
---
 xen/arch/arm/xen.lds.S |  4 
 xen/arch/x86/xen.lds.S |  4 
 xen/common/kernel.c|  5 +
 xen/include/xen/init.h | 57 --
 xen/include/xen/lib.h  |  1 +
 5 files changed, 69 insertions(+), 2 deletions(-)

diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index 2d54f224ec..c9b9546435 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -61,6 +61,10 @@ SECTIONS
*(.lockprofile.data)
__lock_profile_end = .;
 #endif
+   . = ALIGN(POINTER_ALIGN);
+   __param_start = .;
+   *(.data.param)
+   __param_end = .;
   } :text
 
 #if defined(BUILD_ID)
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index ff08bbe42a..6a7bbb8ca1 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -120,6 +120,10 @@ SECTIONS
*(.lockprofile.data)
__lock_profile_end = .;
 #endif
+   . = ALIGN(POINTER_ALIGN);
+   __param_start = .;
+   *(.data.param)
+   __param_end = .;
   } :text
 
 #if defined(BUILD_ID)
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index 65cd3a92ba..da1a709146 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -192,6 +192,11 @@ static void __init _cmdline_parse(const char *cmdline)
 parse_params(cmdline, __setup_start, __setup_end);
 }
 
+int runtime_parse(const char *line)
+{
+return parse_params(line, __param_start, __param_end);
+}
+
 /**
  *cmdline_parse -- parses the xen command line.
  * If CONFIG_CMDLINE is set, it would be parsed prior to @cmdline.
diff --git a/xen/include/xen/init.h b/xen/include/xen/init.h
index 234ec25aae..db06c76fdf 100644
--- a/xen/include/xen/init.h
+++ b/xen/include/xen/init.h
@@ -90,11 +90,16 @@ struct kernel_param {
 };
 
 extern const struct kernel_param __setup_start[], __setup_end[];
+extern const struct kernel_param __param_start[], __param_end[];
+
+#define __dataparam   __used_section(".data.param")
+
+#define __param(att)  static const att \
+__attribute__((__aligned__(sizeof(void * struct kernel_param
 
 #define __setup_str static const __initconst \
 __attribute__((__aligned__(1))) char
-#define __kparam static const __initsetup \
-__attribute__((__aligned__(sizeof(void * struct kernel_param
+#define __kparam  __param(__initsetup)
 
 #define custom_param(_name, _var) \
 __setup_str __setup_str_##_var[] = _name; \
@@ -131,6 +136,54 @@ extern const struct kernel_param __setup_start[], 
__setup_end[];
   .len = sizeof(_var), \
   .par.var = &_var }
 
+#define __rtparam __param(__dataparam)
+
+#define custom_runtime_only_param(_name, _var) \
+__rtparam __rtpar_##_var = \
+  { .name = _name, \
+  .type = OPT_CUSTOM, \
+  .par.func = _var }
+#define boolean_runtime_only_param(_name, _var) \
+__rtparam __rtpar_##_var = \
+{ .name = _name, \
+  .type = OPT_BOOL, \
+  .len = sizeof(_var), \
+  .par.var = &_var }
+#define integer_runtime_only_param(_name, _var) \
+__rtparam __rtpar_##_var = \
+{ .name = _name, \
+  .type = OPT_UINT, \
+  .len = sizeof(_var), \
+  .par.var = &_var }
+#define size_runtime_only_param(_name, _var) \
+__rtparam __rtpar_##_var = \
+{ .name = _name, \
+  .type = OPT_SIZE, \
+  .len = sizeof(_var), \
+  .par.var = &_var }
+#define string_runtime_only_param(_name, _var) \
+__rtparam __rtpar_##_var = \
+{ .name = _name, \
+  .type = OPT_STR, \
+  .len = sizeof(_var), \
+  .par.var = &_var }
+
+#define custom_runtime_param(_name, _var) \
+custom_param(_name, _var); \
+custom_runtime_only_param(_name, _var)
+#define boolean_runtime_param(_name, _var) \
+boolean_param(_name, _var); \
+boolean_runtime_only_param(_name, _var)
+#define integer_runtime_param(_name, _var) \
+integer_param(_name, _var); \
+integer_runtime_only_param(_name, _var)
+#define 

[Xen-devel] [PATCH v4 16/53] xen/arch/x86/nmi.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/x86/nmi.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
V3:
- cosmetic changes (Jan Beulich)
---
 xen/arch/x86/nmi.c | 21 +++--
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c
index e44f88045e..d7fce28805 100644
--- a/xen/arch/x86/nmi.c
+++ b/xen/arch/x86/nmi.c
@@ -46,35 +46,44 @@ bool __initdata opt_watchdog;
 /* watchdog_force: If true, process unknown NMIs when running the watchdog. */
 bool watchdog_force;
 
-static void __init parse_watchdog(char *s)
+static int __init parse_watchdog(const char *s)
 {
 if ( !*s )
 {
 opt_watchdog = true;
-return;
+return 0;
 }
 
 switch ( parse_bool(s, NULL) )
 {
 case 0:
 opt_watchdog = false;
-return;
+return 0;
 case 1:
 opt_watchdog = true;
-return;
+return 0;
 }
 
 if ( !strcmp(s, "force") )
 watchdog_force = opt_watchdog = true;
+else
+return -EINVAL;
+
+return 0;
 }
 custom_param("watchdog", parse_watchdog);
 
 /* opt_watchdog_timeout: Number of seconds to wait before panic. */
 static unsigned int opt_watchdog_timeout = 5;
-static void parse_watchdog_timeout(char * s)
+
+static int parse_watchdog_timeout(const char *s)
 {
-opt_watchdog_timeout = simple_strtoull(s, NULL, 0);
+const char *q;
+
+opt_watchdog_timeout = simple_strtoull(s, , 0);
 opt_watchdog = !!opt_watchdog_timeout;
+
+return *q ? -EINVAL : 0;
 }
 custom_param("watchdog_timeout", parse_watchdog_timeout);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 50/53] libxc: add function to set hypervisor parameters

2017-08-23 Thread Juergen Gross
Add a new libxc function to set hypervisor parameters at runtime
similar to boot time parameters via command line.

Cc: Ian Jackson 
Cc: Wei Liu 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
---
V3:
- zero padding fields in sysctl.u.set_parameter
---
 tools/libxc/include/xenctrl.h |  1 +
 tools/libxc/xc_misc.c | 21 +
 2 files changed, 22 insertions(+)

diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h
index c7710b8f36..ad5e6b3d77 100644
--- a/tools/libxc/include/xenctrl.h
+++ b/tools/libxc/include/xenctrl.h
@@ -1210,6 +1210,7 @@ int xc_readconsolering(xc_interface *xch,
int clear, int incremental, uint32_t *pindex);
 
 int xc_send_debug_keys(xc_interface *xch, char *keys);
+int xc_set_parameters(xc_interface *xch, char *params);
 
 typedef xen_sysctl_physinfo_t xc_physinfo_t;
 typedef xen_sysctl_cputopo_t xc_cputopo_t;
diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c
index 2303293c6c..7e15e904e3 100644
--- a/tools/libxc/xc_misc.c
+++ b/tools/libxc/xc_misc.c
@@ -187,6 +187,27 @@ int xc_send_debug_keys(xc_interface *xch, char *keys)
 return ret;
 }
 
+int xc_set_parameters(xc_interface *xch, char *params)
+{
+int ret, len = strlen(params);
+DECLARE_SYSCTL;
+DECLARE_HYPERCALL_BOUNCE(params, len, XC_HYPERCALL_BUFFER_BOUNCE_IN);
+
+if ( xc_hypercall_bounce_pre(xch, params) )
+return -1;
+
+sysctl.cmd = XEN_SYSCTL_set_parameter;
+set_xen_guest_handle(sysctl.u.set_parameter.params, params);
+sysctl.u.set_parameter.size = len;
+memset(sysctl.u.set_parameter.pad, 0, sizeof(sysctl.u.set_parameter.pad));
+
+ret = do_sysctl(xch, );
+
+xc_hypercall_bounce_post(xch, params);
+
+return ret;
+}
+
 int xc_physinfo(xc_interface *xch,
 xc_physinfo_t *put_info)
 {
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 06/53] xen/arch/x86/cpu/mcheck/mce.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/x86/cpu/mcheck/mce.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
 xen/arch/x86/cpu/mcheck/mce.c | 7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c
index 30525dd78b..8015dff8c4 100644
--- a/xen/arch/x86/cpu/mcheck/mce.c
+++ b/xen/arch/x86/cpu/mcheck/mce.c
@@ -62,13 +62,18 @@ struct mca_banks *mca_allbanks;
 #endif
 
 int mce_verbosity;
-static void __init mce_set_verbosity(char *str)
+static int __init mce_set_verbosity(const char *str)
 {
 if (strcmp("verbose", str) == 0)
 mce_verbosity = MCE_VERBOSE;
 else
+{
 printk(KERN_DEBUG "Machine Check verbosity level %s not recognised"
"use mce_verbosity=verbose", str);
+return -EINVAL;
+}
+
+return 0;
 }
 custom_param("mce_verbosity", mce_set_verbosity);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 43/53] xen/arch/x86/hvm/viridian.c: remove custom_param() error messages

2017-08-23 Thread Juergen Gross
With _cmdline_parse() now issuing error messages in case of illegal
parameters signalled by parsing functions specified in custom_param()
the message issued by parse_viridian_version() can be removed.

Cc: Paul Durrant 
Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
Reviewed-by: Paul Durrant 
---
 xen/arch/x86/hvm/viridian.c | 10 +++---
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/xen/arch/x86/hvm/viridian.c b/xen/arch/x86/hvm/viridian.c
index 2edf9d0b23..e0546f32fc 100644
--- a/xen/arch/x86/hvm/viridian.c
+++ b/xen/arch/x86/hvm/viridian.c
@@ -1104,7 +1104,7 @@ static int __init parse_viridian_version(const char *arg)
 {
 n[i] = simple_strtoul(arg, , 0);
 if ( e != t )
-goto fail;
+break;
 }
 
 i++;
@@ -1112,12 +1112,12 @@ static int __init parse_viridian_version(const char 
*arg)
 } while ( *t );
 
 if ( i != 3 )
-goto fail;
+return -EINVAL;
 
 if ( ((typeof(viridian_major))n[0] != n[0]) ||
  ((typeof(viridian_minor))n[1] != n[1]) ||
  ((typeof(viridian_build))n[2] != n[2]) )
-goto fail;
+return -EINVAL;
 
 viridian_major = n[0];
 viridian_minor = n[1];
@@ -1126,10 +1126,6 @@ static int __init parse_viridian_version(const char *arg)
 printk("viridian-version = %#x,%#x,%#x\n",
viridian_major, viridian_minor, viridian_build);
 return 0;
-
- fail:
-printk(XENLOG_WARNING "Invalid viridian-version, using default\n");
-return -EINVAL;
 }
 custom_param("viridian-version", parse_viridian_version);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 30/53] xen/drivers/acpi/tables.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/drivers/acpi/tables.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
 xen/drivers/acpi/tables.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/xen/drivers/acpi/tables.c b/xen/drivers/acpi/tables.c
index dd2031f36a..b890b73901 100644
--- a/xen/drivers/acpi/tables.c
+++ b/xen/drivers/acpi/tables.c
@@ -456,14 +456,15 @@ int __init acpi_table_init(void)
return 0;
 }
 
-static int __init acpi_parse_apic_instance(char *str)
+static int __init acpi_parse_apic_instance(const char *str)
 {
+   const char *q;
 
-   acpi_apic_instance = simple_strtoul(str, NULL, 0);
+   acpi_apic_instance = simple_strtoul(str, , 0);
 
printk(KERN_NOTICE PREFIX "Shall use APIC/MADT table %d\n",
   acpi_apic_instance);
 
-   return 0;
+   return *q ? -EINVAL : 0;
 }
 custom_param("acpi_apic_instance", acpi_parse_apic_instance);
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 28/53] xen/common/memory.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/common/memory.c

to indicate whether the parameter value was parsed successfully.

Cc: Andrew Cooper 
Cc: George Dunlap 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Konrad Rzeszutek Wilk 
Cc: Stefano Stabellini 
Cc: Tim Deegan 
Cc: Wei Liu 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
V3:
- cosmetic changes (Jan Beulich)
---
 xen/common/memory.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/xen/common/memory.c b/xen/common/memory.c
index b2066db07e..26da6050f6 100644
--- a/xen/common/memory.c
+++ b/xen/common/memory.c
@@ -55,7 +55,8 @@ static unsigned int __read_mostly hwdom_max_order = 
CONFIG_HWDOM_MAX_ORDER;
 #ifdef HAS_PASSTHROUGH
 static unsigned int __read_mostly ptdom_max_order = CONFIG_PTDOM_MAX_ORDER;
 #endif
-static void __init parse_max_order(const char *s)
+
+static int __init parse_max_order(const char *s)
 {
 if ( *s != ',' )
 domu_max_order = simple_strtoul(s, , 0);
@@ -67,6 +68,8 @@ static void __init parse_max_order(const char *s)
 if ( *s == ',' && *++s != ',' )
 ptdom_max_order = simple_strtoul(s, , 0);
 #endif
+
+return *s ? -EINVAL : 0;
 }
 custom_param("memop-max-order", parse_max_order);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 29/53] xen/common/sched_credit2.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/common/sched_credit2.c

to indicate whether the parameter value was parsed successfully.

Cc: George Dunlap 
Cc: Dario Faggioli 
Signed-off-by: Juergen Gross 
Acked-by: Dario Faggioli 
Acked-by: Wei Liu 
---
 xen/common/sched_credit2.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/xen/common/sched_credit2.c b/xen/common/sched_credit2.c
index 29c002a63e..9b1db1351f 100644
--- a/xen/common/sched_credit2.c
+++ b/xen/common/sched_credit2.c
@@ -339,7 +339,7 @@ static const char *const opt_runqueue_str[] = {
 };
 static int __read_mostly opt_runqueue = OPT_RUNQUEUE_SOCKET;
 
-static void parse_credit2_runqueue(const char *s)
+static int parse_credit2_runqueue(const char *s)
 {
 unsigned int i;
 
@@ -348,11 +348,13 @@ static void parse_credit2_runqueue(const char *s)
 if ( !strcmp(s, opt_runqueue_str[i]) )
 {
 opt_runqueue = i;
-return;
+return 0;
 }
 }
 
 printk("WARNING, unrecognized value of credit2_runqueue option!\n");
+
+return -EINVAL;
 }
 custom_param("credit2_runqueue", parse_credit2_runqueue);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 34/53] xen/drivers/passthrough/iommu.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/drivers/passthrough/iommu.c

to indicate whether the parameter value was parsed successfully.

This at once fixes a potential problem with multiple iommu=...
parameters: before the change iommu=no iommu=yes would switch iommu
off.

Cc: Jan Beulich 
Signed-off-by: Juergen Gross 
---
V4:
- adapt parse_bool() call (Jan Beulich)

V3:
- dont modify option value in parsing function
---
 xen/drivers/passthrough/iommu.c | 52 +++--
 1 file changed, 29 insertions(+), 23 deletions(-)

diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index f1aefc47ce..1aecf7cf34 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -21,7 +21,7 @@
 #include 
 #include 
 
-static void parse_iommu_param(char *s);
+static int parse_iommu_param(const char *s);
 static void iommu_dump_p2m_table(unsigned char key);
 
 unsigned int __read_mostly iommu_dev_iotlb_timeout = 1000;
@@ -78,10 +78,10 @@ DEFINE_SPINLOCK(iommu_pt_cleanup_lock);
 PAGE_LIST_HEAD(iommu_pt_cleanup_list);
 static struct tasklet iommu_pt_cleanup_tasklet;
 
-static void __init parse_iommu_param(char *s)
+static int __init parse_iommu_param(const char *s)
 {
-char *ss;
-int val;
+const char *ss;
+int val, b, rc = 0;
 
 do {
 val = !!strncmp(s, "no-", 3);
@@ -89,44 +89,50 @@ static void __init parse_iommu_param(char *s)
 s += 3;
 
 ss = strchr(s, ',');
-if ( ss )
-*ss = '\0';
-
-if ( !parse_bool(s, NULL) )
-iommu_enable = 0;
-else if ( !strcmp(s, "force") || !strcmp(s, "required") )
+if ( !ss )
+ss = strchr(s, '\0');
+
+b = parse_bool(s, ss);
+if ( b >= 0 )
+iommu_enable = b;
+else if ( !strncmp(s, "force", ss - s) ||
+  !strncmp(s, "required", ss - s) )
 force_iommu = val;
-else if ( !strcmp(s, "workaround_bios_bug") )
+else if ( !strncmp(s, "workaround_bios_bug", ss - s) )
 iommu_workaround_bios_bug = val;
-else if ( !strcmp(s, "igfx") )
+else if ( !strncmp(s, "igfx", ss - s) )
 iommu_igfx = val;
-else if ( !strcmp(s, "verbose") )
+else if ( !strncmp(s, "verbose", ss - s) )
 iommu_verbose = val;
-else if ( !strcmp(s, "snoop") )
+else if ( !strncmp(s, "snoop", ss - s) )
 iommu_snoop = val;
-else if ( !strcmp(s, "qinval") )
+else if ( !strncmp(s, "qinval", ss - s) )
 iommu_qinval = val;
-else if ( !strcmp(s, "intremap") )
+else if ( !strncmp(s, "intremap", ss - s) )
 iommu_intremap = val;
-else if ( !strcmp(s, "intpost") )
+else if ( !strncmp(s, "intpost", ss - s) )
 iommu_intpost = val;
-else if ( !strcmp(s, "debug") )
+else if ( !strncmp(s, "debug", ss - s) )
 {
 iommu_debug = val;
 if ( val )
 iommu_verbose = 1;
 }
-else if ( !strcmp(s, "amd-iommu-perdev-intremap") )
+else if ( !strncmp(s, "amd-iommu-perdev-intremap", ss - s) )
 amd_iommu_perdev_intremap = val;
-else if ( !strcmp(s, "dom0-passthrough") )
+else if ( !strncmp(s, "dom0-passthrough", ss - s) )
 iommu_passthrough = val;
-else if ( !strcmp(s, "dom0-strict") )
+else if ( !strncmp(s, "dom0-strict", ss - s) )
 iommu_dom0_strict = val;
-else if ( !strcmp(s, "sharept") )
+else if ( !strncmp(s, "sharept", ss - s) )
 iommu_hap_pt_share = val;
+else
+rc = -EINVAL;
 
 s = ss + 1;
-} while ( ss );
+} while ( *ss );
+
+return rc;
 }
 
 int iommu_domain_init(struct domain *d)
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 08/53] xen/arch/x86/dom0_build.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/x86/dom0_build.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
Reviewed-by: Jan Beulich 
---
V3:
- cosmetic changes (Jan Beulich)
- dont modify option value in parsing function
---
 xen/arch/x86/dom0_build.c | 32 ++--
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/dom0_build.c b/xen/arch/x86/dom0_build.c
index 0c125e61eb..f616b99ddc 100644
--- a/xen/arch/x86/dom0_build.c
+++ b/xen/arch/x86/dom0_build.c
@@ -47,7 +47,8 @@ static long __init parse_amt(const char *s, const char **ps)
 long pages = parse_size_and_unit((*s == '-') ? s+1 : s, ps) >> PAGE_SHIFT;
 return (*s == '-') ? -pages : pages;
 }
-static void __init parse_dom0_mem(const char *s)
+
+static int __init parse_dom0_mem(const char *s)
 {
 do {
 if ( !strncmp(s, "min:", 4) )
@@ -57,13 +58,15 @@ static void __init parse_dom0_mem(const char *s)
 else
 dom0_nrpages = parse_amt(s, );
 } while ( *s++ == ',' );
+
+return *s ? -EINVAL : 0;
 }
 custom_param("dom0_mem", parse_dom0_mem);
 
 static unsigned int __initdata opt_dom0_max_vcpus_min = 1;
 static unsigned int __initdata opt_dom0_max_vcpus_max = UINT_MAX;
 
-static void __init parse_dom0_max_vcpus(const char *s)
+static int __init parse_dom0_max_vcpus(const char *s)
 {
 if ( *s == '-' )   /* -M */
 opt_dom0_max_vcpus_max = simple_strtoul(s + 1, , 0);
@@ -77,6 +80,8 @@ static void __init parse_dom0_max_vcpus(const char *s)
 else if ( *s++ == '-' && *s ) /* N-M */
 opt_dom0_max_vcpus_max = simple_strtoul(s, , 0);
 }
+
+return *s ? -EINVAL : 0;
 }
 custom_param("dom0_max_vcpus", parse_dom0_max_vcpus);
 
@@ -85,7 +90,7 @@ static __initdata unsigned int dom0_pxms[MAX_NUMNODES] =
 { [0 ... MAX_NUMNODES - 1] = ~0 };
 static __initdata bool dom0_affinity_relaxed;
 
-static void __init parse_dom0_nodes(const char *s)
+static int __init parse_dom0_nodes(const char *s)
 {
 do {
 if ( isdigit(*s) )
@@ -103,6 +108,8 @@ static void __init parse_dom0_nodes(const char *s)
 else
 break;
 } while ( ++dom0_nr_pxms < ARRAY_SIZE(dom0_pxms) && *s++ == ',' );
+
+return *s ? -EINVAL : 0;
 }
 custom_param("dom0_nodes", parse_dom0_nodes);
 
@@ -183,25 +190,30 @@ bool __initdata dom0_pvh;
  *  - pvh   Create a PVHv2 Dom0.
  *  - shadowUse shadow paging for Dom0.
  */
-static void __init parse_dom0_param(char *s)
+static int __init parse_dom0_param(const char *s)
 {
-char *ss;
+const char *ss;
+int rc = 0;
 
 do {
 
 ss = strchr(s, ',');
-if ( ss )
-*ss = '\0';
+if ( !ss )
+ss = strchr(s, '\0');
 
-if ( !strcmp(s, "pvh") )
+if ( !strncmp(s, "pvh", ss - s) )
 dom0_pvh = true;
 #ifdef CONFIG_SHADOW_PAGING
-else if ( !strcmp(s, "shadow") )
+else if ( !strncmp(s, "shadow", ss - s) )
 opt_dom0_shadow = true;
 #endif
+else
+rc = -EINVAL;
 
 s = ss + 1;
-} while ( ss );
+} while ( *ss );
+
+return rc;
 }
 custom_param("dom0", parse_dom0_param);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 14/53] xen/arch/x86/microcode.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/x86/microcode.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
 xen/arch/x86/microcode.c | 10 +++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/xen/arch/x86/microcode.c b/xen/arch/x86/microcode.c
index 7558202efa..77c1efc97f 100644
--- a/xen/arch/x86/microcode.c
+++ b/xen/arch/x86/microcode.c
@@ -73,15 +73,19 @@ void __init microcode_set_module(unsigned int idx)
  * If the EFI has forced which of the multiboot payloads is to be used,
  * no parsing will be attempted.
  */
-static void __init parse_ucode(char *s)
+static int __init parse_ucode(const char *s)
 {
+const char *q = NULL;
+
 if ( ucode_mod_forced ) /* Forced by EFI */
-   return;
+   return 0;
 
 if ( !strncmp(s, "scan", 4) )
 ucode_scan = 1;
 else
-ucode_mod_idx = simple_strtol(s, NULL, 0);
+ucode_mod_idx = simple_strtol(s, , 0);
+
+return (q && *q) ? -EINVAL : 0;
 }
 custom_param("ucode", parse_ucode);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 45/53] xen/common/kexec.c: remove custom_param() error messages

2017-08-23 Thread Juergen Gross
With _cmdline_parse() now issuing error messages in case of illegal
parameters signalled by parsing functions specified in custom_param()
some messages issued by parse_low_crashinfo() and
parse_crashinfo_maxaddr() can be removed.

Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
---
 xen/common/kexec.c | 5 -
 1 file changed, 5 deletions(-)

diff --git a/xen/common/kexec.c b/xen/common/kexec.c
index fcc68bd4d8..e0f1e3eafa 100644
--- a/xen/common/kexec.c
+++ b/xen/common/kexec.c
@@ -213,7 +213,6 @@ static int __init parse_low_crashinfo(const char *str)
 low_crashinfo_mode = LOW_CRASHINFO_ALL;
 else
 {
-printk("Unknown low_crashinfo parameter '%s'.  Defaulting to min.\n", 
str);
 low_crashinfo_mode = LOW_CRASHINFO_MIN;
 return -EINVAL;
 }
@@ -240,11 +239,7 @@ static int __init parse_crashinfo_maxaddr(const char *str)
 if ( (addr = parse_size_and_unit(str, )) )
 crashinfo_maxaddr = addr;
 else
-{
-printk("Unable to parse crashinfo_maxaddr. Defaulting to 
%"PRIpaddr"\n",
-   crashinfo_maxaddr);
 return -EINVAL;
-}
 
 return *q ? -EINVAL : 0;
 }
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 42/53] xen/arch/x86/cpu/mcheck/mce.c: remove custom_param() error messages

2017-08-23 Thread Juergen Gross
With _cmdline_parse() now issuing error messages in case of illegal
parameters signalled by parsing functions specified in custom_param()
the message issued by mce_set_verbosity() can be removed.

Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
Acked-by: Jan Beulich 
---
 xen/arch/x86/cpu/mcheck/mce.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c
index 8015dff8c4..7affe2591e 100644
--- a/xen/arch/x86/cpu/mcheck/mce.c
+++ b/xen/arch/x86/cpu/mcheck/mce.c
@@ -67,11 +67,7 @@ static int __init mce_set_verbosity(const char *str)
 if (strcmp("verbose", str) == 0)
 mce_verbosity = MCE_VERBOSE;
 else
-{
-printk(KERN_DEBUG "Machine Check verbosity level %s not recognised"
-   "use mce_verbosity=verbose", str);
 return -EINVAL;
-}
 
 return 0;
 }
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 20/53] xen/arch/x86/setup.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/x86/setup.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
 xen/arch/x86/setup.c | 35 +--
 1 file changed, 25 insertions(+), 10 deletions(-)

diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 414681d5a1..ec96287966 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -67,7 +67,7 @@ unsigned long __read_mostly cr4_pv32_mask;
 /* "acpi=force":  Override the disable blacklist.   */
 /* "acpi=ht": Limit ACPI just to boot-time to enable HT.*/
 /* "acpi=noirq":  Disables ACPI interrupt routing.  */
-static void parse_acpi_param(char *s);
+static int parse_acpi_param(const char *s);
 custom_param("acpi", parse_acpi_param);
 
 /*  Linux config option: propagated to domain0. */
@@ -102,59 +102,70 @@ unsigned long __read_mostly mmu_cr4_features = 
XEN_MINIMAL_CR4;
 /* smep: Enable/disable Supervisor Mode Execution Protection (default on). */
 #define SMEP_HVM_ONLY (-1)
 static s8 __initdata opt_smep = 1;
-static void __init parse_smep_param(char *s)
+
+static int __init parse_smep_param(const char *s)
 {
 if ( !*s )
 {
 opt_smep = 1;
-return;
+return 0;
 }
 
 switch ( parse_bool(s, NULL) )
 {
 case 0:
 opt_smep = 0;
-return;
+return 0;
 case 1:
 opt_smep = 1;
-return;
+return 0;
 }
 
 if ( !strcmp(s, "hvm") )
 opt_smep = SMEP_HVM_ONLY;
+else
+return -EINVAL;
+
+return 0;
 }
 custom_param("smep", parse_smep_param);
 
 /* smap: Enable/disable Supervisor Mode Access Prevention (default on). */
 #define SMAP_HVM_ONLY (-1)
 static s8 __initdata opt_smap = 1;
-static void __init parse_smap_param(char *s)
+
+static int __init parse_smap_param(const char *s)
 {
 if ( !*s )
 {
 opt_smap = 1;
-return;
+return 0;
 }
 
 switch ( parse_bool(s, NULL) )
 {
 case 0:
 opt_smap = 0;
-return;
+return 0;
 case 1:
 opt_smap = 1;
-return;
+return 0;
 }
 
 if ( !strcmp(s, "hvm") )
 opt_smap = SMAP_HVM_ONLY;
+else
+return -EINVAL;
+
+return 0;
 }
 custom_param("smap", parse_smap_param);
 
 bool __read_mostly acpi_disabled;
 bool __initdata acpi_force;
 static char __initdata acpi_param[10] = "";
-static void __init parse_acpi_param(char *s)
+
+static int __init parse_acpi_param(const char *s)
 {
 /* Save the parameter so it can be propagated to domain0. */
 safe_strcpy(acpi_param, s);
@@ -180,6 +191,10 @@ static void __init parse_acpi_param(char *s)
 {
 acpi_noirq_set();
 }
+else
+return -EINVAL;
+
+return 0;
 }
 
 static const module_t *__initdata initial_images;
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 21/53] xen/arch/x86/shutdown.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/arch/x86/shutdown.c

to indicate whether the parameter value was parsed successfully.

Cc: Jan Beulich 
Cc: Andrew Cooper 
Signed-off-by: Juergen Gross 
---
V4:
- issue a message in case of reboot=efi and no EFI runtime services
  (Jan Beulich)

V3:
- dont stop loop at first invalid character (Jan Beulich)
---
 xen/arch/x86/shutdown.c | 14 +-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/shutdown.c b/xen/arch/x86/shutdown.c
index f63b8a668f..a87aa60add 100644
--- a/xen/arch/x86/shutdown.c
+++ b/xen/arch/x86/shutdown.c
@@ -51,8 +51,11 @@ static int reboot_mode;
  * efiUse the EFI reboot (if running under EFI)
  */
 static enum reboot_type reboot_type = BOOT_INVALID;
-static void __init set_reboot_type(char *str)
+
+static int __init set_reboot_type(const char *str)
 {
+int rc = 0;
+
 for ( ; ; )
 {
 switch ( *str )
@@ -74,6 +77,9 @@ static void __init set_reboot_type(char *str)
 case 't':
 reboot_type = *str;
 break;
+default:
+rc = -EINVAL;
+break;
 }
 if ( (str = strchr(str, ',')) == NULL )
 break;
@@ -81,7 +87,13 @@ static void __init set_reboot_type(char *str)
 }
 
 if ( reboot_type == BOOT_EFI && !efi_enabled(EFI_RS) )
+{
+printk("EFI reboot selected, but no EFI runtime services available.\n"
+   "Falling back to default reboot type.\n");
 reboot_type = BOOT_INVALID;
+}
+
+return rc;
 }
 custom_param("reboot", set_reboot_type);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 38/53] xen/drivers/video/vesa.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/drivers/video/vesa.c

to indicate whether the parameter value was parsed successfully.

Cc: Andrew Cooper 
Cc: George Dunlap 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Konrad Rzeszutek Wilk 
Cc: Stefano Stabellini 
Cc: Tim Deegan 
Cc: Wei Liu 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
 xen/drivers/video/vesa.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/video/vesa.c b/xen/drivers/video/vesa.c
index 09d344c021..c92497e0bc 100644
--- a/xen/drivers/video/vesa.c
+++ b/xen/drivers/video/vesa.c
@@ -29,12 +29,14 @@ static unsigned int vram_remap;
 integer_param("vesa-map", vram_remap);
 
 static int font_height;
-static void __init parse_font_height(const char *s)
+static int __init parse_font_height(const char *s)
 {
 if ( simple_strtoul(s, , 10) == 8 && (*s++ == 'x') )
 font_height = simple_strtoul(s, , 10);
 if ( *s != '\0' )
 font_height = 0;
+
+return 0;
 }
 custom_param("font", parse_font_height);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 24/53] xen/common/core_parking.c: let custom parameter parsing routines return errno

2017-08-23 Thread Juergen Gross
Modify the custom parameter parsing routines in:

xen/common/core_parking.c

to indicate whether the parameter value was parsed successfully.

Cc: Andrew Cooper 
Cc: George Dunlap 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Konrad Rzeszutek Wilk 
Cc: Stefano Stabellini 
Cc: Tim Deegan 
Cc: Wei Liu 
Signed-off-by: Juergen Gross 
Acked-by: Wei Liu 
Acked-by: Jan Beulich 
---
 xen/common/core_parking.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/xen/common/core_parking.c b/xen/common/core_parking.c
index de269e06c2..803c6c7911 100644
--- a/xen/common/core_parking.c
+++ b/xen/common/core_parking.c
@@ -41,14 +41,16 @@ static enum core_parking_controller {
 PERFORMANCE_FIRST
 } core_parking_controller = POWER_FIRST;
 
-static void __init setup_core_parking_option(char *str)
+static int __init setup_core_parking_option(const char *str)
 {
 if ( !strcmp(str, "power") )
 core_parking_controller = POWER_FIRST;
 else if ( !strcmp(str, "performance") )
 core_parking_controller = PERFORMANCE_FIRST;
 else
-return;
+return -EINVAL;
+
+return 0;
 }
 custom_param("core_parking", setup_core_parking_option);
 
-- 
2.12.3


___
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel


[Xen-devel] [PATCH v4 01/53] xen: add an optional string end parameter to parse_bool()

2017-08-23 Thread Juergen Gross
Add a parameter to parse_bool() to specify the end of the to be
parsed string. Specifying it as NULL will preserve the current
behavior to parse until the end of the input string, while passing
a non-NULL pointer will specify the first character after the input
string.

This will allow to parse boolean sub-strings without having to
write a NUL byte into the input string.

Modify all users of parse_bool() to pass NULL for the new parameter.

Cc: Stefano Stabellini 
Cc: Julien Grall 
Cc: Andrew Cooper 
Cc: George Dunlap 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Konrad Rzeszutek Wilk 
Cc: Tim Deegan 
Cc: Wei Liu 
Cc: Kevin Tian 
Signed-off-by: Juergen Gross 
---
 xen/arch/arm/acpi/boot.c  |  2 +-
 xen/arch/x86/cpu/vpmu.c   |  2 +-
 xen/arch/x86/mm.c |  2 +-
 xen/arch/x86/nmi.c|  2 +-
 xen/arch/x86/psr.c|  2 +-
 xen/arch/x86/setup.c  |  6 +++---
 xen/arch/x86/x86_64/mmconfig-shared.c |  2 +-
 xen/common/kernel.c   | 28 
 xen/drivers/char/console.c|  2 +-
 xen/drivers/cpufreq/cpufreq.c |  2 +-
 xen/drivers/passthrough/iommu.c   |  2 +-
 xen/drivers/passthrough/vtd/quirks.c  |  2 +-
 xen/include/xen/lib.h |  2 +-
 13 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/xen/arch/arm/acpi/boot.c b/xen/arch/arm/acpi/boot.c
index 889208a0ea..a5a6f55f0e 100644
--- a/xen/arch/arm/acpi/boot.c
+++ b/xen/arch/arm/acpi/boot.c
@@ -199,7 +199,7 @@ static void __init parse_acpi_param(char *arg)
 return;
 
 /* Interpret the parameter for use within Xen. */
-if ( !parse_bool(arg) )
+if ( !parse_bool(arg, NULL) )
 param_acpi_off = true;
 else if ( !strcmp(arg, "force") ) /* force ACPI to be enabled */
 param_acpi_force = true;
diff --git a/xen/arch/x86/cpu/vpmu.c b/xen/arch/x86/cpu/vpmu.c
index 90954ca884..1c0ea10777 100644
--- a/xen/arch/x86/cpu/vpmu.c
+++ b/xen/arch/x86/cpu/vpmu.c
@@ -80,7 +80,7 @@ static void __init parse_vpmu_params(char *s)
 {
 char *sep, *p = s;
 
-switch ( parse_bool(s) )
+switch ( parse_bool(s, NULL) )
 {
 case 0:
 break;
diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c
index ed77270586..5b0e55d7d9 100644
--- a/xen/arch/x86/mm.c
+++ b/xen/arch/x86/mm.c
@@ -184,7 +184,7 @@ static void __init parse_mmio_relax(const char *s)
 if ( !*s )
 opt_mmio_relax = 1;
 else
-opt_mmio_relax = parse_bool(s);
+opt_mmio_relax = parse_bool(s, NULL);
 if ( opt_mmio_relax < 0 && strcmp(s, "all") )
 opt_mmio_relax = 0;
 }
diff --git a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c
index 8914581f66..e44f88045e 100644
--- a/xen/arch/x86/nmi.c
+++ b/xen/arch/x86/nmi.c
@@ -54,7 +54,7 @@ static void __init parse_watchdog(char *s)
 return;
 }
 
-switch ( parse_bool(s) )
+switch ( parse_bool(s, NULL) )
 {
 case 0:
 opt_watchdog = false;
diff --git a/xen/arch/x86/psr.c b/xen/arch/x86/psr.c
index c2036cbed4..25a85b65b2 100644
--- a/xen/arch/x86/psr.c
+++ b/xen/arch/x86/psr.c
@@ -427,7 +427,7 @@ static void __init parse_psr_bool(char *s, char *value, 
char *feature,
 opt_psr |= mask;
 else
 {
-int val_int = parse_bool(value);
+int val_int = parse_bool(value, NULL);
 
 if ( val_int == 0 )
 opt_psr &= ~mask;
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index db5df6956d..414681d5a1 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -110,7 +110,7 @@ static void __init parse_smep_param(char *s)
 return;
 }
 
-switch ( parse_bool(s) )
+switch ( parse_bool(s, NULL) )
 {
 case 0:
 opt_smep = 0;
@@ -136,7 +136,7 @@ static void __init parse_smap_param(char *s)
 return;
 }
 
-switch ( parse_bool(s) )
+switch ( parse_bool(s, NULL) )
 {
 case 0:
 opt_smap = 0;
@@ -160,7 +160,7 @@ static void __init parse_acpi_param(char *s)
 safe_strcpy(acpi_param, s);
 
 /* Interpret the parameter for use within Xen. */
-if ( !parse_bool(s) )
+if ( !parse_bool(s, NULL) )
 {
 disable_acpi();
 }
diff --git a/xen/arch/x86/x86_64/mmconfig-shared.c 
b/xen/arch/x86/x86_64/mmconfig-shared.c
index 488470bfeb..dbf9ff07fa 100644
--- a/xen/arch/x86/x86_64/mmconfig-shared.c
+++ b/xen/arch/x86/x86_64/mmconfig-shared.c
@@ -37,7 +37,7 @@ static void __init parse_mmcfg(char *s)
 if ( ss )
 *ss = '\0';
 
-if ( !parse_bool(s) )
+if ( !parse_bool(s, NULL) )
 pci_probe &= ~PCI_PROBE_MMCONF;
 else if ( !strcmp(s, "amd_fam10") || !strcmp(s, "amd-fam10") )

  1   2   3   >