Re: [PATCH RFC] seccomp: Implement syscall isolation based on memory areas

2020-06-01 Thread Billy Laws
> On May 30, 2020, at 5:26 PM, Gabriel Krisman Bertazi  
> wrote:
>
> Andy Lutomirski  writes:
>
>>>> On May 29, 2020, at 11:00 PM, Gabriel Krisman Bertazi 
>>>>  wrote:
>>>
>>> Modern Windows applications are executing system call instructions
>>> directly from the application's code without going through the WinAPI.
>>> This breaks Wine emulation, because it doesn't have a chance to
>>> intercept and emulate these syscalls before they are submitted to Linux.
>>>
>>> In addition, we cannot simply trap every system call of the application
>>> to userspace using PTRACE_SYSEMU, because performance would suffer,
>>> since our main use case is to run Windows games over Linux.  Therefore,
>>> we need some in-kernel filtering to decide whether the syscall was
>>> issued by the wine code or by the windows application.
>>
>> Do you really need in-kernel filtering?  What if you could have
>> efficient userspace filtering instead?  That is, set something up so
>> that all syscalls, except those from a special address, are translated
>> to CALL thunk where the thunk is configured per task.  Then the thunk
>> can do whatever emulation is needed.
>
> Hi,
>
> I suggested something similar to my customer, by using
> libsyscall-intercept.  The idea would be overwritting the syscall
> instruction with a call to the entry point.  I'm not a specialist on the
> specifics of Windows games, (cc'ed Paul Gofman, who can provide more
> details on that side), but as far as I understand, the reason why that
> is not feasible is that the anti-cheat protection in games will abort
> execution if the binary region was modified either on-disk or in-memory.
>
> Is there some mechanism to do that without modiyfing the application?

Hi,

I work on an emulator for the Nintendo Switch that uses a similar technique,
in our testing it works very well and is much more performant than even
PTRACE_SYSEMU.

To work around DRM reading the memory contents I think mprotect could
be used, after patching the syscall a copy of the original code could be
kept somewhere in memory and the patched region mapped --X.
With this, any time the DRM attempts to read to the patched region and
perform integrity checks it will cause a segfault and a branch to the
signal handler. This handler can then return the contents of the original,
unpatched region to satisfy them checks.

Are memory contents checked by DRM solutions too often for this to be
performant?
--
Billy Laws
>
>> Getting the details and especially the interaction with any seccomp
>> filters that may be installed right could be tricky, but the performance
>> should be decent, at least on non-PTI systems.
>>
>> (If we go this route, I suspect that the correct interaction with
>> seccomp is that this type of redirection takes precedence over seccomp
>> and seccomp filters are not invoked for redirected syscalls. After all,
>> a redirected syscall is, functionally, not a syscall at all.)
>>
>
>
> --
> Gabriel Krisman Bertazi


Re: [PATCH V1 00/12] LP0 entry and exit support for Tegra210

2019-05-28 Thread Billy Laws
Hi,
By the looks of this you configure wake events but the pmc driver
still only configures lp1, which is the same as linux 4 tegra 4.4+
which also doesn't support lp0, if its selected in dts it'll just
change it to LP1/SC7 (both have same code path and neither set any lp0
stuff trm says). What confuses me further is that l4t and this
ptachset both configure wake events, which I think should only work in
LP0 and not LP1 and yet neither have lp0 entry code for t210. I also
looked at ATF, whis sets the flags to wake the cpu on interrupts,
which would suggest that it only supports lp1 (in deep sleep I dont
think them flags would work). Am I missing some important detail here?
Two other things, will you be adding full lp0 in later patchets and
will they use the bpmp or not?


Re: [PATCH v2 4/4] mfd: max77620: add documentation for low battery monitoring

2019-01-31 Thread Billy laws



