Exemple #1
0
    def _generateSystemCallParameters(self):
        params = {}
        function = self.choice(("SwitchPrivilegeLevel", None))
        if function is not None:
            params["Function"] = function

        priv_level = self.choice(("U", "S", "M", 0, 1, 3, "Random", None))
        if priv_level is not None:
            params["PrivilegeLevel"] = priv_level

        target_addr = self._generateTargetAddress(priv_level)
        if target_addr is not None:
            params["TargetAddr"] = target_addr

        # Don't skip validation if no target address is specified
        skip_addr_validation = self.choice((0, 1, None))
        if (skip_addr_validation is not None) and (
            ("TargetAddr" in params) or (skip_addr_validation != 1)):
            params["SkipAddrValidation"] = skip_addr_validation

        if RandomUtils.random32(0, 4) == 4:
            choices_mod = ChoicesModifier(self.genThread)
            choices_mod.modifyPagingChoices(
                "Page Allocation Scheme",
                {
                    "RandomFreeAlloc": 0,
                    "FlatMapAlloc": 10
                },
            )
            params["AddrChoicesModID"] = choices_mod.registerSet()

        # for param_name in ('InterruptMask', 'SUM', 'MXR', 'MPRV'):
        for param_name in ("InterruptMask", ):
            param_val = self.choice((0, 1, "Same", "Flip", "Random", None))

            if param_val is not None:
                params[param_name] = param_val

        return params
Exemple #2
0
    def _generateSystemCallParameters(self):
        params = {}
        function = self.choice(('SwitchPrivilegeLevel', None))
        if function is not None:
            params['Function'] = function

        priv_level = self.choice(('U', 'S', 'M', 0, 1, 3, 'Random', None))
        if priv_level is not None:
            params['PrivilegeLevel'] = priv_level

        target_addr = self._generateTargetAddress(priv_level)
        if (target_addr is not None):
            params['TargetAddr'] = target_addr

        skip_addr_validation = self.choice((0, 1, None))
        if skip_addr_validation is not None:
            # Don't skip validation if no target address is specified
            if ('TargetAddr' in params) or (skip_addr_validation != 1):
                params['SkipAddrValidation'] = skip_addr_validation

        if RandomUtils.random32(0, 4) == 4:
            choices_mod = ChoicesModifier(self.genThread)
            choices_mod.modifyPagingChoices('Page Allocation Scheme', {
                'RandomFreeAlloc': 0,
                'FlatMapAlloc': 10
            })
            params['AddrChoicesModID'] = choices_mod.registerSet()

        # TODO(Noah): Add testing for SUM, MXR and MPRV when support for changing those fields is
        # established.
        #for param_name in ('InterruptMask', 'SUM', 'MXR', 'MPRV'):
        for param_name in ('InterruptMask', ):
            param_val = self.choice((0, 1, 'Same', 'Flip', 'Random', None))

            if param_val is not None:
                params[param_name] = param_val

        return params