On 31 January 2019 21:05:46 GMT, Rob Herring  wrote:
>On Wed, Jan 30, 2019 at 8:29 PM Mark Zhang  wrote:
>>
>> On 1/31/2019 3:53 AM, Rob Herring wrote:
>> > On Tue, Jan 29, 2019 at 04:55:31PM +0800, Mark Zhang wrote:
>> >> Adding documentation for low battery monitor properties:
>> >> - maxim,low-battery-dac-enable
>> >> - maxim,low-battery-dac-disable
>> >> - maxim,low-battery-shutdown-enable
>> >> - maxim,low-battery-shutdown-disable
>> >> - maxim,low-battery-reset-enable
>> >> - maxim,low-battery-reset-disable
>> >>
>> >> Signed-off-by: Mark Zhang 
>> >> ---
>> >>  Documentation/devicetree/bindings/mfd/max77620.txt | 14
>++
>> >>  1 file changed, 14 insertions(+)
>> >>
>> >> diff --git a/Documentation/devicetree/bindings/mfd/max77620.txt
>b/Documentation/devicetree/bindings/mfd/max77620.txt
>> >> index 484b17e4fba5..5fed0a463b80 100644
>> >> --- a/Documentation/devicetree/bindings/mfd/max77620.txt
>> >> +++ b/Documentation/devicetree/bindings/mfd/max77620.txt
>> >> @@ -142,6 +142,20 @@ Optional properties:
>> >>  Device supports 100/1000/3000/6000 Ohms.
>> >>  Default will be set to 1000 Ohm.
>> >>
>> >> +Low-Battery Monitor:
>> >> +==
>> >> +This sub-node configure low battery monitor configuration
>registers. Device has
>> >> +support for low-battery monitor configuration through child DT
>node
>> >> +"low-battery-monitor".
>
>Missed this the first time, but there's not really any reason for
>these to be in a child node.
>
>> >> +
>> >> +Optional properties:
>> >> +- maxim,low-battery-dac-enable: Enable low battery DAC.
>> >> +- maxim,low-battery-dac-disable: Disable low battery DAC.
>> >> +- maxim,low-battery-shutdown-enable: Enable low battery
>shutdown.
>> >> +- maxim,low-battery-shutdown-disable: Disable low battery
>shutdown.
>> >> +- maxim,low-battery-reset-enable: Enable low battery reset.
>> >> +- maxim,low-battery-reset-disable: Disable low battery reset.
>> >
>> > Do you really need 3 states with the 3rd being prop not present.
>>
>> Yeah, so I think we can just keep 3 of them and shorten the names a
>little bit
>> (lbm stands for "low battery monitoring"):
>> - maxim,lbm-dac-enable
>> - maxim,lbm-shutdown-enable
>> - maxim,lbm-reset-enable
>>
>> Does this look good to you?
>
>Yes. However, are these 3 mutually exclusive? If so, then perhaps
>'maxim,low-battery-mode = ""'?
I agree, would also allow the addition of the voltage cut off point 
configuration by just adding more defines.(current forces 3.something v cutoff)
>
>Rob


Re: [2/2] mfd: max77620: Add low battery monitor support

2019-01-29 Thread Billy Laws
It does, see this article
https://blog.quendi.moe/2018/07/03/en-debugging-nintendo-switch-linux-power-management-battery-desync-edition/


On Tue, Jan 29, 2019 at 9:03 AM Mark Zhang  wrote:
>
> On 1/29/2019 3:36 PM, Billy Laws wrote:
> > Sure, that's fine with me, will send then this gets accepted. Two
> > other things: you should probably set the reg to 0 if the property
> > isn't specified as regmap_add_irqchip sets it to 0xff (basically all
> > enabled on highest limit), and you haven't updated the dt-bindings.
>
> Billy, v2 is out, dt-bindings patches are added.
> But after a second thought, I don't think regmap_add_irqchip might set
> registers to 0xff. I mean, for 2 registers which this patch set touches,
> they're not IRQ registers(mask/status/...), so regmap_add_irqchip should
> not touch them so I didn't make changes to driver codes in v2.
>
> Mark
>
> >
> > On Tue, Jan 29, 2019 at 6:52 AM Mark Zhang  wrote:
> >>
> >> On 1/27/2019 10:54 PM, Billy Laws wrote:
> >>>  >This patch adds PMIC configurations for low-battery
> >>>  >monitoring by handling max77620 register CNFGGLBL1.
> >>>  >
> >>> It might be an idea to add lbhyst configuration here and support using
> >>> custom lbdac values to specify a different cutoff point.
> >>
> >> Yeah this patch doesn't have support to program LBHYST & LBDAC because
> >> according to our experiences, we don't have requirement to modify them
> >> when low battery monitor support added.
> >>
> >> I think we can create a new patch to support these 2 fields in the future
> >> when we really need them. Or you can create a patch if you have requirement
> >> for them, is this OK to you Billy?
> >>
> >> Mark
> >>
> >>>
> >>> See: https://datasheetspdf.com/pdf-file/924230/Maxim/MAX8698C/1  pg 46
> >>>  >Signed-off-by: Laxman Dewangan 
> >>>  >Signed-off-by: Venkat Reddy Talla 
> >>>  >Signed-off-by: Mark Zhang 
> >>>  >---
> >>>  > drivers/mfd/max77620.c | 57 +-
> >>>  > 1 file changed, 56 insertions(+), 1 deletion(-)
> >>>  >
> >>>  >diff --git a/drivers/mfd/max77620.c b/drivers/mfd/max77620.c
> >>>  >index f58143103185..9e50d145afd8 100644
> >>>  >--- a/drivers/mfd/max77620.c
> >>>  >+++ b/drivers/mfd/max77620.c
> >>>  >@@ -474,6 +474,57 @@ static int
> >>> max77620_init_backup_battery_charging(struct max77620_chip *chip)
> >>>  >  return ret;
> >>>  > }
> >>>  >
> >>>  >+static int max77620_init_low_battery_monitor(struct max77620_chip 
> >>> *chip)
> >>>  >+{
> >>>  >+ struct device *dev = chip->dev;
> >>>  >+ struct device_node *np;
> >>>  >+ bool pval;
> >>>  >+ u8 mask = 0;
> >>>  >+ u8 val = 0;
> >>>  >+ int ret;
> >>>  >+
> >>>  >+ np = of_get_child_by_name(dev->of_node, "low-battery-monitor");
> >>>  >+ if (!np) {
> >>>  >+ dev_info(dev, "Low battery monitoring support disabled\n");
> >>>  >+ return 0;
> >>>  >+ }
> >>>  >+
> >>>  >+ pval = of_property_read_bool(np, "maxim,low-battery-dac-enable");
> >>>  >+ if (pval) {
> >>>  >+ mask |= MAX77620_CNFGGLBL1_LBDAC_EN;
> >>>  >+ val |= MAX77620_CNFGGLBL1_LBDAC_EN;
> >>>  >+ }
> >>>  >+
> >>>  >+ pval = of_property_read_bool(np, "maxim,low-battery-dac-disable");
> >>>  >+ if (pval)
> >>>  >+ mask |= MAX77620_CNFGGLBL1_LBDAC_EN;
> >>>  >+
> >>>  >+ pval = of_property_read_bool(np, "maxim,low-battery-shutdown-enable");
> >>>  >+ if (pval) {
> >>>  >+ mask |= MAX77620_CNFGGLBL1_MPPLD;
> >>>  >+ val |= MAX77620_CNFGGLBL1_MPPLD;
> >>>  >+ }
> >>>  >+
> >>>  >+ pval = of_property_read_bool(np, 
> >>> "maxim,low-battery-shutdown-disable");
> >>>  >+ if (pval)
> >>>  >+ mask |= MAX77620_CNFGGLBL1_MPPLD;
> >>>  >+
> >>>  >+ pval = of_property_read_bool(np, "maxim,low-battery-reset-enable");
> >>>  >+ if (pval) {
> >>>  >+ mask |= MAX77620_CNFGGLBL1_LBRSTEN;
> >>>  >+ val |= MAX77620_CNFGGLBL1_LBRSTEN;
> >>>  >+ }
> >>>  >+
> >>>  >+ pval = of_property_read_bool(np, "maxim,low-battery-reset-disable");
> >>>  >+ if (pval)
> >>>  >+ mask |= MAX77620_CNFGGLBL1_LBRSTEN;
> >>>  >+
> >>>  >+ ret = regmap_update_bits(chip->rmap, MAX77620_REG_CNFGGLBL1, mask, 
> >>> val);
> >>>  >+ if (ret < 0)
> >>>  >+ dev_err(dev, "Reg CNFGGLBL1 update failed: %d\n", ret);
> >>>  >+ return ret;
> >>>  >+}
> >>>  >+
> >>>  > static int max77620_read_es_version(struct max77620_chip *chip)
> >>>  > {
> >>>  >  unsigned int val;
> >>>  >@@ -563,7 +614,11 @@ static int max77620_probe(struct i2c_client 
> >>> *client,
> >>>  >  if (ret < 0)
> >>>  >  return ret;
> >>>  >
> >>>  >- ret =  devm_mfd_add_devices(chip->dev, PLATFORM_DEVID_NONE,
> >>>  >+ ret = max77620_init_low_battery_monitor(chip);
> >>>  >+ if (ret < 0)
> >>>  >+ return ret;
> >>>  >+
> >>>  >+ ret = devm_mfd_add_devices(chip->dev, PLATFORM_DEVID_NONE,
> >>>  >  mfd_cells, n_mfd_cells, NULL, 0,
> >>>  >  regmap_irq_get_domain(chip->top_irq_data));
> >>>  >  if (ret < 0) {
> >>>


Re: [2/2] mfd: max77620: Add low battery monitor support

2019-01-28 Thread Billy Laws
Sure, that's fine with me, will send then this gets accepted. Two
other things: you should probably set the reg to 0 if the property
isn't specified as regmap_add_irqchip sets it to 0xff (basically all
enabled on highest limit), and you haven't updated the dt-bindings.

On Tue, Jan 29, 2019 at 6:52 AM Mark Zhang  wrote:
>
> On 1/27/2019 10:54 PM, Billy Laws wrote:
> >  >This patch adds PMIC configurations for low-battery
> >  >monitoring by handling max77620 register CNFGGLBL1.
> >  >
> > It might be an idea to add lbhyst configuration here and support using
> > custom lbdac values to specify a different cutoff point.
>
> Yeah this patch doesn't have support to program LBHYST & LBDAC because
> according to our experiences, we don't have requirement to modify them
> when low battery monitor support added.
>
> I think we can create a new patch to support these 2 fields in the future
> when we really need them. Or you can create a patch if you have requirement
> for them, is this OK to you Billy?
>
> Mark
>
> >
> > See: https://datasheetspdf.com/pdf-file/924230/Maxim/MAX8698C/1  pg 46
> >  >Signed-off-by: Laxman Dewangan 
> >  >Signed-off-by: Venkat Reddy Talla 
> >  >Signed-off-by: Mark Zhang 
> >  >---
> >  > drivers/mfd/max77620.c | 57 +-
> >  > 1 file changed, 56 insertions(+), 1 deletion(-)
> >  >
> >  >diff --git a/drivers/mfd/max77620.c b/drivers/mfd/max77620.c
> >  >index f58143103185..9e50d145afd8 100644
> >  >--- a/drivers/mfd/max77620.c
> >  >+++ b/drivers/mfd/max77620.c
> >  >@@ -474,6 +474,57 @@ static int
> > max77620_init_backup_battery_charging(struct max77620_chip *chip)
> >  >  return ret;
> >  > }
> >  >
> >  >+static int max77620_init_low_battery_monitor(struct max77620_chip *chip)
> >  >+{
> >  >+ struct device *dev = chip->dev;
> >  >+ struct device_node *np;
> >  >+ bool pval;
> >  >+ u8 mask = 0;
> >  >+ u8 val = 0;
> >  >+ int ret;
> >  >+
> >  >+ np = of_get_child_by_name(dev->of_node, "low-battery-monitor");
> >  >+ if (!np) {
> >  >+ dev_info(dev, "Low battery monitoring support disabled\n");
> >  >+ return 0;
> >  >+ }
> >  >+
> >  >+ pval = of_property_read_bool(np, "maxim,low-battery-dac-enable");
> >  >+ if (pval) {
> >  >+ mask |= MAX77620_CNFGGLBL1_LBDAC_EN;
> >  >+ val |= MAX77620_CNFGGLBL1_LBDAC_EN;
> >  >+ }
> >  >+
> >  >+ pval = of_property_read_bool(np, "maxim,low-battery-dac-disable");
> >  >+ if (pval)
> >  >+ mask |= MAX77620_CNFGGLBL1_LBDAC_EN;
> >  >+
> >  >+ pval = of_property_read_bool(np, "maxim,low-battery-shutdown-enable");
> >  >+ if (pval) {
> >  >+ mask |= MAX77620_CNFGGLBL1_MPPLD;
> >  >+ val |= MAX77620_CNFGGLBL1_MPPLD;
> >  >+ }
> >  >+
> >  >+ pval = of_property_read_bool(np, "maxim,low-battery-shutdown-disable");
> >  >+ if (pval)
> >  >+ mask |= MAX77620_CNFGGLBL1_MPPLD;
> >  >+
> >  >+ pval = of_property_read_bool(np, "maxim,low-battery-reset-enable");
> >  >+ if (pval) {
> >  >+ mask |= MAX77620_CNFGGLBL1_LBRSTEN;
> >  >+ val |= MAX77620_CNFGGLBL1_LBRSTEN;
> >  >+ }
> >  >+
> >  >+ pval = of_property_read_bool(np, "maxim,low-battery-reset-disable");
> >  >+ if (pval)
> >  >+ mask |= MAX77620_CNFGGLBL1_LBRSTEN;
> >  >+
> >  >+ ret = regmap_update_bits(chip->rmap, MAX77620_REG_CNFGGLBL1, mask, val);
> >  >+ if (ret < 0)
> >  >+ dev_err(dev, "Reg CNFGGLBL1 update failed: %d\n", ret);
> >  >+ return ret;
> >  >+}
> >  >+
> >  > static int max77620_read_es_version(struct max77620_chip *chip)
> >  > {
> >  >  unsigned int val;
> >  >@@ -563,7 +614,11 @@ static int max77620_probe(struct i2c_client *client,
> >  >  if (ret < 0)
> >  >  return ret;
> >  >
> >  >- ret =  devm_mfd_add_devices(chip->dev, PLATFORM_DEVID_NONE,
> >  >+ ret = max77620_init_low_battery_monitor(chip);
> >  >+ if (ret < 0)
> >  >+ return ret;
> >  >+
> >  >+ ret = devm_mfd_add_devices(chip->dev, PLATFORM_DEVID_NONE,
> >  >  mfd_cells, n_mfd_cells, NULL, 0,
> >  >  regmap_irq_get_domain(chip->top_irq_data));
> >  >  if (ret < 0) {
> >


Re: [2/2] mfd: max77620: Add low battery monitor support

2019-01-27 Thread Billy Laws
On 1/28/19, Lee Jones  wrote:
> Re-sending due to dodgy looking 'reply-to'.
>
> On Sun, 27 Jan 2019, Billy Laws wrote:
>
>> >This patch adds PMIC configurations for low-battery
>> >monitoring by handling max77620 register CNFGGLBL1.
>> >
>> It might be an idea to add lbhyst configuration here and support using
>> custom lbdac values to specify a different cutoff point.
>
> Do you know why this email was sent independent of the original
> submission?  Something wrong with your mailer?
>
I tried to add the reply to manually in thunderbird as I wasn't
subscribed to the mailing list, seems it didn't exactly work.
> --
> Lee Jones [李琼斯]
> Linaro Services Technical Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog
>


Re: [2/2] mfd: max77620: Add low battery monitor support

2019-01-27 Thread Billy Laws

>This patch adds PMIC configurations for low-battery
>monitoring by handling max77620 register CNFGGLBL1.
>
It might be an idea to add lbhyst configuration here and support using
custom lbdac values to specify a different cutoff point.

See: https://datasheetspdf.com/pdf-file/924230/Maxim/MAX8698C/1  pg 46
>Signed-off-by: Laxman Dewangan 
>Signed-off-by: Venkat Reddy Talla 
>Signed-off-by: Mark Zhang 
>---
> drivers/mfd/max77620.c | 57 +-
> 1 file changed, 56 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/mfd/max77620.c b/drivers/mfd/max77620.c
>index f58143103185..9e50d145afd8 100644
>--- a/drivers/mfd/max77620.c
>+++ b/drivers/mfd/max77620.c
>@@ -474,6 +474,57 @@ static int 
max77620_init_backup_battery_charging(struct max77620_chip *chip)

>  return ret;
> }
>
>+static int max77620_init_low_battery_monitor(struct max77620_chip *chip)
>+{
>+ struct device *dev = chip->dev;
>+ struct device_node *np;
>+ bool pval;
>+ u8 mask = 0;
>+ u8 val = 0;
>+ int ret;
>+
>+ np = of_get_child_by_name(dev->of_node, "low-battery-monitor");
>+ if (!np) {
>+ dev_info(dev, "Low battery monitoring support disabled\n");
>+ return 0;
>+ }
>+
>+ pval = of_property_read_bool(np, "maxim,low-battery-dac-enable");
>+ if (pval) {
>+ mask |= MAX77620_CNFGGLBL1_LBDAC_EN;
>+ val |= MAX77620_CNFGGLBL1_LBDAC_EN;
>+ }
>+
>+ pval = of_property_read_bool(np, "maxim,low-battery-dac-disable");
>+ if (pval)
>+ mask |= MAX77620_CNFGGLBL1_LBDAC_EN;
>+
>+ pval = of_property_read_bool(np, "maxim,low-battery-shutdown-enable");
>+ if (pval) {
>+ mask |= MAX77620_CNFGGLBL1_MPPLD;
>+ val |= MAX77620_CNFGGLBL1_MPPLD;
>+ }
>+
>+ pval = of_property_read_bool(np, "maxim,low-battery-shutdown-disable");
>+ if (pval)
>+ mask |= MAX77620_CNFGGLBL1_MPPLD;
>+
>+ pval = of_property_read_bool(np, "maxim,low-battery-reset-enable");
>+ if (pval) {
>+ mask |= MAX77620_CNFGGLBL1_LBRSTEN;
>+ val |= MAX77620_CNFGGLBL1_LBRSTEN;
>+ }
>+
>+ pval = of_property_read_bool(np, "maxim,low-battery-reset-disable");
>+ if (pval)
>+ mask |= MAX77620_CNFGGLBL1_LBRSTEN;
>+
>+ ret = regmap_update_bits(chip->rmap, MAX77620_REG_CNFGGLBL1, mask, val);
>+ if (ret < 0)
>+ dev_err(dev, "Reg CNFGGLBL1 update failed: %d\n", ret);
>+ return ret;
>+}
>+
> static int max77620_read_es_version(struct max77620_chip *chip)
> {
>  unsigned int val;
>@@ -563,7 +614,11 @@ static int max77620_probe(struct i2c_client *client,
>  if (ret < 0)
>  return ret;
>
>- ret =  devm_mfd_add_devices(chip->dev, PLATFORM_DEVID_NONE,
>+ ret = max77620_init_low_battery_monitor(chip);
>+ if (ret < 0)
>+ return ret;
>+
>+ ret = devm_mfd_add_devices(chip->dev, PLATFORM_DEVID_NONE,
>  mfd_cells, n_mfd_cells, NULL, 0,
>  regmap_irq_get_domain(chip->top_irq_data));
>  if (ret < 0) {